mutation.go 1.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/batchmsg"
  14. "wechat-api/ent/category"
  15. "wechat-api/ent/chatrecords"
  16. "wechat-api/ent/chatsession"
  17. "wechat-api/ent/contact"
  18. "wechat-api/ent/creditbalance"
  19. "wechat-api/ent/creditusage"
  20. "wechat-api/ent/custom_types"
  21. "wechat-api/ent/employee"
  22. "wechat-api/ent/employeeconfig"
  23. "wechat-api/ent/label"
  24. "wechat-api/ent/labelrelationship"
  25. "wechat-api/ent/labeltagging"
  26. "wechat-api/ent/message"
  27. "wechat-api/ent/messagerecords"
  28. "wechat-api/ent/msg"
  29. "wechat-api/ent/payrecharge"
  30. "wechat-api/ent/predicate"
  31. "wechat-api/ent/server"
  32. "wechat-api/ent/sopnode"
  33. "wechat-api/ent/sopstage"
  34. "wechat-api/ent/soptask"
  35. "wechat-api/ent/token"
  36. "wechat-api/ent/tutorial"
  37. "wechat-api/ent/usagedetail"
  38. "wechat-api/ent/usagestatisticday"
  39. "wechat-api/ent/usagestatistichour"
  40. "wechat-api/ent/usagestatisticmonth"
  41. "wechat-api/ent/usagetotal"
  42. "wechat-api/ent/whatsapp"
  43. "wechat-api/ent/whatsappchannel"
  44. "wechat-api/ent/workexperience"
  45. "wechat-api/ent/wpchatroom"
  46. "wechat-api/ent/wpchatroommember"
  47. "wechat-api/ent/wx"
  48. "wechat-api/ent/wxcard"
  49. "wechat-api/ent/wxcarduser"
  50. "wechat-api/ent/wxcardvisit"
  51. "entgo.io/ent"
  52. "entgo.io/ent/dialect/sql"
  53. )
  54. const (
  55. // Operation types.
  56. OpCreate = ent.OpCreate
  57. OpDelete = ent.OpDelete
  58. OpDeleteOne = ent.OpDeleteOne
  59. OpUpdate = ent.OpUpdate
  60. OpUpdateOne = ent.OpUpdateOne
  61. // Node types.
  62. TypeAgent = "Agent"
  63. TypeAgentBase = "AgentBase"
  64. TypeAliyunAvatar = "AliyunAvatar"
  65. TypeAllocAgent = "AllocAgent"
  66. TypeBatchMsg = "BatchMsg"
  67. TypeCategory = "Category"
  68. TypeChatRecords = "ChatRecords"
  69. TypeChatSession = "ChatSession"
  70. TypeContact = "Contact"
  71. TypeCreditBalance = "CreditBalance"
  72. TypeCreditUsage = "CreditUsage"
  73. TypeEmployee = "Employee"
  74. TypeEmployeeConfig = "EmployeeConfig"
  75. TypeLabel = "Label"
  76. TypeLabelRelationship = "LabelRelationship"
  77. TypeLabelTagging = "LabelTagging"
  78. TypeMessage = "Message"
  79. TypeMessageRecords = "MessageRecords"
  80. TypeMsg = "Msg"
  81. TypePayRecharge = "PayRecharge"
  82. TypeServer = "Server"
  83. TypeSopNode = "SopNode"
  84. TypeSopStage = "SopStage"
  85. TypeSopTask = "SopTask"
  86. TypeToken = "Token"
  87. TypeTutorial = "Tutorial"
  88. TypeUsageDetail = "UsageDetail"
  89. TypeUsageStatisticDay = "UsageStatisticDay"
  90. TypeUsageStatisticHour = "UsageStatisticHour"
  91. TypeUsageStatisticMonth = "UsageStatisticMonth"
  92. TypeUsageTotal = "UsageTotal"
  93. TypeWhatsapp = "Whatsapp"
  94. TypeWhatsappChannel = "WhatsappChannel"
  95. TypeWorkExperience = "WorkExperience"
  96. TypeWpChatroom = "WpChatroom"
  97. TypeWpChatroomMember = "WpChatroomMember"
  98. TypeWx = "Wx"
  99. TypeWxCard = "WxCard"
  100. TypeWxCardUser = "WxCardUser"
  101. TypeWxCardVisit = "WxCardVisit"
  102. )
  103. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  104. type AgentMutation struct {
  105. config
  106. op Op
  107. typ string
  108. id *uint64
  109. created_at *time.Time
  110. updated_at *time.Time
  111. deleted_at *time.Time
  112. name *string
  113. role *string
  114. status *int
  115. addstatus *int
  116. background *string
  117. examples *string
  118. organization_id *uint64
  119. addorganization_id *int64
  120. dataset_id *string
  121. collection_id *string
  122. clearedFields map[string]struct{}
  123. wx_agent map[uint64]struct{}
  124. removedwx_agent map[uint64]struct{}
  125. clearedwx_agent bool
  126. token_agent map[uint64]struct{}
  127. removedtoken_agent map[uint64]struct{}
  128. clearedtoken_agent bool
  129. wa_agent map[uint64]struct{}
  130. removedwa_agent map[uint64]struct{}
  131. clearedwa_agent bool
  132. done bool
  133. oldValue func(context.Context) (*Agent, error)
  134. predicates []predicate.Agent
  135. }
  136. var _ ent.Mutation = (*AgentMutation)(nil)
  137. // agentOption allows management of the mutation configuration using functional options.
  138. type agentOption func(*AgentMutation)
  139. // newAgentMutation creates new mutation for the Agent entity.
  140. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  141. m := &AgentMutation{
  142. config: c,
  143. op: op,
  144. typ: TypeAgent,
  145. clearedFields: make(map[string]struct{}),
  146. }
  147. for _, opt := range opts {
  148. opt(m)
  149. }
  150. return m
  151. }
  152. // withAgentID sets the ID field of the mutation.
  153. func withAgentID(id uint64) agentOption {
  154. return func(m *AgentMutation) {
  155. var (
  156. err error
  157. once sync.Once
  158. value *Agent
  159. )
  160. m.oldValue = func(ctx context.Context) (*Agent, error) {
  161. once.Do(func() {
  162. if m.done {
  163. err = errors.New("querying old values post mutation is not allowed")
  164. } else {
  165. value, err = m.Client().Agent.Get(ctx, id)
  166. }
  167. })
  168. return value, err
  169. }
  170. m.id = &id
  171. }
  172. }
  173. // withAgent sets the old Agent of the mutation.
  174. func withAgent(node *Agent) agentOption {
  175. return func(m *AgentMutation) {
  176. m.oldValue = func(context.Context) (*Agent, error) {
  177. return node, nil
  178. }
  179. m.id = &node.ID
  180. }
  181. }
  182. // Client returns a new `ent.Client` from the mutation. If the mutation was
  183. // executed in a transaction (ent.Tx), a transactional client is returned.
  184. func (m AgentMutation) Client() *Client {
  185. client := &Client{config: m.config}
  186. client.init()
  187. return client
  188. }
  189. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  190. // it returns an error otherwise.
  191. func (m AgentMutation) Tx() (*Tx, error) {
  192. if _, ok := m.driver.(*txDriver); !ok {
  193. return nil, errors.New("ent: mutation is not running in a transaction")
  194. }
  195. tx := &Tx{config: m.config}
  196. tx.init()
  197. return tx, nil
  198. }
  199. // SetID sets the value of the id field. Note that this
  200. // operation is only accepted on creation of Agent entities.
  201. func (m *AgentMutation) SetID(id uint64) {
  202. m.id = &id
  203. }
  204. // ID returns the ID value in the mutation. Note that the ID is only available
  205. // if it was provided to the builder or after it was returned from the database.
  206. func (m *AgentMutation) ID() (id uint64, exists bool) {
  207. if m.id == nil {
  208. return
  209. }
  210. return *m.id, true
  211. }
  212. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  213. // That means, if the mutation is applied within a transaction with an isolation level such
  214. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  215. // or updated by the mutation.
  216. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  217. switch {
  218. case m.op.Is(OpUpdateOne | OpDeleteOne):
  219. id, exists := m.ID()
  220. if exists {
  221. return []uint64{id}, nil
  222. }
  223. fallthrough
  224. case m.op.Is(OpUpdate | OpDelete):
  225. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  226. default:
  227. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  228. }
  229. }
  230. // SetCreatedAt sets the "created_at" field.
  231. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  232. m.created_at = &t
  233. }
  234. // CreatedAt returns the value of the "created_at" field in the mutation.
  235. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  236. v := m.created_at
  237. if v == nil {
  238. return
  239. }
  240. return *v, true
  241. }
  242. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  243. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  245. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  246. if !m.op.Is(OpUpdateOne) {
  247. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  248. }
  249. if m.id == nil || m.oldValue == nil {
  250. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  251. }
  252. oldValue, err := m.oldValue(ctx)
  253. if err != nil {
  254. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  255. }
  256. return oldValue.CreatedAt, nil
  257. }
  258. // ResetCreatedAt resets all changes to the "created_at" field.
  259. func (m *AgentMutation) ResetCreatedAt() {
  260. m.created_at = nil
  261. }
  262. // SetUpdatedAt sets the "updated_at" field.
  263. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  264. m.updated_at = &t
  265. }
  266. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  267. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  268. v := m.updated_at
  269. if v == nil {
  270. return
  271. }
  272. return *v, true
  273. }
  274. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  275. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  277. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  278. if !m.op.Is(OpUpdateOne) {
  279. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  280. }
  281. if m.id == nil || m.oldValue == nil {
  282. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  283. }
  284. oldValue, err := m.oldValue(ctx)
  285. if err != nil {
  286. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  287. }
  288. return oldValue.UpdatedAt, nil
  289. }
  290. // ResetUpdatedAt resets all changes to the "updated_at" field.
  291. func (m *AgentMutation) ResetUpdatedAt() {
  292. m.updated_at = nil
  293. }
  294. // SetDeletedAt sets the "deleted_at" field.
  295. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  296. m.deleted_at = &t
  297. }
  298. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  299. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  300. v := m.deleted_at
  301. if v == nil {
  302. return
  303. }
  304. return *v, true
  305. }
  306. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  307. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  309. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  310. if !m.op.Is(OpUpdateOne) {
  311. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  312. }
  313. if m.id == nil || m.oldValue == nil {
  314. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  315. }
  316. oldValue, err := m.oldValue(ctx)
  317. if err != nil {
  318. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  319. }
  320. return oldValue.DeletedAt, nil
  321. }
  322. // ClearDeletedAt clears the value of the "deleted_at" field.
  323. func (m *AgentMutation) ClearDeletedAt() {
  324. m.deleted_at = nil
  325. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  326. }
  327. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  328. func (m *AgentMutation) DeletedAtCleared() bool {
  329. _, ok := m.clearedFields[agent.FieldDeletedAt]
  330. return ok
  331. }
  332. // ResetDeletedAt resets all changes to the "deleted_at" field.
  333. func (m *AgentMutation) ResetDeletedAt() {
  334. m.deleted_at = nil
  335. delete(m.clearedFields, agent.FieldDeletedAt)
  336. }
  337. // SetName sets the "name" field.
  338. func (m *AgentMutation) SetName(s string) {
  339. m.name = &s
  340. }
  341. // Name returns the value of the "name" field in the mutation.
  342. func (m *AgentMutation) Name() (r string, exists bool) {
  343. v := m.name
  344. if v == nil {
  345. return
  346. }
  347. return *v, true
  348. }
  349. // OldName returns the old "name" field's value of the Agent entity.
  350. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  352. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  353. if !m.op.Is(OpUpdateOne) {
  354. return v, errors.New("OldName is only allowed on UpdateOne operations")
  355. }
  356. if m.id == nil || m.oldValue == nil {
  357. return v, errors.New("OldName requires an ID field in the mutation")
  358. }
  359. oldValue, err := m.oldValue(ctx)
  360. if err != nil {
  361. return v, fmt.Errorf("querying old value for OldName: %w", err)
  362. }
  363. return oldValue.Name, nil
  364. }
  365. // ResetName resets all changes to the "name" field.
  366. func (m *AgentMutation) ResetName() {
  367. m.name = nil
  368. }
  369. // SetRole sets the "role" field.
  370. func (m *AgentMutation) SetRole(s string) {
  371. m.role = &s
  372. }
  373. // Role returns the value of the "role" field in the mutation.
  374. func (m *AgentMutation) Role() (r string, exists bool) {
  375. v := m.role
  376. if v == nil {
  377. return
  378. }
  379. return *v, true
  380. }
  381. // OldRole returns the old "role" field's value of the Agent entity.
  382. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  384. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  385. if !m.op.Is(OpUpdateOne) {
  386. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  387. }
  388. if m.id == nil || m.oldValue == nil {
  389. return v, errors.New("OldRole requires an ID field in the mutation")
  390. }
  391. oldValue, err := m.oldValue(ctx)
  392. if err != nil {
  393. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  394. }
  395. return oldValue.Role, nil
  396. }
  397. // ResetRole resets all changes to the "role" field.
  398. func (m *AgentMutation) ResetRole() {
  399. m.role = nil
  400. }
  401. // SetStatus sets the "status" field.
  402. func (m *AgentMutation) SetStatus(i int) {
  403. m.status = &i
  404. m.addstatus = nil
  405. }
  406. // Status returns the value of the "status" field in the mutation.
  407. func (m *AgentMutation) Status() (r int, exists bool) {
  408. v := m.status
  409. if v == nil {
  410. return
  411. }
  412. return *v, true
  413. }
  414. // OldStatus returns the old "status" field's value of the Agent entity.
  415. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  417. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  418. if !m.op.Is(OpUpdateOne) {
  419. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  420. }
  421. if m.id == nil || m.oldValue == nil {
  422. return v, errors.New("OldStatus requires an ID field in the mutation")
  423. }
  424. oldValue, err := m.oldValue(ctx)
  425. if err != nil {
  426. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  427. }
  428. return oldValue.Status, nil
  429. }
  430. // AddStatus adds i to the "status" field.
  431. func (m *AgentMutation) AddStatus(i int) {
  432. if m.addstatus != nil {
  433. *m.addstatus += i
  434. } else {
  435. m.addstatus = &i
  436. }
  437. }
  438. // AddedStatus returns the value that was added to the "status" field in this mutation.
  439. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  440. v := m.addstatus
  441. if v == nil {
  442. return
  443. }
  444. return *v, true
  445. }
  446. // ClearStatus clears the value of the "status" field.
  447. func (m *AgentMutation) ClearStatus() {
  448. m.status = nil
  449. m.addstatus = nil
  450. m.clearedFields[agent.FieldStatus] = struct{}{}
  451. }
  452. // StatusCleared returns if the "status" field was cleared in this mutation.
  453. func (m *AgentMutation) StatusCleared() bool {
  454. _, ok := m.clearedFields[agent.FieldStatus]
  455. return ok
  456. }
  457. // ResetStatus resets all changes to the "status" field.
  458. func (m *AgentMutation) ResetStatus() {
  459. m.status = nil
  460. m.addstatus = nil
  461. delete(m.clearedFields, agent.FieldStatus)
  462. }
  463. // SetBackground sets the "background" field.
  464. func (m *AgentMutation) SetBackground(s string) {
  465. m.background = &s
  466. }
  467. // Background returns the value of the "background" field in the mutation.
  468. func (m *AgentMutation) Background() (r string, exists bool) {
  469. v := m.background
  470. if v == nil {
  471. return
  472. }
  473. return *v, true
  474. }
  475. // OldBackground returns the old "background" field's value of the Agent entity.
  476. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  478. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  479. if !m.op.Is(OpUpdateOne) {
  480. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  481. }
  482. if m.id == nil || m.oldValue == nil {
  483. return v, errors.New("OldBackground requires an ID field in the mutation")
  484. }
  485. oldValue, err := m.oldValue(ctx)
  486. if err != nil {
  487. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  488. }
  489. return oldValue.Background, nil
  490. }
  491. // ClearBackground clears the value of the "background" field.
  492. func (m *AgentMutation) ClearBackground() {
  493. m.background = nil
  494. m.clearedFields[agent.FieldBackground] = struct{}{}
  495. }
  496. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  497. func (m *AgentMutation) BackgroundCleared() bool {
  498. _, ok := m.clearedFields[agent.FieldBackground]
  499. return ok
  500. }
  501. // ResetBackground resets all changes to the "background" field.
  502. func (m *AgentMutation) ResetBackground() {
  503. m.background = nil
  504. delete(m.clearedFields, agent.FieldBackground)
  505. }
  506. // SetExamples sets the "examples" field.
  507. func (m *AgentMutation) SetExamples(s string) {
  508. m.examples = &s
  509. }
  510. // Examples returns the value of the "examples" field in the mutation.
  511. func (m *AgentMutation) Examples() (r string, exists bool) {
  512. v := m.examples
  513. if v == nil {
  514. return
  515. }
  516. return *v, true
  517. }
  518. // OldExamples returns the old "examples" field's value of the Agent entity.
  519. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  521. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  522. if !m.op.Is(OpUpdateOne) {
  523. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  524. }
  525. if m.id == nil || m.oldValue == nil {
  526. return v, errors.New("OldExamples requires an ID field in the mutation")
  527. }
  528. oldValue, err := m.oldValue(ctx)
  529. if err != nil {
  530. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  531. }
  532. return oldValue.Examples, nil
  533. }
  534. // ClearExamples clears the value of the "examples" field.
  535. func (m *AgentMutation) ClearExamples() {
  536. m.examples = nil
  537. m.clearedFields[agent.FieldExamples] = struct{}{}
  538. }
  539. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  540. func (m *AgentMutation) ExamplesCleared() bool {
  541. _, ok := m.clearedFields[agent.FieldExamples]
  542. return ok
  543. }
  544. // ResetExamples resets all changes to the "examples" field.
  545. func (m *AgentMutation) ResetExamples() {
  546. m.examples = nil
  547. delete(m.clearedFields, agent.FieldExamples)
  548. }
  549. // SetOrganizationID sets the "organization_id" field.
  550. func (m *AgentMutation) SetOrganizationID(u uint64) {
  551. m.organization_id = &u
  552. m.addorganization_id = nil
  553. }
  554. // OrganizationID returns the value of the "organization_id" field in the mutation.
  555. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  556. v := m.organization_id
  557. if v == nil {
  558. return
  559. }
  560. return *v, true
  561. }
  562. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  563. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  565. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  566. if !m.op.Is(OpUpdateOne) {
  567. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  568. }
  569. if m.id == nil || m.oldValue == nil {
  570. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  571. }
  572. oldValue, err := m.oldValue(ctx)
  573. if err != nil {
  574. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  575. }
  576. return oldValue.OrganizationID, nil
  577. }
  578. // AddOrganizationID adds u to the "organization_id" field.
  579. func (m *AgentMutation) AddOrganizationID(u int64) {
  580. if m.addorganization_id != nil {
  581. *m.addorganization_id += u
  582. } else {
  583. m.addorganization_id = &u
  584. }
  585. }
  586. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  587. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  588. v := m.addorganization_id
  589. if v == nil {
  590. return
  591. }
  592. return *v, true
  593. }
  594. // ResetOrganizationID resets all changes to the "organization_id" field.
  595. func (m *AgentMutation) ResetOrganizationID() {
  596. m.organization_id = nil
  597. m.addorganization_id = nil
  598. }
  599. // SetDatasetID sets the "dataset_id" field.
  600. func (m *AgentMutation) SetDatasetID(s string) {
  601. m.dataset_id = &s
  602. }
  603. // DatasetID returns the value of the "dataset_id" field in the mutation.
  604. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  605. v := m.dataset_id
  606. if v == nil {
  607. return
  608. }
  609. return *v, true
  610. }
  611. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  612. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  614. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  615. if !m.op.Is(OpUpdateOne) {
  616. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  617. }
  618. if m.id == nil || m.oldValue == nil {
  619. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  620. }
  621. oldValue, err := m.oldValue(ctx)
  622. if err != nil {
  623. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  624. }
  625. return oldValue.DatasetID, nil
  626. }
  627. // ResetDatasetID resets all changes to the "dataset_id" field.
  628. func (m *AgentMutation) ResetDatasetID() {
  629. m.dataset_id = nil
  630. }
  631. // SetCollectionID sets the "collection_id" field.
  632. func (m *AgentMutation) SetCollectionID(s string) {
  633. m.collection_id = &s
  634. }
  635. // CollectionID returns the value of the "collection_id" field in the mutation.
  636. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  637. v := m.collection_id
  638. if v == nil {
  639. return
  640. }
  641. return *v, true
  642. }
  643. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  644. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  646. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  647. if !m.op.Is(OpUpdateOne) {
  648. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  649. }
  650. if m.id == nil || m.oldValue == nil {
  651. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  652. }
  653. oldValue, err := m.oldValue(ctx)
  654. if err != nil {
  655. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  656. }
  657. return oldValue.CollectionID, nil
  658. }
  659. // ResetCollectionID resets all changes to the "collection_id" field.
  660. func (m *AgentMutation) ResetCollectionID() {
  661. m.collection_id = nil
  662. }
  663. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  664. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  665. if m.wx_agent == nil {
  666. m.wx_agent = make(map[uint64]struct{})
  667. }
  668. for i := range ids {
  669. m.wx_agent[ids[i]] = struct{}{}
  670. }
  671. }
  672. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  673. func (m *AgentMutation) ClearWxAgent() {
  674. m.clearedwx_agent = true
  675. }
  676. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  677. func (m *AgentMutation) WxAgentCleared() bool {
  678. return m.clearedwx_agent
  679. }
  680. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  681. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  682. if m.removedwx_agent == nil {
  683. m.removedwx_agent = make(map[uint64]struct{})
  684. }
  685. for i := range ids {
  686. delete(m.wx_agent, ids[i])
  687. m.removedwx_agent[ids[i]] = struct{}{}
  688. }
  689. }
  690. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  691. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  692. for id := range m.removedwx_agent {
  693. ids = append(ids, id)
  694. }
  695. return
  696. }
  697. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  698. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  699. for id := range m.wx_agent {
  700. ids = append(ids, id)
  701. }
  702. return
  703. }
  704. // ResetWxAgent resets all changes to the "wx_agent" edge.
  705. func (m *AgentMutation) ResetWxAgent() {
  706. m.wx_agent = nil
  707. m.clearedwx_agent = false
  708. m.removedwx_agent = nil
  709. }
  710. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  711. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  712. if m.token_agent == nil {
  713. m.token_agent = make(map[uint64]struct{})
  714. }
  715. for i := range ids {
  716. m.token_agent[ids[i]] = struct{}{}
  717. }
  718. }
  719. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  720. func (m *AgentMutation) ClearTokenAgent() {
  721. m.clearedtoken_agent = true
  722. }
  723. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  724. func (m *AgentMutation) TokenAgentCleared() bool {
  725. return m.clearedtoken_agent
  726. }
  727. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  728. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  729. if m.removedtoken_agent == nil {
  730. m.removedtoken_agent = make(map[uint64]struct{})
  731. }
  732. for i := range ids {
  733. delete(m.token_agent, ids[i])
  734. m.removedtoken_agent[ids[i]] = struct{}{}
  735. }
  736. }
  737. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  738. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  739. for id := range m.removedtoken_agent {
  740. ids = append(ids, id)
  741. }
  742. return
  743. }
  744. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  745. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  746. for id := range m.token_agent {
  747. ids = append(ids, id)
  748. }
  749. return
  750. }
  751. // ResetTokenAgent resets all changes to the "token_agent" edge.
  752. func (m *AgentMutation) ResetTokenAgent() {
  753. m.token_agent = nil
  754. m.clearedtoken_agent = false
  755. m.removedtoken_agent = nil
  756. }
  757. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  758. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  759. if m.wa_agent == nil {
  760. m.wa_agent = make(map[uint64]struct{})
  761. }
  762. for i := range ids {
  763. m.wa_agent[ids[i]] = struct{}{}
  764. }
  765. }
  766. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  767. func (m *AgentMutation) ClearWaAgent() {
  768. m.clearedwa_agent = true
  769. }
  770. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  771. func (m *AgentMutation) WaAgentCleared() bool {
  772. return m.clearedwa_agent
  773. }
  774. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  775. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  776. if m.removedwa_agent == nil {
  777. m.removedwa_agent = make(map[uint64]struct{})
  778. }
  779. for i := range ids {
  780. delete(m.wa_agent, ids[i])
  781. m.removedwa_agent[ids[i]] = struct{}{}
  782. }
  783. }
  784. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  785. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  786. for id := range m.removedwa_agent {
  787. ids = append(ids, id)
  788. }
  789. return
  790. }
  791. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  792. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  793. for id := range m.wa_agent {
  794. ids = append(ids, id)
  795. }
  796. return
  797. }
  798. // ResetWaAgent resets all changes to the "wa_agent" edge.
  799. func (m *AgentMutation) ResetWaAgent() {
  800. m.wa_agent = nil
  801. m.clearedwa_agent = false
  802. m.removedwa_agent = nil
  803. }
  804. // Where appends a list predicates to the AgentMutation builder.
  805. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  806. m.predicates = append(m.predicates, ps...)
  807. }
  808. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  809. // users can use type-assertion to append predicates that do not depend on any generated package.
  810. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  811. p := make([]predicate.Agent, len(ps))
  812. for i := range ps {
  813. p[i] = ps[i]
  814. }
  815. m.Where(p...)
  816. }
  817. // Op returns the operation name.
  818. func (m *AgentMutation) Op() Op {
  819. return m.op
  820. }
  821. // SetOp allows setting the mutation operation.
  822. func (m *AgentMutation) SetOp(op Op) {
  823. m.op = op
  824. }
  825. // Type returns the node type of this mutation (Agent).
  826. func (m *AgentMutation) Type() string {
  827. return m.typ
  828. }
  829. // Fields returns all fields that were changed during this mutation. Note that in
  830. // order to get all numeric fields that were incremented/decremented, call
  831. // AddedFields().
  832. func (m *AgentMutation) Fields() []string {
  833. fields := make([]string, 0, 11)
  834. if m.created_at != nil {
  835. fields = append(fields, agent.FieldCreatedAt)
  836. }
  837. if m.updated_at != nil {
  838. fields = append(fields, agent.FieldUpdatedAt)
  839. }
  840. if m.deleted_at != nil {
  841. fields = append(fields, agent.FieldDeletedAt)
  842. }
  843. if m.name != nil {
  844. fields = append(fields, agent.FieldName)
  845. }
  846. if m.role != nil {
  847. fields = append(fields, agent.FieldRole)
  848. }
  849. if m.status != nil {
  850. fields = append(fields, agent.FieldStatus)
  851. }
  852. if m.background != nil {
  853. fields = append(fields, agent.FieldBackground)
  854. }
  855. if m.examples != nil {
  856. fields = append(fields, agent.FieldExamples)
  857. }
  858. if m.organization_id != nil {
  859. fields = append(fields, agent.FieldOrganizationID)
  860. }
  861. if m.dataset_id != nil {
  862. fields = append(fields, agent.FieldDatasetID)
  863. }
  864. if m.collection_id != nil {
  865. fields = append(fields, agent.FieldCollectionID)
  866. }
  867. return fields
  868. }
  869. // Field returns the value of a field with the given name. The second boolean
  870. // return value indicates that this field was not set, or was not defined in the
  871. // schema.
  872. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  873. switch name {
  874. case agent.FieldCreatedAt:
  875. return m.CreatedAt()
  876. case agent.FieldUpdatedAt:
  877. return m.UpdatedAt()
  878. case agent.FieldDeletedAt:
  879. return m.DeletedAt()
  880. case agent.FieldName:
  881. return m.Name()
  882. case agent.FieldRole:
  883. return m.Role()
  884. case agent.FieldStatus:
  885. return m.Status()
  886. case agent.FieldBackground:
  887. return m.Background()
  888. case agent.FieldExamples:
  889. return m.Examples()
  890. case agent.FieldOrganizationID:
  891. return m.OrganizationID()
  892. case agent.FieldDatasetID:
  893. return m.DatasetID()
  894. case agent.FieldCollectionID:
  895. return m.CollectionID()
  896. }
  897. return nil, false
  898. }
  899. // OldField returns the old value of the field from the database. An error is
  900. // returned if the mutation operation is not UpdateOne, or the query to the
  901. // database failed.
  902. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  903. switch name {
  904. case agent.FieldCreatedAt:
  905. return m.OldCreatedAt(ctx)
  906. case agent.FieldUpdatedAt:
  907. return m.OldUpdatedAt(ctx)
  908. case agent.FieldDeletedAt:
  909. return m.OldDeletedAt(ctx)
  910. case agent.FieldName:
  911. return m.OldName(ctx)
  912. case agent.FieldRole:
  913. return m.OldRole(ctx)
  914. case agent.FieldStatus:
  915. return m.OldStatus(ctx)
  916. case agent.FieldBackground:
  917. return m.OldBackground(ctx)
  918. case agent.FieldExamples:
  919. return m.OldExamples(ctx)
  920. case agent.FieldOrganizationID:
  921. return m.OldOrganizationID(ctx)
  922. case agent.FieldDatasetID:
  923. return m.OldDatasetID(ctx)
  924. case agent.FieldCollectionID:
  925. return m.OldCollectionID(ctx)
  926. }
  927. return nil, fmt.Errorf("unknown Agent field %s", name)
  928. }
  929. // SetField sets the value of a field with the given name. It returns an error if
  930. // the field is not defined in the schema, or if the type mismatched the field
  931. // type.
  932. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  933. switch name {
  934. case agent.FieldCreatedAt:
  935. v, ok := value.(time.Time)
  936. if !ok {
  937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  938. }
  939. m.SetCreatedAt(v)
  940. return nil
  941. case agent.FieldUpdatedAt:
  942. v, ok := value.(time.Time)
  943. if !ok {
  944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  945. }
  946. m.SetUpdatedAt(v)
  947. return nil
  948. case agent.FieldDeletedAt:
  949. v, ok := value.(time.Time)
  950. if !ok {
  951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  952. }
  953. m.SetDeletedAt(v)
  954. return nil
  955. case agent.FieldName:
  956. v, ok := value.(string)
  957. if !ok {
  958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  959. }
  960. m.SetName(v)
  961. return nil
  962. case agent.FieldRole:
  963. v, ok := value.(string)
  964. if !ok {
  965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  966. }
  967. m.SetRole(v)
  968. return nil
  969. case agent.FieldStatus:
  970. v, ok := value.(int)
  971. if !ok {
  972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  973. }
  974. m.SetStatus(v)
  975. return nil
  976. case agent.FieldBackground:
  977. v, ok := value.(string)
  978. if !ok {
  979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  980. }
  981. m.SetBackground(v)
  982. return nil
  983. case agent.FieldExamples:
  984. v, ok := value.(string)
  985. if !ok {
  986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  987. }
  988. m.SetExamples(v)
  989. return nil
  990. case agent.FieldOrganizationID:
  991. v, ok := value.(uint64)
  992. if !ok {
  993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  994. }
  995. m.SetOrganizationID(v)
  996. return nil
  997. case agent.FieldDatasetID:
  998. v, ok := value.(string)
  999. if !ok {
  1000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1001. }
  1002. m.SetDatasetID(v)
  1003. return nil
  1004. case agent.FieldCollectionID:
  1005. v, ok := value.(string)
  1006. if !ok {
  1007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1008. }
  1009. m.SetCollectionID(v)
  1010. return nil
  1011. }
  1012. return fmt.Errorf("unknown Agent field %s", name)
  1013. }
  1014. // AddedFields returns all numeric fields that were incremented/decremented during
  1015. // this mutation.
  1016. func (m *AgentMutation) AddedFields() []string {
  1017. var fields []string
  1018. if m.addstatus != nil {
  1019. fields = append(fields, agent.FieldStatus)
  1020. }
  1021. if m.addorganization_id != nil {
  1022. fields = append(fields, agent.FieldOrganizationID)
  1023. }
  1024. return fields
  1025. }
  1026. // AddedField returns the numeric value that was incremented/decremented on a field
  1027. // with the given name. The second boolean return value indicates that this field
  1028. // was not set, or was not defined in the schema.
  1029. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1030. switch name {
  1031. case agent.FieldStatus:
  1032. return m.AddedStatus()
  1033. case agent.FieldOrganizationID:
  1034. return m.AddedOrganizationID()
  1035. }
  1036. return nil, false
  1037. }
  1038. // AddField adds the value to the field with the given name. It returns an error if
  1039. // the field is not defined in the schema, or if the type mismatched the field
  1040. // type.
  1041. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1042. switch name {
  1043. case agent.FieldStatus:
  1044. v, ok := value.(int)
  1045. if !ok {
  1046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1047. }
  1048. m.AddStatus(v)
  1049. return nil
  1050. case agent.FieldOrganizationID:
  1051. v, ok := value.(int64)
  1052. if !ok {
  1053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1054. }
  1055. m.AddOrganizationID(v)
  1056. return nil
  1057. }
  1058. return fmt.Errorf("unknown Agent numeric field %s", name)
  1059. }
  1060. // ClearedFields returns all nullable fields that were cleared during this
  1061. // mutation.
  1062. func (m *AgentMutation) ClearedFields() []string {
  1063. var fields []string
  1064. if m.FieldCleared(agent.FieldDeletedAt) {
  1065. fields = append(fields, agent.FieldDeletedAt)
  1066. }
  1067. if m.FieldCleared(agent.FieldStatus) {
  1068. fields = append(fields, agent.FieldStatus)
  1069. }
  1070. if m.FieldCleared(agent.FieldBackground) {
  1071. fields = append(fields, agent.FieldBackground)
  1072. }
  1073. if m.FieldCleared(agent.FieldExamples) {
  1074. fields = append(fields, agent.FieldExamples)
  1075. }
  1076. return fields
  1077. }
  1078. // FieldCleared returns a boolean indicating if a field with the given name was
  1079. // cleared in this mutation.
  1080. func (m *AgentMutation) FieldCleared(name string) bool {
  1081. _, ok := m.clearedFields[name]
  1082. return ok
  1083. }
  1084. // ClearField clears the value of the field with the given name. It returns an
  1085. // error if the field is not defined in the schema.
  1086. func (m *AgentMutation) ClearField(name string) error {
  1087. switch name {
  1088. case agent.FieldDeletedAt:
  1089. m.ClearDeletedAt()
  1090. return nil
  1091. case agent.FieldStatus:
  1092. m.ClearStatus()
  1093. return nil
  1094. case agent.FieldBackground:
  1095. m.ClearBackground()
  1096. return nil
  1097. case agent.FieldExamples:
  1098. m.ClearExamples()
  1099. return nil
  1100. }
  1101. return fmt.Errorf("unknown Agent nullable field %s", name)
  1102. }
  1103. // ResetField resets all changes in the mutation for the field with the given name.
  1104. // It returns an error if the field is not defined in the schema.
  1105. func (m *AgentMutation) ResetField(name string) error {
  1106. switch name {
  1107. case agent.FieldCreatedAt:
  1108. m.ResetCreatedAt()
  1109. return nil
  1110. case agent.FieldUpdatedAt:
  1111. m.ResetUpdatedAt()
  1112. return nil
  1113. case agent.FieldDeletedAt:
  1114. m.ResetDeletedAt()
  1115. return nil
  1116. case agent.FieldName:
  1117. m.ResetName()
  1118. return nil
  1119. case agent.FieldRole:
  1120. m.ResetRole()
  1121. return nil
  1122. case agent.FieldStatus:
  1123. m.ResetStatus()
  1124. return nil
  1125. case agent.FieldBackground:
  1126. m.ResetBackground()
  1127. return nil
  1128. case agent.FieldExamples:
  1129. m.ResetExamples()
  1130. return nil
  1131. case agent.FieldOrganizationID:
  1132. m.ResetOrganizationID()
  1133. return nil
  1134. case agent.FieldDatasetID:
  1135. m.ResetDatasetID()
  1136. return nil
  1137. case agent.FieldCollectionID:
  1138. m.ResetCollectionID()
  1139. return nil
  1140. }
  1141. return fmt.Errorf("unknown Agent field %s", name)
  1142. }
  1143. // AddedEdges returns all edge names that were set/added in this mutation.
  1144. func (m *AgentMutation) AddedEdges() []string {
  1145. edges := make([]string, 0, 3)
  1146. if m.wx_agent != nil {
  1147. edges = append(edges, agent.EdgeWxAgent)
  1148. }
  1149. if m.token_agent != nil {
  1150. edges = append(edges, agent.EdgeTokenAgent)
  1151. }
  1152. if m.wa_agent != nil {
  1153. edges = append(edges, agent.EdgeWaAgent)
  1154. }
  1155. return edges
  1156. }
  1157. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1158. // name in this mutation.
  1159. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1160. switch name {
  1161. case agent.EdgeWxAgent:
  1162. ids := make([]ent.Value, 0, len(m.wx_agent))
  1163. for id := range m.wx_agent {
  1164. ids = append(ids, id)
  1165. }
  1166. return ids
  1167. case agent.EdgeTokenAgent:
  1168. ids := make([]ent.Value, 0, len(m.token_agent))
  1169. for id := range m.token_agent {
  1170. ids = append(ids, id)
  1171. }
  1172. return ids
  1173. case agent.EdgeWaAgent:
  1174. ids := make([]ent.Value, 0, len(m.wa_agent))
  1175. for id := range m.wa_agent {
  1176. ids = append(ids, id)
  1177. }
  1178. return ids
  1179. }
  1180. return nil
  1181. }
  1182. // RemovedEdges returns all edge names that were removed in this mutation.
  1183. func (m *AgentMutation) RemovedEdges() []string {
  1184. edges := make([]string, 0, 3)
  1185. if m.removedwx_agent != nil {
  1186. edges = append(edges, agent.EdgeWxAgent)
  1187. }
  1188. if m.removedtoken_agent != nil {
  1189. edges = append(edges, agent.EdgeTokenAgent)
  1190. }
  1191. if m.removedwa_agent != nil {
  1192. edges = append(edges, agent.EdgeWaAgent)
  1193. }
  1194. return edges
  1195. }
  1196. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1197. // the given name in this mutation.
  1198. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1199. switch name {
  1200. case agent.EdgeWxAgent:
  1201. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1202. for id := range m.removedwx_agent {
  1203. ids = append(ids, id)
  1204. }
  1205. return ids
  1206. case agent.EdgeTokenAgent:
  1207. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1208. for id := range m.removedtoken_agent {
  1209. ids = append(ids, id)
  1210. }
  1211. return ids
  1212. case agent.EdgeWaAgent:
  1213. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1214. for id := range m.removedwa_agent {
  1215. ids = append(ids, id)
  1216. }
  1217. return ids
  1218. }
  1219. return nil
  1220. }
  1221. // ClearedEdges returns all edge names that were cleared in this mutation.
  1222. func (m *AgentMutation) ClearedEdges() []string {
  1223. edges := make([]string, 0, 3)
  1224. if m.clearedwx_agent {
  1225. edges = append(edges, agent.EdgeWxAgent)
  1226. }
  1227. if m.clearedtoken_agent {
  1228. edges = append(edges, agent.EdgeTokenAgent)
  1229. }
  1230. if m.clearedwa_agent {
  1231. edges = append(edges, agent.EdgeWaAgent)
  1232. }
  1233. return edges
  1234. }
  1235. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1236. // was cleared in this mutation.
  1237. func (m *AgentMutation) EdgeCleared(name string) bool {
  1238. switch name {
  1239. case agent.EdgeWxAgent:
  1240. return m.clearedwx_agent
  1241. case agent.EdgeTokenAgent:
  1242. return m.clearedtoken_agent
  1243. case agent.EdgeWaAgent:
  1244. return m.clearedwa_agent
  1245. }
  1246. return false
  1247. }
  1248. // ClearEdge clears the value of the edge with the given name. It returns an error
  1249. // if that edge is not defined in the schema.
  1250. func (m *AgentMutation) ClearEdge(name string) error {
  1251. switch name {
  1252. }
  1253. return fmt.Errorf("unknown Agent unique edge %s", name)
  1254. }
  1255. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1256. // It returns an error if the edge is not defined in the schema.
  1257. func (m *AgentMutation) ResetEdge(name string) error {
  1258. switch name {
  1259. case agent.EdgeWxAgent:
  1260. m.ResetWxAgent()
  1261. return nil
  1262. case agent.EdgeTokenAgent:
  1263. m.ResetTokenAgent()
  1264. return nil
  1265. case agent.EdgeWaAgent:
  1266. m.ResetWaAgent()
  1267. return nil
  1268. }
  1269. return fmt.Errorf("unknown Agent edge %s", name)
  1270. }
  1271. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1272. type AgentBaseMutation struct {
  1273. config
  1274. op Op
  1275. typ string
  1276. id *string
  1277. q *string
  1278. a *string
  1279. chunk_index *uint64
  1280. addchunk_index *int64
  1281. indexes *[]string
  1282. appendindexes []string
  1283. dataset_id *string
  1284. collection_id *string
  1285. source_name *string
  1286. can_write *[]bool
  1287. appendcan_write []bool
  1288. is_owner *[]bool
  1289. appendis_owner []bool
  1290. clearedFields map[string]struct{}
  1291. wx_agent map[uint64]struct{}
  1292. removedwx_agent map[uint64]struct{}
  1293. clearedwx_agent bool
  1294. done bool
  1295. oldValue func(context.Context) (*AgentBase, error)
  1296. predicates []predicate.AgentBase
  1297. }
  1298. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1299. // agentbaseOption allows management of the mutation configuration using functional options.
  1300. type agentbaseOption func(*AgentBaseMutation)
  1301. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1302. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1303. m := &AgentBaseMutation{
  1304. config: c,
  1305. op: op,
  1306. typ: TypeAgentBase,
  1307. clearedFields: make(map[string]struct{}),
  1308. }
  1309. for _, opt := range opts {
  1310. opt(m)
  1311. }
  1312. return m
  1313. }
  1314. // withAgentBaseID sets the ID field of the mutation.
  1315. func withAgentBaseID(id string) agentbaseOption {
  1316. return func(m *AgentBaseMutation) {
  1317. var (
  1318. err error
  1319. once sync.Once
  1320. value *AgentBase
  1321. )
  1322. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1323. once.Do(func() {
  1324. if m.done {
  1325. err = errors.New("querying old values post mutation is not allowed")
  1326. } else {
  1327. value, err = m.Client().AgentBase.Get(ctx, id)
  1328. }
  1329. })
  1330. return value, err
  1331. }
  1332. m.id = &id
  1333. }
  1334. }
  1335. // withAgentBase sets the old AgentBase of the mutation.
  1336. func withAgentBase(node *AgentBase) agentbaseOption {
  1337. return func(m *AgentBaseMutation) {
  1338. m.oldValue = func(context.Context) (*AgentBase, error) {
  1339. return node, nil
  1340. }
  1341. m.id = &node.ID
  1342. }
  1343. }
  1344. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1345. // executed in a transaction (ent.Tx), a transactional client is returned.
  1346. func (m AgentBaseMutation) Client() *Client {
  1347. client := &Client{config: m.config}
  1348. client.init()
  1349. return client
  1350. }
  1351. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1352. // it returns an error otherwise.
  1353. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1354. if _, ok := m.driver.(*txDriver); !ok {
  1355. return nil, errors.New("ent: mutation is not running in a transaction")
  1356. }
  1357. tx := &Tx{config: m.config}
  1358. tx.init()
  1359. return tx, nil
  1360. }
  1361. // SetID sets the value of the id field. Note that this
  1362. // operation is only accepted on creation of AgentBase entities.
  1363. func (m *AgentBaseMutation) SetID(id string) {
  1364. m.id = &id
  1365. }
  1366. // ID returns the ID value in the mutation. Note that the ID is only available
  1367. // if it was provided to the builder or after it was returned from the database.
  1368. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1369. if m.id == nil {
  1370. return
  1371. }
  1372. return *m.id, true
  1373. }
  1374. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1375. // That means, if the mutation is applied within a transaction with an isolation level such
  1376. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1377. // or updated by the mutation.
  1378. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1379. switch {
  1380. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1381. id, exists := m.ID()
  1382. if exists {
  1383. return []string{id}, nil
  1384. }
  1385. fallthrough
  1386. case m.op.Is(OpUpdate | OpDelete):
  1387. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1388. default:
  1389. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1390. }
  1391. }
  1392. // SetQ sets the "q" field.
  1393. func (m *AgentBaseMutation) SetQ(s string) {
  1394. m.q = &s
  1395. }
  1396. // Q returns the value of the "q" field in the mutation.
  1397. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1398. v := m.q
  1399. if v == nil {
  1400. return
  1401. }
  1402. return *v, true
  1403. }
  1404. // OldQ returns the old "q" field's value of the AgentBase entity.
  1405. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1407. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1408. if !m.op.Is(OpUpdateOne) {
  1409. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1410. }
  1411. if m.id == nil || m.oldValue == nil {
  1412. return v, errors.New("OldQ requires an ID field in the mutation")
  1413. }
  1414. oldValue, err := m.oldValue(ctx)
  1415. if err != nil {
  1416. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1417. }
  1418. return oldValue.Q, nil
  1419. }
  1420. // ClearQ clears the value of the "q" field.
  1421. func (m *AgentBaseMutation) ClearQ() {
  1422. m.q = nil
  1423. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1424. }
  1425. // QCleared returns if the "q" field was cleared in this mutation.
  1426. func (m *AgentBaseMutation) QCleared() bool {
  1427. _, ok := m.clearedFields[agentbase.FieldQ]
  1428. return ok
  1429. }
  1430. // ResetQ resets all changes to the "q" field.
  1431. func (m *AgentBaseMutation) ResetQ() {
  1432. m.q = nil
  1433. delete(m.clearedFields, agentbase.FieldQ)
  1434. }
  1435. // SetA sets the "a" field.
  1436. func (m *AgentBaseMutation) SetA(s string) {
  1437. m.a = &s
  1438. }
  1439. // A returns the value of the "a" field in the mutation.
  1440. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1441. v := m.a
  1442. if v == nil {
  1443. return
  1444. }
  1445. return *v, true
  1446. }
  1447. // OldA returns the old "a" field's value of the AgentBase entity.
  1448. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1450. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1451. if !m.op.Is(OpUpdateOne) {
  1452. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1453. }
  1454. if m.id == nil || m.oldValue == nil {
  1455. return v, errors.New("OldA requires an ID field in the mutation")
  1456. }
  1457. oldValue, err := m.oldValue(ctx)
  1458. if err != nil {
  1459. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1460. }
  1461. return oldValue.A, nil
  1462. }
  1463. // ClearA clears the value of the "a" field.
  1464. func (m *AgentBaseMutation) ClearA() {
  1465. m.a = nil
  1466. m.clearedFields[agentbase.FieldA] = struct{}{}
  1467. }
  1468. // ACleared returns if the "a" field was cleared in this mutation.
  1469. func (m *AgentBaseMutation) ACleared() bool {
  1470. _, ok := m.clearedFields[agentbase.FieldA]
  1471. return ok
  1472. }
  1473. // ResetA resets all changes to the "a" field.
  1474. func (m *AgentBaseMutation) ResetA() {
  1475. m.a = nil
  1476. delete(m.clearedFields, agentbase.FieldA)
  1477. }
  1478. // SetChunkIndex sets the "chunk_index" field.
  1479. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1480. m.chunk_index = &u
  1481. m.addchunk_index = nil
  1482. }
  1483. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1484. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1485. v := m.chunk_index
  1486. if v == nil {
  1487. return
  1488. }
  1489. return *v, true
  1490. }
  1491. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1492. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1494. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1495. if !m.op.Is(OpUpdateOne) {
  1496. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1497. }
  1498. if m.id == nil || m.oldValue == nil {
  1499. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1500. }
  1501. oldValue, err := m.oldValue(ctx)
  1502. if err != nil {
  1503. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1504. }
  1505. return oldValue.ChunkIndex, nil
  1506. }
  1507. // AddChunkIndex adds u to the "chunk_index" field.
  1508. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1509. if m.addchunk_index != nil {
  1510. *m.addchunk_index += u
  1511. } else {
  1512. m.addchunk_index = &u
  1513. }
  1514. }
  1515. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1516. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1517. v := m.addchunk_index
  1518. if v == nil {
  1519. return
  1520. }
  1521. return *v, true
  1522. }
  1523. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1524. func (m *AgentBaseMutation) ResetChunkIndex() {
  1525. m.chunk_index = nil
  1526. m.addchunk_index = nil
  1527. }
  1528. // SetIndexes sets the "indexes" field.
  1529. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1530. m.indexes = &s
  1531. m.appendindexes = nil
  1532. }
  1533. // Indexes returns the value of the "indexes" field in the mutation.
  1534. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1535. v := m.indexes
  1536. if v == nil {
  1537. return
  1538. }
  1539. return *v, true
  1540. }
  1541. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1542. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1544. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1545. if !m.op.Is(OpUpdateOne) {
  1546. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1547. }
  1548. if m.id == nil || m.oldValue == nil {
  1549. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1550. }
  1551. oldValue, err := m.oldValue(ctx)
  1552. if err != nil {
  1553. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1554. }
  1555. return oldValue.Indexes, nil
  1556. }
  1557. // AppendIndexes adds s to the "indexes" field.
  1558. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1559. m.appendindexes = append(m.appendindexes, s...)
  1560. }
  1561. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1562. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1563. if len(m.appendindexes) == 0 {
  1564. return nil, false
  1565. }
  1566. return m.appendindexes, true
  1567. }
  1568. // ClearIndexes clears the value of the "indexes" field.
  1569. func (m *AgentBaseMutation) ClearIndexes() {
  1570. m.indexes = nil
  1571. m.appendindexes = nil
  1572. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1573. }
  1574. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1575. func (m *AgentBaseMutation) IndexesCleared() bool {
  1576. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1577. return ok
  1578. }
  1579. // ResetIndexes resets all changes to the "indexes" field.
  1580. func (m *AgentBaseMutation) ResetIndexes() {
  1581. m.indexes = nil
  1582. m.appendindexes = nil
  1583. delete(m.clearedFields, agentbase.FieldIndexes)
  1584. }
  1585. // SetDatasetID sets the "dataset_id" field.
  1586. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1587. m.dataset_id = &s
  1588. }
  1589. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1590. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1591. v := m.dataset_id
  1592. if v == nil {
  1593. return
  1594. }
  1595. return *v, true
  1596. }
  1597. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1598. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1600. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1601. if !m.op.Is(OpUpdateOne) {
  1602. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1603. }
  1604. if m.id == nil || m.oldValue == nil {
  1605. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1606. }
  1607. oldValue, err := m.oldValue(ctx)
  1608. if err != nil {
  1609. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1610. }
  1611. return oldValue.DatasetID, nil
  1612. }
  1613. // ClearDatasetID clears the value of the "dataset_id" field.
  1614. func (m *AgentBaseMutation) ClearDatasetID() {
  1615. m.dataset_id = nil
  1616. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1617. }
  1618. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1619. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1620. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1621. return ok
  1622. }
  1623. // ResetDatasetID resets all changes to the "dataset_id" field.
  1624. func (m *AgentBaseMutation) ResetDatasetID() {
  1625. m.dataset_id = nil
  1626. delete(m.clearedFields, agentbase.FieldDatasetID)
  1627. }
  1628. // SetCollectionID sets the "collection_id" field.
  1629. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1630. m.collection_id = &s
  1631. }
  1632. // CollectionID returns the value of the "collection_id" field in the mutation.
  1633. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1634. v := m.collection_id
  1635. if v == nil {
  1636. return
  1637. }
  1638. return *v, true
  1639. }
  1640. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1641. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1643. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1644. if !m.op.Is(OpUpdateOne) {
  1645. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1646. }
  1647. if m.id == nil || m.oldValue == nil {
  1648. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1649. }
  1650. oldValue, err := m.oldValue(ctx)
  1651. if err != nil {
  1652. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1653. }
  1654. return oldValue.CollectionID, nil
  1655. }
  1656. // ClearCollectionID clears the value of the "collection_id" field.
  1657. func (m *AgentBaseMutation) ClearCollectionID() {
  1658. m.collection_id = nil
  1659. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1660. }
  1661. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1662. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1663. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1664. return ok
  1665. }
  1666. // ResetCollectionID resets all changes to the "collection_id" field.
  1667. func (m *AgentBaseMutation) ResetCollectionID() {
  1668. m.collection_id = nil
  1669. delete(m.clearedFields, agentbase.FieldCollectionID)
  1670. }
  1671. // SetSourceName sets the "source_name" field.
  1672. func (m *AgentBaseMutation) SetSourceName(s string) {
  1673. m.source_name = &s
  1674. }
  1675. // SourceName returns the value of the "source_name" field in the mutation.
  1676. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1677. v := m.source_name
  1678. if v == nil {
  1679. return
  1680. }
  1681. return *v, true
  1682. }
  1683. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1684. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1686. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1687. if !m.op.Is(OpUpdateOne) {
  1688. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1689. }
  1690. if m.id == nil || m.oldValue == nil {
  1691. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1692. }
  1693. oldValue, err := m.oldValue(ctx)
  1694. if err != nil {
  1695. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1696. }
  1697. return oldValue.SourceName, nil
  1698. }
  1699. // ClearSourceName clears the value of the "source_name" field.
  1700. func (m *AgentBaseMutation) ClearSourceName() {
  1701. m.source_name = nil
  1702. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1703. }
  1704. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1705. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1706. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1707. return ok
  1708. }
  1709. // ResetSourceName resets all changes to the "source_name" field.
  1710. func (m *AgentBaseMutation) ResetSourceName() {
  1711. m.source_name = nil
  1712. delete(m.clearedFields, agentbase.FieldSourceName)
  1713. }
  1714. // SetCanWrite sets the "can_write" field.
  1715. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1716. m.can_write = &b
  1717. m.appendcan_write = nil
  1718. }
  1719. // CanWrite returns the value of the "can_write" field in the mutation.
  1720. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1721. v := m.can_write
  1722. if v == nil {
  1723. return
  1724. }
  1725. return *v, true
  1726. }
  1727. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1728. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1730. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1731. if !m.op.Is(OpUpdateOne) {
  1732. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1733. }
  1734. if m.id == nil || m.oldValue == nil {
  1735. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1736. }
  1737. oldValue, err := m.oldValue(ctx)
  1738. if err != nil {
  1739. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1740. }
  1741. return oldValue.CanWrite, nil
  1742. }
  1743. // AppendCanWrite adds b to the "can_write" field.
  1744. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1745. m.appendcan_write = append(m.appendcan_write, b...)
  1746. }
  1747. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1748. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1749. if len(m.appendcan_write) == 0 {
  1750. return nil, false
  1751. }
  1752. return m.appendcan_write, true
  1753. }
  1754. // ClearCanWrite clears the value of the "can_write" field.
  1755. func (m *AgentBaseMutation) ClearCanWrite() {
  1756. m.can_write = nil
  1757. m.appendcan_write = nil
  1758. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1759. }
  1760. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1761. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1762. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1763. return ok
  1764. }
  1765. // ResetCanWrite resets all changes to the "can_write" field.
  1766. func (m *AgentBaseMutation) ResetCanWrite() {
  1767. m.can_write = nil
  1768. m.appendcan_write = nil
  1769. delete(m.clearedFields, agentbase.FieldCanWrite)
  1770. }
  1771. // SetIsOwner sets the "is_owner" field.
  1772. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1773. m.is_owner = &b
  1774. m.appendis_owner = nil
  1775. }
  1776. // IsOwner returns the value of the "is_owner" field in the mutation.
  1777. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1778. v := m.is_owner
  1779. if v == nil {
  1780. return
  1781. }
  1782. return *v, true
  1783. }
  1784. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1785. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1787. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1788. if !m.op.Is(OpUpdateOne) {
  1789. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1790. }
  1791. if m.id == nil || m.oldValue == nil {
  1792. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1793. }
  1794. oldValue, err := m.oldValue(ctx)
  1795. if err != nil {
  1796. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1797. }
  1798. return oldValue.IsOwner, nil
  1799. }
  1800. // AppendIsOwner adds b to the "is_owner" field.
  1801. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1802. m.appendis_owner = append(m.appendis_owner, b...)
  1803. }
  1804. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1805. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1806. if len(m.appendis_owner) == 0 {
  1807. return nil, false
  1808. }
  1809. return m.appendis_owner, true
  1810. }
  1811. // ClearIsOwner clears the value of the "is_owner" field.
  1812. func (m *AgentBaseMutation) ClearIsOwner() {
  1813. m.is_owner = nil
  1814. m.appendis_owner = nil
  1815. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1816. }
  1817. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1818. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1819. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1820. return ok
  1821. }
  1822. // ResetIsOwner resets all changes to the "is_owner" field.
  1823. func (m *AgentBaseMutation) ResetIsOwner() {
  1824. m.is_owner = nil
  1825. m.appendis_owner = nil
  1826. delete(m.clearedFields, agentbase.FieldIsOwner)
  1827. }
  1828. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1829. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1830. if m.wx_agent == nil {
  1831. m.wx_agent = make(map[uint64]struct{})
  1832. }
  1833. for i := range ids {
  1834. m.wx_agent[ids[i]] = struct{}{}
  1835. }
  1836. }
  1837. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1838. func (m *AgentBaseMutation) ClearWxAgent() {
  1839. m.clearedwx_agent = true
  1840. }
  1841. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1842. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1843. return m.clearedwx_agent
  1844. }
  1845. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1846. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1847. if m.removedwx_agent == nil {
  1848. m.removedwx_agent = make(map[uint64]struct{})
  1849. }
  1850. for i := range ids {
  1851. delete(m.wx_agent, ids[i])
  1852. m.removedwx_agent[ids[i]] = struct{}{}
  1853. }
  1854. }
  1855. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1856. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1857. for id := range m.removedwx_agent {
  1858. ids = append(ids, id)
  1859. }
  1860. return
  1861. }
  1862. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1863. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1864. for id := range m.wx_agent {
  1865. ids = append(ids, id)
  1866. }
  1867. return
  1868. }
  1869. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1870. func (m *AgentBaseMutation) ResetWxAgent() {
  1871. m.wx_agent = nil
  1872. m.clearedwx_agent = false
  1873. m.removedwx_agent = nil
  1874. }
  1875. // Where appends a list predicates to the AgentBaseMutation builder.
  1876. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1877. m.predicates = append(m.predicates, ps...)
  1878. }
  1879. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1880. // users can use type-assertion to append predicates that do not depend on any generated package.
  1881. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1882. p := make([]predicate.AgentBase, len(ps))
  1883. for i := range ps {
  1884. p[i] = ps[i]
  1885. }
  1886. m.Where(p...)
  1887. }
  1888. // Op returns the operation name.
  1889. func (m *AgentBaseMutation) Op() Op {
  1890. return m.op
  1891. }
  1892. // SetOp allows setting the mutation operation.
  1893. func (m *AgentBaseMutation) SetOp(op Op) {
  1894. m.op = op
  1895. }
  1896. // Type returns the node type of this mutation (AgentBase).
  1897. func (m *AgentBaseMutation) Type() string {
  1898. return m.typ
  1899. }
  1900. // Fields returns all fields that were changed during this mutation. Note that in
  1901. // order to get all numeric fields that were incremented/decremented, call
  1902. // AddedFields().
  1903. func (m *AgentBaseMutation) Fields() []string {
  1904. fields := make([]string, 0, 9)
  1905. if m.q != nil {
  1906. fields = append(fields, agentbase.FieldQ)
  1907. }
  1908. if m.a != nil {
  1909. fields = append(fields, agentbase.FieldA)
  1910. }
  1911. if m.chunk_index != nil {
  1912. fields = append(fields, agentbase.FieldChunkIndex)
  1913. }
  1914. if m.indexes != nil {
  1915. fields = append(fields, agentbase.FieldIndexes)
  1916. }
  1917. if m.dataset_id != nil {
  1918. fields = append(fields, agentbase.FieldDatasetID)
  1919. }
  1920. if m.collection_id != nil {
  1921. fields = append(fields, agentbase.FieldCollectionID)
  1922. }
  1923. if m.source_name != nil {
  1924. fields = append(fields, agentbase.FieldSourceName)
  1925. }
  1926. if m.can_write != nil {
  1927. fields = append(fields, agentbase.FieldCanWrite)
  1928. }
  1929. if m.is_owner != nil {
  1930. fields = append(fields, agentbase.FieldIsOwner)
  1931. }
  1932. return fields
  1933. }
  1934. // Field returns the value of a field with the given name. The second boolean
  1935. // return value indicates that this field was not set, or was not defined in the
  1936. // schema.
  1937. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1938. switch name {
  1939. case agentbase.FieldQ:
  1940. return m.Q()
  1941. case agentbase.FieldA:
  1942. return m.A()
  1943. case agentbase.FieldChunkIndex:
  1944. return m.ChunkIndex()
  1945. case agentbase.FieldIndexes:
  1946. return m.Indexes()
  1947. case agentbase.FieldDatasetID:
  1948. return m.DatasetID()
  1949. case agentbase.FieldCollectionID:
  1950. return m.CollectionID()
  1951. case agentbase.FieldSourceName:
  1952. return m.SourceName()
  1953. case agentbase.FieldCanWrite:
  1954. return m.CanWrite()
  1955. case agentbase.FieldIsOwner:
  1956. return m.IsOwner()
  1957. }
  1958. return nil, false
  1959. }
  1960. // OldField returns the old value of the field from the database. An error is
  1961. // returned if the mutation operation is not UpdateOne, or the query to the
  1962. // database failed.
  1963. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1964. switch name {
  1965. case agentbase.FieldQ:
  1966. return m.OldQ(ctx)
  1967. case agentbase.FieldA:
  1968. return m.OldA(ctx)
  1969. case agentbase.FieldChunkIndex:
  1970. return m.OldChunkIndex(ctx)
  1971. case agentbase.FieldIndexes:
  1972. return m.OldIndexes(ctx)
  1973. case agentbase.FieldDatasetID:
  1974. return m.OldDatasetID(ctx)
  1975. case agentbase.FieldCollectionID:
  1976. return m.OldCollectionID(ctx)
  1977. case agentbase.FieldSourceName:
  1978. return m.OldSourceName(ctx)
  1979. case agentbase.FieldCanWrite:
  1980. return m.OldCanWrite(ctx)
  1981. case agentbase.FieldIsOwner:
  1982. return m.OldIsOwner(ctx)
  1983. }
  1984. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1985. }
  1986. // SetField sets the value of a field with the given name. It returns an error if
  1987. // the field is not defined in the schema, or if the type mismatched the field
  1988. // type.
  1989. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1990. switch name {
  1991. case agentbase.FieldQ:
  1992. v, ok := value.(string)
  1993. if !ok {
  1994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1995. }
  1996. m.SetQ(v)
  1997. return nil
  1998. case agentbase.FieldA:
  1999. v, ok := value.(string)
  2000. if !ok {
  2001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2002. }
  2003. m.SetA(v)
  2004. return nil
  2005. case agentbase.FieldChunkIndex:
  2006. v, ok := value.(uint64)
  2007. if !ok {
  2008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2009. }
  2010. m.SetChunkIndex(v)
  2011. return nil
  2012. case agentbase.FieldIndexes:
  2013. v, ok := value.([]string)
  2014. if !ok {
  2015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2016. }
  2017. m.SetIndexes(v)
  2018. return nil
  2019. case agentbase.FieldDatasetID:
  2020. v, ok := value.(string)
  2021. if !ok {
  2022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2023. }
  2024. m.SetDatasetID(v)
  2025. return nil
  2026. case agentbase.FieldCollectionID:
  2027. v, ok := value.(string)
  2028. if !ok {
  2029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2030. }
  2031. m.SetCollectionID(v)
  2032. return nil
  2033. case agentbase.FieldSourceName:
  2034. v, ok := value.(string)
  2035. if !ok {
  2036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2037. }
  2038. m.SetSourceName(v)
  2039. return nil
  2040. case agentbase.FieldCanWrite:
  2041. v, ok := value.([]bool)
  2042. if !ok {
  2043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2044. }
  2045. m.SetCanWrite(v)
  2046. return nil
  2047. case agentbase.FieldIsOwner:
  2048. v, ok := value.([]bool)
  2049. if !ok {
  2050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2051. }
  2052. m.SetIsOwner(v)
  2053. return nil
  2054. }
  2055. return fmt.Errorf("unknown AgentBase field %s", name)
  2056. }
  2057. // AddedFields returns all numeric fields that were incremented/decremented during
  2058. // this mutation.
  2059. func (m *AgentBaseMutation) AddedFields() []string {
  2060. var fields []string
  2061. if m.addchunk_index != nil {
  2062. fields = append(fields, agentbase.FieldChunkIndex)
  2063. }
  2064. return fields
  2065. }
  2066. // AddedField returns the numeric value that was incremented/decremented on a field
  2067. // with the given name. The second boolean return value indicates that this field
  2068. // was not set, or was not defined in the schema.
  2069. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2070. switch name {
  2071. case agentbase.FieldChunkIndex:
  2072. return m.AddedChunkIndex()
  2073. }
  2074. return nil, false
  2075. }
  2076. // AddField adds the value to the field with the given name. It returns an error if
  2077. // the field is not defined in the schema, or if the type mismatched the field
  2078. // type.
  2079. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2080. switch name {
  2081. case agentbase.FieldChunkIndex:
  2082. v, ok := value.(int64)
  2083. if !ok {
  2084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2085. }
  2086. m.AddChunkIndex(v)
  2087. return nil
  2088. }
  2089. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2090. }
  2091. // ClearedFields returns all nullable fields that were cleared during this
  2092. // mutation.
  2093. func (m *AgentBaseMutation) ClearedFields() []string {
  2094. var fields []string
  2095. if m.FieldCleared(agentbase.FieldQ) {
  2096. fields = append(fields, agentbase.FieldQ)
  2097. }
  2098. if m.FieldCleared(agentbase.FieldA) {
  2099. fields = append(fields, agentbase.FieldA)
  2100. }
  2101. if m.FieldCleared(agentbase.FieldIndexes) {
  2102. fields = append(fields, agentbase.FieldIndexes)
  2103. }
  2104. if m.FieldCleared(agentbase.FieldDatasetID) {
  2105. fields = append(fields, agentbase.FieldDatasetID)
  2106. }
  2107. if m.FieldCleared(agentbase.FieldCollectionID) {
  2108. fields = append(fields, agentbase.FieldCollectionID)
  2109. }
  2110. if m.FieldCleared(agentbase.FieldSourceName) {
  2111. fields = append(fields, agentbase.FieldSourceName)
  2112. }
  2113. if m.FieldCleared(agentbase.FieldCanWrite) {
  2114. fields = append(fields, agentbase.FieldCanWrite)
  2115. }
  2116. if m.FieldCleared(agentbase.FieldIsOwner) {
  2117. fields = append(fields, agentbase.FieldIsOwner)
  2118. }
  2119. return fields
  2120. }
  2121. // FieldCleared returns a boolean indicating if a field with the given name was
  2122. // cleared in this mutation.
  2123. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2124. _, ok := m.clearedFields[name]
  2125. return ok
  2126. }
  2127. // ClearField clears the value of the field with the given name. It returns an
  2128. // error if the field is not defined in the schema.
  2129. func (m *AgentBaseMutation) ClearField(name string) error {
  2130. switch name {
  2131. case agentbase.FieldQ:
  2132. m.ClearQ()
  2133. return nil
  2134. case agentbase.FieldA:
  2135. m.ClearA()
  2136. return nil
  2137. case agentbase.FieldIndexes:
  2138. m.ClearIndexes()
  2139. return nil
  2140. case agentbase.FieldDatasetID:
  2141. m.ClearDatasetID()
  2142. return nil
  2143. case agentbase.FieldCollectionID:
  2144. m.ClearCollectionID()
  2145. return nil
  2146. case agentbase.FieldSourceName:
  2147. m.ClearSourceName()
  2148. return nil
  2149. case agentbase.FieldCanWrite:
  2150. m.ClearCanWrite()
  2151. return nil
  2152. case agentbase.FieldIsOwner:
  2153. m.ClearIsOwner()
  2154. return nil
  2155. }
  2156. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2157. }
  2158. // ResetField resets all changes in the mutation for the field with the given name.
  2159. // It returns an error if the field is not defined in the schema.
  2160. func (m *AgentBaseMutation) ResetField(name string) error {
  2161. switch name {
  2162. case agentbase.FieldQ:
  2163. m.ResetQ()
  2164. return nil
  2165. case agentbase.FieldA:
  2166. m.ResetA()
  2167. return nil
  2168. case agentbase.FieldChunkIndex:
  2169. m.ResetChunkIndex()
  2170. return nil
  2171. case agentbase.FieldIndexes:
  2172. m.ResetIndexes()
  2173. return nil
  2174. case agentbase.FieldDatasetID:
  2175. m.ResetDatasetID()
  2176. return nil
  2177. case agentbase.FieldCollectionID:
  2178. m.ResetCollectionID()
  2179. return nil
  2180. case agentbase.FieldSourceName:
  2181. m.ResetSourceName()
  2182. return nil
  2183. case agentbase.FieldCanWrite:
  2184. m.ResetCanWrite()
  2185. return nil
  2186. case agentbase.FieldIsOwner:
  2187. m.ResetIsOwner()
  2188. return nil
  2189. }
  2190. return fmt.Errorf("unknown AgentBase field %s", name)
  2191. }
  2192. // AddedEdges returns all edge names that were set/added in this mutation.
  2193. func (m *AgentBaseMutation) AddedEdges() []string {
  2194. edges := make([]string, 0, 1)
  2195. if m.wx_agent != nil {
  2196. edges = append(edges, agentbase.EdgeWxAgent)
  2197. }
  2198. return edges
  2199. }
  2200. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2201. // name in this mutation.
  2202. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2203. switch name {
  2204. case agentbase.EdgeWxAgent:
  2205. ids := make([]ent.Value, 0, len(m.wx_agent))
  2206. for id := range m.wx_agent {
  2207. ids = append(ids, id)
  2208. }
  2209. return ids
  2210. }
  2211. return nil
  2212. }
  2213. // RemovedEdges returns all edge names that were removed in this mutation.
  2214. func (m *AgentBaseMutation) RemovedEdges() []string {
  2215. edges := make([]string, 0, 1)
  2216. if m.removedwx_agent != nil {
  2217. edges = append(edges, agentbase.EdgeWxAgent)
  2218. }
  2219. return edges
  2220. }
  2221. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2222. // the given name in this mutation.
  2223. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2224. switch name {
  2225. case agentbase.EdgeWxAgent:
  2226. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2227. for id := range m.removedwx_agent {
  2228. ids = append(ids, id)
  2229. }
  2230. return ids
  2231. }
  2232. return nil
  2233. }
  2234. // ClearedEdges returns all edge names that were cleared in this mutation.
  2235. func (m *AgentBaseMutation) ClearedEdges() []string {
  2236. edges := make([]string, 0, 1)
  2237. if m.clearedwx_agent {
  2238. edges = append(edges, agentbase.EdgeWxAgent)
  2239. }
  2240. return edges
  2241. }
  2242. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2243. // was cleared in this mutation.
  2244. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2245. switch name {
  2246. case agentbase.EdgeWxAgent:
  2247. return m.clearedwx_agent
  2248. }
  2249. return false
  2250. }
  2251. // ClearEdge clears the value of the edge with the given name. It returns an error
  2252. // if that edge is not defined in the schema.
  2253. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2254. switch name {
  2255. }
  2256. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2257. }
  2258. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2259. // It returns an error if the edge is not defined in the schema.
  2260. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2261. switch name {
  2262. case agentbase.EdgeWxAgent:
  2263. m.ResetWxAgent()
  2264. return nil
  2265. }
  2266. return fmt.Errorf("unknown AgentBase edge %s", name)
  2267. }
  2268. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2269. type AliyunAvatarMutation struct {
  2270. config
  2271. op Op
  2272. typ string
  2273. id *uint64
  2274. created_at *time.Time
  2275. updated_at *time.Time
  2276. deleted_at *time.Time
  2277. user_id *uint64
  2278. adduser_id *int64
  2279. biz_id *string
  2280. access_key_id *string
  2281. access_key_secret *string
  2282. app_id *string
  2283. tenant_id *uint64
  2284. addtenant_id *int64
  2285. response *string
  2286. token *string
  2287. session_id *string
  2288. clearedFields map[string]struct{}
  2289. done bool
  2290. oldValue func(context.Context) (*AliyunAvatar, error)
  2291. predicates []predicate.AliyunAvatar
  2292. }
  2293. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2294. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2295. type aliyunavatarOption func(*AliyunAvatarMutation)
  2296. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2297. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2298. m := &AliyunAvatarMutation{
  2299. config: c,
  2300. op: op,
  2301. typ: TypeAliyunAvatar,
  2302. clearedFields: make(map[string]struct{}),
  2303. }
  2304. for _, opt := range opts {
  2305. opt(m)
  2306. }
  2307. return m
  2308. }
  2309. // withAliyunAvatarID sets the ID field of the mutation.
  2310. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2311. return func(m *AliyunAvatarMutation) {
  2312. var (
  2313. err error
  2314. once sync.Once
  2315. value *AliyunAvatar
  2316. )
  2317. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2318. once.Do(func() {
  2319. if m.done {
  2320. err = errors.New("querying old values post mutation is not allowed")
  2321. } else {
  2322. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2323. }
  2324. })
  2325. return value, err
  2326. }
  2327. m.id = &id
  2328. }
  2329. }
  2330. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2331. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2332. return func(m *AliyunAvatarMutation) {
  2333. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2334. return node, nil
  2335. }
  2336. m.id = &node.ID
  2337. }
  2338. }
  2339. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2340. // executed in a transaction (ent.Tx), a transactional client is returned.
  2341. func (m AliyunAvatarMutation) Client() *Client {
  2342. client := &Client{config: m.config}
  2343. client.init()
  2344. return client
  2345. }
  2346. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2347. // it returns an error otherwise.
  2348. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2349. if _, ok := m.driver.(*txDriver); !ok {
  2350. return nil, errors.New("ent: mutation is not running in a transaction")
  2351. }
  2352. tx := &Tx{config: m.config}
  2353. tx.init()
  2354. return tx, nil
  2355. }
  2356. // SetID sets the value of the id field. Note that this
  2357. // operation is only accepted on creation of AliyunAvatar entities.
  2358. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2359. m.id = &id
  2360. }
  2361. // ID returns the ID value in the mutation. Note that the ID is only available
  2362. // if it was provided to the builder or after it was returned from the database.
  2363. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2364. if m.id == nil {
  2365. return
  2366. }
  2367. return *m.id, true
  2368. }
  2369. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2370. // That means, if the mutation is applied within a transaction with an isolation level such
  2371. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2372. // or updated by the mutation.
  2373. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2374. switch {
  2375. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2376. id, exists := m.ID()
  2377. if exists {
  2378. return []uint64{id}, nil
  2379. }
  2380. fallthrough
  2381. case m.op.Is(OpUpdate | OpDelete):
  2382. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2383. default:
  2384. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2385. }
  2386. }
  2387. // SetCreatedAt sets the "created_at" field.
  2388. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2389. m.created_at = &t
  2390. }
  2391. // CreatedAt returns the value of the "created_at" field in the mutation.
  2392. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2393. v := m.created_at
  2394. if v == nil {
  2395. return
  2396. }
  2397. return *v, true
  2398. }
  2399. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2400. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2402. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2403. if !m.op.Is(OpUpdateOne) {
  2404. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2405. }
  2406. if m.id == nil || m.oldValue == nil {
  2407. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2408. }
  2409. oldValue, err := m.oldValue(ctx)
  2410. if err != nil {
  2411. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2412. }
  2413. return oldValue.CreatedAt, nil
  2414. }
  2415. // ResetCreatedAt resets all changes to the "created_at" field.
  2416. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2417. m.created_at = nil
  2418. }
  2419. // SetUpdatedAt sets the "updated_at" field.
  2420. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2421. m.updated_at = &t
  2422. }
  2423. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2424. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2425. v := m.updated_at
  2426. if v == nil {
  2427. return
  2428. }
  2429. return *v, true
  2430. }
  2431. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2432. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2434. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2435. if !m.op.Is(OpUpdateOne) {
  2436. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2437. }
  2438. if m.id == nil || m.oldValue == nil {
  2439. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2440. }
  2441. oldValue, err := m.oldValue(ctx)
  2442. if err != nil {
  2443. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2444. }
  2445. return oldValue.UpdatedAt, nil
  2446. }
  2447. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2448. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2449. m.updated_at = nil
  2450. }
  2451. // SetDeletedAt sets the "deleted_at" field.
  2452. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2453. m.deleted_at = &t
  2454. }
  2455. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2456. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2457. v := m.deleted_at
  2458. if v == nil {
  2459. return
  2460. }
  2461. return *v, true
  2462. }
  2463. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2464. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2466. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2467. if !m.op.Is(OpUpdateOne) {
  2468. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2469. }
  2470. if m.id == nil || m.oldValue == nil {
  2471. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2472. }
  2473. oldValue, err := m.oldValue(ctx)
  2474. if err != nil {
  2475. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2476. }
  2477. return oldValue.DeletedAt, nil
  2478. }
  2479. // ClearDeletedAt clears the value of the "deleted_at" field.
  2480. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2481. m.deleted_at = nil
  2482. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2483. }
  2484. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2485. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2486. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2487. return ok
  2488. }
  2489. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2490. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2491. m.deleted_at = nil
  2492. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2493. }
  2494. // SetUserID sets the "user_id" field.
  2495. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2496. m.user_id = &u
  2497. m.adduser_id = nil
  2498. }
  2499. // UserID returns the value of the "user_id" field in the mutation.
  2500. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2501. v := m.user_id
  2502. if v == nil {
  2503. return
  2504. }
  2505. return *v, true
  2506. }
  2507. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2508. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2510. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2511. if !m.op.Is(OpUpdateOne) {
  2512. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2513. }
  2514. if m.id == nil || m.oldValue == nil {
  2515. return v, errors.New("OldUserID requires an ID field in the mutation")
  2516. }
  2517. oldValue, err := m.oldValue(ctx)
  2518. if err != nil {
  2519. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2520. }
  2521. return oldValue.UserID, nil
  2522. }
  2523. // AddUserID adds u to the "user_id" field.
  2524. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2525. if m.adduser_id != nil {
  2526. *m.adduser_id += u
  2527. } else {
  2528. m.adduser_id = &u
  2529. }
  2530. }
  2531. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2532. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2533. v := m.adduser_id
  2534. if v == nil {
  2535. return
  2536. }
  2537. return *v, true
  2538. }
  2539. // ResetUserID resets all changes to the "user_id" field.
  2540. func (m *AliyunAvatarMutation) ResetUserID() {
  2541. m.user_id = nil
  2542. m.adduser_id = nil
  2543. }
  2544. // SetBizID sets the "biz_id" field.
  2545. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2546. m.biz_id = &s
  2547. }
  2548. // BizID returns the value of the "biz_id" field in the mutation.
  2549. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2550. v := m.biz_id
  2551. if v == nil {
  2552. return
  2553. }
  2554. return *v, true
  2555. }
  2556. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2557. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2559. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2560. if !m.op.Is(OpUpdateOne) {
  2561. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2562. }
  2563. if m.id == nil || m.oldValue == nil {
  2564. return v, errors.New("OldBizID requires an ID field in the mutation")
  2565. }
  2566. oldValue, err := m.oldValue(ctx)
  2567. if err != nil {
  2568. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2569. }
  2570. return oldValue.BizID, nil
  2571. }
  2572. // ResetBizID resets all changes to the "biz_id" field.
  2573. func (m *AliyunAvatarMutation) ResetBizID() {
  2574. m.biz_id = nil
  2575. }
  2576. // SetAccessKeyID sets the "access_key_id" field.
  2577. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2578. m.access_key_id = &s
  2579. }
  2580. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2581. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2582. v := m.access_key_id
  2583. if v == nil {
  2584. return
  2585. }
  2586. return *v, true
  2587. }
  2588. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2589. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2591. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2592. if !m.op.Is(OpUpdateOne) {
  2593. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2594. }
  2595. if m.id == nil || m.oldValue == nil {
  2596. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2597. }
  2598. oldValue, err := m.oldValue(ctx)
  2599. if err != nil {
  2600. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2601. }
  2602. return oldValue.AccessKeyID, nil
  2603. }
  2604. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2605. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2606. m.access_key_id = nil
  2607. }
  2608. // SetAccessKeySecret sets the "access_key_secret" field.
  2609. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2610. m.access_key_secret = &s
  2611. }
  2612. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2613. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2614. v := m.access_key_secret
  2615. if v == nil {
  2616. return
  2617. }
  2618. return *v, true
  2619. }
  2620. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2621. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2623. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2624. if !m.op.Is(OpUpdateOne) {
  2625. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2626. }
  2627. if m.id == nil || m.oldValue == nil {
  2628. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2629. }
  2630. oldValue, err := m.oldValue(ctx)
  2631. if err != nil {
  2632. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2633. }
  2634. return oldValue.AccessKeySecret, nil
  2635. }
  2636. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2637. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2638. m.access_key_secret = nil
  2639. }
  2640. // SetAppID sets the "app_id" field.
  2641. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2642. m.app_id = &s
  2643. }
  2644. // AppID returns the value of the "app_id" field in the mutation.
  2645. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2646. v := m.app_id
  2647. if v == nil {
  2648. return
  2649. }
  2650. return *v, true
  2651. }
  2652. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2653. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2655. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2656. if !m.op.Is(OpUpdateOne) {
  2657. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2658. }
  2659. if m.id == nil || m.oldValue == nil {
  2660. return v, errors.New("OldAppID requires an ID field in the mutation")
  2661. }
  2662. oldValue, err := m.oldValue(ctx)
  2663. if err != nil {
  2664. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2665. }
  2666. return oldValue.AppID, nil
  2667. }
  2668. // ClearAppID clears the value of the "app_id" field.
  2669. func (m *AliyunAvatarMutation) ClearAppID() {
  2670. m.app_id = nil
  2671. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2672. }
  2673. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2674. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2675. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2676. return ok
  2677. }
  2678. // ResetAppID resets all changes to the "app_id" field.
  2679. func (m *AliyunAvatarMutation) ResetAppID() {
  2680. m.app_id = nil
  2681. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2682. }
  2683. // SetTenantID sets the "tenant_id" field.
  2684. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2685. m.tenant_id = &u
  2686. m.addtenant_id = nil
  2687. }
  2688. // TenantID returns the value of the "tenant_id" field in the mutation.
  2689. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2690. v := m.tenant_id
  2691. if v == nil {
  2692. return
  2693. }
  2694. return *v, true
  2695. }
  2696. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2697. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2699. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2700. if !m.op.Is(OpUpdateOne) {
  2701. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2702. }
  2703. if m.id == nil || m.oldValue == nil {
  2704. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2705. }
  2706. oldValue, err := m.oldValue(ctx)
  2707. if err != nil {
  2708. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2709. }
  2710. return oldValue.TenantID, nil
  2711. }
  2712. // AddTenantID adds u to the "tenant_id" field.
  2713. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2714. if m.addtenant_id != nil {
  2715. *m.addtenant_id += u
  2716. } else {
  2717. m.addtenant_id = &u
  2718. }
  2719. }
  2720. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2721. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2722. v := m.addtenant_id
  2723. if v == nil {
  2724. return
  2725. }
  2726. return *v, true
  2727. }
  2728. // ResetTenantID resets all changes to the "tenant_id" field.
  2729. func (m *AliyunAvatarMutation) ResetTenantID() {
  2730. m.tenant_id = nil
  2731. m.addtenant_id = nil
  2732. }
  2733. // SetResponse sets the "response" field.
  2734. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2735. m.response = &s
  2736. }
  2737. // Response returns the value of the "response" field in the mutation.
  2738. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2739. v := m.response
  2740. if v == nil {
  2741. return
  2742. }
  2743. return *v, true
  2744. }
  2745. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2746. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2748. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2749. if !m.op.Is(OpUpdateOne) {
  2750. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2751. }
  2752. if m.id == nil || m.oldValue == nil {
  2753. return v, errors.New("OldResponse requires an ID field in the mutation")
  2754. }
  2755. oldValue, err := m.oldValue(ctx)
  2756. if err != nil {
  2757. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2758. }
  2759. return oldValue.Response, nil
  2760. }
  2761. // ResetResponse resets all changes to the "response" field.
  2762. func (m *AliyunAvatarMutation) ResetResponse() {
  2763. m.response = nil
  2764. }
  2765. // SetToken sets the "token" field.
  2766. func (m *AliyunAvatarMutation) SetToken(s string) {
  2767. m.token = &s
  2768. }
  2769. // Token returns the value of the "token" field in the mutation.
  2770. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2771. v := m.token
  2772. if v == nil {
  2773. return
  2774. }
  2775. return *v, true
  2776. }
  2777. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2778. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2780. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2781. if !m.op.Is(OpUpdateOne) {
  2782. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2783. }
  2784. if m.id == nil || m.oldValue == nil {
  2785. return v, errors.New("OldToken requires an ID field in the mutation")
  2786. }
  2787. oldValue, err := m.oldValue(ctx)
  2788. if err != nil {
  2789. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2790. }
  2791. return oldValue.Token, nil
  2792. }
  2793. // ResetToken resets all changes to the "token" field.
  2794. func (m *AliyunAvatarMutation) ResetToken() {
  2795. m.token = nil
  2796. }
  2797. // SetSessionID sets the "session_id" field.
  2798. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2799. m.session_id = &s
  2800. }
  2801. // SessionID returns the value of the "session_id" field in the mutation.
  2802. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2803. v := m.session_id
  2804. if v == nil {
  2805. return
  2806. }
  2807. return *v, true
  2808. }
  2809. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2810. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2812. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2813. if !m.op.Is(OpUpdateOne) {
  2814. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2815. }
  2816. if m.id == nil || m.oldValue == nil {
  2817. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2818. }
  2819. oldValue, err := m.oldValue(ctx)
  2820. if err != nil {
  2821. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2822. }
  2823. return oldValue.SessionID, nil
  2824. }
  2825. // ResetSessionID resets all changes to the "session_id" field.
  2826. func (m *AliyunAvatarMutation) ResetSessionID() {
  2827. m.session_id = nil
  2828. }
  2829. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2830. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2831. m.predicates = append(m.predicates, ps...)
  2832. }
  2833. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2834. // users can use type-assertion to append predicates that do not depend on any generated package.
  2835. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2836. p := make([]predicate.AliyunAvatar, len(ps))
  2837. for i := range ps {
  2838. p[i] = ps[i]
  2839. }
  2840. m.Where(p...)
  2841. }
  2842. // Op returns the operation name.
  2843. func (m *AliyunAvatarMutation) Op() Op {
  2844. return m.op
  2845. }
  2846. // SetOp allows setting the mutation operation.
  2847. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2848. m.op = op
  2849. }
  2850. // Type returns the node type of this mutation (AliyunAvatar).
  2851. func (m *AliyunAvatarMutation) Type() string {
  2852. return m.typ
  2853. }
  2854. // Fields returns all fields that were changed during this mutation. Note that in
  2855. // order to get all numeric fields that were incremented/decremented, call
  2856. // AddedFields().
  2857. func (m *AliyunAvatarMutation) Fields() []string {
  2858. fields := make([]string, 0, 12)
  2859. if m.created_at != nil {
  2860. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2861. }
  2862. if m.updated_at != nil {
  2863. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2864. }
  2865. if m.deleted_at != nil {
  2866. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2867. }
  2868. if m.user_id != nil {
  2869. fields = append(fields, aliyunavatar.FieldUserID)
  2870. }
  2871. if m.biz_id != nil {
  2872. fields = append(fields, aliyunavatar.FieldBizID)
  2873. }
  2874. if m.access_key_id != nil {
  2875. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2876. }
  2877. if m.access_key_secret != nil {
  2878. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2879. }
  2880. if m.app_id != nil {
  2881. fields = append(fields, aliyunavatar.FieldAppID)
  2882. }
  2883. if m.tenant_id != nil {
  2884. fields = append(fields, aliyunavatar.FieldTenantID)
  2885. }
  2886. if m.response != nil {
  2887. fields = append(fields, aliyunavatar.FieldResponse)
  2888. }
  2889. if m.token != nil {
  2890. fields = append(fields, aliyunavatar.FieldToken)
  2891. }
  2892. if m.session_id != nil {
  2893. fields = append(fields, aliyunavatar.FieldSessionID)
  2894. }
  2895. return fields
  2896. }
  2897. // Field returns the value of a field with the given name. The second boolean
  2898. // return value indicates that this field was not set, or was not defined in the
  2899. // schema.
  2900. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2901. switch name {
  2902. case aliyunavatar.FieldCreatedAt:
  2903. return m.CreatedAt()
  2904. case aliyunavatar.FieldUpdatedAt:
  2905. return m.UpdatedAt()
  2906. case aliyunavatar.FieldDeletedAt:
  2907. return m.DeletedAt()
  2908. case aliyunavatar.FieldUserID:
  2909. return m.UserID()
  2910. case aliyunavatar.FieldBizID:
  2911. return m.BizID()
  2912. case aliyunavatar.FieldAccessKeyID:
  2913. return m.AccessKeyID()
  2914. case aliyunavatar.FieldAccessKeySecret:
  2915. return m.AccessKeySecret()
  2916. case aliyunavatar.FieldAppID:
  2917. return m.AppID()
  2918. case aliyunavatar.FieldTenantID:
  2919. return m.TenantID()
  2920. case aliyunavatar.FieldResponse:
  2921. return m.Response()
  2922. case aliyunavatar.FieldToken:
  2923. return m.Token()
  2924. case aliyunavatar.FieldSessionID:
  2925. return m.SessionID()
  2926. }
  2927. return nil, false
  2928. }
  2929. // OldField returns the old value of the field from the database. An error is
  2930. // returned if the mutation operation is not UpdateOne, or the query to the
  2931. // database failed.
  2932. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2933. switch name {
  2934. case aliyunavatar.FieldCreatedAt:
  2935. return m.OldCreatedAt(ctx)
  2936. case aliyunavatar.FieldUpdatedAt:
  2937. return m.OldUpdatedAt(ctx)
  2938. case aliyunavatar.FieldDeletedAt:
  2939. return m.OldDeletedAt(ctx)
  2940. case aliyunavatar.FieldUserID:
  2941. return m.OldUserID(ctx)
  2942. case aliyunavatar.FieldBizID:
  2943. return m.OldBizID(ctx)
  2944. case aliyunavatar.FieldAccessKeyID:
  2945. return m.OldAccessKeyID(ctx)
  2946. case aliyunavatar.FieldAccessKeySecret:
  2947. return m.OldAccessKeySecret(ctx)
  2948. case aliyunavatar.FieldAppID:
  2949. return m.OldAppID(ctx)
  2950. case aliyunavatar.FieldTenantID:
  2951. return m.OldTenantID(ctx)
  2952. case aliyunavatar.FieldResponse:
  2953. return m.OldResponse(ctx)
  2954. case aliyunavatar.FieldToken:
  2955. return m.OldToken(ctx)
  2956. case aliyunavatar.FieldSessionID:
  2957. return m.OldSessionID(ctx)
  2958. }
  2959. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2960. }
  2961. // SetField sets the value of a field with the given name. It returns an error if
  2962. // the field is not defined in the schema, or if the type mismatched the field
  2963. // type.
  2964. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2965. switch name {
  2966. case aliyunavatar.FieldCreatedAt:
  2967. v, ok := value.(time.Time)
  2968. if !ok {
  2969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2970. }
  2971. m.SetCreatedAt(v)
  2972. return nil
  2973. case aliyunavatar.FieldUpdatedAt:
  2974. v, ok := value.(time.Time)
  2975. if !ok {
  2976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2977. }
  2978. m.SetUpdatedAt(v)
  2979. return nil
  2980. case aliyunavatar.FieldDeletedAt:
  2981. v, ok := value.(time.Time)
  2982. if !ok {
  2983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2984. }
  2985. m.SetDeletedAt(v)
  2986. return nil
  2987. case aliyunavatar.FieldUserID:
  2988. v, ok := value.(uint64)
  2989. if !ok {
  2990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2991. }
  2992. m.SetUserID(v)
  2993. return nil
  2994. case aliyunavatar.FieldBizID:
  2995. v, ok := value.(string)
  2996. if !ok {
  2997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2998. }
  2999. m.SetBizID(v)
  3000. return nil
  3001. case aliyunavatar.FieldAccessKeyID:
  3002. v, ok := value.(string)
  3003. if !ok {
  3004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3005. }
  3006. m.SetAccessKeyID(v)
  3007. return nil
  3008. case aliyunavatar.FieldAccessKeySecret:
  3009. v, ok := value.(string)
  3010. if !ok {
  3011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3012. }
  3013. m.SetAccessKeySecret(v)
  3014. return nil
  3015. case aliyunavatar.FieldAppID:
  3016. v, ok := value.(string)
  3017. if !ok {
  3018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3019. }
  3020. m.SetAppID(v)
  3021. return nil
  3022. case aliyunavatar.FieldTenantID:
  3023. v, ok := value.(uint64)
  3024. if !ok {
  3025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3026. }
  3027. m.SetTenantID(v)
  3028. return nil
  3029. case aliyunavatar.FieldResponse:
  3030. v, ok := value.(string)
  3031. if !ok {
  3032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3033. }
  3034. m.SetResponse(v)
  3035. return nil
  3036. case aliyunavatar.FieldToken:
  3037. v, ok := value.(string)
  3038. if !ok {
  3039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3040. }
  3041. m.SetToken(v)
  3042. return nil
  3043. case aliyunavatar.FieldSessionID:
  3044. v, ok := value.(string)
  3045. if !ok {
  3046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3047. }
  3048. m.SetSessionID(v)
  3049. return nil
  3050. }
  3051. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3052. }
  3053. // AddedFields returns all numeric fields that were incremented/decremented during
  3054. // this mutation.
  3055. func (m *AliyunAvatarMutation) AddedFields() []string {
  3056. var fields []string
  3057. if m.adduser_id != nil {
  3058. fields = append(fields, aliyunavatar.FieldUserID)
  3059. }
  3060. if m.addtenant_id != nil {
  3061. fields = append(fields, aliyunavatar.FieldTenantID)
  3062. }
  3063. return fields
  3064. }
  3065. // AddedField returns the numeric value that was incremented/decremented on a field
  3066. // with the given name. The second boolean return value indicates that this field
  3067. // was not set, or was not defined in the schema.
  3068. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3069. switch name {
  3070. case aliyunavatar.FieldUserID:
  3071. return m.AddedUserID()
  3072. case aliyunavatar.FieldTenantID:
  3073. return m.AddedTenantID()
  3074. }
  3075. return nil, false
  3076. }
  3077. // AddField adds the value to the field with the given name. It returns an error if
  3078. // the field is not defined in the schema, or if the type mismatched the field
  3079. // type.
  3080. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3081. switch name {
  3082. case aliyunavatar.FieldUserID:
  3083. v, ok := value.(int64)
  3084. if !ok {
  3085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3086. }
  3087. m.AddUserID(v)
  3088. return nil
  3089. case aliyunavatar.FieldTenantID:
  3090. v, ok := value.(int64)
  3091. if !ok {
  3092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3093. }
  3094. m.AddTenantID(v)
  3095. return nil
  3096. }
  3097. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3098. }
  3099. // ClearedFields returns all nullable fields that were cleared during this
  3100. // mutation.
  3101. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3102. var fields []string
  3103. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3104. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3105. }
  3106. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3107. fields = append(fields, aliyunavatar.FieldAppID)
  3108. }
  3109. return fields
  3110. }
  3111. // FieldCleared returns a boolean indicating if a field with the given name was
  3112. // cleared in this mutation.
  3113. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3114. _, ok := m.clearedFields[name]
  3115. return ok
  3116. }
  3117. // ClearField clears the value of the field with the given name. It returns an
  3118. // error if the field is not defined in the schema.
  3119. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3120. switch name {
  3121. case aliyunavatar.FieldDeletedAt:
  3122. m.ClearDeletedAt()
  3123. return nil
  3124. case aliyunavatar.FieldAppID:
  3125. m.ClearAppID()
  3126. return nil
  3127. }
  3128. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3129. }
  3130. // ResetField resets all changes in the mutation for the field with the given name.
  3131. // It returns an error if the field is not defined in the schema.
  3132. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3133. switch name {
  3134. case aliyunavatar.FieldCreatedAt:
  3135. m.ResetCreatedAt()
  3136. return nil
  3137. case aliyunavatar.FieldUpdatedAt:
  3138. m.ResetUpdatedAt()
  3139. return nil
  3140. case aliyunavatar.FieldDeletedAt:
  3141. m.ResetDeletedAt()
  3142. return nil
  3143. case aliyunavatar.FieldUserID:
  3144. m.ResetUserID()
  3145. return nil
  3146. case aliyunavatar.FieldBizID:
  3147. m.ResetBizID()
  3148. return nil
  3149. case aliyunavatar.FieldAccessKeyID:
  3150. m.ResetAccessKeyID()
  3151. return nil
  3152. case aliyunavatar.FieldAccessKeySecret:
  3153. m.ResetAccessKeySecret()
  3154. return nil
  3155. case aliyunavatar.FieldAppID:
  3156. m.ResetAppID()
  3157. return nil
  3158. case aliyunavatar.FieldTenantID:
  3159. m.ResetTenantID()
  3160. return nil
  3161. case aliyunavatar.FieldResponse:
  3162. m.ResetResponse()
  3163. return nil
  3164. case aliyunavatar.FieldToken:
  3165. m.ResetToken()
  3166. return nil
  3167. case aliyunavatar.FieldSessionID:
  3168. m.ResetSessionID()
  3169. return nil
  3170. }
  3171. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3172. }
  3173. // AddedEdges returns all edge names that were set/added in this mutation.
  3174. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3175. edges := make([]string, 0, 0)
  3176. return edges
  3177. }
  3178. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3179. // name in this mutation.
  3180. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3181. return nil
  3182. }
  3183. // RemovedEdges returns all edge names that were removed in this mutation.
  3184. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3185. edges := make([]string, 0, 0)
  3186. return edges
  3187. }
  3188. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3189. // the given name in this mutation.
  3190. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3191. return nil
  3192. }
  3193. // ClearedEdges returns all edge names that were cleared in this mutation.
  3194. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3195. edges := make([]string, 0, 0)
  3196. return edges
  3197. }
  3198. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3199. // was cleared in this mutation.
  3200. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3201. return false
  3202. }
  3203. // ClearEdge clears the value of the edge with the given name. It returns an error
  3204. // if that edge is not defined in the schema.
  3205. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3206. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3207. }
  3208. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3209. // It returns an error if the edge is not defined in the schema.
  3210. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3211. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3212. }
  3213. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3214. type AllocAgentMutation struct {
  3215. config
  3216. op Op
  3217. typ string
  3218. id *uint64
  3219. created_at *time.Time
  3220. updated_at *time.Time
  3221. deleted_at *time.Time
  3222. user_id *string
  3223. organization_id *uint64
  3224. addorganization_id *int64
  3225. agents *[]uint64
  3226. appendagents []uint64
  3227. status *int
  3228. addstatus *int
  3229. clearedFields map[string]struct{}
  3230. done bool
  3231. oldValue func(context.Context) (*AllocAgent, error)
  3232. predicates []predicate.AllocAgent
  3233. }
  3234. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3235. // allocagentOption allows management of the mutation configuration using functional options.
  3236. type allocagentOption func(*AllocAgentMutation)
  3237. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3238. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3239. m := &AllocAgentMutation{
  3240. config: c,
  3241. op: op,
  3242. typ: TypeAllocAgent,
  3243. clearedFields: make(map[string]struct{}),
  3244. }
  3245. for _, opt := range opts {
  3246. opt(m)
  3247. }
  3248. return m
  3249. }
  3250. // withAllocAgentID sets the ID field of the mutation.
  3251. func withAllocAgentID(id uint64) allocagentOption {
  3252. return func(m *AllocAgentMutation) {
  3253. var (
  3254. err error
  3255. once sync.Once
  3256. value *AllocAgent
  3257. )
  3258. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3259. once.Do(func() {
  3260. if m.done {
  3261. err = errors.New("querying old values post mutation is not allowed")
  3262. } else {
  3263. value, err = m.Client().AllocAgent.Get(ctx, id)
  3264. }
  3265. })
  3266. return value, err
  3267. }
  3268. m.id = &id
  3269. }
  3270. }
  3271. // withAllocAgent sets the old AllocAgent of the mutation.
  3272. func withAllocAgent(node *AllocAgent) allocagentOption {
  3273. return func(m *AllocAgentMutation) {
  3274. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3275. return node, nil
  3276. }
  3277. m.id = &node.ID
  3278. }
  3279. }
  3280. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3281. // executed in a transaction (ent.Tx), a transactional client is returned.
  3282. func (m AllocAgentMutation) Client() *Client {
  3283. client := &Client{config: m.config}
  3284. client.init()
  3285. return client
  3286. }
  3287. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3288. // it returns an error otherwise.
  3289. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3290. if _, ok := m.driver.(*txDriver); !ok {
  3291. return nil, errors.New("ent: mutation is not running in a transaction")
  3292. }
  3293. tx := &Tx{config: m.config}
  3294. tx.init()
  3295. return tx, nil
  3296. }
  3297. // SetID sets the value of the id field. Note that this
  3298. // operation is only accepted on creation of AllocAgent entities.
  3299. func (m *AllocAgentMutation) SetID(id uint64) {
  3300. m.id = &id
  3301. }
  3302. // ID returns the ID value in the mutation. Note that the ID is only available
  3303. // if it was provided to the builder or after it was returned from the database.
  3304. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3305. if m.id == nil {
  3306. return
  3307. }
  3308. return *m.id, true
  3309. }
  3310. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3311. // That means, if the mutation is applied within a transaction with an isolation level such
  3312. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3313. // or updated by the mutation.
  3314. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3315. switch {
  3316. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3317. id, exists := m.ID()
  3318. if exists {
  3319. return []uint64{id}, nil
  3320. }
  3321. fallthrough
  3322. case m.op.Is(OpUpdate | OpDelete):
  3323. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3324. default:
  3325. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3326. }
  3327. }
  3328. // SetCreatedAt sets the "created_at" field.
  3329. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3330. m.created_at = &t
  3331. }
  3332. // CreatedAt returns the value of the "created_at" field in the mutation.
  3333. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3334. v := m.created_at
  3335. if v == nil {
  3336. return
  3337. }
  3338. return *v, true
  3339. }
  3340. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3341. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3343. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3344. if !m.op.Is(OpUpdateOne) {
  3345. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3346. }
  3347. if m.id == nil || m.oldValue == nil {
  3348. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3349. }
  3350. oldValue, err := m.oldValue(ctx)
  3351. if err != nil {
  3352. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3353. }
  3354. return oldValue.CreatedAt, nil
  3355. }
  3356. // ResetCreatedAt resets all changes to the "created_at" field.
  3357. func (m *AllocAgentMutation) ResetCreatedAt() {
  3358. m.created_at = nil
  3359. }
  3360. // SetUpdatedAt sets the "updated_at" field.
  3361. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3362. m.updated_at = &t
  3363. }
  3364. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3365. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3366. v := m.updated_at
  3367. if v == nil {
  3368. return
  3369. }
  3370. return *v, true
  3371. }
  3372. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3373. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3375. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3376. if !m.op.Is(OpUpdateOne) {
  3377. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3378. }
  3379. if m.id == nil || m.oldValue == nil {
  3380. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3381. }
  3382. oldValue, err := m.oldValue(ctx)
  3383. if err != nil {
  3384. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3385. }
  3386. return oldValue.UpdatedAt, nil
  3387. }
  3388. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3389. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3390. m.updated_at = nil
  3391. }
  3392. // SetDeletedAt sets the "deleted_at" field.
  3393. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3394. m.deleted_at = &t
  3395. }
  3396. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3397. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3398. v := m.deleted_at
  3399. if v == nil {
  3400. return
  3401. }
  3402. return *v, true
  3403. }
  3404. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3405. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3407. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3408. if !m.op.Is(OpUpdateOne) {
  3409. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3410. }
  3411. if m.id == nil || m.oldValue == nil {
  3412. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3413. }
  3414. oldValue, err := m.oldValue(ctx)
  3415. if err != nil {
  3416. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3417. }
  3418. return oldValue.DeletedAt, nil
  3419. }
  3420. // ClearDeletedAt clears the value of the "deleted_at" field.
  3421. func (m *AllocAgentMutation) ClearDeletedAt() {
  3422. m.deleted_at = nil
  3423. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3424. }
  3425. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3426. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3427. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3428. return ok
  3429. }
  3430. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3431. func (m *AllocAgentMutation) ResetDeletedAt() {
  3432. m.deleted_at = nil
  3433. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3434. }
  3435. // SetUserID sets the "user_id" field.
  3436. func (m *AllocAgentMutation) SetUserID(s string) {
  3437. m.user_id = &s
  3438. }
  3439. // UserID returns the value of the "user_id" field in the mutation.
  3440. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3441. v := m.user_id
  3442. if v == nil {
  3443. return
  3444. }
  3445. return *v, true
  3446. }
  3447. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3448. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3450. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3451. if !m.op.Is(OpUpdateOne) {
  3452. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3453. }
  3454. if m.id == nil || m.oldValue == nil {
  3455. return v, errors.New("OldUserID requires an ID field in the mutation")
  3456. }
  3457. oldValue, err := m.oldValue(ctx)
  3458. if err != nil {
  3459. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3460. }
  3461. return oldValue.UserID, nil
  3462. }
  3463. // ClearUserID clears the value of the "user_id" field.
  3464. func (m *AllocAgentMutation) ClearUserID() {
  3465. m.user_id = nil
  3466. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3467. }
  3468. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3469. func (m *AllocAgentMutation) UserIDCleared() bool {
  3470. _, ok := m.clearedFields[allocagent.FieldUserID]
  3471. return ok
  3472. }
  3473. // ResetUserID resets all changes to the "user_id" field.
  3474. func (m *AllocAgentMutation) ResetUserID() {
  3475. m.user_id = nil
  3476. delete(m.clearedFields, allocagent.FieldUserID)
  3477. }
  3478. // SetOrganizationID sets the "organization_id" field.
  3479. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3480. m.organization_id = &u
  3481. m.addorganization_id = nil
  3482. }
  3483. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3484. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3485. v := m.organization_id
  3486. if v == nil {
  3487. return
  3488. }
  3489. return *v, true
  3490. }
  3491. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3492. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3494. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3495. if !m.op.Is(OpUpdateOne) {
  3496. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3497. }
  3498. if m.id == nil || m.oldValue == nil {
  3499. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3500. }
  3501. oldValue, err := m.oldValue(ctx)
  3502. if err != nil {
  3503. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3504. }
  3505. return oldValue.OrganizationID, nil
  3506. }
  3507. // AddOrganizationID adds u to the "organization_id" field.
  3508. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3509. if m.addorganization_id != nil {
  3510. *m.addorganization_id += u
  3511. } else {
  3512. m.addorganization_id = &u
  3513. }
  3514. }
  3515. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3516. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3517. v := m.addorganization_id
  3518. if v == nil {
  3519. return
  3520. }
  3521. return *v, true
  3522. }
  3523. // ClearOrganizationID clears the value of the "organization_id" field.
  3524. func (m *AllocAgentMutation) ClearOrganizationID() {
  3525. m.organization_id = nil
  3526. m.addorganization_id = nil
  3527. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3528. }
  3529. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3530. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3531. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3532. return ok
  3533. }
  3534. // ResetOrganizationID resets all changes to the "organization_id" field.
  3535. func (m *AllocAgentMutation) ResetOrganizationID() {
  3536. m.organization_id = nil
  3537. m.addorganization_id = nil
  3538. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3539. }
  3540. // SetAgents sets the "agents" field.
  3541. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3542. m.agents = &u
  3543. m.appendagents = nil
  3544. }
  3545. // Agents returns the value of the "agents" field in the mutation.
  3546. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3547. v := m.agents
  3548. if v == nil {
  3549. return
  3550. }
  3551. return *v, true
  3552. }
  3553. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3554. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3556. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3557. if !m.op.Is(OpUpdateOne) {
  3558. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3559. }
  3560. if m.id == nil || m.oldValue == nil {
  3561. return v, errors.New("OldAgents requires an ID field in the mutation")
  3562. }
  3563. oldValue, err := m.oldValue(ctx)
  3564. if err != nil {
  3565. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3566. }
  3567. return oldValue.Agents, nil
  3568. }
  3569. // AppendAgents adds u to the "agents" field.
  3570. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3571. m.appendagents = append(m.appendagents, u...)
  3572. }
  3573. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3574. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3575. if len(m.appendagents) == 0 {
  3576. return nil, false
  3577. }
  3578. return m.appendagents, true
  3579. }
  3580. // ResetAgents resets all changes to the "agents" field.
  3581. func (m *AllocAgentMutation) ResetAgents() {
  3582. m.agents = nil
  3583. m.appendagents = nil
  3584. }
  3585. // SetStatus sets the "status" field.
  3586. func (m *AllocAgentMutation) SetStatus(i int) {
  3587. m.status = &i
  3588. m.addstatus = nil
  3589. }
  3590. // Status returns the value of the "status" field in the mutation.
  3591. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3592. v := m.status
  3593. if v == nil {
  3594. return
  3595. }
  3596. return *v, true
  3597. }
  3598. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3599. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3601. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3602. if !m.op.Is(OpUpdateOne) {
  3603. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3604. }
  3605. if m.id == nil || m.oldValue == nil {
  3606. return v, errors.New("OldStatus requires an ID field in the mutation")
  3607. }
  3608. oldValue, err := m.oldValue(ctx)
  3609. if err != nil {
  3610. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3611. }
  3612. return oldValue.Status, nil
  3613. }
  3614. // AddStatus adds i to the "status" field.
  3615. func (m *AllocAgentMutation) AddStatus(i int) {
  3616. if m.addstatus != nil {
  3617. *m.addstatus += i
  3618. } else {
  3619. m.addstatus = &i
  3620. }
  3621. }
  3622. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3623. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3624. v := m.addstatus
  3625. if v == nil {
  3626. return
  3627. }
  3628. return *v, true
  3629. }
  3630. // ClearStatus clears the value of the "status" field.
  3631. func (m *AllocAgentMutation) ClearStatus() {
  3632. m.status = nil
  3633. m.addstatus = nil
  3634. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3635. }
  3636. // StatusCleared returns if the "status" field was cleared in this mutation.
  3637. func (m *AllocAgentMutation) StatusCleared() bool {
  3638. _, ok := m.clearedFields[allocagent.FieldStatus]
  3639. return ok
  3640. }
  3641. // ResetStatus resets all changes to the "status" field.
  3642. func (m *AllocAgentMutation) ResetStatus() {
  3643. m.status = nil
  3644. m.addstatus = nil
  3645. delete(m.clearedFields, allocagent.FieldStatus)
  3646. }
  3647. // Where appends a list predicates to the AllocAgentMutation builder.
  3648. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3649. m.predicates = append(m.predicates, ps...)
  3650. }
  3651. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3652. // users can use type-assertion to append predicates that do not depend on any generated package.
  3653. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3654. p := make([]predicate.AllocAgent, len(ps))
  3655. for i := range ps {
  3656. p[i] = ps[i]
  3657. }
  3658. m.Where(p...)
  3659. }
  3660. // Op returns the operation name.
  3661. func (m *AllocAgentMutation) Op() Op {
  3662. return m.op
  3663. }
  3664. // SetOp allows setting the mutation operation.
  3665. func (m *AllocAgentMutation) SetOp(op Op) {
  3666. m.op = op
  3667. }
  3668. // Type returns the node type of this mutation (AllocAgent).
  3669. func (m *AllocAgentMutation) Type() string {
  3670. return m.typ
  3671. }
  3672. // Fields returns all fields that were changed during this mutation. Note that in
  3673. // order to get all numeric fields that were incremented/decremented, call
  3674. // AddedFields().
  3675. func (m *AllocAgentMutation) Fields() []string {
  3676. fields := make([]string, 0, 7)
  3677. if m.created_at != nil {
  3678. fields = append(fields, allocagent.FieldCreatedAt)
  3679. }
  3680. if m.updated_at != nil {
  3681. fields = append(fields, allocagent.FieldUpdatedAt)
  3682. }
  3683. if m.deleted_at != nil {
  3684. fields = append(fields, allocagent.FieldDeletedAt)
  3685. }
  3686. if m.user_id != nil {
  3687. fields = append(fields, allocagent.FieldUserID)
  3688. }
  3689. if m.organization_id != nil {
  3690. fields = append(fields, allocagent.FieldOrganizationID)
  3691. }
  3692. if m.agents != nil {
  3693. fields = append(fields, allocagent.FieldAgents)
  3694. }
  3695. if m.status != nil {
  3696. fields = append(fields, allocagent.FieldStatus)
  3697. }
  3698. return fields
  3699. }
  3700. // Field returns the value of a field with the given name. The second boolean
  3701. // return value indicates that this field was not set, or was not defined in the
  3702. // schema.
  3703. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3704. switch name {
  3705. case allocagent.FieldCreatedAt:
  3706. return m.CreatedAt()
  3707. case allocagent.FieldUpdatedAt:
  3708. return m.UpdatedAt()
  3709. case allocagent.FieldDeletedAt:
  3710. return m.DeletedAt()
  3711. case allocagent.FieldUserID:
  3712. return m.UserID()
  3713. case allocagent.FieldOrganizationID:
  3714. return m.OrganizationID()
  3715. case allocagent.FieldAgents:
  3716. return m.Agents()
  3717. case allocagent.FieldStatus:
  3718. return m.Status()
  3719. }
  3720. return nil, false
  3721. }
  3722. // OldField returns the old value of the field from the database. An error is
  3723. // returned if the mutation operation is not UpdateOne, or the query to the
  3724. // database failed.
  3725. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3726. switch name {
  3727. case allocagent.FieldCreatedAt:
  3728. return m.OldCreatedAt(ctx)
  3729. case allocagent.FieldUpdatedAt:
  3730. return m.OldUpdatedAt(ctx)
  3731. case allocagent.FieldDeletedAt:
  3732. return m.OldDeletedAt(ctx)
  3733. case allocagent.FieldUserID:
  3734. return m.OldUserID(ctx)
  3735. case allocagent.FieldOrganizationID:
  3736. return m.OldOrganizationID(ctx)
  3737. case allocagent.FieldAgents:
  3738. return m.OldAgents(ctx)
  3739. case allocagent.FieldStatus:
  3740. return m.OldStatus(ctx)
  3741. }
  3742. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3743. }
  3744. // SetField sets the value of a field with the given name. It returns an error if
  3745. // the field is not defined in the schema, or if the type mismatched the field
  3746. // type.
  3747. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3748. switch name {
  3749. case allocagent.FieldCreatedAt:
  3750. v, ok := value.(time.Time)
  3751. if !ok {
  3752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3753. }
  3754. m.SetCreatedAt(v)
  3755. return nil
  3756. case allocagent.FieldUpdatedAt:
  3757. v, ok := value.(time.Time)
  3758. if !ok {
  3759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3760. }
  3761. m.SetUpdatedAt(v)
  3762. return nil
  3763. case allocagent.FieldDeletedAt:
  3764. v, ok := value.(time.Time)
  3765. if !ok {
  3766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3767. }
  3768. m.SetDeletedAt(v)
  3769. return nil
  3770. case allocagent.FieldUserID:
  3771. v, ok := value.(string)
  3772. if !ok {
  3773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3774. }
  3775. m.SetUserID(v)
  3776. return nil
  3777. case allocagent.FieldOrganizationID:
  3778. v, ok := value.(uint64)
  3779. if !ok {
  3780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3781. }
  3782. m.SetOrganizationID(v)
  3783. return nil
  3784. case allocagent.FieldAgents:
  3785. v, ok := value.([]uint64)
  3786. if !ok {
  3787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3788. }
  3789. m.SetAgents(v)
  3790. return nil
  3791. case allocagent.FieldStatus:
  3792. v, ok := value.(int)
  3793. if !ok {
  3794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3795. }
  3796. m.SetStatus(v)
  3797. return nil
  3798. }
  3799. return fmt.Errorf("unknown AllocAgent field %s", name)
  3800. }
  3801. // AddedFields returns all numeric fields that were incremented/decremented during
  3802. // this mutation.
  3803. func (m *AllocAgentMutation) AddedFields() []string {
  3804. var fields []string
  3805. if m.addorganization_id != nil {
  3806. fields = append(fields, allocagent.FieldOrganizationID)
  3807. }
  3808. if m.addstatus != nil {
  3809. fields = append(fields, allocagent.FieldStatus)
  3810. }
  3811. return fields
  3812. }
  3813. // AddedField returns the numeric value that was incremented/decremented on a field
  3814. // with the given name. The second boolean return value indicates that this field
  3815. // was not set, or was not defined in the schema.
  3816. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3817. switch name {
  3818. case allocagent.FieldOrganizationID:
  3819. return m.AddedOrganizationID()
  3820. case allocagent.FieldStatus:
  3821. return m.AddedStatus()
  3822. }
  3823. return nil, false
  3824. }
  3825. // AddField adds the value to the field with the given name. It returns an error if
  3826. // the field is not defined in the schema, or if the type mismatched the field
  3827. // type.
  3828. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3829. switch name {
  3830. case allocagent.FieldOrganizationID:
  3831. v, ok := value.(int64)
  3832. if !ok {
  3833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3834. }
  3835. m.AddOrganizationID(v)
  3836. return nil
  3837. case allocagent.FieldStatus:
  3838. v, ok := value.(int)
  3839. if !ok {
  3840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3841. }
  3842. m.AddStatus(v)
  3843. return nil
  3844. }
  3845. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3846. }
  3847. // ClearedFields returns all nullable fields that were cleared during this
  3848. // mutation.
  3849. func (m *AllocAgentMutation) ClearedFields() []string {
  3850. var fields []string
  3851. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3852. fields = append(fields, allocagent.FieldDeletedAt)
  3853. }
  3854. if m.FieldCleared(allocagent.FieldUserID) {
  3855. fields = append(fields, allocagent.FieldUserID)
  3856. }
  3857. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3858. fields = append(fields, allocagent.FieldOrganizationID)
  3859. }
  3860. if m.FieldCleared(allocagent.FieldStatus) {
  3861. fields = append(fields, allocagent.FieldStatus)
  3862. }
  3863. return fields
  3864. }
  3865. // FieldCleared returns a boolean indicating if a field with the given name was
  3866. // cleared in this mutation.
  3867. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3868. _, ok := m.clearedFields[name]
  3869. return ok
  3870. }
  3871. // ClearField clears the value of the field with the given name. It returns an
  3872. // error if the field is not defined in the schema.
  3873. func (m *AllocAgentMutation) ClearField(name string) error {
  3874. switch name {
  3875. case allocagent.FieldDeletedAt:
  3876. m.ClearDeletedAt()
  3877. return nil
  3878. case allocagent.FieldUserID:
  3879. m.ClearUserID()
  3880. return nil
  3881. case allocagent.FieldOrganizationID:
  3882. m.ClearOrganizationID()
  3883. return nil
  3884. case allocagent.FieldStatus:
  3885. m.ClearStatus()
  3886. return nil
  3887. }
  3888. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3889. }
  3890. // ResetField resets all changes in the mutation for the field with the given name.
  3891. // It returns an error if the field is not defined in the schema.
  3892. func (m *AllocAgentMutation) ResetField(name string) error {
  3893. switch name {
  3894. case allocagent.FieldCreatedAt:
  3895. m.ResetCreatedAt()
  3896. return nil
  3897. case allocagent.FieldUpdatedAt:
  3898. m.ResetUpdatedAt()
  3899. return nil
  3900. case allocagent.FieldDeletedAt:
  3901. m.ResetDeletedAt()
  3902. return nil
  3903. case allocagent.FieldUserID:
  3904. m.ResetUserID()
  3905. return nil
  3906. case allocagent.FieldOrganizationID:
  3907. m.ResetOrganizationID()
  3908. return nil
  3909. case allocagent.FieldAgents:
  3910. m.ResetAgents()
  3911. return nil
  3912. case allocagent.FieldStatus:
  3913. m.ResetStatus()
  3914. return nil
  3915. }
  3916. return fmt.Errorf("unknown AllocAgent field %s", name)
  3917. }
  3918. // AddedEdges returns all edge names that were set/added in this mutation.
  3919. func (m *AllocAgentMutation) AddedEdges() []string {
  3920. edges := make([]string, 0, 0)
  3921. return edges
  3922. }
  3923. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3924. // name in this mutation.
  3925. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3926. return nil
  3927. }
  3928. // RemovedEdges returns all edge names that were removed in this mutation.
  3929. func (m *AllocAgentMutation) RemovedEdges() []string {
  3930. edges := make([]string, 0, 0)
  3931. return edges
  3932. }
  3933. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3934. // the given name in this mutation.
  3935. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3936. return nil
  3937. }
  3938. // ClearedEdges returns all edge names that were cleared in this mutation.
  3939. func (m *AllocAgentMutation) ClearedEdges() []string {
  3940. edges := make([]string, 0, 0)
  3941. return edges
  3942. }
  3943. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3944. // was cleared in this mutation.
  3945. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3946. return false
  3947. }
  3948. // ClearEdge clears the value of the edge with the given name. It returns an error
  3949. // if that edge is not defined in the schema.
  3950. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3951. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3952. }
  3953. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3954. // It returns an error if the edge is not defined in the schema.
  3955. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3956. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3957. }
  3958. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3959. type BatchMsgMutation struct {
  3960. config
  3961. op Op
  3962. typ string
  3963. id *uint64
  3964. created_at *time.Time
  3965. updated_at *time.Time
  3966. deleted_at *time.Time
  3967. status *uint8
  3968. addstatus *int8
  3969. batch_no *string
  3970. task_name *string
  3971. fromwxid *string
  3972. msg *string
  3973. tag *string
  3974. tagids *string
  3975. total *int32
  3976. addtotal *int32
  3977. success *int32
  3978. addsuccess *int32
  3979. fail *int32
  3980. addfail *int32
  3981. start_time *time.Time
  3982. stop_time *time.Time
  3983. send_time *time.Time
  3984. _type *int32
  3985. add_type *int32
  3986. organization_id *uint64
  3987. addorganization_id *int64
  3988. ctype *uint64
  3989. addctype *int64
  3990. cc *string
  3991. phone *string
  3992. clearedFields map[string]struct{}
  3993. done bool
  3994. oldValue func(context.Context) (*BatchMsg, error)
  3995. predicates []predicate.BatchMsg
  3996. }
  3997. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3998. // batchmsgOption allows management of the mutation configuration using functional options.
  3999. type batchmsgOption func(*BatchMsgMutation)
  4000. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  4001. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  4002. m := &BatchMsgMutation{
  4003. config: c,
  4004. op: op,
  4005. typ: TypeBatchMsg,
  4006. clearedFields: make(map[string]struct{}),
  4007. }
  4008. for _, opt := range opts {
  4009. opt(m)
  4010. }
  4011. return m
  4012. }
  4013. // withBatchMsgID sets the ID field of the mutation.
  4014. func withBatchMsgID(id uint64) batchmsgOption {
  4015. return func(m *BatchMsgMutation) {
  4016. var (
  4017. err error
  4018. once sync.Once
  4019. value *BatchMsg
  4020. )
  4021. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  4022. once.Do(func() {
  4023. if m.done {
  4024. err = errors.New("querying old values post mutation is not allowed")
  4025. } else {
  4026. value, err = m.Client().BatchMsg.Get(ctx, id)
  4027. }
  4028. })
  4029. return value, err
  4030. }
  4031. m.id = &id
  4032. }
  4033. }
  4034. // withBatchMsg sets the old BatchMsg of the mutation.
  4035. func withBatchMsg(node *BatchMsg) batchmsgOption {
  4036. return func(m *BatchMsgMutation) {
  4037. m.oldValue = func(context.Context) (*BatchMsg, error) {
  4038. return node, nil
  4039. }
  4040. m.id = &node.ID
  4041. }
  4042. }
  4043. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4044. // executed in a transaction (ent.Tx), a transactional client is returned.
  4045. func (m BatchMsgMutation) Client() *Client {
  4046. client := &Client{config: m.config}
  4047. client.init()
  4048. return client
  4049. }
  4050. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4051. // it returns an error otherwise.
  4052. func (m BatchMsgMutation) Tx() (*Tx, error) {
  4053. if _, ok := m.driver.(*txDriver); !ok {
  4054. return nil, errors.New("ent: mutation is not running in a transaction")
  4055. }
  4056. tx := &Tx{config: m.config}
  4057. tx.init()
  4058. return tx, nil
  4059. }
  4060. // SetID sets the value of the id field. Note that this
  4061. // operation is only accepted on creation of BatchMsg entities.
  4062. func (m *BatchMsgMutation) SetID(id uint64) {
  4063. m.id = &id
  4064. }
  4065. // ID returns the ID value in the mutation. Note that the ID is only available
  4066. // if it was provided to the builder or after it was returned from the database.
  4067. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  4068. if m.id == nil {
  4069. return
  4070. }
  4071. return *m.id, true
  4072. }
  4073. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4074. // That means, if the mutation is applied within a transaction with an isolation level such
  4075. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4076. // or updated by the mutation.
  4077. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  4078. switch {
  4079. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4080. id, exists := m.ID()
  4081. if exists {
  4082. return []uint64{id}, nil
  4083. }
  4084. fallthrough
  4085. case m.op.Is(OpUpdate | OpDelete):
  4086. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4087. default:
  4088. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4089. }
  4090. }
  4091. // SetCreatedAt sets the "created_at" field.
  4092. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4093. m.created_at = &t
  4094. }
  4095. // CreatedAt returns the value of the "created_at" field in the mutation.
  4096. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4097. v := m.created_at
  4098. if v == nil {
  4099. return
  4100. }
  4101. return *v, true
  4102. }
  4103. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4104. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4106. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4107. if !m.op.Is(OpUpdateOne) {
  4108. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4109. }
  4110. if m.id == nil || m.oldValue == nil {
  4111. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4112. }
  4113. oldValue, err := m.oldValue(ctx)
  4114. if err != nil {
  4115. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4116. }
  4117. return oldValue.CreatedAt, nil
  4118. }
  4119. // ResetCreatedAt resets all changes to the "created_at" field.
  4120. func (m *BatchMsgMutation) ResetCreatedAt() {
  4121. m.created_at = nil
  4122. }
  4123. // SetUpdatedAt sets the "updated_at" field.
  4124. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4125. m.updated_at = &t
  4126. }
  4127. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4128. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4129. v := m.updated_at
  4130. if v == nil {
  4131. return
  4132. }
  4133. return *v, true
  4134. }
  4135. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4136. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4138. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4139. if !m.op.Is(OpUpdateOne) {
  4140. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4141. }
  4142. if m.id == nil || m.oldValue == nil {
  4143. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4144. }
  4145. oldValue, err := m.oldValue(ctx)
  4146. if err != nil {
  4147. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4148. }
  4149. return oldValue.UpdatedAt, nil
  4150. }
  4151. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4152. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4153. m.updated_at = nil
  4154. }
  4155. // SetDeletedAt sets the "deleted_at" field.
  4156. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4157. m.deleted_at = &t
  4158. }
  4159. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4160. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4161. v := m.deleted_at
  4162. if v == nil {
  4163. return
  4164. }
  4165. return *v, true
  4166. }
  4167. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4168. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4170. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4171. if !m.op.Is(OpUpdateOne) {
  4172. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4173. }
  4174. if m.id == nil || m.oldValue == nil {
  4175. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4176. }
  4177. oldValue, err := m.oldValue(ctx)
  4178. if err != nil {
  4179. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4180. }
  4181. return oldValue.DeletedAt, nil
  4182. }
  4183. // ClearDeletedAt clears the value of the "deleted_at" field.
  4184. func (m *BatchMsgMutation) ClearDeletedAt() {
  4185. m.deleted_at = nil
  4186. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4187. }
  4188. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4189. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4190. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4191. return ok
  4192. }
  4193. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4194. func (m *BatchMsgMutation) ResetDeletedAt() {
  4195. m.deleted_at = nil
  4196. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4197. }
  4198. // SetStatus sets the "status" field.
  4199. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4200. m.status = &u
  4201. m.addstatus = nil
  4202. }
  4203. // Status returns the value of the "status" field in the mutation.
  4204. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4205. v := m.status
  4206. if v == nil {
  4207. return
  4208. }
  4209. return *v, true
  4210. }
  4211. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4212. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4214. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4215. if !m.op.Is(OpUpdateOne) {
  4216. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4217. }
  4218. if m.id == nil || m.oldValue == nil {
  4219. return v, errors.New("OldStatus requires an ID field in the mutation")
  4220. }
  4221. oldValue, err := m.oldValue(ctx)
  4222. if err != nil {
  4223. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4224. }
  4225. return oldValue.Status, nil
  4226. }
  4227. // AddStatus adds u to the "status" field.
  4228. func (m *BatchMsgMutation) AddStatus(u int8) {
  4229. if m.addstatus != nil {
  4230. *m.addstatus += u
  4231. } else {
  4232. m.addstatus = &u
  4233. }
  4234. }
  4235. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4236. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4237. v := m.addstatus
  4238. if v == nil {
  4239. return
  4240. }
  4241. return *v, true
  4242. }
  4243. // ClearStatus clears the value of the "status" field.
  4244. func (m *BatchMsgMutation) ClearStatus() {
  4245. m.status = nil
  4246. m.addstatus = nil
  4247. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4248. }
  4249. // StatusCleared returns if the "status" field was cleared in this mutation.
  4250. func (m *BatchMsgMutation) StatusCleared() bool {
  4251. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4252. return ok
  4253. }
  4254. // ResetStatus resets all changes to the "status" field.
  4255. func (m *BatchMsgMutation) ResetStatus() {
  4256. m.status = nil
  4257. m.addstatus = nil
  4258. delete(m.clearedFields, batchmsg.FieldStatus)
  4259. }
  4260. // SetBatchNo sets the "batch_no" field.
  4261. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4262. m.batch_no = &s
  4263. }
  4264. // BatchNo returns the value of the "batch_no" field in the mutation.
  4265. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4266. v := m.batch_no
  4267. if v == nil {
  4268. return
  4269. }
  4270. return *v, true
  4271. }
  4272. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4273. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4275. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4276. if !m.op.Is(OpUpdateOne) {
  4277. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4278. }
  4279. if m.id == nil || m.oldValue == nil {
  4280. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4281. }
  4282. oldValue, err := m.oldValue(ctx)
  4283. if err != nil {
  4284. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4285. }
  4286. return oldValue.BatchNo, nil
  4287. }
  4288. // ClearBatchNo clears the value of the "batch_no" field.
  4289. func (m *BatchMsgMutation) ClearBatchNo() {
  4290. m.batch_no = nil
  4291. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4292. }
  4293. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4294. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4295. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4296. return ok
  4297. }
  4298. // ResetBatchNo resets all changes to the "batch_no" field.
  4299. func (m *BatchMsgMutation) ResetBatchNo() {
  4300. m.batch_no = nil
  4301. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4302. }
  4303. // SetTaskName sets the "task_name" field.
  4304. func (m *BatchMsgMutation) SetTaskName(s string) {
  4305. m.task_name = &s
  4306. }
  4307. // TaskName returns the value of the "task_name" field in the mutation.
  4308. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4309. v := m.task_name
  4310. if v == nil {
  4311. return
  4312. }
  4313. return *v, true
  4314. }
  4315. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4316. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4318. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4319. if !m.op.Is(OpUpdateOne) {
  4320. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4321. }
  4322. if m.id == nil || m.oldValue == nil {
  4323. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4324. }
  4325. oldValue, err := m.oldValue(ctx)
  4326. if err != nil {
  4327. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4328. }
  4329. return oldValue.TaskName, nil
  4330. }
  4331. // ClearTaskName clears the value of the "task_name" field.
  4332. func (m *BatchMsgMutation) ClearTaskName() {
  4333. m.task_name = nil
  4334. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4335. }
  4336. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4337. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4338. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4339. return ok
  4340. }
  4341. // ResetTaskName resets all changes to the "task_name" field.
  4342. func (m *BatchMsgMutation) ResetTaskName() {
  4343. m.task_name = nil
  4344. delete(m.clearedFields, batchmsg.FieldTaskName)
  4345. }
  4346. // SetFromwxid sets the "fromwxid" field.
  4347. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4348. m.fromwxid = &s
  4349. }
  4350. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4351. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4352. v := m.fromwxid
  4353. if v == nil {
  4354. return
  4355. }
  4356. return *v, true
  4357. }
  4358. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4359. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4361. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4362. if !m.op.Is(OpUpdateOne) {
  4363. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4364. }
  4365. if m.id == nil || m.oldValue == nil {
  4366. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4367. }
  4368. oldValue, err := m.oldValue(ctx)
  4369. if err != nil {
  4370. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4371. }
  4372. return oldValue.Fromwxid, nil
  4373. }
  4374. // ClearFromwxid clears the value of the "fromwxid" field.
  4375. func (m *BatchMsgMutation) ClearFromwxid() {
  4376. m.fromwxid = nil
  4377. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4378. }
  4379. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4380. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4381. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4382. return ok
  4383. }
  4384. // ResetFromwxid resets all changes to the "fromwxid" field.
  4385. func (m *BatchMsgMutation) ResetFromwxid() {
  4386. m.fromwxid = nil
  4387. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4388. }
  4389. // SetMsg sets the "msg" field.
  4390. func (m *BatchMsgMutation) SetMsg(s string) {
  4391. m.msg = &s
  4392. }
  4393. // Msg returns the value of the "msg" field in the mutation.
  4394. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4395. v := m.msg
  4396. if v == nil {
  4397. return
  4398. }
  4399. return *v, true
  4400. }
  4401. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4402. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4404. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4405. if !m.op.Is(OpUpdateOne) {
  4406. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4407. }
  4408. if m.id == nil || m.oldValue == nil {
  4409. return v, errors.New("OldMsg requires an ID field in the mutation")
  4410. }
  4411. oldValue, err := m.oldValue(ctx)
  4412. if err != nil {
  4413. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4414. }
  4415. return oldValue.Msg, nil
  4416. }
  4417. // ClearMsg clears the value of the "msg" field.
  4418. func (m *BatchMsgMutation) ClearMsg() {
  4419. m.msg = nil
  4420. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4421. }
  4422. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4423. func (m *BatchMsgMutation) MsgCleared() bool {
  4424. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4425. return ok
  4426. }
  4427. // ResetMsg resets all changes to the "msg" field.
  4428. func (m *BatchMsgMutation) ResetMsg() {
  4429. m.msg = nil
  4430. delete(m.clearedFields, batchmsg.FieldMsg)
  4431. }
  4432. // SetTag sets the "tag" field.
  4433. func (m *BatchMsgMutation) SetTag(s string) {
  4434. m.tag = &s
  4435. }
  4436. // Tag returns the value of the "tag" field in the mutation.
  4437. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4438. v := m.tag
  4439. if v == nil {
  4440. return
  4441. }
  4442. return *v, true
  4443. }
  4444. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4445. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4447. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4448. if !m.op.Is(OpUpdateOne) {
  4449. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4450. }
  4451. if m.id == nil || m.oldValue == nil {
  4452. return v, errors.New("OldTag requires an ID field in the mutation")
  4453. }
  4454. oldValue, err := m.oldValue(ctx)
  4455. if err != nil {
  4456. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4457. }
  4458. return oldValue.Tag, nil
  4459. }
  4460. // ClearTag clears the value of the "tag" field.
  4461. func (m *BatchMsgMutation) ClearTag() {
  4462. m.tag = nil
  4463. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4464. }
  4465. // TagCleared returns if the "tag" field was cleared in this mutation.
  4466. func (m *BatchMsgMutation) TagCleared() bool {
  4467. _, ok := m.clearedFields[batchmsg.FieldTag]
  4468. return ok
  4469. }
  4470. // ResetTag resets all changes to the "tag" field.
  4471. func (m *BatchMsgMutation) ResetTag() {
  4472. m.tag = nil
  4473. delete(m.clearedFields, batchmsg.FieldTag)
  4474. }
  4475. // SetTagids sets the "tagids" field.
  4476. func (m *BatchMsgMutation) SetTagids(s string) {
  4477. m.tagids = &s
  4478. }
  4479. // Tagids returns the value of the "tagids" field in the mutation.
  4480. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4481. v := m.tagids
  4482. if v == nil {
  4483. return
  4484. }
  4485. return *v, true
  4486. }
  4487. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4488. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4490. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4491. if !m.op.Is(OpUpdateOne) {
  4492. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4493. }
  4494. if m.id == nil || m.oldValue == nil {
  4495. return v, errors.New("OldTagids requires an ID field in the mutation")
  4496. }
  4497. oldValue, err := m.oldValue(ctx)
  4498. if err != nil {
  4499. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4500. }
  4501. return oldValue.Tagids, nil
  4502. }
  4503. // ClearTagids clears the value of the "tagids" field.
  4504. func (m *BatchMsgMutation) ClearTagids() {
  4505. m.tagids = nil
  4506. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4507. }
  4508. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4509. func (m *BatchMsgMutation) TagidsCleared() bool {
  4510. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4511. return ok
  4512. }
  4513. // ResetTagids resets all changes to the "tagids" field.
  4514. func (m *BatchMsgMutation) ResetTagids() {
  4515. m.tagids = nil
  4516. delete(m.clearedFields, batchmsg.FieldTagids)
  4517. }
  4518. // SetTotal sets the "total" field.
  4519. func (m *BatchMsgMutation) SetTotal(i int32) {
  4520. m.total = &i
  4521. m.addtotal = nil
  4522. }
  4523. // Total returns the value of the "total" field in the mutation.
  4524. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4525. v := m.total
  4526. if v == nil {
  4527. return
  4528. }
  4529. return *v, true
  4530. }
  4531. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4532. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4534. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4535. if !m.op.Is(OpUpdateOne) {
  4536. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4537. }
  4538. if m.id == nil || m.oldValue == nil {
  4539. return v, errors.New("OldTotal requires an ID field in the mutation")
  4540. }
  4541. oldValue, err := m.oldValue(ctx)
  4542. if err != nil {
  4543. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4544. }
  4545. return oldValue.Total, nil
  4546. }
  4547. // AddTotal adds i to the "total" field.
  4548. func (m *BatchMsgMutation) AddTotal(i int32) {
  4549. if m.addtotal != nil {
  4550. *m.addtotal += i
  4551. } else {
  4552. m.addtotal = &i
  4553. }
  4554. }
  4555. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4556. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4557. v := m.addtotal
  4558. if v == nil {
  4559. return
  4560. }
  4561. return *v, true
  4562. }
  4563. // ClearTotal clears the value of the "total" field.
  4564. func (m *BatchMsgMutation) ClearTotal() {
  4565. m.total = nil
  4566. m.addtotal = nil
  4567. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4568. }
  4569. // TotalCleared returns if the "total" field was cleared in this mutation.
  4570. func (m *BatchMsgMutation) TotalCleared() bool {
  4571. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4572. return ok
  4573. }
  4574. // ResetTotal resets all changes to the "total" field.
  4575. func (m *BatchMsgMutation) ResetTotal() {
  4576. m.total = nil
  4577. m.addtotal = nil
  4578. delete(m.clearedFields, batchmsg.FieldTotal)
  4579. }
  4580. // SetSuccess sets the "success" field.
  4581. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4582. m.success = &i
  4583. m.addsuccess = nil
  4584. }
  4585. // Success returns the value of the "success" field in the mutation.
  4586. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4587. v := m.success
  4588. if v == nil {
  4589. return
  4590. }
  4591. return *v, true
  4592. }
  4593. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4594. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4596. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4597. if !m.op.Is(OpUpdateOne) {
  4598. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4599. }
  4600. if m.id == nil || m.oldValue == nil {
  4601. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4602. }
  4603. oldValue, err := m.oldValue(ctx)
  4604. if err != nil {
  4605. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4606. }
  4607. return oldValue.Success, nil
  4608. }
  4609. // AddSuccess adds i to the "success" field.
  4610. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4611. if m.addsuccess != nil {
  4612. *m.addsuccess += i
  4613. } else {
  4614. m.addsuccess = &i
  4615. }
  4616. }
  4617. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4618. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4619. v := m.addsuccess
  4620. if v == nil {
  4621. return
  4622. }
  4623. return *v, true
  4624. }
  4625. // ClearSuccess clears the value of the "success" field.
  4626. func (m *BatchMsgMutation) ClearSuccess() {
  4627. m.success = nil
  4628. m.addsuccess = nil
  4629. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4630. }
  4631. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4632. func (m *BatchMsgMutation) SuccessCleared() bool {
  4633. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4634. return ok
  4635. }
  4636. // ResetSuccess resets all changes to the "success" field.
  4637. func (m *BatchMsgMutation) ResetSuccess() {
  4638. m.success = nil
  4639. m.addsuccess = nil
  4640. delete(m.clearedFields, batchmsg.FieldSuccess)
  4641. }
  4642. // SetFail sets the "fail" field.
  4643. func (m *BatchMsgMutation) SetFail(i int32) {
  4644. m.fail = &i
  4645. m.addfail = nil
  4646. }
  4647. // Fail returns the value of the "fail" field in the mutation.
  4648. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4649. v := m.fail
  4650. if v == nil {
  4651. return
  4652. }
  4653. return *v, true
  4654. }
  4655. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4656. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4658. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4659. if !m.op.Is(OpUpdateOne) {
  4660. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4661. }
  4662. if m.id == nil || m.oldValue == nil {
  4663. return v, errors.New("OldFail requires an ID field in the mutation")
  4664. }
  4665. oldValue, err := m.oldValue(ctx)
  4666. if err != nil {
  4667. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4668. }
  4669. return oldValue.Fail, nil
  4670. }
  4671. // AddFail adds i to the "fail" field.
  4672. func (m *BatchMsgMutation) AddFail(i int32) {
  4673. if m.addfail != nil {
  4674. *m.addfail += i
  4675. } else {
  4676. m.addfail = &i
  4677. }
  4678. }
  4679. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4680. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4681. v := m.addfail
  4682. if v == nil {
  4683. return
  4684. }
  4685. return *v, true
  4686. }
  4687. // ClearFail clears the value of the "fail" field.
  4688. func (m *BatchMsgMutation) ClearFail() {
  4689. m.fail = nil
  4690. m.addfail = nil
  4691. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4692. }
  4693. // FailCleared returns if the "fail" field was cleared in this mutation.
  4694. func (m *BatchMsgMutation) FailCleared() bool {
  4695. _, ok := m.clearedFields[batchmsg.FieldFail]
  4696. return ok
  4697. }
  4698. // ResetFail resets all changes to the "fail" field.
  4699. func (m *BatchMsgMutation) ResetFail() {
  4700. m.fail = nil
  4701. m.addfail = nil
  4702. delete(m.clearedFields, batchmsg.FieldFail)
  4703. }
  4704. // SetStartTime sets the "start_time" field.
  4705. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4706. m.start_time = &t
  4707. }
  4708. // StartTime returns the value of the "start_time" field in the mutation.
  4709. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4710. v := m.start_time
  4711. if v == nil {
  4712. return
  4713. }
  4714. return *v, true
  4715. }
  4716. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4717. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4719. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4720. if !m.op.Is(OpUpdateOne) {
  4721. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4722. }
  4723. if m.id == nil || m.oldValue == nil {
  4724. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4725. }
  4726. oldValue, err := m.oldValue(ctx)
  4727. if err != nil {
  4728. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4729. }
  4730. return oldValue.StartTime, nil
  4731. }
  4732. // ClearStartTime clears the value of the "start_time" field.
  4733. func (m *BatchMsgMutation) ClearStartTime() {
  4734. m.start_time = nil
  4735. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4736. }
  4737. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4738. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4739. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4740. return ok
  4741. }
  4742. // ResetStartTime resets all changes to the "start_time" field.
  4743. func (m *BatchMsgMutation) ResetStartTime() {
  4744. m.start_time = nil
  4745. delete(m.clearedFields, batchmsg.FieldStartTime)
  4746. }
  4747. // SetStopTime sets the "stop_time" field.
  4748. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4749. m.stop_time = &t
  4750. }
  4751. // StopTime returns the value of the "stop_time" field in the mutation.
  4752. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4753. v := m.stop_time
  4754. if v == nil {
  4755. return
  4756. }
  4757. return *v, true
  4758. }
  4759. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4760. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4762. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4763. if !m.op.Is(OpUpdateOne) {
  4764. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4765. }
  4766. if m.id == nil || m.oldValue == nil {
  4767. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4768. }
  4769. oldValue, err := m.oldValue(ctx)
  4770. if err != nil {
  4771. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4772. }
  4773. return oldValue.StopTime, nil
  4774. }
  4775. // ClearStopTime clears the value of the "stop_time" field.
  4776. func (m *BatchMsgMutation) ClearStopTime() {
  4777. m.stop_time = nil
  4778. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4779. }
  4780. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4781. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4782. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4783. return ok
  4784. }
  4785. // ResetStopTime resets all changes to the "stop_time" field.
  4786. func (m *BatchMsgMutation) ResetStopTime() {
  4787. m.stop_time = nil
  4788. delete(m.clearedFields, batchmsg.FieldStopTime)
  4789. }
  4790. // SetSendTime sets the "send_time" field.
  4791. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4792. m.send_time = &t
  4793. }
  4794. // SendTime returns the value of the "send_time" field in the mutation.
  4795. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4796. v := m.send_time
  4797. if v == nil {
  4798. return
  4799. }
  4800. return *v, true
  4801. }
  4802. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4803. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4805. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4806. if !m.op.Is(OpUpdateOne) {
  4807. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4808. }
  4809. if m.id == nil || m.oldValue == nil {
  4810. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4811. }
  4812. oldValue, err := m.oldValue(ctx)
  4813. if err != nil {
  4814. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4815. }
  4816. return oldValue.SendTime, nil
  4817. }
  4818. // ClearSendTime clears the value of the "send_time" field.
  4819. func (m *BatchMsgMutation) ClearSendTime() {
  4820. m.send_time = nil
  4821. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4822. }
  4823. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4824. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4825. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4826. return ok
  4827. }
  4828. // ResetSendTime resets all changes to the "send_time" field.
  4829. func (m *BatchMsgMutation) ResetSendTime() {
  4830. m.send_time = nil
  4831. delete(m.clearedFields, batchmsg.FieldSendTime)
  4832. }
  4833. // SetType sets the "type" field.
  4834. func (m *BatchMsgMutation) SetType(i int32) {
  4835. m._type = &i
  4836. m.add_type = nil
  4837. }
  4838. // GetType returns the value of the "type" field in the mutation.
  4839. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4840. v := m._type
  4841. if v == nil {
  4842. return
  4843. }
  4844. return *v, true
  4845. }
  4846. // OldType returns the old "type" field's value of the BatchMsg entity.
  4847. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4849. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4850. if !m.op.Is(OpUpdateOne) {
  4851. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4852. }
  4853. if m.id == nil || m.oldValue == nil {
  4854. return v, errors.New("OldType requires an ID field in the mutation")
  4855. }
  4856. oldValue, err := m.oldValue(ctx)
  4857. if err != nil {
  4858. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4859. }
  4860. return oldValue.Type, nil
  4861. }
  4862. // AddType adds i to the "type" field.
  4863. func (m *BatchMsgMutation) AddType(i int32) {
  4864. if m.add_type != nil {
  4865. *m.add_type += i
  4866. } else {
  4867. m.add_type = &i
  4868. }
  4869. }
  4870. // AddedType returns the value that was added to the "type" field in this mutation.
  4871. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4872. v := m.add_type
  4873. if v == nil {
  4874. return
  4875. }
  4876. return *v, true
  4877. }
  4878. // ClearType clears the value of the "type" field.
  4879. func (m *BatchMsgMutation) ClearType() {
  4880. m._type = nil
  4881. m.add_type = nil
  4882. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4883. }
  4884. // TypeCleared returns if the "type" field was cleared in this mutation.
  4885. func (m *BatchMsgMutation) TypeCleared() bool {
  4886. _, ok := m.clearedFields[batchmsg.FieldType]
  4887. return ok
  4888. }
  4889. // ResetType resets all changes to the "type" field.
  4890. func (m *BatchMsgMutation) ResetType() {
  4891. m._type = nil
  4892. m.add_type = nil
  4893. delete(m.clearedFields, batchmsg.FieldType)
  4894. }
  4895. // SetOrganizationID sets the "organization_id" field.
  4896. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4897. m.organization_id = &u
  4898. m.addorganization_id = nil
  4899. }
  4900. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4901. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4902. v := m.organization_id
  4903. if v == nil {
  4904. return
  4905. }
  4906. return *v, true
  4907. }
  4908. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4909. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4911. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4912. if !m.op.Is(OpUpdateOne) {
  4913. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4914. }
  4915. if m.id == nil || m.oldValue == nil {
  4916. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4917. }
  4918. oldValue, err := m.oldValue(ctx)
  4919. if err != nil {
  4920. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4921. }
  4922. return oldValue.OrganizationID, nil
  4923. }
  4924. // AddOrganizationID adds u to the "organization_id" field.
  4925. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4926. if m.addorganization_id != nil {
  4927. *m.addorganization_id += u
  4928. } else {
  4929. m.addorganization_id = &u
  4930. }
  4931. }
  4932. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4933. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4934. v := m.addorganization_id
  4935. if v == nil {
  4936. return
  4937. }
  4938. return *v, true
  4939. }
  4940. // ResetOrganizationID resets all changes to the "organization_id" field.
  4941. func (m *BatchMsgMutation) ResetOrganizationID() {
  4942. m.organization_id = nil
  4943. m.addorganization_id = nil
  4944. }
  4945. // SetCtype sets the "ctype" field.
  4946. func (m *BatchMsgMutation) SetCtype(u uint64) {
  4947. m.ctype = &u
  4948. m.addctype = nil
  4949. }
  4950. // Ctype returns the value of the "ctype" field in the mutation.
  4951. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  4952. v := m.ctype
  4953. if v == nil {
  4954. return
  4955. }
  4956. return *v, true
  4957. }
  4958. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  4959. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4960. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4961. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  4962. if !m.op.Is(OpUpdateOne) {
  4963. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  4964. }
  4965. if m.id == nil || m.oldValue == nil {
  4966. return v, errors.New("OldCtype requires an ID field in the mutation")
  4967. }
  4968. oldValue, err := m.oldValue(ctx)
  4969. if err != nil {
  4970. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  4971. }
  4972. return oldValue.Ctype, nil
  4973. }
  4974. // AddCtype adds u to the "ctype" field.
  4975. func (m *BatchMsgMutation) AddCtype(u int64) {
  4976. if m.addctype != nil {
  4977. *m.addctype += u
  4978. } else {
  4979. m.addctype = &u
  4980. }
  4981. }
  4982. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  4983. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  4984. v := m.addctype
  4985. if v == nil {
  4986. return
  4987. }
  4988. return *v, true
  4989. }
  4990. // ResetCtype resets all changes to the "ctype" field.
  4991. func (m *BatchMsgMutation) ResetCtype() {
  4992. m.ctype = nil
  4993. m.addctype = nil
  4994. }
  4995. // SetCc sets the "cc" field.
  4996. func (m *BatchMsgMutation) SetCc(s string) {
  4997. m.cc = &s
  4998. }
  4999. // Cc returns the value of the "cc" field in the mutation.
  5000. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  5001. v := m.cc
  5002. if v == nil {
  5003. return
  5004. }
  5005. return *v, true
  5006. }
  5007. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  5008. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5010. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  5011. if !m.op.Is(OpUpdateOne) {
  5012. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  5013. }
  5014. if m.id == nil || m.oldValue == nil {
  5015. return v, errors.New("OldCc requires an ID field in the mutation")
  5016. }
  5017. oldValue, err := m.oldValue(ctx)
  5018. if err != nil {
  5019. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  5020. }
  5021. return oldValue.Cc, nil
  5022. }
  5023. // ClearCc clears the value of the "cc" field.
  5024. func (m *BatchMsgMutation) ClearCc() {
  5025. m.cc = nil
  5026. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  5027. }
  5028. // CcCleared returns if the "cc" field was cleared in this mutation.
  5029. func (m *BatchMsgMutation) CcCleared() bool {
  5030. _, ok := m.clearedFields[batchmsg.FieldCc]
  5031. return ok
  5032. }
  5033. // ResetCc resets all changes to the "cc" field.
  5034. func (m *BatchMsgMutation) ResetCc() {
  5035. m.cc = nil
  5036. delete(m.clearedFields, batchmsg.FieldCc)
  5037. }
  5038. // SetPhone sets the "phone" field.
  5039. func (m *BatchMsgMutation) SetPhone(s string) {
  5040. m.phone = &s
  5041. }
  5042. // Phone returns the value of the "phone" field in the mutation.
  5043. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  5044. v := m.phone
  5045. if v == nil {
  5046. return
  5047. }
  5048. return *v, true
  5049. }
  5050. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  5051. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5053. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  5054. if !m.op.Is(OpUpdateOne) {
  5055. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  5056. }
  5057. if m.id == nil || m.oldValue == nil {
  5058. return v, errors.New("OldPhone requires an ID field in the mutation")
  5059. }
  5060. oldValue, err := m.oldValue(ctx)
  5061. if err != nil {
  5062. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  5063. }
  5064. return oldValue.Phone, nil
  5065. }
  5066. // ClearPhone clears the value of the "phone" field.
  5067. func (m *BatchMsgMutation) ClearPhone() {
  5068. m.phone = nil
  5069. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  5070. }
  5071. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  5072. func (m *BatchMsgMutation) PhoneCleared() bool {
  5073. _, ok := m.clearedFields[batchmsg.FieldPhone]
  5074. return ok
  5075. }
  5076. // ResetPhone resets all changes to the "phone" field.
  5077. func (m *BatchMsgMutation) ResetPhone() {
  5078. m.phone = nil
  5079. delete(m.clearedFields, batchmsg.FieldPhone)
  5080. }
  5081. // Where appends a list predicates to the BatchMsgMutation builder.
  5082. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  5083. m.predicates = append(m.predicates, ps...)
  5084. }
  5085. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  5086. // users can use type-assertion to append predicates that do not depend on any generated package.
  5087. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  5088. p := make([]predicate.BatchMsg, len(ps))
  5089. for i := range ps {
  5090. p[i] = ps[i]
  5091. }
  5092. m.Where(p...)
  5093. }
  5094. // Op returns the operation name.
  5095. func (m *BatchMsgMutation) Op() Op {
  5096. return m.op
  5097. }
  5098. // SetOp allows setting the mutation operation.
  5099. func (m *BatchMsgMutation) SetOp(op Op) {
  5100. m.op = op
  5101. }
  5102. // Type returns the node type of this mutation (BatchMsg).
  5103. func (m *BatchMsgMutation) Type() string {
  5104. return m.typ
  5105. }
  5106. // Fields returns all fields that were changed during this mutation. Note that in
  5107. // order to get all numeric fields that were incremented/decremented, call
  5108. // AddedFields().
  5109. func (m *BatchMsgMutation) Fields() []string {
  5110. fields := make([]string, 0, 21)
  5111. if m.created_at != nil {
  5112. fields = append(fields, batchmsg.FieldCreatedAt)
  5113. }
  5114. if m.updated_at != nil {
  5115. fields = append(fields, batchmsg.FieldUpdatedAt)
  5116. }
  5117. if m.deleted_at != nil {
  5118. fields = append(fields, batchmsg.FieldDeletedAt)
  5119. }
  5120. if m.status != nil {
  5121. fields = append(fields, batchmsg.FieldStatus)
  5122. }
  5123. if m.batch_no != nil {
  5124. fields = append(fields, batchmsg.FieldBatchNo)
  5125. }
  5126. if m.task_name != nil {
  5127. fields = append(fields, batchmsg.FieldTaskName)
  5128. }
  5129. if m.fromwxid != nil {
  5130. fields = append(fields, batchmsg.FieldFromwxid)
  5131. }
  5132. if m.msg != nil {
  5133. fields = append(fields, batchmsg.FieldMsg)
  5134. }
  5135. if m.tag != nil {
  5136. fields = append(fields, batchmsg.FieldTag)
  5137. }
  5138. if m.tagids != nil {
  5139. fields = append(fields, batchmsg.FieldTagids)
  5140. }
  5141. if m.total != nil {
  5142. fields = append(fields, batchmsg.FieldTotal)
  5143. }
  5144. if m.success != nil {
  5145. fields = append(fields, batchmsg.FieldSuccess)
  5146. }
  5147. if m.fail != nil {
  5148. fields = append(fields, batchmsg.FieldFail)
  5149. }
  5150. if m.start_time != nil {
  5151. fields = append(fields, batchmsg.FieldStartTime)
  5152. }
  5153. if m.stop_time != nil {
  5154. fields = append(fields, batchmsg.FieldStopTime)
  5155. }
  5156. if m.send_time != nil {
  5157. fields = append(fields, batchmsg.FieldSendTime)
  5158. }
  5159. if m._type != nil {
  5160. fields = append(fields, batchmsg.FieldType)
  5161. }
  5162. if m.organization_id != nil {
  5163. fields = append(fields, batchmsg.FieldOrganizationID)
  5164. }
  5165. if m.ctype != nil {
  5166. fields = append(fields, batchmsg.FieldCtype)
  5167. }
  5168. if m.cc != nil {
  5169. fields = append(fields, batchmsg.FieldCc)
  5170. }
  5171. if m.phone != nil {
  5172. fields = append(fields, batchmsg.FieldPhone)
  5173. }
  5174. return fields
  5175. }
  5176. // Field returns the value of a field with the given name. The second boolean
  5177. // return value indicates that this field was not set, or was not defined in the
  5178. // schema.
  5179. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  5180. switch name {
  5181. case batchmsg.FieldCreatedAt:
  5182. return m.CreatedAt()
  5183. case batchmsg.FieldUpdatedAt:
  5184. return m.UpdatedAt()
  5185. case batchmsg.FieldDeletedAt:
  5186. return m.DeletedAt()
  5187. case batchmsg.FieldStatus:
  5188. return m.Status()
  5189. case batchmsg.FieldBatchNo:
  5190. return m.BatchNo()
  5191. case batchmsg.FieldTaskName:
  5192. return m.TaskName()
  5193. case batchmsg.FieldFromwxid:
  5194. return m.Fromwxid()
  5195. case batchmsg.FieldMsg:
  5196. return m.Msg()
  5197. case batchmsg.FieldTag:
  5198. return m.Tag()
  5199. case batchmsg.FieldTagids:
  5200. return m.Tagids()
  5201. case batchmsg.FieldTotal:
  5202. return m.Total()
  5203. case batchmsg.FieldSuccess:
  5204. return m.Success()
  5205. case batchmsg.FieldFail:
  5206. return m.Fail()
  5207. case batchmsg.FieldStartTime:
  5208. return m.StartTime()
  5209. case batchmsg.FieldStopTime:
  5210. return m.StopTime()
  5211. case batchmsg.FieldSendTime:
  5212. return m.SendTime()
  5213. case batchmsg.FieldType:
  5214. return m.GetType()
  5215. case batchmsg.FieldOrganizationID:
  5216. return m.OrganizationID()
  5217. case batchmsg.FieldCtype:
  5218. return m.Ctype()
  5219. case batchmsg.FieldCc:
  5220. return m.Cc()
  5221. case batchmsg.FieldPhone:
  5222. return m.Phone()
  5223. }
  5224. return nil, false
  5225. }
  5226. // OldField returns the old value of the field from the database. An error is
  5227. // returned if the mutation operation is not UpdateOne, or the query to the
  5228. // database failed.
  5229. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5230. switch name {
  5231. case batchmsg.FieldCreatedAt:
  5232. return m.OldCreatedAt(ctx)
  5233. case batchmsg.FieldUpdatedAt:
  5234. return m.OldUpdatedAt(ctx)
  5235. case batchmsg.FieldDeletedAt:
  5236. return m.OldDeletedAt(ctx)
  5237. case batchmsg.FieldStatus:
  5238. return m.OldStatus(ctx)
  5239. case batchmsg.FieldBatchNo:
  5240. return m.OldBatchNo(ctx)
  5241. case batchmsg.FieldTaskName:
  5242. return m.OldTaskName(ctx)
  5243. case batchmsg.FieldFromwxid:
  5244. return m.OldFromwxid(ctx)
  5245. case batchmsg.FieldMsg:
  5246. return m.OldMsg(ctx)
  5247. case batchmsg.FieldTag:
  5248. return m.OldTag(ctx)
  5249. case batchmsg.FieldTagids:
  5250. return m.OldTagids(ctx)
  5251. case batchmsg.FieldTotal:
  5252. return m.OldTotal(ctx)
  5253. case batchmsg.FieldSuccess:
  5254. return m.OldSuccess(ctx)
  5255. case batchmsg.FieldFail:
  5256. return m.OldFail(ctx)
  5257. case batchmsg.FieldStartTime:
  5258. return m.OldStartTime(ctx)
  5259. case batchmsg.FieldStopTime:
  5260. return m.OldStopTime(ctx)
  5261. case batchmsg.FieldSendTime:
  5262. return m.OldSendTime(ctx)
  5263. case batchmsg.FieldType:
  5264. return m.OldType(ctx)
  5265. case batchmsg.FieldOrganizationID:
  5266. return m.OldOrganizationID(ctx)
  5267. case batchmsg.FieldCtype:
  5268. return m.OldCtype(ctx)
  5269. case batchmsg.FieldCc:
  5270. return m.OldCc(ctx)
  5271. case batchmsg.FieldPhone:
  5272. return m.OldPhone(ctx)
  5273. }
  5274. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5275. }
  5276. // SetField sets the value of a field with the given name. It returns an error if
  5277. // the field is not defined in the schema, or if the type mismatched the field
  5278. // type.
  5279. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5280. switch name {
  5281. case batchmsg.FieldCreatedAt:
  5282. v, ok := value.(time.Time)
  5283. if !ok {
  5284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5285. }
  5286. m.SetCreatedAt(v)
  5287. return nil
  5288. case batchmsg.FieldUpdatedAt:
  5289. v, ok := value.(time.Time)
  5290. if !ok {
  5291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5292. }
  5293. m.SetUpdatedAt(v)
  5294. return nil
  5295. case batchmsg.FieldDeletedAt:
  5296. v, ok := value.(time.Time)
  5297. if !ok {
  5298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5299. }
  5300. m.SetDeletedAt(v)
  5301. return nil
  5302. case batchmsg.FieldStatus:
  5303. v, ok := value.(uint8)
  5304. if !ok {
  5305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5306. }
  5307. m.SetStatus(v)
  5308. return nil
  5309. case batchmsg.FieldBatchNo:
  5310. v, ok := value.(string)
  5311. if !ok {
  5312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5313. }
  5314. m.SetBatchNo(v)
  5315. return nil
  5316. case batchmsg.FieldTaskName:
  5317. v, ok := value.(string)
  5318. if !ok {
  5319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5320. }
  5321. m.SetTaskName(v)
  5322. return nil
  5323. case batchmsg.FieldFromwxid:
  5324. v, ok := value.(string)
  5325. if !ok {
  5326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5327. }
  5328. m.SetFromwxid(v)
  5329. return nil
  5330. case batchmsg.FieldMsg:
  5331. v, ok := value.(string)
  5332. if !ok {
  5333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5334. }
  5335. m.SetMsg(v)
  5336. return nil
  5337. case batchmsg.FieldTag:
  5338. v, ok := value.(string)
  5339. if !ok {
  5340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5341. }
  5342. m.SetTag(v)
  5343. return nil
  5344. case batchmsg.FieldTagids:
  5345. v, ok := value.(string)
  5346. if !ok {
  5347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5348. }
  5349. m.SetTagids(v)
  5350. return nil
  5351. case batchmsg.FieldTotal:
  5352. v, ok := value.(int32)
  5353. if !ok {
  5354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5355. }
  5356. m.SetTotal(v)
  5357. return nil
  5358. case batchmsg.FieldSuccess:
  5359. v, ok := value.(int32)
  5360. if !ok {
  5361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5362. }
  5363. m.SetSuccess(v)
  5364. return nil
  5365. case batchmsg.FieldFail:
  5366. v, ok := value.(int32)
  5367. if !ok {
  5368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5369. }
  5370. m.SetFail(v)
  5371. return nil
  5372. case batchmsg.FieldStartTime:
  5373. v, ok := value.(time.Time)
  5374. if !ok {
  5375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5376. }
  5377. m.SetStartTime(v)
  5378. return nil
  5379. case batchmsg.FieldStopTime:
  5380. v, ok := value.(time.Time)
  5381. if !ok {
  5382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5383. }
  5384. m.SetStopTime(v)
  5385. return nil
  5386. case batchmsg.FieldSendTime:
  5387. v, ok := value.(time.Time)
  5388. if !ok {
  5389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5390. }
  5391. m.SetSendTime(v)
  5392. return nil
  5393. case batchmsg.FieldType:
  5394. v, ok := value.(int32)
  5395. if !ok {
  5396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5397. }
  5398. m.SetType(v)
  5399. return nil
  5400. case batchmsg.FieldOrganizationID:
  5401. v, ok := value.(uint64)
  5402. if !ok {
  5403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5404. }
  5405. m.SetOrganizationID(v)
  5406. return nil
  5407. case batchmsg.FieldCtype:
  5408. v, ok := value.(uint64)
  5409. if !ok {
  5410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5411. }
  5412. m.SetCtype(v)
  5413. return nil
  5414. case batchmsg.FieldCc:
  5415. v, ok := value.(string)
  5416. if !ok {
  5417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5418. }
  5419. m.SetCc(v)
  5420. return nil
  5421. case batchmsg.FieldPhone:
  5422. v, ok := value.(string)
  5423. if !ok {
  5424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5425. }
  5426. m.SetPhone(v)
  5427. return nil
  5428. }
  5429. return fmt.Errorf("unknown BatchMsg field %s", name)
  5430. }
  5431. // AddedFields returns all numeric fields that were incremented/decremented during
  5432. // this mutation.
  5433. func (m *BatchMsgMutation) AddedFields() []string {
  5434. var fields []string
  5435. if m.addstatus != nil {
  5436. fields = append(fields, batchmsg.FieldStatus)
  5437. }
  5438. if m.addtotal != nil {
  5439. fields = append(fields, batchmsg.FieldTotal)
  5440. }
  5441. if m.addsuccess != nil {
  5442. fields = append(fields, batchmsg.FieldSuccess)
  5443. }
  5444. if m.addfail != nil {
  5445. fields = append(fields, batchmsg.FieldFail)
  5446. }
  5447. if m.add_type != nil {
  5448. fields = append(fields, batchmsg.FieldType)
  5449. }
  5450. if m.addorganization_id != nil {
  5451. fields = append(fields, batchmsg.FieldOrganizationID)
  5452. }
  5453. if m.addctype != nil {
  5454. fields = append(fields, batchmsg.FieldCtype)
  5455. }
  5456. return fields
  5457. }
  5458. // AddedField returns the numeric value that was incremented/decremented on a field
  5459. // with the given name. The second boolean return value indicates that this field
  5460. // was not set, or was not defined in the schema.
  5461. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5462. switch name {
  5463. case batchmsg.FieldStatus:
  5464. return m.AddedStatus()
  5465. case batchmsg.FieldTotal:
  5466. return m.AddedTotal()
  5467. case batchmsg.FieldSuccess:
  5468. return m.AddedSuccess()
  5469. case batchmsg.FieldFail:
  5470. return m.AddedFail()
  5471. case batchmsg.FieldType:
  5472. return m.AddedType()
  5473. case batchmsg.FieldOrganizationID:
  5474. return m.AddedOrganizationID()
  5475. case batchmsg.FieldCtype:
  5476. return m.AddedCtype()
  5477. }
  5478. return nil, false
  5479. }
  5480. // AddField adds the value to the field with the given name. It returns an error if
  5481. // the field is not defined in the schema, or if the type mismatched the field
  5482. // type.
  5483. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5484. switch name {
  5485. case batchmsg.FieldStatus:
  5486. v, ok := value.(int8)
  5487. if !ok {
  5488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5489. }
  5490. m.AddStatus(v)
  5491. return nil
  5492. case batchmsg.FieldTotal:
  5493. v, ok := value.(int32)
  5494. if !ok {
  5495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5496. }
  5497. m.AddTotal(v)
  5498. return nil
  5499. case batchmsg.FieldSuccess:
  5500. v, ok := value.(int32)
  5501. if !ok {
  5502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5503. }
  5504. m.AddSuccess(v)
  5505. return nil
  5506. case batchmsg.FieldFail:
  5507. v, ok := value.(int32)
  5508. if !ok {
  5509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5510. }
  5511. m.AddFail(v)
  5512. return nil
  5513. case batchmsg.FieldType:
  5514. v, ok := value.(int32)
  5515. if !ok {
  5516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5517. }
  5518. m.AddType(v)
  5519. return nil
  5520. case batchmsg.FieldOrganizationID:
  5521. v, ok := value.(int64)
  5522. if !ok {
  5523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5524. }
  5525. m.AddOrganizationID(v)
  5526. return nil
  5527. case batchmsg.FieldCtype:
  5528. v, ok := value.(int64)
  5529. if !ok {
  5530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5531. }
  5532. m.AddCtype(v)
  5533. return nil
  5534. }
  5535. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5536. }
  5537. // ClearedFields returns all nullable fields that were cleared during this
  5538. // mutation.
  5539. func (m *BatchMsgMutation) ClearedFields() []string {
  5540. var fields []string
  5541. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5542. fields = append(fields, batchmsg.FieldDeletedAt)
  5543. }
  5544. if m.FieldCleared(batchmsg.FieldStatus) {
  5545. fields = append(fields, batchmsg.FieldStatus)
  5546. }
  5547. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5548. fields = append(fields, batchmsg.FieldBatchNo)
  5549. }
  5550. if m.FieldCleared(batchmsg.FieldTaskName) {
  5551. fields = append(fields, batchmsg.FieldTaskName)
  5552. }
  5553. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5554. fields = append(fields, batchmsg.FieldFromwxid)
  5555. }
  5556. if m.FieldCleared(batchmsg.FieldMsg) {
  5557. fields = append(fields, batchmsg.FieldMsg)
  5558. }
  5559. if m.FieldCleared(batchmsg.FieldTag) {
  5560. fields = append(fields, batchmsg.FieldTag)
  5561. }
  5562. if m.FieldCleared(batchmsg.FieldTagids) {
  5563. fields = append(fields, batchmsg.FieldTagids)
  5564. }
  5565. if m.FieldCleared(batchmsg.FieldTotal) {
  5566. fields = append(fields, batchmsg.FieldTotal)
  5567. }
  5568. if m.FieldCleared(batchmsg.FieldSuccess) {
  5569. fields = append(fields, batchmsg.FieldSuccess)
  5570. }
  5571. if m.FieldCleared(batchmsg.FieldFail) {
  5572. fields = append(fields, batchmsg.FieldFail)
  5573. }
  5574. if m.FieldCleared(batchmsg.FieldStartTime) {
  5575. fields = append(fields, batchmsg.FieldStartTime)
  5576. }
  5577. if m.FieldCleared(batchmsg.FieldStopTime) {
  5578. fields = append(fields, batchmsg.FieldStopTime)
  5579. }
  5580. if m.FieldCleared(batchmsg.FieldSendTime) {
  5581. fields = append(fields, batchmsg.FieldSendTime)
  5582. }
  5583. if m.FieldCleared(batchmsg.FieldType) {
  5584. fields = append(fields, batchmsg.FieldType)
  5585. }
  5586. if m.FieldCleared(batchmsg.FieldCc) {
  5587. fields = append(fields, batchmsg.FieldCc)
  5588. }
  5589. if m.FieldCleared(batchmsg.FieldPhone) {
  5590. fields = append(fields, batchmsg.FieldPhone)
  5591. }
  5592. return fields
  5593. }
  5594. // FieldCleared returns a boolean indicating if a field with the given name was
  5595. // cleared in this mutation.
  5596. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5597. _, ok := m.clearedFields[name]
  5598. return ok
  5599. }
  5600. // ClearField clears the value of the field with the given name. It returns an
  5601. // error if the field is not defined in the schema.
  5602. func (m *BatchMsgMutation) ClearField(name string) error {
  5603. switch name {
  5604. case batchmsg.FieldDeletedAt:
  5605. m.ClearDeletedAt()
  5606. return nil
  5607. case batchmsg.FieldStatus:
  5608. m.ClearStatus()
  5609. return nil
  5610. case batchmsg.FieldBatchNo:
  5611. m.ClearBatchNo()
  5612. return nil
  5613. case batchmsg.FieldTaskName:
  5614. m.ClearTaskName()
  5615. return nil
  5616. case batchmsg.FieldFromwxid:
  5617. m.ClearFromwxid()
  5618. return nil
  5619. case batchmsg.FieldMsg:
  5620. m.ClearMsg()
  5621. return nil
  5622. case batchmsg.FieldTag:
  5623. m.ClearTag()
  5624. return nil
  5625. case batchmsg.FieldTagids:
  5626. m.ClearTagids()
  5627. return nil
  5628. case batchmsg.FieldTotal:
  5629. m.ClearTotal()
  5630. return nil
  5631. case batchmsg.FieldSuccess:
  5632. m.ClearSuccess()
  5633. return nil
  5634. case batchmsg.FieldFail:
  5635. m.ClearFail()
  5636. return nil
  5637. case batchmsg.FieldStartTime:
  5638. m.ClearStartTime()
  5639. return nil
  5640. case batchmsg.FieldStopTime:
  5641. m.ClearStopTime()
  5642. return nil
  5643. case batchmsg.FieldSendTime:
  5644. m.ClearSendTime()
  5645. return nil
  5646. case batchmsg.FieldType:
  5647. m.ClearType()
  5648. return nil
  5649. case batchmsg.FieldCc:
  5650. m.ClearCc()
  5651. return nil
  5652. case batchmsg.FieldPhone:
  5653. m.ClearPhone()
  5654. return nil
  5655. }
  5656. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5657. }
  5658. // ResetField resets all changes in the mutation for the field with the given name.
  5659. // It returns an error if the field is not defined in the schema.
  5660. func (m *BatchMsgMutation) ResetField(name string) error {
  5661. switch name {
  5662. case batchmsg.FieldCreatedAt:
  5663. m.ResetCreatedAt()
  5664. return nil
  5665. case batchmsg.FieldUpdatedAt:
  5666. m.ResetUpdatedAt()
  5667. return nil
  5668. case batchmsg.FieldDeletedAt:
  5669. m.ResetDeletedAt()
  5670. return nil
  5671. case batchmsg.FieldStatus:
  5672. m.ResetStatus()
  5673. return nil
  5674. case batchmsg.FieldBatchNo:
  5675. m.ResetBatchNo()
  5676. return nil
  5677. case batchmsg.FieldTaskName:
  5678. m.ResetTaskName()
  5679. return nil
  5680. case batchmsg.FieldFromwxid:
  5681. m.ResetFromwxid()
  5682. return nil
  5683. case batchmsg.FieldMsg:
  5684. m.ResetMsg()
  5685. return nil
  5686. case batchmsg.FieldTag:
  5687. m.ResetTag()
  5688. return nil
  5689. case batchmsg.FieldTagids:
  5690. m.ResetTagids()
  5691. return nil
  5692. case batchmsg.FieldTotal:
  5693. m.ResetTotal()
  5694. return nil
  5695. case batchmsg.FieldSuccess:
  5696. m.ResetSuccess()
  5697. return nil
  5698. case batchmsg.FieldFail:
  5699. m.ResetFail()
  5700. return nil
  5701. case batchmsg.FieldStartTime:
  5702. m.ResetStartTime()
  5703. return nil
  5704. case batchmsg.FieldStopTime:
  5705. m.ResetStopTime()
  5706. return nil
  5707. case batchmsg.FieldSendTime:
  5708. m.ResetSendTime()
  5709. return nil
  5710. case batchmsg.FieldType:
  5711. m.ResetType()
  5712. return nil
  5713. case batchmsg.FieldOrganizationID:
  5714. m.ResetOrganizationID()
  5715. return nil
  5716. case batchmsg.FieldCtype:
  5717. m.ResetCtype()
  5718. return nil
  5719. case batchmsg.FieldCc:
  5720. m.ResetCc()
  5721. return nil
  5722. case batchmsg.FieldPhone:
  5723. m.ResetPhone()
  5724. return nil
  5725. }
  5726. return fmt.Errorf("unknown BatchMsg field %s", name)
  5727. }
  5728. // AddedEdges returns all edge names that were set/added in this mutation.
  5729. func (m *BatchMsgMutation) AddedEdges() []string {
  5730. edges := make([]string, 0, 0)
  5731. return edges
  5732. }
  5733. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5734. // name in this mutation.
  5735. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5736. return nil
  5737. }
  5738. // RemovedEdges returns all edge names that were removed in this mutation.
  5739. func (m *BatchMsgMutation) RemovedEdges() []string {
  5740. edges := make([]string, 0, 0)
  5741. return edges
  5742. }
  5743. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5744. // the given name in this mutation.
  5745. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5746. return nil
  5747. }
  5748. // ClearedEdges returns all edge names that were cleared in this mutation.
  5749. func (m *BatchMsgMutation) ClearedEdges() []string {
  5750. edges := make([]string, 0, 0)
  5751. return edges
  5752. }
  5753. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5754. // was cleared in this mutation.
  5755. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5756. return false
  5757. }
  5758. // ClearEdge clears the value of the edge with the given name. It returns an error
  5759. // if that edge is not defined in the schema.
  5760. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5761. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5762. }
  5763. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5764. // It returns an error if the edge is not defined in the schema.
  5765. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5766. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5767. }
  5768. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5769. type CategoryMutation struct {
  5770. config
  5771. op Op
  5772. typ string
  5773. id *uint64
  5774. created_at *time.Time
  5775. updated_at *time.Time
  5776. deleted_at *time.Time
  5777. name *string
  5778. organization_id *uint64
  5779. addorganization_id *int64
  5780. clearedFields map[string]struct{}
  5781. done bool
  5782. oldValue func(context.Context) (*Category, error)
  5783. predicates []predicate.Category
  5784. }
  5785. var _ ent.Mutation = (*CategoryMutation)(nil)
  5786. // categoryOption allows management of the mutation configuration using functional options.
  5787. type categoryOption func(*CategoryMutation)
  5788. // newCategoryMutation creates new mutation for the Category entity.
  5789. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5790. m := &CategoryMutation{
  5791. config: c,
  5792. op: op,
  5793. typ: TypeCategory,
  5794. clearedFields: make(map[string]struct{}),
  5795. }
  5796. for _, opt := range opts {
  5797. opt(m)
  5798. }
  5799. return m
  5800. }
  5801. // withCategoryID sets the ID field of the mutation.
  5802. func withCategoryID(id uint64) categoryOption {
  5803. return func(m *CategoryMutation) {
  5804. var (
  5805. err error
  5806. once sync.Once
  5807. value *Category
  5808. )
  5809. m.oldValue = func(ctx context.Context) (*Category, error) {
  5810. once.Do(func() {
  5811. if m.done {
  5812. err = errors.New("querying old values post mutation is not allowed")
  5813. } else {
  5814. value, err = m.Client().Category.Get(ctx, id)
  5815. }
  5816. })
  5817. return value, err
  5818. }
  5819. m.id = &id
  5820. }
  5821. }
  5822. // withCategory sets the old Category of the mutation.
  5823. func withCategory(node *Category) categoryOption {
  5824. return func(m *CategoryMutation) {
  5825. m.oldValue = func(context.Context) (*Category, error) {
  5826. return node, nil
  5827. }
  5828. m.id = &node.ID
  5829. }
  5830. }
  5831. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5832. // executed in a transaction (ent.Tx), a transactional client is returned.
  5833. func (m CategoryMutation) Client() *Client {
  5834. client := &Client{config: m.config}
  5835. client.init()
  5836. return client
  5837. }
  5838. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5839. // it returns an error otherwise.
  5840. func (m CategoryMutation) Tx() (*Tx, error) {
  5841. if _, ok := m.driver.(*txDriver); !ok {
  5842. return nil, errors.New("ent: mutation is not running in a transaction")
  5843. }
  5844. tx := &Tx{config: m.config}
  5845. tx.init()
  5846. return tx, nil
  5847. }
  5848. // SetID sets the value of the id field. Note that this
  5849. // operation is only accepted on creation of Category entities.
  5850. func (m *CategoryMutation) SetID(id uint64) {
  5851. m.id = &id
  5852. }
  5853. // ID returns the ID value in the mutation. Note that the ID is only available
  5854. // if it was provided to the builder or after it was returned from the database.
  5855. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5856. if m.id == nil {
  5857. return
  5858. }
  5859. return *m.id, true
  5860. }
  5861. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5862. // That means, if the mutation is applied within a transaction with an isolation level such
  5863. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5864. // or updated by the mutation.
  5865. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5866. switch {
  5867. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5868. id, exists := m.ID()
  5869. if exists {
  5870. return []uint64{id}, nil
  5871. }
  5872. fallthrough
  5873. case m.op.Is(OpUpdate | OpDelete):
  5874. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5875. default:
  5876. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5877. }
  5878. }
  5879. // SetCreatedAt sets the "created_at" field.
  5880. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5881. m.created_at = &t
  5882. }
  5883. // CreatedAt returns the value of the "created_at" field in the mutation.
  5884. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5885. v := m.created_at
  5886. if v == nil {
  5887. return
  5888. }
  5889. return *v, true
  5890. }
  5891. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5892. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5894. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5895. if !m.op.Is(OpUpdateOne) {
  5896. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5897. }
  5898. if m.id == nil || m.oldValue == nil {
  5899. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5900. }
  5901. oldValue, err := m.oldValue(ctx)
  5902. if err != nil {
  5903. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5904. }
  5905. return oldValue.CreatedAt, nil
  5906. }
  5907. // ResetCreatedAt resets all changes to the "created_at" field.
  5908. func (m *CategoryMutation) ResetCreatedAt() {
  5909. m.created_at = nil
  5910. }
  5911. // SetUpdatedAt sets the "updated_at" field.
  5912. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5913. m.updated_at = &t
  5914. }
  5915. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5916. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5917. v := m.updated_at
  5918. if v == nil {
  5919. return
  5920. }
  5921. return *v, true
  5922. }
  5923. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5924. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5926. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5927. if !m.op.Is(OpUpdateOne) {
  5928. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5929. }
  5930. if m.id == nil || m.oldValue == nil {
  5931. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5932. }
  5933. oldValue, err := m.oldValue(ctx)
  5934. if err != nil {
  5935. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5936. }
  5937. return oldValue.UpdatedAt, nil
  5938. }
  5939. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5940. func (m *CategoryMutation) ResetUpdatedAt() {
  5941. m.updated_at = nil
  5942. }
  5943. // SetDeletedAt sets the "deleted_at" field.
  5944. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5945. m.deleted_at = &t
  5946. }
  5947. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5948. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5949. v := m.deleted_at
  5950. if v == nil {
  5951. return
  5952. }
  5953. return *v, true
  5954. }
  5955. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5956. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5958. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5959. if !m.op.Is(OpUpdateOne) {
  5960. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5961. }
  5962. if m.id == nil || m.oldValue == nil {
  5963. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5964. }
  5965. oldValue, err := m.oldValue(ctx)
  5966. if err != nil {
  5967. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5968. }
  5969. return oldValue.DeletedAt, nil
  5970. }
  5971. // ClearDeletedAt clears the value of the "deleted_at" field.
  5972. func (m *CategoryMutation) ClearDeletedAt() {
  5973. m.deleted_at = nil
  5974. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5975. }
  5976. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5977. func (m *CategoryMutation) DeletedAtCleared() bool {
  5978. _, ok := m.clearedFields[category.FieldDeletedAt]
  5979. return ok
  5980. }
  5981. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5982. func (m *CategoryMutation) ResetDeletedAt() {
  5983. m.deleted_at = nil
  5984. delete(m.clearedFields, category.FieldDeletedAt)
  5985. }
  5986. // SetName sets the "name" field.
  5987. func (m *CategoryMutation) SetName(s string) {
  5988. m.name = &s
  5989. }
  5990. // Name returns the value of the "name" field in the mutation.
  5991. func (m *CategoryMutation) Name() (r string, exists bool) {
  5992. v := m.name
  5993. if v == nil {
  5994. return
  5995. }
  5996. return *v, true
  5997. }
  5998. // OldName returns the old "name" field's value of the Category entity.
  5999. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6001. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  6002. if !m.op.Is(OpUpdateOne) {
  6003. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6004. }
  6005. if m.id == nil || m.oldValue == nil {
  6006. return v, errors.New("OldName requires an ID field in the mutation")
  6007. }
  6008. oldValue, err := m.oldValue(ctx)
  6009. if err != nil {
  6010. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6011. }
  6012. return oldValue.Name, nil
  6013. }
  6014. // ResetName resets all changes to the "name" field.
  6015. func (m *CategoryMutation) ResetName() {
  6016. m.name = nil
  6017. }
  6018. // SetOrganizationID sets the "organization_id" field.
  6019. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  6020. m.organization_id = &u
  6021. m.addorganization_id = nil
  6022. }
  6023. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6024. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  6025. v := m.organization_id
  6026. if v == nil {
  6027. return
  6028. }
  6029. return *v, true
  6030. }
  6031. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  6032. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6034. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6035. if !m.op.Is(OpUpdateOne) {
  6036. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6037. }
  6038. if m.id == nil || m.oldValue == nil {
  6039. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6040. }
  6041. oldValue, err := m.oldValue(ctx)
  6042. if err != nil {
  6043. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6044. }
  6045. return oldValue.OrganizationID, nil
  6046. }
  6047. // AddOrganizationID adds u to the "organization_id" field.
  6048. func (m *CategoryMutation) AddOrganizationID(u int64) {
  6049. if m.addorganization_id != nil {
  6050. *m.addorganization_id += u
  6051. } else {
  6052. m.addorganization_id = &u
  6053. }
  6054. }
  6055. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6056. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  6057. v := m.addorganization_id
  6058. if v == nil {
  6059. return
  6060. }
  6061. return *v, true
  6062. }
  6063. // ResetOrganizationID resets all changes to the "organization_id" field.
  6064. func (m *CategoryMutation) ResetOrganizationID() {
  6065. m.organization_id = nil
  6066. m.addorganization_id = nil
  6067. }
  6068. // Where appends a list predicates to the CategoryMutation builder.
  6069. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  6070. m.predicates = append(m.predicates, ps...)
  6071. }
  6072. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  6073. // users can use type-assertion to append predicates that do not depend on any generated package.
  6074. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  6075. p := make([]predicate.Category, len(ps))
  6076. for i := range ps {
  6077. p[i] = ps[i]
  6078. }
  6079. m.Where(p...)
  6080. }
  6081. // Op returns the operation name.
  6082. func (m *CategoryMutation) Op() Op {
  6083. return m.op
  6084. }
  6085. // SetOp allows setting the mutation operation.
  6086. func (m *CategoryMutation) SetOp(op Op) {
  6087. m.op = op
  6088. }
  6089. // Type returns the node type of this mutation (Category).
  6090. func (m *CategoryMutation) Type() string {
  6091. return m.typ
  6092. }
  6093. // Fields returns all fields that were changed during this mutation. Note that in
  6094. // order to get all numeric fields that were incremented/decremented, call
  6095. // AddedFields().
  6096. func (m *CategoryMutation) Fields() []string {
  6097. fields := make([]string, 0, 5)
  6098. if m.created_at != nil {
  6099. fields = append(fields, category.FieldCreatedAt)
  6100. }
  6101. if m.updated_at != nil {
  6102. fields = append(fields, category.FieldUpdatedAt)
  6103. }
  6104. if m.deleted_at != nil {
  6105. fields = append(fields, category.FieldDeletedAt)
  6106. }
  6107. if m.name != nil {
  6108. fields = append(fields, category.FieldName)
  6109. }
  6110. if m.organization_id != nil {
  6111. fields = append(fields, category.FieldOrganizationID)
  6112. }
  6113. return fields
  6114. }
  6115. // Field returns the value of a field with the given name. The second boolean
  6116. // return value indicates that this field was not set, or was not defined in the
  6117. // schema.
  6118. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  6119. switch name {
  6120. case category.FieldCreatedAt:
  6121. return m.CreatedAt()
  6122. case category.FieldUpdatedAt:
  6123. return m.UpdatedAt()
  6124. case category.FieldDeletedAt:
  6125. return m.DeletedAt()
  6126. case category.FieldName:
  6127. return m.Name()
  6128. case category.FieldOrganizationID:
  6129. return m.OrganizationID()
  6130. }
  6131. return nil, false
  6132. }
  6133. // OldField returns the old value of the field from the database. An error is
  6134. // returned if the mutation operation is not UpdateOne, or the query to the
  6135. // database failed.
  6136. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6137. switch name {
  6138. case category.FieldCreatedAt:
  6139. return m.OldCreatedAt(ctx)
  6140. case category.FieldUpdatedAt:
  6141. return m.OldUpdatedAt(ctx)
  6142. case category.FieldDeletedAt:
  6143. return m.OldDeletedAt(ctx)
  6144. case category.FieldName:
  6145. return m.OldName(ctx)
  6146. case category.FieldOrganizationID:
  6147. return m.OldOrganizationID(ctx)
  6148. }
  6149. return nil, fmt.Errorf("unknown Category field %s", name)
  6150. }
  6151. // SetField sets the value of a field with the given name. It returns an error if
  6152. // the field is not defined in the schema, or if the type mismatched the field
  6153. // type.
  6154. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  6155. switch name {
  6156. case category.FieldCreatedAt:
  6157. v, ok := value.(time.Time)
  6158. if !ok {
  6159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6160. }
  6161. m.SetCreatedAt(v)
  6162. return nil
  6163. case category.FieldUpdatedAt:
  6164. v, ok := value.(time.Time)
  6165. if !ok {
  6166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6167. }
  6168. m.SetUpdatedAt(v)
  6169. return nil
  6170. case category.FieldDeletedAt:
  6171. v, ok := value.(time.Time)
  6172. if !ok {
  6173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6174. }
  6175. m.SetDeletedAt(v)
  6176. return nil
  6177. case category.FieldName:
  6178. v, ok := value.(string)
  6179. if !ok {
  6180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6181. }
  6182. m.SetName(v)
  6183. return nil
  6184. case category.FieldOrganizationID:
  6185. v, ok := value.(uint64)
  6186. if !ok {
  6187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6188. }
  6189. m.SetOrganizationID(v)
  6190. return nil
  6191. }
  6192. return fmt.Errorf("unknown Category field %s", name)
  6193. }
  6194. // AddedFields returns all numeric fields that were incremented/decremented during
  6195. // this mutation.
  6196. func (m *CategoryMutation) AddedFields() []string {
  6197. var fields []string
  6198. if m.addorganization_id != nil {
  6199. fields = append(fields, category.FieldOrganizationID)
  6200. }
  6201. return fields
  6202. }
  6203. // AddedField returns the numeric value that was incremented/decremented on a field
  6204. // with the given name. The second boolean return value indicates that this field
  6205. // was not set, or was not defined in the schema.
  6206. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  6207. switch name {
  6208. case category.FieldOrganizationID:
  6209. return m.AddedOrganizationID()
  6210. }
  6211. return nil, false
  6212. }
  6213. // AddField adds the value to the field with the given name. It returns an error if
  6214. // the field is not defined in the schema, or if the type mismatched the field
  6215. // type.
  6216. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  6217. switch name {
  6218. case category.FieldOrganizationID:
  6219. v, ok := value.(int64)
  6220. if !ok {
  6221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6222. }
  6223. m.AddOrganizationID(v)
  6224. return nil
  6225. }
  6226. return fmt.Errorf("unknown Category numeric field %s", name)
  6227. }
  6228. // ClearedFields returns all nullable fields that were cleared during this
  6229. // mutation.
  6230. func (m *CategoryMutation) ClearedFields() []string {
  6231. var fields []string
  6232. if m.FieldCleared(category.FieldDeletedAt) {
  6233. fields = append(fields, category.FieldDeletedAt)
  6234. }
  6235. return fields
  6236. }
  6237. // FieldCleared returns a boolean indicating if a field with the given name was
  6238. // cleared in this mutation.
  6239. func (m *CategoryMutation) FieldCleared(name string) bool {
  6240. _, ok := m.clearedFields[name]
  6241. return ok
  6242. }
  6243. // ClearField clears the value of the field with the given name. It returns an
  6244. // error if the field is not defined in the schema.
  6245. func (m *CategoryMutation) ClearField(name string) error {
  6246. switch name {
  6247. case category.FieldDeletedAt:
  6248. m.ClearDeletedAt()
  6249. return nil
  6250. }
  6251. return fmt.Errorf("unknown Category nullable field %s", name)
  6252. }
  6253. // ResetField resets all changes in the mutation for the field with the given name.
  6254. // It returns an error if the field is not defined in the schema.
  6255. func (m *CategoryMutation) ResetField(name string) error {
  6256. switch name {
  6257. case category.FieldCreatedAt:
  6258. m.ResetCreatedAt()
  6259. return nil
  6260. case category.FieldUpdatedAt:
  6261. m.ResetUpdatedAt()
  6262. return nil
  6263. case category.FieldDeletedAt:
  6264. m.ResetDeletedAt()
  6265. return nil
  6266. case category.FieldName:
  6267. m.ResetName()
  6268. return nil
  6269. case category.FieldOrganizationID:
  6270. m.ResetOrganizationID()
  6271. return nil
  6272. }
  6273. return fmt.Errorf("unknown Category field %s", name)
  6274. }
  6275. // AddedEdges returns all edge names that were set/added in this mutation.
  6276. func (m *CategoryMutation) AddedEdges() []string {
  6277. edges := make([]string, 0, 0)
  6278. return edges
  6279. }
  6280. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6281. // name in this mutation.
  6282. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  6283. return nil
  6284. }
  6285. // RemovedEdges returns all edge names that were removed in this mutation.
  6286. func (m *CategoryMutation) RemovedEdges() []string {
  6287. edges := make([]string, 0, 0)
  6288. return edges
  6289. }
  6290. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6291. // the given name in this mutation.
  6292. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  6293. return nil
  6294. }
  6295. // ClearedEdges returns all edge names that were cleared in this mutation.
  6296. func (m *CategoryMutation) ClearedEdges() []string {
  6297. edges := make([]string, 0, 0)
  6298. return edges
  6299. }
  6300. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6301. // was cleared in this mutation.
  6302. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6303. return false
  6304. }
  6305. // ClearEdge clears the value of the edge with the given name. It returns an error
  6306. // if that edge is not defined in the schema.
  6307. func (m *CategoryMutation) ClearEdge(name string) error {
  6308. return fmt.Errorf("unknown Category unique edge %s", name)
  6309. }
  6310. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6311. // It returns an error if the edge is not defined in the schema.
  6312. func (m *CategoryMutation) ResetEdge(name string) error {
  6313. return fmt.Errorf("unknown Category edge %s", name)
  6314. }
  6315. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6316. type ChatRecordsMutation struct {
  6317. config
  6318. op Op
  6319. typ string
  6320. id *uint64
  6321. created_at *time.Time
  6322. updated_at *time.Time
  6323. deleted_at *time.Time
  6324. content *string
  6325. content_type *uint8
  6326. addcontent_type *int8
  6327. session_id *uint64
  6328. addsession_id *int64
  6329. user_id *uint64
  6330. adduser_id *int64
  6331. bot_id *uint64
  6332. addbot_id *int64
  6333. bot_type *uint8
  6334. addbot_type *int8
  6335. clearedFields map[string]struct{}
  6336. done bool
  6337. oldValue func(context.Context) (*ChatRecords, error)
  6338. predicates []predicate.ChatRecords
  6339. }
  6340. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6341. // chatrecordsOption allows management of the mutation configuration using functional options.
  6342. type chatrecordsOption func(*ChatRecordsMutation)
  6343. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6344. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6345. m := &ChatRecordsMutation{
  6346. config: c,
  6347. op: op,
  6348. typ: TypeChatRecords,
  6349. clearedFields: make(map[string]struct{}),
  6350. }
  6351. for _, opt := range opts {
  6352. opt(m)
  6353. }
  6354. return m
  6355. }
  6356. // withChatRecordsID sets the ID field of the mutation.
  6357. func withChatRecordsID(id uint64) chatrecordsOption {
  6358. return func(m *ChatRecordsMutation) {
  6359. var (
  6360. err error
  6361. once sync.Once
  6362. value *ChatRecords
  6363. )
  6364. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6365. once.Do(func() {
  6366. if m.done {
  6367. err = errors.New("querying old values post mutation is not allowed")
  6368. } else {
  6369. value, err = m.Client().ChatRecords.Get(ctx, id)
  6370. }
  6371. })
  6372. return value, err
  6373. }
  6374. m.id = &id
  6375. }
  6376. }
  6377. // withChatRecords sets the old ChatRecords of the mutation.
  6378. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6379. return func(m *ChatRecordsMutation) {
  6380. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6381. return node, nil
  6382. }
  6383. m.id = &node.ID
  6384. }
  6385. }
  6386. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6387. // executed in a transaction (ent.Tx), a transactional client is returned.
  6388. func (m ChatRecordsMutation) Client() *Client {
  6389. client := &Client{config: m.config}
  6390. client.init()
  6391. return client
  6392. }
  6393. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6394. // it returns an error otherwise.
  6395. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6396. if _, ok := m.driver.(*txDriver); !ok {
  6397. return nil, errors.New("ent: mutation is not running in a transaction")
  6398. }
  6399. tx := &Tx{config: m.config}
  6400. tx.init()
  6401. return tx, nil
  6402. }
  6403. // SetID sets the value of the id field. Note that this
  6404. // operation is only accepted on creation of ChatRecords entities.
  6405. func (m *ChatRecordsMutation) SetID(id uint64) {
  6406. m.id = &id
  6407. }
  6408. // ID returns the ID value in the mutation. Note that the ID is only available
  6409. // if it was provided to the builder or after it was returned from the database.
  6410. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6411. if m.id == nil {
  6412. return
  6413. }
  6414. return *m.id, true
  6415. }
  6416. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6417. // That means, if the mutation is applied within a transaction with an isolation level such
  6418. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6419. // or updated by the mutation.
  6420. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6421. switch {
  6422. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6423. id, exists := m.ID()
  6424. if exists {
  6425. return []uint64{id}, nil
  6426. }
  6427. fallthrough
  6428. case m.op.Is(OpUpdate | OpDelete):
  6429. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6430. default:
  6431. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6432. }
  6433. }
  6434. // SetCreatedAt sets the "created_at" field.
  6435. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6436. m.created_at = &t
  6437. }
  6438. // CreatedAt returns the value of the "created_at" field in the mutation.
  6439. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6440. v := m.created_at
  6441. if v == nil {
  6442. return
  6443. }
  6444. return *v, true
  6445. }
  6446. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6447. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6449. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6450. if !m.op.Is(OpUpdateOne) {
  6451. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6452. }
  6453. if m.id == nil || m.oldValue == nil {
  6454. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6455. }
  6456. oldValue, err := m.oldValue(ctx)
  6457. if err != nil {
  6458. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6459. }
  6460. return oldValue.CreatedAt, nil
  6461. }
  6462. // ResetCreatedAt resets all changes to the "created_at" field.
  6463. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6464. m.created_at = nil
  6465. }
  6466. // SetUpdatedAt sets the "updated_at" field.
  6467. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6468. m.updated_at = &t
  6469. }
  6470. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6471. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6472. v := m.updated_at
  6473. if v == nil {
  6474. return
  6475. }
  6476. return *v, true
  6477. }
  6478. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6479. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6481. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6482. if !m.op.Is(OpUpdateOne) {
  6483. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6484. }
  6485. if m.id == nil || m.oldValue == nil {
  6486. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6487. }
  6488. oldValue, err := m.oldValue(ctx)
  6489. if err != nil {
  6490. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6491. }
  6492. return oldValue.UpdatedAt, nil
  6493. }
  6494. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6495. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6496. m.updated_at = nil
  6497. }
  6498. // SetDeletedAt sets the "deleted_at" field.
  6499. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6500. m.deleted_at = &t
  6501. }
  6502. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6503. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6504. v := m.deleted_at
  6505. if v == nil {
  6506. return
  6507. }
  6508. return *v, true
  6509. }
  6510. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6511. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6513. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6514. if !m.op.Is(OpUpdateOne) {
  6515. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6516. }
  6517. if m.id == nil || m.oldValue == nil {
  6518. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6519. }
  6520. oldValue, err := m.oldValue(ctx)
  6521. if err != nil {
  6522. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6523. }
  6524. return oldValue.DeletedAt, nil
  6525. }
  6526. // ClearDeletedAt clears the value of the "deleted_at" field.
  6527. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6528. m.deleted_at = nil
  6529. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6530. }
  6531. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6532. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6533. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6534. return ok
  6535. }
  6536. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6537. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6538. m.deleted_at = nil
  6539. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6540. }
  6541. // SetContent sets the "content" field.
  6542. func (m *ChatRecordsMutation) SetContent(s string) {
  6543. m.content = &s
  6544. }
  6545. // Content returns the value of the "content" field in the mutation.
  6546. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6547. v := m.content
  6548. if v == nil {
  6549. return
  6550. }
  6551. return *v, true
  6552. }
  6553. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6554. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6556. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6557. if !m.op.Is(OpUpdateOne) {
  6558. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6559. }
  6560. if m.id == nil || m.oldValue == nil {
  6561. return v, errors.New("OldContent requires an ID field in the mutation")
  6562. }
  6563. oldValue, err := m.oldValue(ctx)
  6564. if err != nil {
  6565. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6566. }
  6567. return oldValue.Content, nil
  6568. }
  6569. // ResetContent resets all changes to the "content" field.
  6570. func (m *ChatRecordsMutation) ResetContent() {
  6571. m.content = nil
  6572. }
  6573. // SetContentType sets the "content_type" field.
  6574. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6575. m.content_type = &u
  6576. m.addcontent_type = nil
  6577. }
  6578. // ContentType returns the value of the "content_type" field in the mutation.
  6579. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6580. v := m.content_type
  6581. if v == nil {
  6582. return
  6583. }
  6584. return *v, true
  6585. }
  6586. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6587. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6589. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6590. if !m.op.Is(OpUpdateOne) {
  6591. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6592. }
  6593. if m.id == nil || m.oldValue == nil {
  6594. return v, errors.New("OldContentType requires an ID field in the mutation")
  6595. }
  6596. oldValue, err := m.oldValue(ctx)
  6597. if err != nil {
  6598. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6599. }
  6600. return oldValue.ContentType, nil
  6601. }
  6602. // AddContentType adds u to the "content_type" field.
  6603. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6604. if m.addcontent_type != nil {
  6605. *m.addcontent_type += u
  6606. } else {
  6607. m.addcontent_type = &u
  6608. }
  6609. }
  6610. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6611. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6612. v := m.addcontent_type
  6613. if v == nil {
  6614. return
  6615. }
  6616. return *v, true
  6617. }
  6618. // ResetContentType resets all changes to the "content_type" field.
  6619. func (m *ChatRecordsMutation) ResetContentType() {
  6620. m.content_type = nil
  6621. m.addcontent_type = nil
  6622. }
  6623. // SetSessionID sets the "session_id" field.
  6624. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6625. m.session_id = &u
  6626. m.addsession_id = nil
  6627. }
  6628. // SessionID returns the value of the "session_id" field in the mutation.
  6629. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6630. v := m.session_id
  6631. if v == nil {
  6632. return
  6633. }
  6634. return *v, true
  6635. }
  6636. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6637. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6639. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6640. if !m.op.Is(OpUpdateOne) {
  6641. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6642. }
  6643. if m.id == nil || m.oldValue == nil {
  6644. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6645. }
  6646. oldValue, err := m.oldValue(ctx)
  6647. if err != nil {
  6648. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6649. }
  6650. return oldValue.SessionID, nil
  6651. }
  6652. // AddSessionID adds u to the "session_id" field.
  6653. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6654. if m.addsession_id != nil {
  6655. *m.addsession_id += u
  6656. } else {
  6657. m.addsession_id = &u
  6658. }
  6659. }
  6660. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6661. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6662. v := m.addsession_id
  6663. if v == nil {
  6664. return
  6665. }
  6666. return *v, true
  6667. }
  6668. // ResetSessionID resets all changes to the "session_id" field.
  6669. func (m *ChatRecordsMutation) ResetSessionID() {
  6670. m.session_id = nil
  6671. m.addsession_id = nil
  6672. }
  6673. // SetUserID sets the "user_id" field.
  6674. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6675. m.user_id = &u
  6676. m.adduser_id = nil
  6677. }
  6678. // UserID returns the value of the "user_id" field in the mutation.
  6679. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6680. v := m.user_id
  6681. if v == nil {
  6682. return
  6683. }
  6684. return *v, true
  6685. }
  6686. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6687. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6689. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6690. if !m.op.Is(OpUpdateOne) {
  6691. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6692. }
  6693. if m.id == nil || m.oldValue == nil {
  6694. return v, errors.New("OldUserID requires an ID field in the mutation")
  6695. }
  6696. oldValue, err := m.oldValue(ctx)
  6697. if err != nil {
  6698. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6699. }
  6700. return oldValue.UserID, nil
  6701. }
  6702. // AddUserID adds u to the "user_id" field.
  6703. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6704. if m.adduser_id != nil {
  6705. *m.adduser_id += u
  6706. } else {
  6707. m.adduser_id = &u
  6708. }
  6709. }
  6710. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6711. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6712. v := m.adduser_id
  6713. if v == nil {
  6714. return
  6715. }
  6716. return *v, true
  6717. }
  6718. // ResetUserID resets all changes to the "user_id" field.
  6719. func (m *ChatRecordsMutation) ResetUserID() {
  6720. m.user_id = nil
  6721. m.adduser_id = nil
  6722. }
  6723. // SetBotID sets the "bot_id" field.
  6724. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6725. m.bot_id = &u
  6726. m.addbot_id = nil
  6727. }
  6728. // BotID returns the value of the "bot_id" field in the mutation.
  6729. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6730. v := m.bot_id
  6731. if v == nil {
  6732. return
  6733. }
  6734. return *v, true
  6735. }
  6736. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6737. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6739. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6740. if !m.op.Is(OpUpdateOne) {
  6741. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6742. }
  6743. if m.id == nil || m.oldValue == nil {
  6744. return v, errors.New("OldBotID requires an ID field in the mutation")
  6745. }
  6746. oldValue, err := m.oldValue(ctx)
  6747. if err != nil {
  6748. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6749. }
  6750. return oldValue.BotID, nil
  6751. }
  6752. // AddBotID adds u to the "bot_id" field.
  6753. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6754. if m.addbot_id != nil {
  6755. *m.addbot_id += u
  6756. } else {
  6757. m.addbot_id = &u
  6758. }
  6759. }
  6760. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6761. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6762. v := m.addbot_id
  6763. if v == nil {
  6764. return
  6765. }
  6766. return *v, true
  6767. }
  6768. // ResetBotID resets all changes to the "bot_id" field.
  6769. func (m *ChatRecordsMutation) ResetBotID() {
  6770. m.bot_id = nil
  6771. m.addbot_id = nil
  6772. }
  6773. // SetBotType sets the "bot_type" field.
  6774. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6775. m.bot_type = &u
  6776. m.addbot_type = nil
  6777. }
  6778. // BotType returns the value of the "bot_type" field in the mutation.
  6779. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6780. v := m.bot_type
  6781. if v == nil {
  6782. return
  6783. }
  6784. return *v, true
  6785. }
  6786. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6787. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6789. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6790. if !m.op.Is(OpUpdateOne) {
  6791. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6792. }
  6793. if m.id == nil || m.oldValue == nil {
  6794. return v, errors.New("OldBotType requires an ID field in the mutation")
  6795. }
  6796. oldValue, err := m.oldValue(ctx)
  6797. if err != nil {
  6798. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6799. }
  6800. return oldValue.BotType, nil
  6801. }
  6802. // AddBotType adds u to the "bot_type" field.
  6803. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6804. if m.addbot_type != nil {
  6805. *m.addbot_type += u
  6806. } else {
  6807. m.addbot_type = &u
  6808. }
  6809. }
  6810. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6811. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6812. v := m.addbot_type
  6813. if v == nil {
  6814. return
  6815. }
  6816. return *v, true
  6817. }
  6818. // ResetBotType resets all changes to the "bot_type" field.
  6819. func (m *ChatRecordsMutation) ResetBotType() {
  6820. m.bot_type = nil
  6821. m.addbot_type = nil
  6822. }
  6823. // Where appends a list predicates to the ChatRecordsMutation builder.
  6824. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6825. m.predicates = append(m.predicates, ps...)
  6826. }
  6827. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6828. // users can use type-assertion to append predicates that do not depend on any generated package.
  6829. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6830. p := make([]predicate.ChatRecords, len(ps))
  6831. for i := range ps {
  6832. p[i] = ps[i]
  6833. }
  6834. m.Where(p...)
  6835. }
  6836. // Op returns the operation name.
  6837. func (m *ChatRecordsMutation) Op() Op {
  6838. return m.op
  6839. }
  6840. // SetOp allows setting the mutation operation.
  6841. func (m *ChatRecordsMutation) SetOp(op Op) {
  6842. m.op = op
  6843. }
  6844. // Type returns the node type of this mutation (ChatRecords).
  6845. func (m *ChatRecordsMutation) Type() string {
  6846. return m.typ
  6847. }
  6848. // Fields returns all fields that were changed during this mutation. Note that in
  6849. // order to get all numeric fields that were incremented/decremented, call
  6850. // AddedFields().
  6851. func (m *ChatRecordsMutation) Fields() []string {
  6852. fields := make([]string, 0, 9)
  6853. if m.created_at != nil {
  6854. fields = append(fields, chatrecords.FieldCreatedAt)
  6855. }
  6856. if m.updated_at != nil {
  6857. fields = append(fields, chatrecords.FieldUpdatedAt)
  6858. }
  6859. if m.deleted_at != nil {
  6860. fields = append(fields, chatrecords.FieldDeletedAt)
  6861. }
  6862. if m.content != nil {
  6863. fields = append(fields, chatrecords.FieldContent)
  6864. }
  6865. if m.content_type != nil {
  6866. fields = append(fields, chatrecords.FieldContentType)
  6867. }
  6868. if m.session_id != nil {
  6869. fields = append(fields, chatrecords.FieldSessionID)
  6870. }
  6871. if m.user_id != nil {
  6872. fields = append(fields, chatrecords.FieldUserID)
  6873. }
  6874. if m.bot_id != nil {
  6875. fields = append(fields, chatrecords.FieldBotID)
  6876. }
  6877. if m.bot_type != nil {
  6878. fields = append(fields, chatrecords.FieldBotType)
  6879. }
  6880. return fields
  6881. }
  6882. // Field returns the value of a field with the given name. The second boolean
  6883. // return value indicates that this field was not set, or was not defined in the
  6884. // schema.
  6885. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6886. switch name {
  6887. case chatrecords.FieldCreatedAt:
  6888. return m.CreatedAt()
  6889. case chatrecords.FieldUpdatedAt:
  6890. return m.UpdatedAt()
  6891. case chatrecords.FieldDeletedAt:
  6892. return m.DeletedAt()
  6893. case chatrecords.FieldContent:
  6894. return m.Content()
  6895. case chatrecords.FieldContentType:
  6896. return m.ContentType()
  6897. case chatrecords.FieldSessionID:
  6898. return m.SessionID()
  6899. case chatrecords.FieldUserID:
  6900. return m.UserID()
  6901. case chatrecords.FieldBotID:
  6902. return m.BotID()
  6903. case chatrecords.FieldBotType:
  6904. return m.BotType()
  6905. }
  6906. return nil, false
  6907. }
  6908. // OldField returns the old value of the field from the database. An error is
  6909. // returned if the mutation operation is not UpdateOne, or the query to the
  6910. // database failed.
  6911. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6912. switch name {
  6913. case chatrecords.FieldCreatedAt:
  6914. return m.OldCreatedAt(ctx)
  6915. case chatrecords.FieldUpdatedAt:
  6916. return m.OldUpdatedAt(ctx)
  6917. case chatrecords.FieldDeletedAt:
  6918. return m.OldDeletedAt(ctx)
  6919. case chatrecords.FieldContent:
  6920. return m.OldContent(ctx)
  6921. case chatrecords.FieldContentType:
  6922. return m.OldContentType(ctx)
  6923. case chatrecords.FieldSessionID:
  6924. return m.OldSessionID(ctx)
  6925. case chatrecords.FieldUserID:
  6926. return m.OldUserID(ctx)
  6927. case chatrecords.FieldBotID:
  6928. return m.OldBotID(ctx)
  6929. case chatrecords.FieldBotType:
  6930. return m.OldBotType(ctx)
  6931. }
  6932. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6933. }
  6934. // SetField sets the value of a field with the given name. It returns an error if
  6935. // the field is not defined in the schema, or if the type mismatched the field
  6936. // type.
  6937. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6938. switch name {
  6939. case chatrecords.FieldCreatedAt:
  6940. v, ok := value.(time.Time)
  6941. if !ok {
  6942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6943. }
  6944. m.SetCreatedAt(v)
  6945. return nil
  6946. case chatrecords.FieldUpdatedAt:
  6947. v, ok := value.(time.Time)
  6948. if !ok {
  6949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6950. }
  6951. m.SetUpdatedAt(v)
  6952. return nil
  6953. case chatrecords.FieldDeletedAt:
  6954. v, ok := value.(time.Time)
  6955. if !ok {
  6956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6957. }
  6958. m.SetDeletedAt(v)
  6959. return nil
  6960. case chatrecords.FieldContent:
  6961. v, ok := value.(string)
  6962. if !ok {
  6963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6964. }
  6965. m.SetContent(v)
  6966. return nil
  6967. case chatrecords.FieldContentType:
  6968. v, ok := value.(uint8)
  6969. if !ok {
  6970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6971. }
  6972. m.SetContentType(v)
  6973. return nil
  6974. case chatrecords.FieldSessionID:
  6975. v, ok := value.(uint64)
  6976. if !ok {
  6977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6978. }
  6979. m.SetSessionID(v)
  6980. return nil
  6981. case chatrecords.FieldUserID:
  6982. v, ok := value.(uint64)
  6983. if !ok {
  6984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6985. }
  6986. m.SetUserID(v)
  6987. return nil
  6988. case chatrecords.FieldBotID:
  6989. v, ok := value.(uint64)
  6990. if !ok {
  6991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6992. }
  6993. m.SetBotID(v)
  6994. return nil
  6995. case chatrecords.FieldBotType:
  6996. v, ok := value.(uint8)
  6997. if !ok {
  6998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6999. }
  7000. m.SetBotType(v)
  7001. return nil
  7002. }
  7003. return fmt.Errorf("unknown ChatRecords field %s", name)
  7004. }
  7005. // AddedFields returns all numeric fields that were incremented/decremented during
  7006. // this mutation.
  7007. func (m *ChatRecordsMutation) AddedFields() []string {
  7008. var fields []string
  7009. if m.addcontent_type != nil {
  7010. fields = append(fields, chatrecords.FieldContentType)
  7011. }
  7012. if m.addsession_id != nil {
  7013. fields = append(fields, chatrecords.FieldSessionID)
  7014. }
  7015. if m.adduser_id != nil {
  7016. fields = append(fields, chatrecords.FieldUserID)
  7017. }
  7018. if m.addbot_id != nil {
  7019. fields = append(fields, chatrecords.FieldBotID)
  7020. }
  7021. if m.addbot_type != nil {
  7022. fields = append(fields, chatrecords.FieldBotType)
  7023. }
  7024. return fields
  7025. }
  7026. // AddedField returns the numeric value that was incremented/decremented on a field
  7027. // with the given name. The second boolean return value indicates that this field
  7028. // was not set, or was not defined in the schema.
  7029. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  7030. switch name {
  7031. case chatrecords.FieldContentType:
  7032. return m.AddedContentType()
  7033. case chatrecords.FieldSessionID:
  7034. return m.AddedSessionID()
  7035. case chatrecords.FieldUserID:
  7036. return m.AddedUserID()
  7037. case chatrecords.FieldBotID:
  7038. return m.AddedBotID()
  7039. case chatrecords.FieldBotType:
  7040. return m.AddedBotType()
  7041. }
  7042. return nil, false
  7043. }
  7044. // AddField adds the value to the field with the given name. It returns an error if
  7045. // the field is not defined in the schema, or if the type mismatched the field
  7046. // type.
  7047. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  7048. switch name {
  7049. case chatrecords.FieldContentType:
  7050. v, ok := value.(int8)
  7051. if !ok {
  7052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7053. }
  7054. m.AddContentType(v)
  7055. return nil
  7056. case chatrecords.FieldSessionID:
  7057. v, ok := value.(int64)
  7058. if !ok {
  7059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7060. }
  7061. m.AddSessionID(v)
  7062. return nil
  7063. case chatrecords.FieldUserID:
  7064. v, ok := value.(int64)
  7065. if !ok {
  7066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7067. }
  7068. m.AddUserID(v)
  7069. return nil
  7070. case chatrecords.FieldBotID:
  7071. v, ok := value.(int64)
  7072. if !ok {
  7073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7074. }
  7075. m.AddBotID(v)
  7076. return nil
  7077. case chatrecords.FieldBotType:
  7078. v, ok := value.(int8)
  7079. if !ok {
  7080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7081. }
  7082. m.AddBotType(v)
  7083. return nil
  7084. }
  7085. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  7086. }
  7087. // ClearedFields returns all nullable fields that were cleared during this
  7088. // mutation.
  7089. func (m *ChatRecordsMutation) ClearedFields() []string {
  7090. var fields []string
  7091. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  7092. fields = append(fields, chatrecords.FieldDeletedAt)
  7093. }
  7094. return fields
  7095. }
  7096. // FieldCleared returns a boolean indicating if a field with the given name was
  7097. // cleared in this mutation.
  7098. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  7099. _, ok := m.clearedFields[name]
  7100. return ok
  7101. }
  7102. // ClearField clears the value of the field with the given name. It returns an
  7103. // error if the field is not defined in the schema.
  7104. func (m *ChatRecordsMutation) ClearField(name string) error {
  7105. switch name {
  7106. case chatrecords.FieldDeletedAt:
  7107. m.ClearDeletedAt()
  7108. return nil
  7109. }
  7110. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  7111. }
  7112. // ResetField resets all changes in the mutation for the field with the given name.
  7113. // It returns an error if the field is not defined in the schema.
  7114. func (m *ChatRecordsMutation) ResetField(name string) error {
  7115. switch name {
  7116. case chatrecords.FieldCreatedAt:
  7117. m.ResetCreatedAt()
  7118. return nil
  7119. case chatrecords.FieldUpdatedAt:
  7120. m.ResetUpdatedAt()
  7121. return nil
  7122. case chatrecords.FieldDeletedAt:
  7123. m.ResetDeletedAt()
  7124. return nil
  7125. case chatrecords.FieldContent:
  7126. m.ResetContent()
  7127. return nil
  7128. case chatrecords.FieldContentType:
  7129. m.ResetContentType()
  7130. return nil
  7131. case chatrecords.FieldSessionID:
  7132. m.ResetSessionID()
  7133. return nil
  7134. case chatrecords.FieldUserID:
  7135. m.ResetUserID()
  7136. return nil
  7137. case chatrecords.FieldBotID:
  7138. m.ResetBotID()
  7139. return nil
  7140. case chatrecords.FieldBotType:
  7141. m.ResetBotType()
  7142. return nil
  7143. }
  7144. return fmt.Errorf("unknown ChatRecords field %s", name)
  7145. }
  7146. // AddedEdges returns all edge names that were set/added in this mutation.
  7147. func (m *ChatRecordsMutation) AddedEdges() []string {
  7148. edges := make([]string, 0, 0)
  7149. return edges
  7150. }
  7151. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7152. // name in this mutation.
  7153. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  7154. return nil
  7155. }
  7156. // RemovedEdges returns all edge names that were removed in this mutation.
  7157. func (m *ChatRecordsMutation) RemovedEdges() []string {
  7158. edges := make([]string, 0, 0)
  7159. return edges
  7160. }
  7161. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7162. // the given name in this mutation.
  7163. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  7164. return nil
  7165. }
  7166. // ClearedEdges returns all edge names that were cleared in this mutation.
  7167. func (m *ChatRecordsMutation) ClearedEdges() []string {
  7168. edges := make([]string, 0, 0)
  7169. return edges
  7170. }
  7171. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7172. // was cleared in this mutation.
  7173. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  7174. return false
  7175. }
  7176. // ClearEdge clears the value of the edge with the given name. It returns an error
  7177. // if that edge is not defined in the schema.
  7178. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  7179. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  7180. }
  7181. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7182. // It returns an error if the edge is not defined in the schema.
  7183. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  7184. return fmt.Errorf("unknown ChatRecords edge %s", name)
  7185. }
  7186. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  7187. type ChatSessionMutation struct {
  7188. config
  7189. op Op
  7190. typ string
  7191. id *uint64
  7192. created_at *time.Time
  7193. updated_at *time.Time
  7194. deleted_at *time.Time
  7195. name *string
  7196. user_id *uint64
  7197. adduser_id *int64
  7198. bot_id *uint64
  7199. addbot_id *int64
  7200. bot_type *uint8
  7201. addbot_type *int8
  7202. clearedFields map[string]struct{}
  7203. done bool
  7204. oldValue func(context.Context) (*ChatSession, error)
  7205. predicates []predicate.ChatSession
  7206. }
  7207. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  7208. // chatsessionOption allows management of the mutation configuration using functional options.
  7209. type chatsessionOption func(*ChatSessionMutation)
  7210. // newChatSessionMutation creates new mutation for the ChatSession entity.
  7211. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  7212. m := &ChatSessionMutation{
  7213. config: c,
  7214. op: op,
  7215. typ: TypeChatSession,
  7216. clearedFields: make(map[string]struct{}),
  7217. }
  7218. for _, opt := range opts {
  7219. opt(m)
  7220. }
  7221. return m
  7222. }
  7223. // withChatSessionID sets the ID field of the mutation.
  7224. func withChatSessionID(id uint64) chatsessionOption {
  7225. return func(m *ChatSessionMutation) {
  7226. var (
  7227. err error
  7228. once sync.Once
  7229. value *ChatSession
  7230. )
  7231. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  7232. once.Do(func() {
  7233. if m.done {
  7234. err = errors.New("querying old values post mutation is not allowed")
  7235. } else {
  7236. value, err = m.Client().ChatSession.Get(ctx, id)
  7237. }
  7238. })
  7239. return value, err
  7240. }
  7241. m.id = &id
  7242. }
  7243. }
  7244. // withChatSession sets the old ChatSession of the mutation.
  7245. func withChatSession(node *ChatSession) chatsessionOption {
  7246. return func(m *ChatSessionMutation) {
  7247. m.oldValue = func(context.Context) (*ChatSession, error) {
  7248. return node, nil
  7249. }
  7250. m.id = &node.ID
  7251. }
  7252. }
  7253. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7254. // executed in a transaction (ent.Tx), a transactional client is returned.
  7255. func (m ChatSessionMutation) Client() *Client {
  7256. client := &Client{config: m.config}
  7257. client.init()
  7258. return client
  7259. }
  7260. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7261. // it returns an error otherwise.
  7262. func (m ChatSessionMutation) Tx() (*Tx, error) {
  7263. if _, ok := m.driver.(*txDriver); !ok {
  7264. return nil, errors.New("ent: mutation is not running in a transaction")
  7265. }
  7266. tx := &Tx{config: m.config}
  7267. tx.init()
  7268. return tx, nil
  7269. }
  7270. // SetID sets the value of the id field. Note that this
  7271. // operation is only accepted on creation of ChatSession entities.
  7272. func (m *ChatSessionMutation) SetID(id uint64) {
  7273. m.id = &id
  7274. }
  7275. // ID returns the ID value in the mutation. Note that the ID is only available
  7276. // if it was provided to the builder or after it was returned from the database.
  7277. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  7278. if m.id == nil {
  7279. return
  7280. }
  7281. return *m.id, true
  7282. }
  7283. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7284. // That means, if the mutation is applied within a transaction with an isolation level such
  7285. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7286. // or updated by the mutation.
  7287. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  7288. switch {
  7289. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7290. id, exists := m.ID()
  7291. if exists {
  7292. return []uint64{id}, nil
  7293. }
  7294. fallthrough
  7295. case m.op.Is(OpUpdate | OpDelete):
  7296. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7297. default:
  7298. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7299. }
  7300. }
  7301. // SetCreatedAt sets the "created_at" field.
  7302. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7303. m.created_at = &t
  7304. }
  7305. // CreatedAt returns the value of the "created_at" field in the mutation.
  7306. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7307. v := m.created_at
  7308. if v == nil {
  7309. return
  7310. }
  7311. return *v, true
  7312. }
  7313. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7314. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7316. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7317. if !m.op.Is(OpUpdateOne) {
  7318. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7319. }
  7320. if m.id == nil || m.oldValue == nil {
  7321. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7322. }
  7323. oldValue, err := m.oldValue(ctx)
  7324. if err != nil {
  7325. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7326. }
  7327. return oldValue.CreatedAt, nil
  7328. }
  7329. // ResetCreatedAt resets all changes to the "created_at" field.
  7330. func (m *ChatSessionMutation) ResetCreatedAt() {
  7331. m.created_at = nil
  7332. }
  7333. // SetUpdatedAt sets the "updated_at" field.
  7334. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7335. m.updated_at = &t
  7336. }
  7337. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7338. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7339. v := m.updated_at
  7340. if v == nil {
  7341. return
  7342. }
  7343. return *v, true
  7344. }
  7345. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7346. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7348. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7349. if !m.op.Is(OpUpdateOne) {
  7350. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7351. }
  7352. if m.id == nil || m.oldValue == nil {
  7353. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7354. }
  7355. oldValue, err := m.oldValue(ctx)
  7356. if err != nil {
  7357. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7358. }
  7359. return oldValue.UpdatedAt, nil
  7360. }
  7361. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7362. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7363. m.updated_at = nil
  7364. }
  7365. // SetDeletedAt sets the "deleted_at" field.
  7366. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7367. m.deleted_at = &t
  7368. }
  7369. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7370. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7371. v := m.deleted_at
  7372. if v == nil {
  7373. return
  7374. }
  7375. return *v, true
  7376. }
  7377. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7378. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7380. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7381. if !m.op.Is(OpUpdateOne) {
  7382. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7383. }
  7384. if m.id == nil || m.oldValue == nil {
  7385. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7386. }
  7387. oldValue, err := m.oldValue(ctx)
  7388. if err != nil {
  7389. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7390. }
  7391. return oldValue.DeletedAt, nil
  7392. }
  7393. // ClearDeletedAt clears the value of the "deleted_at" field.
  7394. func (m *ChatSessionMutation) ClearDeletedAt() {
  7395. m.deleted_at = nil
  7396. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7397. }
  7398. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7399. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7400. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7401. return ok
  7402. }
  7403. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7404. func (m *ChatSessionMutation) ResetDeletedAt() {
  7405. m.deleted_at = nil
  7406. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7407. }
  7408. // SetName sets the "name" field.
  7409. func (m *ChatSessionMutation) SetName(s string) {
  7410. m.name = &s
  7411. }
  7412. // Name returns the value of the "name" field in the mutation.
  7413. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7414. v := m.name
  7415. if v == nil {
  7416. return
  7417. }
  7418. return *v, true
  7419. }
  7420. // OldName returns the old "name" field's value of the ChatSession entity.
  7421. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7423. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7424. if !m.op.Is(OpUpdateOne) {
  7425. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7426. }
  7427. if m.id == nil || m.oldValue == nil {
  7428. return v, errors.New("OldName requires an ID field in the mutation")
  7429. }
  7430. oldValue, err := m.oldValue(ctx)
  7431. if err != nil {
  7432. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7433. }
  7434. return oldValue.Name, nil
  7435. }
  7436. // ResetName resets all changes to the "name" field.
  7437. func (m *ChatSessionMutation) ResetName() {
  7438. m.name = nil
  7439. }
  7440. // SetUserID sets the "user_id" field.
  7441. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7442. m.user_id = &u
  7443. m.adduser_id = nil
  7444. }
  7445. // UserID returns the value of the "user_id" field in the mutation.
  7446. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7447. v := m.user_id
  7448. if v == nil {
  7449. return
  7450. }
  7451. return *v, true
  7452. }
  7453. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7454. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7456. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7457. if !m.op.Is(OpUpdateOne) {
  7458. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7459. }
  7460. if m.id == nil || m.oldValue == nil {
  7461. return v, errors.New("OldUserID requires an ID field in the mutation")
  7462. }
  7463. oldValue, err := m.oldValue(ctx)
  7464. if err != nil {
  7465. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7466. }
  7467. return oldValue.UserID, nil
  7468. }
  7469. // AddUserID adds u to the "user_id" field.
  7470. func (m *ChatSessionMutation) AddUserID(u int64) {
  7471. if m.adduser_id != nil {
  7472. *m.adduser_id += u
  7473. } else {
  7474. m.adduser_id = &u
  7475. }
  7476. }
  7477. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7478. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7479. v := m.adduser_id
  7480. if v == nil {
  7481. return
  7482. }
  7483. return *v, true
  7484. }
  7485. // ResetUserID resets all changes to the "user_id" field.
  7486. func (m *ChatSessionMutation) ResetUserID() {
  7487. m.user_id = nil
  7488. m.adduser_id = nil
  7489. }
  7490. // SetBotID sets the "bot_id" field.
  7491. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7492. m.bot_id = &u
  7493. m.addbot_id = nil
  7494. }
  7495. // BotID returns the value of the "bot_id" field in the mutation.
  7496. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7497. v := m.bot_id
  7498. if v == nil {
  7499. return
  7500. }
  7501. return *v, true
  7502. }
  7503. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7504. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7506. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7507. if !m.op.Is(OpUpdateOne) {
  7508. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7509. }
  7510. if m.id == nil || m.oldValue == nil {
  7511. return v, errors.New("OldBotID requires an ID field in the mutation")
  7512. }
  7513. oldValue, err := m.oldValue(ctx)
  7514. if err != nil {
  7515. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7516. }
  7517. return oldValue.BotID, nil
  7518. }
  7519. // AddBotID adds u to the "bot_id" field.
  7520. func (m *ChatSessionMutation) AddBotID(u int64) {
  7521. if m.addbot_id != nil {
  7522. *m.addbot_id += u
  7523. } else {
  7524. m.addbot_id = &u
  7525. }
  7526. }
  7527. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7528. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7529. v := m.addbot_id
  7530. if v == nil {
  7531. return
  7532. }
  7533. return *v, true
  7534. }
  7535. // ResetBotID resets all changes to the "bot_id" field.
  7536. func (m *ChatSessionMutation) ResetBotID() {
  7537. m.bot_id = nil
  7538. m.addbot_id = nil
  7539. }
  7540. // SetBotType sets the "bot_type" field.
  7541. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7542. m.bot_type = &u
  7543. m.addbot_type = nil
  7544. }
  7545. // BotType returns the value of the "bot_type" field in the mutation.
  7546. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7547. v := m.bot_type
  7548. if v == nil {
  7549. return
  7550. }
  7551. return *v, true
  7552. }
  7553. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7554. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7556. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7557. if !m.op.Is(OpUpdateOne) {
  7558. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7559. }
  7560. if m.id == nil || m.oldValue == nil {
  7561. return v, errors.New("OldBotType requires an ID field in the mutation")
  7562. }
  7563. oldValue, err := m.oldValue(ctx)
  7564. if err != nil {
  7565. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7566. }
  7567. return oldValue.BotType, nil
  7568. }
  7569. // AddBotType adds u to the "bot_type" field.
  7570. func (m *ChatSessionMutation) AddBotType(u int8) {
  7571. if m.addbot_type != nil {
  7572. *m.addbot_type += u
  7573. } else {
  7574. m.addbot_type = &u
  7575. }
  7576. }
  7577. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7578. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7579. v := m.addbot_type
  7580. if v == nil {
  7581. return
  7582. }
  7583. return *v, true
  7584. }
  7585. // ResetBotType resets all changes to the "bot_type" field.
  7586. func (m *ChatSessionMutation) ResetBotType() {
  7587. m.bot_type = nil
  7588. m.addbot_type = nil
  7589. }
  7590. // Where appends a list predicates to the ChatSessionMutation builder.
  7591. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7592. m.predicates = append(m.predicates, ps...)
  7593. }
  7594. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7595. // users can use type-assertion to append predicates that do not depend on any generated package.
  7596. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7597. p := make([]predicate.ChatSession, len(ps))
  7598. for i := range ps {
  7599. p[i] = ps[i]
  7600. }
  7601. m.Where(p...)
  7602. }
  7603. // Op returns the operation name.
  7604. func (m *ChatSessionMutation) Op() Op {
  7605. return m.op
  7606. }
  7607. // SetOp allows setting the mutation operation.
  7608. func (m *ChatSessionMutation) SetOp(op Op) {
  7609. m.op = op
  7610. }
  7611. // Type returns the node type of this mutation (ChatSession).
  7612. func (m *ChatSessionMutation) Type() string {
  7613. return m.typ
  7614. }
  7615. // Fields returns all fields that were changed during this mutation. Note that in
  7616. // order to get all numeric fields that were incremented/decremented, call
  7617. // AddedFields().
  7618. func (m *ChatSessionMutation) Fields() []string {
  7619. fields := make([]string, 0, 7)
  7620. if m.created_at != nil {
  7621. fields = append(fields, chatsession.FieldCreatedAt)
  7622. }
  7623. if m.updated_at != nil {
  7624. fields = append(fields, chatsession.FieldUpdatedAt)
  7625. }
  7626. if m.deleted_at != nil {
  7627. fields = append(fields, chatsession.FieldDeletedAt)
  7628. }
  7629. if m.name != nil {
  7630. fields = append(fields, chatsession.FieldName)
  7631. }
  7632. if m.user_id != nil {
  7633. fields = append(fields, chatsession.FieldUserID)
  7634. }
  7635. if m.bot_id != nil {
  7636. fields = append(fields, chatsession.FieldBotID)
  7637. }
  7638. if m.bot_type != nil {
  7639. fields = append(fields, chatsession.FieldBotType)
  7640. }
  7641. return fields
  7642. }
  7643. // Field returns the value of a field with the given name. The second boolean
  7644. // return value indicates that this field was not set, or was not defined in the
  7645. // schema.
  7646. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7647. switch name {
  7648. case chatsession.FieldCreatedAt:
  7649. return m.CreatedAt()
  7650. case chatsession.FieldUpdatedAt:
  7651. return m.UpdatedAt()
  7652. case chatsession.FieldDeletedAt:
  7653. return m.DeletedAt()
  7654. case chatsession.FieldName:
  7655. return m.Name()
  7656. case chatsession.FieldUserID:
  7657. return m.UserID()
  7658. case chatsession.FieldBotID:
  7659. return m.BotID()
  7660. case chatsession.FieldBotType:
  7661. return m.BotType()
  7662. }
  7663. return nil, false
  7664. }
  7665. // OldField returns the old value of the field from the database. An error is
  7666. // returned if the mutation operation is not UpdateOne, or the query to the
  7667. // database failed.
  7668. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7669. switch name {
  7670. case chatsession.FieldCreatedAt:
  7671. return m.OldCreatedAt(ctx)
  7672. case chatsession.FieldUpdatedAt:
  7673. return m.OldUpdatedAt(ctx)
  7674. case chatsession.FieldDeletedAt:
  7675. return m.OldDeletedAt(ctx)
  7676. case chatsession.FieldName:
  7677. return m.OldName(ctx)
  7678. case chatsession.FieldUserID:
  7679. return m.OldUserID(ctx)
  7680. case chatsession.FieldBotID:
  7681. return m.OldBotID(ctx)
  7682. case chatsession.FieldBotType:
  7683. return m.OldBotType(ctx)
  7684. }
  7685. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7686. }
  7687. // SetField sets the value of a field with the given name. It returns an error if
  7688. // the field is not defined in the schema, or if the type mismatched the field
  7689. // type.
  7690. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7691. switch name {
  7692. case chatsession.FieldCreatedAt:
  7693. v, ok := value.(time.Time)
  7694. if !ok {
  7695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7696. }
  7697. m.SetCreatedAt(v)
  7698. return nil
  7699. case chatsession.FieldUpdatedAt:
  7700. v, ok := value.(time.Time)
  7701. if !ok {
  7702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7703. }
  7704. m.SetUpdatedAt(v)
  7705. return nil
  7706. case chatsession.FieldDeletedAt:
  7707. v, ok := value.(time.Time)
  7708. if !ok {
  7709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7710. }
  7711. m.SetDeletedAt(v)
  7712. return nil
  7713. case chatsession.FieldName:
  7714. v, ok := value.(string)
  7715. if !ok {
  7716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7717. }
  7718. m.SetName(v)
  7719. return nil
  7720. case chatsession.FieldUserID:
  7721. v, ok := value.(uint64)
  7722. if !ok {
  7723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7724. }
  7725. m.SetUserID(v)
  7726. return nil
  7727. case chatsession.FieldBotID:
  7728. v, ok := value.(uint64)
  7729. if !ok {
  7730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7731. }
  7732. m.SetBotID(v)
  7733. return nil
  7734. case chatsession.FieldBotType:
  7735. v, ok := value.(uint8)
  7736. if !ok {
  7737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7738. }
  7739. m.SetBotType(v)
  7740. return nil
  7741. }
  7742. return fmt.Errorf("unknown ChatSession field %s", name)
  7743. }
  7744. // AddedFields returns all numeric fields that were incremented/decremented during
  7745. // this mutation.
  7746. func (m *ChatSessionMutation) AddedFields() []string {
  7747. var fields []string
  7748. if m.adduser_id != nil {
  7749. fields = append(fields, chatsession.FieldUserID)
  7750. }
  7751. if m.addbot_id != nil {
  7752. fields = append(fields, chatsession.FieldBotID)
  7753. }
  7754. if m.addbot_type != nil {
  7755. fields = append(fields, chatsession.FieldBotType)
  7756. }
  7757. return fields
  7758. }
  7759. // AddedField returns the numeric value that was incremented/decremented on a field
  7760. // with the given name. The second boolean return value indicates that this field
  7761. // was not set, or was not defined in the schema.
  7762. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7763. switch name {
  7764. case chatsession.FieldUserID:
  7765. return m.AddedUserID()
  7766. case chatsession.FieldBotID:
  7767. return m.AddedBotID()
  7768. case chatsession.FieldBotType:
  7769. return m.AddedBotType()
  7770. }
  7771. return nil, false
  7772. }
  7773. // AddField adds the value to the field with the given name. It returns an error if
  7774. // the field is not defined in the schema, or if the type mismatched the field
  7775. // type.
  7776. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7777. switch name {
  7778. case chatsession.FieldUserID:
  7779. v, ok := value.(int64)
  7780. if !ok {
  7781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7782. }
  7783. m.AddUserID(v)
  7784. return nil
  7785. case chatsession.FieldBotID:
  7786. v, ok := value.(int64)
  7787. if !ok {
  7788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7789. }
  7790. m.AddBotID(v)
  7791. return nil
  7792. case chatsession.FieldBotType:
  7793. v, ok := value.(int8)
  7794. if !ok {
  7795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7796. }
  7797. m.AddBotType(v)
  7798. return nil
  7799. }
  7800. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7801. }
  7802. // ClearedFields returns all nullable fields that were cleared during this
  7803. // mutation.
  7804. func (m *ChatSessionMutation) ClearedFields() []string {
  7805. var fields []string
  7806. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7807. fields = append(fields, chatsession.FieldDeletedAt)
  7808. }
  7809. return fields
  7810. }
  7811. // FieldCleared returns a boolean indicating if a field with the given name was
  7812. // cleared in this mutation.
  7813. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7814. _, ok := m.clearedFields[name]
  7815. return ok
  7816. }
  7817. // ClearField clears the value of the field with the given name. It returns an
  7818. // error if the field is not defined in the schema.
  7819. func (m *ChatSessionMutation) ClearField(name string) error {
  7820. switch name {
  7821. case chatsession.FieldDeletedAt:
  7822. m.ClearDeletedAt()
  7823. return nil
  7824. }
  7825. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7826. }
  7827. // ResetField resets all changes in the mutation for the field with the given name.
  7828. // It returns an error if the field is not defined in the schema.
  7829. func (m *ChatSessionMutation) ResetField(name string) error {
  7830. switch name {
  7831. case chatsession.FieldCreatedAt:
  7832. m.ResetCreatedAt()
  7833. return nil
  7834. case chatsession.FieldUpdatedAt:
  7835. m.ResetUpdatedAt()
  7836. return nil
  7837. case chatsession.FieldDeletedAt:
  7838. m.ResetDeletedAt()
  7839. return nil
  7840. case chatsession.FieldName:
  7841. m.ResetName()
  7842. return nil
  7843. case chatsession.FieldUserID:
  7844. m.ResetUserID()
  7845. return nil
  7846. case chatsession.FieldBotID:
  7847. m.ResetBotID()
  7848. return nil
  7849. case chatsession.FieldBotType:
  7850. m.ResetBotType()
  7851. return nil
  7852. }
  7853. return fmt.Errorf("unknown ChatSession field %s", name)
  7854. }
  7855. // AddedEdges returns all edge names that were set/added in this mutation.
  7856. func (m *ChatSessionMutation) AddedEdges() []string {
  7857. edges := make([]string, 0, 0)
  7858. return edges
  7859. }
  7860. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7861. // name in this mutation.
  7862. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7863. return nil
  7864. }
  7865. // RemovedEdges returns all edge names that were removed in this mutation.
  7866. func (m *ChatSessionMutation) RemovedEdges() []string {
  7867. edges := make([]string, 0, 0)
  7868. return edges
  7869. }
  7870. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7871. // the given name in this mutation.
  7872. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7873. return nil
  7874. }
  7875. // ClearedEdges returns all edge names that were cleared in this mutation.
  7876. func (m *ChatSessionMutation) ClearedEdges() []string {
  7877. edges := make([]string, 0, 0)
  7878. return edges
  7879. }
  7880. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7881. // was cleared in this mutation.
  7882. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7883. return false
  7884. }
  7885. // ClearEdge clears the value of the edge with the given name. It returns an error
  7886. // if that edge is not defined in the schema.
  7887. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7888. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7889. }
  7890. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7891. // It returns an error if the edge is not defined in the schema.
  7892. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7893. return fmt.Errorf("unknown ChatSession edge %s", name)
  7894. }
  7895. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7896. type ContactMutation struct {
  7897. config
  7898. op Op
  7899. typ string
  7900. id *uint64
  7901. created_at *time.Time
  7902. updated_at *time.Time
  7903. status *uint8
  7904. addstatus *int8
  7905. deleted_at *time.Time
  7906. wx_wxid *string
  7907. _type *int
  7908. add_type *int
  7909. wxid *string
  7910. account *string
  7911. nickname *string
  7912. markname *string
  7913. headimg *string
  7914. sex *int
  7915. addsex *int
  7916. starrole *string
  7917. dontseeit *int
  7918. adddontseeit *int
  7919. dontseeme *int
  7920. adddontseeme *int
  7921. lag *string
  7922. gid *string
  7923. gname *string
  7924. v3 *string
  7925. organization_id *uint64
  7926. addorganization_id *int64
  7927. ctype *uint64
  7928. addctype *int64
  7929. csex *int
  7930. addcsex *int
  7931. cage *int
  7932. addcage *int
  7933. cname *string
  7934. carea *string
  7935. cmobile *string
  7936. cbirthday *string
  7937. cbirtharea *string
  7938. cidcard_no *string
  7939. ctitle *string
  7940. cc *string
  7941. phone *string
  7942. clearedFields map[string]struct{}
  7943. contact_relationships map[uint64]struct{}
  7944. removedcontact_relationships map[uint64]struct{}
  7945. clearedcontact_relationships bool
  7946. contact_messages map[uint64]struct{}
  7947. removedcontact_messages map[uint64]struct{}
  7948. clearedcontact_messages bool
  7949. done bool
  7950. oldValue func(context.Context) (*Contact, error)
  7951. predicates []predicate.Contact
  7952. }
  7953. var _ ent.Mutation = (*ContactMutation)(nil)
  7954. // contactOption allows management of the mutation configuration using functional options.
  7955. type contactOption func(*ContactMutation)
  7956. // newContactMutation creates new mutation for the Contact entity.
  7957. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7958. m := &ContactMutation{
  7959. config: c,
  7960. op: op,
  7961. typ: TypeContact,
  7962. clearedFields: make(map[string]struct{}),
  7963. }
  7964. for _, opt := range opts {
  7965. opt(m)
  7966. }
  7967. return m
  7968. }
  7969. // withContactID sets the ID field of the mutation.
  7970. func withContactID(id uint64) contactOption {
  7971. return func(m *ContactMutation) {
  7972. var (
  7973. err error
  7974. once sync.Once
  7975. value *Contact
  7976. )
  7977. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7978. once.Do(func() {
  7979. if m.done {
  7980. err = errors.New("querying old values post mutation is not allowed")
  7981. } else {
  7982. value, err = m.Client().Contact.Get(ctx, id)
  7983. }
  7984. })
  7985. return value, err
  7986. }
  7987. m.id = &id
  7988. }
  7989. }
  7990. // withContact sets the old Contact of the mutation.
  7991. func withContact(node *Contact) contactOption {
  7992. return func(m *ContactMutation) {
  7993. m.oldValue = func(context.Context) (*Contact, error) {
  7994. return node, nil
  7995. }
  7996. m.id = &node.ID
  7997. }
  7998. }
  7999. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8000. // executed in a transaction (ent.Tx), a transactional client is returned.
  8001. func (m ContactMutation) Client() *Client {
  8002. client := &Client{config: m.config}
  8003. client.init()
  8004. return client
  8005. }
  8006. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8007. // it returns an error otherwise.
  8008. func (m ContactMutation) Tx() (*Tx, error) {
  8009. if _, ok := m.driver.(*txDriver); !ok {
  8010. return nil, errors.New("ent: mutation is not running in a transaction")
  8011. }
  8012. tx := &Tx{config: m.config}
  8013. tx.init()
  8014. return tx, nil
  8015. }
  8016. // SetID sets the value of the id field. Note that this
  8017. // operation is only accepted on creation of Contact entities.
  8018. func (m *ContactMutation) SetID(id uint64) {
  8019. m.id = &id
  8020. }
  8021. // ID returns the ID value in the mutation. Note that the ID is only available
  8022. // if it was provided to the builder or after it was returned from the database.
  8023. func (m *ContactMutation) ID() (id uint64, exists bool) {
  8024. if m.id == nil {
  8025. return
  8026. }
  8027. return *m.id, true
  8028. }
  8029. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8030. // That means, if the mutation is applied within a transaction with an isolation level such
  8031. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8032. // or updated by the mutation.
  8033. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  8034. switch {
  8035. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8036. id, exists := m.ID()
  8037. if exists {
  8038. return []uint64{id}, nil
  8039. }
  8040. fallthrough
  8041. case m.op.Is(OpUpdate | OpDelete):
  8042. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  8043. default:
  8044. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8045. }
  8046. }
  8047. // SetCreatedAt sets the "created_at" field.
  8048. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  8049. m.created_at = &t
  8050. }
  8051. // CreatedAt returns the value of the "created_at" field in the mutation.
  8052. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  8053. v := m.created_at
  8054. if v == nil {
  8055. return
  8056. }
  8057. return *v, true
  8058. }
  8059. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  8060. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8062. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8063. if !m.op.Is(OpUpdateOne) {
  8064. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8065. }
  8066. if m.id == nil || m.oldValue == nil {
  8067. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8068. }
  8069. oldValue, err := m.oldValue(ctx)
  8070. if err != nil {
  8071. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8072. }
  8073. return oldValue.CreatedAt, nil
  8074. }
  8075. // ResetCreatedAt resets all changes to the "created_at" field.
  8076. func (m *ContactMutation) ResetCreatedAt() {
  8077. m.created_at = nil
  8078. }
  8079. // SetUpdatedAt sets the "updated_at" field.
  8080. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  8081. m.updated_at = &t
  8082. }
  8083. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8084. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  8085. v := m.updated_at
  8086. if v == nil {
  8087. return
  8088. }
  8089. return *v, true
  8090. }
  8091. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  8092. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8094. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8095. if !m.op.Is(OpUpdateOne) {
  8096. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8097. }
  8098. if m.id == nil || m.oldValue == nil {
  8099. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8100. }
  8101. oldValue, err := m.oldValue(ctx)
  8102. if err != nil {
  8103. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8104. }
  8105. return oldValue.UpdatedAt, nil
  8106. }
  8107. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8108. func (m *ContactMutation) ResetUpdatedAt() {
  8109. m.updated_at = nil
  8110. }
  8111. // SetStatus sets the "status" field.
  8112. func (m *ContactMutation) SetStatus(u uint8) {
  8113. m.status = &u
  8114. m.addstatus = nil
  8115. }
  8116. // Status returns the value of the "status" field in the mutation.
  8117. func (m *ContactMutation) Status() (r uint8, exists bool) {
  8118. v := m.status
  8119. if v == nil {
  8120. return
  8121. }
  8122. return *v, true
  8123. }
  8124. // OldStatus returns the old "status" 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) OldStatus(ctx context.Context) (v uint8, err error) {
  8128. if !m.op.Is(OpUpdateOne) {
  8129. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8130. }
  8131. if m.id == nil || m.oldValue == nil {
  8132. return v, errors.New("OldStatus 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 OldStatus: %w", err)
  8137. }
  8138. return oldValue.Status, nil
  8139. }
  8140. // AddStatus adds u to the "status" field.
  8141. func (m *ContactMutation) AddStatus(u int8) {
  8142. if m.addstatus != nil {
  8143. *m.addstatus += u
  8144. } else {
  8145. m.addstatus = &u
  8146. }
  8147. }
  8148. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8149. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  8150. v := m.addstatus
  8151. if v == nil {
  8152. return
  8153. }
  8154. return *v, true
  8155. }
  8156. // ClearStatus clears the value of the "status" field.
  8157. func (m *ContactMutation) ClearStatus() {
  8158. m.status = nil
  8159. m.addstatus = nil
  8160. m.clearedFields[contact.FieldStatus] = struct{}{}
  8161. }
  8162. // StatusCleared returns if the "status" field was cleared in this mutation.
  8163. func (m *ContactMutation) StatusCleared() bool {
  8164. _, ok := m.clearedFields[contact.FieldStatus]
  8165. return ok
  8166. }
  8167. // ResetStatus resets all changes to the "status" field.
  8168. func (m *ContactMutation) ResetStatus() {
  8169. m.status = nil
  8170. m.addstatus = nil
  8171. delete(m.clearedFields, contact.FieldStatus)
  8172. }
  8173. // SetDeletedAt sets the "deleted_at" field.
  8174. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  8175. m.deleted_at = &t
  8176. }
  8177. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8178. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  8179. v := m.deleted_at
  8180. if v == nil {
  8181. return
  8182. }
  8183. return *v, true
  8184. }
  8185. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  8186. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8188. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8189. if !m.op.Is(OpUpdateOne) {
  8190. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8191. }
  8192. if m.id == nil || m.oldValue == nil {
  8193. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8194. }
  8195. oldValue, err := m.oldValue(ctx)
  8196. if err != nil {
  8197. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8198. }
  8199. return oldValue.DeletedAt, nil
  8200. }
  8201. // ClearDeletedAt clears the value of the "deleted_at" field.
  8202. func (m *ContactMutation) ClearDeletedAt() {
  8203. m.deleted_at = nil
  8204. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  8205. }
  8206. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8207. func (m *ContactMutation) DeletedAtCleared() bool {
  8208. _, ok := m.clearedFields[contact.FieldDeletedAt]
  8209. return ok
  8210. }
  8211. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8212. func (m *ContactMutation) ResetDeletedAt() {
  8213. m.deleted_at = nil
  8214. delete(m.clearedFields, contact.FieldDeletedAt)
  8215. }
  8216. // SetWxWxid sets the "wx_wxid" field.
  8217. func (m *ContactMutation) SetWxWxid(s string) {
  8218. m.wx_wxid = &s
  8219. }
  8220. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  8221. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  8222. v := m.wx_wxid
  8223. if v == nil {
  8224. return
  8225. }
  8226. return *v, true
  8227. }
  8228. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  8229. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8231. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8232. if !m.op.Is(OpUpdateOne) {
  8233. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8234. }
  8235. if m.id == nil || m.oldValue == nil {
  8236. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8237. }
  8238. oldValue, err := m.oldValue(ctx)
  8239. if err != nil {
  8240. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8241. }
  8242. return oldValue.WxWxid, nil
  8243. }
  8244. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8245. func (m *ContactMutation) ResetWxWxid() {
  8246. m.wx_wxid = nil
  8247. }
  8248. // SetType sets the "type" field.
  8249. func (m *ContactMutation) SetType(i int) {
  8250. m._type = &i
  8251. m.add_type = nil
  8252. }
  8253. // GetType returns the value of the "type" field in the mutation.
  8254. func (m *ContactMutation) GetType() (r int, exists bool) {
  8255. v := m._type
  8256. if v == nil {
  8257. return
  8258. }
  8259. return *v, true
  8260. }
  8261. // OldType returns the old "type" field's value of the Contact entity.
  8262. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8264. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  8265. if !m.op.Is(OpUpdateOne) {
  8266. return v, errors.New("OldType is only allowed on UpdateOne operations")
  8267. }
  8268. if m.id == nil || m.oldValue == nil {
  8269. return v, errors.New("OldType requires an ID field in the mutation")
  8270. }
  8271. oldValue, err := m.oldValue(ctx)
  8272. if err != nil {
  8273. return v, fmt.Errorf("querying old value for OldType: %w", err)
  8274. }
  8275. return oldValue.Type, nil
  8276. }
  8277. // AddType adds i to the "type" field.
  8278. func (m *ContactMutation) AddType(i int) {
  8279. if m.add_type != nil {
  8280. *m.add_type += i
  8281. } else {
  8282. m.add_type = &i
  8283. }
  8284. }
  8285. // AddedType returns the value that was added to the "type" field in this mutation.
  8286. func (m *ContactMutation) AddedType() (r int, exists bool) {
  8287. v := m.add_type
  8288. if v == nil {
  8289. return
  8290. }
  8291. return *v, true
  8292. }
  8293. // ClearType clears the value of the "type" field.
  8294. func (m *ContactMutation) ClearType() {
  8295. m._type = nil
  8296. m.add_type = nil
  8297. m.clearedFields[contact.FieldType] = struct{}{}
  8298. }
  8299. // TypeCleared returns if the "type" field was cleared in this mutation.
  8300. func (m *ContactMutation) TypeCleared() bool {
  8301. _, ok := m.clearedFields[contact.FieldType]
  8302. return ok
  8303. }
  8304. // ResetType resets all changes to the "type" field.
  8305. func (m *ContactMutation) ResetType() {
  8306. m._type = nil
  8307. m.add_type = nil
  8308. delete(m.clearedFields, contact.FieldType)
  8309. }
  8310. // SetWxid sets the "wxid" field.
  8311. func (m *ContactMutation) SetWxid(s string) {
  8312. m.wxid = &s
  8313. }
  8314. // Wxid returns the value of the "wxid" field in the mutation.
  8315. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8316. v := m.wxid
  8317. if v == nil {
  8318. return
  8319. }
  8320. return *v, true
  8321. }
  8322. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8323. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8325. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8326. if !m.op.Is(OpUpdateOne) {
  8327. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8328. }
  8329. if m.id == nil || m.oldValue == nil {
  8330. return v, errors.New("OldWxid requires an ID field in the mutation")
  8331. }
  8332. oldValue, err := m.oldValue(ctx)
  8333. if err != nil {
  8334. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8335. }
  8336. return oldValue.Wxid, nil
  8337. }
  8338. // ResetWxid resets all changes to the "wxid" field.
  8339. func (m *ContactMutation) ResetWxid() {
  8340. m.wxid = nil
  8341. }
  8342. // SetAccount sets the "account" field.
  8343. func (m *ContactMutation) SetAccount(s string) {
  8344. m.account = &s
  8345. }
  8346. // Account returns the value of the "account" field in the mutation.
  8347. func (m *ContactMutation) Account() (r string, exists bool) {
  8348. v := m.account
  8349. if v == nil {
  8350. return
  8351. }
  8352. return *v, true
  8353. }
  8354. // OldAccount returns the old "account" field's value of the Contact entity.
  8355. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8357. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8358. if !m.op.Is(OpUpdateOne) {
  8359. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8360. }
  8361. if m.id == nil || m.oldValue == nil {
  8362. return v, errors.New("OldAccount requires an ID field in the mutation")
  8363. }
  8364. oldValue, err := m.oldValue(ctx)
  8365. if err != nil {
  8366. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8367. }
  8368. return oldValue.Account, nil
  8369. }
  8370. // ResetAccount resets all changes to the "account" field.
  8371. func (m *ContactMutation) ResetAccount() {
  8372. m.account = nil
  8373. }
  8374. // SetNickname sets the "nickname" field.
  8375. func (m *ContactMutation) SetNickname(s string) {
  8376. m.nickname = &s
  8377. }
  8378. // Nickname returns the value of the "nickname" field in the mutation.
  8379. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8380. v := m.nickname
  8381. if v == nil {
  8382. return
  8383. }
  8384. return *v, true
  8385. }
  8386. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8387. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8389. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8390. if !m.op.Is(OpUpdateOne) {
  8391. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8392. }
  8393. if m.id == nil || m.oldValue == nil {
  8394. return v, errors.New("OldNickname requires an ID field in the mutation")
  8395. }
  8396. oldValue, err := m.oldValue(ctx)
  8397. if err != nil {
  8398. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8399. }
  8400. return oldValue.Nickname, nil
  8401. }
  8402. // ResetNickname resets all changes to the "nickname" field.
  8403. func (m *ContactMutation) ResetNickname() {
  8404. m.nickname = nil
  8405. }
  8406. // SetMarkname sets the "markname" field.
  8407. func (m *ContactMutation) SetMarkname(s string) {
  8408. m.markname = &s
  8409. }
  8410. // Markname returns the value of the "markname" field in the mutation.
  8411. func (m *ContactMutation) Markname() (r string, exists bool) {
  8412. v := m.markname
  8413. if v == nil {
  8414. return
  8415. }
  8416. return *v, true
  8417. }
  8418. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8419. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8421. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8422. if !m.op.Is(OpUpdateOne) {
  8423. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8424. }
  8425. if m.id == nil || m.oldValue == nil {
  8426. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8427. }
  8428. oldValue, err := m.oldValue(ctx)
  8429. if err != nil {
  8430. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8431. }
  8432. return oldValue.Markname, nil
  8433. }
  8434. // ResetMarkname resets all changes to the "markname" field.
  8435. func (m *ContactMutation) ResetMarkname() {
  8436. m.markname = nil
  8437. }
  8438. // SetHeadimg sets the "headimg" field.
  8439. func (m *ContactMutation) SetHeadimg(s string) {
  8440. m.headimg = &s
  8441. }
  8442. // Headimg returns the value of the "headimg" field in the mutation.
  8443. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8444. v := m.headimg
  8445. if v == nil {
  8446. return
  8447. }
  8448. return *v, true
  8449. }
  8450. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8451. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8453. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8454. if !m.op.Is(OpUpdateOne) {
  8455. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8456. }
  8457. if m.id == nil || m.oldValue == nil {
  8458. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8459. }
  8460. oldValue, err := m.oldValue(ctx)
  8461. if err != nil {
  8462. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8463. }
  8464. return oldValue.Headimg, nil
  8465. }
  8466. // ResetHeadimg resets all changes to the "headimg" field.
  8467. func (m *ContactMutation) ResetHeadimg() {
  8468. m.headimg = nil
  8469. }
  8470. // SetSex sets the "sex" field.
  8471. func (m *ContactMutation) SetSex(i int) {
  8472. m.sex = &i
  8473. m.addsex = nil
  8474. }
  8475. // Sex returns the value of the "sex" field in the mutation.
  8476. func (m *ContactMutation) Sex() (r int, exists bool) {
  8477. v := m.sex
  8478. if v == nil {
  8479. return
  8480. }
  8481. return *v, true
  8482. }
  8483. // OldSex returns the old "sex" field's value of the Contact entity.
  8484. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8486. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8487. if !m.op.Is(OpUpdateOne) {
  8488. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8489. }
  8490. if m.id == nil || m.oldValue == nil {
  8491. return v, errors.New("OldSex requires an ID field in the mutation")
  8492. }
  8493. oldValue, err := m.oldValue(ctx)
  8494. if err != nil {
  8495. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8496. }
  8497. return oldValue.Sex, nil
  8498. }
  8499. // AddSex adds i to the "sex" field.
  8500. func (m *ContactMutation) AddSex(i int) {
  8501. if m.addsex != nil {
  8502. *m.addsex += i
  8503. } else {
  8504. m.addsex = &i
  8505. }
  8506. }
  8507. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8508. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8509. v := m.addsex
  8510. if v == nil {
  8511. return
  8512. }
  8513. return *v, true
  8514. }
  8515. // ResetSex resets all changes to the "sex" field.
  8516. func (m *ContactMutation) ResetSex() {
  8517. m.sex = nil
  8518. m.addsex = nil
  8519. }
  8520. // SetStarrole sets the "starrole" field.
  8521. func (m *ContactMutation) SetStarrole(s string) {
  8522. m.starrole = &s
  8523. }
  8524. // Starrole returns the value of the "starrole" field in the mutation.
  8525. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8526. v := m.starrole
  8527. if v == nil {
  8528. return
  8529. }
  8530. return *v, true
  8531. }
  8532. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8533. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8535. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8536. if !m.op.Is(OpUpdateOne) {
  8537. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8538. }
  8539. if m.id == nil || m.oldValue == nil {
  8540. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8541. }
  8542. oldValue, err := m.oldValue(ctx)
  8543. if err != nil {
  8544. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8545. }
  8546. return oldValue.Starrole, nil
  8547. }
  8548. // ResetStarrole resets all changes to the "starrole" field.
  8549. func (m *ContactMutation) ResetStarrole() {
  8550. m.starrole = nil
  8551. }
  8552. // SetDontseeit sets the "dontseeit" field.
  8553. func (m *ContactMutation) SetDontseeit(i int) {
  8554. m.dontseeit = &i
  8555. m.adddontseeit = nil
  8556. }
  8557. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8558. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8559. v := m.dontseeit
  8560. if v == nil {
  8561. return
  8562. }
  8563. return *v, true
  8564. }
  8565. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8566. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8568. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8569. if !m.op.Is(OpUpdateOne) {
  8570. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8571. }
  8572. if m.id == nil || m.oldValue == nil {
  8573. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8574. }
  8575. oldValue, err := m.oldValue(ctx)
  8576. if err != nil {
  8577. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8578. }
  8579. return oldValue.Dontseeit, nil
  8580. }
  8581. // AddDontseeit adds i to the "dontseeit" field.
  8582. func (m *ContactMutation) AddDontseeit(i int) {
  8583. if m.adddontseeit != nil {
  8584. *m.adddontseeit += i
  8585. } else {
  8586. m.adddontseeit = &i
  8587. }
  8588. }
  8589. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8590. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8591. v := m.adddontseeit
  8592. if v == nil {
  8593. return
  8594. }
  8595. return *v, true
  8596. }
  8597. // ResetDontseeit resets all changes to the "dontseeit" field.
  8598. func (m *ContactMutation) ResetDontseeit() {
  8599. m.dontseeit = nil
  8600. m.adddontseeit = nil
  8601. }
  8602. // SetDontseeme sets the "dontseeme" field.
  8603. func (m *ContactMutation) SetDontseeme(i int) {
  8604. m.dontseeme = &i
  8605. m.adddontseeme = nil
  8606. }
  8607. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8608. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8609. v := m.dontseeme
  8610. if v == nil {
  8611. return
  8612. }
  8613. return *v, true
  8614. }
  8615. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8616. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8618. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8619. if !m.op.Is(OpUpdateOne) {
  8620. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8621. }
  8622. if m.id == nil || m.oldValue == nil {
  8623. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8624. }
  8625. oldValue, err := m.oldValue(ctx)
  8626. if err != nil {
  8627. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8628. }
  8629. return oldValue.Dontseeme, nil
  8630. }
  8631. // AddDontseeme adds i to the "dontseeme" field.
  8632. func (m *ContactMutation) AddDontseeme(i int) {
  8633. if m.adddontseeme != nil {
  8634. *m.adddontseeme += i
  8635. } else {
  8636. m.adddontseeme = &i
  8637. }
  8638. }
  8639. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8640. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8641. v := m.adddontseeme
  8642. if v == nil {
  8643. return
  8644. }
  8645. return *v, true
  8646. }
  8647. // ResetDontseeme resets all changes to the "dontseeme" field.
  8648. func (m *ContactMutation) ResetDontseeme() {
  8649. m.dontseeme = nil
  8650. m.adddontseeme = nil
  8651. }
  8652. // SetLag sets the "lag" field.
  8653. func (m *ContactMutation) SetLag(s string) {
  8654. m.lag = &s
  8655. }
  8656. // Lag returns the value of the "lag" field in the mutation.
  8657. func (m *ContactMutation) Lag() (r string, exists bool) {
  8658. v := m.lag
  8659. if v == nil {
  8660. return
  8661. }
  8662. return *v, true
  8663. }
  8664. // OldLag returns the old "lag" field's value of the Contact entity.
  8665. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8667. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8668. if !m.op.Is(OpUpdateOne) {
  8669. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8670. }
  8671. if m.id == nil || m.oldValue == nil {
  8672. return v, errors.New("OldLag requires an ID field in the mutation")
  8673. }
  8674. oldValue, err := m.oldValue(ctx)
  8675. if err != nil {
  8676. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8677. }
  8678. return oldValue.Lag, nil
  8679. }
  8680. // ResetLag resets all changes to the "lag" field.
  8681. func (m *ContactMutation) ResetLag() {
  8682. m.lag = nil
  8683. }
  8684. // SetGid sets the "gid" field.
  8685. func (m *ContactMutation) SetGid(s string) {
  8686. m.gid = &s
  8687. }
  8688. // Gid returns the value of the "gid" field in the mutation.
  8689. func (m *ContactMutation) Gid() (r string, exists bool) {
  8690. v := m.gid
  8691. if v == nil {
  8692. return
  8693. }
  8694. return *v, true
  8695. }
  8696. // OldGid returns the old "gid" field's value of the Contact entity.
  8697. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8699. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8700. if !m.op.Is(OpUpdateOne) {
  8701. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8702. }
  8703. if m.id == nil || m.oldValue == nil {
  8704. return v, errors.New("OldGid requires an ID field in the mutation")
  8705. }
  8706. oldValue, err := m.oldValue(ctx)
  8707. if err != nil {
  8708. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8709. }
  8710. return oldValue.Gid, nil
  8711. }
  8712. // ResetGid resets all changes to the "gid" field.
  8713. func (m *ContactMutation) ResetGid() {
  8714. m.gid = nil
  8715. }
  8716. // SetGname sets the "gname" field.
  8717. func (m *ContactMutation) SetGname(s string) {
  8718. m.gname = &s
  8719. }
  8720. // Gname returns the value of the "gname" field in the mutation.
  8721. func (m *ContactMutation) Gname() (r string, exists bool) {
  8722. v := m.gname
  8723. if v == nil {
  8724. return
  8725. }
  8726. return *v, true
  8727. }
  8728. // OldGname returns the old "gname" field's value of the Contact entity.
  8729. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8731. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8732. if !m.op.Is(OpUpdateOne) {
  8733. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8734. }
  8735. if m.id == nil || m.oldValue == nil {
  8736. return v, errors.New("OldGname requires an ID field in the mutation")
  8737. }
  8738. oldValue, err := m.oldValue(ctx)
  8739. if err != nil {
  8740. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8741. }
  8742. return oldValue.Gname, nil
  8743. }
  8744. // ResetGname resets all changes to the "gname" field.
  8745. func (m *ContactMutation) ResetGname() {
  8746. m.gname = nil
  8747. }
  8748. // SetV3 sets the "v3" field.
  8749. func (m *ContactMutation) SetV3(s string) {
  8750. m.v3 = &s
  8751. }
  8752. // V3 returns the value of the "v3" field in the mutation.
  8753. func (m *ContactMutation) V3() (r string, exists bool) {
  8754. v := m.v3
  8755. if v == nil {
  8756. return
  8757. }
  8758. return *v, true
  8759. }
  8760. // OldV3 returns the old "v3" field's value of the Contact entity.
  8761. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8763. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8764. if !m.op.Is(OpUpdateOne) {
  8765. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8766. }
  8767. if m.id == nil || m.oldValue == nil {
  8768. return v, errors.New("OldV3 requires an ID field in the mutation")
  8769. }
  8770. oldValue, err := m.oldValue(ctx)
  8771. if err != nil {
  8772. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8773. }
  8774. return oldValue.V3, nil
  8775. }
  8776. // ResetV3 resets all changes to the "v3" field.
  8777. func (m *ContactMutation) ResetV3() {
  8778. m.v3 = nil
  8779. }
  8780. // SetOrganizationID sets the "organization_id" field.
  8781. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8782. m.organization_id = &u
  8783. m.addorganization_id = nil
  8784. }
  8785. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8786. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8787. v := m.organization_id
  8788. if v == nil {
  8789. return
  8790. }
  8791. return *v, true
  8792. }
  8793. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8794. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8796. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8797. if !m.op.Is(OpUpdateOne) {
  8798. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8799. }
  8800. if m.id == nil || m.oldValue == nil {
  8801. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8802. }
  8803. oldValue, err := m.oldValue(ctx)
  8804. if err != nil {
  8805. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8806. }
  8807. return oldValue.OrganizationID, nil
  8808. }
  8809. // AddOrganizationID adds u to the "organization_id" field.
  8810. func (m *ContactMutation) AddOrganizationID(u int64) {
  8811. if m.addorganization_id != nil {
  8812. *m.addorganization_id += u
  8813. } else {
  8814. m.addorganization_id = &u
  8815. }
  8816. }
  8817. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8818. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8819. v := m.addorganization_id
  8820. if v == nil {
  8821. return
  8822. }
  8823. return *v, true
  8824. }
  8825. // ClearOrganizationID clears the value of the "organization_id" field.
  8826. func (m *ContactMutation) ClearOrganizationID() {
  8827. m.organization_id = nil
  8828. m.addorganization_id = nil
  8829. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8830. }
  8831. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8832. func (m *ContactMutation) OrganizationIDCleared() bool {
  8833. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8834. return ok
  8835. }
  8836. // ResetOrganizationID resets all changes to the "organization_id" field.
  8837. func (m *ContactMutation) ResetOrganizationID() {
  8838. m.organization_id = nil
  8839. m.addorganization_id = nil
  8840. delete(m.clearedFields, contact.FieldOrganizationID)
  8841. }
  8842. // SetCtype sets the "ctype" field.
  8843. func (m *ContactMutation) SetCtype(u uint64) {
  8844. m.ctype = &u
  8845. m.addctype = nil
  8846. }
  8847. // Ctype returns the value of the "ctype" field in the mutation.
  8848. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  8849. v := m.ctype
  8850. if v == nil {
  8851. return
  8852. }
  8853. return *v, true
  8854. }
  8855. // OldCtype returns the old "ctype" field's value of the Contact entity.
  8856. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8858. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  8859. if !m.op.Is(OpUpdateOne) {
  8860. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  8861. }
  8862. if m.id == nil || m.oldValue == nil {
  8863. return v, errors.New("OldCtype requires an ID field in the mutation")
  8864. }
  8865. oldValue, err := m.oldValue(ctx)
  8866. if err != nil {
  8867. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  8868. }
  8869. return oldValue.Ctype, nil
  8870. }
  8871. // AddCtype adds u to the "ctype" field.
  8872. func (m *ContactMutation) AddCtype(u int64) {
  8873. if m.addctype != nil {
  8874. *m.addctype += u
  8875. } else {
  8876. m.addctype = &u
  8877. }
  8878. }
  8879. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  8880. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  8881. v := m.addctype
  8882. if v == nil {
  8883. return
  8884. }
  8885. return *v, true
  8886. }
  8887. // ResetCtype resets all changes to the "ctype" field.
  8888. func (m *ContactMutation) ResetCtype() {
  8889. m.ctype = nil
  8890. m.addctype = nil
  8891. }
  8892. // SetCsex sets the "csex" field.
  8893. func (m *ContactMutation) SetCsex(i int) {
  8894. m.csex = &i
  8895. m.addcsex = nil
  8896. }
  8897. // Csex returns the value of the "csex" field in the mutation.
  8898. func (m *ContactMutation) Csex() (r int, exists bool) {
  8899. v := m.csex
  8900. if v == nil {
  8901. return
  8902. }
  8903. return *v, true
  8904. }
  8905. // OldCsex returns the old "csex" field's value of the Contact entity.
  8906. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8908. func (m *ContactMutation) OldCsex(ctx context.Context) (v int, err error) {
  8909. if !m.op.Is(OpUpdateOne) {
  8910. return v, errors.New("OldCsex is only allowed on UpdateOne operations")
  8911. }
  8912. if m.id == nil || m.oldValue == nil {
  8913. return v, errors.New("OldCsex requires an ID field in the mutation")
  8914. }
  8915. oldValue, err := m.oldValue(ctx)
  8916. if err != nil {
  8917. return v, fmt.Errorf("querying old value for OldCsex: %w", err)
  8918. }
  8919. return oldValue.Csex, nil
  8920. }
  8921. // AddCsex adds i to the "csex" field.
  8922. func (m *ContactMutation) AddCsex(i int) {
  8923. if m.addcsex != nil {
  8924. *m.addcsex += i
  8925. } else {
  8926. m.addcsex = &i
  8927. }
  8928. }
  8929. // AddedCsex returns the value that was added to the "csex" field in this mutation.
  8930. func (m *ContactMutation) AddedCsex() (r int, exists bool) {
  8931. v := m.addcsex
  8932. if v == nil {
  8933. return
  8934. }
  8935. return *v, true
  8936. }
  8937. // ResetCsex resets all changes to the "csex" field.
  8938. func (m *ContactMutation) ResetCsex() {
  8939. m.csex = nil
  8940. m.addcsex = nil
  8941. }
  8942. // SetCage sets the "cage" field.
  8943. func (m *ContactMutation) SetCage(i int) {
  8944. m.cage = &i
  8945. m.addcage = nil
  8946. }
  8947. // Cage returns the value of the "cage" field in the mutation.
  8948. func (m *ContactMutation) Cage() (r int, exists bool) {
  8949. v := m.cage
  8950. if v == nil {
  8951. return
  8952. }
  8953. return *v, true
  8954. }
  8955. // OldCage returns the old "cage" field's value of the Contact entity.
  8956. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8958. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  8959. if !m.op.Is(OpUpdateOne) {
  8960. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  8961. }
  8962. if m.id == nil || m.oldValue == nil {
  8963. return v, errors.New("OldCage requires an ID field in the mutation")
  8964. }
  8965. oldValue, err := m.oldValue(ctx)
  8966. if err != nil {
  8967. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  8968. }
  8969. return oldValue.Cage, nil
  8970. }
  8971. // AddCage adds i to the "cage" field.
  8972. func (m *ContactMutation) AddCage(i int) {
  8973. if m.addcage != nil {
  8974. *m.addcage += i
  8975. } else {
  8976. m.addcage = &i
  8977. }
  8978. }
  8979. // AddedCage returns the value that was added to the "cage" field in this mutation.
  8980. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  8981. v := m.addcage
  8982. if v == nil {
  8983. return
  8984. }
  8985. return *v, true
  8986. }
  8987. // ResetCage resets all changes to the "cage" field.
  8988. func (m *ContactMutation) ResetCage() {
  8989. m.cage = nil
  8990. m.addcage = nil
  8991. }
  8992. // SetCname sets the "cname" field.
  8993. func (m *ContactMutation) SetCname(s string) {
  8994. m.cname = &s
  8995. }
  8996. // Cname returns the value of the "cname" field in the mutation.
  8997. func (m *ContactMutation) Cname() (r string, exists bool) {
  8998. v := m.cname
  8999. if v == nil {
  9000. return
  9001. }
  9002. return *v, true
  9003. }
  9004. // OldCname returns the old "cname" field's value of the Contact entity.
  9005. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9007. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  9008. if !m.op.Is(OpUpdateOne) {
  9009. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  9010. }
  9011. if m.id == nil || m.oldValue == nil {
  9012. return v, errors.New("OldCname requires an ID field in the mutation")
  9013. }
  9014. oldValue, err := m.oldValue(ctx)
  9015. if err != nil {
  9016. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  9017. }
  9018. return oldValue.Cname, nil
  9019. }
  9020. // ResetCname resets all changes to the "cname" field.
  9021. func (m *ContactMutation) ResetCname() {
  9022. m.cname = nil
  9023. }
  9024. // SetCarea sets the "carea" field.
  9025. func (m *ContactMutation) SetCarea(s string) {
  9026. m.carea = &s
  9027. }
  9028. // Carea returns the value of the "carea" field in the mutation.
  9029. func (m *ContactMutation) Carea() (r string, exists bool) {
  9030. v := m.carea
  9031. if v == nil {
  9032. return
  9033. }
  9034. return *v, true
  9035. }
  9036. // OldCarea returns the old "carea" field's value of the Contact entity.
  9037. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9039. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  9040. if !m.op.Is(OpUpdateOne) {
  9041. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  9042. }
  9043. if m.id == nil || m.oldValue == nil {
  9044. return v, errors.New("OldCarea requires an ID field in the mutation")
  9045. }
  9046. oldValue, err := m.oldValue(ctx)
  9047. if err != nil {
  9048. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  9049. }
  9050. return oldValue.Carea, nil
  9051. }
  9052. // ResetCarea resets all changes to the "carea" field.
  9053. func (m *ContactMutation) ResetCarea() {
  9054. m.carea = nil
  9055. }
  9056. // SetCmobile sets the "cmobile" field.
  9057. func (m *ContactMutation) SetCmobile(s string) {
  9058. m.cmobile = &s
  9059. }
  9060. // Cmobile returns the value of the "cmobile" field in the mutation.
  9061. func (m *ContactMutation) Cmobile() (r string, exists bool) {
  9062. v := m.cmobile
  9063. if v == nil {
  9064. return
  9065. }
  9066. return *v, true
  9067. }
  9068. // OldCmobile returns the old "cmobile" field's value of the Contact entity.
  9069. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9071. func (m *ContactMutation) OldCmobile(ctx context.Context) (v string, err error) {
  9072. if !m.op.Is(OpUpdateOne) {
  9073. return v, errors.New("OldCmobile is only allowed on UpdateOne operations")
  9074. }
  9075. if m.id == nil || m.oldValue == nil {
  9076. return v, errors.New("OldCmobile requires an ID field in the mutation")
  9077. }
  9078. oldValue, err := m.oldValue(ctx)
  9079. if err != nil {
  9080. return v, fmt.Errorf("querying old value for OldCmobile: %w", err)
  9081. }
  9082. return oldValue.Cmobile, nil
  9083. }
  9084. // ResetCmobile resets all changes to the "cmobile" field.
  9085. func (m *ContactMutation) ResetCmobile() {
  9086. m.cmobile = nil
  9087. }
  9088. // SetCbirthday sets the "cbirthday" field.
  9089. func (m *ContactMutation) SetCbirthday(s string) {
  9090. m.cbirthday = &s
  9091. }
  9092. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  9093. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  9094. v := m.cbirthday
  9095. if v == nil {
  9096. return
  9097. }
  9098. return *v, true
  9099. }
  9100. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  9101. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9103. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  9104. if !m.op.Is(OpUpdateOne) {
  9105. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  9106. }
  9107. if m.id == nil || m.oldValue == nil {
  9108. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  9109. }
  9110. oldValue, err := m.oldValue(ctx)
  9111. if err != nil {
  9112. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  9113. }
  9114. return oldValue.Cbirthday, nil
  9115. }
  9116. // ResetCbirthday resets all changes to the "cbirthday" field.
  9117. func (m *ContactMutation) ResetCbirthday() {
  9118. m.cbirthday = nil
  9119. }
  9120. // SetCbirtharea sets the "cbirtharea" field.
  9121. func (m *ContactMutation) SetCbirtharea(s string) {
  9122. m.cbirtharea = &s
  9123. }
  9124. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  9125. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  9126. v := m.cbirtharea
  9127. if v == nil {
  9128. return
  9129. }
  9130. return *v, true
  9131. }
  9132. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  9133. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9135. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  9136. if !m.op.Is(OpUpdateOne) {
  9137. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  9138. }
  9139. if m.id == nil || m.oldValue == nil {
  9140. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  9141. }
  9142. oldValue, err := m.oldValue(ctx)
  9143. if err != nil {
  9144. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  9145. }
  9146. return oldValue.Cbirtharea, nil
  9147. }
  9148. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  9149. func (m *ContactMutation) ResetCbirtharea() {
  9150. m.cbirtharea = nil
  9151. }
  9152. // SetCidcardNo sets the "cidcard_no" field.
  9153. func (m *ContactMutation) SetCidcardNo(s string) {
  9154. m.cidcard_no = &s
  9155. }
  9156. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  9157. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  9158. v := m.cidcard_no
  9159. if v == nil {
  9160. return
  9161. }
  9162. return *v, true
  9163. }
  9164. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  9165. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9167. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  9168. if !m.op.Is(OpUpdateOne) {
  9169. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  9170. }
  9171. if m.id == nil || m.oldValue == nil {
  9172. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  9173. }
  9174. oldValue, err := m.oldValue(ctx)
  9175. if err != nil {
  9176. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  9177. }
  9178. return oldValue.CidcardNo, nil
  9179. }
  9180. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  9181. func (m *ContactMutation) ResetCidcardNo() {
  9182. m.cidcard_no = nil
  9183. }
  9184. // SetCtitle sets the "ctitle" field.
  9185. func (m *ContactMutation) SetCtitle(s string) {
  9186. m.ctitle = &s
  9187. }
  9188. // Ctitle returns the value of the "ctitle" field in the mutation.
  9189. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  9190. v := m.ctitle
  9191. if v == nil {
  9192. return
  9193. }
  9194. return *v, true
  9195. }
  9196. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  9197. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9199. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  9200. if !m.op.Is(OpUpdateOne) {
  9201. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  9202. }
  9203. if m.id == nil || m.oldValue == nil {
  9204. return v, errors.New("OldCtitle requires an ID field in the mutation")
  9205. }
  9206. oldValue, err := m.oldValue(ctx)
  9207. if err != nil {
  9208. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  9209. }
  9210. return oldValue.Ctitle, nil
  9211. }
  9212. // ResetCtitle resets all changes to the "ctitle" field.
  9213. func (m *ContactMutation) ResetCtitle() {
  9214. m.ctitle = nil
  9215. }
  9216. // SetCc sets the "cc" field.
  9217. func (m *ContactMutation) SetCc(s string) {
  9218. m.cc = &s
  9219. }
  9220. // Cc returns the value of the "cc" field in the mutation.
  9221. func (m *ContactMutation) Cc() (r string, exists bool) {
  9222. v := m.cc
  9223. if v == nil {
  9224. return
  9225. }
  9226. return *v, true
  9227. }
  9228. // OldCc returns the old "cc" field's value of the Contact entity.
  9229. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9231. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  9232. if !m.op.Is(OpUpdateOne) {
  9233. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  9234. }
  9235. if m.id == nil || m.oldValue == nil {
  9236. return v, errors.New("OldCc requires an ID field in the mutation")
  9237. }
  9238. oldValue, err := m.oldValue(ctx)
  9239. if err != nil {
  9240. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  9241. }
  9242. return oldValue.Cc, nil
  9243. }
  9244. // ResetCc resets all changes to the "cc" field.
  9245. func (m *ContactMutation) ResetCc() {
  9246. m.cc = nil
  9247. }
  9248. // SetPhone sets the "phone" field.
  9249. func (m *ContactMutation) SetPhone(s string) {
  9250. m.phone = &s
  9251. }
  9252. // Phone returns the value of the "phone" field in the mutation.
  9253. func (m *ContactMutation) Phone() (r string, exists bool) {
  9254. v := m.phone
  9255. if v == nil {
  9256. return
  9257. }
  9258. return *v, true
  9259. }
  9260. // OldPhone returns the old "phone" field's value of the Contact entity.
  9261. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9263. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  9264. if !m.op.Is(OpUpdateOne) {
  9265. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  9266. }
  9267. if m.id == nil || m.oldValue == nil {
  9268. return v, errors.New("OldPhone requires an ID field in the mutation")
  9269. }
  9270. oldValue, err := m.oldValue(ctx)
  9271. if err != nil {
  9272. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  9273. }
  9274. return oldValue.Phone, nil
  9275. }
  9276. // ResetPhone resets all changes to the "phone" field.
  9277. func (m *ContactMutation) ResetPhone() {
  9278. m.phone = nil
  9279. }
  9280. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  9281. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  9282. if m.contact_relationships == nil {
  9283. m.contact_relationships = make(map[uint64]struct{})
  9284. }
  9285. for i := range ids {
  9286. m.contact_relationships[ids[i]] = struct{}{}
  9287. }
  9288. }
  9289. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  9290. func (m *ContactMutation) ClearContactRelationships() {
  9291. m.clearedcontact_relationships = true
  9292. }
  9293. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  9294. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  9295. return m.clearedcontact_relationships
  9296. }
  9297. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  9298. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  9299. if m.removedcontact_relationships == nil {
  9300. m.removedcontact_relationships = make(map[uint64]struct{})
  9301. }
  9302. for i := range ids {
  9303. delete(m.contact_relationships, ids[i])
  9304. m.removedcontact_relationships[ids[i]] = struct{}{}
  9305. }
  9306. }
  9307. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  9308. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  9309. for id := range m.removedcontact_relationships {
  9310. ids = append(ids, id)
  9311. }
  9312. return
  9313. }
  9314. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  9315. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  9316. for id := range m.contact_relationships {
  9317. ids = append(ids, id)
  9318. }
  9319. return
  9320. }
  9321. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  9322. func (m *ContactMutation) ResetContactRelationships() {
  9323. m.contact_relationships = nil
  9324. m.clearedcontact_relationships = false
  9325. m.removedcontact_relationships = nil
  9326. }
  9327. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  9328. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  9329. if m.contact_messages == nil {
  9330. m.contact_messages = make(map[uint64]struct{})
  9331. }
  9332. for i := range ids {
  9333. m.contact_messages[ids[i]] = struct{}{}
  9334. }
  9335. }
  9336. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  9337. func (m *ContactMutation) ClearContactMessages() {
  9338. m.clearedcontact_messages = true
  9339. }
  9340. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  9341. func (m *ContactMutation) ContactMessagesCleared() bool {
  9342. return m.clearedcontact_messages
  9343. }
  9344. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  9345. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  9346. if m.removedcontact_messages == nil {
  9347. m.removedcontact_messages = make(map[uint64]struct{})
  9348. }
  9349. for i := range ids {
  9350. delete(m.contact_messages, ids[i])
  9351. m.removedcontact_messages[ids[i]] = struct{}{}
  9352. }
  9353. }
  9354. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  9355. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  9356. for id := range m.removedcontact_messages {
  9357. ids = append(ids, id)
  9358. }
  9359. return
  9360. }
  9361. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  9362. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  9363. for id := range m.contact_messages {
  9364. ids = append(ids, id)
  9365. }
  9366. return
  9367. }
  9368. // ResetContactMessages resets all changes to the "contact_messages" edge.
  9369. func (m *ContactMutation) ResetContactMessages() {
  9370. m.contact_messages = nil
  9371. m.clearedcontact_messages = false
  9372. m.removedcontact_messages = nil
  9373. }
  9374. // Where appends a list predicates to the ContactMutation builder.
  9375. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  9376. m.predicates = append(m.predicates, ps...)
  9377. }
  9378. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  9379. // users can use type-assertion to append predicates that do not depend on any generated package.
  9380. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  9381. p := make([]predicate.Contact, len(ps))
  9382. for i := range ps {
  9383. p[i] = ps[i]
  9384. }
  9385. m.Where(p...)
  9386. }
  9387. // Op returns the operation name.
  9388. func (m *ContactMutation) Op() Op {
  9389. return m.op
  9390. }
  9391. // SetOp allows setting the mutation operation.
  9392. func (m *ContactMutation) SetOp(op Op) {
  9393. m.op = op
  9394. }
  9395. // Type returns the node type of this mutation (Contact).
  9396. func (m *ContactMutation) Type() string {
  9397. return m.typ
  9398. }
  9399. // Fields returns all fields that were changed during this mutation. Note that in
  9400. // order to get all numeric fields that were incremented/decremented, call
  9401. // AddedFields().
  9402. func (m *ContactMutation) Fields() []string {
  9403. fields := make([]string, 0, 32)
  9404. if m.created_at != nil {
  9405. fields = append(fields, contact.FieldCreatedAt)
  9406. }
  9407. if m.updated_at != nil {
  9408. fields = append(fields, contact.FieldUpdatedAt)
  9409. }
  9410. if m.status != nil {
  9411. fields = append(fields, contact.FieldStatus)
  9412. }
  9413. if m.deleted_at != nil {
  9414. fields = append(fields, contact.FieldDeletedAt)
  9415. }
  9416. if m.wx_wxid != nil {
  9417. fields = append(fields, contact.FieldWxWxid)
  9418. }
  9419. if m._type != nil {
  9420. fields = append(fields, contact.FieldType)
  9421. }
  9422. if m.wxid != nil {
  9423. fields = append(fields, contact.FieldWxid)
  9424. }
  9425. if m.account != nil {
  9426. fields = append(fields, contact.FieldAccount)
  9427. }
  9428. if m.nickname != nil {
  9429. fields = append(fields, contact.FieldNickname)
  9430. }
  9431. if m.markname != nil {
  9432. fields = append(fields, contact.FieldMarkname)
  9433. }
  9434. if m.headimg != nil {
  9435. fields = append(fields, contact.FieldHeadimg)
  9436. }
  9437. if m.sex != nil {
  9438. fields = append(fields, contact.FieldSex)
  9439. }
  9440. if m.starrole != nil {
  9441. fields = append(fields, contact.FieldStarrole)
  9442. }
  9443. if m.dontseeit != nil {
  9444. fields = append(fields, contact.FieldDontseeit)
  9445. }
  9446. if m.dontseeme != nil {
  9447. fields = append(fields, contact.FieldDontseeme)
  9448. }
  9449. if m.lag != nil {
  9450. fields = append(fields, contact.FieldLag)
  9451. }
  9452. if m.gid != nil {
  9453. fields = append(fields, contact.FieldGid)
  9454. }
  9455. if m.gname != nil {
  9456. fields = append(fields, contact.FieldGname)
  9457. }
  9458. if m.v3 != nil {
  9459. fields = append(fields, contact.FieldV3)
  9460. }
  9461. if m.organization_id != nil {
  9462. fields = append(fields, contact.FieldOrganizationID)
  9463. }
  9464. if m.ctype != nil {
  9465. fields = append(fields, contact.FieldCtype)
  9466. }
  9467. if m.csex != nil {
  9468. fields = append(fields, contact.FieldCsex)
  9469. }
  9470. if m.cage != nil {
  9471. fields = append(fields, contact.FieldCage)
  9472. }
  9473. if m.cname != nil {
  9474. fields = append(fields, contact.FieldCname)
  9475. }
  9476. if m.carea != nil {
  9477. fields = append(fields, contact.FieldCarea)
  9478. }
  9479. if m.cmobile != nil {
  9480. fields = append(fields, contact.FieldCmobile)
  9481. }
  9482. if m.cbirthday != nil {
  9483. fields = append(fields, contact.FieldCbirthday)
  9484. }
  9485. if m.cbirtharea != nil {
  9486. fields = append(fields, contact.FieldCbirtharea)
  9487. }
  9488. if m.cidcard_no != nil {
  9489. fields = append(fields, contact.FieldCidcardNo)
  9490. }
  9491. if m.ctitle != nil {
  9492. fields = append(fields, contact.FieldCtitle)
  9493. }
  9494. if m.cc != nil {
  9495. fields = append(fields, contact.FieldCc)
  9496. }
  9497. if m.phone != nil {
  9498. fields = append(fields, contact.FieldPhone)
  9499. }
  9500. return fields
  9501. }
  9502. // Field returns the value of a field with the given name. The second boolean
  9503. // return value indicates that this field was not set, or was not defined in the
  9504. // schema.
  9505. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  9506. switch name {
  9507. case contact.FieldCreatedAt:
  9508. return m.CreatedAt()
  9509. case contact.FieldUpdatedAt:
  9510. return m.UpdatedAt()
  9511. case contact.FieldStatus:
  9512. return m.Status()
  9513. case contact.FieldDeletedAt:
  9514. return m.DeletedAt()
  9515. case contact.FieldWxWxid:
  9516. return m.WxWxid()
  9517. case contact.FieldType:
  9518. return m.GetType()
  9519. case contact.FieldWxid:
  9520. return m.Wxid()
  9521. case contact.FieldAccount:
  9522. return m.Account()
  9523. case contact.FieldNickname:
  9524. return m.Nickname()
  9525. case contact.FieldMarkname:
  9526. return m.Markname()
  9527. case contact.FieldHeadimg:
  9528. return m.Headimg()
  9529. case contact.FieldSex:
  9530. return m.Sex()
  9531. case contact.FieldStarrole:
  9532. return m.Starrole()
  9533. case contact.FieldDontseeit:
  9534. return m.Dontseeit()
  9535. case contact.FieldDontseeme:
  9536. return m.Dontseeme()
  9537. case contact.FieldLag:
  9538. return m.Lag()
  9539. case contact.FieldGid:
  9540. return m.Gid()
  9541. case contact.FieldGname:
  9542. return m.Gname()
  9543. case contact.FieldV3:
  9544. return m.V3()
  9545. case contact.FieldOrganizationID:
  9546. return m.OrganizationID()
  9547. case contact.FieldCtype:
  9548. return m.Ctype()
  9549. case contact.FieldCsex:
  9550. return m.Csex()
  9551. case contact.FieldCage:
  9552. return m.Cage()
  9553. case contact.FieldCname:
  9554. return m.Cname()
  9555. case contact.FieldCarea:
  9556. return m.Carea()
  9557. case contact.FieldCmobile:
  9558. return m.Cmobile()
  9559. case contact.FieldCbirthday:
  9560. return m.Cbirthday()
  9561. case contact.FieldCbirtharea:
  9562. return m.Cbirtharea()
  9563. case contact.FieldCidcardNo:
  9564. return m.CidcardNo()
  9565. case contact.FieldCtitle:
  9566. return m.Ctitle()
  9567. case contact.FieldCc:
  9568. return m.Cc()
  9569. case contact.FieldPhone:
  9570. return m.Phone()
  9571. }
  9572. return nil, false
  9573. }
  9574. // OldField returns the old value of the field from the database. An error is
  9575. // returned if the mutation operation is not UpdateOne, or the query to the
  9576. // database failed.
  9577. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9578. switch name {
  9579. case contact.FieldCreatedAt:
  9580. return m.OldCreatedAt(ctx)
  9581. case contact.FieldUpdatedAt:
  9582. return m.OldUpdatedAt(ctx)
  9583. case contact.FieldStatus:
  9584. return m.OldStatus(ctx)
  9585. case contact.FieldDeletedAt:
  9586. return m.OldDeletedAt(ctx)
  9587. case contact.FieldWxWxid:
  9588. return m.OldWxWxid(ctx)
  9589. case contact.FieldType:
  9590. return m.OldType(ctx)
  9591. case contact.FieldWxid:
  9592. return m.OldWxid(ctx)
  9593. case contact.FieldAccount:
  9594. return m.OldAccount(ctx)
  9595. case contact.FieldNickname:
  9596. return m.OldNickname(ctx)
  9597. case contact.FieldMarkname:
  9598. return m.OldMarkname(ctx)
  9599. case contact.FieldHeadimg:
  9600. return m.OldHeadimg(ctx)
  9601. case contact.FieldSex:
  9602. return m.OldSex(ctx)
  9603. case contact.FieldStarrole:
  9604. return m.OldStarrole(ctx)
  9605. case contact.FieldDontseeit:
  9606. return m.OldDontseeit(ctx)
  9607. case contact.FieldDontseeme:
  9608. return m.OldDontseeme(ctx)
  9609. case contact.FieldLag:
  9610. return m.OldLag(ctx)
  9611. case contact.FieldGid:
  9612. return m.OldGid(ctx)
  9613. case contact.FieldGname:
  9614. return m.OldGname(ctx)
  9615. case contact.FieldV3:
  9616. return m.OldV3(ctx)
  9617. case contact.FieldOrganizationID:
  9618. return m.OldOrganizationID(ctx)
  9619. case contact.FieldCtype:
  9620. return m.OldCtype(ctx)
  9621. case contact.FieldCsex:
  9622. return m.OldCsex(ctx)
  9623. case contact.FieldCage:
  9624. return m.OldCage(ctx)
  9625. case contact.FieldCname:
  9626. return m.OldCname(ctx)
  9627. case contact.FieldCarea:
  9628. return m.OldCarea(ctx)
  9629. case contact.FieldCmobile:
  9630. return m.OldCmobile(ctx)
  9631. case contact.FieldCbirthday:
  9632. return m.OldCbirthday(ctx)
  9633. case contact.FieldCbirtharea:
  9634. return m.OldCbirtharea(ctx)
  9635. case contact.FieldCidcardNo:
  9636. return m.OldCidcardNo(ctx)
  9637. case contact.FieldCtitle:
  9638. return m.OldCtitle(ctx)
  9639. case contact.FieldCc:
  9640. return m.OldCc(ctx)
  9641. case contact.FieldPhone:
  9642. return m.OldPhone(ctx)
  9643. }
  9644. return nil, fmt.Errorf("unknown Contact field %s", name)
  9645. }
  9646. // SetField sets the value of a field with the given name. It returns an error if
  9647. // the field is not defined in the schema, or if the type mismatched the field
  9648. // type.
  9649. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  9650. switch name {
  9651. case contact.FieldCreatedAt:
  9652. v, ok := value.(time.Time)
  9653. if !ok {
  9654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9655. }
  9656. m.SetCreatedAt(v)
  9657. return nil
  9658. case contact.FieldUpdatedAt:
  9659. v, ok := value.(time.Time)
  9660. if !ok {
  9661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9662. }
  9663. m.SetUpdatedAt(v)
  9664. return nil
  9665. case contact.FieldStatus:
  9666. v, ok := value.(uint8)
  9667. if !ok {
  9668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9669. }
  9670. m.SetStatus(v)
  9671. return nil
  9672. case contact.FieldDeletedAt:
  9673. v, ok := value.(time.Time)
  9674. if !ok {
  9675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9676. }
  9677. m.SetDeletedAt(v)
  9678. return nil
  9679. case contact.FieldWxWxid:
  9680. v, ok := value.(string)
  9681. if !ok {
  9682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9683. }
  9684. m.SetWxWxid(v)
  9685. return nil
  9686. case contact.FieldType:
  9687. v, ok := value.(int)
  9688. if !ok {
  9689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9690. }
  9691. m.SetType(v)
  9692. return nil
  9693. case contact.FieldWxid:
  9694. v, ok := value.(string)
  9695. if !ok {
  9696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9697. }
  9698. m.SetWxid(v)
  9699. return nil
  9700. case contact.FieldAccount:
  9701. v, ok := value.(string)
  9702. if !ok {
  9703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9704. }
  9705. m.SetAccount(v)
  9706. return nil
  9707. case contact.FieldNickname:
  9708. v, ok := value.(string)
  9709. if !ok {
  9710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9711. }
  9712. m.SetNickname(v)
  9713. return nil
  9714. case contact.FieldMarkname:
  9715. v, ok := value.(string)
  9716. if !ok {
  9717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9718. }
  9719. m.SetMarkname(v)
  9720. return nil
  9721. case contact.FieldHeadimg:
  9722. v, ok := value.(string)
  9723. if !ok {
  9724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9725. }
  9726. m.SetHeadimg(v)
  9727. return nil
  9728. case contact.FieldSex:
  9729. v, ok := value.(int)
  9730. if !ok {
  9731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9732. }
  9733. m.SetSex(v)
  9734. return nil
  9735. case contact.FieldStarrole:
  9736. v, ok := value.(string)
  9737. if !ok {
  9738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9739. }
  9740. m.SetStarrole(v)
  9741. return nil
  9742. case contact.FieldDontseeit:
  9743. v, ok := value.(int)
  9744. if !ok {
  9745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9746. }
  9747. m.SetDontseeit(v)
  9748. return nil
  9749. case contact.FieldDontseeme:
  9750. v, ok := value.(int)
  9751. if !ok {
  9752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9753. }
  9754. m.SetDontseeme(v)
  9755. return nil
  9756. case contact.FieldLag:
  9757. v, ok := value.(string)
  9758. if !ok {
  9759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9760. }
  9761. m.SetLag(v)
  9762. return nil
  9763. case contact.FieldGid:
  9764. v, ok := value.(string)
  9765. if !ok {
  9766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9767. }
  9768. m.SetGid(v)
  9769. return nil
  9770. case contact.FieldGname:
  9771. v, ok := value.(string)
  9772. if !ok {
  9773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9774. }
  9775. m.SetGname(v)
  9776. return nil
  9777. case contact.FieldV3:
  9778. v, ok := value.(string)
  9779. if !ok {
  9780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9781. }
  9782. m.SetV3(v)
  9783. return nil
  9784. case contact.FieldOrganizationID:
  9785. v, ok := value.(uint64)
  9786. if !ok {
  9787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9788. }
  9789. m.SetOrganizationID(v)
  9790. return nil
  9791. case contact.FieldCtype:
  9792. v, ok := value.(uint64)
  9793. if !ok {
  9794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9795. }
  9796. m.SetCtype(v)
  9797. return nil
  9798. case contact.FieldCsex:
  9799. v, ok := value.(int)
  9800. if !ok {
  9801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9802. }
  9803. m.SetCsex(v)
  9804. return nil
  9805. case contact.FieldCage:
  9806. v, ok := value.(int)
  9807. if !ok {
  9808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9809. }
  9810. m.SetCage(v)
  9811. return nil
  9812. case contact.FieldCname:
  9813. v, ok := value.(string)
  9814. if !ok {
  9815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9816. }
  9817. m.SetCname(v)
  9818. return nil
  9819. case contact.FieldCarea:
  9820. v, ok := value.(string)
  9821. if !ok {
  9822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9823. }
  9824. m.SetCarea(v)
  9825. return nil
  9826. case contact.FieldCmobile:
  9827. v, ok := value.(string)
  9828. if !ok {
  9829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9830. }
  9831. m.SetCmobile(v)
  9832. return nil
  9833. case contact.FieldCbirthday:
  9834. v, ok := value.(string)
  9835. if !ok {
  9836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9837. }
  9838. m.SetCbirthday(v)
  9839. return nil
  9840. case contact.FieldCbirtharea:
  9841. v, ok := value.(string)
  9842. if !ok {
  9843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9844. }
  9845. m.SetCbirtharea(v)
  9846. return nil
  9847. case contact.FieldCidcardNo:
  9848. v, ok := value.(string)
  9849. if !ok {
  9850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9851. }
  9852. m.SetCidcardNo(v)
  9853. return nil
  9854. case contact.FieldCtitle:
  9855. v, ok := value.(string)
  9856. if !ok {
  9857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9858. }
  9859. m.SetCtitle(v)
  9860. return nil
  9861. case contact.FieldCc:
  9862. v, ok := value.(string)
  9863. if !ok {
  9864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9865. }
  9866. m.SetCc(v)
  9867. return nil
  9868. case contact.FieldPhone:
  9869. v, ok := value.(string)
  9870. if !ok {
  9871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9872. }
  9873. m.SetPhone(v)
  9874. return nil
  9875. }
  9876. return fmt.Errorf("unknown Contact field %s", name)
  9877. }
  9878. // AddedFields returns all numeric fields that were incremented/decremented during
  9879. // this mutation.
  9880. func (m *ContactMutation) AddedFields() []string {
  9881. var fields []string
  9882. if m.addstatus != nil {
  9883. fields = append(fields, contact.FieldStatus)
  9884. }
  9885. if m.add_type != nil {
  9886. fields = append(fields, contact.FieldType)
  9887. }
  9888. if m.addsex != nil {
  9889. fields = append(fields, contact.FieldSex)
  9890. }
  9891. if m.adddontseeit != nil {
  9892. fields = append(fields, contact.FieldDontseeit)
  9893. }
  9894. if m.adddontseeme != nil {
  9895. fields = append(fields, contact.FieldDontseeme)
  9896. }
  9897. if m.addorganization_id != nil {
  9898. fields = append(fields, contact.FieldOrganizationID)
  9899. }
  9900. if m.addctype != nil {
  9901. fields = append(fields, contact.FieldCtype)
  9902. }
  9903. if m.addcsex != nil {
  9904. fields = append(fields, contact.FieldCsex)
  9905. }
  9906. if m.addcage != nil {
  9907. fields = append(fields, contact.FieldCage)
  9908. }
  9909. return fields
  9910. }
  9911. // AddedField returns the numeric value that was incremented/decremented on a field
  9912. // with the given name. The second boolean return value indicates that this field
  9913. // was not set, or was not defined in the schema.
  9914. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  9915. switch name {
  9916. case contact.FieldStatus:
  9917. return m.AddedStatus()
  9918. case contact.FieldType:
  9919. return m.AddedType()
  9920. case contact.FieldSex:
  9921. return m.AddedSex()
  9922. case contact.FieldDontseeit:
  9923. return m.AddedDontseeit()
  9924. case contact.FieldDontseeme:
  9925. return m.AddedDontseeme()
  9926. case contact.FieldOrganizationID:
  9927. return m.AddedOrganizationID()
  9928. case contact.FieldCtype:
  9929. return m.AddedCtype()
  9930. case contact.FieldCsex:
  9931. return m.AddedCsex()
  9932. case contact.FieldCage:
  9933. return m.AddedCage()
  9934. }
  9935. return nil, false
  9936. }
  9937. // AddField adds the value to the field with the given name. It returns an error if
  9938. // the field is not defined in the schema, or if the type mismatched the field
  9939. // type.
  9940. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9941. switch name {
  9942. case contact.FieldStatus:
  9943. v, ok := value.(int8)
  9944. if !ok {
  9945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9946. }
  9947. m.AddStatus(v)
  9948. return nil
  9949. case contact.FieldType:
  9950. v, ok := value.(int)
  9951. if !ok {
  9952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9953. }
  9954. m.AddType(v)
  9955. return nil
  9956. case contact.FieldSex:
  9957. v, ok := value.(int)
  9958. if !ok {
  9959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9960. }
  9961. m.AddSex(v)
  9962. return nil
  9963. case contact.FieldDontseeit:
  9964. v, ok := value.(int)
  9965. if !ok {
  9966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9967. }
  9968. m.AddDontseeit(v)
  9969. return nil
  9970. case contact.FieldDontseeme:
  9971. v, ok := value.(int)
  9972. if !ok {
  9973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9974. }
  9975. m.AddDontseeme(v)
  9976. return nil
  9977. case contact.FieldOrganizationID:
  9978. v, ok := value.(int64)
  9979. if !ok {
  9980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9981. }
  9982. m.AddOrganizationID(v)
  9983. return nil
  9984. case contact.FieldCtype:
  9985. v, ok := value.(int64)
  9986. if !ok {
  9987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9988. }
  9989. m.AddCtype(v)
  9990. return nil
  9991. case contact.FieldCsex:
  9992. v, ok := value.(int)
  9993. if !ok {
  9994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9995. }
  9996. m.AddCsex(v)
  9997. return nil
  9998. case contact.FieldCage:
  9999. v, ok := value.(int)
  10000. if !ok {
  10001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10002. }
  10003. m.AddCage(v)
  10004. return nil
  10005. }
  10006. return fmt.Errorf("unknown Contact numeric field %s", name)
  10007. }
  10008. // ClearedFields returns all nullable fields that were cleared during this
  10009. // mutation.
  10010. func (m *ContactMutation) ClearedFields() []string {
  10011. var fields []string
  10012. if m.FieldCleared(contact.FieldStatus) {
  10013. fields = append(fields, contact.FieldStatus)
  10014. }
  10015. if m.FieldCleared(contact.FieldDeletedAt) {
  10016. fields = append(fields, contact.FieldDeletedAt)
  10017. }
  10018. if m.FieldCleared(contact.FieldType) {
  10019. fields = append(fields, contact.FieldType)
  10020. }
  10021. if m.FieldCleared(contact.FieldOrganizationID) {
  10022. fields = append(fields, contact.FieldOrganizationID)
  10023. }
  10024. return fields
  10025. }
  10026. // FieldCleared returns a boolean indicating if a field with the given name was
  10027. // cleared in this mutation.
  10028. func (m *ContactMutation) FieldCleared(name string) bool {
  10029. _, ok := m.clearedFields[name]
  10030. return ok
  10031. }
  10032. // ClearField clears the value of the field with the given name. It returns an
  10033. // error if the field is not defined in the schema.
  10034. func (m *ContactMutation) ClearField(name string) error {
  10035. switch name {
  10036. case contact.FieldStatus:
  10037. m.ClearStatus()
  10038. return nil
  10039. case contact.FieldDeletedAt:
  10040. m.ClearDeletedAt()
  10041. return nil
  10042. case contact.FieldType:
  10043. m.ClearType()
  10044. return nil
  10045. case contact.FieldOrganizationID:
  10046. m.ClearOrganizationID()
  10047. return nil
  10048. }
  10049. return fmt.Errorf("unknown Contact nullable field %s", name)
  10050. }
  10051. // ResetField resets all changes in the mutation for the field with the given name.
  10052. // It returns an error if the field is not defined in the schema.
  10053. func (m *ContactMutation) ResetField(name string) error {
  10054. switch name {
  10055. case contact.FieldCreatedAt:
  10056. m.ResetCreatedAt()
  10057. return nil
  10058. case contact.FieldUpdatedAt:
  10059. m.ResetUpdatedAt()
  10060. return nil
  10061. case contact.FieldStatus:
  10062. m.ResetStatus()
  10063. return nil
  10064. case contact.FieldDeletedAt:
  10065. m.ResetDeletedAt()
  10066. return nil
  10067. case contact.FieldWxWxid:
  10068. m.ResetWxWxid()
  10069. return nil
  10070. case contact.FieldType:
  10071. m.ResetType()
  10072. return nil
  10073. case contact.FieldWxid:
  10074. m.ResetWxid()
  10075. return nil
  10076. case contact.FieldAccount:
  10077. m.ResetAccount()
  10078. return nil
  10079. case contact.FieldNickname:
  10080. m.ResetNickname()
  10081. return nil
  10082. case contact.FieldMarkname:
  10083. m.ResetMarkname()
  10084. return nil
  10085. case contact.FieldHeadimg:
  10086. m.ResetHeadimg()
  10087. return nil
  10088. case contact.FieldSex:
  10089. m.ResetSex()
  10090. return nil
  10091. case contact.FieldStarrole:
  10092. m.ResetStarrole()
  10093. return nil
  10094. case contact.FieldDontseeit:
  10095. m.ResetDontseeit()
  10096. return nil
  10097. case contact.FieldDontseeme:
  10098. m.ResetDontseeme()
  10099. return nil
  10100. case contact.FieldLag:
  10101. m.ResetLag()
  10102. return nil
  10103. case contact.FieldGid:
  10104. m.ResetGid()
  10105. return nil
  10106. case contact.FieldGname:
  10107. m.ResetGname()
  10108. return nil
  10109. case contact.FieldV3:
  10110. m.ResetV3()
  10111. return nil
  10112. case contact.FieldOrganizationID:
  10113. m.ResetOrganizationID()
  10114. return nil
  10115. case contact.FieldCtype:
  10116. m.ResetCtype()
  10117. return nil
  10118. case contact.FieldCsex:
  10119. m.ResetCsex()
  10120. return nil
  10121. case contact.FieldCage:
  10122. m.ResetCage()
  10123. return nil
  10124. case contact.FieldCname:
  10125. m.ResetCname()
  10126. return nil
  10127. case contact.FieldCarea:
  10128. m.ResetCarea()
  10129. return nil
  10130. case contact.FieldCmobile:
  10131. m.ResetCmobile()
  10132. return nil
  10133. case contact.FieldCbirthday:
  10134. m.ResetCbirthday()
  10135. return nil
  10136. case contact.FieldCbirtharea:
  10137. m.ResetCbirtharea()
  10138. return nil
  10139. case contact.FieldCidcardNo:
  10140. m.ResetCidcardNo()
  10141. return nil
  10142. case contact.FieldCtitle:
  10143. m.ResetCtitle()
  10144. return nil
  10145. case contact.FieldCc:
  10146. m.ResetCc()
  10147. return nil
  10148. case contact.FieldPhone:
  10149. m.ResetPhone()
  10150. return nil
  10151. }
  10152. return fmt.Errorf("unknown Contact field %s", name)
  10153. }
  10154. // AddedEdges returns all edge names that were set/added in this mutation.
  10155. func (m *ContactMutation) AddedEdges() []string {
  10156. edges := make([]string, 0, 2)
  10157. if m.contact_relationships != nil {
  10158. edges = append(edges, contact.EdgeContactRelationships)
  10159. }
  10160. if m.contact_messages != nil {
  10161. edges = append(edges, contact.EdgeContactMessages)
  10162. }
  10163. return edges
  10164. }
  10165. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10166. // name in this mutation.
  10167. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  10168. switch name {
  10169. case contact.EdgeContactRelationships:
  10170. ids := make([]ent.Value, 0, len(m.contact_relationships))
  10171. for id := range m.contact_relationships {
  10172. ids = append(ids, id)
  10173. }
  10174. return ids
  10175. case contact.EdgeContactMessages:
  10176. ids := make([]ent.Value, 0, len(m.contact_messages))
  10177. for id := range m.contact_messages {
  10178. ids = append(ids, id)
  10179. }
  10180. return ids
  10181. }
  10182. return nil
  10183. }
  10184. // RemovedEdges returns all edge names that were removed in this mutation.
  10185. func (m *ContactMutation) RemovedEdges() []string {
  10186. edges := make([]string, 0, 2)
  10187. if m.removedcontact_relationships != nil {
  10188. edges = append(edges, contact.EdgeContactRelationships)
  10189. }
  10190. if m.removedcontact_messages != nil {
  10191. edges = append(edges, contact.EdgeContactMessages)
  10192. }
  10193. return edges
  10194. }
  10195. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10196. // the given name in this mutation.
  10197. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  10198. switch name {
  10199. case contact.EdgeContactRelationships:
  10200. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  10201. for id := range m.removedcontact_relationships {
  10202. ids = append(ids, id)
  10203. }
  10204. return ids
  10205. case contact.EdgeContactMessages:
  10206. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  10207. for id := range m.removedcontact_messages {
  10208. ids = append(ids, id)
  10209. }
  10210. return ids
  10211. }
  10212. return nil
  10213. }
  10214. // ClearedEdges returns all edge names that were cleared in this mutation.
  10215. func (m *ContactMutation) ClearedEdges() []string {
  10216. edges := make([]string, 0, 2)
  10217. if m.clearedcontact_relationships {
  10218. edges = append(edges, contact.EdgeContactRelationships)
  10219. }
  10220. if m.clearedcontact_messages {
  10221. edges = append(edges, contact.EdgeContactMessages)
  10222. }
  10223. return edges
  10224. }
  10225. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10226. // was cleared in this mutation.
  10227. func (m *ContactMutation) EdgeCleared(name string) bool {
  10228. switch name {
  10229. case contact.EdgeContactRelationships:
  10230. return m.clearedcontact_relationships
  10231. case contact.EdgeContactMessages:
  10232. return m.clearedcontact_messages
  10233. }
  10234. return false
  10235. }
  10236. // ClearEdge clears the value of the edge with the given name. It returns an error
  10237. // if that edge is not defined in the schema.
  10238. func (m *ContactMutation) ClearEdge(name string) error {
  10239. switch name {
  10240. }
  10241. return fmt.Errorf("unknown Contact unique edge %s", name)
  10242. }
  10243. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10244. // It returns an error if the edge is not defined in the schema.
  10245. func (m *ContactMutation) ResetEdge(name string) error {
  10246. switch name {
  10247. case contact.EdgeContactRelationships:
  10248. m.ResetContactRelationships()
  10249. return nil
  10250. case contact.EdgeContactMessages:
  10251. m.ResetContactMessages()
  10252. return nil
  10253. }
  10254. return fmt.Errorf("unknown Contact edge %s", name)
  10255. }
  10256. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  10257. type CreditBalanceMutation struct {
  10258. config
  10259. op Op
  10260. typ string
  10261. id *uint64
  10262. created_at *time.Time
  10263. updated_at *time.Time
  10264. deleted_at *time.Time
  10265. user_id *string
  10266. balance *float32
  10267. addbalance *float32
  10268. status *int
  10269. addstatus *int
  10270. organization_id *uint64
  10271. addorganization_id *int64
  10272. clearedFields map[string]struct{}
  10273. done bool
  10274. oldValue func(context.Context) (*CreditBalance, error)
  10275. predicates []predicate.CreditBalance
  10276. }
  10277. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  10278. // creditbalanceOption allows management of the mutation configuration using functional options.
  10279. type creditbalanceOption func(*CreditBalanceMutation)
  10280. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  10281. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  10282. m := &CreditBalanceMutation{
  10283. config: c,
  10284. op: op,
  10285. typ: TypeCreditBalance,
  10286. clearedFields: make(map[string]struct{}),
  10287. }
  10288. for _, opt := range opts {
  10289. opt(m)
  10290. }
  10291. return m
  10292. }
  10293. // withCreditBalanceID sets the ID field of the mutation.
  10294. func withCreditBalanceID(id uint64) creditbalanceOption {
  10295. return func(m *CreditBalanceMutation) {
  10296. var (
  10297. err error
  10298. once sync.Once
  10299. value *CreditBalance
  10300. )
  10301. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  10302. once.Do(func() {
  10303. if m.done {
  10304. err = errors.New("querying old values post mutation is not allowed")
  10305. } else {
  10306. value, err = m.Client().CreditBalance.Get(ctx, id)
  10307. }
  10308. })
  10309. return value, err
  10310. }
  10311. m.id = &id
  10312. }
  10313. }
  10314. // withCreditBalance sets the old CreditBalance of the mutation.
  10315. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  10316. return func(m *CreditBalanceMutation) {
  10317. m.oldValue = func(context.Context) (*CreditBalance, error) {
  10318. return node, nil
  10319. }
  10320. m.id = &node.ID
  10321. }
  10322. }
  10323. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10324. // executed in a transaction (ent.Tx), a transactional client is returned.
  10325. func (m CreditBalanceMutation) Client() *Client {
  10326. client := &Client{config: m.config}
  10327. client.init()
  10328. return client
  10329. }
  10330. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10331. // it returns an error otherwise.
  10332. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  10333. if _, ok := m.driver.(*txDriver); !ok {
  10334. return nil, errors.New("ent: mutation is not running in a transaction")
  10335. }
  10336. tx := &Tx{config: m.config}
  10337. tx.init()
  10338. return tx, nil
  10339. }
  10340. // SetID sets the value of the id field. Note that this
  10341. // operation is only accepted on creation of CreditBalance entities.
  10342. func (m *CreditBalanceMutation) SetID(id uint64) {
  10343. m.id = &id
  10344. }
  10345. // ID returns the ID value in the mutation. Note that the ID is only available
  10346. // if it was provided to the builder or after it was returned from the database.
  10347. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  10348. if m.id == nil {
  10349. return
  10350. }
  10351. return *m.id, true
  10352. }
  10353. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10354. // That means, if the mutation is applied within a transaction with an isolation level such
  10355. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10356. // or updated by the mutation.
  10357. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  10358. switch {
  10359. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10360. id, exists := m.ID()
  10361. if exists {
  10362. return []uint64{id}, nil
  10363. }
  10364. fallthrough
  10365. case m.op.Is(OpUpdate | OpDelete):
  10366. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  10367. default:
  10368. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10369. }
  10370. }
  10371. // SetCreatedAt sets the "created_at" field.
  10372. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  10373. m.created_at = &t
  10374. }
  10375. // CreatedAt returns the value of the "created_at" field in the mutation.
  10376. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  10377. v := m.created_at
  10378. if v == nil {
  10379. return
  10380. }
  10381. return *v, true
  10382. }
  10383. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  10384. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10386. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10387. if !m.op.Is(OpUpdateOne) {
  10388. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10389. }
  10390. if m.id == nil || m.oldValue == nil {
  10391. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10392. }
  10393. oldValue, err := m.oldValue(ctx)
  10394. if err != nil {
  10395. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10396. }
  10397. return oldValue.CreatedAt, nil
  10398. }
  10399. // ResetCreatedAt resets all changes to the "created_at" field.
  10400. func (m *CreditBalanceMutation) ResetCreatedAt() {
  10401. m.created_at = nil
  10402. }
  10403. // SetUpdatedAt sets the "updated_at" field.
  10404. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  10405. m.updated_at = &t
  10406. }
  10407. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10408. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  10409. v := m.updated_at
  10410. if v == nil {
  10411. return
  10412. }
  10413. return *v, true
  10414. }
  10415. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  10416. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10418. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10419. if !m.op.Is(OpUpdateOne) {
  10420. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10421. }
  10422. if m.id == nil || m.oldValue == nil {
  10423. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10424. }
  10425. oldValue, err := m.oldValue(ctx)
  10426. if err != nil {
  10427. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10428. }
  10429. return oldValue.UpdatedAt, nil
  10430. }
  10431. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10432. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  10433. m.updated_at = nil
  10434. }
  10435. // SetDeletedAt sets the "deleted_at" field.
  10436. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  10437. m.deleted_at = &t
  10438. }
  10439. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10440. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  10441. v := m.deleted_at
  10442. if v == nil {
  10443. return
  10444. }
  10445. return *v, true
  10446. }
  10447. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  10448. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10450. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10451. if !m.op.Is(OpUpdateOne) {
  10452. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10453. }
  10454. if m.id == nil || m.oldValue == nil {
  10455. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10456. }
  10457. oldValue, err := m.oldValue(ctx)
  10458. if err != nil {
  10459. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10460. }
  10461. return oldValue.DeletedAt, nil
  10462. }
  10463. // ClearDeletedAt clears the value of the "deleted_at" field.
  10464. func (m *CreditBalanceMutation) ClearDeletedAt() {
  10465. m.deleted_at = nil
  10466. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  10467. }
  10468. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10469. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  10470. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  10471. return ok
  10472. }
  10473. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10474. func (m *CreditBalanceMutation) ResetDeletedAt() {
  10475. m.deleted_at = nil
  10476. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  10477. }
  10478. // SetUserID sets the "user_id" field.
  10479. func (m *CreditBalanceMutation) SetUserID(s string) {
  10480. m.user_id = &s
  10481. }
  10482. // UserID returns the value of the "user_id" field in the mutation.
  10483. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  10484. v := m.user_id
  10485. if v == nil {
  10486. return
  10487. }
  10488. return *v, true
  10489. }
  10490. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  10491. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10493. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  10494. if !m.op.Is(OpUpdateOne) {
  10495. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10496. }
  10497. if m.id == nil || m.oldValue == nil {
  10498. return v, errors.New("OldUserID requires an ID field in the mutation")
  10499. }
  10500. oldValue, err := m.oldValue(ctx)
  10501. if err != nil {
  10502. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10503. }
  10504. return oldValue.UserID, nil
  10505. }
  10506. // ClearUserID clears the value of the "user_id" field.
  10507. func (m *CreditBalanceMutation) ClearUserID() {
  10508. m.user_id = nil
  10509. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  10510. }
  10511. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  10512. func (m *CreditBalanceMutation) UserIDCleared() bool {
  10513. _, ok := m.clearedFields[creditbalance.FieldUserID]
  10514. return ok
  10515. }
  10516. // ResetUserID resets all changes to the "user_id" field.
  10517. func (m *CreditBalanceMutation) ResetUserID() {
  10518. m.user_id = nil
  10519. delete(m.clearedFields, creditbalance.FieldUserID)
  10520. }
  10521. // SetBalance sets the "balance" field.
  10522. func (m *CreditBalanceMutation) SetBalance(f float32) {
  10523. m.balance = &f
  10524. m.addbalance = nil
  10525. }
  10526. // Balance returns the value of the "balance" field in the mutation.
  10527. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  10528. v := m.balance
  10529. if v == nil {
  10530. return
  10531. }
  10532. return *v, true
  10533. }
  10534. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  10535. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10537. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  10538. if !m.op.Is(OpUpdateOne) {
  10539. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  10540. }
  10541. if m.id == nil || m.oldValue == nil {
  10542. return v, errors.New("OldBalance requires an ID field in the mutation")
  10543. }
  10544. oldValue, err := m.oldValue(ctx)
  10545. if err != nil {
  10546. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  10547. }
  10548. return oldValue.Balance, nil
  10549. }
  10550. // AddBalance adds f to the "balance" field.
  10551. func (m *CreditBalanceMutation) AddBalance(f float32) {
  10552. if m.addbalance != nil {
  10553. *m.addbalance += f
  10554. } else {
  10555. m.addbalance = &f
  10556. }
  10557. }
  10558. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  10559. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  10560. v := m.addbalance
  10561. if v == nil {
  10562. return
  10563. }
  10564. return *v, true
  10565. }
  10566. // ResetBalance resets all changes to the "balance" field.
  10567. func (m *CreditBalanceMutation) ResetBalance() {
  10568. m.balance = nil
  10569. m.addbalance = nil
  10570. }
  10571. // SetStatus sets the "status" field.
  10572. func (m *CreditBalanceMutation) SetStatus(i int) {
  10573. m.status = &i
  10574. m.addstatus = nil
  10575. }
  10576. // Status returns the value of the "status" field in the mutation.
  10577. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  10578. v := m.status
  10579. if v == nil {
  10580. return
  10581. }
  10582. return *v, true
  10583. }
  10584. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  10585. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10587. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  10588. if !m.op.Is(OpUpdateOne) {
  10589. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10590. }
  10591. if m.id == nil || m.oldValue == nil {
  10592. return v, errors.New("OldStatus requires an ID field in the mutation")
  10593. }
  10594. oldValue, err := m.oldValue(ctx)
  10595. if err != nil {
  10596. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10597. }
  10598. return oldValue.Status, nil
  10599. }
  10600. // AddStatus adds i to the "status" field.
  10601. func (m *CreditBalanceMutation) AddStatus(i int) {
  10602. if m.addstatus != nil {
  10603. *m.addstatus += i
  10604. } else {
  10605. m.addstatus = &i
  10606. }
  10607. }
  10608. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10609. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  10610. v := m.addstatus
  10611. if v == nil {
  10612. return
  10613. }
  10614. return *v, true
  10615. }
  10616. // ClearStatus clears the value of the "status" field.
  10617. func (m *CreditBalanceMutation) ClearStatus() {
  10618. m.status = nil
  10619. m.addstatus = nil
  10620. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  10621. }
  10622. // StatusCleared returns if the "status" field was cleared in this mutation.
  10623. func (m *CreditBalanceMutation) StatusCleared() bool {
  10624. _, ok := m.clearedFields[creditbalance.FieldStatus]
  10625. return ok
  10626. }
  10627. // ResetStatus resets all changes to the "status" field.
  10628. func (m *CreditBalanceMutation) ResetStatus() {
  10629. m.status = nil
  10630. m.addstatus = nil
  10631. delete(m.clearedFields, creditbalance.FieldStatus)
  10632. }
  10633. // SetOrganizationID sets the "organization_id" field.
  10634. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  10635. m.organization_id = &u
  10636. m.addorganization_id = nil
  10637. }
  10638. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10639. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  10640. v := m.organization_id
  10641. if v == nil {
  10642. return
  10643. }
  10644. return *v, true
  10645. }
  10646. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  10647. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10649. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10650. if !m.op.Is(OpUpdateOne) {
  10651. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10652. }
  10653. if m.id == nil || m.oldValue == nil {
  10654. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10655. }
  10656. oldValue, err := m.oldValue(ctx)
  10657. if err != nil {
  10658. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10659. }
  10660. return oldValue.OrganizationID, nil
  10661. }
  10662. // AddOrganizationID adds u to the "organization_id" field.
  10663. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  10664. if m.addorganization_id != nil {
  10665. *m.addorganization_id += u
  10666. } else {
  10667. m.addorganization_id = &u
  10668. }
  10669. }
  10670. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10671. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  10672. v := m.addorganization_id
  10673. if v == nil {
  10674. return
  10675. }
  10676. return *v, true
  10677. }
  10678. // ClearOrganizationID clears the value of the "organization_id" field.
  10679. func (m *CreditBalanceMutation) ClearOrganizationID() {
  10680. m.organization_id = nil
  10681. m.addorganization_id = nil
  10682. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  10683. }
  10684. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10685. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  10686. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  10687. return ok
  10688. }
  10689. // ResetOrganizationID resets all changes to the "organization_id" field.
  10690. func (m *CreditBalanceMutation) ResetOrganizationID() {
  10691. m.organization_id = nil
  10692. m.addorganization_id = nil
  10693. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  10694. }
  10695. // Where appends a list predicates to the CreditBalanceMutation builder.
  10696. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  10697. m.predicates = append(m.predicates, ps...)
  10698. }
  10699. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  10700. // users can use type-assertion to append predicates that do not depend on any generated package.
  10701. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  10702. p := make([]predicate.CreditBalance, len(ps))
  10703. for i := range ps {
  10704. p[i] = ps[i]
  10705. }
  10706. m.Where(p...)
  10707. }
  10708. // Op returns the operation name.
  10709. func (m *CreditBalanceMutation) Op() Op {
  10710. return m.op
  10711. }
  10712. // SetOp allows setting the mutation operation.
  10713. func (m *CreditBalanceMutation) SetOp(op Op) {
  10714. m.op = op
  10715. }
  10716. // Type returns the node type of this mutation (CreditBalance).
  10717. func (m *CreditBalanceMutation) Type() string {
  10718. return m.typ
  10719. }
  10720. // Fields returns all fields that were changed during this mutation. Note that in
  10721. // order to get all numeric fields that were incremented/decremented, call
  10722. // AddedFields().
  10723. func (m *CreditBalanceMutation) Fields() []string {
  10724. fields := make([]string, 0, 7)
  10725. if m.created_at != nil {
  10726. fields = append(fields, creditbalance.FieldCreatedAt)
  10727. }
  10728. if m.updated_at != nil {
  10729. fields = append(fields, creditbalance.FieldUpdatedAt)
  10730. }
  10731. if m.deleted_at != nil {
  10732. fields = append(fields, creditbalance.FieldDeletedAt)
  10733. }
  10734. if m.user_id != nil {
  10735. fields = append(fields, creditbalance.FieldUserID)
  10736. }
  10737. if m.balance != nil {
  10738. fields = append(fields, creditbalance.FieldBalance)
  10739. }
  10740. if m.status != nil {
  10741. fields = append(fields, creditbalance.FieldStatus)
  10742. }
  10743. if m.organization_id != nil {
  10744. fields = append(fields, creditbalance.FieldOrganizationID)
  10745. }
  10746. return fields
  10747. }
  10748. // Field returns the value of a field with the given name. The second boolean
  10749. // return value indicates that this field was not set, or was not defined in the
  10750. // schema.
  10751. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  10752. switch name {
  10753. case creditbalance.FieldCreatedAt:
  10754. return m.CreatedAt()
  10755. case creditbalance.FieldUpdatedAt:
  10756. return m.UpdatedAt()
  10757. case creditbalance.FieldDeletedAt:
  10758. return m.DeletedAt()
  10759. case creditbalance.FieldUserID:
  10760. return m.UserID()
  10761. case creditbalance.FieldBalance:
  10762. return m.Balance()
  10763. case creditbalance.FieldStatus:
  10764. return m.Status()
  10765. case creditbalance.FieldOrganizationID:
  10766. return m.OrganizationID()
  10767. }
  10768. return nil, false
  10769. }
  10770. // OldField returns the old value of the field from the database. An error is
  10771. // returned if the mutation operation is not UpdateOne, or the query to the
  10772. // database failed.
  10773. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10774. switch name {
  10775. case creditbalance.FieldCreatedAt:
  10776. return m.OldCreatedAt(ctx)
  10777. case creditbalance.FieldUpdatedAt:
  10778. return m.OldUpdatedAt(ctx)
  10779. case creditbalance.FieldDeletedAt:
  10780. return m.OldDeletedAt(ctx)
  10781. case creditbalance.FieldUserID:
  10782. return m.OldUserID(ctx)
  10783. case creditbalance.FieldBalance:
  10784. return m.OldBalance(ctx)
  10785. case creditbalance.FieldStatus:
  10786. return m.OldStatus(ctx)
  10787. case creditbalance.FieldOrganizationID:
  10788. return m.OldOrganizationID(ctx)
  10789. }
  10790. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  10791. }
  10792. // SetField sets the value of a field with the given name. It returns an error if
  10793. // the field is not defined in the schema, or if the type mismatched the field
  10794. // type.
  10795. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  10796. switch name {
  10797. case creditbalance.FieldCreatedAt:
  10798. v, ok := value.(time.Time)
  10799. if !ok {
  10800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10801. }
  10802. m.SetCreatedAt(v)
  10803. return nil
  10804. case creditbalance.FieldUpdatedAt:
  10805. v, ok := value.(time.Time)
  10806. if !ok {
  10807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10808. }
  10809. m.SetUpdatedAt(v)
  10810. return nil
  10811. case creditbalance.FieldDeletedAt:
  10812. v, ok := value.(time.Time)
  10813. if !ok {
  10814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10815. }
  10816. m.SetDeletedAt(v)
  10817. return nil
  10818. case creditbalance.FieldUserID:
  10819. v, ok := value.(string)
  10820. if !ok {
  10821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10822. }
  10823. m.SetUserID(v)
  10824. return nil
  10825. case creditbalance.FieldBalance:
  10826. v, ok := value.(float32)
  10827. if !ok {
  10828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10829. }
  10830. m.SetBalance(v)
  10831. return nil
  10832. case creditbalance.FieldStatus:
  10833. v, ok := value.(int)
  10834. if !ok {
  10835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10836. }
  10837. m.SetStatus(v)
  10838. return nil
  10839. case creditbalance.FieldOrganizationID:
  10840. v, ok := value.(uint64)
  10841. if !ok {
  10842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10843. }
  10844. m.SetOrganizationID(v)
  10845. return nil
  10846. }
  10847. return fmt.Errorf("unknown CreditBalance field %s", name)
  10848. }
  10849. // AddedFields returns all numeric fields that were incremented/decremented during
  10850. // this mutation.
  10851. func (m *CreditBalanceMutation) AddedFields() []string {
  10852. var fields []string
  10853. if m.addbalance != nil {
  10854. fields = append(fields, creditbalance.FieldBalance)
  10855. }
  10856. if m.addstatus != nil {
  10857. fields = append(fields, creditbalance.FieldStatus)
  10858. }
  10859. if m.addorganization_id != nil {
  10860. fields = append(fields, creditbalance.FieldOrganizationID)
  10861. }
  10862. return fields
  10863. }
  10864. // AddedField returns the numeric value that was incremented/decremented on a field
  10865. // with the given name. The second boolean return value indicates that this field
  10866. // was not set, or was not defined in the schema.
  10867. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  10868. switch name {
  10869. case creditbalance.FieldBalance:
  10870. return m.AddedBalance()
  10871. case creditbalance.FieldStatus:
  10872. return m.AddedStatus()
  10873. case creditbalance.FieldOrganizationID:
  10874. return m.AddedOrganizationID()
  10875. }
  10876. return nil, false
  10877. }
  10878. // AddField adds the value to the field with the given name. It returns an error if
  10879. // the field is not defined in the schema, or if the type mismatched the field
  10880. // type.
  10881. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  10882. switch name {
  10883. case creditbalance.FieldBalance:
  10884. v, ok := value.(float32)
  10885. if !ok {
  10886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10887. }
  10888. m.AddBalance(v)
  10889. return nil
  10890. case creditbalance.FieldStatus:
  10891. v, ok := value.(int)
  10892. if !ok {
  10893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10894. }
  10895. m.AddStatus(v)
  10896. return nil
  10897. case creditbalance.FieldOrganizationID:
  10898. v, ok := value.(int64)
  10899. if !ok {
  10900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10901. }
  10902. m.AddOrganizationID(v)
  10903. return nil
  10904. }
  10905. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  10906. }
  10907. // ClearedFields returns all nullable fields that were cleared during this
  10908. // mutation.
  10909. func (m *CreditBalanceMutation) ClearedFields() []string {
  10910. var fields []string
  10911. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  10912. fields = append(fields, creditbalance.FieldDeletedAt)
  10913. }
  10914. if m.FieldCleared(creditbalance.FieldUserID) {
  10915. fields = append(fields, creditbalance.FieldUserID)
  10916. }
  10917. if m.FieldCleared(creditbalance.FieldStatus) {
  10918. fields = append(fields, creditbalance.FieldStatus)
  10919. }
  10920. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  10921. fields = append(fields, creditbalance.FieldOrganizationID)
  10922. }
  10923. return fields
  10924. }
  10925. // FieldCleared returns a boolean indicating if a field with the given name was
  10926. // cleared in this mutation.
  10927. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  10928. _, ok := m.clearedFields[name]
  10929. return ok
  10930. }
  10931. // ClearField clears the value of the field with the given name. It returns an
  10932. // error if the field is not defined in the schema.
  10933. func (m *CreditBalanceMutation) ClearField(name string) error {
  10934. switch name {
  10935. case creditbalance.FieldDeletedAt:
  10936. m.ClearDeletedAt()
  10937. return nil
  10938. case creditbalance.FieldUserID:
  10939. m.ClearUserID()
  10940. return nil
  10941. case creditbalance.FieldStatus:
  10942. m.ClearStatus()
  10943. return nil
  10944. case creditbalance.FieldOrganizationID:
  10945. m.ClearOrganizationID()
  10946. return nil
  10947. }
  10948. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  10949. }
  10950. // ResetField resets all changes in the mutation for the field with the given name.
  10951. // It returns an error if the field is not defined in the schema.
  10952. func (m *CreditBalanceMutation) ResetField(name string) error {
  10953. switch name {
  10954. case creditbalance.FieldCreatedAt:
  10955. m.ResetCreatedAt()
  10956. return nil
  10957. case creditbalance.FieldUpdatedAt:
  10958. m.ResetUpdatedAt()
  10959. return nil
  10960. case creditbalance.FieldDeletedAt:
  10961. m.ResetDeletedAt()
  10962. return nil
  10963. case creditbalance.FieldUserID:
  10964. m.ResetUserID()
  10965. return nil
  10966. case creditbalance.FieldBalance:
  10967. m.ResetBalance()
  10968. return nil
  10969. case creditbalance.FieldStatus:
  10970. m.ResetStatus()
  10971. return nil
  10972. case creditbalance.FieldOrganizationID:
  10973. m.ResetOrganizationID()
  10974. return nil
  10975. }
  10976. return fmt.Errorf("unknown CreditBalance field %s", name)
  10977. }
  10978. // AddedEdges returns all edge names that were set/added in this mutation.
  10979. func (m *CreditBalanceMutation) AddedEdges() []string {
  10980. edges := make([]string, 0, 0)
  10981. return edges
  10982. }
  10983. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10984. // name in this mutation.
  10985. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  10986. return nil
  10987. }
  10988. // RemovedEdges returns all edge names that were removed in this mutation.
  10989. func (m *CreditBalanceMutation) RemovedEdges() []string {
  10990. edges := make([]string, 0, 0)
  10991. return edges
  10992. }
  10993. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10994. // the given name in this mutation.
  10995. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  10996. return nil
  10997. }
  10998. // ClearedEdges returns all edge names that were cleared in this mutation.
  10999. func (m *CreditBalanceMutation) ClearedEdges() []string {
  11000. edges := make([]string, 0, 0)
  11001. return edges
  11002. }
  11003. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11004. // was cleared in this mutation.
  11005. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  11006. return false
  11007. }
  11008. // ClearEdge clears the value of the edge with the given name. It returns an error
  11009. // if that edge is not defined in the schema.
  11010. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  11011. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  11012. }
  11013. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11014. // It returns an error if the edge is not defined in the schema.
  11015. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  11016. return fmt.Errorf("unknown CreditBalance edge %s", name)
  11017. }
  11018. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  11019. type CreditUsageMutation struct {
  11020. config
  11021. op Op
  11022. typ string
  11023. id *uint64
  11024. created_at *time.Time
  11025. updated_at *time.Time
  11026. deleted_at *time.Time
  11027. user_id *string
  11028. number *float32
  11029. addnumber *float32
  11030. status *int
  11031. addstatus *int
  11032. ntype *int
  11033. addntype *int
  11034. table *string
  11035. organization_id *uint64
  11036. addorganization_id *int64
  11037. nid *uint64
  11038. addnid *int64
  11039. reason *string
  11040. operator *string
  11041. clearedFields map[string]struct{}
  11042. done bool
  11043. oldValue func(context.Context) (*CreditUsage, error)
  11044. predicates []predicate.CreditUsage
  11045. }
  11046. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  11047. // creditusageOption allows management of the mutation configuration using functional options.
  11048. type creditusageOption func(*CreditUsageMutation)
  11049. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  11050. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  11051. m := &CreditUsageMutation{
  11052. config: c,
  11053. op: op,
  11054. typ: TypeCreditUsage,
  11055. clearedFields: make(map[string]struct{}),
  11056. }
  11057. for _, opt := range opts {
  11058. opt(m)
  11059. }
  11060. return m
  11061. }
  11062. // withCreditUsageID sets the ID field of the mutation.
  11063. func withCreditUsageID(id uint64) creditusageOption {
  11064. return func(m *CreditUsageMutation) {
  11065. var (
  11066. err error
  11067. once sync.Once
  11068. value *CreditUsage
  11069. )
  11070. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  11071. once.Do(func() {
  11072. if m.done {
  11073. err = errors.New("querying old values post mutation is not allowed")
  11074. } else {
  11075. value, err = m.Client().CreditUsage.Get(ctx, id)
  11076. }
  11077. })
  11078. return value, err
  11079. }
  11080. m.id = &id
  11081. }
  11082. }
  11083. // withCreditUsage sets the old CreditUsage of the mutation.
  11084. func withCreditUsage(node *CreditUsage) creditusageOption {
  11085. return func(m *CreditUsageMutation) {
  11086. m.oldValue = func(context.Context) (*CreditUsage, error) {
  11087. return node, nil
  11088. }
  11089. m.id = &node.ID
  11090. }
  11091. }
  11092. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11093. // executed in a transaction (ent.Tx), a transactional client is returned.
  11094. func (m CreditUsageMutation) Client() *Client {
  11095. client := &Client{config: m.config}
  11096. client.init()
  11097. return client
  11098. }
  11099. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11100. // it returns an error otherwise.
  11101. func (m CreditUsageMutation) Tx() (*Tx, error) {
  11102. if _, ok := m.driver.(*txDriver); !ok {
  11103. return nil, errors.New("ent: mutation is not running in a transaction")
  11104. }
  11105. tx := &Tx{config: m.config}
  11106. tx.init()
  11107. return tx, nil
  11108. }
  11109. // SetID sets the value of the id field. Note that this
  11110. // operation is only accepted on creation of CreditUsage entities.
  11111. func (m *CreditUsageMutation) SetID(id uint64) {
  11112. m.id = &id
  11113. }
  11114. // ID returns the ID value in the mutation. Note that the ID is only available
  11115. // if it was provided to the builder or after it was returned from the database.
  11116. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  11117. if m.id == nil {
  11118. return
  11119. }
  11120. return *m.id, true
  11121. }
  11122. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11123. // That means, if the mutation is applied within a transaction with an isolation level such
  11124. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11125. // or updated by the mutation.
  11126. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  11127. switch {
  11128. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11129. id, exists := m.ID()
  11130. if exists {
  11131. return []uint64{id}, nil
  11132. }
  11133. fallthrough
  11134. case m.op.Is(OpUpdate | OpDelete):
  11135. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  11136. default:
  11137. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11138. }
  11139. }
  11140. // SetCreatedAt sets the "created_at" field.
  11141. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  11142. m.created_at = &t
  11143. }
  11144. // CreatedAt returns the value of the "created_at" field in the mutation.
  11145. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  11146. v := m.created_at
  11147. if v == nil {
  11148. return
  11149. }
  11150. return *v, true
  11151. }
  11152. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  11153. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11155. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11156. if !m.op.Is(OpUpdateOne) {
  11157. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11158. }
  11159. if m.id == nil || m.oldValue == nil {
  11160. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11161. }
  11162. oldValue, err := m.oldValue(ctx)
  11163. if err != nil {
  11164. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11165. }
  11166. return oldValue.CreatedAt, nil
  11167. }
  11168. // ResetCreatedAt resets all changes to the "created_at" field.
  11169. func (m *CreditUsageMutation) ResetCreatedAt() {
  11170. m.created_at = nil
  11171. }
  11172. // SetUpdatedAt sets the "updated_at" field.
  11173. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  11174. m.updated_at = &t
  11175. }
  11176. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11177. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  11178. v := m.updated_at
  11179. if v == nil {
  11180. return
  11181. }
  11182. return *v, true
  11183. }
  11184. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  11185. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11187. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11188. if !m.op.Is(OpUpdateOne) {
  11189. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11190. }
  11191. if m.id == nil || m.oldValue == nil {
  11192. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11193. }
  11194. oldValue, err := m.oldValue(ctx)
  11195. if err != nil {
  11196. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11197. }
  11198. return oldValue.UpdatedAt, nil
  11199. }
  11200. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11201. func (m *CreditUsageMutation) ResetUpdatedAt() {
  11202. m.updated_at = nil
  11203. }
  11204. // SetDeletedAt sets the "deleted_at" field.
  11205. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  11206. m.deleted_at = &t
  11207. }
  11208. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11209. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  11210. v := m.deleted_at
  11211. if v == nil {
  11212. return
  11213. }
  11214. return *v, true
  11215. }
  11216. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  11217. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11219. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11220. if !m.op.Is(OpUpdateOne) {
  11221. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11222. }
  11223. if m.id == nil || m.oldValue == nil {
  11224. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11225. }
  11226. oldValue, err := m.oldValue(ctx)
  11227. if err != nil {
  11228. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11229. }
  11230. return oldValue.DeletedAt, nil
  11231. }
  11232. // ClearDeletedAt clears the value of the "deleted_at" field.
  11233. func (m *CreditUsageMutation) ClearDeletedAt() {
  11234. m.deleted_at = nil
  11235. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  11236. }
  11237. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11238. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  11239. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  11240. return ok
  11241. }
  11242. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11243. func (m *CreditUsageMutation) ResetDeletedAt() {
  11244. m.deleted_at = nil
  11245. delete(m.clearedFields, creditusage.FieldDeletedAt)
  11246. }
  11247. // SetUserID sets the "user_id" field.
  11248. func (m *CreditUsageMutation) SetUserID(s string) {
  11249. m.user_id = &s
  11250. }
  11251. // UserID returns the value of the "user_id" field in the mutation.
  11252. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  11253. v := m.user_id
  11254. if v == nil {
  11255. return
  11256. }
  11257. return *v, true
  11258. }
  11259. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  11260. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11262. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  11263. if !m.op.Is(OpUpdateOne) {
  11264. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  11265. }
  11266. if m.id == nil || m.oldValue == nil {
  11267. return v, errors.New("OldUserID requires an ID field in the mutation")
  11268. }
  11269. oldValue, err := m.oldValue(ctx)
  11270. if err != nil {
  11271. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  11272. }
  11273. return oldValue.UserID, nil
  11274. }
  11275. // ClearUserID clears the value of the "user_id" field.
  11276. func (m *CreditUsageMutation) ClearUserID() {
  11277. m.user_id = nil
  11278. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  11279. }
  11280. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  11281. func (m *CreditUsageMutation) UserIDCleared() bool {
  11282. _, ok := m.clearedFields[creditusage.FieldUserID]
  11283. return ok
  11284. }
  11285. // ResetUserID resets all changes to the "user_id" field.
  11286. func (m *CreditUsageMutation) ResetUserID() {
  11287. m.user_id = nil
  11288. delete(m.clearedFields, creditusage.FieldUserID)
  11289. }
  11290. // SetNumber sets the "number" field.
  11291. func (m *CreditUsageMutation) SetNumber(f float32) {
  11292. m.number = &f
  11293. m.addnumber = nil
  11294. }
  11295. // Number returns the value of the "number" field in the mutation.
  11296. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  11297. v := m.number
  11298. if v == nil {
  11299. return
  11300. }
  11301. return *v, true
  11302. }
  11303. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  11304. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11306. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  11307. if !m.op.Is(OpUpdateOne) {
  11308. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  11309. }
  11310. if m.id == nil || m.oldValue == nil {
  11311. return v, errors.New("OldNumber requires an ID field in the mutation")
  11312. }
  11313. oldValue, err := m.oldValue(ctx)
  11314. if err != nil {
  11315. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  11316. }
  11317. return oldValue.Number, nil
  11318. }
  11319. // AddNumber adds f to the "number" field.
  11320. func (m *CreditUsageMutation) AddNumber(f float32) {
  11321. if m.addnumber != nil {
  11322. *m.addnumber += f
  11323. } else {
  11324. m.addnumber = &f
  11325. }
  11326. }
  11327. // AddedNumber returns the value that was added to the "number" field in this mutation.
  11328. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  11329. v := m.addnumber
  11330. if v == nil {
  11331. return
  11332. }
  11333. return *v, true
  11334. }
  11335. // ResetNumber resets all changes to the "number" field.
  11336. func (m *CreditUsageMutation) ResetNumber() {
  11337. m.number = nil
  11338. m.addnumber = nil
  11339. }
  11340. // SetStatus sets the "status" field.
  11341. func (m *CreditUsageMutation) SetStatus(i int) {
  11342. m.status = &i
  11343. m.addstatus = nil
  11344. }
  11345. // Status returns the value of the "status" field in the mutation.
  11346. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  11347. v := m.status
  11348. if v == nil {
  11349. return
  11350. }
  11351. return *v, true
  11352. }
  11353. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  11354. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11356. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  11357. if !m.op.Is(OpUpdateOne) {
  11358. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11359. }
  11360. if m.id == nil || m.oldValue == nil {
  11361. return v, errors.New("OldStatus requires an ID field in the mutation")
  11362. }
  11363. oldValue, err := m.oldValue(ctx)
  11364. if err != nil {
  11365. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11366. }
  11367. return oldValue.Status, nil
  11368. }
  11369. // AddStatus adds i to the "status" field.
  11370. func (m *CreditUsageMutation) AddStatus(i int) {
  11371. if m.addstatus != nil {
  11372. *m.addstatus += i
  11373. } else {
  11374. m.addstatus = &i
  11375. }
  11376. }
  11377. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11378. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  11379. v := m.addstatus
  11380. if v == nil {
  11381. return
  11382. }
  11383. return *v, true
  11384. }
  11385. // ClearStatus clears the value of the "status" field.
  11386. func (m *CreditUsageMutation) ClearStatus() {
  11387. m.status = nil
  11388. m.addstatus = nil
  11389. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  11390. }
  11391. // StatusCleared returns if the "status" field was cleared in this mutation.
  11392. func (m *CreditUsageMutation) StatusCleared() bool {
  11393. _, ok := m.clearedFields[creditusage.FieldStatus]
  11394. return ok
  11395. }
  11396. // ResetStatus resets all changes to the "status" field.
  11397. func (m *CreditUsageMutation) ResetStatus() {
  11398. m.status = nil
  11399. m.addstatus = nil
  11400. delete(m.clearedFields, creditusage.FieldStatus)
  11401. }
  11402. // SetNtype sets the "ntype" field.
  11403. func (m *CreditUsageMutation) SetNtype(i int) {
  11404. m.ntype = &i
  11405. m.addntype = nil
  11406. }
  11407. // Ntype returns the value of the "ntype" field in the mutation.
  11408. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  11409. v := m.ntype
  11410. if v == nil {
  11411. return
  11412. }
  11413. return *v, true
  11414. }
  11415. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  11416. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11418. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  11419. if !m.op.Is(OpUpdateOne) {
  11420. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  11421. }
  11422. if m.id == nil || m.oldValue == nil {
  11423. return v, errors.New("OldNtype requires an ID field in the mutation")
  11424. }
  11425. oldValue, err := m.oldValue(ctx)
  11426. if err != nil {
  11427. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  11428. }
  11429. return oldValue.Ntype, nil
  11430. }
  11431. // AddNtype adds i to the "ntype" field.
  11432. func (m *CreditUsageMutation) AddNtype(i int) {
  11433. if m.addntype != nil {
  11434. *m.addntype += i
  11435. } else {
  11436. m.addntype = &i
  11437. }
  11438. }
  11439. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  11440. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  11441. v := m.addntype
  11442. if v == nil {
  11443. return
  11444. }
  11445. return *v, true
  11446. }
  11447. // ResetNtype resets all changes to the "ntype" field.
  11448. func (m *CreditUsageMutation) ResetNtype() {
  11449. m.ntype = nil
  11450. m.addntype = nil
  11451. }
  11452. // SetTable sets the "table" field.
  11453. func (m *CreditUsageMutation) SetTable(s string) {
  11454. m.table = &s
  11455. }
  11456. // Table returns the value of the "table" field in the mutation.
  11457. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  11458. v := m.table
  11459. if v == nil {
  11460. return
  11461. }
  11462. return *v, true
  11463. }
  11464. // OldTable returns the old "table" field's value of the CreditUsage entity.
  11465. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11467. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  11468. if !m.op.Is(OpUpdateOne) {
  11469. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  11470. }
  11471. if m.id == nil || m.oldValue == nil {
  11472. return v, errors.New("OldTable requires an ID field in the mutation")
  11473. }
  11474. oldValue, err := m.oldValue(ctx)
  11475. if err != nil {
  11476. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  11477. }
  11478. return oldValue.Table, nil
  11479. }
  11480. // ResetTable resets all changes to the "table" field.
  11481. func (m *CreditUsageMutation) ResetTable() {
  11482. m.table = nil
  11483. }
  11484. // SetOrganizationID sets the "organization_id" field.
  11485. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  11486. m.organization_id = &u
  11487. m.addorganization_id = nil
  11488. }
  11489. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11490. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  11491. v := m.organization_id
  11492. if v == nil {
  11493. return
  11494. }
  11495. return *v, true
  11496. }
  11497. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  11498. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11500. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11501. if !m.op.Is(OpUpdateOne) {
  11502. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11503. }
  11504. if m.id == nil || m.oldValue == nil {
  11505. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11506. }
  11507. oldValue, err := m.oldValue(ctx)
  11508. if err != nil {
  11509. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11510. }
  11511. return oldValue.OrganizationID, nil
  11512. }
  11513. // AddOrganizationID adds u to the "organization_id" field.
  11514. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  11515. if m.addorganization_id != nil {
  11516. *m.addorganization_id += u
  11517. } else {
  11518. m.addorganization_id = &u
  11519. }
  11520. }
  11521. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11522. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  11523. v := m.addorganization_id
  11524. if v == nil {
  11525. return
  11526. }
  11527. return *v, true
  11528. }
  11529. // ClearOrganizationID clears the value of the "organization_id" field.
  11530. func (m *CreditUsageMutation) ClearOrganizationID() {
  11531. m.organization_id = nil
  11532. m.addorganization_id = nil
  11533. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  11534. }
  11535. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11536. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  11537. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  11538. return ok
  11539. }
  11540. // ResetOrganizationID resets all changes to the "organization_id" field.
  11541. func (m *CreditUsageMutation) ResetOrganizationID() {
  11542. m.organization_id = nil
  11543. m.addorganization_id = nil
  11544. delete(m.clearedFields, creditusage.FieldOrganizationID)
  11545. }
  11546. // SetNid sets the "nid" field.
  11547. func (m *CreditUsageMutation) SetNid(u uint64) {
  11548. m.nid = &u
  11549. m.addnid = nil
  11550. }
  11551. // Nid returns the value of the "nid" field in the mutation.
  11552. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  11553. v := m.nid
  11554. if v == nil {
  11555. return
  11556. }
  11557. return *v, true
  11558. }
  11559. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  11560. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11562. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  11563. if !m.op.Is(OpUpdateOne) {
  11564. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  11565. }
  11566. if m.id == nil || m.oldValue == nil {
  11567. return v, errors.New("OldNid requires an ID field in the mutation")
  11568. }
  11569. oldValue, err := m.oldValue(ctx)
  11570. if err != nil {
  11571. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  11572. }
  11573. return oldValue.Nid, nil
  11574. }
  11575. // AddNid adds u to the "nid" field.
  11576. func (m *CreditUsageMutation) AddNid(u int64) {
  11577. if m.addnid != nil {
  11578. *m.addnid += u
  11579. } else {
  11580. m.addnid = &u
  11581. }
  11582. }
  11583. // AddedNid returns the value that was added to the "nid" field in this mutation.
  11584. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  11585. v := m.addnid
  11586. if v == nil {
  11587. return
  11588. }
  11589. return *v, true
  11590. }
  11591. // ResetNid resets all changes to the "nid" field.
  11592. func (m *CreditUsageMutation) ResetNid() {
  11593. m.nid = nil
  11594. m.addnid = nil
  11595. }
  11596. // SetReason sets the "reason" field.
  11597. func (m *CreditUsageMutation) SetReason(s string) {
  11598. m.reason = &s
  11599. }
  11600. // Reason returns the value of the "reason" field in the mutation.
  11601. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  11602. v := m.reason
  11603. if v == nil {
  11604. return
  11605. }
  11606. return *v, true
  11607. }
  11608. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  11609. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11611. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  11612. if !m.op.Is(OpUpdateOne) {
  11613. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  11614. }
  11615. if m.id == nil || m.oldValue == nil {
  11616. return v, errors.New("OldReason requires an ID field in the mutation")
  11617. }
  11618. oldValue, err := m.oldValue(ctx)
  11619. if err != nil {
  11620. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  11621. }
  11622. return oldValue.Reason, nil
  11623. }
  11624. // ResetReason resets all changes to the "reason" field.
  11625. func (m *CreditUsageMutation) ResetReason() {
  11626. m.reason = nil
  11627. }
  11628. // SetOperator sets the "operator" field.
  11629. func (m *CreditUsageMutation) SetOperator(s string) {
  11630. m.operator = &s
  11631. }
  11632. // Operator returns the value of the "operator" field in the mutation.
  11633. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  11634. v := m.operator
  11635. if v == nil {
  11636. return
  11637. }
  11638. return *v, true
  11639. }
  11640. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  11641. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11643. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  11644. if !m.op.Is(OpUpdateOne) {
  11645. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  11646. }
  11647. if m.id == nil || m.oldValue == nil {
  11648. return v, errors.New("OldOperator requires an ID field in the mutation")
  11649. }
  11650. oldValue, err := m.oldValue(ctx)
  11651. if err != nil {
  11652. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  11653. }
  11654. return oldValue.Operator, nil
  11655. }
  11656. // ResetOperator resets all changes to the "operator" field.
  11657. func (m *CreditUsageMutation) ResetOperator() {
  11658. m.operator = nil
  11659. }
  11660. // Where appends a list predicates to the CreditUsageMutation builder.
  11661. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  11662. m.predicates = append(m.predicates, ps...)
  11663. }
  11664. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  11665. // users can use type-assertion to append predicates that do not depend on any generated package.
  11666. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  11667. p := make([]predicate.CreditUsage, len(ps))
  11668. for i := range ps {
  11669. p[i] = ps[i]
  11670. }
  11671. m.Where(p...)
  11672. }
  11673. // Op returns the operation name.
  11674. func (m *CreditUsageMutation) Op() Op {
  11675. return m.op
  11676. }
  11677. // SetOp allows setting the mutation operation.
  11678. func (m *CreditUsageMutation) SetOp(op Op) {
  11679. m.op = op
  11680. }
  11681. // Type returns the node type of this mutation (CreditUsage).
  11682. func (m *CreditUsageMutation) Type() string {
  11683. return m.typ
  11684. }
  11685. // Fields returns all fields that were changed during this mutation. Note that in
  11686. // order to get all numeric fields that were incremented/decremented, call
  11687. // AddedFields().
  11688. func (m *CreditUsageMutation) Fields() []string {
  11689. fields := make([]string, 0, 12)
  11690. if m.created_at != nil {
  11691. fields = append(fields, creditusage.FieldCreatedAt)
  11692. }
  11693. if m.updated_at != nil {
  11694. fields = append(fields, creditusage.FieldUpdatedAt)
  11695. }
  11696. if m.deleted_at != nil {
  11697. fields = append(fields, creditusage.FieldDeletedAt)
  11698. }
  11699. if m.user_id != nil {
  11700. fields = append(fields, creditusage.FieldUserID)
  11701. }
  11702. if m.number != nil {
  11703. fields = append(fields, creditusage.FieldNumber)
  11704. }
  11705. if m.status != nil {
  11706. fields = append(fields, creditusage.FieldStatus)
  11707. }
  11708. if m.ntype != nil {
  11709. fields = append(fields, creditusage.FieldNtype)
  11710. }
  11711. if m.table != nil {
  11712. fields = append(fields, creditusage.FieldTable)
  11713. }
  11714. if m.organization_id != nil {
  11715. fields = append(fields, creditusage.FieldOrganizationID)
  11716. }
  11717. if m.nid != nil {
  11718. fields = append(fields, creditusage.FieldNid)
  11719. }
  11720. if m.reason != nil {
  11721. fields = append(fields, creditusage.FieldReason)
  11722. }
  11723. if m.operator != nil {
  11724. fields = append(fields, creditusage.FieldOperator)
  11725. }
  11726. return fields
  11727. }
  11728. // Field returns the value of a field with the given name. The second boolean
  11729. // return value indicates that this field was not set, or was not defined in the
  11730. // schema.
  11731. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  11732. switch name {
  11733. case creditusage.FieldCreatedAt:
  11734. return m.CreatedAt()
  11735. case creditusage.FieldUpdatedAt:
  11736. return m.UpdatedAt()
  11737. case creditusage.FieldDeletedAt:
  11738. return m.DeletedAt()
  11739. case creditusage.FieldUserID:
  11740. return m.UserID()
  11741. case creditusage.FieldNumber:
  11742. return m.Number()
  11743. case creditusage.FieldStatus:
  11744. return m.Status()
  11745. case creditusage.FieldNtype:
  11746. return m.Ntype()
  11747. case creditusage.FieldTable:
  11748. return m.Table()
  11749. case creditusage.FieldOrganizationID:
  11750. return m.OrganizationID()
  11751. case creditusage.FieldNid:
  11752. return m.Nid()
  11753. case creditusage.FieldReason:
  11754. return m.Reason()
  11755. case creditusage.FieldOperator:
  11756. return m.Operator()
  11757. }
  11758. return nil, false
  11759. }
  11760. // OldField returns the old value of the field from the database. An error is
  11761. // returned if the mutation operation is not UpdateOne, or the query to the
  11762. // database failed.
  11763. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11764. switch name {
  11765. case creditusage.FieldCreatedAt:
  11766. return m.OldCreatedAt(ctx)
  11767. case creditusage.FieldUpdatedAt:
  11768. return m.OldUpdatedAt(ctx)
  11769. case creditusage.FieldDeletedAt:
  11770. return m.OldDeletedAt(ctx)
  11771. case creditusage.FieldUserID:
  11772. return m.OldUserID(ctx)
  11773. case creditusage.FieldNumber:
  11774. return m.OldNumber(ctx)
  11775. case creditusage.FieldStatus:
  11776. return m.OldStatus(ctx)
  11777. case creditusage.FieldNtype:
  11778. return m.OldNtype(ctx)
  11779. case creditusage.FieldTable:
  11780. return m.OldTable(ctx)
  11781. case creditusage.FieldOrganizationID:
  11782. return m.OldOrganizationID(ctx)
  11783. case creditusage.FieldNid:
  11784. return m.OldNid(ctx)
  11785. case creditusage.FieldReason:
  11786. return m.OldReason(ctx)
  11787. case creditusage.FieldOperator:
  11788. return m.OldOperator(ctx)
  11789. }
  11790. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  11791. }
  11792. // SetField sets the value of a field with the given name. It returns an error if
  11793. // the field is not defined in the schema, or if the type mismatched the field
  11794. // type.
  11795. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  11796. switch name {
  11797. case creditusage.FieldCreatedAt:
  11798. v, ok := value.(time.Time)
  11799. if !ok {
  11800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11801. }
  11802. m.SetCreatedAt(v)
  11803. return nil
  11804. case creditusage.FieldUpdatedAt:
  11805. v, ok := value.(time.Time)
  11806. if !ok {
  11807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11808. }
  11809. m.SetUpdatedAt(v)
  11810. return nil
  11811. case creditusage.FieldDeletedAt:
  11812. v, ok := value.(time.Time)
  11813. if !ok {
  11814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11815. }
  11816. m.SetDeletedAt(v)
  11817. return nil
  11818. case creditusage.FieldUserID:
  11819. v, ok := value.(string)
  11820. if !ok {
  11821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11822. }
  11823. m.SetUserID(v)
  11824. return nil
  11825. case creditusage.FieldNumber:
  11826. v, ok := value.(float32)
  11827. if !ok {
  11828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11829. }
  11830. m.SetNumber(v)
  11831. return nil
  11832. case creditusage.FieldStatus:
  11833. v, ok := value.(int)
  11834. if !ok {
  11835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11836. }
  11837. m.SetStatus(v)
  11838. return nil
  11839. case creditusage.FieldNtype:
  11840. v, ok := value.(int)
  11841. if !ok {
  11842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11843. }
  11844. m.SetNtype(v)
  11845. return nil
  11846. case creditusage.FieldTable:
  11847. v, ok := value.(string)
  11848. if !ok {
  11849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11850. }
  11851. m.SetTable(v)
  11852. return nil
  11853. case creditusage.FieldOrganizationID:
  11854. v, ok := value.(uint64)
  11855. if !ok {
  11856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11857. }
  11858. m.SetOrganizationID(v)
  11859. return nil
  11860. case creditusage.FieldNid:
  11861. v, ok := value.(uint64)
  11862. if !ok {
  11863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11864. }
  11865. m.SetNid(v)
  11866. return nil
  11867. case creditusage.FieldReason:
  11868. v, ok := value.(string)
  11869. if !ok {
  11870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11871. }
  11872. m.SetReason(v)
  11873. return nil
  11874. case creditusage.FieldOperator:
  11875. v, ok := value.(string)
  11876. if !ok {
  11877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11878. }
  11879. m.SetOperator(v)
  11880. return nil
  11881. }
  11882. return fmt.Errorf("unknown CreditUsage field %s", name)
  11883. }
  11884. // AddedFields returns all numeric fields that were incremented/decremented during
  11885. // this mutation.
  11886. func (m *CreditUsageMutation) AddedFields() []string {
  11887. var fields []string
  11888. if m.addnumber != nil {
  11889. fields = append(fields, creditusage.FieldNumber)
  11890. }
  11891. if m.addstatus != nil {
  11892. fields = append(fields, creditusage.FieldStatus)
  11893. }
  11894. if m.addntype != nil {
  11895. fields = append(fields, creditusage.FieldNtype)
  11896. }
  11897. if m.addorganization_id != nil {
  11898. fields = append(fields, creditusage.FieldOrganizationID)
  11899. }
  11900. if m.addnid != nil {
  11901. fields = append(fields, creditusage.FieldNid)
  11902. }
  11903. return fields
  11904. }
  11905. // AddedField returns the numeric value that was incremented/decremented on a field
  11906. // with the given name. The second boolean return value indicates that this field
  11907. // was not set, or was not defined in the schema.
  11908. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  11909. switch name {
  11910. case creditusage.FieldNumber:
  11911. return m.AddedNumber()
  11912. case creditusage.FieldStatus:
  11913. return m.AddedStatus()
  11914. case creditusage.FieldNtype:
  11915. return m.AddedNtype()
  11916. case creditusage.FieldOrganizationID:
  11917. return m.AddedOrganizationID()
  11918. case creditusage.FieldNid:
  11919. return m.AddedNid()
  11920. }
  11921. return nil, false
  11922. }
  11923. // AddField adds the value to the field with the given name. It returns an error if
  11924. // the field is not defined in the schema, or if the type mismatched the field
  11925. // type.
  11926. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  11927. switch name {
  11928. case creditusage.FieldNumber:
  11929. v, ok := value.(float32)
  11930. if !ok {
  11931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11932. }
  11933. m.AddNumber(v)
  11934. return nil
  11935. case creditusage.FieldStatus:
  11936. v, ok := value.(int)
  11937. if !ok {
  11938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11939. }
  11940. m.AddStatus(v)
  11941. return nil
  11942. case creditusage.FieldNtype:
  11943. v, ok := value.(int)
  11944. if !ok {
  11945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11946. }
  11947. m.AddNtype(v)
  11948. return nil
  11949. case creditusage.FieldOrganizationID:
  11950. v, ok := value.(int64)
  11951. if !ok {
  11952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11953. }
  11954. m.AddOrganizationID(v)
  11955. return nil
  11956. case creditusage.FieldNid:
  11957. v, ok := value.(int64)
  11958. if !ok {
  11959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11960. }
  11961. m.AddNid(v)
  11962. return nil
  11963. }
  11964. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  11965. }
  11966. // ClearedFields returns all nullable fields that were cleared during this
  11967. // mutation.
  11968. func (m *CreditUsageMutation) ClearedFields() []string {
  11969. var fields []string
  11970. if m.FieldCleared(creditusage.FieldDeletedAt) {
  11971. fields = append(fields, creditusage.FieldDeletedAt)
  11972. }
  11973. if m.FieldCleared(creditusage.FieldUserID) {
  11974. fields = append(fields, creditusage.FieldUserID)
  11975. }
  11976. if m.FieldCleared(creditusage.FieldStatus) {
  11977. fields = append(fields, creditusage.FieldStatus)
  11978. }
  11979. if m.FieldCleared(creditusage.FieldOrganizationID) {
  11980. fields = append(fields, creditusage.FieldOrganizationID)
  11981. }
  11982. return fields
  11983. }
  11984. // FieldCleared returns a boolean indicating if a field with the given name was
  11985. // cleared in this mutation.
  11986. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  11987. _, ok := m.clearedFields[name]
  11988. return ok
  11989. }
  11990. // ClearField clears the value of the field with the given name. It returns an
  11991. // error if the field is not defined in the schema.
  11992. func (m *CreditUsageMutation) ClearField(name string) error {
  11993. switch name {
  11994. case creditusage.FieldDeletedAt:
  11995. m.ClearDeletedAt()
  11996. return nil
  11997. case creditusage.FieldUserID:
  11998. m.ClearUserID()
  11999. return nil
  12000. case creditusage.FieldStatus:
  12001. m.ClearStatus()
  12002. return nil
  12003. case creditusage.FieldOrganizationID:
  12004. m.ClearOrganizationID()
  12005. return nil
  12006. }
  12007. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  12008. }
  12009. // ResetField resets all changes in the mutation for the field with the given name.
  12010. // It returns an error if the field is not defined in the schema.
  12011. func (m *CreditUsageMutation) ResetField(name string) error {
  12012. switch name {
  12013. case creditusage.FieldCreatedAt:
  12014. m.ResetCreatedAt()
  12015. return nil
  12016. case creditusage.FieldUpdatedAt:
  12017. m.ResetUpdatedAt()
  12018. return nil
  12019. case creditusage.FieldDeletedAt:
  12020. m.ResetDeletedAt()
  12021. return nil
  12022. case creditusage.FieldUserID:
  12023. m.ResetUserID()
  12024. return nil
  12025. case creditusage.FieldNumber:
  12026. m.ResetNumber()
  12027. return nil
  12028. case creditusage.FieldStatus:
  12029. m.ResetStatus()
  12030. return nil
  12031. case creditusage.FieldNtype:
  12032. m.ResetNtype()
  12033. return nil
  12034. case creditusage.FieldTable:
  12035. m.ResetTable()
  12036. return nil
  12037. case creditusage.FieldOrganizationID:
  12038. m.ResetOrganizationID()
  12039. return nil
  12040. case creditusage.FieldNid:
  12041. m.ResetNid()
  12042. return nil
  12043. case creditusage.FieldReason:
  12044. m.ResetReason()
  12045. return nil
  12046. case creditusage.FieldOperator:
  12047. m.ResetOperator()
  12048. return nil
  12049. }
  12050. return fmt.Errorf("unknown CreditUsage field %s", name)
  12051. }
  12052. // AddedEdges returns all edge names that were set/added in this mutation.
  12053. func (m *CreditUsageMutation) AddedEdges() []string {
  12054. edges := make([]string, 0, 0)
  12055. return edges
  12056. }
  12057. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12058. // name in this mutation.
  12059. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  12060. return nil
  12061. }
  12062. // RemovedEdges returns all edge names that were removed in this mutation.
  12063. func (m *CreditUsageMutation) RemovedEdges() []string {
  12064. edges := make([]string, 0, 0)
  12065. return edges
  12066. }
  12067. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12068. // the given name in this mutation.
  12069. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  12070. return nil
  12071. }
  12072. // ClearedEdges returns all edge names that were cleared in this mutation.
  12073. func (m *CreditUsageMutation) ClearedEdges() []string {
  12074. edges := make([]string, 0, 0)
  12075. return edges
  12076. }
  12077. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12078. // was cleared in this mutation.
  12079. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  12080. return false
  12081. }
  12082. // ClearEdge clears the value of the edge with the given name. It returns an error
  12083. // if that edge is not defined in the schema.
  12084. func (m *CreditUsageMutation) ClearEdge(name string) error {
  12085. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  12086. }
  12087. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12088. // It returns an error if the edge is not defined in the schema.
  12089. func (m *CreditUsageMutation) ResetEdge(name string) error {
  12090. return fmt.Errorf("unknown CreditUsage edge %s", name)
  12091. }
  12092. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  12093. type EmployeeMutation struct {
  12094. config
  12095. op Op
  12096. typ string
  12097. id *uint64
  12098. created_at *time.Time
  12099. updated_at *time.Time
  12100. deleted_at *time.Time
  12101. title *string
  12102. avatar *string
  12103. tags *string
  12104. hire_count *int
  12105. addhire_count *int
  12106. service_count *int
  12107. addservice_count *int
  12108. achievement_count *int
  12109. addachievement_count *int
  12110. intro *string
  12111. estimate *string
  12112. skill *string
  12113. ability_type *string
  12114. scene *string
  12115. switch_in *string
  12116. video_url *string
  12117. organization_id *uint64
  12118. addorganization_id *int64
  12119. category_id *uint64
  12120. addcategory_id *int64
  12121. api_base *string
  12122. api_key *string
  12123. ai_info *string
  12124. is_vip *int
  12125. addis_vip *int
  12126. chat_url *string
  12127. clearedFields map[string]struct{}
  12128. em_work_experiences map[uint64]struct{}
  12129. removedem_work_experiences map[uint64]struct{}
  12130. clearedem_work_experiences bool
  12131. em_tutorial map[uint64]struct{}
  12132. removedem_tutorial map[uint64]struct{}
  12133. clearedem_tutorial bool
  12134. done bool
  12135. oldValue func(context.Context) (*Employee, error)
  12136. predicates []predicate.Employee
  12137. }
  12138. var _ ent.Mutation = (*EmployeeMutation)(nil)
  12139. // employeeOption allows management of the mutation configuration using functional options.
  12140. type employeeOption func(*EmployeeMutation)
  12141. // newEmployeeMutation creates new mutation for the Employee entity.
  12142. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  12143. m := &EmployeeMutation{
  12144. config: c,
  12145. op: op,
  12146. typ: TypeEmployee,
  12147. clearedFields: make(map[string]struct{}),
  12148. }
  12149. for _, opt := range opts {
  12150. opt(m)
  12151. }
  12152. return m
  12153. }
  12154. // withEmployeeID sets the ID field of the mutation.
  12155. func withEmployeeID(id uint64) employeeOption {
  12156. return func(m *EmployeeMutation) {
  12157. var (
  12158. err error
  12159. once sync.Once
  12160. value *Employee
  12161. )
  12162. m.oldValue = func(ctx context.Context) (*Employee, error) {
  12163. once.Do(func() {
  12164. if m.done {
  12165. err = errors.New("querying old values post mutation is not allowed")
  12166. } else {
  12167. value, err = m.Client().Employee.Get(ctx, id)
  12168. }
  12169. })
  12170. return value, err
  12171. }
  12172. m.id = &id
  12173. }
  12174. }
  12175. // withEmployee sets the old Employee of the mutation.
  12176. func withEmployee(node *Employee) employeeOption {
  12177. return func(m *EmployeeMutation) {
  12178. m.oldValue = func(context.Context) (*Employee, error) {
  12179. return node, nil
  12180. }
  12181. m.id = &node.ID
  12182. }
  12183. }
  12184. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12185. // executed in a transaction (ent.Tx), a transactional client is returned.
  12186. func (m EmployeeMutation) Client() *Client {
  12187. client := &Client{config: m.config}
  12188. client.init()
  12189. return client
  12190. }
  12191. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12192. // it returns an error otherwise.
  12193. func (m EmployeeMutation) Tx() (*Tx, error) {
  12194. if _, ok := m.driver.(*txDriver); !ok {
  12195. return nil, errors.New("ent: mutation is not running in a transaction")
  12196. }
  12197. tx := &Tx{config: m.config}
  12198. tx.init()
  12199. return tx, nil
  12200. }
  12201. // SetID sets the value of the id field. Note that this
  12202. // operation is only accepted on creation of Employee entities.
  12203. func (m *EmployeeMutation) SetID(id uint64) {
  12204. m.id = &id
  12205. }
  12206. // ID returns the ID value in the mutation. Note that the ID is only available
  12207. // if it was provided to the builder or after it was returned from the database.
  12208. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  12209. if m.id == nil {
  12210. return
  12211. }
  12212. return *m.id, true
  12213. }
  12214. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12215. // That means, if the mutation is applied within a transaction with an isolation level such
  12216. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12217. // or updated by the mutation.
  12218. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  12219. switch {
  12220. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12221. id, exists := m.ID()
  12222. if exists {
  12223. return []uint64{id}, nil
  12224. }
  12225. fallthrough
  12226. case m.op.Is(OpUpdate | OpDelete):
  12227. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  12228. default:
  12229. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12230. }
  12231. }
  12232. // SetCreatedAt sets the "created_at" field.
  12233. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  12234. m.created_at = &t
  12235. }
  12236. // CreatedAt returns the value of the "created_at" field in the mutation.
  12237. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  12238. v := m.created_at
  12239. if v == nil {
  12240. return
  12241. }
  12242. return *v, true
  12243. }
  12244. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  12245. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12247. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12248. if !m.op.Is(OpUpdateOne) {
  12249. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12250. }
  12251. if m.id == nil || m.oldValue == nil {
  12252. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12253. }
  12254. oldValue, err := m.oldValue(ctx)
  12255. if err != nil {
  12256. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12257. }
  12258. return oldValue.CreatedAt, nil
  12259. }
  12260. // ResetCreatedAt resets all changes to the "created_at" field.
  12261. func (m *EmployeeMutation) ResetCreatedAt() {
  12262. m.created_at = nil
  12263. }
  12264. // SetUpdatedAt sets the "updated_at" field.
  12265. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  12266. m.updated_at = &t
  12267. }
  12268. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12269. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  12270. v := m.updated_at
  12271. if v == nil {
  12272. return
  12273. }
  12274. return *v, true
  12275. }
  12276. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  12277. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12279. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12280. if !m.op.Is(OpUpdateOne) {
  12281. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12282. }
  12283. if m.id == nil || m.oldValue == nil {
  12284. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12285. }
  12286. oldValue, err := m.oldValue(ctx)
  12287. if err != nil {
  12288. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12289. }
  12290. return oldValue.UpdatedAt, nil
  12291. }
  12292. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12293. func (m *EmployeeMutation) ResetUpdatedAt() {
  12294. m.updated_at = nil
  12295. }
  12296. // SetDeletedAt sets the "deleted_at" field.
  12297. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  12298. m.deleted_at = &t
  12299. }
  12300. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12301. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  12302. v := m.deleted_at
  12303. if v == nil {
  12304. return
  12305. }
  12306. return *v, true
  12307. }
  12308. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  12309. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12311. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12312. if !m.op.Is(OpUpdateOne) {
  12313. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12314. }
  12315. if m.id == nil || m.oldValue == nil {
  12316. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12317. }
  12318. oldValue, err := m.oldValue(ctx)
  12319. if err != nil {
  12320. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12321. }
  12322. return oldValue.DeletedAt, nil
  12323. }
  12324. // ClearDeletedAt clears the value of the "deleted_at" field.
  12325. func (m *EmployeeMutation) ClearDeletedAt() {
  12326. m.deleted_at = nil
  12327. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  12328. }
  12329. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12330. func (m *EmployeeMutation) DeletedAtCleared() bool {
  12331. _, ok := m.clearedFields[employee.FieldDeletedAt]
  12332. return ok
  12333. }
  12334. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12335. func (m *EmployeeMutation) ResetDeletedAt() {
  12336. m.deleted_at = nil
  12337. delete(m.clearedFields, employee.FieldDeletedAt)
  12338. }
  12339. // SetTitle sets the "title" field.
  12340. func (m *EmployeeMutation) SetTitle(s string) {
  12341. m.title = &s
  12342. }
  12343. // Title returns the value of the "title" field in the mutation.
  12344. func (m *EmployeeMutation) Title() (r string, exists bool) {
  12345. v := m.title
  12346. if v == nil {
  12347. return
  12348. }
  12349. return *v, true
  12350. }
  12351. // OldTitle returns the old "title" field's value of the Employee entity.
  12352. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12354. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  12355. if !m.op.Is(OpUpdateOne) {
  12356. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  12357. }
  12358. if m.id == nil || m.oldValue == nil {
  12359. return v, errors.New("OldTitle requires an ID field in the mutation")
  12360. }
  12361. oldValue, err := m.oldValue(ctx)
  12362. if err != nil {
  12363. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  12364. }
  12365. return oldValue.Title, nil
  12366. }
  12367. // ResetTitle resets all changes to the "title" field.
  12368. func (m *EmployeeMutation) ResetTitle() {
  12369. m.title = nil
  12370. }
  12371. // SetAvatar sets the "avatar" field.
  12372. func (m *EmployeeMutation) SetAvatar(s string) {
  12373. m.avatar = &s
  12374. }
  12375. // Avatar returns the value of the "avatar" field in the mutation.
  12376. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  12377. v := m.avatar
  12378. if v == nil {
  12379. return
  12380. }
  12381. return *v, true
  12382. }
  12383. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  12384. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12386. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  12387. if !m.op.Is(OpUpdateOne) {
  12388. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  12389. }
  12390. if m.id == nil || m.oldValue == nil {
  12391. return v, errors.New("OldAvatar requires an ID field in the mutation")
  12392. }
  12393. oldValue, err := m.oldValue(ctx)
  12394. if err != nil {
  12395. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  12396. }
  12397. return oldValue.Avatar, nil
  12398. }
  12399. // ResetAvatar resets all changes to the "avatar" field.
  12400. func (m *EmployeeMutation) ResetAvatar() {
  12401. m.avatar = nil
  12402. }
  12403. // SetTags sets the "tags" field.
  12404. func (m *EmployeeMutation) SetTags(s string) {
  12405. m.tags = &s
  12406. }
  12407. // Tags returns the value of the "tags" field in the mutation.
  12408. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  12409. v := m.tags
  12410. if v == nil {
  12411. return
  12412. }
  12413. return *v, true
  12414. }
  12415. // OldTags returns the old "tags" field's value of the Employee entity.
  12416. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12418. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  12419. if !m.op.Is(OpUpdateOne) {
  12420. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  12421. }
  12422. if m.id == nil || m.oldValue == nil {
  12423. return v, errors.New("OldTags requires an ID field in the mutation")
  12424. }
  12425. oldValue, err := m.oldValue(ctx)
  12426. if err != nil {
  12427. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  12428. }
  12429. return oldValue.Tags, nil
  12430. }
  12431. // ResetTags resets all changes to the "tags" field.
  12432. func (m *EmployeeMutation) ResetTags() {
  12433. m.tags = nil
  12434. }
  12435. // SetHireCount sets the "hire_count" field.
  12436. func (m *EmployeeMutation) SetHireCount(i int) {
  12437. m.hire_count = &i
  12438. m.addhire_count = nil
  12439. }
  12440. // HireCount returns the value of the "hire_count" field in the mutation.
  12441. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  12442. v := m.hire_count
  12443. if v == nil {
  12444. return
  12445. }
  12446. return *v, true
  12447. }
  12448. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  12449. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12451. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  12452. if !m.op.Is(OpUpdateOne) {
  12453. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  12454. }
  12455. if m.id == nil || m.oldValue == nil {
  12456. return v, errors.New("OldHireCount requires an ID field in the mutation")
  12457. }
  12458. oldValue, err := m.oldValue(ctx)
  12459. if err != nil {
  12460. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  12461. }
  12462. return oldValue.HireCount, nil
  12463. }
  12464. // AddHireCount adds i to the "hire_count" field.
  12465. func (m *EmployeeMutation) AddHireCount(i int) {
  12466. if m.addhire_count != nil {
  12467. *m.addhire_count += i
  12468. } else {
  12469. m.addhire_count = &i
  12470. }
  12471. }
  12472. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  12473. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  12474. v := m.addhire_count
  12475. if v == nil {
  12476. return
  12477. }
  12478. return *v, true
  12479. }
  12480. // ResetHireCount resets all changes to the "hire_count" field.
  12481. func (m *EmployeeMutation) ResetHireCount() {
  12482. m.hire_count = nil
  12483. m.addhire_count = nil
  12484. }
  12485. // SetServiceCount sets the "service_count" field.
  12486. func (m *EmployeeMutation) SetServiceCount(i int) {
  12487. m.service_count = &i
  12488. m.addservice_count = nil
  12489. }
  12490. // ServiceCount returns the value of the "service_count" field in the mutation.
  12491. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  12492. v := m.service_count
  12493. if v == nil {
  12494. return
  12495. }
  12496. return *v, true
  12497. }
  12498. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  12499. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12501. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  12502. if !m.op.Is(OpUpdateOne) {
  12503. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  12504. }
  12505. if m.id == nil || m.oldValue == nil {
  12506. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  12507. }
  12508. oldValue, err := m.oldValue(ctx)
  12509. if err != nil {
  12510. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  12511. }
  12512. return oldValue.ServiceCount, nil
  12513. }
  12514. // AddServiceCount adds i to the "service_count" field.
  12515. func (m *EmployeeMutation) AddServiceCount(i int) {
  12516. if m.addservice_count != nil {
  12517. *m.addservice_count += i
  12518. } else {
  12519. m.addservice_count = &i
  12520. }
  12521. }
  12522. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  12523. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  12524. v := m.addservice_count
  12525. if v == nil {
  12526. return
  12527. }
  12528. return *v, true
  12529. }
  12530. // ResetServiceCount resets all changes to the "service_count" field.
  12531. func (m *EmployeeMutation) ResetServiceCount() {
  12532. m.service_count = nil
  12533. m.addservice_count = nil
  12534. }
  12535. // SetAchievementCount sets the "achievement_count" field.
  12536. func (m *EmployeeMutation) SetAchievementCount(i int) {
  12537. m.achievement_count = &i
  12538. m.addachievement_count = nil
  12539. }
  12540. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  12541. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  12542. v := m.achievement_count
  12543. if v == nil {
  12544. return
  12545. }
  12546. return *v, true
  12547. }
  12548. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  12549. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12551. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  12552. if !m.op.Is(OpUpdateOne) {
  12553. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  12554. }
  12555. if m.id == nil || m.oldValue == nil {
  12556. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  12557. }
  12558. oldValue, err := m.oldValue(ctx)
  12559. if err != nil {
  12560. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  12561. }
  12562. return oldValue.AchievementCount, nil
  12563. }
  12564. // AddAchievementCount adds i to the "achievement_count" field.
  12565. func (m *EmployeeMutation) AddAchievementCount(i int) {
  12566. if m.addachievement_count != nil {
  12567. *m.addachievement_count += i
  12568. } else {
  12569. m.addachievement_count = &i
  12570. }
  12571. }
  12572. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  12573. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  12574. v := m.addachievement_count
  12575. if v == nil {
  12576. return
  12577. }
  12578. return *v, true
  12579. }
  12580. // ResetAchievementCount resets all changes to the "achievement_count" field.
  12581. func (m *EmployeeMutation) ResetAchievementCount() {
  12582. m.achievement_count = nil
  12583. m.addachievement_count = nil
  12584. }
  12585. // SetIntro sets the "intro" field.
  12586. func (m *EmployeeMutation) SetIntro(s string) {
  12587. m.intro = &s
  12588. }
  12589. // Intro returns the value of the "intro" field in the mutation.
  12590. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  12591. v := m.intro
  12592. if v == nil {
  12593. return
  12594. }
  12595. return *v, true
  12596. }
  12597. // OldIntro returns the old "intro" field's value of the Employee entity.
  12598. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12600. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  12601. if !m.op.Is(OpUpdateOne) {
  12602. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  12603. }
  12604. if m.id == nil || m.oldValue == nil {
  12605. return v, errors.New("OldIntro requires an ID field in the mutation")
  12606. }
  12607. oldValue, err := m.oldValue(ctx)
  12608. if err != nil {
  12609. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  12610. }
  12611. return oldValue.Intro, nil
  12612. }
  12613. // ResetIntro resets all changes to the "intro" field.
  12614. func (m *EmployeeMutation) ResetIntro() {
  12615. m.intro = nil
  12616. }
  12617. // SetEstimate sets the "estimate" field.
  12618. func (m *EmployeeMutation) SetEstimate(s string) {
  12619. m.estimate = &s
  12620. }
  12621. // Estimate returns the value of the "estimate" field in the mutation.
  12622. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  12623. v := m.estimate
  12624. if v == nil {
  12625. return
  12626. }
  12627. return *v, true
  12628. }
  12629. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  12630. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12632. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  12633. if !m.op.Is(OpUpdateOne) {
  12634. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  12635. }
  12636. if m.id == nil || m.oldValue == nil {
  12637. return v, errors.New("OldEstimate requires an ID field in the mutation")
  12638. }
  12639. oldValue, err := m.oldValue(ctx)
  12640. if err != nil {
  12641. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  12642. }
  12643. return oldValue.Estimate, nil
  12644. }
  12645. // ResetEstimate resets all changes to the "estimate" field.
  12646. func (m *EmployeeMutation) ResetEstimate() {
  12647. m.estimate = nil
  12648. }
  12649. // SetSkill sets the "skill" field.
  12650. func (m *EmployeeMutation) SetSkill(s string) {
  12651. m.skill = &s
  12652. }
  12653. // Skill returns the value of the "skill" field in the mutation.
  12654. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  12655. v := m.skill
  12656. if v == nil {
  12657. return
  12658. }
  12659. return *v, true
  12660. }
  12661. // OldSkill returns the old "skill" field's value of the Employee entity.
  12662. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12664. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  12665. if !m.op.Is(OpUpdateOne) {
  12666. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  12667. }
  12668. if m.id == nil || m.oldValue == nil {
  12669. return v, errors.New("OldSkill requires an ID field in the mutation")
  12670. }
  12671. oldValue, err := m.oldValue(ctx)
  12672. if err != nil {
  12673. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  12674. }
  12675. return oldValue.Skill, nil
  12676. }
  12677. // ResetSkill resets all changes to the "skill" field.
  12678. func (m *EmployeeMutation) ResetSkill() {
  12679. m.skill = nil
  12680. }
  12681. // SetAbilityType sets the "ability_type" field.
  12682. func (m *EmployeeMutation) SetAbilityType(s string) {
  12683. m.ability_type = &s
  12684. }
  12685. // AbilityType returns the value of the "ability_type" field in the mutation.
  12686. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  12687. v := m.ability_type
  12688. if v == nil {
  12689. return
  12690. }
  12691. return *v, true
  12692. }
  12693. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  12694. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12696. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  12697. if !m.op.Is(OpUpdateOne) {
  12698. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  12699. }
  12700. if m.id == nil || m.oldValue == nil {
  12701. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  12702. }
  12703. oldValue, err := m.oldValue(ctx)
  12704. if err != nil {
  12705. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  12706. }
  12707. return oldValue.AbilityType, nil
  12708. }
  12709. // ResetAbilityType resets all changes to the "ability_type" field.
  12710. func (m *EmployeeMutation) ResetAbilityType() {
  12711. m.ability_type = nil
  12712. }
  12713. // SetScene sets the "scene" field.
  12714. func (m *EmployeeMutation) SetScene(s string) {
  12715. m.scene = &s
  12716. }
  12717. // Scene returns the value of the "scene" field in the mutation.
  12718. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  12719. v := m.scene
  12720. if v == nil {
  12721. return
  12722. }
  12723. return *v, true
  12724. }
  12725. // OldScene returns the old "scene" field's value of the Employee entity.
  12726. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12728. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  12729. if !m.op.Is(OpUpdateOne) {
  12730. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  12731. }
  12732. if m.id == nil || m.oldValue == nil {
  12733. return v, errors.New("OldScene requires an ID field in the mutation")
  12734. }
  12735. oldValue, err := m.oldValue(ctx)
  12736. if err != nil {
  12737. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  12738. }
  12739. return oldValue.Scene, nil
  12740. }
  12741. // ResetScene resets all changes to the "scene" field.
  12742. func (m *EmployeeMutation) ResetScene() {
  12743. m.scene = nil
  12744. }
  12745. // SetSwitchIn sets the "switch_in" field.
  12746. func (m *EmployeeMutation) SetSwitchIn(s string) {
  12747. m.switch_in = &s
  12748. }
  12749. // SwitchIn returns the value of the "switch_in" field in the mutation.
  12750. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  12751. v := m.switch_in
  12752. if v == nil {
  12753. return
  12754. }
  12755. return *v, true
  12756. }
  12757. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  12758. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12760. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  12761. if !m.op.Is(OpUpdateOne) {
  12762. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  12763. }
  12764. if m.id == nil || m.oldValue == nil {
  12765. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  12766. }
  12767. oldValue, err := m.oldValue(ctx)
  12768. if err != nil {
  12769. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  12770. }
  12771. return oldValue.SwitchIn, nil
  12772. }
  12773. // ResetSwitchIn resets all changes to the "switch_in" field.
  12774. func (m *EmployeeMutation) ResetSwitchIn() {
  12775. m.switch_in = nil
  12776. }
  12777. // SetVideoURL sets the "video_url" field.
  12778. func (m *EmployeeMutation) SetVideoURL(s string) {
  12779. m.video_url = &s
  12780. }
  12781. // VideoURL returns the value of the "video_url" field in the mutation.
  12782. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  12783. v := m.video_url
  12784. if v == nil {
  12785. return
  12786. }
  12787. return *v, true
  12788. }
  12789. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  12790. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12792. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  12793. if !m.op.Is(OpUpdateOne) {
  12794. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  12795. }
  12796. if m.id == nil || m.oldValue == nil {
  12797. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  12798. }
  12799. oldValue, err := m.oldValue(ctx)
  12800. if err != nil {
  12801. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  12802. }
  12803. return oldValue.VideoURL, nil
  12804. }
  12805. // ResetVideoURL resets all changes to the "video_url" field.
  12806. func (m *EmployeeMutation) ResetVideoURL() {
  12807. m.video_url = nil
  12808. }
  12809. // SetOrganizationID sets the "organization_id" field.
  12810. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  12811. m.organization_id = &u
  12812. m.addorganization_id = nil
  12813. }
  12814. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12815. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  12816. v := m.organization_id
  12817. if v == nil {
  12818. return
  12819. }
  12820. return *v, true
  12821. }
  12822. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  12823. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12825. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12826. if !m.op.Is(OpUpdateOne) {
  12827. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12828. }
  12829. if m.id == nil || m.oldValue == nil {
  12830. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12831. }
  12832. oldValue, err := m.oldValue(ctx)
  12833. if err != nil {
  12834. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12835. }
  12836. return oldValue.OrganizationID, nil
  12837. }
  12838. // AddOrganizationID adds u to the "organization_id" field.
  12839. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  12840. if m.addorganization_id != nil {
  12841. *m.addorganization_id += u
  12842. } else {
  12843. m.addorganization_id = &u
  12844. }
  12845. }
  12846. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12847. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  12848. v := m.addorganization_id
  12849. if v == nil {
  12850. return
  12851. }
  12852. return *v, true
  12853. }
  12854. // ResetOrganizationID resets all changes to the "organization_id" field.
  12855. func (m *EmployeeMutation) ResetOrganizationID() {
  12856. m.organization_id = nil
  12857. m.addorganization_id = nil
  12858. }
  12859. // SetCategoryID sets the "category_id" field.
  12860. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  12861. m.category_id = &u
  12862. m.addcategory_id = nil
  12863. }
  12864. // CategoryID returns the value of the "category_id" field in the mutation.
  12865. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  12866. v := m.category_id
  12867. if v == nil {
  12868. return
  12869. }
  12870. return *v, true
  12871. }
  12872. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  12873. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12875. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  12876. if !m.op.Is(OpUpdateOne) {
  12877. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  12878. }
  12879. if m.id == nil || m.oldValue == nil {
  12880. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  12881. }
  12882. oldValue, err := m.oldValue(ctx)
  12883. if err != nil {
  12884. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  12885. }
  12886. return oldValue.CategoryID, nil
  12887. }
  12888. // AddCategoryID adds u to the "category_id" field.
  12889. func (m *EmployeeMutation) AddCategoryID(u int64) {
  12890. if m.addcategory_id != nil {
  12891. *m.addcategory_id += u
  12892. } else {
  12893. m.addcategory_id = &u
  12894. }
  12895. }
  12896. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  12897. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  12898. v := m.addcategory_id
  12899. if v == nil {
  12900. return
  12901. }
  12902. return *v, true
  12903. }
  12904. // ResetCategoryID resets all changes to the "category_id" field.
  12905. func (m *EmployeeMutation) ResetCategoryID() {
  12906. m.category_id = nil
  12907. m.addcategory_id = nil
  12908. }
  12909. // SetAPIBase sets the "api_base" field.
  12910. func (m *EmployeeMutation) SetAPIBase(s string) {
  12911. m.api_base = &s
  12912. }
  12913. // APIBase returns the value of the "api_base" field in the mutation.
  12914. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  12915. v := m.api_base
  12916. if v == nil {
  12917. return
  12918. }
  12919. return *v, true
  12920. }
  12921. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  12922. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12924. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  12925. if !m.op.Is(OpUpdateOne) {
  12926. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  12927. }
  12928. if m.id == nil || m.oldValue == nil {
  12929. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  12930. }
  12931. oldValue, err := m.oldValue(ctx)
  12932. if err != nil {
  12933. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  12934. }
  12935. return oldValue.APIBase, nil
  12936. }
  12937. // ResetAPIBase resets all changes to the "api_base" field.
  12938. func (m *EmployeeMutation) ResetAPIBase() {
  12939. m.api_base = nil
  12940. }
  12941. // SetAPIKey sets the "api_key" field.
  12942. func (m *EmployeeMutation) SetAPIKey(s string) {
  12943. m.api_key = &s
  12944. }
  12945. // APIKey returns the value of the "api_key" field in the mutation.
  12946. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  12947. v := m.api_key
  12948. if v == nil {
  12949. return
  12950. }
  12951. return *v, true
  12952. }
  12953. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  12954. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12956. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  12957. if !m.op.Is(OpUpdateOne) {
  12958. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  12959. }
  12960. if m.id == nil || m.oldValue == nil {
  12961. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  12962. }
  12963. oldValue, err := m.oldValue(ctx)
  12964. if err != nil {
  12965. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  12966. }
  12967. return oldValue.APIKey, nil
  12968. }
  12969. // ResetAPIKey resets all changes to the "api_key" field.
  12970. func (m *EmployeeMutation) ResetAPIKey() {
  12971. m.api_key = nil
  12972. }
  12973. // SetAiInfo sets the "ai_info" field.
  12974. func (m *EmployeeMutation) SetAiInfo(s string) {
  12975. m.ai_info = &s
  12976. }
  12977. // AiInfo returns the value of the "ai_info" field in the mutation.
  12978. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  12979. v := m.ai_info
  12980. if v == nil {
  12981. return
  12982. }
  12983. return *v, true
  12984. }
  12985. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  12986. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12988. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  12989. if !m.op.Is(OpUpdateOne) {
  12990. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  12991. }
  12992. if m.id == nil || m.oldValue == nil {
  12993. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  12994. }
  12995. oldValue, err := m.oldValue(ctx)
  12996. if err != nil {
  12997. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  12998. }
  12999. return oldValue.AiInfo, nil
  13000. }
  13001. // ClearAiInfo clears the value of the "ai_info" field.
  13002. func (m *EmployeeMutation) ClearAiInfo() {
  13003. m.ai_info = nil
  13004. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  13005. }
  13006. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  13007. func (m *EmployeeMutation) AiInfoCleared() bool {
  13008. _, ok := m.clearedFields[employee.FieldAiInfo]
  13009. return ok
  13010. }
  13011. // ResetAiInfo resets all changes to the "ai_info" field.
  13012. func (m *EmployeeMutation) ResetAiInfo() {
  13013. m.ai_info = nil
  13014. delete(m.clearedFields, employee.FieldAiInfo)
  13015. }
  13016. // SetIsVip sets the "is_vip" field.
  13017. func (m *EmployeeMutation) SetIsVip(i int) {
  13018. m.is_vip = &i
  13019. m.addis_vip = nil
  13020. }
  13021. // IsVip returns the value of the "is_vip" field in the mutation.
  13022. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  13023. v := m.is_vip
  13024. if v == nil {
  13025. return
  13026. }
  13027. return *v, true
  13028. }
  13029. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  13030. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13032. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  13033. if !m.op.Is(OpUpdateOne) {
  13034. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  13035. }
  13036. if m.id == nil || m.oldValue == nil {
  13037. return v, errors.New("OldIsVip requires an ID field in the mutation")
  13038. }
  13039. oldValue, err := m.oldValue(ctx)
  13040. if err != nil {
  13041. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  13042. }
  13043. return oldValue.IsVip, nil
  13044. }
  13045. // AddIsVip adds i to the "is_vip" field.
  13046. func (m *EmployeeMutation) AddIsVip(i int) {
  13047. if m.addis_vip != nil {
  13048. *m.addis_vip += i
  13049. } else {
  13050. m.addis_vip = &i
  13051. }
  13052. }
  13053. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  13054. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  13055. v := m.addis_vip
  13056. if v == nil {
  13057. return
  13058. }
  13059. return *v, true
  13060. }
  13061. // ResetIsVip resets all changes to the "is_vip" field.
  13062. func (m *EmployeeMutation) ResetIsVip() {
  13063. m.is_vip = nil
  13064. m.addis_vip = nil
  13065. }
  13066. // SetChatURL sets the "chat_url" field.
  13067. func (m *EmployeeMutation) SetChatURL(s string) {
  13068. m.chat_url = &s
  13069. }
  13070. // ChatURL returns the value of the "chat_url" field in the mutation.
  13071. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  13072. v := m.chat_url
  13073. if v == nil {
  13074. return
  13075. }
  13076. return *v, true
  13077. }
  13078. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  13079. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13081. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  13082. if !m.op.Is(OpUpdateOne) {
  13083. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  13084. }
  13085. if m.id == nil || m.oldValue == nil {
  13086. return v, errors.New("OldChatURL requires an ID field in the mutation")
  13087. }
  13088. oldValue, err := m.oldValue(ctx)
  13089. if err != nil {
  13090. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  13091. }
  13092. return oldValue.ChatURL, nil
  13093. }
  13094. // ResetChatURL resets all changes to the "chat_url" field.
  13095. func (m *EmployeeMutation) ResetChatURL() {
  13096. m.chat_url = nil
  13097. }
  13098. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  13099. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  13100. if m.em_work_experiences == nil {
  13101. m.em_work_experiences = make(map[uint64]struct{})
  13102. }
  13103. for i := range ids {
  13104. m.em_work_experiences[ids[i]] = struct{}{}
  13105. }
  13106. }
  13107. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  13108. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  13109. m.clearedem_work_experiences = true
  13110. }
  13111. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  13112. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  13113. return m.clearedem_work_experiences
  13114. }
  13115. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  13116. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  13117. if m.removedem_work_experiences == nil {
  13118. m.removedem_work_experiences = make(map[uint64]struct{})
  13119. }
  13120. for i := range ids {
  13121. delete(m.em_work_experiences, ids[i])
  13122. m.removedem_work_experiences[ids[i]] = struct{}{}
  13123. }
  13124. }
  13125. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  13126. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  13127. for id := range m.removedem_work_experiences {
  13128. ids = append(ids, id)
  13129. }
  13130. return
  13131. }
  13132. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  13133. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  13134. for id := range m.em_work_experiences {
  13135. ids = append(ids, id)
  13136. }
  13137. return
  13138. }
  13139. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  13140. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  13141. m.em_work_experiences = nil
  13142. m.clearedem_work_experiences = false
  13143. m.removedem_work_experiences = nil
  13144. }
  13145. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  13146. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  13147. if m.em_tutorial == nil {
  13148. m.em_tutorial = make(map[uint64]struct{})
  13149. }
  13150. for i := range ids {
  13151. m.em_tutorial[ids[i]] = struct{}{}
  13152. }
  13153. }
  13154. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  13155. func (m *EmployeeMutation) ClearEmTutorial() {
  13156. m.clearedem_tutorial = true
  13157. }
  13158. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  13159. func (m *EmployeeMutation) EmTutorialCleared() bool {
  13160. return m.clearedem_tutorial
  13161. }
  13162. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  13163. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  13164. if m.removedem_tutorial == nil {
  13165. m.removedem_tutorial = make(map[uint64]struct{})
  13166. }
  13167. for i := range ids {
  13168. delete(m.em_tutorial, ids[i])
  13169. m.removedem_tutorial[ids[i]] = struct{}{}
  13170. }
  13171. }
  13172. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  13173. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  13174. for id := range m.removedem_tutorial {
  13175. ids = append(ids, id)
  13176. }
  13177. return
  13178. }
  13179. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  13180. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  13181. for id := range m.em_tutorial {
  13182. ids = append(ids, id)
  13183. }
  13184. return
  13185. }
  13186. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  13187. func (m *EmployeeMutation) ResetEmTutorial() {
  13188. m.em_tutorial = nil
  13189. m.clearedem_tutorial = false
  13190. m.removedem_tutorial = nil
  13191. }
  13192. // Where appends a list predicates to the EmployeeMutation builder.
  13193. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  13194. m.predicates = append(m.predicates, ps...)
  13195. }
  13196. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  13197. // users can use type-assertion to append predicates that do not depend on any generated package.
  13198. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  13199. p := make([]predicate.Employee, len(ps))
  13200. for i := range ps {
  13201. p[i] = ps[i]
  13202. }
  13203. m.Where(p...)
  13204. }
  13205. // Op returns the operation name.
  13206. func (m *EmployeeMutation) Op() Op {
  13207. return m.op
  13208. }
  13209. // SetOp allows setting the mutation operation.
  13210. func (m *EmployeeMutation) SetOp(op Op) {
  13211. m.op = op
  13212. }
  13213. // Type returns the node type of this mutation (Employee).
  13214. func (m *EmployeeMutation) Type() string {
  13215. return m.typ
  13216. }
  13217. // Fields returns all fields that were changed during this mutation. Note that in
  13218. // order to get all numeric fields that were incremented/decremented, call
  13219. // AddedFields().
  13220. func (m *EmployeeMutation) Fields() []string {
  13221. fields := make([]string, 0, 23)
  13222. if m.created_at != nil {
  13223. fields = append(fields, employee.FieldCreatedAt)
  13224. }
  13225. if m.updated_at != nil {
  13226. fields = append(fields, employee.FieldUpdatedAt)
  13227. }
  13228. if m.deleted_at != nil {
  13229. fields = append(fields, employee.FieldDeletedAt)
  13230. }
  13231. if m.title != nil {
  13232. fields = append(fields, employee.FieldTitle)
  13233. }
  13234. if m.avatar != nil {
  13235. fields = append(fields, employee.FieldAvatar)
  13236. }
  13237. if m.tags != nil {
  13238. fields = append(fields, employee.FieldTags)
  13239. }
  13240. if m.hire_count != nil {
  13241. fields = append(fields, employee.FieldHireCount)
  13242. }
  13243. if m.service_count != nil {
  13244. fields = append(fields, employee.FieldServiceCount)
  13245. }
  13246. if m.achievement_count != nil {
  13247. fields = append(fields, employee.FieldAchievementCount)
  13248. }
  13249. if m.intro != nil {
  13250. fields = append(fields, employee.FieldIntro)
  13251. }
  13252. if m.estimate != nil {
  13253. fields = append(fields, employee.FieldEstimate)
  13254. }
  13255. if m.skill != nil {
  13256. fields = append(fields, employee.FieldSkill)
  13257. }
  13258. if m.ability_type != nil {
  13259. fields = append(fields, employee.FieldAbilityType)
  13260. }
  13261. if m.scene != nil {
  13262. fields = append(fields, employee.FieldScene)
  13263. }
  13264. if m.switch_in != nil {
  13265. fields = append(fields, employee.FieldSwitchIn)
  13266. }
  13267. if m.video_url != nil {
  13268. fields = append(fields, employee.FieldVideoURL)
  13269. }
  13270. if m.organization_id != nil {
  13271. fields = append(fields, employee.FieldOrganizationID)
  13272. }
  13273. if m.category_id != nil {
  13274. fields = append(fields, employee.FieldCategoryID)
  13275. }
  13276. if m.api_base != nil {
  13277. fields = append(fields, employee.FieldAPIBase)
  13278. }
  13279. if m.api_key != nil {
  13280. fields = append(fields, employee.FieldAPIKey)
  13281. }
  13282. if m.ai_info != nil {
  13283. fields = append(fields, employee.FieldAiInfo)
  13284. }
  13285. if m.is_vip != nil {
  13286. fields = append(fields, employee.FieldIsVip)
  13287. }
  13288. if m.chat_url != nil {
  13289. fields = append(fields, employee.FieldChatURL)
  13290. }
  13291. return fields
  13292. }
  13293. // Field returns the value of a field with the given name. The second boolean
  13294. // return value indicates that this field was not set, or was not defined in the
  13295. // schema.
  13296. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  13297. switch name {
  13298. case employee.FieldCreatedAt:
  13299. return m.CreatedAt()
  13300. case employee.FieldUpdatedAt:
  13301. return m.UpdatedAt()
  13302. case employee.FieldDeletedAt:
  13303. return m.DeletedAt()
  13304. case employee.FieldTitle:
  13305. return m.Title()
  13306. case employee.FieldAvatar:
  13307. return m.Avatar()
  13308. case employee.FieldTags:
  13309. return m.Tags()
  13310. case employee.FieldHireCount:
  13311. return m.HireCount()
  13312. case employee.FieldServiceCount:
  13313. return m.ServiceCount()
  13314. case employee.FieldAchievementCount:
  13315. return m.AchievementCount()
  13316. case employee.FieldIntro:
  13317. return m.Intro()
  13318. case employee.FieldEstimate:
  13319. return m.Estimate()
  13320. case employee.FieldSkill:
  13321. return m.Skill()
  13322. case employee.FieldAbilityType:
  13323. return m.AbilityType()
  13324. case employee.FieldScene:
  13325. return m.Scene()
  13326. case employee.FieldSwitchIn:
  13327. return m.SwitchIn()
  13328. case employee.FieldVideoURL:
  13329. return m.VideoURL()
  13330. case employee.FieldOrganizationID:
  13331. return m.OrganizationID()
  13332. case employee.FieldCategoryID:
  13333. return m.CategoryID()
  13334. case employee.FieldAPIBase:
  13335. return m.APIBase()
  13336. case employee.FieldAPIKey:
  13337. return m.APIKey()
  13338. case employee.FieldAiInfo:
  13339. return m.AiInfo()
  13340. case employee.FieldIsVip:
  13341. return m.IsVip()
  13342. case employee.FieldChatURL:
  13343. return m.ChatURL()
  13344. }
  13345. return nil, false
  13346. }
  13347. // OldField returns the old value of the field from the database. An error is
  13348. // returned if the mutation operation is not UpdateOne, or the query to the
  13349. // database failed.
  13350. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13351. switch name {
  13352. case employee.FieldCreatedAt:
  13353. return m.OldCreatedAt(ctx)
  13354. case employee.FieldUpdatedAt:
  13355. return m.OldUpdatedAt(ctx)
  13356. case employee.FieldDeletedAt:
  13357. return m.OldDeletedAt(ctx)
  13358. case employee.FieldTitle:
  13359. return m.OldTitle(ctx)
  13360. case employee.FieldAvatar:
  13361. return m.OldAvatar(ctx)
  13362. case employee.FieldTags:
  13363. return m.OldTags(ctx)
  13364. case employee.FieldHireCount:
  13365. return m.OldHireCount(ctx)
  13366. case employee.FieldServiceCount:
  13367. return m.OldServiceCount(ctx)
  13368. case employee.FieldAchievementCount:
  13369. return m.OldAchievementCount(ctx)
  13370. case employee.FieldIntro:
  13371. return m.OldIntro(ctx)
  13372. case employee.FieldEstimate:
  13373. return m.OldEstimate(ctx)
  13374. case employee.FieldSkill:
  13375. return m.OldSkill(ctx)
  13376. case employee.FieldAbilityType:
  13377. return m.OldAbilityType(ctx)
  13378. case employee.FieldScene:
  13379. return m.OldScene(ctx)
  13380. case employee.FieldSwitchIn:
  13381. return m.OldSwitchIn(ctx)
  13382. case employee.FieldVideoURL:
  13383. return m.OldVideoURL(ctx)
  13384. case employee.FieldOrganizationID:
  13385. return m.OldOrganizationID(ctx)
  13386. case employee.FieldCategoryID:
  13387. return m.OldCategoryID(ctx)
  13388. case employee.FieldAPIBase:
  13389. return m.OldAPIBase(ctx)
  13390. case employee.FieldAPIKey:
  13391. return m.OldAPIKey(ctx)
  13392. case employee.FieldAiInfo:
  13393. return m.OldAiInfo(ctx)
  13394. case employee.FieldIsVip:
  13395. return m.OldIsVip(ctx)
  13396. case employee.FieldChatURL:
  13397. return m.OldChatURL(ctx)
  13398. }
  13399. return nil, fmt.Errorf("unknown Employee field %s", name)
  13400. }
  13401. // SetField sets the value of a field with the given name. It returns an error if
  13402. // the field is not defined in the schema, or if the type mismatched the field
  13403. // type.
  13404. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  13405. switch name {
  13406. case employee.FieldCreatedAt:
  13407. v, ok := value.(time.Time)
  13408. if !ok {
  13409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13410. }
  13411. m.SetCreatedAt(v)
  13412. return nil
  13413. case employee.FieldUpdatedAt:
  13414. v, ok := value.(time.Time)
  13415. if !ok {
  13416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13417. }
  13418. m.SetUpdatedAt(v)
  13419. return nil
  13420. case employee.FieldDeletedAt:
  13421. v, ok := value.(time.Time)
  13422. if !ok {
  13423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13424. }
  13425. m.SetDeletedAt(v)
  13426. return nil
  13427. case employee.FieldTitle:
  13428. v, ok := value.(string)
  13429. if !ok {
  13430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13431. }
  13432. m.SetTitle(v)
  13433. return nil
  13434. case employee.FieldAvatar:
  13435. v, ok := value.(string)
  13436. if !ok {
  13437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13438. }
  13439. m.SetAvatar(v)
  13440. return nil
  13441. case employee.FieldTags:
  13442. v, ok := value.(string)
  13443. if !ok {
  13444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13445. }
  13446. m.SetTags(v)
  13447. return nil
  13448. case employee.FieldHireCount:
  13449. v, ok := value.(int)
  13450. if !ok {
  13451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13452. }
  13453. m.SetHireCount(v)
  13454. return nil
  13455. case employee.FieldServiceCount:
  13456. v, ok := value.(int)
  13457. if !ok {
  13458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13459. }
  13460. m.SetServiceCount(v)
  13461. return nil
  13462. case employee.FieldAchievementCount:
  13463. v, ok := value.(int)
  13464. if !ok {
  13465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13466. }
  13467. m.SetAchievementCount(v)
  13468. return nil
  13469. case employee.FieldIntro:
  13470. v, ok := value.(string)
  13471. if !ok {
  13472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13473. }
  13474. m.SetIntro(v)
  13475. return nil
  13476. case employee.FieldEstimate:
  13477. v, ok := value.(string)
  13478. if !ok {
  13479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13480. }
  13481. m.SetEstimate(v)
  13482. return nil
  13483. case employee.FieldSkill:
  13484. v, ok := value.(string)
  13485. if !ok {
  13486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13487. }
  13488. m.SetSkill(v)
  13489. return nil
  13490. case employee.FieldAbilityType:
  13491. v, ok := value.(string)
  13492. if !ok {
  13493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13494. }
  13495. m.SetAbilityType(v)
  13496. return nil
  13497. case employee.FieldScene:
  13498. v, ok := value.(string)
  13499. if !ok {
  13500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13501. }
  13502. m.SetScene(v)
  13503. return nil
  13504. case employee.FieldSwitchIn:
  13505. v, ok := value.(string)
  13506. if !ok {
  13507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13508. }
  13509. m.SetSwitchIn(v)
  13510. return nil
  13511. case employee.FieldVideoURL:
  13512. v, ok := value.(string)
  13513. if !ok {
  13514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13515. }
  13516. m.SetVideoURL(v)
  13517. return nil
  13518. case employee.FieldOrganizationID:
  13519. v, ok := value.(uint64)
  13520. if !ok {
  13521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13522. }
  13523. m.SetOrganizationID(v)
  13524. return nil
  13525. case employee.FieldCategoryID:
  13526. v, ok := value.(uint64)
  13527. if !ok {
  13528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13529. }
  13530. m.SetCategoryID(v)
  13531. return nil
  13532. case employee.FieldAPIBase:
  13533. v, ok := value.(string)
  13534. if !ok {
  13535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13536. }
  13537. m.SetAPIBase(v)
  13538. return nil
  13539. case employee.FieldAPIKey:
  13540. v, ok := value.(string)
  13541. if !ok {
  13542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13543. }
  13544. m.SetAPIKey(v)
  13545. return nil
  13546. case employee.FieldAiInfo:
  13547. v, ok := value.(string)
  13548. if !ok {
  13549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13550. }
  13551. m.SetAiInfo(v)
  13552. return nil
  13553. case employee.FieldIsVip:
  13554. v, ok := value.(int)
  13555. if !ok {
  13556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13557. }
  13558. m.SetIsVip(v)
  13559. return nil
  13560. case employee.FieldChatURL:
  13561. v, ok := value.(string)
  13562. if !ok {
  13563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13564. }
  13565. m.SetChatURL(v)
  13566. return nil
  13567. }
  13568. return fmt.Errorf("unknown Employee field %s", name)
  13569. }
  13570. // AddedFields returns all numeric fields that were incremented/decremented during
  13571. // this mutation.
  13572. func (m *EmployeeMutation) AddedFields() []string {
  13573. var fields []string
  13574. if m.addhire_count != nil {
  13575. fields = append(fields, employee.FieldHireCount)
  13576. }
  13577. if m.addservice_count != nil {
  13578. fields = append(fields, employee.FieldServiceCount)
  13579. }
  13580. if m.addachievement_count != nil {
  13581. fields = append(fields, employee.FieldAchievementCount)
  13582. }
  13583. if m.addorganization_id != nil {
  13584. fields = append(fields, employee.FieldOrganizationID)
  13585. }
  13586. if m.addcategory_id != nil {
  13587. fields = append(fields, employee.FieldCategoryID)
  13588. }
  13589. if m.addis_vip != nil {
  13590. fields = append(fields, employee.FieldIsVip)
  13591. }
  13592. return fields
  13593. }
  13594. // AddedField returns the numeric value that was incremented/decremented on a field
  13595. // with the given name. The second boolean return value indicates that this field
  13596. // was not set, or was not defined in the schema.
  13597. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  13598. switch name {
  13599. case employee.FieldHireCount:
  13600. return m.AddedHireCount()
  13601. case employee.FieldServiceCount:
  13602. return m.AddedServiceCount()
  13603. case employee.FieldAchievementCount:
  13604. return m.AddedAchievementCount()
  13605. case employee.FieldOrganizationID:
  13606. return m.AddedOrganizationID()
  13607. case employee.FieldCategoryID:
  13608. return m.AddedCategoryID()
  13609. case employee.FieldIsVip:
  13610. return m.AddedIsVip()
  13611. }
  13612. return nil, false
  13613. }
  13614. // AddField adds the value to the field with the given name. It returns an error if
  13615. // the field is not defined in the schema, or if the type mismatched the field
  13616. // type.
  13617. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  13618. switch name {
  13619. case employee.FieldHireCount:
  13620. v, ok := value.(int)
  13621. if !ok {
  13622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13623. }
  13624. m.AddHireCount(v)
  13625. return nil
  13626. case employee.FieldServiceCount:
  13627. v, ok := value.(int)
  13628. if !ok {
  13629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13630. }
  13631. m.AddServiceCount(v)
  13632. return nil
  13633. case employee.FieldAchievementCount:
  13634. v, ok := value.(int)
  13635. if !ok {
  13636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13637. }
  13638. m.AddAchievementCount(v)
  13639. return nil
  13640. case employee.FieldOrganizationID:
  13641. v, ok := value.(int64)
  13642. if !ok {
  13643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13644. }
  13645. m.AddOrganizationID(v)
  13646. return nil
  13647. case employee.FieldCategoryID:
  13648. v, ok := value.(int64)
  13649. if !ok {
  13650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13651. }
  13652. m.AddCategoryID(v)
  13653. return nil
  13654. case employee.FieldIsVip:
  13655. v, ok := value.(int)
  13656. if !ok {
  13657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13658. }
  13659. m.AddIsVip(v)
  13660. return nil
  13661. }
  13662. return fmt.Errorf("unknown Employee numeric field %s", name)
  13663. }
  13664. // ClearedFields returns all nullable fields that were cleared during this
  13665. // mutation.
  13666. func (m *EmployeeMutation) ClearedFields() []string {
  13667. var fields []string
  13668. if m.FieldCleared(employee.FieldDeletedAt) {
  13669. fields = append(fields, employee.FieldDeletedAt)
  13670. }
  13671. if m.FieldCleared(employee.FieldAiInfo) {
  13672. fields = append(fields, employee.FieldAiInfo)
  13673. }
  13674. return fields
  13675. }
  13676. // FieldCleared returns a boolean indicating if a field with the given name was
  13677. // cleared in this mutation.
  13678. func (m *EmployeeMutation) FieldCleared(name string) bool {
  13679. _, ok := m.clearedFields[name]
  13680. return ok
  13681. }
  13682. // ClearField clears the value of the field with the given name. It returns an
  13683. // error if the field is not defined in the schema.
  13684. func (m *EmployeeMutation) ClearField(name string) error {
  13685. switch name {
  13686. case employee.FieldDeletedAt:
  13687. m.ClearDeletedAt()
  13688. return nil
  13689. case employee.FieldAiInfo:
  13690. m.ClearAiInfo()
  13691. return nil
  13692. }
  13693. return fmt.Errorf("unknown Employee nullable field %s", name)
  13694. }
  13695. // ResetField resets all changes in the mutation for the field with the given name.
  13696. // It returns an error if the field is not defined in the schema.
  13697. func (m *EmployeeMutation) ResetField(name string) error {
  13698. switch name {
  13699. case employee.FieldCreatedAt:
  13700. m.ResetCreatedAt()
  13701. return nil
  13702. case employee.FieldUpdatedAt:
  13703. m.ResetUpdatedAt()
  13704. return nil
  13705. case employee.FieldDeletedAt:
  13706. m.ResetDeletedAt()
  13707. return nil
  13708. case employee.FieldTitle:
  13709. m.ResetTitle()
  13710. return nil
  13711. case employee.FieldAvatar:
  13712. m.ResetAvatar()
  13713. return nil
  13714. case employee.FieldTags:
  13715. m.ResetTags()
  13716. return nil
  13717. case employee.FieldHireCount:
  13718. m.ResetHireCount()
  13719. return nil
  13720. case employee.FieldServiceCount:
  13721. m.ResetServiceCount()
  13722. return nil
  13723. case employee.FieldAchievementCount:
  13724. m.ResetAchievementCount()
  13725. return nil
  13726. case employee.FieldIntro:
  13727. m.ResetIntro()
  13728. return nil
  13729. case employee.FieldEstimate:
  13730. m.ResetEstimate()
  13731. return nil
  13732. case employee.FieldSkill:
  13733. m.ResetSkill()
  13734. return nil
  13735. case employee.FieldAbilityType:
  13736. m.ResetAbilityType()
  13737. return nil
  13738. case employee.FieldScene:
  13739. m.ResetScene()
  13740. return nil
  13741. case employee.FieldSwitchIn:
  13742. m.ResetSwitchIn()
  13743. return nil
  13744. case employee.FieldVideoURL:
  13745. m.ResetVideoURL()
  13746. return nil
  13747. case employee.FieldOrganizationID:
  13748. m.ResetOrganizationID()
  13749. return nil
  13750. case employee.FieldCategoryID:
  13751. m.ResetCategoryID()
  13752. return nil
  13753. case employee.FieldAPIBase:
  13754. m.ResetAPIBase()
  13755. return nil
  13756. case employee.FieldAPIKey:
  13757. m.ResetAPIKey()
  13758. return nil
  13759. case employee.FieldAiInfo:
  13760. m.ResetAiInfo()
  13761. return nil
  13762. case employee.FieldIsVip:
  13763. m.ResetIsVip()
  13764. return nil
  13765. case employee.FieldChatURL:
  13766. m.ResetChatURL()
  13767. return nil
  13768. }
  13769. return fmt.Errorf("unknown Employee field %s", name)
  13770. }
  13771. // AddedEdges returns all edge names that were set/added in this mutation.
  13772. func (m *EmployeeMutation) AddedEdges() []string {
  13773. edges := make([]string, 0, 2)
  13774. if m.em_work_experiences != nil {
  13775. edges = append(edges, employee.EdgeEmWorkExperiences)
  13776. }
  13777. if m.em_tutorial != nil {
  13778. edges = append(edges, employee.EdgeEmTutorial)
  13779. }
  13780. return edges
  13781. }
  13782. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13783. // name in this mutation.
  13784. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  13785. switch name {
  13786. case employee.EdgeEmWorkExperiences:
  13787. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  13788. for id := range m.em_work_experiences {
  13789. ids = append(ids, id)
  13790. }
  13791. return ids
  13792. case employee.EdgeEmTutorial:
  13793. ids := make([]ent.Value, 0, len(m.em_tutorial))
  13794. for id := range m.em_tutorial {
  13795. ids = append(ids, id)
  13796. }
  13797. return ids
  13798. }
  13799. return nil
  13800. }
  13801. // RemovedEdges returns all edge names that were removed in this mutation.
  13802. func (m *EmployeeMutation) RemovedEdges() []string {
  13803. edges := make([]string, 0, 2)
  13804. if m.removedem_work_experiences != nil {
  13805. edges = append(edges, employee.EdgeEmWorkExperiences)
  13806. }
  13807. if m.removedem_tutorial != nil {
  13808. edges = append(edges, employee.EdgeEmTutorial)
  13809. }
  13810. return edges
  13811. }
  13812. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13813. // the given name in this mutation.
  13814. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  13815. switch name {
  13816. case employee.EdgeEmWorkExperiences:
  13817. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  13818. for id := range m.removedem_work_experiences {
  13819. ids = append(ids, id)
  13820. }
  13821. return ids
  13822. case employee.EdgeEmTutorial:
  13823. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  13824. for id := range m.removedem_tutorial {
  13825. ids = append(ids, id)
  13826. }
  13827. return ids
  13828. }
  13829. return nil
  13830. }
  13831. // ClearedEdges returns all edge names that were cleared in this mutation.
  13832. func (m *EmployeeMutation) ClearedEdges() []string {
  13833. edges := make([]string, 0, 2)
  13834. if m.clearedem_work_experiences {
  13835. edges = append(edges, employee.EdgeEmWorkExperiences)
  13836. }
  13837. if m.clearedem_tutorial {
  13838. edges = append(edges, employee.EdgeEmTutorial)
  13839. }
  13840. return edges
  13841. }
  13842. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13843. // was cleared in this mutation.
  13844. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  13845. switch name {
  13846. case employee.EdgeEmWorkExperiences:
  13847. return m.clearedem_work_experiences
  13848. case employee.EdgeEmTutorial:
  13849. return m.clearedem_tutorial
  13850. }
  13851. return false
  13852. }
  13853. // ClearEdge clears the value of the edge with the given name. It returns an error
  13854. // if that edge is not defined in the schema.
  13855. func (m *EmployeeMutation) ClearEdge(name string) error {
  13856. switch name {
  13857. }
  13858. return fmt.Errorf("unknown Employee unique edge %s", name)
  13859. }
  13860. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13861. // It returns an error if the edge is not defined in the schema.
  13862. func (m *EmployeeMutation) ResetEdge(name string) error {
  13863. switch name {
  13864. case employee.EdgeEmWorkExperiences:
  13865. m.ResetEmWorkExperiences()
  13866. return nil
  13867. case employee.EdgeEmTutorial:
  13868. m.ResetEmTutorial()
  13869. return nil
  13870. }
  13871. return fmt.Errorf("unknown Employee edge %s", name)
  13872. }
  13873. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  13874. type EmployeeConfigMutation struct {
  13875. config
  13876. op Op
  13877. typ string
  13878. id *uint64
  13879. created_at *time.Time
  13880. updated_at *time.Time
  13881. deleted_at *time.Time
  13882. stype *string
  13883. title *string
  13884. photo *string
  13885. organization_id *uint64
  13886. addorganization_id *int64
  13887. clearedFields map[string]struct{}
  13888. done bool
  13889. oldValue func(context.Context) (*EmployeeConfig, error)
  13890. predicates []predicate.EmployeeConfig
  13891. }
  13892. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  13893. // employeeconfigOption allows management of the mutation configuration using functional options.
  13894. type employeeconfigOption func(*EmployeeConfigMutation)
  13895. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  13896. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  13897. m := &EmployeeConfigMutation{
  13898. config: c,
  13899. op: op,
  13900. typ: TypeEmployeeConfig,
  13901. clearedFields: make(map[string]struct{}),
  13902. }
  13903. for _, opt := range opts {
  13904. opt(m)
  13905. }
  13906. return m
  13907. }
  13908. // withEmployeeConfigID sets the ID field of the mutation.
  13909. func withEmployeeConfigID(id uint64) employeeconfigOption {
  13910. return func(m *EmployeeConfigMutation) {
  13911. var (
  13912. err error
  13913. once sync.Once
  13914. value *EmployeeConfig
  13915. )
  13916. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  13917. once.Do(func() {
  13918. if m.done {
  13919. err = errors.New("querying old values post mutation is not allowed")
  13920. } else {
  13921. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  13922. }
  13923. })
  13924. return value, err
  13925. }
  13926. m.id = &id
  13927. }
  13928. }
  13929. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  13930. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  13931. return func(m *EmployeeConfigMutation) {
  13932. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  13933. return node, nil
  13934. }
  13935. m.id = &node.ID
  13936. }
  13937. }
  13938. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13939. // executed in a transaction (ent.Tx), a transactional client is returned.
  13940. func (m EmployeeConfigMutation) Client() *Client {
  13941. client := &Client{config: m.config}
  13942. client.init()
  13943. return client
  13944. }
  13945. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13946. // it returns an error otherwise.
  13947. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  13948. if _, ok := m.driver.(*txDriver); !ok {
  13949. return nil, errors.New("ent: mutation is not running in a transaction")
  13950. }
  13951. tx := &Tx{config: m.config}
  13952. tx.init()
  13953. return tx, nil
  13954. }
  13955. // SetID sets the value of the id field. Note that this
  13956. // operation is only accepted on creation of EmployeeConfig entities.
  13957. func (m *EmployeeConfigMutation) SetID(id uint64) {
  13958. m.id = &id
  13959. }
  13960. // ID returns the ID value in the mutation. Note that the ID is only available
  13961. // if it was provided to the builder or after it was returned from the database.
  13962. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  13963. if m.id == nil {
  13964. return
  13965. }
  13966. return *m.id, true
  13967. }
  13968. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13969. // That means, if the mutation is applied within a transaction with an isolation level such
  13970. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13971. // or updated by the mutation.
  13972. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  13973. switch {
  13974. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13975. id, exists := m.ID()
  13976. if exists {
  13977. return []uint64{id}, nil
  13978. }
  13979. fallthrough
  13980. case m.op.Is(OpUpdate | OpDelete):
  13981. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  13982. default:
  13983. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13984. }
  13985. }
  13986. // SetCreatedAt sets the "created_at" field.
  13987. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  13988. m.created_at = &t
  13989. }
  13990. // CreatedAt returns the value of the "created_at" field in the mutation.
  13991. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  13992. v := m.created_at
  13993. if v == nil {
  13994. return
  13995. }
  13996. return *v, true
  13997. }
  13998. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  13999. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14001. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14002. if !m.op.Is(OpUpdateOne) {
  14003. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14004. }
  14005. if m.id == nil || m.oldValue == nil {
  14006. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14007. }
  14008. oldValue, err := m.oldValue(ctx)
  14009. if err != nil {
  14010. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14011. }
  14012. return oldValue.CreatedAt, nil
  14013. }
  14014. // ResetCreatedAt resets all changes to the "created_at" field.
  14015. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  14016. m.created_at = nil
  14017. }
  14018. // SetUpdatedAt sets the "updated_at" field.
  14019. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  14020. m.updated_at = &t
  14021. }
  14022. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14023. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  14024. v := m.updated_at
  14025. if v == nil {
  14026. return
  14027. }
  14028. return *v, true
  14029. }
  14030. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  14031. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14033. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14034. if !m.op.Is(OpUpdateOne) {
  14035. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14036. }
  14037. if m.id == nil || m.oldValue == nil {
  14038. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14039. }
  14040. oldValue, err := m.oldValue(ctx)
  14041. if err != nil {
  14042. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14043. }
  14044. return oldValue.UpdatedAt, nil
  14045. }
  14046. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14047. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  14048. m.updated_at = nil
  14049. }
  14050. // SetDeletedAt sets the "deleted_at" field.
  14051. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  14052. m.deleted_at = &t
  14053. }
  14054. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14055. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  14056. v := m.deleted_at
  14057. if v == nil {
  14058. return
  14059. }
  14060. return *v, true
  14061. }
  14062. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  14063. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14065. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14066. if !m.op.Is(OpUpdateOne) {
  14067. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14068. }
  14069. if m.id == nil || m.oldValue == nil {
  14070. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14071. }
  14072. oldValue, err := m.oldValue(ctx)
  14073. if err != nil {
  14074. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14075. }
  14076. return oldValue.DeletedAt, nil
  14077. }
  14078. // ClearDeletedAt clears the value of the "deleted_at" field.
  14079. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  14080. m.deleted_at = nil
  14081. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  14082. }
  14083. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14084. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  14085. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  14086. return ok
  14087. }
  14088. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14089. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  14090. m.deleted_at = nil
  14091. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  14092. }
  14093. // SetStype sets the "stype" field.
  14094. func (m *EmployeeConfigMutation) SetStype(s string) {
  14095. m.stype = &s
  14096. }
  14097. // Stype returns the value of the "stype" field in the mutation.
  14098. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  14099. v := m.stype
  14100. if v == nil {
  14101. return
  14102. }
  14103. return *v, true
  14104. }
  14105. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  14106. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14108. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  14109. if !m.op.Is(OpUpdateOne) {
  14110. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  14111. }
  14112. if m.id == nil || m.oldValue == nil {
  14113. return v, errors.New("OldStype requires an ID field in the mutation")
  14114. }
  14115. oldValue, err := m.oldValue(ctx)
  14116. if err != nil {
  14117. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  14118. }
  14119. return oldValue.Stype, nil
  14120. }
  14121. // ResetStype resets all changes to the "stype" field.
  14122. func (m *EmployeeConfigMutation) ResetStype() {
  14123. m.stype = nil
  14124. }
  14125. // SetTitle sets the "title" field.
  14126. func (m *EmployeeConfigMutation) SetTitle(s string) {
  14127. m.title = &s
  14128. }
  14129. // Title returns the value of the "title" field in the mutation.
  14130. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  14131. v := m.title
  14132. if v == nil {
  14133. return
  14134. }
  14135. return *v, true
  14136. }
  14137. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  14138. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14140. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  14141. if !m.op.Is(OpUpdateOne) {
  14142. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  14143. }
  14144. if m.id == nil || m.oldValue == nil {
  14145. return v, errors.New("OldTitle requires an ID field in the mutation")
  14146. }
  14147. oldValue, err := m.oldValue(ctx)
  14148. if err != nil {
  14149. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  14150. }
  14151. return oldValue.Title, nil
  14152. }
  14153. // ResetTitle resets all changes to the "title" field.
  14154. func (m *EmployeeConfigMutation) ResetTitle() {
  14155. m.title = nil
  14156. }
  14157. // SetPhoto sets the "photo" field.
  14158. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  14159. m.photo = &s
  14160. }
  14161. // Photo returns the value of the "photo" field in the mutation.
  14162. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  14163. v := m.photo
  14164. if v == nil {
  14165. return
  14166. }
  14167. return *v, true
  14168. }
  14169. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  14170. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14172. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  14173. if !m.op.Is(OpUpdateOne) {
  14174. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  14175. }
  14176. if m.id == nil || m.oldValue == nil {
  14177. return v, errors.New("OldPhoto requires an ID field in the mutation")
  14178. }
  14179. oldValue, err := m.oldValue(ctx)
  14180. if err != nil {
  14181. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  14182. }
  14183. return oldValue.Photo, nil
  14184. }
  14185. // ResetPhoto resets all changes to the "photo" field.
  14186. func (m *EmployeeConfigMutation) ResetPhoto() {
  14187. m.photo = nil
  14188. }
  14189. // SetOrganizationID sets the "organization_id" field.
  14190. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  14191. m.organization_id = &u
  14192. m.addorganization_id = nil
  14193. }
  14194. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14195. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  14196. v := m.organization_id
  14197. if v == nil {
  14198. return
  14199. }
  14200. return *v, true
  14201. }
  14202. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  14203. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14205. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14206. if !m.op.Is(OpUpdateOne) {
  14207. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14208. }
  14209. if m.id == nil || m.oldValue == nil {
  14210. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14211. }
  14212. oldValue, err := m.oldValue(ctx)
  14213. if err != nil {
  14214. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14215. }
  14216. return oldValue.OrganizationID, nil
  14217. }
  14218. // AddOrganizationID adds u to the "organization_id" field.
  14219. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  14220. if m.addorganization_id != nil {
  14221. *m.addorganization_id += u
  14222. } else {
  14223. m.addorganization_id = &u
  14224. }
  14225. }
  14226. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14227. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  14228. v := m.addorganization_id
  14229. if v == nil {
  14230. return
  14231. }
  14232. return *v, true
  14233. }
  14234. // ClearOrganizationID clears the value of the "organization_id" field.
  14235. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  14236. m.organization_id = nil
  14237. m.addorganization_id = nil
  14238. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  14239. }
  14240. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14241. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  14242. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  14243. return ok
  14244. }
  14245. // ResetOrganizationID resets all changes to the "organization_id" field.
  14246. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  14247. m.organization_id = nil
  14248. m.addorganization_id = nil
  14249. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  14250. }
  14251. // Where appends a list predicates to the EmployeeConfigMutation builder.
  14252. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  14253. m.predicates = append(m.predicates, ps...)
  14254. }
  14255. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  14256. // users can use type-assertion to append predicates that do not depend on any generated package.
  14257. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  14258. p := make([]predicate.EmployeeConfig, len(ps))
  14259. for i := range ps {
  14260. p[i] = ps[i]
  14261. }
  14262. m.Where(p...)
  14263. }
  14264. // Op returns the operation name.
  14265. func (m *EmployeeConfigMutation) Op() Op {
  14266. return m.op
  14267. }
  14268. // SetOp allows setting the mutation operation.
  14269. func (m *EmployeeConfigMutation) SetOp(op Op) {
  14270. m.op = op
  14271. }
  14272. // Type returns the node type of this mutation (EmployeeConfig).
  14273. func (m *EmployeeConfigMutation) Type() string {
  14274. return m.typ
  14275. }
  14276. // Fields returns all fields that were changed during this mutation. Note that in
  14277. // order to get all numeric fields that were incremented/decremented, call
  14278. // AddedFields().
  14279. func (m *EmployeeConfigMutation) Fields() []string {
  14280. fields := make([]string, 0, 7)
  14281. if m.created_at != nil {
  14282. fields = append(fields, employeeconfig.FieldCreatedAt)
  14283. }
  14284. if m.updated_at != nil {
  14285. fields = append(fields, employeeconfig.FieldUpdatedAt)
  14286. }
  14287. if m.deleted_at != nil {
  14288. fields = append(fields, employeeconfig.FieldDeletedAt)
  14289. }
  14290. if m.stype != nil {
  14291. fields = append(fields, employeeconfig.FieldStype)
  14292. }
  14293. if m.title != nil {
  14294. fields = append(fields, employeeconfig.FieldTitle)
  14295. }
  14296. if m.photo != nil {
  14297. fields = append(fields, employeeconfig.FieldPhoto)
  14298. }
  14299. if m.organization_id != nil {
  14300. fields = append(fields, employeeconfig.FieldOrganizationID)
  14301. }
  14302. return fields
  14303. }
  14304. // Field returns the value of a field with the given name. The second boolean
  14305. // return value indicates that this field was not set, or was not defined in the
  14306. // schema.
  14307. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  14308. switch name {
  14309. case employeeconfig.FieldCreatedAt:
  14310. return m.CreatedAt()
  14311. case employeeconfig.FieldUpdatedAt:
  14312. return m.UpdatedAt()
  14313. case employeeconfig.FieldDeletedAt:
  14314. return m.DeletedAt()
  14315. case employeeconfig.FieldStype:
  14316. return m.Stype()
  14317. case employeeconfig.FieldTitle:
  14318. return m.Title()
  14319. case employeeconfig.FieldPhoto:
  14320. return m.Photo()
  14321. case employeeconfig.FieldOrganizationID:
  14322. return m.OrganizationID()
  14323. }
  14324. return nil, false
  14325. }
  14326. // OldField returns the old value of the field from the database. An error is
  14327. // returned if the mutation operation is not UpdateOne, or the query to the
  14328. // database failed.
  14329. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14330. switch name {
  14331. case employeeconfig.FieldCreatedAt:
  14332. return m.OldCreatedAt(ctx)
  14333. case employeeconfig.FieldUpdatedAt:
  14334. return m.OldUpdatedAt(ctx)
  14335. case employeeconfig.FieldDeletedAt:
  14336. return m.OldDeletedAt(ctx)
  14337. case employeeconfig.FieldStype:
  14338. return m.OldStype(ctx)
  14339. case employeeconfig.FieldTitle:
  14340. return m.OldTitle(ctx)
  14341. case employeeconfig.FieldPhoto:
  14342. return m.OldPhoto(ctx)
  14343. case employeeconfig.FieldOrganizationID:
  14344. return m.OldOrganizationID(ctx)
  14345. }
  14346. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  14347. }
  14348. // SetField sets the value of a field with the given name. It returns an error if
  14349. // the field is not defined in the schema, or if the type mismatched the field
  14350. // type.
  14351. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  14352. switch name {
  14353. case employeeconfig.FieldCreatedAt:
  14354. v, ok := value.(time.Time)
  14355. if !ok {
  14356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14357. }
  14358. m.SetCreatedAt(v)
  14359. return nil
  14360. case employeeconfig.FieldUpdatedAt:
  14361. v, ok := value.(time.Time)
  14362. if !ok {
  14363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14364. }
  14365. m.SetUpdatedAt(v)
  14366. return nil
  14367. case employeeconfig.FieldDeletedAt:
  14368. v, ok := value.(time.Time)
  14369. if !ok {
  14370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14371. }
  14372. m.SetDeletedAt(v)
  14373. return nil
  14374. case employeeconfig.FieldStype:
  14375. v, ok := value.(string)
  14376. if !ok {
  14377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14378. }
  14379. m.SetStype(v)
  14380. return nil
  14381. case employeeconfig.FieldTitle:
  14382. v, ok := value.(string)
  14383. if !ok {
  14384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14385. }
  14386. m.SetTitle(v)
  14387. return nil
  14388. case employeeconfig.FieldPhoto:
  14389. v, ok := value.(string)
  14390. if !ok {
  14391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14392. }
  14393. m.SetPhoto(v)
  14394. return nil
  14395. case employeeconfig.FieldOrganizationID:
  14396. v, ok := value.(uint64)
  14397. if !ok {
  14398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14399. }
  14400. m.SetOrganizationID(v)
  14401. return nil
  14402. }
  14403. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  14404. }
  14405. // AddedFields returns all numeric fields that were incremented/decremented during
  14406. // this mutation.
  14407. func (m *EmployeeConfigMutation) AddedFields() []string {
  14408. var fields []string
  14409. if m.addorganization_id != nil {
  14410. fields = append(fields, employeeconfig.FieldOrganizationID)
  14411. }
  14412. return fields
  14413. }
  14414. // AddedField returns the numeric value that was incremented/decremented on a field
  14415. // with the given name. The second boolean return value indicates that this field
  14416. // was not set, or was not defined in the schema.
  14417. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  14418. switch name {
  14419. case employeeconfig.FieldOrganizationID:
  14420. return m.AddedOrganizationID()
  14421. }
  14422. return nil, false
  14423. }
  14424. // AddField adds the value to the field with the given name. It returns an error if
  14425. // the field is not defined in the schema, or if the type mismatched the field
  14426. // type.
  14427. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  14428. switch name {
  14429. case employeeconfig.FieldOrganizationID:
  14430. v, ok := value.(int64)
  14431. if !ok {
  14432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14433. }
  14434. m.AddOrganizationID(v)
  14435. return nil
  14436. }
  14437. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  14438. }
  14439. // ClearedFields returns all nullable fields that were cleared during this
  14440. // mutation.
  14441. func (m *EmployeeConfigMutation) ClearedFields() []string {
  14442. var fields []string
  14443. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  14444. fields = append(fields, employeeconfig.FieldDeletedAt)
  14445. }
  14446. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  14447. fields = append(fields, employeeconfig.FieldOrganizationID)
  14448. }
  14449. return fields
  14450. }
  14451. // FieldCleared returns a boolean indicating if a field with the given name was
  14452. // cleared in this mutation.
  14453. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  14454. _, ok := m.clearedFields[name]
  14455. return ok
  14456. }
  14457. // ClearField clears the value of the field with the given name. It returns an
  14458. // error if the field is not defined in the schema.
  14459. func (m *EmployeeConfigMutation) ClearField(name string) error {
  14460. switch name {
  14461. case employeeconfig.FieldDeletedAt:
  14462. m.ClearDeletedAt()
  14463. return nil
  14464. case employeeconfig.FieldOrganizationID:
  14465. m.ClearOrganizationID()
  14466. return nil
  14467. }
  14468. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  14469. }
  14470. // ResetField resets all changes in the mutation for the field with the given name.
  14471. // It returns an error if the field is not defined in the schema.
  14472. func (m *EmployeeConfigMutation) ResetField(name string) error {
  14473. switch name {
  14474. case employeeconfig.FieldCreatedAt:
  14475. m.ResetCreatedAt()
  14476. return nil
  14477. case employeeconfig.FieldUpdatedAt:
  14478. m.ResetUpdatedAt()
  14479. return nil
  14480. case employeeconfig.FieldDeletedAt:
  14481. m.ResetDeletedAt()
  14482. return nil
  14483. case employeeconfig.FieldStype:
  14484. m.ResetStype()
  14485. return nil
  14486. case employeeconfig.FieldTitle:
  14487. m.ResetTitle()
  14488. return nil
  14489. case employeeconfig.FieldPhoto:
  14490. m.ResetPhoto()
  14491. return nil
  14492. case employeeconfig.FieldOrganizationID:
  14493. m.ResetOrganizationID()
  14494. return nil
  14495. }
  14496. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  14497. }
  14498. // AddedEdges returns all edge names that were set/added in this mutation.
  14499. func (m *EmployeeConfigMutation) AddedEdges() []string {
  14500. edges := make([]string, 0, 0)
  14501. return edges
  14502. }
  14503. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14504. // name in this mutation.
  14505. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  14506. return nil
  14507. }
  14508. // RemovedEdges returns all edge names that were removed in this mutation.
  14509. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  14510. edges := make([]string, 0, 0)
  14511. return edges
  14512. }
  14513. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14514. // the given name in this mutation.
  14515. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  14516. return nil
  14517. }
  14518. // ClearedEdges returns all edge names that were cleared in this mutation.
  14519. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  14520. edges := make([]string, 0, 0)
  14521. return edges
  14522. }
  14523. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14524. // was cleared in this mutation.
  14525. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  14526. return false
  14527. }
  14528. // ClearEdge clears the value of the edge with the given name. It returns an error
  14529. // if that edge is not defined in the schema.
  14530. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  14531. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  14532. }
  14533. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14534. // It returns an error if the edge is not defined in the schema.
  14535. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  14536. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  14537. }
  14538. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  14539. type LabelMutation struct {
  14540. config
  14541. op Op
  14542. typ string
  14543. id *uint64
  14544. created_at *time.Time
  14545. updated_at *time.Time
  14546. status *uint8
  14547. addstatus *int8
  14548. _type *int
  14549. add_type *int
  14550. name *string
  14551. from *int
  14552. addfrom *int
  14553. mode *int
  14554. addmode *int
  14555. conditions *string
  14556. organization_id *uint64
  14557. addorganization_id *int64
  14558. ctype *uint64
  14559. addctype *int64
  14560. clearedFields map[string]struct{}
  14561. label_relationships map[uint64]struct{}
  14562. removedlabel_relationships map[uint64]struct{}
  14563. clearedlabel_relationships bool
  14564. done bool
  14565. oldValue func(context.Context) (*Label, error)
  14566. predicates []predicate.Label
  14567. }
  14568. var _ ent.Mutation = (*LabelMutation)(nil)
  14569. // labelOption allows management of the mutation configuration using functional options.
  14570. type labelOption func(*LabelMutation)
  14571. // newLabelMutation creates new mutation for the Label entity.
  14572. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  14573. m := &LabelMutation{
  14574. config: c,
  14575. op: op,
  14576. typ: TypeLabel,
  14577. clearedFields: make(map[string]struct{}),
  14578. }
  14579. for _, opt := range opts {
  14580. opt(m)
  14581. }
  14582. return m
  14583. }
  14584. // withLabelID sets the ID field of the mutation.
  14585. func withLabelID(id uint64) labelOption {
  14586. return func(m *LabelMutation) {
  14587. var (
  14588. err error
  14589. once sync.Once
  14590. value *Label
  14591. )
  14592. m.oldValue = func(ctx context.Context) (*Label, error) {
  14593. once.Do(func() {
  14594. if m.done {
  14595. err = errors.New("querying old values post mutation is not allowed")
  14596. } else {
  14597. value, err = m.Client().Label.Get(ctx, id)
  14598. }
  14599. })
  14600. return value, err
  14601. }
  14602. m.id = &id
  14603. }
  14604. }
  14605. // withLabel sets the old Label of the mutation.
  14606. func withLabel(node *Label) labelOption {
  14607. return func(m *LabelMutation) {
  14608. m.oldValue = func(context.Context) (*Label, error) {
  14609. return node, nil
  14610. }
  14611. m.id = &node.ID
  14612. }
  14613. }
  14614. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14615. // executed in a transaction (ent.Tx), a transactional client is returned.
  14616. func (m LabelMutation) Client() *Client {
  14617. client := &Client{config: m.config}
  14618. client.init()
  14619. return client
  14620. }
  14621. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14622. // it returns an error otherwise.
  14623. func (m LabelMutation) Tx() (*Tx, error) {
  14624. if _, ok := m.driver.(*txDriver); !ok {
  14625. return nil, errors.New("ent: mutation is not running in a transaction")
  14626. }
  14627. tx := &Tx{config: m.config}
  14628. tx.init()
  14629. return tx, nil
  14630. }
  14631. // SetID sets the value of the id field. Note that this
  14632. // operation is only accepted on creation of Label entities.
  14633. func (m *LabelMutation) SetID(id uint64) {
  14634. m.id = &id
  14635. }
  14636. // ID returns the ID value in the mutation. Note that the ID is only available
  14637. // if it was provided to the builder or after it was returned from the database.
  14638. func (m *LabelMutation) ID() (id uint64, exists bool) {
  14639. if m.id == nil {
  14640. return
  14641. }
  14642. return *m.id, true
  14643. }
  14644. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14645. // That means, if the mutation is applied within a transaction with an isolation level such
  14646. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14647. // or updated by the mutation.
  14648. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  14649. switch {
  14650. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14651. id, exists := m.ID()
  14652. if exists {
  14653. return []uint64{id}, nil
  14654. }
  14655. fallthrough
  14656. case m.op.Is(OpUpdate | OpDelete):
  14657. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  14658. default:
  14659. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14660. }
  14661. }
  14662. // SetCreatedAt sets the "created_at" field.
  14663. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  14664. m.created_at = &t
  14665. }
  14666. // CreatedAt returns the value of the "created_at" field in the mutation.
  14667. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  14668. v := m.created_at
  14669. if v == nil {
  14670. return
  14671. }
  14672. return *v, true
  14673. }
  14674. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  14675. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14677. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14678. if !m.op.Is(OpUpdateOne) {
  14679. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14680. }
  14681. if m.id == nil || m.oldValue == nil {
  14682. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14683. }
  14684. oldValue, err := m.oldValue(ctx)
  14685. if err != nil {
  14686. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14687. }
  14688. return oldValue.CreatedAt, nil
  14689. }
  14690. // ResetCreatedAt resets all changes to the "created_at" field.
  14691. func (m *LabelMutation) ResetCreatedAt() {
  14692. m.created_at = nil
  14693. }
  14694. // SetUpdatedAt sets the "updated_at" field.
  14695. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  14696. m.updated_at = &t
  14697. }
  14698. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14699. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  14700. v := m.updated_at
  14701. if v == nil {
  14702. return
  14703. }
  14704. return *v, true
  14705. }
  14706. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  14707. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14709. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14710. if !m.op.Is(OpUpdateOne) {
  14711. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14712. }
  14713. if m.id == nil || m.oldValue == nil {
  14714. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14715. }
  14716. oldValue, err := m.oldValue(ctx)
  14717. if err != nil {
  14718. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14719. }
  14720. return oldValue.UpdatedAt, nil
  14721. }
  14722. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14723. func (m *LabelMutation) ResetUpdatedAt() {
  14724. m.updated_at = nil
  14725. }
  14726. // SetStatus sets the "status" field.
  14727. func (m *LabelMutation) SetStatus(u uint8) {
  14728. m.status = &u
  14729. m.addstatus = nil
  14730. }
  14731. // Status returns the value of the "status" field in the mutation.
  14732. func (m *LabelMutation) Status() (r uint8, exists bool) {
  14733. v := m.status
  14734. if v == nil {
  14735. return
  14736. }
  14737. return *v, true
  14738. }
  14739. // OldStatus returns the old "status" field's value of the Label entity.
  14740. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14742. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14743. if !m.op.Is(OpUpdateOne) {
  14744. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14745. }
  14746. if m.id == nil || m.oldValue == nil {
  14747. return v, errors.New("OldStatus requires an ID field in the mutation")
  14748. }
  14749. oldValue, err := m.oldValue(ctx)
  14750. if err != nil {
  14751. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14752. }
  14753. return oldValue.Status, nil
  14754. }
  14755. // AddStatus adds u to the "status" field.
  14756. func (m *LabelMutation) AddStatus(u int8) {
  14757. if m.addstatus != nil {
  14758. *m.addstatus += u
  14759. } else {
  14760. m.addstatus = &u
  14761. }
  14762. }
  14763. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14764. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  14765. v := m.addstatus
  14766. if v == nil {
  14767. return
  14768. }
  14769. return *v, true
  14770. }
  14771. // ClearStatus clears the value of the "status" field.
  14772. func (m *LabelMutation) ClearStatus() {
  14773. m.status = nil
  14774. m.addstatus = nil
  14775. m.clearedFields[label.FieldStatus] = struct{}{}
  14776. }
  14777. // StatusCleared returns if the "status" field was cleared in this mutation.
  14778. func (m *LabelMutation) StatusCleared() bool {
  14779. _, ok := m.clearedFields[label.FieldStatus]
  14780. return ok
  14781. }
  14782. // ResetStatus resets all changes to the "status" field.
  14783. func (m *LabelMutation) ResetStatus() {
  14784. m.status = nil
  14785. m.addstatus = nil
  14786. delete(m.clearedFields, label.FieldStatus)
  14787. }
  14788. // SetType sets the "type" field.
  14789. func (m *LabelMutation) SetType(i int) {
  14790. m._type = &i
  14791. m.add_type = nil
  14792. }
  14793. // GetType returns the value of the "type" field in the mutation.
  14794. func (m *LabelMutation) GetType() (r int, exists bool) {
  14795. v := m._type
  14796. if v == nil {
  14797. return
  14798. }
  14799. return *v, true
  14800. }
  14801. // OldType returns the old "type" field's value of the Label entity.
  14802. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14804. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  14805. if !m.op.Is(OpUpdateOne) {
  14806. return v, errors.New("OldType is only allowed on UpdateOne operations")
  14807. }
  14808. if m.id == nil || m.oldValue == nil {
  14809. return v, errors.New("OldType requires an ID field in the mutation")
  14810. }
  14811. oldValue, err := m.oldValue(ctx)
  14812. if err != nil {
  14813. return v, fmt.Errorf("querying old value for OldType: %w", err)
  14814. }
  14815. return oldValue.Type, nil
  14816. }
  14817. // AddType adds i to the "type" field.
  14818. func (m *LabelMutation) AddType(i int) {
  14819. if m.add_type != nil {
  14820. *m.add_type += i
  14821. } else {
  14822. m.add_type = &i
  14823. }
  14824. }
  14825. // AddedType returns the value that was added to the "type" field in this mutation.
  14826. func (m *LabelMutation) AddedType() (r int, exists bool) {
  14827. v := m.add_type
  14828. if v == nil {
  14829. return
  14830. }
  14831. return *v, true
  14832. }
  14833. // ResetType resets all changes to the "type" field.
  14834. func (m *LabelMutation) ResetType() {
  14835. m._type = nil
  14836. m.add_type = nil
  14837. }
  14838. // SetName sets the "name" field.
  14839. func (m *LabelMutation) SetName(s string) {
  14840. m.name = &s
  14841. }
  14842. // Name returns the value of the "name" field in the mutation.
  14843. func (m *LabelMutation) Name() (r string, exists bool) {
  14844. v := m.name
  14845. if v == nil {
  14846. return
  14847. }
  14848. return *v, true
  14849. }
  14850. // OldName returns the old "name" field's value of the Label entity.
  14851. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14853. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  14854. if !m.op.Is(OpUpdateOne) {
  14855. return v, errors.New("OldName is only allowed on UpdateOne operations")
  14856. }
  14857. if m.id == nil || m.oldValue == nil {
  14858. return v, errors.New("OldName requires an ID field in the mutation")
  14859. }
  14860. oldValue, err := m.oldValue(ctx)
  14861. if err != nil {
  14862. return v, fmt.Errorf("querying old value for OldName: %w", err)
  14863. }
  14864. return oldValue.Name, nil
  14865. }
  14866. // ResetName resets all changes to the "name" field.
  14867. func (m *LabelMutation) ResetName() {
  14868. m.name = nil
  14869. }
  14870. // SetFrom sets the "from" field.
  14871. func (m *LabelMutation) SetFrom(i int) {
  14872. m.from = &i
  14873. m.addfrom = nil
  14874. }
  14875. // From returns the value of the "from" field in the mutation.
  14876. func (m *LabelMutation) From() (r int, exists bool) {
  14877. v := m.from
  14878. if v == nil {
  14879. return
  14880. }
  14881. return *v, true
  14882. }
  14883. // OldFrom returns the old "from" field's value of the Label entity.
  14884. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14886. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  14887. if !m.op.Is(OpUpdateOne) {
  14888. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  14889. }
  14890. if m.id == nil || m.oldValue == nil {
  14891. return v, errors.New("OldFrom requires an ID field in the mutation")
  14892. }
  14893. oldValue, err := m.oldValue(ctx)
  14894. if err != nil {
  14895. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  14896. }
  14897. return oldValue.From, nil
  14898. }
  14899. // AddFrom adds i to the "from" field.
  14900. func (m *LabelMutation) AddFrom(i int) {
  14901. if m.addfrom != nil {
  14902. *m.addfrom += i
  14903. } else {
  14904. m.addfrom = &i
  14905. }
  14906. }
  14907. // AddedFrom returns the value that was added to the "from" field in this mutation.
  14908. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  14909. v := m.addfrom
  14910. if v == nil {
  14911. return
  14912. }
  14913. return *v, true
  14914. }
  14915. // ResetFrom resets all changes to the "from" field.
  14916. func (m *LabelMutation) ResetFrom() {
  14917. m.from = nil
  14918. m.addfrom = nil
  14919. }
  14920. // SetMode sets the "mode" field.
  14921. func (m *LabelMutation) SetMode(i int) {
  14922. m.mode = &i
  14923. m.addmode = nil
  14924. }
  14925. // Mode returns the value of the "mode" field in the mutation.
  14926. func (m *LabelMutation) Mode() (r int, exists bool) {
  14927. v := m.mode
  14928. if v == nil {
  14929. return
  14930. }
  14931. return *v, true
  14932. }
  14933. // OldMode returns the old "mode" field's value of the Label entity.
  14934. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14936. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  14937. if !m.op.Is(OpUpdateOne) {
  14938. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  14939. }
  14940. if m.id == nil || m.oldValue == nil {
  14941. return v, errors.New("OldMode requires an ID field in the mutation")
  14942. }
  14943. oldValue, err := m.oldValue(ctx)
  14944. if err != nil {
  14945. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  14946. }
  14947. return oldValue.Mode, nil
  14948. }
  14949. // AddMode adds i to the "mode" field.
  14950. func (m *LabelMutation) AddMode(i int) {
  14951. if m.addmode != nil {
  14952. *m.addmode += i
  14953. } else {
  14954. m.addmode = &i
  14955. }
  14956. }
  14957. // AddedMode returns the value that was added to the "mode" field in this mutation.
  14958. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  14959. v := m.addmode
  14960. if v == nil {
  14961. return
  14962. }
  14963. return *v, true
  14964. }
  14965. // ResetMode resets all changes to the "mode" field.
  14966. func (m *LabelMutation) ResetMode() {
  14967. m.mode = nil
  14968. m.addmode = nil
  14969. }
  14970. // SetConditions sets the "conditions" field.
  14971. func (m *LabelMutation) SetConditions(s string) {
  14972. m.conditions = &s
  14973. }
  14974. // Conditions returns the value of the "conditions" field in the mutation.
  14975. func (m *LabelMutation) Conditions() (r string, exists bool) {
  14976. v := m.conditions
  14977. if v == nil {
  14978. return
  14979. }
  14980. return *v, true
  14981. }
  14982. // OldConditions returns the old "conditions" field's value of the Label entity.
  14983. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14985. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  14986. if !m.op.Is(OpUpdateOne) {
  14987. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  14988. }
  14989. if m.id == nil || m.oldValue == nil {
  14990. return v, errors.New("OldConditions requires an ID field in the mutation")
  14991. }
  14992. oldValue, err := m.oldValue(ctx)
  14993. if err != nil {
  14994. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  14995. }
  14996. return oldValue.Conditions, nil
  14997. }
  14998. // ClearConditions clears the value of the "conditions" field.
  14999. func (m *LabelMutation) ClearConditions() {
  15000. m.conditions = nil
  15001. m.clearedFields[label.FieldConditions] = struct{}{}
  15002. }
  15003. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  15004. func (m *LabelMutation) ConditionsCleared() bool {
  15005. _, ok := m.clearedFields[label.FieldConditions]
  15006. return ok
  15007. }
  15008. // ResetConditions resets all changes to the "conditions" field.
  15009. func (m *LabelMutation) ResetConditions() {
  15010. m.conditions = nil
  15011. delete(m.clearedFields, label.FieldConditions)
  15012. }
  15013. // SetOrganizationID sets the "organization_id" field.
  15014. func (m *LabelMutation) SetOrganizationID(u uint64) {
  15015. m.organization_id = &u
  15016. m.addorganization_id = nil
  15017. }
  15018. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15019. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  15020. v := m.organization_id
  15021. if v == nil {
  15022. return
  15023. }
  15024. return *v, true
  15025. }
  15026. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  15027. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15029. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15030. if !m.op.Is(OpUpdateOne) {
  15031. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15032. }
  15033. if m.id == nil || m.oldValue == nil {
  15034. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15035. }
  15036. oldValue, err := m.oldValue(ctx)
  15037. if err != nil {
  15038. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15039. }
  15040. return oldValue.OrganizationID, nil
  15041. }
  15042. // AddOrganizationID adds u to the "organization_id" field.
  15043. func (m *LabelMutation) AddOrganizationID(u int64) {
  15044. if m.addorganization_id != nil {
  15045. *m.addorganization_id += u
  15046. } else {
  15047. m.addorganization_id = &u
  15048. }
  15049. }
  15050. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15051. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  15052. v := m.addorganization_id
  15053. if v == nil {
  15054. return
  15055. }
  15056. return *v, true
  15057. }
  15058. // ClearOrganizationID clears the value of the "organization_id" field.
  15059. func (m *LabelMutation) ClearOrganizationID() {
  15060. m.organization_id = nil
  15061. m.addorganization_id = nil
  15062. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  15063. }
  15064. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15065. func (m *LabelMutation) OrganizationIDCleared() bool {
  15066. _, ok := m.clearedFields[label.FieldOrganizationID]
  15067. return ok
  15068. }
  15069. // ResetOrganizationID resets all changes to the "organization_id" field.
  15070. func (m *LabelMutation) ResetOrganizationID() {
  15071. m.organization_id = nil
  15072. m.addorganization_id = nil
  15073. delete(m.clearedFields, label.FieldOrganizationID)
  15074. }
  15075. // SetCtype sets the "ctype" field.
  15076. func (m *LabelMutation) SetCtype(u uint64) {
  15077. m.ctype = &u
  15078. m.addctype = nil
  15079. }
  15080. // Ctype returns the value of the "ctype" field in the mutation.
  15081. func (m *LabelMutation) Ctype() (r uint64, exists bool) {
  15082. v := m.ctype
  15083. if v == nil {
  15084. return
  15085. }
  15086. return *v, true
  15087. }
  15088. // OldCtype returns the old "ctype" field's value of the Label entity.
  15089. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15091. func (m *LabelMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  15092. if !m.op.Is(OpUpdateOne) {
  15093. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  15094. }
  15095. if m.id == nil || m.oldValue == nil {
  15096. return v, errors.New("OldCtype requires an ID field in the mutation")
  15097. }
  15098. oldValue, err := m.oldValue(ctx)
  15099. if err != nil {
  15100. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  15101. }
  15102. return oldValue.Ctype, nil
  15103. }
  15104. // AddCtype adds u to the "ctype" field.
  15105. func (m *LabelMutation) AddCtype(u int64) {
  15106. if m.addctype != nil {
  15107. *m.addctype += u
  15108. } else {
  15109. m.addctype = &u
  15110. }
  15111. }
  15112. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  15113. func (m *LabelMutation) AddedCtype() (r int64, exists bool) {
  15114. v := m.addctype
  15115. if v == nil {
  15116. return
  15117. }
  15118. return *v, true
  15119. }
  15120. // ResetCtype resets all changes to the "ctype" field.
  15121. func (m *LabelMutation) ResetCtype() {
  15122. m.ctype = nil
  15123. m.addctype = nil
  15124. }
  15125. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  15126. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  15127. if m.label_relationships == nil {
  15128. m.label_relationships = make(map[uint64]struct{})
  15129. }
  15130. for i := range ids {
  15131. m.label_relationships[ids[i]] = struct{}{}
  15132. }
  15133. }
  15134. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  15135. func (m *LabelMutation) ClearLabelRelationships() {
  15136. m.clearedlabel_relationships = true
  15137. }
  15138. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  15139. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  15140. return m.clearedlabel_relationships
  15141. }
  15142. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  15143. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  15144. if m.removedlabel_relationships == nil {
  15145. m.removedlabel_relationships = make(map[uint64]struct{})
  15146. }
  15147. for i := range ids {
  15148. delete(m.label_relationships, ids[i])
  15149. m.removedlabel_relationships[ids[i]] = struct{}{}
  15150. }
  15151. }
  15152. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  15153. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  15154. for id := range m.removedlabel_relationships {
  15155. ids = append(ids, id)
  15156. }
  15157. return
  15158. }
  15159. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  15160. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  15161. for id := range m.label_relationships {
  15162. ids = append(ids, id)
  15163. }
  15164. return
  15165. }
  15166. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  15167. func (m *LabelMutation) ResetLabelRelationships() {
  15168. m.label_relationships = nil
  15169. m.clearedlabel_relationships = false
  15170. m.removedlabel_relationships = nil
  15171. }
  15172. // Where appends a list predicates to the LabelMutation builder.
  15173. func (m *LabelMutation) Where(ps ...predicate.Label) {
  15174. m.predicates = append(m.predicates, ps...)
  15175. }
  15176. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  15177. // users can use type-assertion to append predicates that do not depend on any generated package.
  15178. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  15179. p := make([]predicate.Label, len(ps))
  15180. for i := range ps {
  15181. p[i] = ps[i]
  15182. }
  15183. m.Where(p...)
  15184. }
  15185. // Op returns the operation name.
  15186. func (m *LabelMutation) Op() Op {
  15187. return m.op
  15188. }
  15189. // SetOp allows setting the mutation operation.
  15190. func (m *LabelMutation) SetOp(op Op) {
  15191. m.op = op
  15192. }
  15193. // Type returns the node type of this mutation (Label).
  15194. func (m *LabelMutation) Type() string {
  15195. return m.typ
  15196. }
  15197. // Fields returns all fields that were changed during this mutation. Note that in
  15198. // order to get all numeric fields that were incremented/decremented, call
  15199. // AddedFields().
  15200. func (m *LabelMutation) Fields() []string {
  15201. fields := make([]string, 0, 10)
  15202. if m.created_at != nil {
  15203. fields = append(fields, label.FieldCreatedAt)
  15204. }
  15205. if m.updated_at != nil {
  15206. fields = append(fields, label.FieldUpdatedAt)
  15207. }
  15208. if m.status != nil {
  15209. fields = append(fields, label.FieldStatus)
  15210. }
  15211. if m._type != nil {
  15212. fields = append(fields, label.FieldType)
  15213. }
  15214. if m.name != nil {
  15215. fields = append(fields, label.FieldName)
  15216. }
  15217. if m.from != nil {
  15218. fields = append(fields, label.FieldFrom)
  15219. }
  15220. if m.mode != nil {
  15221. fields = append(fields, label.FieldMode)
  15222. }
  15223. if m.conditions != nil {
  15224. fields = append(fields, label.FieldConditions)
  15225. }
  15226. if m.organization_id != nil {
  15227. fields = append(fields, label.FieldOrganizationID)
  15228. }
  15229. if m.ctype != nil {
  15230. fields = append(fields, label.FieldCtype)
  15231. }
  15232. return fields
  15233. }
  15234. // Field returns the value of a field with the given name. The second boolean
  15235. // return value indicates that this field was not set, or was not defined in the
  15236. // schema.
  15237. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  15238. switch name {
  15239. case label.FieldCreatedAt:
  15240. return m.CreatedAt()
  15241. case label.FieldUpdatedAt:
  15242. return m.UpdatedAt()
  15243. case label.FieldStatus:
  15244. return m.Status()
  15245. case label.FieldType:
  15246. return m.GetType()
  15247. case label.FieldName:
  15248. return m.Name()
  15249. case label.FieldFrom:
  15250. return m.From()
  15251. case label.FieldMode:
  15252. return m.Mode()
  15253. case label.FieldConditions:
  15254. return m.Conditions()
  15255. case label.FieldOrganizationID:
  15256. return m.OrganizationID()
  15257. case label.FieldCtype:
  15258. return m.Ctype()
  15259. }
  15260. return nil, false
  15261. }
  15262. // OldField returns the old value of the field from the database. An error is
  15263. // returned if the mutation operation is not UpdateOne, or the query to the
  15264. // database failed.
  15265. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15266. switch name {
  15267. case label.FieldCreatedAt:
  15268. return m.OldCreatedAt(ctx)
  15269. case label.FieldUpdatedAt:
  15270. return m.OldUpdatedAt(ctx)
  15271. case label.FieldStatus:
  15272. return m.OldStatus(ctx)
  15273. case label.FieldType:
  15274. return m.OldType(ctx)
  15275. case label.FieldName:
  15276. return m.OldName(ctx)
  15277. case label.FieldFrom:
  15278. return m.OldFrom(ctx)
  15279. case label.FieldMode:
  15280. return m.OldMode(ctx)
  15281. case label.FieldConditions:
  15282. return m.OldConditions(ctx)
  15283. case label.FieldOrganizationID:
  15284. return m.OldOrganizationID(ctx)
  15285. case label.FieldCtype:
  15286. return m.OldCtype(ctx)
  15287. }
  15288. return nil, fmt.Errorf("unknown Label field %s", name)
  15289. }
  15290. // SetField sets the value of a field with the given name. It returns an error if
  15291. // the field is not defined in the schema, or if the type mismatched the field
  15292. // type.
  15293. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  15294. switch name {
  15295. case label.FieldCreatedAt:
  15296. v, ok := value.(time.Time)
  15297. if !ok {
  15298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15299. }
  15300. m.SetCreatedAt(v)
  15301. return nil
  15302. case label.FieldUpdatedAt:
  15303. v, ok := value.(time.Time)
  15304. if !ok {
  15305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15306. }
  15307. m.SetUpdatedAt(v)
  15308. return nil
  15309. case label.FieldStatus:
  15310. v, ok := value.(uint8)
  15311. if !ok {
  15312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15313. }
  15314. m.SetStatus(v)
  15315. return nil
  15316. case label.FieldType:
  15317. v, ok := value.(int)
  15318. if !ok {
  15319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15320. }
  15321. m.SetType(v)
  15322. return nil
  15323. case label.FieldName:
  15324. v, ok := value.(string)
  15325. if !ok {
  15326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15327. }
  15328. m.SetName(v)
  15329. return nil
  15330. case label.FieldFrom:
  15331. v, ok := value.(int)
  15332. if !ok {
  15333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15334. }
  15335. m.SetFrom(v)
  15336. return nil
  15337. case label.FieldMode:
  15338. v, ok := value.(int)
  15339. if !ok {
  15340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15341. }
  15342. m.SetMode(v)
  15343. return nil
  15344. case label.FieldConditions:
  15345. v, ok := value.(string)
  15346. if !ok {
  15347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15348. }
  15349. m.SetConditions(v)
  15350. return nil
  15351. case label.FieldOrganizationID:
  15352. v, ok := value.(uint64)
  15353. if !ok {
  15354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15355. }
  15356. m.SetOrganizationID(v)
  15357. return nil
  15358. case label.FieldCtype:
  15359. v, ok := value.(uint64)
  15360. if !ok {
  15361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15362. }
  15363. m.SetCtype(v)
  15364. return nil
  15365. }
  15366. return fmt.Errorf("unknown Label field %s", name)
  15367. }
  15368. // AddedFields returns all numeric fields that were incremented/decremented during
  15369. // this mutation.
  15370. func (m *LabelMutation) AddedFields() []string {
  15371. var fields []string
  15372. if m.addstatus != nil {
  15373. fields = append(fields, label.FieldStatus)
  15374. }
  15375. if m.add_type != nil {
  15376. fields = append(fields, label.FieldType)
  15377. }
  15378. if m.addfrom != nil {
  15379. fields = append(fields, label.FieldFrom)
  15380. }
  15381. if m.addmode != nil {
  15382. fields = append(fields, label.FieldMode)
  15383. }
  15384. if m.addorganization_id != nil {
  15385. fields = append(fields, label.FieldOrganizationID)
  15386. }
  15387. if m.addctype != nil {
  15388. fields = append(fields, label.FieldCtype)
  15389. }
  15390. return fields
  15391. }
  15392. // AddedField returns the numeric value that was incremented/decremented on a field
  15393. // with the given name. The second boolean return value indicates that this field
  15394. // was not set, or was not defined in the schema.
  15395. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  15396. switch name {
  15397. case label.FieldStatus:
  15398. return m.AddedStatus()
  15399. case label.FieldType:
  15400. return m.AddedType()
  15401. case label.FieldFrom:
  15402. return m.AddedFrom()
  15403. case label.FieldMode:
  15404. return m.AddedMode()
  15405. case label.FieldOrganizationID:
  15406. return m.AddedOrganizationID()
  15407. case label.FieldCtype:
  15408. return m.AddedCtype()
  15409. }
  15410. return nil, false
  15411. }
  15412. // AddField adds the value to the field with the given name. It returns an error if
  15413. // the field is not defined in the schema, or if the type mismatched the field
  15414. // type.
  15415. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  15416. switch name {
  15417. case label.FieldStatus:
  15418. v, ok := value.(int8)
  15419. if !ok {
  15420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15421. }
  15422. m.AddStatus(v)
  15423. return nil
  15424. case label.FieldType:
  15425. v, ok := value.(int)
  15426. if !ok {
  15427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15428. }
  15429. m.AddType(v)
  15430. return nil
  15431. case label.FieldFrom:
  15432. v, ok := value.(int)
  15433. if !ok {
  15434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15435. }
  15436. m.AddFrom(v)
  15437. return nil
  15438. case label.FieldMode:
  15439. v, ok := value.(int)
  15440. if !ok {
  15441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15442. }
  15443. m.AddMode(v)
  15444. return nil
  15445. case label.FieldOrganizationID:
  15446. v, ok := value.(int64)
  15447. if !ok {
  15448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15449. }
  15450. m.AddOrganizationID(v)
  15451. return nil
  15452. case label.FieldCtype:
  15453. v, ok := value.(int64)
  15454. if !ok {
  15455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15456. }
  15457. m.AddCtype(v)
  15458. return nil
  15459. }
  15460. return fmt.Errorf("unknown Label numeric field %s", name)
  15461. }
  15462. // ClearedFields returns all nullable fields that were cleared during this
  15463. // mutation.
  15464. func (m *LabelMutation) ClearedFields() []string {
  15465. var fields []string
  15466. if m.FieldCleared(label.FieldStatus) {
  15467. fields = append(fields, label.FieldStatus)
  15468. }
  15469. if m.FieldCleared(label.FieldConditions) {
  15470. fields = append(fields, label.FieldConditions)
  15471. }
  15472. if m.FieldCleared(label.FieldOrganizationID) {
  15473. fields = append(fields, label.FieldOrganizationID)
  15474. }
  15475. return fields
  15476. }
  15477. // FieldCleared returns a boolean indicating if a field with the given name was
  15478. // cleared in this mutation.
  15479. func (m *LabelMutation) FieldCleared(name string) bool {
  15480. _, ok := m.clearedFields[name]
  15481. return ok
  15482. }
  15483. // ClearField clears the value of the field with the given name. It returns an
  15484. // error if the field is not defined in the schema.
  15485. func (m *LabelMutation) ClearField(name string) error {
  15486. switch name {
  15487. case label.FieldStatus:
  15488. m.ClearStatus()
  15489. return nil
  15490. case label.FieldConditions:
  15491. m.ClearConditions()
  15492. return nil
  15493. case label.FieldOrganizationID:
  15494. m.ClearOrganizationID()
  15495. return nil
  15496. }
  15497. return fmt.Errorf("unknown Label nullable field %s", name)
  15498. }
  15499. // ResetField resets all changes in the mutation for the field with the given name.
  15500. // It returns an error if the field is not defined in the schema.
  15501. func (m *LabelMutation) ResetField(name string) error {
  15502. switch name {
  15503. case label.FieldCreatedAt:
  15504. m.ResetCreatedAt()
  15505. return nil
  15506. case label.FieldUpdatedAt:
  15507. m.ResetUpdatedAt()
  15508. return nil
  15509. case label.FieldStatus:
  15510. m.ResetStatus()
  15511. return nil
  15512. case label.FieldType:
  15513. m.ResetType()
  15514. return nil
  15515. case label.FieldName:
  15516. m.ResetName()
  15517. return nil
  15518. case label.FieldFrom:
  15519. m.ResetFrom()
  15520. return nil
  15521. case label.FieldMode:
  15522. m.ResetMode()
  15523. return nil
  15524. case label.FieldConditions:
  15525. m.ResetConditions()
  15526. return nil
  15527. case label.FieldOrganizationID:
  15528. m.ResetOrganizationID()
  15529. return nil
  15530. case label.FieldCtype:
  15531. m.ResetCtype()
  15532. return nil
  15533. }
  15534. return fmt.Errorf("unknown Label field %s", name)
  15535. }
  15536. // AddedEdges returns all edge names that were set/added in this mutation.
  15537. func (m *LabelMutation) AddedEdges() []string {
  15538. edges := make([]string, 0, 1)
  15539. if m.label_relationships != nil {
  15540. edges = append(edges, label.EdgeLabelRelationships)
  15541. }
  15542. return edges
  15543. }
  15544. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15545. // name in this mutation.
  15546. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  15547. switch name {
  15548. case label.EdgeLabelRelationships:
  15549. ids := make([]ent.Value, 0, len(m.label_relationships))
  15550. for id := range m.label_relationships {
  15551. ids = append(ids, id)
  15552. }
  15553. return ids
  15554. }
  15555. return nil
  15556. }
  15557. // RemovedEdges returns all edge names that were removed in this mutation.
  15558. func (m *LabelMutation) RemovedEdges() []string {
  15559. edges := make([]string, 0, 1)
  15560. if m.removedlabel_relationships != nil {
  15561. edges = append(edges, label.EdgeLabelRelationships)
  15562. }
  15563. return edges
  15564. }
  15565. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15566. // the given name in this mutation.
  15567. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  15568. switch name {
  15569. case label.EdgeLabelRelationships:
  15570. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  15571. for id := range m.removedlabel_relationships {
  15572. ids = append(ids, id)
  15573. }
  15574. return ids
  15575. }
  15576. return nil
  15577. }
  15578. // ClearedEdges returns all edge names that were cleared in this mutation.
  15579. func (m *LabelMutation) ClearedEdges() []string {
  15580. edges := make([]string, 0, 1)
  15581. if m.clearedlabel_relationships {
  15582. edges = append(edges, label.EdgeLabelRelationships)
  15583. }
  15584. return edges
  15585. }
  15586. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15587. // was cleared in this mutation.
  15588. func (m *LabelMutation) EdgeCleared(name string) bool {
  15589. switch name {
  15590. case label.EdgeLabelRelationships:
  15591. return m.clearedlabel_relationships
  15592. }
  15593. return false
  15594. }
  15595. // ClearEdge clears the value of the edge with the given name. It returns an error
  15596. // if that edge is not defined in the schema.
  15597. func (m *LabelMutation) ClearEdge(name string) error {
  15598. switch name {
  15599. }
  15600. return fmt.Errorf("unknown Label unique edge %s", name)
  15601. }
  15602. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15603. // It returns an error if the edge is not defined in the schema.
  15604. func (m *LabelMutation) ResetEdge(name string) error {
  15605. switch name {
  15606. case label.EdgeLabelRelationships:
  15607. m.ResetLabelRelationships()
  15608. return nil
  15609. }
  15610. return fmt.Errorf("unknown Label edge %s", name)
  15611. }
  15612. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  15613. type LabelRelationshipMutation struct {
  15614. config
  15615. op Op
  15616. typ string
  15617. id *uint64
  15618. created_at *time.Time
  15619. updated_at *time.Time
  15620. status *uint8
  15621. addstatus *int8
  15622. organization_id *uint64
  15623. addorganization_id *int64
  15624. ctype *uint64
  15625. addctype *int64
  15626. clearedFields map[string]struct{}
  15627. contacts *uint64
  15628. clearedcontacts bool
  15629. labels *uint64
  15630. clearedlabels bool
  15631. done bool
  15632. oldValue func(context.Context) (*LabelRelationship, error)
  15633. predicates []predicate.LabelRelationship
  15634. }
  15635. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  15636. // labelrelationshipOption allows management of the mutation configuration using functional options.
  15637. type labelrelationshipOption func(*LabelRelationshipMutation)
  15638. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  15639. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  15640. m := &LabelRelationshipMutation{
  15641. config: c,
  15642. op: op,
  15643. typ: TypeLabelRelationship,
  15644. clearedFields: make(map[string]struct{}),
  15645. }
  15646. for _, opt := range opts {
  15647. opt(m)
  15648. }
  15649. return m
  15650. }
  15651. // withLabelRelationshipID sets the ID field of the mutation.
  15652. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  15653. return func(m *LabelRelationshipMutation) {
  15654. var (
  15655. err error
  15656. once sync.Once
  15657. value *LabelRelationship
  15658. )
  15659. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  15660. once.Do(func() {
  15661. if m.done {
  15662. err = errors.New("querying old values post mutation is not allowed")
  15663. } else {
  15664. value, err = m.Client().LabelRelationship.Get(ctx, id)
  15665. }
  15666. })
  15667. return value, err
  15668. }
  15669. m.id = &id
  15670. }
  15671. }
  15672. // withLabelRelationship sets the old LabelRelationship of the mutation.
  15673. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  15674. return func(m *LabelRelationshipMutation) {
  15675. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  15676. return node, nil
  15677. }
  15678. m.id = &node.ID
  15679. }
  15680. }
  15681. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15682. // executed in a transaction (ent.Tx), a transactional client is returned.
  15683. func (m LabelRelationshipMutation) Client() *Client {
  15684. client := &Client{config: m.config}
  15685. client.init()
  15686. return client
  15687. }
  15688. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15689. // it returns an error otherwise.
  15690. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  15691. if _, ok := m.driver.(*txDriver); !ok {
  15692. return nil, errors.New("ent: mutation is not running in a transaction")
  15693. }
  15694. tx := &Tx{config: m.config}
  15695. tx.init()
  15696. return tx, nil
  15697. }
  15698. // SetID sets the value of the id field. Note that this
  15699. // operation is only accepted on creation of LabelRelationship entities.
  15700. func (m *LabelRelationshipMutation) SetID(id uint64) {
  15701. m.id = &id
  15702. }
  15703. // ID returns the ID value in the mutation. Note that the ID is only available
  15704. // if it was provided to the builder or after it was returned from the database.
  15705. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  15706. if m.id == nil {
  15707. return
  15708. }
  15709. return *m.id, true
  15710. }
  15711. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15712. // That means, if the mutation is applied within a transaction with an isolation level such
  15713. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15714. // or updated by the mutation.
  15715. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  15716. switch {
  15717. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15718. id, exists := m.ID()
  15719. if exists {
  15720. return []uint64{id}, nil
  15721. }
  15722. fallthrough
  15723. case m.op.Is(OpUpdate | OpDelete):
  15724. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  15725. default:
  15726. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15727. }
  15728. }
  15729. // SetCreatedAt sets the "created_at" field.
  15730. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  15731. m.created_at = &t
  15732. }
  15733. // CreatedAt returns the value of the "created_at" field in the mutation.
  15734. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  15735. v := m.created_at
  15736. if v == nil {
  15737. return
  15738. }
  15739. return *v, true
  15740. }
  15741. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  15742. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15744. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15745. if !m.op.Is(OpUpdateOne) {
  15746. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15747. }
  15748. if m.id == nil || m.oldValue == nil {
  15749. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15750. }
  15751. oldValue, err := m.oldValue(ctx)
  15752. if err != nil {
  15753. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15754. }
  15755. return oldValue.CreatedAt, nil
  15756. }
  15757. // ResetCreatedAt resets all changes to the "created_at" field.
  15758. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  15759. m.created_at = nil
  15760. }
  15761. // SetUpdatedAt sets the "updated_at" field.
  15762. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  15763. m.updated_at = &t
  15764. }
  15765. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15766. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  15767. v := m.updated_at
  15768. if v == nil {
  15769. return
  15770. }
  15771. return *v, true
  15772. }
  15773. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  15774. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15776. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15777. if !m.op.Is(OpUpdateOne) {
  15778. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15779. }
  15780. if m.id == nil || m.oldValue == nil {
  15781. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15782. }
  15783. oldValue, err := m.oldValue(ctx)
  15784. if err != nil {
  15785. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15786. }
  15787. return oldValue.UpdatedAt, nil
  15788. }
  15789. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15790. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  15791. m.updated_at = nil
  15792. }
  15793. // SetStatus sets the "status" field.
  15794. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  15795. m.status = &u
  15796. m.addstatus = nil
  15797. }
  15798. // Status returns the value of the "status" field in the mutation.
  15799. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  15800. v := m.status
  15801. if v == nil {
  15802. return
  15803. }
  15804. return *v, true
  15805. }
  15806. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  15807. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15809. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15810. if !m.op.Is(OpUpdateOne) {
  15811. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15812. }
  15813. if m.id == nil || m.oldValue == nil {
  15814. return v, errors.New("OldStatus requires an ID field in the mutation")
  15815. }
  15816. oldValue, err := m.oldValue(ctx)
  15817. if err != nil {
  15818. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15819. }
  15820. return oldValue.Status, nil
  15821. }
  15822. // AddStatus adds u to the "status" field.
  15823. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  15824. if m.addstatus != nil {
  15825. *m.addstatus += u
  15826. } else {
  15827. m.addstatus = &u
  15828. }
  15829. }
  15830. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15831. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  15832. v := m.addstatus
  15833. if v == nil {
  15834. return
  15835. }
  15836. return *v, true
  15837. }
  15838. // ClearStatus clears the value of the "status" field.
  15839. func (m *LabelRelationshipMutation) ClearStatus() {
  15840. m.status = nil
  15841. m.addstatus = nil
  15842. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  15843. }
  15844. // StatusCleared returns if the "status" field was cleared in this mutation.
  15845. func (m *LabelRelationshipMutation) StatusCleared() bool {
  15846. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  15847. return ok
  15848. }
  15849. // ResetStatus resets all changes to the "status" field.
  15850. func (m *LabelRelationshipMutation) ResetStatus() {
  15851. m.status = nil
  15852. m.addstatus = nil
  15853. delete(m.clearedFields, labelrelationship.FieldStatus)
  15854. }
  15855. // SetLabelID sets the "label_id" field.
  15856. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  15857. m.labels = &u
  15858. }
  15859. // LabelID returns the value of the "label_id" field in the mutation.
  15860. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  15861. v := m.labels
  15862. if v == nil {
  15863. return
  15864. }
  15865. return *v, true
  15866. }
  15867. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  15868. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15870. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  15871. if !m.op.Is(OpUpdateOne) {
  15872. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  15873. }
  15874. if m.id == nil || m.oldValue == nil {
  15875. return v, errors.New("OldLabelID requires an ID field in the mutation")
  15876. }
  15877. oldValue, err := m.oldValue(ctx)
  15878. if err != nil {
  15879. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  15880. }
  15881. return oldValue.LabelID, nil
  15882. }
  15883. // ResetLabelID resets all changes to the "label_id" field.
  15884. func (m *LabelRelationshipMutation) ResetLabelID() {
  15885. m.labels = nil
  15886. }
  15887. // SetContactID sets the "contact_id" field.
  15888. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  15889. m.contacts = &u
  15890. }
  15891. // ContactID returns the value of the "contact_id" field in the mutation.
  15892. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  15893. v := m.contacts
  15894. if v == nil {
  15895. return
  15896. }
  15897. return *v, true
  15898. }
  15899. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  15900. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15902. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  15903. if !m.op.Is(OpUpdateOne) {
  15904. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  15905. }
  15906. if m.id == nil || m.oldValue == nil {
  15907. return v, errors.New("OldContactID requires an ID field in the mutation")
  15908. }
  15909. oldValue, err := m.oldValue(ctx)
  15910. if err != nil {
  15911. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  15912. }
  15913. return oldValue.ContactID, nil
  15914. }
  15915. // ResetContactID resets all changes to the "contact_id" field.
  15916. func (m *LabelRelationshipMutation) ResetContactID() {
  15917. m.contacts = nil
  15918. }
  15919. // SetOrganizationID sets the "organization_id" field.
  15920. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  15921. m.organization_id = &u
  15922. m.addorganization_id = nil
  15923. }
  15924. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15925. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  15926. v := m.organization_id
  15927. if v == nil {
  15928. return
  15929. }
  15930. return *v, true
  15931. }
  15932. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  15933. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15935. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15936. if !m.op.Is(OpUpdateOne) {
  15937. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15938. }
  15939. if m.id == nil || m.oldValue == nil {
  15940. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15941. }
  15942. oldValue, err := m.oldValue(ctx)
  15943. if err != nil {
  15944. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15945. }
  15946. return oldValue.OrganizationID, nil
  15947. }
  15948. // AddOrganizationID adds u to the "organization_id" field.
  15949. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  15950. if m.addorganization_id != nil {
  15951. *m.addorganization_id += u
  15952. } else {
  15953. m.addorganization_id = &u
  15954. }
  15955. }
  15956. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15957. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  15958. v := m.addorganization_id
  15959. if v == nil {
  15960. return
  15961. }
  15962. return *v, true
  15963. }
  15964. // ClearOrganizationID clears the value of the "organization_id" field.
  15965. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  15966. m.organization_id = nil
  15967. m.addorganization_id = nil
  15968. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  15969. }
  15970. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15971. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  15972. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  15973. return ok
  15974. }
  15975. // ResetOrganizationID resets all changes to the "organization_id" field.
  15976. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  15977. m.organization_id = nil
  15978. m.addorganization_id = nil
  15979. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  15980. }
  15981. // SetCtype sets the "ctype" field.
  15982. func (m *LabelRelationshipMutation) SetCtype(u uint64) {
  15983. m.ctype = &u
  15984. m.addctype = nil
  15985. }
  15986. // Ctype returns the value of the "ctype" field in the mutation.
  15987. func (m *LabelRelationshipMutation) Ctype() (r uint64, exists bool) {
  15988. v := m.ctype
  15989. if v == nil {
  15990. return
  15991. }
  15992. return *v, true
  15993. }
  15994. // OldCtype returns the old "ctype" field's value of the LabelRelationship entity.
  15995. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15997. func (m *LabelRelationshipMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  15998. if !m.op.Is(OpUpdateOne) {
  15999. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  16000. }
  16001. if m.id == nil || m.oldValue == nil {
  16002. return v, errors.New("OldCtype requires an ID field in the mutation")
  16003. }
  16004. oldValue, err := m.oldValue(ctx)
  16005. if err != nil {
  16006. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  16007. }
  16008. return oldValue.Ctype, nil
  16009. }
  16010. // AddCtype adds u to the "ctype" field.
  16011. func (m *LabelRelationshipMutation) AddCtype(u int64) {
  16012. if m.addctype != nil {
  16013. *m.addctype += u
  16014. } else {
  16015. m.addctype = &u
  16016. }
  16017. }
  16018. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  16019. func (m *LabelRelationshipMutation) AddedCtype() (r int64, exists bool) {
  16020. v := m.addctype
  16021. if v == nil {
  16022. return
  16023. }
  16024. return *v, true
  16025. }
  16026. // ResetCtype resets all changes to the "ctype" field.
  16027. func (m *LabelRelationshipMutation) ResetCtype() {
  16028. m.ctype = nil
  16029. m.addctype = nil
  16030. }
  16031. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  16032. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  16033. m.contacts = &id
  16034. }
  16035. // ClearContacts clears the "contacts" edge to the Contact entity.
  16036. func (m *LabelRelationshipMutation) ClearContacts() {
  16037. m.clearedcontacts = true
  16038. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  16039. }
  16040. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  16041. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  16042. return m.clearedcontacts
  16043. }
  16044. // ContactsID returns the "contacts" edge ID in the mutation.
  16045. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  16046. if m.contacts != nil {
  16047. return *m.contacts, true
  16048. }
  16049. return
  16050. }
  16051. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  16052. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16053. // ContactsID instead. It exists only for internal usage by the builders.
  16054. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  16055. if id := m.contacts; id != nil {
  16056. ids = append(ids, *id)
  16057. }
  16058. return
  16059. }
  16060. // ResetContacts resets all changes to the "contacts" edge.
  16061. func (m *LabelRelationshipMutation) ResetContacts() {
  16062. m.contacts = nil
  16063. m.clearedcontacts = false
  16064. }
  16065. // SetLabelsID sets the "labels" edge to the Label entity by id.
  16066. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  16067. m.labels = &id
  16068. }
  16069. // ClearLabels clears the "labels" edge to the Label entity.
  16070. func (m *LabelRelationshipMutation) ClearLabels() {
  16071. m.clearedlabels = true
  16072. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  16073. }
  16074. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  16075. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  16076. return m.clearedlabels
  16077. }
  16078. // LabelsID returns the "labels" edge ID in the mutation.
  16079. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  16080. if m.labels != nil {
  16081. return *m.labels, true
  16082. }
  16083. return
  16084. }
  16085. // LabelsIDs returns the "labels" edge IDs in the mutation.
  16086. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16087. // LabelsID instead. It exists only for internal usage by the builders.
  16088. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  16089. if id := m.labels; id != nil {
  16090. ids = append(ids, *id)
  16091. }
  16092. return
  16093. }
  16094. // ResetLabels resets all changes to the "labels" edge.
  16095. func (m *LabelRelationshipMutation) ResetLabels() {
  16096. m.labels = nil
  16097. m.clearedlabels = false
  16098. }
  16099. // Where appends a list predicates to the LabelRelationshipMutation builder.
  16100. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  16101. m.predicates = append(m.predicates, ps...)
  16102. }
  16103. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  16104. // users can use type-assertion to append predicates that do not depend on any generated package.
  16105. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  16106. p := make([]predicate.LabelRelationship, len(ps))
  16107. for i := range ps {
  16108. p[i] = ps[i]
  16109. }
  16110. m.Where(p...)
  16111. }
  16112. // Op returns the operation name.
  16113. func (m *LabelRelationshipMutation) Op() Op {
  16114. return m.op
  16115. }
  16116. // SetOp allows setting the mutation operation.
  16117. func (m *LabelRelationshipMutation) SetOp(op Op) {
  16118. m.op = op
  16119. }
  16120. // Type returns the node type of this mutation (LabelRelationship).
  16121. func (m *LabelRelationshipMutation) Type() string {
  16122. return m.typ
  16123. }
  16124. // Fields returns all fields that were changed during this mutation. Note that in
  16125. // order to get all numeric fields that were incremented/decremented, call
  16126. // AddedFields().
  16127. func (m *LabelRelationshipMutation) Fields() []string {
  16128. fields := make([]string, 0, 7)
  16129. if m.created_at != nil {
  16130. fields = append(fields, labelrelationship.FieldCreatedAt)
  16131. }
  16132. if m.updated_at != nil {
  16133. fields = append(fields, labelrelationship.FieldUpdatedAt)
  16134. }
  16135. if m.status != nil {
  16136. fields = append(fields, labelrelationship.FieldStatus)
  16137. }
  16138. if m.labels != nil {
  16139. fields = append(fields, labelrelationship.FieldLabelID)
  16140. }
  16141. if m.contacts != nil {
  16142. fields = append(fields, labelrelationship.FieldContactID)
  16143. }
  16144. if m.organization_id != nil {
  16145. fields = append(fields, labelrelationship.FieldOrganizationID)
  16146. }
  16147. if m.ctype != nil {
  16148. fields = append(fields, labelrelationship.FieldCtype)
  16149. }
  16150. return fields
  16151. }
  16152. // Field returns the value of a field with the given name. The second boolean
  16153. // return value indicates that this field was not set, or was not defined in the
  16154. // schema.
  16155. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  16156. switch name {
  16157. case labelrelationship.FieldCreatedAt:
  16158. return m.CreatedAt()
  16159. case labelrelationship.FieldUpdatedAt:
  16160. return m.UpdatedAt()
  16161. case labelrelationship.FieldStatus:
  16162. return m.Status()
  16163. case labelrelationship.FieldLabelID:
  16164. return m.LabelID()
  16165. case labelrelationship.FieldContactID:
  16166. return m.ContactID()
  16167. case labelrelationship.FieldOrganizationID:
  16168. return m.OrganizationID()
  16169. case labelrelationship.FieldCtype:
  16170. return m.Ctype()
  16171. }
  16172. return nil, false
  16173. }
  16174. // OldField returns the old value of the field from the database. An error is
  16175. // returned if the mutation operation is not UpdateOne, or the query to the
  16176. // database failed.
  16177. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16178. switch name {
  16179. case labelrelationship.FieldCreatedAt:
  16180. return m.OldCreatedAt(ctx)
  16181. case labelrelationship.FieldUpdatedAt:
  16182. return m.OldUpdatedAt(ctx)
  16183. case labelrelationship.FieldStatus:
  16184. return m.OldStatus(ctx)
  16185. case labelrelationship.FieldLabelID:
  16186. return m.OldLabelID(ctx)
  16187. case labelrelationship.FieldContactID:
  16188. return m.OldContactID(ctx)
  16189. case labelrelationship.FieldOrganizationID:
  16190. return m.OldOrganizationID(ctx)
  16191. case labelrelationship.FieldCtype:
  16192. return m.OldCtype(ctx)
  16193. }
  16194. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  16195. }
  16196. // SetField sets the value of a field with the given name. It returns an error if
  16197. // the field is not defined in the schema, or if the type mismatched the field
  16198. // type.
  16199. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  16200. switch name {
  16201. case labelrelationship.FieldCreatedAt:
  16202. v, ok := value.(time.Time)
  16203. if !ok {
  16204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16205. }
  16206. m.SetCreatedAt(v)
  16207. return nil
  16208. case labelrelationship.FieldUpdatedAt:
  16209. v, ok := value.(time.Time)
  16210. if !ok {
  16211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16212. }
  16213. m.SetUpdatedAt(v)
  16214. return nil
  16215. case labelrelationship.FieldStatus:
  16216. v, ok := value.(uint8)
  16217. if !ok {
  16218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16219. }
  16220. m.SetStatus(v)
  16221. return nil
  16222. case labelrelationship.FieldLabelID:
  16223. v, ok := value.(uint64)
  16224. if !ok {
  16225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16226. }
  16227. m.SetLabelID(v)
  16228. return nil
  16229. case labelrelationship.FieldContactID:
  16230. v, ok := value.(uint64)
  16231. if !ok {
  16232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16233. }
  16234. m.SetContactID(v)
  16235. return nil
  16236. case labelrelationship.FieldOrganizationID:
  16237. v, ok := value.(uint64)
  16238. if !ok {
  16239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16240. }
  16241. m.SetOrganizationID(v)
  16242. return nil
  16243. case labelrelationship.FieldCtype:
  16244. v, ok := value.(uint64)
  16245. if !ok {
  16246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16247. }
  16248. m.SetCtype(v)
  16249. return nil
  16250. }
  16251. return fmt.Errorf("unknown LabelRelationship field %s", name)
  16252. }
  16253. // AddedFields returns all numeric fields that were incremented/decremented during
  16254. // this mutation.
  16255. func (m *LabelRelationshipMutation) AddedFields() []string {
  16256. var fields []string
  16257. if m.addstatus != nil {
  16258. fields = append(fields, labelrelationship.FieldStatus)
  16259. }
  16260. if m.addorganization_id != nil {
  16261. fields = append(fields, labelrelationship.FieldOrganizationID)
  16262. }
  16263. if m.addctype != nil {
  16264. fields = append(fields, labelrelationship.FieldCtype)
  16265. }
  16266. return fields
  16267. }
  16268. // AddedField returns the numeric value that was incremented/decremented on a field
  16269. // with the given name. The second boolean return value indicates that this field
  16270. // was not set, or was not defined in the schema.
  16271. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  16272. switch name {
  16273. case labelrelationship.FieldStatus:
  16274. return m.AddedStatus()
  16275. case labelrelationship.FieldOrganizationID:
  16276. return m.AddedOrganizationID()
  16277. case labelrelationship.FieldCtype:
  16278. return m.AddedCtype()
  16279. }
  16280. return nil, false
  16281. }
  16282. // AddField adds the value to the field with the given name. It returns an error if
  16283. // the field is not defined in the schema, or if the type mismatched the field
  16284. // type.
  16285. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  16286. switch name {
  16287. case labelrelationship.FieldStatus:
  16288. v, ok := value.(int8)
  16289. if !ok {
  16290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16291. }
  16292. m.AddStatus(v)
  16293. return nil
  16294. case labelrelationship.FieldOrganizationID:
  16295. v, ok := value.(int64)
  16296. if !ok {
  16297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16298. }
  16299. m.AddOrganizationID(v)
  16300. return nil
  16301. case labelrelationship.FieldCtype:
  16302. v, ok := value.(int64)
  16303. if !ok {
  16304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16305. }
  16306. m.AddCtype(v)
  16307. return nil
  16308. }
  16309. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  16310. }
  16311. // ClearedFields returns all nullable fields that were cleared during this
  16312. // mutation.
  16313. func (m *LabelRelationshipMutation) ClearedFields() []string {
  16314. var fields []string
  16315. if m.FieldCleared(labelrelationship.FieldStatus) {
  16316. fields = append(fields, labelrelationship.FieldStatus)
  16317. }
  16318. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  16319. fields = append(fields, labelrelationship.FieldOrganizationID)
  16320. }
  16321. return fields
  16322. }
  16323. // FieldCleared returns a boolean indicating if a field with the given name was
  16324. // cleared in this mutation.
  16325. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  16326. _, ok := m.clearedFields[name]
  16327. return ok
  16328. }
  16329. // ClearField clears the value of the field with the given name. It returns an
  16330. // error if the field is not defined in the schema.
  16331. func (m *LabelRelationshipMutation) ClearField(name string) error {
  16332. switch name {
  16333. case labelrelationship.FieldStatus:
  16334. m.ClearStatus()
  16335. return nil
  16336. case labelrelationship.FieldOrganizationID:
  16337. m.ClearOrganizationID()
  16338. return nil
  16339. }
  16340. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  16341. }
  16342. // ResetField resets all changes in the mutation for the field with the given name.
  16343. // It returns an error if the field is not defined in the schema.
  16344. func (m *LabelRelationshipMutation) ResetField(name string) error {
  16345. switch name {
  16346. case labelrelationship.FieldCreatedAt:
  16347. m.ResetCreatedAt()
  16348. return nil
  16349. case labelrelationship.FieldUpdatedAt:
  16350. m.ResetUpdatedAt()
  16351. return nil
  16352. case labelrelationship.FieldStatus:
  16353. m.ResetStatus()
  16354. return nil
  16355. case labelrelationship.FieldLabelID:
  16356. m.ResetLabelID()
  16357. return nil
  16358. case labelrelationship.FieldContactID:
  16359. m.ResetContactID()
  16360. return nil
  16361. case labelrelationship.FieldOrganizationID:
  16362. m.ResetOrganizationID()
  16363. return nil
  16364. case labelrelationship.FieldCtype:
  16365. m.ResetCtype()
  16366. return nil
  16367. }
  16368. return fmt.Errorf("unknown LabelRelationship field %s", name)
  16369. }
  16370. // AddedEdges returns all edge names that were set/added in this mutation.
  16371. func (m *LabelRelationshipMutation) AddedEdges() []string {
  16372. edges := make([]string, 0, 2)
  16373. if m.contacts != nil {
  16374. edges = append(edges, labelrelationship.EdgeContacts)
  16375. }
  16376. if m.labels != nil {
  16377. edges = append(edges, labelrelationship.EdgeLabels)
  16378. }
  16379. return edges
  16380. }
  16381. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16382. // name in this mutation.
  16383. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  16384. switch name {
  16385. case labelrelationship.EdgeContacts:
  16386. if id := m.contacts; id != nil {
  16387. return []ent.Value{*id}
  16388. }
  16389. case labelrelationship.EdgeLabels:
  16390. if id := m.labels; id != nil {
  16391. return []ent.Value{*id}
  16392. }
  16393. }
  16394. return nil
  16395. }
  16396. // RemovedEdges returns all edge names that were removed in this mutation.
  16397. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  16398. edges := make([]string, 0, 2)
  16399. return edges
  16400. }
  16401. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16402. // the given name in this mutation.
  16403. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  16404. return nil
  16405. }
  16406. // ClearedEdges returns all edge names that were cleared in this mutation.
  16407. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  16408. edges := make([]string, 0, 2)
  16409. if m.clearedcontacts {
  16410. edges = append(edges, labelrelationship.EdgeContacts)
  16411. }
  16412. if m.clearedlabels {
  16413. edges = append(edges, labelrelationship.EdgeLabels)
  16414. }
  16415. return edges
  16416. }
  16417. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16418. // was cleared in this mutation.
  16419. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  16420. switch name {
  16421. case labelrelationship.EdgeContacts:
  16422. return m.clearedcontacts
  16423. case labelrelationship.EdgeLabels:
  16424. return m.clearedlabels
  16425. }
  16426. return false
  16427. }
  16428. // ClearEdge clears the value of the edge with the given name. It returns an error
  16429. // if that edge is not defined in the schema.
  16430. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  16431. switch name {
  16432. case labelrelationship.EdgeContacts:
  16433. m.ClearContacts()
  16434. return nil
  16435. case labelrelationship.EdgeLabels:
  16436. m.ClearLabels()
  16437. return nil
  16438. }
  16439. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  16440. }
  16441. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16442. // It returns an error if the edge is not defined in the schema.
  16443. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  16444. switch name {
  16445. case labelrelationship.EdgeContacts:
  16446. m.ResetContacts()
  16447. return nil
  16448. case labelrelationship.EdgeLabels:
  16449. m.ResetLabels()
  16450. return nil
  16451. }
  16452. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  16453. }
  16454. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  16455. type LabelTaggingMutation struct {
  16456. config
  16457. op Op
  16458. typ string
  16459. id *uint64
  16460. created_at *time.Time
  16461. updated_at *time.Time
  16462. status *uint8
  16463. addstatus *int8
  16464. deleted_at *time.Time
  16465. organization_id *uint64
  16466. addorganization_id *int64
  16467. _type *int
  16468. add_type *int
  16469. conditions *string
  16470. action_label_add *[]uint64
  16471. appendaction_label_add []uint64
  16472. action_label_del *[]uint64
  16473. appendaction_label_del []uint64
  16474. clearedFields map[string]struct{}
  16475. done bool
  16476. oldValue func(context.Context) (*LabelTagging, error)
  16477. predicates []predicate.LabelTagging
  16478. }
  16479. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  16480. // labeltaggingOption allows management of the mutation configuration using functional options.
  16481. type labeltaggingOption func(*LabelTaggingMutation)
  16482. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  16483. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  16484. m := &LabelTaggingMutation{
  16485. config: c,
  16486. op: op,
  16487. typ: TypeLabelTagging,
  16488. clearedFields: make(map[string]struct{}),
  16489. }
  16490. for _, opt := range opts {
  16491. opt(m)
  16492. }
  16493. return m
  16494. }
  16495. // withLabelTaggingID sets the ID field of the mutation.
  16496. func withLabelTaggingID(id uint64) labeltaggingOption {
  16497. return func(m *LabelTaggingMutation) {
  16498. var (
  16499. err error
  16500. once sync.Once
  16501. value *LabelTagging
  16502. )
  16503. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  16504. once.Do(func() {
  16505. if m.done {
  16506. err = errors.New("querying old values post mutation is not allowed")
  16507. } else {
  16508. value, err = m.Client().LabelTagging.Get(ctx, id)
  16509. }
  16510. })
  16511. return value, err
  16512. }
  16513. m.id = &id
  16514. }
  16515. }
  16516. // withLabelTagging sets the old LabelTagging of the mutation.
  16517. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  16518. return func(m *LabelTaggingMutation) {
  16519. m.oldValue = func(context.Context) (*LabelTagging, error) {
  16520. return node, nil
  16521. }
  16522. m.id = &node.ID
  16523. }
  16524. }
  16525. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16526. // executed in a transaction (ent.Tx), a transactional client is returned.
  16527. func (m LabelTaggingMutation) Client() *Client {
  16528. client := &Client{config: m.config}
  16529. client.init()
  16530. return client
  16531. }
  16532. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16533. // it returns an error otherwise.
  16534. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  16535. if _, ok := m.driver.(*txDriver); !ok {
  16536. return nil, errors.New("ent: mutation is not running in a transaction")
  16537. }
  16538. tx := &Tx{config: m.config}
  16539. tx.init()
  16540. return tx, nil
  16541. }
  16542. // SetID sets the value of the id field. Note that this
  16543. // operation is only accepted on creation of LabelTagging entities.
  16544. func (m *LabelTaggingMutation) SetID(id uint64) {
  16545. m.id = &id
  16546. }
  16547. // ID returns the ID value in the mutation. Note that the ID is only available
  16548. // if it was provided to the builder or after it was returned from the database.
  16549. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  16550. if m.id == nil {
  16551. return
  16552. }
  16553. return *m.id, true
  16554. }
  16555. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16556. // That means, if the mutation is applied within a transaction with an isolation level such
  16557. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16558. // or updated by the mutation.
  16559. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  16560. switch {
  16561. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16562. id, exists := m.ID()
  16563. if exists {
  16564. return []uint64{id}, nil
  16565. }
  16566. fallthrough
  16567. case m.op.Is(OpUpdate | OpDelete):
  16568. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  16569. default:
  16570. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16571. }
  16572. }
  16573. // SetCreatedAt sets the "created_at" field.
  16574. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  16575. m.created_at = &t
  16576. }
  16577. // CreatedAt returns the value of the "created_at" field in the mutation.
  16578. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  16579. v := m.created_at
  16580. if v == nil {
  16581. return
  16582. }
  16583. return *v, true
  16584. }
  16585. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  16586. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16588. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16589. if !m.op.Is(OpUpdateOne) {
  16590. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16591. }
  16592. if m.id == nil || m.oldValue == nil {
  16593. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16594. }
  16595. oldValue, err := m.oldValue(ctx)
  16596. if err != nil {
  16597. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16598. }
  16599. return oldValue.CreatedAt, nil
  16600. }
  16601. // ResetCreatedAt resets all changes to the "created_at" field.
  16602. func (m *LabelTaggingMutation) ResetCreatedAt() {
  16603. m.created_at = nil
  16604. }
  16605. // SetUpdatedAt sets the "updated_at" field.
  16606. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  16607. m.updated_at = &t
  16608. }
  16609. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16610. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  16611. v := m.updated_at
  16612. if v == nil {
  16613. return
  16614. }
  16615. return *v, true
  16616. }
  16617. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  16618. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16620. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16621. if !m.op.Is(OpUpdateOne) {
  16622. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16623. }
  16624. if m.id == nil || m.oldValue == nil {
  16625. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16626. }
  16627. oldValue, err := m.oldValue(ctx)
  16628. if err != nil {
  16629. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16630. }
  16631. return oldValue.UpdatedAt, nil
  16632. }
  16633. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16634. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  16635. m.updated_at = nil
  16636. }
  16637. // SetStatus sets the "status" field.
  16638. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  16639. m.status = &u
  16640. m.addstatus = nil
  16641. }
  16642. // Status returns the value of the "status" field in the mutation.
  16643. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  16644. v := m.status
  16645. if v == nil {
  16646. return
  16647. }
  16648. return *v, true
  16649. }
  16650. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  16651. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16653. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16654. if !m.op.Is(OpUpdateOne) {
  16655. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16656. }
  16657. if m.id == nil || m.oldValue == nil {
  16658. return v, errors.New("OldStatus requires an ID field in the mutation")
  16659. }
  16660. oldValue, err := m.oldValue(ctx)
  16661. if err != nil {
  16662. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16663. }
  16664. return oldValue.Status, nil
  16665. }
  16666. // AddStatus adds u to the "status" field.
  16667. func (m *LabelTaggingMutation) AddStatus(u int8) {
  16668. if m.addstatus != nil {
  16669. *m.addstatus += u
  16670. } else {
  16671. m.addstatus = &u
  16672. }
  16673. }
  16674. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16675. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  16676. v := m.addstatus
  16677. if v == nil {
  16678. return
  16679. }
  16680. return *v, true
  16681. }
  16682. // ClearStatus clears the value of the "status" field.
  16683. func (m *LabelTaggingMutation) ClearStatus() {
  16684. m.status = nil
  16685. m.addstatus = nil
  16686. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  16687. }
  16688. // StatusCleared returns if the "status" field was cleared in this mutation.
  16689. func (m *LabelTaggingMutation) StatusCleared() bool {
  16690. _, ok := m.clearedFields[labeltagging.FieldStatus]
  16691. return ok
  16692. }
  16693. // ResetStatus resets all changes to the "status" field.
  16694. func (m *LabelTaggingMutation) ResetStatus() {
  16695. m.status = nil
  16696. m.addstatus = nil
  16697. delete(m.clearedFields, labeltagging.FieldStatus)
  16698. }
  16699. // SetDeletedAt sets the "deleted_at" field.
  16700. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  16701. m.deleted_at = &t
  16702. }
  16703. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16704. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  16705. v := m.deleted_at
  16706. if v == nil {
  16707. return
  16708. }
  16709. return *v, true
  16710. }
  16711. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  16712. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16714. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16715. if !m.op.Is(OpUpdateOne) {
  16716. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16717. }
  16718. if m.id == nil || m.oldValue == nil {
  16719. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16720. }
  16721. oldValue, err := m.oldValue(ctx)
  16722. if err != nil {
  16723. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16724. }
  16725. return oldValue.DeletedAt, nil
  16726. }
  16727. // ClearDeletedAt clears the value of the "deleted_at" field.
  16728. func (m *LabelTaggingMutation) ClearDeletedAt() {
  16729. m.deleted_at = nil
  16730. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  16731. }
  16732. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16733. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  16734. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  16735. return ok
  16736. }
  16737. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16738. func (m *LabelTaggingMutation) ResetDeletedAt() {
  16739. m.deleted_at = nil
  16740. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  16741. }
  16742. // SetOrganizationID sets the "organization_id" field.
  16743. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  16744. m.organization_id = &u
  16745. m.addorganization_id = nil
  16746. }
  16747. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16748. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  16749. v := m.organization_id
  16750. if v == nil {
  16751. return
  16752. }
  16753. return *v, true
  16754. }
  16755. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  16756. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16758. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16759. if !m.op.Is(OpUpdateOne) {
  16760. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16761. }
  16762. if m.id == nil || m.oldValue == nil {
  16763. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16764. }
  16765. oldValue, err := m.oldValue(ctx)
  16766. if err != nil {
  16767. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16768. }
  16769. return oldValue.OrganizationID, nil
  16770. }
  16771. // AddOrganizationID adds u to the "organization_id" field.
  16772. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  16773. if m.addorganization_id != nil {
  16774. *m.addorganization_id += u
  16775. } else {
  16776. m.addorganization_id = &u
  16777. }
  16778. }
  16779. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16780. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  16781. v := m.addorganization_id
  16782. if v == nil {
  16783. return
  16784. }
  16785. return *v, true
  16786. }
  16787. // ResetOrganizationID resets all changes to the "organization_id" field.
  16788. func (m *LabelTaggingMutation) ResetOrganizationID() {
  16789. m.organization_id = nil
  16790. m.addorganization_id = nil
  16791. }
  16792. // SetType sets the "type" field.
  16793. func (m *LabelTaggingMutation) SetType(i int) {
  16794. m._type = &i
  16795. m.add_type = nil
  16796. }
  16797. // GetType returns the value of the "type" field in the mutation.
  16798. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  16799. v := m._type
  16800. if v == nil {
  16801. return
  16802. }
  16803. return *v, true
  16804. }
  16805. // OldType returns the old "type" field's value of the LabelTagging entity.
  16806. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16808. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  16809. if !m.op.Is(OpUpdateOne) {
  16810. return v, errors.New("OldType is only allowed on UpdateOne operations")
  16811. }
  16812. if m.id == nil || m.oldValue == nil {
  16813. return v, errors.New("OldType requires an ID field in the mutation")
  16814. }
  16815. oldValue, err := m.oldValue(ctx)
  16816. if err != nil {
  16817. return v, fmt.Errorf("querying old value for OldType: %w", err)
  16818. }
  16819. return oldValue.Type, nil
  16820. }
  16821. // AddType adds i to the "type" field.
  16822. func (m *LabelTaggingMutation) AddType(i int) {
  16823. if m.add_type != nil {
  16824. *m.add_type += i
  16825. } else {
  16826. m.add_type = &i
  16827. }
  16828. }
  16829. // AddedType returns the value that was added to the "type" field in this mutation.
  16830. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  16831. v := m.add_type
  16832. if v == nil {
  16833. return
  16834. }
  16835. return *v, true
  16836. }
  16837. // ResetType resets all changes to the "type" field.
  16838. func (m *LabelTaggingMutation) ResetType() {
  16839. m._type = nil
  16840. m.add_type = nil
  16841. }
  16842. // SetConditions sets the "conditions" field.
  16843. func (m *LabelTaggingMutation) SetConditions(s string) {
  16844. m.conditions = &s
  16845. }
  16846. // Conditions returns the value of the "conditions" field in the mutation.
  16847. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  16848. v := m.conditions
  16849. if v == nil {
  16850. return
  16851. }
  16852. return *v, true
  16853. }
  16854. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  16855. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16857. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  16858. if !m.op.Is(OpUpdateOne) {
  16859. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16860. }
  16861. if m.id == nil || m.oldValue == nil {
  16862. return v, errors.New("OldConditions requires an ID field in the mutation")
  16863. }
  16864. oldValue, err := m.oldValue(ctx)
  16865. if err != nil {
  16866. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  16867. }
  16868. return oldValue.Conditions, nil
  16869. }
  16870. // ResetConditions resets all changes to the "conditions" field.
  16871. func (m *LabelTaggingMutation) ResetConditions() {
  16872. m.conditions = nil
  16873. }
  16874. // SetActionLabelAdd sets the "action_label_add" field.
  16875. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  16876. m.action_label_add = &u
  16877. m.appendaction_label_add = nil
  16878. }
  16879. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  16880. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  16881. v := m.action_label_add
  16882. if v == nil {
  16883. return
  16884. }
  16885. return *v, true
  16886. }
  16887. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  16888. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16890. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  16891. if !m.op.Is(OpUpdateOne) {
  16892. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  16893. }
  16894. if m.id == nil || m.oldValue == nil {
  16895. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  16896. }
  16897. oldValue, err := m.oldValue(ctx)
  16898. if err != nil {
  16899. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  16900. }
  16901. return oldValue.ActionLabelAdd, nil
  16902. }
  16903. // AppendActionLabelAdd adds u to the "action_label_add" field.
  16904. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  16905. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  16906. }
  16907. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  16908. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  16909. if len(m.appendaction_label_add) == 0 {
  16910. return nil, false
  16911. }
  16912. return m.appendaction_label_add, true
  16913. }
  16914. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  16915. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  16916. m.action_label_add = nil
  16917. m.appendaction_label_add = nil
  16918. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  16919. }
  16920. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  16921. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  16922. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  16923. return ok
  16924. }
  16925. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  16926. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  16927. m.action_label_add = nil
  16928. m.appendaction_label_add = nil
  16929. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  16930. }
  16931. // SetActionLabelDel sets the "action_label_del" field.
  16932. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  16933. m.action_label_del = &u
  16934. m.appendaction_label_del = nil
  16935. }
  16936. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  16937. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  16938. v := m.action_label_del
  16939. if v == nil {
  16940. return
  16941. }
  16942. return *v, true
  16943. }
  16944. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  16945. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16947. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  16948. if !m.op.Is(OpUpdateOne) {
  16949. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  16950. }
  16951. if m.id == nil || m.oldValue == nil {
  16952. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  16953. }
  16954. oldValue, err := m.oldValue(ctx)
  16955. if err != nil {
  16956. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  16957. }
  16958. return oldValue.ActionLabelDel, nil
  16959. }
  16960. // AppendActionLabelDel adds u to the "action_label_del" field.
  16961. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  16962. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  16963. }
  16964. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  16965. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  16966. if len(m.appendaction_label_del) == 0 {
  16967. return nil, false
  16968. }
  16969. return m.appendaction_label_del, true
  16970. }
  16971. // ClearActionLabelDel clears the value of the "action_label_del" field.
  16972. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  16973. m.action_label_del = nil
  16974. m.appendaction_label_del = nil
  16975. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  16976. }
  16977. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  16978. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  16979. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  16980. return ok
  16981. }
  16982. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  16983. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  16984. m.action_label_del = nil
  16985. m.appendaction_label_del = nil
  16986. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  16987. }
  16988. // Where appends a list predicates to the LabelTaggingMutation builder.
  16989. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  16990. m.predicates = append(m.predicates, ps...)
  16991. }
  16992. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  16993. // users can use type-assertion to append predicates that do not depend on any generated package.
  16994. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  16995. p := make([]predicate.LabelTagging, len(ps))
  16996. for i := range ps {
  16997. p[i] = ps[i]
  16998. }
  16999. m.Where(p...)
  17000. }
  17001. // Op returns the operation name.
  17002. func (m *LabelTaggingMutation) Op() Op {
  17003. return m.op
  17004. }
  17005. // SetOp allows setting the mutation operation.
  17006. func (m *LabelTaggingMutation) SetOp(op Op) {
  17007. m.op = op
  17008. }
  17009. // Type returns the node type of this mutation (LabelTagging).
  17010. func (m *LabelTaggingMutation) Type() string {
  17011. return m.typ
  17012. }
  17013. // Fields returns all fields that were changed during this mutation. Note that in
  17014. // order to get all numeric fields that were incremented/decremented, call
  17015. // AddedFields().
  17016. func (m *LabelTaggingMutation) Fields() []string {
  17017. fields := make([]string, 0, 9)
  17018. if m.created_at != nil {
  17019. fields = append(fields, labeltagging.FieldCreatedAt)
  17020. }
  17021. if m.updated_at != nil {
  17022. fields = append(fields, labeltagging.FieldUpdatedAt)
  17023. }
  17024. if m.status != nil {
  17025. fields = append(fields, labeltagging.FieldStatus)
  17026. }
  17027. if m.deleted_at != nil {
  17028. fields = append(fields, labeltagging.FieldDeletedAt)
  17029. }
  17030. if m.organization_id != nil {
  17031. fields = append(fields, labeltagging.FieldOrganizationID)
  17032. }
  17033. if m._type != nil {
  17034. fields = append(fields, labeltagging.FieldType)
  17035. }
  17036. if m.conditions != nil {
  17037. fields = append(fields, labeltagging.FieldConditions)
  17038. }
  17039. if m.action_label_add != nil {
  17040. fields = append(fields, labeltagging.FieldActionLabelAdd)
  17041. }
  17042. if m.action_label_del != nil {
  17043. fields = append(fields, labeltagging.FieldActionLabelDel)
  17044. }
  17045. return fields
  17046. }
  17047. // Field returns the value of a field with the given name. The second boolean
  17048. // return value indicates that this field was not set, or was not defined in the
  17049. // schema.
  17050. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  17051. switch name {
  17052. case labeltagging.FieldCreatedAt:
  17053. return m.CreatedAt()
  17054. case labeltagging.FieldUpdatedAt:
  17055. return m.UpdatedAt()
  17056. case labeltagging.FieldStatus:
  17057. return m.Status()
  17058. case labeltagging.FieldDeletedAt:
  17059. return m.DeletedAt()
  17060. case labeltagging.FieldOrganizationID:
  17061. return m.OrganizationID()
  17062. case labeltagging.FieldType:
  17063. return m.GetType()
  17064. case labeltagging.FieldConditions:
  17065. return m.Conditions()
  17066. case labeltagging.FieldActionLabelAdd:
  17067. return m.ActionLabelAdd()
  17068. case labeltagging.FieldActionLabelDel:
  17069. return m.ActionLabelDel()
  17070. }
  17071. return nil, false
  17072. }
  17073. // OldField returns the old value of the field from the database. An error is
  17074. // returned if the mutation operation is not UpdateOne, or the query to the
  17075. // database failed.
  17076. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17077. switch name {
  17078. case labeltagging.FieldCreatedAt:
  17079. return m.OldCreatedAt(ctx)
  17080. case labeltagging.FieldUpdatedAt:
  17081. return m.OldUpdatedAt(ctx)
  17082. case labeltagging.FieldStatus:
  17083. return m.OldStatus(ctx)
  17084. case labeltagging.FieldDeletedAt:
  17085. return m.OldDeletedAt(ctx)
  17086. case labeltagging.FieldOrganizationID:
  17087. return m.OldOrganizationID(ctx)
  17088. case labeltagging.FieldType:
  17089. return m.OldType(ctx)
  17090. case labeltagging.FieldConditions:
  17091. return m.OldConditions(ctx)
  17092. case labeltagging.FieldActionLabelAdd:
  17093. return m.OldActionLabelAdd(ctx)
  17094. case labeltagging.FieldActionLabelDel:
  17095. return m.OldActionLabelDel(ctx)
  17096. }
  17097. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  17098. }
  17099. // SetField sets the value of a field with the given name. It returns an error if
  17100. // the field is not defined in the schema, or if the type mismatched the field
  17101. // type.
  17102. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  17103. switch name {
  17104. case labeltagging.FieldCreatedAt:
  17105. v, ok := value.(time.Time)
  17106. if !ok {
  17107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17108. }
  17109. m.SetCreatedAt(v)
  17110. return nil
  17111. case labeltagging.FieldUpdatedAt:
  17112. v, ok := value.(time.Time)
  17113. if !ok {
  17114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17115. }
  17116. m.SetUpdatedAt(v)
  17117. return nil
  17118. case labeltagging.FieldStatus:
  17119. v, ok := value.(uint8)
  17120. if !ok {
  17121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17122. }
  17123. m.SetStatus(v)
  17124. return nil
  17125. case labeltagging.FieldDeletedAt:
  17126. v, ok := value.(time.Time)
  17127. if !ok {
  17128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17129. }
  17130. m.SetDeletedAt(v)
  17131. return nil
  17132. case labeltagging.FieldOrganizationID:
  17133. v, ok := value.(uint64)
  17134. if !ok {
  17135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17136. }
  17137. m.SetOrganizationID(v)
  17138. return nil
  17139. case labeltagging.FieldType:
  17140. v, ok := value.(int)
  17141. if !ok {
  17142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17143. }
  17144. m.SetType(v)
  17145. return nil
  17146. case labeltagging.FieldConditions:
  17147. v, ok := value.(string)
  17148. if !ok {
  17149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17150. }
  17151. m.SetConditions(v)
  17152. return nil
  17153. case labeltagging.FieldActionLabelAdd:
  17154. v, ok := value.([]uint64)
  17155. if !ok {
  17156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17157. }
  17158. m.SetActionLabelAdd(v)
  17159. return nil
  17160. case labeltagging.FieldActionLabelDel:
  17161. v, ok := value.([]uint64)
  17162. if !ok {
  17163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17164. }
  17165. m.SetActionLabelDel(v)
  17166. return nil
  17167. }
  17168. return fmt.Errorf("unknown LabelTagging field %s", name)
  17169. }
  17170. // AddedFields returns all numeric fields that were incremented/decremented during
  17171. // this mutation.
  17172. func (m *LabelTaggingMutation) AddedFields() []string {
  17173. var fields []string
  17174. if m.addstatus != nil {
  17175. fields = append(fields, labeltagging.FieldStatus)
  17176. }
  17177. if m.addorganization_id != nil {
  17178. fields = append(fields, labeltagging.FieldOrganizationID)
  17179. }
  17180. if m.add_type != nil {
  17181. fields = append(fields, labeltagging.FieldType)
  17182. }
  17183. return fields
  17184. }
  17185. // AddedField returns the numeric value that was incremented/decremented on a field
  17186. // with the given name. The second boolean return value indicates that this field
  17187. // was not set, or was not defined in the schema.
  17188. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  17189. switch name {
  17190. case labeltagging.FieldStatus:
  17191. return m.AddedStatus()
  17192. case labeltagging.FieldOrganizationID:
  17193. return m.AddedOrganizationID()
  17194. case labeltagging.FieldType:
  17195. return m.AddedType()
  17196. }
  17197. return nil, false
  17198. }
  17199. // AddField adds the value to the field with the given name. It returns an error if
  17200. // the field is not defined in the schema, or if the type mismatched the field
  17201. // type.
  17202. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  17203. switch name {
  17204. case labeltagging.FieldStatus:
  17205. v, ok := value.(int8)
  17206. if !ok {
  17207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17208. }
  17209. m.AddStatus(v)
  17210. return nil
  17211. case labeltagging.FieldOrganizationID:
  17212. v, ok := value.(int64)
  17213. if !ok {
  17214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17215. }
  17216. m.AddOrganizationID(v)
  17217. return nil
  17218. case labeltagging.FieldType:
  17219. v, ok := value.(int)
  17220. if !ok {
  17221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17222. }
  17223. m.AddType(v)
  17224. return nil
  17225. }
  17226. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  17227. }
  17228. // ClearedFields returns all nullable fields that were cleared during this
  17229. // mutation.
  17230. func (m *LabelTaggingMutation) ClearedFields() []string {
  17231. var fields []string
  17232. if m.FieldCleared(labeltagging.FieldStatus) {
  17233. fields = append(fields, labeltagging.FieldStatus)
  17234. }
  17235. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  17236. fields = append(fields, labeltagging.FieldDeletedAt)
  17237. }
  17238. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  17239. fields = append(fields, labeltagging.FieldActionLabelAdd)
  17240. }
  17241. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  17242. fields = append(fields, labeltagging.FieldActionLabelDel)
  17243. }
  17244. return fields
  17245. }
  17246. // FieldCleared returns a boolean indicating if a field with the given name was
  17247. // cleared in this mutation.
  17248. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  17249. _, ok := m.clearedFields[name]
  17250. return ok
  17251. }
  17252. // ClearField clears the value of the field with the given name. It returns an
  17253. // error if the field is not defined in the schema.
  17254. func (m *LabelTaggingMutation) ClearField(name string) error {
  17255. switch name {
  17256. case labeltagging.FieldStatus:
  17257. m.ClearStatus()
  17258. return nil
  17259. case labeltagging.FieldDeletedAt:
  17260. m.ClearDeletedAt()
  17261. return nil
  17262. case labeltagging.FieldActionLabelAdd:
  17263. m.ClearActionLabelAdd()
  17264. return nil
  17265. case labeltagging.FieldActionLabelDel:
  17266. m.ClearActionLabelDel()
  17267. return nil
  17268. }
  17269. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  17270. }
  17271. // ResetField resets all changes in the mutation for the field with the given name.
  17272. // It returns an error if the field is not defined in the schema.
  17273. func (m *LabelTaggingMutation) ResetField(name string) error {
  17274. switch name {
  17275. case labeltagging.FieldCreatedAt:
  17276. m.ResetCreatedAt()
  17277. return nil
  17278. case labeltagging.FieldUpdatedAt:
  17279. m.ResetUpdatedAt()
  17280. return nil
  17281. case labeltagging.FieldStatus:
  17282. m.ResetStatus()
  17283. return nil
  17284. case labeltagging.FieldDeletedAt:
  17285. m.ResetDeletedAt()
  17286. return nil
  17287. case labeltagging.FieldOrganizationID:
  17288. m.ResetOrganizationID()
  17289. return nil
  17290. case labeltagging.FieldType:
  17291. m.ResetType()
  17292. return nil
  17293. case labeltagging.FieldConditions:
  17294. m.ResetConditions()
  17295. return nil
  17296. case labeltagging.FieldActionLabelAdd:
  17297. m.ResetActionLabelAdd()
  17298. return nil
  17299. case labeltagging.FieldActionLabelDel:
  17300. m.ResetActionLabelDel()
  17301. return nil
  17302. }
  17303. return fmt.Errorf("unknown LabelTagging field %s", name)
  17304. }
  17305. // AddedEdges returns all edge names that were set/added in this mutation.
  17306. func (m *LabelTaggingMutation) AddedEdges() []string {
  17307. edges := make([]string, 0, 0)
  17308. return edges
  17309. }
  17310. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17311. // name in this mutation.
  17312. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  17313. return nil
  17314. }
  17315. // RemovedEdges returns all edge names that were removed in this mutation.
  17316. func (m *LabelTaggingMutation) RemovedEdges() []string {
  17317. edges := make([]string, 0, 0)
  17318. return edges
  17319. }
  17320. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17321. // the given name in this mutation.
  17322. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  17323. return nil
  17324. }
  17325. // ClearedEdges returns all edge names that were cleared in this mutation.
  17326. func (m *LabelTaggingMutation) ClearedEdges() []string {
  17327. edges := make([]string, 0, 0)
  17328. return edges
  17329. }
  17330. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17331. // was cleared in this mutation.
  17332. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  17333. return false
  17334. }
  17335. // ClearEdge clears the value of the edge with the given name. It returns an error
  17336. // if that edge is not defined in the schema.
  17337. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  17338. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  17339. }
  17340. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17341. // It returns an error if the edge is not defined in the schema.
  17342. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  17343. return fmt.Errorf("unknown LabelTagging edge %s", name)
  17344. }
  17345. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  17346. type MessageMutation struct {
  17347. config
  17348. op Op
  17349. typ string
  17350. id *int
  17351. wx_wxid *string
  17352. wxid *string
  17353. content *string
  17354. clearedFields map[string]struct{}
  17355. done bool
  17356. oldValue func(context.Context) (*Message, error)
  17357. predicates []predicate.Message
  17358. }
  17359. var _ ent.Mutation = (*MessageMutation)(nil)
  17360. // messageOption allows management of the mutation configuration using functional options.
  17361. type messageOption func(*MessageMutation)
  17362. // newMessageMutation creates new mutation for the Message entity.
  17363. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  17364. m := &MessageMutation{
  17365. config: c,
  17366. op: op,
  17367. typ: TypeMessage,
  17368. clearedFields: make(map[string]struct{}),
  17369. }
  17370. for _, opt := range opts {
  17371. opt(m)
  17372. }
  17373. return m
  17374. }
  17375. // withMessageID sets the ID field of the mutation.
  17376. func withMessageID(id int) messageOption {
  17377. return func(m *MessageMutation) {
  17378. var (
  17379. err error
  17380. once sync.Once
  17381. value *Message
  17382. )
  17383. m.oldValue = func(ctx context.Context) (*Message, error) {
  17384. once.Do(func() {
  17385. if m.done {
  17386. err = errors.New("querying old values post mutation is not allowed")
  17387. } else {
  17388. value, err = m.Client().Message.Get(ctx, id)
  17389. }
  17390. })
  17391. return value, err
  17392. }
  17393. m.id = &id
  17394. }
  17395. }
  17396. // withMessage sets the old Message of the mutation.
  17397. func withMessage(node *Message) messageOption {
  17398. return func(m *MessageMutation) {
  17399. m.oldValue = func(context.Context) (*Message, error) {
  17400. return node, nil
  17401. }
  17402. m.id = &node.ID
  17403. }
  17404. }
  17405. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17406. // executed in a transaction (ent.Tx), a transactional client is returned.
  17407. func (m MessageMutation) Client() *Client {
  17408. client := &Client{config: m.config}
  17409. client.init()
  17410. return client
  17411. }
  17412. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17413. // it returns an error otherwise.
  17414. func (m MessageMutation) Tx() (*Tx, error) {
  17415. if _, ok := m.driver.(*txDriver); !ok {
  17416. return nil, errors.New("ent: mutation is not running in a transaction")
  17417. }
  17418. tx := &Tx{config: m.config}
  17419. tx.init()
  17420. return tx, nil
  17421. }
  17422. // ID returns the ID value in the mutation. Note that the ID is only available
  17423. // if it was provided to the builder or after it was returned from the database.
  17424. func (m *MessageMutation) ID() (id int, exists bool) {
  17425. if m.id == nil {
  17426. return
  17427. }
  17428. return *m.id, true
  17429. }
  17430. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17431. // That means, if the mutation is applied within a transaction with an isolation level such
  17432. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17433. // or updated by the mutation.
  17434. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  17435. switch {
  17436. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17437. id, exists := m.ID()
  17438. if exists {
  17439. return []int{id}, nil
  17440. }
  17441. fallthrough
  17442. case m.op.Is(OpUpdate | OpDelete):
  17443. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  17444. default:
  17445. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17446. }
  17447. }
  17448. // SetWxWxid sets the "wx_wxid" field.
  17449. func (m *MessageMutation) SetWxWxid(s string) {
  17450. m.wx_wxid = &s
  17451. }
  17452. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  17453. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  17454. v := m.wx_wxid
  17455. if v == nil {
  17456. return
  17457. }
  17458. return *v, true
  17459. }
  17460. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  17461. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17463. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  17464. if !m.op.Is(OpUpdateOne) {
  17465. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  17466. }
  17467. if m.id == nil || m.oldValue == nil {
  17468. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  17469. }
  17470. oldValue, err := m.oldValue(ctx)
  17471. if err != nil {
  17472. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  17473. }
  17474. return oldValue.WxWxid, nil
  17475. }
  17476. // ClearWxWxid clears the value of the "wx_wxid" field.
  17477. func (m *MessageMutation) ClearWxWxid() {
  17478. m.wx_wxid = nil
  17479. m.clearedFields[message.FieldWxWxid] = struct{}{}
  17480. }
  17481. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  17482. func (m *MessageMutation) WxWxidCleared() bool {
  17483. _, ok := m.clearedFields[message.FieldWxWxid]
  17484. return ok
  17485. }
  17486. // ResetWxWxid resets all changes to the "wx_wxid" field.
  17487. func (m *MessageMutation) ResetWxWxid() {
  17488. m.wx_wxid = nil
  17489. delete(m.clearedFields, message.FieldWxWxid)
  17490. }
  17491. // SetWxid sets the "wxid" field.
  17492. func (m *MessageMutation) SetWxid(s string) {
  17493. m.wxid = &s
  17494. }
  17495. // Wxid returns the value of the "wxid" field in the mutation.
  17496. func (m *MessageMutation) Wxid() (r string, exists bool) {
  17497. v := m.wxid
  17498. if v == nil {
  17499. return
  17500. }
  17501. return *v, true
  17502. }
  17503. // OldWxid returns the old "wxid" field's value of the Message entity.
  17504. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17506. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  17507. if !m.op.Is(OpUpdateOne) {
  17508. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  17509. }
  17510. if m.id == nil || m.oldValue == nil {
  17511. return v, errors.New("OldWxid requires an ID field in the mutation")
  17512. }
  17513. oldValue, err := m.oldValue(ctx)
  17514. if err != nil {
  17515. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  17516. }
  17517. return oldValue.Wxid, nil
  17518. }
  17519. // ResetWxid resets all changes to the "wxid" field.
  17520. func (m *MessageMutation) ResetWxid() {
  17521. m.wxid = nil
  17522. }
  17523. // SetContent sets the "content" field.
  17524. func (m *MessageMutation) SetContent(s string) {
  17525. m.content = &s
  17526. }
  17527. // Content returns the value of the "content" field in the mutation.
  17528. func (m *MessageMutation) Content() (r string, exists bool) {
  17529. v := m.content
  17530. if v == nil {
  17531. return
  17532. }
  17533. return *v, true
  17534. }
  17535. // OldContent returns the old "content" field's value of the Message entity.
  17536. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17538. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  17539. if !m.op.Is(OpUpdateOne) {
  17540. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17541. }
  17542. if m.id == nil || m.oldValue == nil {
  17543. return v, errors.New("OldContent requires an ID field in the mutation")
  17544. }
  17545. oldValue, err := m.oldValue(ctx)
  17546. if err != nil {
  17547. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17548. }
  17549. return oldValue.Content, nil
  17550. }
  17551. // ResetContent resets all changes to the "content" field.
  17552. func (m *MessageMutation) ResetContent() {
  17553. m.content = nil
  17554. }
  17555. // Where appends a list predicates to the MessageMutation builder.
  17556. func (m *MessageMutation) Where(ps ...predicate.Message) {
  17557. m.predicates = append(m.predicates, ps...)
  17558. }
  17559. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  17560. // users can use type-assertion to append predicates that do not depend on any generated package.
  17561. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  17562. p := make([]predicate.Message, len(ps))
  17563. for i := range ps {
  17564. p[i] = ps[i]
  17565. }
  17566. m.Where(p...)
  17567. }
  17568. // Op returns the operation name.
  17569. func (m *MessageMutation) Op() Op {
  17570. return m.op
  17571. }
  17572. // SetOp allows setting the mutation operation.
  17573. func (m *MessageMutation) SetOp(op Op) {
  17574. m.op = op
  17575. }
  17576. // Type returns the node type of this mutation (Message).
  17577. func (m *MessageMutation) Type() string {
  17578. return m.typ
  17579. }
  17580. // Fields returns all fields that were changed during this mutation. Note that in
  17581. // order to get all numeric fields that were incremented/decremented, call
  17582. // AddedFields().
  17583. func (m *MessageMutation) Fields() []string {
  17584. fields := make([]string, 0, 3)
  17585. if m.wx_wxid != nil {
  17586. fields = append(fields, message.FieldWxWxid)
  17587. }
  17588. if m.wxid != nil {
  17589. fields = append(fields, message.FieldWxid)
  17590. }
  17591. if m.content != nil {
  17592. fields = append(fields, message.FieldContent)
  17593. }
  17594. return fields
  17595. }
  17596. // Field returns the value of a field with the given name. The second boolean
  17597. // return value indicates that this field was not set, or was not defined in the
  17598. // schema.
  17599. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  17600. switch name {
  17601. case message.FieldWxWxid:
  17602. return m.WxWxid()
  17603. case message.FieldWxid:
  17604. return m.Wxid()
  17605. case message.FieldContent:
  17606. return m.Content()
  17607. }
  17608. return nil, false
  17609. }
  17610. // OldField returns the old value of the field from the database. An error is
  17611. // returned if the mutation operation is not UpdateOne, or the query to the
  17612. // database failed.
  17613. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17614. switch name {
  17615. case message.FieldWxWxid:
  17616. return m.OldWxWxid(ctx)
  17617. case message.FieldWxid:
  17618. return m.OldWxid(ctx)
  17619. case message.FieldContent:
  17620. return m.OldContent(ctx)
  17621. }
  17622. return nil, fmt.Errorf("unknown Message field %s", name)
  17623. }
  17624. // SetField sets the value of a field with the given name. It returns an error if
  17625. // the field is not defined in the schema, or if the type mismatched the field
  17626. // type.
  17627. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  17628. switch name {
  17629. case message.FieldWxWxid:
  17630. v, ok := value.(string)
  17631. if !ok {
  17632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17633. }
  17634. m.SetWxWxid(v)
  17635. return nil
  17636. case message.FieldWxid:
  17637. v, ok := value.(string)
  17638. if !ok {
  17639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17640. }
  17641. m.SetWxid(v)
  17642. return nil
  17643. case message.FieldContent:
  17644. v, ok := value.(string)
  17645. if !ok {
  17646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17647. }
  17648. m.SetContent(v)
  17649. return nil
  17650. }
  17651. return fmt.Errorf("unknown Message field %s", name)
  17652. }
  17653. // AddedFields returns all numeric fields that were incremented/decremented during
  17654. // this mutation.
  17655. func (m *MessageMutation) AddedFields() []string {
  17656. return nil
  17657. }
  17658. // AddedField returns the numeric value that was incremented/decremented on a field
  17659. // with the given name. The second boolean return value indicates that this field
  17660. // was not set, or was not defined in the schema.
  17661. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  17662. return nil, false
  17663. }
  17664. // AddField adds the value to the field with the given name. It returns an error if
  17665. // the field is not defined in the schema, or if the type mismatched the field
  17666. // type.
  17667. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  17668. switch name {
  17669. }
  17670. return fmt.Errorf("unknown Message numeric field %s", name)
  17671. }
  17672. // ClearedFields returns all nullable fields that were cleared during this
  17673. // mutation.
  17674. func (m *MessageMutation) ClearedFields() []string {
  17675. var fields []string
  17676. if m.FieldCleared(message.FieldWxWxid) {
  17677. fields = append(fields, message.FieldWxWxid)
  17678. }
  17679. return fields
  17680. }
  17681. // FieldCleared returns a boolean indicating if a field with the given name was
  17682. // cleared in this mutation.
  17683. func (m *MessageMutation) FieldCleared(name string) bool {
  17684. _, ok := m.clearedFields[name]
  17685. return ok
  17686. }
  17687. // ClearField clears the value of the field with the given name. It returns an
  17688. // error if the field is not defined in the schema.
  17689. func (m *MessageMutation) ClearField(name string) error {
  17690. switch name {
  17691. case message.FieldWxWxid:
  17692. m.ClearWxWxid()
  17693. return nil
  17694. }
  17695. return fmt.Errorf("unknown Message nullable field %s", name)
  17696. }
  17697. // ResetField resets all changes in the mutation for the field with the given name.
  17698. // It returns an error if the field is not defined in the schema.
  17699. func (m *MessageMutation) ResetField(name string) error {
  17700. switch name {
  17701. case message.FieldWxWxid:
  17702. m.ResetWxWxid()
  17703. return nil
  17704. case message.FieldWxid:
  17705. m.ResetWxid()
  17706. return nil
  17707. case message.FieldContent:
  17708. m.ResetContent()
  17709. return nil
  17710. }
  17711. return fmt.Errorf("unknown Message field %s", name)
  17712. }
  17713. // AddedEdges returns all edge names that were set/added in this mutation.
  17714. func (m *MessageMutation) AddedEdges() []string {
  17715. edges := make([]string, 0, 0)
  17716. return edges
  17717. }
  17718. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17719. // name in this mutation.
  17720. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  17721. return nil
  17722. }
  17723. // RemovedEdges returns all edge names that were removed in this mutation.
  17724. func (m *MessageMutation) RemovedEdges() []string {
  17725. edges := make([]string, 0, 0)
  17726. return edges
  17727. }
  17728. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17729. // the given name in this mutation.
  17730. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  17731. return nil
  17732. }
  17733. // ClearedEdges returns all edge names that were cleared in this mutation.
  17734. func (m *MessageMutation) ClearedEdges() []string {
  17735. edges := make([]string, 0, 0)
  17736. return edges
  17737. }
  17738. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17739. // was cleared in this mutation.
  17740. func (m *MessageMutation) EdgeCleared(name string) bool {
  17741. return false
  17742. }
  17743. // ClearEdge clears the value of the edge with the given name. It returns an error
  17744. // if that edge is not defined in the schema.
  17745. func (m *MessageMutation) ClearEdge(name string) error {
  17746. return fmt.Errorf("unknown Message unique edge %s", name)
  17747. }
  17748. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17749. // It returns an error if the edge is not defined in the schema.
  17750. func (m *MessageMutation) ResetEdge(name string) error {
  17751. return fmt.Errorf("unknown Message edge %s", name)
  17752. }
  17753. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  17754. type MessageRecordsMutation struct {
  17755. config
  17756. op Op
  17757. typ string
  17758. id *uint64
  17759. created_at *time.Time
  17760. updated_at *time.Time
  17761. status *uint8
  17762. addstatus *int8
  17763. bot_wxid *string
  17764. contact_type *int
  17765. addcontact_type *int
  17766. contact_wxid *string
  17767. content_type *int
  17768. addcontent_type *int
  17769. content *string
  17770. meta *custom_types.Meta
  17771. error_detail *string
  17772. send_time *time.Time
  17773. source_type *int
  17774. addsource_type *int
  17775. organization_id *uint64
  17776. addorganization_id *int64
  17777. clearedFields map[string]struct{}
  17778. sop_stage *uint64
  17779. clearedsop_stage bool
  17780. sop_node *uint64
  17781. clearedsop_node bool
  17782. message_contact *uint64
  17783. clearedmessage_contact bool
  17784. done bool
  17785. oldValue func(context.Context) (*MessageRecords, error)
  17786. predicates []predicate.MessageRecords
  17787. }
  17788. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  17789. // messagerecordsOption allows management of the mutation configuration using functional options.
  17790. type messagerecordsOption func(*MessageRecordsMutation)
  17791. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  17792. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  17793. m := &MessageRecordsMutation{
  17794. config: c,
  17795. op: op,
  17796. typ: TypeMessageRecords,
  17797. clearedFields: make(map[string]struct{}),
  17798. }
  17799. for _, opt := range opts {
  17800. opt(m)
  17801. }
  17802. return m
  17803. }
  17804. // withMessageRecordsID sets the ID field of the mutation.
  17805. func withMessageRecordsID(id uint64) messagerecordsOption {
  17806. return func(m *MessageRecordsMutation) {
  17807. var (
  17808. err error
  17809. once sync.Once
  17810. value *MessageRecords
  17811. )
  17812. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  17813. once.Do(func() {
  17814. if m.done {
  17815. err = errors.New("querying old values post mutation is not allowed")
  17816. } else {
  17817. value, err = m.Client().MessageRecords.Get(ctx, id)
  17818. }
  17819. })
  17820. return value, err
  17821. }
  17822. m.id = &id
  17823. }
  17824. }
  17825. // withMessageRecords sets the old MessageRecords of the mutation.
  17826. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  17827. return func(m *MessageRecordsMutation) {
  17828. m.oldValue = func(context.Context) (*MessageRecords, error) {
  17829. return node, nil
  17830. }
  17831. m.id = &node.ID
  17832. }
  17833. }
  17834. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17835. // executed in a transaction (ent.Tx), a transactional client is returned.
  17836. func (m MessageRecordsMutation) Client() *Client {
  17837. client := &Client{config: m.config}
  17838. client.init()
  17839. return client
  17840. }
  17841. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17842. // it returns an error otherwise.
  17843. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  17844. if _, ok := m.driver.(*txDriver); !ok {
  17845. return nil, errors.New("ent: mutation is not running in a transaction")
  17846. }
  17847. tx := &Tx{config: m.config}
  17848. tx.init()
  17849. return tx, nil
  17850. }
  17851. // SetID sets the value of the id field. Note that this
  17852. // operation is only accepted on creation of MessageRecords entities.
  17853. func (m *MessageRecordsMutation) SetID(id uint64) {
  17854. m.id = &id
  17855. }
  17856. // ID returns the ID value in the mutation. Note that the ID is only available
  17857. // if it was provided to the builder or after it was returned from the database.
  17858. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  17859. if m.id == nil {
  17860. return
  17861. }
  17862. return *m.id, true
  17863. }
  17864. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17865. // That means, if the mutation is applied within a transaction with an isolation level such
  17866. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17867. // or updated by the mutation.
  17868. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  17869. switch {
  17870. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17871. id, exists := m.ID()
  17872. if exists {
  17873. return []uint64{id}, nil
  17874. }
  17875. fallthrough
  17876. case m.op.Is(OpUpdate | OpDelete):
  17877. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  17878. default:
  17879. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17880. }
  17881. }
  17882. // SetCreatedAt sets the "created_at" field.
  17883. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  17884. m.created_at = &t
  17885. }
  17886. // CreatedAt returns the value of the "created_at" field in the mutation.
  17887. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  17888. v := m.created_at
  17889. if v == nil {
  17890. return
  17891. }
  17892. return *v, true
  17893. }
  17894. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  17895. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17897. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17898. if !m.op.Is(OpUpdateOne) {
  17899. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17900. }
  17901. if m.id == nil || m.oldValue == nil {
  17902. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17903. }
  17904. oldValue, err := m.oldValue(ctx)
  17905. if err != nil {
  17906. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17907. }
  17908. return oldValue.CreatedAt, nil
  17909. }
  17910. // ResetCreatedAt resets all changes to the "created_at" field.
  17911. func (m *MessageRecordsMutation) ResetCreatedAt() {
  17912. m.created_at = nil
  17913. }
  17914. // SetUpdatedAt sets the "updated_at" field.
  17915. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  17916. m.updated_at = &t
  17917. }
  17918. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17919. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  17920. v := m.updated_at
  17921. if v == nil {
  17922. return
  17923. }
  17924. return *v, true
  17925. }
  17926. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  17927. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17929. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17930. if !m.op.Is(OpUpdateOne) {
  17931. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17932. }
  17933. if m.id == nil || m.oldValue == nil {
  17934. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17935. }
  17936. oldValue, err := m.oldValue(ctx)
  17937. if err != nil {
  17938. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17939. }
  17940. return oldValue.UpdatedAt, nil
  17941. }
  17942. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17943. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  17944. m.updated_at = nil
  17945. }
  17946. // SetStatus sets the "status" field.
  17947. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  17948. m.status = &u
  17949. m.addstatus = nil
  17950. }
  17951. // Status returns the value of the "status" field in the mutation.
  17952. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  17953. v := m.status
  17954. if v == nil {
  17955. return
  17956. }
  17957. return *v, true
  17958. }
  17959. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  17960. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17962. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17963. if !m.op.Is(OpUpdateOne) {
  17964. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17965. }
  17966. if m.id == nil || m.oldValue == nil {
  17967. return v, errors.New("OldStatus requires an ID field in the mutation")
  17968. }
  17969. oldValue, err := m.oldValue(ctx)
  17970. if err != nil {
  17971. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17972. }
  17973. return oldValue.Status, nil
  17974. }
  17975. // AddStatus adds u to the "status" field.
  17976. func (m *MessageRecordsMutation) AddStatus(u int8) {
  17977. if m.addstatus != nil {
  17978. *m.addstatus += u
  17979. } else {
  17980. m.addstatus = &u
  17981. }
  17982. }
  17983. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17984. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  17985. v := m.addstatus
  17986. if v == nil {
  17987. return
  17988. }
  17989. return *v, true
  17990. }
  17991. // ClearStatus clears the value of the "status" field.
  17992. func (m *MessageRecordsMutation) ClearStatus() {
  17993. m.status = nil
  17994. m.addstatus = nil
  17995. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  17996. }
  17997. // StatusCleared returns if the "status" field was cleared in this mutation.
  17998. func (m *MessageRecordsMutation) StatusCleared() bool {
  17999. _, ok := m.clearedFields[messagerecords.FieldStatus]
  18000. return ok
  18001. }
  18002. // ResetStatus resets all changes to the "status" field.
  18003. func (m *MessageRecordsMutation) ResetStatus() {
  18004. m.status = nil
  18005. m.addstatus = nil
  18006. delete(m.clearedFields, messagerecords.FieldStatus)
  18007. }
  18008. // SetBotWxid sets the "bot_wxid" field.
  18009. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  18010. m.bot_wxid = &s
  18011. }
  18012. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  18013. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  18014. v := m.bot_wxid
  18015. if v == nil {
  18016. return
  18017. }
  18018. return *v, true
  18019. }
  18020. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  18021. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18023. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  18024. if !m.op.Is(OpUpdateOne) {
  18025. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  18026. }
  18027. if m.id == nil || m.oldValue == nil {
  18028. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  18029. }
  18030. oldValue, err := m.oldValue(ctx)
  18031. if err != nil {
  18032. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  18033. }
  18034. return oldValue.BotWxid, nil
  18035. }
  18036. // ResetBotWxid resets all changes to the "bot_wxid" field.
  18037. func (m *MessageRecordsMutation) ResetBotWxid() {
  18038. m.bot_wxid = nil
  18039. }
  18040. // SetContactID sets the "contact_id" field.
  18041. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  18042. m.message_contact = &u
  18043. }
  18044. // ContactID returns the value of the "contact_id" field in the mutation.
  18045. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  18046. v := m.message_contact
  18047. if v == nil {
  18048. return
  18049. }
  18050. return *v, true
  18051. }
  18052. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  18053. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18055. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  18056. if !m.op.Is(OpUpdateOne) {
  18057. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  18058. }
  18059. if m.id == nil || m.oldValue == nil {
  18060. return v, errors.New("OldContactID requires an ID field in the mutation")
  18061. }
  18062. oldValue, err := m.oldValue(ctx)
  18063. if err != nil {
  18064. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  18065. }
  18066. return oldValue.ContactID, nil
  18067. }
  18068. // ClearContactID clears the value of the "contact_id" field.
  18069. func (m *MessageRecordsMutation) ClearContactID() {
  18070. m.message_contact = nil
  18071. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  18072. }
  18073. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  18074. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  18075. _, ok := m.clearedFields[messagerecords.FieldContactID]
  18076. return ok
  18077. }
  18078. // ResetContactID resets all changes to the "contact_id" field.
  18079. func (m *MessageRecordsMutation) ResetContactID() {
  18080. m.message_contact = nil
  18081. delete(m.clearedFields, messagerecords.FieldContactID)
  18082. }
  18083. // SetContactType sets the "contact_type" field.
  18084. func (m *MessageRecordsMutation) SetContactType(i int) {
  18085. m.contact_type = &i
  18086. m.addcontact_type = nil
  18087. }
  18088. // ContactType returns the value of the "contact_type" field in the mutation.
  18089. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  18090. v := m.contact_type
  18091. if v == nil {
  18092. return
  18093. }
  18094. return *v, true
  18095. }
  18096. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  18097. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18099. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  18100. if !m.op.Is(OpUpdateOne) {
  18101. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  18102. }
  18103. if m.id == nil || m.oldValue == nil {
  18104. return v, errors.New("OldContactType requires an ID field in the mutation")
  18105. }
  18106. oldValue, err := m.oldValue(ctx)
  18107. if err != nil {
  18108. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  18109. }
  18110. return oldValue.ContactType, nil
  18111. }
  18112. // AddContactType adds i to the "contact_type" field.
  18113. func (m *MessageRecordsMutation) AddContactType(i int) {
  18114. if m.addcontact_type != nil {
  18115. *m.addcontact_type += i
  18116. } else {
  18117. m.addcontact_type = &i
  18118. }
  18119. }
  18120. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  18121. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  18122. v := m.addcontact_type
  18123. if v == nil {
  18124. return
  18125. }
  18126. return *v, true
  18127. }
  18128. // ResetContactType resets all changes to the "contact_type" field.
  18129. func (m *MessageRecordsMutation) ResetContactType() {
  18130. m.contact_type = nil
  18131. m.addcontact_type = nil
  18132. }
  18133. // SetContactWxid sets the "contact_wxid" field.
  18134. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  18135. m.contact_wxid = &s
  18136. }
  18137. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  18138. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  18139. v := m.contact_wxid
  18140. if v == nil {
  18141. return
  18142. }
  18143. return *v, true
  18144. }
  18145. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  18146. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18148. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  18149. if !m.op.Is(OpUpdateOne) {
  18150. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  18151. }
  18152. if m.id == nil || m.oldValue == nil {
  18153. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  18154. }
  18155. oldValue, err := m.oldValue(ctx)
  18156. if err != nil {
  18157. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  18158. }
  18159. return oldValue.ContactWxid, nil
  18160. }
  18161. // ResetContactWxid resets all changes to the "contact_wxid" field.
  18162. func (m *MessageRecordsMutation) ResetContactWxid() {
  18163. m.contact_wxid = nil
  18164. }
  18165. // SetContentType sets the "content_type" field.
  18166. func (m *MessageRecordsMutation) SetContentType(i int) {
  18167. m.content_type = &i
  18168. m.addcontent_type = nil
  18169. }
  18170. // ContentType returns the value of the "content_type" field in the mutation.
  18171. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  18172. v := m.content_type
  18173. if v == nil {
  18174. return
  18175. }
  18176. return *v, true
  18177. }
  18178. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  18179. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18181. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  18182. if !m.op.Is(OpUpdateOne) {
  18183. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  18184. }
  18185. if m.id == nil || m.oldValue == nil {
  18186. return v, errors.New("OldContentType requires an ID field in the mutation")
  18187. }
  18188. oldValue, err := m.oldValue(ctx)
  18189. if err != nil {
  18190. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  18191. }
  18192. return oldValue.ContentType, nil
  18193. }
  18194. // AddContentType adds i to the "content_type" field.
  18195. func (m *MessageRecordsMutation) AddContentType(i int) {
  18196. if m.addcontent_type != nil {
  18197. *m.addcontent_type += i
  18198. } else {
  18199. m.addcontent_type = &i
  18200. }
  18201. }
  18202. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  18203. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  18204. v := m.addcontent_type
  18205. if v == nil {
  18206. return
  18207. }
  18208. return *v, true
  18209. }
  18210. // ResetContentType resets all changes to the "content_type" field.
  18211. func (m *MessageRecordsMutation) ResetContentType() {
  18212. m.content_type = nil
  18213. m.addcontent_type = nil
  18214. }
  18215. // SetContent sets the "content" field.
  18216. func (m *MessageRecordsMutation) SetContent(s string) {
  18217. m.content = &s
  18218. }
  18219. // Content returns the value of the "content" field in the mutation.
  18220. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  18221. v := m.content
  18222. if v == nil {
  18223. return
  18224. }
  18225. return *v, true
  18226. }
  18227. // OldContent returns the old "content" field's value of the MessageRecords entity.
  18228. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18230. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  18231. if !m.op.Is(OpUpdateOne) {
  18232. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18233. }
  18234. if m.id == nil || m.oldValue == nil {
  18235. return v, errors.New("OldContent requires an ID field in the mutation")
  18236. }
  18237. oldValue, err := m.oldValue(ctx)
  18238. if err != nil {
  18239. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18240. }
  18241. return oldValue.Content, nil
  18242. }
  18243. // ResetContent resets all changes to the "content" field.
  18244. func (m *MessageRecordsMutation) ResetContent() {
  18245. m.content = nil
  18246. }
  18247. // SetMeta sets the "meta" field.
  18248. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  18249. m.meta = &ct
  18250. }
  18251. // Meta returns the value of the "meta" field in the mutation.
  18252. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  18253. v := m.meta
  18254. if v == nil {
  18255. return
  18256. }
  18257. return *v, true
  18258. }
  18259. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  18260. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18262. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  18263. if !m.op.Is(OpUpdateOne) {
  18264. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  18265. }
  18266. if m.id == nil || m.oldValue == nil {
  18267. return v, errors.New("OldMeta requires an ID field in the mutation")
  18268. }
  18269. oldValue, err := m.oldValue(ctx)
  18270. if err != nil {
  18271. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  18272. }
  18273. return oldValue.Meta, nil
  18274. }
  18275. // ClearMeta clears the value of the "meta" field.
  18276. func (m *MessageRecordsMutation) ClearMeta() {
  18277. m.meta = nil
  18278. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  18279. }
  18280. // MetaCleared returns if the "meta" field was cleared in this mutation.
  18281. func (m *MessageRecordsMutation) MetaCleared() bool {
  18282. _, ok := m.clearedFields[messagerecords.FieldMeta]
  18283. return ok
  18284. }
  18285. // ResetMeta resets all changes to the "meta" field.
  18286. func (m *MessageRecordsMutation) ResetMeta() {
  18287. m.meta = nil
  18288. delete(m.clearedFields, messagerecords.FieldMeta)
  18289. }
  18290. // SetErrorDetail sets the "error_detail" field.
  18291. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  18292. m.error_detail = &s
  18293. }
  18294. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  18295. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  18296. v := m.error_detail
  18297. if v == nil {
  18298. return
  18299. }
  18300. return *v, true
  18301. }
  18302. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  18303. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18305. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  18306. if !m.op.Is(OpUpdateOne) {
  18307. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  18308. }
  18309. if m.id == nil || m.oldValue == nil {
  18310. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  18311. }
  18312. oldValue, err := m.oldValue(ctx)
  18313. if err != nil {
  18314. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  18315. }
  18316. return oldValue.ErrorDetail, nil
  18317. }
  18318. // ResetErrorDetail resets all changes to the "error_detail" field.
  18319. func (m *MessageRecordsMutation) ResetErrorDetail() {
  18320. m.error_detail = nil
  18321. }
  18322. // SetSendTime sets the "send_time" field.
  18323. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  18324. m.send_time = &t
  18325. }
  18326. // SendTime returns the value of the "send_time" field in the mutation.
  18327. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  18328. v := m.send_time
  18329. if v == nil {
  18330. return
  18331. }
  18332. return *v, true
  18333. }
  18334. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  18335. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18337. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  18338. if !m.op.Is(OpUpdateOne) {
  18339. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  18340. }
  18341. if m.id == nil || m.oldValue == nil {
  18342. return v, errors.New("OldSendTime requires an ID field in the mutation")
  18343. }
  18344. oldValue, err := m.oldValue(ctx)
  18345. if err != nil {
  18346. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  18347. }
  18348. return oldValue.SendTime, nil
  18349. }
  18350. // ClearSendTime clears the value of the "send_time" field.
  18351. func (m *MessageRecordsMutation) ClearSendTime() {
  18352. m.send_time = nil
  18353. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  18354. }
  18355. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  18356. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  18357. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  18358. return ok
  18359. }
  18360. // ResetSendTime resets all changes to the "send_time" field.
  18361. func (m *MessageRecordsMutation) ResetSendTime() {
  18362. m.send_time = nil
  18363. delete(m.clearedFields, messagerecords.FieldSendTime)
  18364. }
  18365. // SetSourceType sets the "source_type" field.
  18366. func (m *MessageRecordsMutation) SetSourceType(i int) {
  18367. m.source_type = &i
  18368. m.addsource_type = nil
  18369. }
  18370. // SourceType returns the value of the "source_type" field in the mutation.
  18371. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  18372. v := m.source_type
  18373. if v == nil {
  18374. return
  18375. }
  18376. return *v, true
  18377. }
  18378. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  18379. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18381. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  18382. if !m.op.Is(OpUpdateOne) {
  18383. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  18384. }
  18385. if m.id == nil || m.oldValue == nil {
  18386. return v, errors.New("OldSourceType requires an ID field in the mutation")
  18387. }
  18388. oldValue, err := m.oldValue(ctx)
  18389. if err != nil {
  18390. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  18391. }
  18392. return oldValue.SourceType, nil
  18393. }
  18394. // AddSourceType adds i to the "source_type" field.
  18395. func (m *MessageRecordsMutation) AddSourceType(i int) {
  18396. if m.addsource_type != nil {
  18397. *m.addsource_type += i
  18398. } else {
  18399. m.addsource_type = &i
  18400. }
  18401. }
  18402. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  18403. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  18404. v := m.addsource_type
  18405. if v == nil {
  18406. return
  18407. }
  18408. return *v, true
  18409. }
  18410. // ResetSourceType resets all changes to the "source_type" field.
  18411. func (m *MessageRecordsMutation) ResetSourceType() {
  18412. m.source_type = nil
  18413. m.addsource_type = nil
  18414. }
  18415. // SetSourceID sets the "source_id" field.
  18416. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  18417. m.sop_stage = &u
  18418. }
  18419. // SourceID returns the value of the "source_id" field in the mutation.
  18420. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  18421. v := m.sop_stage
  18422. if v == nil {
  18423. return
  18424. }
  18425. return *v, true
  18426. }
  18427. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  18428. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18430. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  18431. if !m.op.Is(OpUpdateOne) {
  18432. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  18433. }
  18434. if m.id == nil || m.oldValue == nil {
  18435. return v, errors.New("OldSourceID requires an ID field in the mutation")
  18436. }
  18437. oldValue, err := m.oldValue(ctx)
  18438. if err != nil {
  18439. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  18440. }
  18441. return oldValue.SourceID, nil
  18442. }
  18443. // ClearSourceID clears the value of the "source_id" field.
  18444. func (m *MessageRecordsMutation) ClearSourceID() {
  18445. m.sop_stage = nil
  18446. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  18447. }
  18448. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  18449. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  18450. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  18451. return ok
  18452. }
  18453. // ResetSourceID resets all changes to the "source_id" field.
  18454. func (m *MessageRecordsMutation) ResetSourceID() {
  18455. m.sop_stage = nil
  18456. delete(m.clearedFields, messagerecords.FieldSourceID)
  18457. }
  18458. // SetSubSourceID sets the "sub_source_id" field.
  18459. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  18460. m.sop_node = &u
  18461. }
  18462. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  18463. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  18464. v := m.sop_node
  18465. if v == nil {
  18466. return
  18467. }
  18468. return *v, true
  18469. }
  18470. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  18471. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18473. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  18474. if !m.op.Is(OpUpdateOne) {
  18475. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  18476. }
  18477. if m.id == nil || m.oldValue == nil {
  18478. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  18479. }
  18480. oldValue, err := m.oldValue(ctx)
  18481. if err != nil {
  18482. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  18483. }
  18484. return oldValue.SubSourceID, nil
  18485. }
  18486. // ClearSubSourceID clears the value of the "sub_source_id" field.
  18487. func (m *MessageRecordsMutation) ClearSubSourceID() {
  18488. m.sop_node = nil
  18489. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  18490. }
  18491. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  18492. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  18493. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  18494. return ok
  18495. }
  18496. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  18497. func (m *MessageRecordsMutation) ResetSubSourceID() {
  18498. m.sop_node = nil
  18499. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  18500. }
  18501. // SetOrganizationID sets the "organization_id" field.
  18502. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  18503. m.organization_id = &u
  18504. m.addorganization_id = nil
  18505. }
  18506. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18507. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  18508. v := m.organization_id
  18509. if v == nil {
  18510. return
  18511. }
  18512. return *v, true
  18513. }
  18514. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  18515. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18517. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18518. if !m.op.Is(OpUpdateOne) {
  18519. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18520. }
  18521. if m.id == nil || m.oldValue == nil {
  18522. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18523. }
  18524. oldValue, err := m.oldValue(ctx)
  18525. if err != nil {
  18526. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18527. }
  18528. return oldValue.OrganizationID, nil
  18529. }
  18530. // AddOrganizationID adds u to the "organization_id" field.
  18531. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  18532. if m.addorganization_id != nil {
  18533. *m.addorganization_id += u
  18534. } else {
  18535. m.addorganization_id = &u
  18536. }
  18537. }
  18538. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18539. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  18540. v := m.addorganization_id
  18541. if v == nil {
  18542. return
  18543. }
  18544. return *v, true
  18545. }
  18546. // ClearOrganizationID clears the value of the "organization_id" field.
  18547. func (m *MessageRecordsMutation) ClearOrganizationID() {
  18548. m.organization_id = nil
  18549. m.addorganization_id = nil
  18550. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  18551. }
  18552. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18553. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  18554. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  18555. return ok
  18556. }
  18557. // ResetOrganizationID resets all changes to the "organization_id" field.
  18558. func (m *MessageRecordsMutation) ResetOrganizationID() {
  18559. m.organization_id = nil
  18560. m.addorganization_id = nil
  18561. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  18562. }
  18563. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  18564. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  18565. m.sop_stage = &id
  18566. }
  18567. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  18568. func (m *MessageRecordsMutation) ClearSopStage() {
  18569. m.clearedsop_stage = true
  18570. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  18571. }
  18572. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  18573. func (m *MessageRecordsMutation) SopStageCleared() bool {
  18574. return m.SourceIDCleared() || m.clearedsop_stage
  18575. }
  18576. // SopStageID returns the "sop_stage" edge ID in the mutation.
  18577. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  18578. if m.sop_stage != nil {
  18579. return *m.sop_stage, true
  18580. }
  18581. return
  18582. }
  18583. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  18584. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18585. // SopStageID instead. It exists only for internal usage by the builders.
  18586. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  18587. if id := m.sop_stage; id != nil {
  18588. ids = append(ids, *id)
  18589. }
  18590. return
  18591. }
  18592. // ResetSopStage resets all changes to the "sop_stage" edge.
  18593. func (m *MessageRecordsMutation) ResetSopStage() {
  18594. m.sop_stage = nil
  18595. m.clearedsop_stage = false
  18596. }
  18597. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  18598. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  18599. m.sop_node = &id
  18600. }
  18601. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  18602. func (m *MessageRecordsMutation) ClearSopNode() {
  18603. m.clearedsop_node = true
  18604. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  18605. }
  18606. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  18607. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  18608. return m.SubSourceIDCleared() || m.clearedsop_node
  18609. }
  18610. // SopNodeID returns the "sop_node" edge ID in the mutation.
  18611. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  18612. if m.sop_node != nil {
  18613. return *m.sop_node, true
  18614. }
  18615. return
  18616. }
  18617. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  18618. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18619. // SopNodeID instead. It exists only for internal usage by the builders.
  18620. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  18621. if id := m.sop_node; id != nil {
  18622. ids = append(ids, *id)
  18623. }
  18624. return
  18625. }
  18626. // ResetSopNode resets all changes to the "sop_node" edge.
  18627. func (m *MessageRecordsMutation) ResetSopNode() {
  18628. m.sop_node = nil
  18629. m.clearedsop_node = false
  18630. }
  18631. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  18632. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  18633. m.message_contact = &id
  18634. }
  18635. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  18636. func (m *MessageRecordsMutation) ClearMessageContact() {
  18637. m.clearedmessage_contact = true
  18638. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  18639. }
  18640. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  18641. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  18642. return m.ContactIDCleared() || m.clearedmessage_contact
  18643. }
  18644. // MessageContactID returns the "message_contact" edge ID in the mutation.
  18645. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  18646. if m.message_contact != nil {
  18647. return *m.message_contact, true
  18648. }
  18649. return
  18650. }
  18651. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  18652. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18653. // MessageContactID instead. It exists only for internal usage by the builders.
  18654. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  18655. if id := m.message_contact; id != nil {
  18656. ids = append(ids, *id)
  18657. }
  18658. return
  18659. }
  18660. // ResetMessageContact resets all changes to the "message_contact" edge.
  18661. func (m *MessageRecordsMutation) ResetMessageContact() {
  18662. m.message_contact = nil
  18663. m.clearedmessage_contact = false
  18664. }
  18665. // Where appends a list predicates to the MessageRecordsMutation builder.
  18666. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  18667. m.predicates = append(m.predicates, ps...)
  18668. }
  18669. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  18670. // users can use type-assertion to append predicates that do not depend on any generated package.
  18671. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  18672. p := make([]predicate.MessageRecords, len(ps))
  18673. for i := range ps {
  18674. p[i] = ps[i]
  18675. }
  18676. m.Where(p...)
  18677. }
  18678. // Op returns the operation name.
  18679. func (m *MessageRecordsMutation) Op() Op {
  18680. return m.op
  18681. }
  18682. // SetOp allows setting the mutation operation.
  18683. func (m *MessageRecordsMutation) SetOp(op Op) {
  18684. m.op = op
  18685. }
  18686. // Type returns the node type of this mutation (MessageRecords).
  18687. func (m *MessageRecordsMutation) Type() string {
  18688. return m.typ
  18689. }
  18690. // Fields returns all fields that were changed during this mutation. Note that in
  18691. // order to get all numeric fields that were incremented/decremented, call
  18692. // AddedFields().
  18693. func (m *MessageRecordsMutation) Fields() []string {
  18694. fields := make([]string, 0, 16)
  18695. if m.created_at != nil {
  18696. fields = append(fields, messagerecords.FieldCreatedAt)
  18697. }
  18698. if m.updated_at != nil {
  18699. fields = append(fields, messagerecords.FieldUpdatedAt)
  18700. }
  18701. if m.status != nil {
  18702. fields = append(fields, messagerecords.FieldStatus)
  18703. }
  18704. if m.bot_wxid != nil {
  18705. fields = append(fields, messagerecords.FieldBotWxid)
  18706. }
  18707. if m.message_contact != nil {
  18708. fields = append(fields, messagerecords.FieldContactID)
  18709. }
  18710. if m.contact_type != nil {
  18711. fields = append(fields, messagerecords.FieldContactType)
  18712. }
  18713. if m.contact_wxid != nil {
  18714. fields = append(fields, messagerecords.FieldContactWxid)
  18715. }
  18716. if m.content_type != nil {
  18717. fields = append(fields, messagerecords.FieldContentType)
  18718. }
  18719. if m.content != nil {
  18720. fields = append(fields, messagerecords.FieldContent)
  18721. }
  18722. if m.meta != nil {
  18723. fields = append(fields, messagerecords.FieldMeta)
  18724. }
  18725. if m.error_detail != nil {
  18726. fields = append(fields, messagerecords.FieldErrorDetail)
  18727. }
  18728. if m.send_time != nil {
  18729. fields = append(fields, messagerecords.FieldSendTime)
  18730. }
  18731. if m.source_type != nil {
  18732. fields = append(fields, messagerecords.FieldSourceType)
  18733. }
  18734. if m.sop_stage != nil {
  18735. fields = append(fields, messagerecords.FieldSourceID)
  18736. }
  18737. if m.sop_node != nil {
  18738. fields = append(fields, messagerecords.FieldSubSourceID)
  18739. }
  18740. if m.organization_id != nil {
  18741. fields = append(fields, messagerecords.FieldOrganizationID)
  18742. }
  18743. return fields
  18744. }
  18745. // Field returns the value of a field with the given name. The second boolean
  18746. // return value indicates that this field was not set, or was not defined in the
  18747. // schema.
  18748. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  18749. switch name {
  18750. case messagerecords.FieldCreatedAt:
  18751. return m.CreatedAt()
  18752. case messagerecords.FieldUpdatedAt:
  18753. return m.UpdatedAt()
  18754. case messagerecords.FieldStatus:
  18755. return m.Status()
  18756. case messagerecords.FieldBotWxid:
  18757. return m.BotWxid()
  18758. case messagerecords.FieldContactID:
  18759. return m.ContactID()
  18760. case messagerecords.FieldContactType:
  18761. return m.ContactType()
  18762. case messagerecords.FieldContactWxid:
  18763. return m.ContactWxid()
  18764. case messagerecords.FieldContentType:
  18765. return m.ContentType()
  18766. case messagerecords.FieldContent:
  18767. return m.Content()
  18768. case messagerecords.FieldMeta:
  18769. return m.Meta()
  18770. case messagerecords.FieldErrorDetail:
  18771. return m.ErrorDetail()
  18772. case messagerecords.FieldSendTime:
  18773. return m.SendTime()
  18774. case messagerecords.FieldSourceType:
  18775. return m.SourceType()
  18776. case messagerecords.FieldSourceID:
  18777. return m.SourceID()
  18778. case messagerecords.FieldSubSourceID:
  18779. return m.SubSourceID()
  18780. case messagerecords.FieldOrganizationID:
  18781. return m.OrganizationID()
  18782. }
  18783. return nil, false
  18784. }
  18785. // OldField returns the old value of the field from the database. An error is
  18786. // returned if the mutation operation is not UpdateOne, or the query to the
  18787. // database failed.
  18788. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18789. switch name {
  18790. case messagerecords.FieldCreatedAt:
  18791. return m.OldCreatedAt(ctx)
  18792. case messagerecords.FieldUpdatedAt:
  18793. return m.OldUpdatedAt(ctx)
  18794. case messagerecords.FieldStatus:
  18795. return m.OldStatus(ctx)
  18796. case messagerecords.FieldBotWxid:
  18797. return m.OldBotWxid(ctx)
  18798. case messagerecords.FieldContactID:
  18799. return m.OldContactID(ctx)
  18800. case messagerecords.FieldContactType:
  18801. return m.OldContactType(ctx)
  18802. case messagerecords.FieldContactWxid:
  18803. return m.OldContactWxid(ctx)
  18804. case messagerecords.FieldContentType:
  18805. return m.OldContentType(ctx)
  18806. case messagerecords.FieldContent:
  18807. return m.OldContent(ctx)
  18808. case messagerecords.FieldMeta:
  18809. return m.OldMeta(ctx)
  18810. case messagerecords.FieldErrorDetail:
  18811. return m.OldErrorDetail(ctx)
  18812. case messagerecords.FieldSendTime:
  18813. return m.OldSendTime(ctx)
  18814. case messagerecords.FieldSourceType:
  18815. return m.OldSourceType(ctx)
  18816. case messagerecords.FieldSourceID:
  18817. return m.OldSourceID(ctx)
  18818. case messagerecords.FieldSubSourceID:
  18819. return m.OldSubSourceID(ctx)
  18820. case messagerecords.FieldOrganizationID:
  18821. return m.OldOrganizationID(ctx)
  18822. }
  18823. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  18824. }
  18825. // SetField sets the value of a field with the given name. It returns an error if
  18826. // the field is not defined in the schema, or if the type mismatched the field
  18827. // type.
  18828. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  18829. switch name {
  18830. case messagerecords.FieldCreatedAt:
  18831. v, ok := value.(time.Time)
  18832. if !ok {
  18833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18834. }
  18835. m.SetCreatedAt(v)
  18836. return nil
  18837. case messagerecords.FieldUpdatedAt:
  18838. v, ok := value.(time.Time)
  18839. if !ok {
  18840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18841. }
  18842. m.SetUpdatedAt(v)
  18843. return nil
  18844. case messagerecords.FieldStatus:
  18845. v, ok := value.(uint8)
  18846. if !ok {
  18847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18848. }
  18849. m.SetStatus(v)
  18850. return nil
  18851. case messagerecords.FieldBotWxid:
  18852. v, ok := value.(string)
  18853. if !ok {
  18854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18855. }
  18856. m.SetBotWxid(v)
  18857. return nil
  18858. case messagerecords.FieldContactID:
  18859. v, ok := value.(uint64)
  18860. if !ok {
  18861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18862. }
  18863. m.SetContactID(v)
  18864. return nil
  18865. case messagerecords.FieldContactType:
  18866. v, ok := value.(int)
  18867. if !ok {
  18868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18869. }
  18870. m.SetContactType(v)
  18871. return nil
  18872. case messagerecords.FieldContactWxid:
  18873. v, ok := value.(string)
  18874. if !ok {
  18875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18876. }
  18877. m.SetContactWxid(v)
  18878. return nil
  18879. case messagerecords.FieldContentType:
  18880. v, ok := value.(int)
  18881. if !ok {
  18882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18883. }
  18884. m.SetContentType(v)
  18885. return nil
  18886. case messagerecords.FieldContent:
  18887. v, ok := value.(string)
  18888. if !ok {
  18889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18890. }
  18891. m.SetContent(v)
  18892. return nil
  18893. case messagerecords.FieldMeta:
  18894. v, ok := value.(custom_types.Meta)
  18895. if !ok {
  18896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18897. }
  18898. m.SetMeta(v)
  18899. return nil
  18900. case messagerecords.FieldErrorDetail:
  18901. v, ok := value.(string)
  18902. if !ok {
  18903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18904. }
  18905. m.SetErrorDetail(v)
  18906. return nil
  18907. case messagerecords.FieldSendTime:
  18908. v, ok := value.(time.Time)
  18909. if !ok {
  18910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18911. }
  18912. m.SetSendTime(v)
  18913. return nil
  18914. case messagerecords.FieldSourceType:
  18915. v, ok := value.(int)
  18916. if !ok {
  18917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18918. }
  18919. m.SetSourceType(v)
  18920. return nil
  18921. case messagerecords.FieldSourceID:
  18922. v, ok := value.(uint64)
  18923. if !ok {
  18924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18925. }
  18926. m.SetSourceID(v)
  18927. return nil
  18928. case messagerecords.FieldSubSourceID:
  18929. v, ok := value.(uint64)
  18930. if !ok {
  18931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18932. }
  18933. m.SetSubSourceID(v)
  18934. return nil
  18935. case messagerecords.FieldOrganizationID:
  18936. v, ok := value.(uint64)
  18937. if !ok {
  18938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18939. }
  18940. m.SetOrganizationID(v)
  18941. return nil
  18942. }
  18943. return fmt.Errorf("unknown MessageRecords field %s", name)
  18944. }
  18945. // AddedFields returns all numeric fields that were incremented/decremented during
  18946. // this mutation.
  18947. func (m *MessageRecordsMutation) AddedFields() []string {
  18948. var fields []string
  18949. if m.addstatus != nil {
  18950. fields = append(fields, messagerecords.FieldStatus)
  18951. }
  18952. if m.addcontact_type != nil {
  18953. fields = append(fields, messagerecords.FieldContactType)
  18954. }
  18955. if m.addcontent_type != nil {
  18956. fields = append(fields, messagerecords.FieldContentType)
  18957. }
  18958. if m.addsource_type != nil {
  18959. fields = append(fields, messagerecords.FieldSourceType)
  18960. }
  18961. if m.addorganization_id != nil {
  18962. fields = append(fields, messagerecords.FieldOrganizationID)
  18963. }
  18964. return fields
  18965. }
  18966. // AddedField returns the numeric value that was incremented/decremented on a field
  18967. // with the given name. The second boolean return value indicates that this field
  18968. // was not set, or was not defined in the schema.
  18969. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  18970. switch name {
  18971. case messagerecords.FieldStatus:
  18972. return m.AddedStatus()
  18973. case messagerecords.FieldContactType:
  18974. return m.AddedContactType()
  18975. case messagerecords.FieldContentType:
  18976. return m.AddedContentType()
  18977. case messagerecords.FieldSourceType:
  18978. return m.AddedSourceType()
  18979. case messagerecords.FieldOrganizationID:
  18980. return m.AddedOrganizationID()
  18981. }
  18982. return nil, false
  18983. }
  18984. // AddField adds the value to the field with the given name. It returns an error if
  18985. // the field is not defined in the schema, or if the type mismatched the field
  18986. // type.
  18987. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  18988. switch name {
  18989. case messagerecords.FieldStatus:
  18990. v, ok := value.(int8)
  18991. if !ok {
  18992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18993. }
  18994. m.AddStatus(v)
  18995. return nil
  18996. case messagerecords.FieldContactType:
  18997. v, ok := value.(int)
  18998. if !ok {
  18999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19000. }
  19001. m.AddContactType(v)
  19002. return nil
  19003. case messagerecords.FieldContentType:
  19004. v, ok := value.(int)
  19005. if !ok {
  19006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19007. }
  19008. m.AddContentType(v)
  19009. return nil
  19010. case messagerecords.FieldSourceType:
  19011. v, ok := value.(int)
  19012. if !ok {
  19013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19014. }
  19015. m.AddSourceType(v)
  19016. return nil
  19017. case messagerecords.FieldOrganizationID:
  19018. v, ok := value.(int64)
  19019. if !ok {
  19020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19021. }
  19022. m.AddOrganizationID(v)
  19023. return nil
  19024. }
  19025. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  19026. }
  19027. // ClearedFields returns all nullable fields that were cleared during this
  19028. // mutation.
  19029. func (m *MessageRecordsMutation) ClearedFields() []string {
  19030. var fields []string
  19031. if m.FieldCleared(messagerecords.FieldStatus) {
  19032. fields = append(fields, messagerecords.FieldStatus)
  19033. }
  19034. if m.FieldCleared(messagerecords.FieldContactID) {
  19035. fields = append(fields, messagerecords.FieldContactID)
  19036. }
  19037. if m.FieldCleared(messagerecords.FieldMeta) {
  19038. fields = append(fields, messagerecords.FieldMeta)
  19039. }
  19040. if m.FieldCleared(messagerecords.FieldSendTime) {
  19041. fields = append(fields, messagerecords.FieldSendTime)
  19042. }
  19043. if m.FieldCleared(messagerecords.FieldSourceID) {
  19044. fields = append(fields, messagerecords.FieldSourceID)
  19045. }
  19046. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  19047. fields = append(fields, messagerecords.FieldSubSourceID)
  19048. }
  19049. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  19050. fields = append(fields, messagerecords.FieldOrganizationID)
  19051. }
  19052. return fields
  19053. }
  19054. // FieldCleared returns a boolean indicating if a field with the given name was
  19055. // cleared in this mutation.
  19056. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  19057. _, ok := m.clearedFields[name]
  19058. return ok
  19059. }
  19060. // ClearField clears the value of the field with the given name. It returns an
  19061. // error if the field is not defined in the schema.
  19062. func (m *MessageRecordsMutation) ClearField(name string) error {
  19063. switch name {
  19064. case messagerecords.FieldStatus:
  19065. m.ClearStatus()
  19066. return nil
  19067. case messagerecords.FieldContactID:
  19068. m.ClearContactID()
  19069. return nil
  19070. case messagerecords.FieldMeta:
  19071. m.ClearMeta()
  19072. return nil
  19073. case messagerecords.FieldSendTime:
  19074. m.ClearSendTime()
  19075. return nil
  19076. case messagerecords.FieldSourceID:
  19077. m.ClearSourceID()
  19078. return nil
  19079. case messagerecords.FieldSubSourceID:
  19080. m.ClearSubSourceID()
  19081. return nil
  19082. case messagerecords.FieldOrganizationID:
  19083. m.ClearOrganizationID()
  19084. return nil
  19085. }
  19086. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  19087. }
  19088. // ResetField resets all changes in the mutation for the field with the given name.
  19089. // It returns an error if the field is not defined in the schema.
  19090. func (m *MessageRecordsMutation) ResetField(name string) error {
  19091. switch name {
  19092. case messagerecords.FieldCreatedAt:
  19093. m.ResetCreatedAt()
  19094. return nil
  19095. case messagerecords.FieldUpdatedAt:
  19096. m.ResetUpdatedAt()
  19097. return nil
  19098. case messagerecords.FieldStatus:
  19099. m.ResetStatus()
  19100. return nil
  19101. case messagerecords.FieldBotWxid:
  19102. m.ResetBotWxid()
  19103. return nil
  19104. case messagerecords.FieldContactID:
  19105. m.ResetContactID()
  19106. return nil
  19107. case messagerecords.FieldContactType:
  19108. m.ResetContactType()
  19109. return nil
  19110. case messagerecords.FieldContactWxid:
  19111. m.ResetContactWxid()
  19112. return nil
  19113. case messagerecords.FieldContentType:
  19114. m.ResetContentType()
  19115. return nil
  19116. case messagerecords.FieldContent:
  19117. m.ResetContent()
  19118. return nil
  19119. case messagerecords.FieldMeta:
  19120. m.ResetMeta()
  19121. return nil
  19122. case messagerecords.FieldErrorDetail:
  19123. m.ResetErrorDetail()
  19124. return nil
  19125. case messagerecords.FieldSendTime:
  19126. m.ResetSendTime()
  19127. return nil
  19128. case messagerecords.FieldSourceType:
  19129. m.ResetSourceType()
  19130. return nil
  19131. case messagerecords.FieldSourceID:
  19132. m.ResetSourceID()
  19133. return nil
  19134. case messagerecords.FieldSubSourceID:
  19135. m.ResetSubSourceID()
  19136. return nil
  19137. case messagerecords.FieldOrganizationID:
  19138. m.ResetOrganizationID()
  19139. return nil
  19140. }
  19141. return fmt.Errorf("unknown MessageRecords field %s", name)
  19142. }
  19143. // AddedEdges returns all edge names that were set/added in this mutation.
  19144. func (m *MessageRecordsMutation) AddedEdges() []string {
  19145. edges := make([]string, 0, 3)
  19146. if m.sop_stage != nil {
  19147. edges = append(edges, messagerecords.EdgeSopStage)
  19148. }
  19149. if m.sop_node != nil {
  19150. edges = append(edges, messagerecords.EdgeSopNode)
  19151. }
  19152. if m.message_contact != nil {
  19153. edges = append(edges, messagerecords.EdgeMessageContact)
  19154. }
  19155. return edges
  19156. }
  19157. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19158. // name in this mutation.
  19159. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  19160. switch name {
  19161. case messagerecords.EdgeSopStage:
  19162. if id := m.sop_stage; id != nil {
  19163. return []ent.Value{*id}
  19164. }
  19165. case messagerecords.EdgeSopNode:
  19166. if id := m.sop_node; id != nil {
  19167. return []ent.Value{*id}
  19168. }
  19169. case messagerecords.EdgeMessageContact:
  19170. if id := m.message_contact; id != nil {
  19171. return []ent.Value{*id}
  19172. }
  19173. }
  19174. return nil
  19175. }
  19176. // RemovedEdges returns all edge names that were removed in this mutation.
  19177. func (m *MessageRecordsMutation) RemovedEdges() []string {
  19178. edges := make([]string, 0, 3)
  19179. return edges
  19180. }
  19181. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19182. // the given name in this mutation.
  19183. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  19184. return nil
  19185. }
  19186. // ClearedEdges returns all edge names that were cleared in this mutation.
  19187. func (m *MessageRecordsMutation) ClearedEdges() []string {
  19188. edges := make([]string, 0, 3)
  19189. if m.clearedsop_stage {
  19190. edges = append(edges, messagerecords.EdgeSopStage)
  19191. }
  19192. if m.clearedsop_node {
  19193. edges = append(edges, messagerecords.EdgeSopNode)
  19194. }
  19195. if m.clearedmessage_contact {
  19196. edges = append(edges, messagerecords.EdgeMessageContact)
  19197. }
  19198. return edges
  19199. }
  19200. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19201. // was cleared in this mutation.
  19202. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  19203. switch name {
  19204. case messagerecords.EdgeSopStage:
  19205. return m.clearedsop_stage
  19206. case messagerecords.EdgeSopNode:
  19207. return m.clearedsop_node
  19208. case messagerecords.EdgeMessageContact:
  19209. return m.clearedmessage_contact
  19210. }
  19211. return false
  19212. }
  19213. // ClearEdge clears the value of the edge with the given name. It returns an error
  19214. // if that edge is not defined in the schema.
  19215. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  19216. switch name {
  19217. case messagerecords.EdgeSopStage:
  19218. m.ClearSopStage()
  19219. return nil
  19220. case messagerecords.EdgeSopNode:
  19221. m.ClearSopNode()
  19222. return nil
  19223. case messagerecords.EdgeMessageContact:
  19224. m.ClearMessageContact()
  19225. return nil
  19226. }
  19227. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  19228. }
  19229. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19230. // It returns an error if the edge is not defined in the schema.
  19231. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  19232. switch name {
  19233. case messagerecords.EdgeSopStage:
  19234. m.ResetSopStage()
  19235. return nil
  19236. case messagerecords.EdgeSopNode:
  19237. m.ResetSopNode()
  19238. return nil
  19239. case messagerecords.EdgeMessageContact:
  19240. m.ResetMessageContact()
  19241. return nil
  19242. }
  19243. return fmt.Errorf("unknown MessageRecords edge %s", name)
  19244. }
  19245. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  19246. type MsgMutation struct {
  19247. config
  19248. op Op
  19249. typ string
  19250. id *uint64
  19251. created_at *time.Time
  19252. updated_at *time.Time
  19253. deleted_at *time.Time
  19254. status *uint8
  19255. addstatus *int8
  19256. fromwxid *string
  19257. toid *string
  19258. msgtype *int32
  19259. addmsgtype *int32
  19260. msg *string
  19261. batch_no *string
  19262. ctype *uint64
  19263. addctype *int64
  19264. cc *string
  19265. phone *string
  19266. clearedFields map[string]struct{}
  19267. done bool
  19268. oldValue func(context.Context) (*Msg, error)
  19269. predicates []predicate.Msg
  19270. }
  19271. var _ ent.Mutation = (*MsgMutation)(nil)
  19272. // msgOption allows management of the mutation configuration using functional options.
  19273. type msgOption func(*MsgMutation)
  19274. // newMsgMutation creates new mutation for the Msg entity.
  19275. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  19276. m := &MsgMutation{
  19277. config: c,
  19278. op: op,
  19279. typ: TypeMsg,
  19280. clearedFields: make(map[string]struct{}),
  19281. }
  19282. for _, opt := range opts {
  19283. opt(m)
  19284. }
  19285. return m
  19286. }
  19287. // withMsgID sets the ID field of the mutation.
  19288. func withMsgID(id uint64) msgOption {
  19289. return func(m *MsgMutation) {
  19290. var (
  19291. err error
  19292. once sync.Once
  19293. value *Msg
  19294. )
  19295. m.oldValue = func(ctx context.Context) (*Msg, error) {
  19296. once.Do(func() {
  19297. if m.done {
  19298. err = errors.New("querying old values post mutation is not allowed")
  19299. } else {
  19300. value, err = m.Client().Msg.Get(ctx, id)
  19301. }
  19302. })
  19303. return value, err
  19304. }
  19305. m.id = &id
  19306. }
  19307. }
  19308. // withMsg sets the old Msg of the mutation.
  19309. func withMsg(node *Msg) msgOption {
  19310. return func(m *MsgMutation) {
  19311. m.oldValue = func(context.Context) (*Msg, error) {
  19312. return node, nil
  19313. }
  19314. m.id = &node.ID
  19315. }
  19316. }
  19317. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19318. // executed in a transaction (ent.Tx), a transactional client is returned.
  19319. func (m MsgMutation) Client() *Client {
  19320. client := &Client{config: m.config}
  19321. client.init()
  19322. return client
  19323. }
  19324. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19325. // it returns an error otherwise.
  19326. func (m MsgMutation) Tx() (*Tx, error) {
  19327. if _, ok := m.driver.(*txDriver); !ok {
  19328. return nil, errors.New("ent: mutation is not running in a transaction")
  19329. }
  19330. tx := &Tx{config: m.config}
  19331. tx.init()
  19332. return tx, nil
  19333. }
  19334. // SetID sets the value of the id field. Note that this
  19335. // operation is only accepted on creation of Msg entities.
  19336. func (m *MsgMutation) SetID(id uint64) {
  19337. m.id = &id
  19338. }
  19339. // ID returns the ID value in the mutation. Note that the ID is only available
  19340. // if it was provided to the builder or after it was returned from the database.
  19341. func (m *MsgMutation) ID() (id uint64, exists bool) {
  19342. if m.id == nil {
  19343. return
  19344. }
  19345. return *m.id, true
  19346. }
  19347. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19348. // That means, if the mutation is applied within a transaction with an isolation level such
  19349. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19350. // or updated by the mutation.
  19351. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  19352. switch {
  19353. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19354. id, exists := m.ID()
  19355. if exists {
  19356. return []uint64{id}, nil
  19357. }
  19358. fallthrough
  19359. case m.op.Is(OpUpdate | OpDelete):
  19360. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  19361. default:
  19362. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19363. }
  19364. }
  19365. // SetCreatedAt sets the "created_at" field.
  19366. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  19367. m.created_at = &t
  19368. }
  19369. // CreatedAt returns the value of the "created_at" field in the mutation.
  19370. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  19371. v := m.created_at
  19372. if v == nil {
  19373. return
  19374. }
  19375. return *v, true
  19376. }
  19377. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  19378. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19380. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19381. if !m.op.Is(OpUpdateOne) {
  19382. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19383. }
  19384. if m.id == nil || m.oldValue == nil {
  19385. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19386. }
  19387. oldValue, err := m.oldValue(ctx)
  19388. if err != nil {
  19389. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19390. }
  19391. return oldValue.CreatedAt, nil
  19392. }
  19393. // ResetCreatedAt resets all changes to the "created_at" field.
  19394. func (m *MsgMutation) ResetCreatedAt() {
  19395. m.created_at = nil
  19396. }
  19397. // SetUpdatedAt sets the "updated_at" field.
  19398. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  19399. m.updated_at = &t
  19400. }
  19401. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19402. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  19403. v := m.updated_at
  19404. if v == nil {
  19405. return
  19406. }
  19407. return *v, true
  19408. }
  19409. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  19410. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19412. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19413. if !m.op.Is(OpUpdateOne) {
  19414. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19415. }
  19416. if m.id == nil || m.oldValue == nil {
  19417. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19418. }
  19419. oldValue, err := m.oldValue(ctx)
  19420. if err != nil {
  19421. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19422. }
  19423. return oldValue.UpdatedAt, nil
  19424. }
  19425. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19426. func (m *MsgMutation) ResetUpdatedAt() {
  19427. m.updated_at = nil
  19428. }
  19429. // SetDeletedAt sets the "deleted_at" field.
  19430. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  19431. m.deleted_at = &t
  19432. }
  19433. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19434. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  19435. v := m.deleted_at
  19436. if v == nil {
  19437. return
  19438. }
  19439. return *v, true
  19440. }
  19441. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  19442. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19444. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19445. if !m.op.Is(OpUpdateOne) {
  19446. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19447. }
  19448. if m.id == nil || m.oldValue == nil {
  19449. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19450. }
  19451. oldValue, err := m.oldValue(ctx)
  19452. if err != nil {
  19453. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19454. }
  19455. return oldValue.DeletedAt, nil
  19456. }
  19457. // ClearDeletedAt clears the value of the "deleted_at" field.
  19458. func (m *MsgMutation) ClearDeletedAt() {
  19459. m.deleted_at = nil
  19460. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  19461. }
  19462. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19463. func (m *MsgMutation) DeletedAtCleared() bool {
  19464. _, ok := m.clearedFields[msg.FieldDeletedAt]
  19465. return ok
  19466. }
  19467. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19468. func (m *MsgMutation) ResetDeletedAt() {
  19469. m.deleted_at = nil
  19470. delete(m.clearedFields, msg.FieldDeletedAt)
  19471. }
  19472. // SetStatus sets the "status" field.
  19473. func (m *MsgMutation) SetStatus(u uint8) {
  19474. m.status = &u
  19475. m.addstatus = nil
  19476. }
  19477. // Status returns the value of the "status" field in the mutation.
  19478. func (m *MsgMutation) Status() (r uint8, exists bool) {
  19479. v := m.status
  19480. if v == nil {
  19481. return
  19482. }
  19483. return *v, true
  19484. }
  19485. // OldStatus returns the old "status" field's value of the Msg entity.
  19486. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19488. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19489. if !m.op.Is(OpUpdateOne) {
  19490. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19491. }
  19492. if m.id == nil || m.oldValue == nil {
  19493. return v, errors.New("OldStatus requires an ID field in the mutation")
  19494. }
  19495. oldValue, err := m.oldValue(ctx)
  19496. if err != nil {
  19497. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19498. }
  19499. return oldValue.Status, nil
  19500. }
  19501. // AddStatus adds u to the "status" field.
  19502. func (m *MsgMutation) AddStatus(u int8) {
  19503. if m.addstatus != nil {
  19504. *m.addstatus += u
  19505. } else {
  19506. m.addstatus = &u
  19507. }
  19508. }
  19509. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19510. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  19511. v := m.addstatus
  19512. if v == nil {
  19513. return
  19514. }
  19515. return *v, true
  19516. }
  19517. // ClearStatus clears the value of the "status" field.
  19518. func (m *MsgMutation) ClearStatus() {
  19519. m.status = nil
  19520. m.addstatus = nil
  19521. m.clearedFields[msg.FieldStatus] = struct{}{}
  19522. }
  19523. // StatusCleared returns if the "status" field was cleared in this mutation.
  19524. func (m *MsgMutation) StatusCleared() bool {
  19525. _, ok := m.clearedFields[msg.FieldStatus]
  19526. return ok
  19527. }
  19528. // ResetStatus resets all changes to the "status" field.
  19529. func (m *MsgMutation) ResetStatus() {
  19530. m.status = nil
  19531. m.addstatus = nil
  19532. delete(m.clearedFields, msg.FieldStatus)
  19533. }
  19534. // SetFromwxid sets the "fromwxid" field.
  19535. func (m *MsgMutation) SetFromwxid(s string) {
  19536. m.fromwxid = &s
  19537. }
  19538. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  19539. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  19540. v := m.fromwxid
  19541. if v == nil {
  19542. return
  19543. }
  19544. return *v, true
  19545. }
  19546. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  19547. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19549. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  19550. if !m.op.Is(OpUpdateOne) {
  19551. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  19552. }
  19553. if m.id == nil || m.oldValue == nil {
  19554. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  19555. }
  19556. oldValue, err := m.oldValue(ctx)
  19557. if err != nil {
  19558. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  19559. }
  19560. return oldValue.Fromwxid, nil
  19561. }
  19562. // ClearFromwxid clears the value of the "fromwxid" field.
  19563. func (m *MsgMutation) ClearFromwxid() {
  19564. m.fromwxid = nil
  19565. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  19566. }
  19567. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  19568. func (m *MsgMutation) FromwxidCleared() bool {
  19569. _, ok := m.clearedFields[msg.FieldFromwxid]
  19570. return ok
  19571. }
  19572. // ResetFromwxid resets all changes to the "fromwxid" field.
  19573. func (m *MsgMutation) ResetFromwxid() {
  19574. m.fromwxid = nil
  19575. delete(m.clearedFields, msg.FieldFromwxid)
  19576. }
  19577. // SetToid sets the "toid" field.
  19578. func (m *MsgMutation) SetToid(s string) {
  19579. m.toid = &s
  19580. }
  19581. // Toid returns the value of the "toid" field in the mutation.
  19582. func (m *MsgMutation) Toid() (r string, exists bool) {
  19583. v := m.toid
  19584. if v == nil {
  19585. return
  19586. }
  19587. return *v, true
  19588. }
  19589. // OldToid returns the old "toid" field's value of the Msg entity.
  19590. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19592. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  19593. if !m.op.Is(OpUpdateOne) {
  19594. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  19595. }
  19596. if m.id == nil || m.oldValue == nil {
  19597. return v, errors.New("OldToid requires an ID field in the mutation")
  19598. }
  19599. oldValue, err := m.oldValue(ctx)
  19600. if err != nil {
  19601. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  19602. }
  19603. return oldValue.Toid, nil
  19604. }
  19605. // ClearToid clears the value of the "toid" field.
  19606. func (m *MsgMutation) ClearToid() {
  19607. m.toid = nil
  19608. m.clearedFields[msg.FieldToid] = struct{}{}
  19609. }
  19610. // ToidCleared returns if the "toid" field was cleared in this mutation.
  19611. func (m *MsgMutation) ToidCleared() bool {
  19612. _, ok := m.clearedFields[msg.FieldToid]
  19613. return ok
  19614. }
  19615. // ResetToid resets all changes to the "toid" field.
  19616. func (m *MsgMutation) ResetToid() {
  19617. m.toid = nil
  19618. delete(m.clearedFields, msg.FieldToid)
  19619. }
  19620. // SetMsgtype sets the "msgtype" field.
  19621. func (m *MsgMutation) SetMsgtype(i int32) {
  19622. m.msgtype = &i
  19623. m.addmsgtype = nil
  19624. }
  19625. // Msgtype returns the value of the "msgtype" field in the mutation.
  19626. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  19627. v := m.msgtype
  19628. if v == nil {
  19629. return
  19630. }
  19631. return *v, true
  19632. }
  19633. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  19634. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19636. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  19637. if !m.op.Is(OpUpdateOne) {
  19638. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  19639. }
  19640. if m.id == nil || m.oldValue == nil {
  19641. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  19642. }
  19643. oldValue, err := m.oldValue(ctx)
  19644. if err != nil {
  19645. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  19646. }
  19647. return oldValue.Msgtype, nil
  19648. }
  19649. // AddMsgtype adds i to the "msgtype" field.
  19650. func (m *MsgMutation) AddMsgtype(i int32) {
  19651. if m.addmsgtype != nil {
  19652. *m.addmsgtype += i
  19653. } else {
  19654. m.addmsgtype = &i
  19655. }
  19656. }
  19657. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  19658. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  19659. v := m.addmsgtype
  19660. if v == nil {
  19661. return
  19662. }
  19663. return *v, true
  19664. }
  19665. // ClearMsgtype clears the value of the "msgtype" field.
  19666. func (m *MsgMutation) ClearMsgtype() {
  19667. m.msgtype = nil
  19668. m.addmsgtype = nil
  19669. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  19670. }
  19671. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  19672. func (m *MsgMutation) MsgtypeCleared() bool {
  19673. _, ok := m.clearedFields[msg.FieldMsgtype]
  19674. return ok
  19675. }
  19676. // ResetMsgtype resets all changes to the "msgtype" field.
  19677. func (m *MsgMutation) ResetMsgtype() {
  19678. m.msgtype = nil
  19679. m.addmsgtype = nil
  19680. delete(m.clearedFields, msg.FieldMsgtype)
  19681. }
  19682. // SetMsg sets the "msg" field.
  19683. func (m *MsgMutation) SetMsg(s string) {
  19684. m.msg = &s
  19685. }
  19686. // Msg returns the value of the "msg" field in the mutation.
  19687. func (m *MsgMutation) Msg() (r string, exists bool) {
  19688. v := m.msg
  19689. if v == nil {
  19690. return
  19691. }
  19692. return *v, true
  19693. }
  19694. // OldMsg returns the old "msg" field's value of the Msg entity.
  19695. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19697. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  19698. if !m.op.Is(OpUpdateOne) {
  19699. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  19700. }
  19701. if m.id == nil || m.oldValue == nil {
  19702. return v, errors.New("OldMsg requires an ID field in the mutation")
  19703. }
  19704. oldValue, err := m.oldValue(ctx)
  19705. if err != nil {
  19706. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  19707. }
  19708. return oldValue.Msg, nil
  19709. }
  19710. // ClearMsg clears the value of the "msg" field.
  19711. func (m *MsgMutation) ClearMsg() {
  19712. m.msg = nil
  19713. m.clearedFields[msg.FieldMsg] = struct{}{}
  19714. }
  19715. // MsgCleared returns if the "msg" field was cleared in this mutation.
  19716. func (m *MsgMutation) MsgCleared() bool {
  19717. _, ok := m.clearedFields[msg.FieldMsg]
  19718. return ok
  19719. }
  19720. // ResetMsg resets all changes to the "msg" field.
  19721. func (m *MsgMutation) ResetMsg() {
  19722. m.msg = nil
  19723. delete(m.clearedFields, msg.FieldMsg)
  19724. }
  19725. // SetBatchNo sets the "batch_no" field.
  19726. func (m *MsgMutation) SetBatchNo(s string) {
  19727. m.batch_no = &s
  19728. }
  19729. // BatchNo returns the value of the "batch_no" field in the mutation.
  19730. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  19731. v := m.batch_no
  19732. if v == nil {
  19733. return
  19734. }
  19735. return *v, true
  19736. }
  19737. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  19738. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19740. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  19741. if !m.op.Is(OpUpdateOne) {
  19742. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  19743. }
  19744. if m.id == nil || m.oldValue == nil {
  19745. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  19746. }
  19747. oldValue, err := m.oldValue(ctx)
  19748. if err != nil {
  19749. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  19750. }
  19751. return oldValue.BatchNo, nil
  19752. }
  19753. // ClearBatchNo clears the value of the "batch_no" field.
  19754. func (m *MsgMutation) ClearBatchNo() {
  19755. m.batch_no = nil
  19756. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  19757. }
  19758. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  19759. func (m *MsgMutation) BatchNoCleared() bool {
  19760. _, ok := m.clearedFields[msg.FieldBatchNo]
  19761. return ok
  19762. }
  19763. // ResetBatchNo resets all changes to the "batch_no" field.
  19764. func (m *MsgMutation) ResetBatchNo() {
  19765. m.batch_no = nil
  19766. delete(m.clearedFields, msg.FieldBatchNo)
  19767. }
  19768. // SetCtype sets the "ctype" field.
  19769. func (m *MsgMutation) SetCtype(u uint64) {
  19770. m.ctype = &u
  19771. m.addctype = nil
  19772. }
  19773. // Ctype returns the value of the "ctype" field in the mutation.
  19774. func (m *MsgMutation) Ctype() (r uint64, exists bool) {
  19775. v := m.ctype
  19776. if v == nil {
  19777. return
  19778. }
  19779. return *v, true
  19780. }
  19781. // OldCtype returns the old "ctype" field's value of the Msg entity.
  19782. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19784. func (m *MsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  19785. if !m.op.Is(OpUpdateOne) {
  19786. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  19787. }
  19788. if m.id == nil || m.oldValue == nil {
  19789. return v, errors.New("OldCtype requires an ID field in the mutation")
  19790. }
  19791. oldValue, err := m.oldValue(ctx)
  19792. if err != nil {
  19793. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  19794. }
  19795. return oldValue.Ctype, nil
  19796. }
  19797. // AddCtype adds u to the "ctype" field.
  19798. func (m *MsgMutation) AddCtype(u int64) {
  19799. if m.addctype != nil {
  19800. *m.addctype += u
  19801. } else {
  19802. m.addctype = &u
  19803. }
  19804. }
  19805. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  19806. func (m *MsgMutation) AddedCtype() (r int64, exists bool) {
  19807. v := m.addctype
  19808. if v == nil {
  19809. return
  19810. }
  19811. return *v, true
  19812. }
  19813. // ResetCtype resets all changes to the "ctype" field.
  19814. func (m *MsgMutation) ResetCtype() {
  19815. m.ctype = nil
  19816. m.addctype = nil
  19817. }
  19818. // SetCc sets the "cc" field.
  19819. func (m *MsgMutation) SetCc(s string) {
  19820. m.cc = &s
  19821. }
  19822. // Cc returns the value of the "cc" field in the mutation.
  19823. func (m *MsgMutation) Cc() (r string, exists bool) {
  19824. v := m.cc
  19825. if v == nil {
  19826. return
  19827. }
  19828. return *v, true
  19829. }
  19830. // OldCc returns the old "cc" field's value of the Msg entity.
  19831. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19833. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  19834. if !m.op.Is(OpUpdateOne) {
  19835. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  19836. }
  19837. if m.id == nil || m.oldValue == nil {
  19838. return v, errors.New("OldCc requires an ID field in the mutation")
  19839. }
  19840. oldValue, err := m.oldValue(ctx)
  19841. if err != nil {
  19842. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  19843. }
  19844. return oldValue.Cc, nil
  19845. }
  19846. // ResetCc resets all changes to the "cc" field.
  19847. func (m *MsgMutation) ResetCc() {
  19848. m.cc = nil
  19849. }
  19850. // SetPhone sets the "phone" field.
  19851. func (m *MsgMutation) SetPhone(s string) {
  19852. m.phone = &s
  19853. }
  19854. // Phone returns the value of the "phone" field in the mutation.
  19855. func (m *MsgMutation) Phone() (r string, exists bool) {
  19856. v := m.phone
  19857. if v == nil {
  19858. return
  19859. }
  19860. return *v, true
  19861. }
  19862. // OldPhone returns the old "phone" field's value of the Msg entity.
  19863. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19865. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  19866. if !m.op.Is(OpUpdateOne) {
  19867. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  19868. }
  19869. if m.id == nil || m.oldValue == nil {
  19870. return v, errors.New("OldPhone requires an ID field in the mutation")
  19871. }
  19872. oldValue, err := m.oldValue(ctx)
  19873. if err != nil {
  19874. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  19875. }
  19876. return oldValue.Phone, nil
  19877. }
  19878. // ResetPhone resets all changes to the "phone" field.
  19879. func (m *MsgMutation) ResetPhone() {
  19880. m.phone = nil
  19881. }
  19882. // Where appends a list predicates to the MsgMutation builder.
  19883. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  19884. m.predicates = append(m.predicates, ps...)
  19885. }
  19886. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  19887. // users can use type-assertion to append predicates that do not depend on any generated package.
  19888. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  19889. p := make([]predicate.Msg, len(ps))
  19890. for i := range ps {
  19891. p[i] = ps[i]
  19892. }
  19893. m.Where(p...)
  19894. }
  19895. // Op returns the operation name.
  19896. func (m *MsgMutation) Op() Op {
  19897. return m.op
  19898. }
  19899. // SetOp allows setting the mutation operation.
  19900. func (m *MsgMutation) SetOp(op Op) {
  19901. m.op = op
  19902. }
  19903. // Type returns the node type of this mutation (Msg).
  19904. func (m *MsgMutation) Type() string {
  19905. return m.typ
  19906. }
  19907. // Fields returns all fields that were changed during this mutation. Note that in
  19908. // order to get all numeric fields that were incremented/decremented, call
  19909. // AddedFields().
  19910. func (m *MsgMutation) Fields() []string {
  19911. fields := make([]string, 0, 12)
  19912. if m.created_at != nil {
  19913. fields = append(fields, msg.FieldCreatedAt)
  19914. }
  19915. if m.updated_at != nil {
  19916. fields = append(fields, msg.FieldUpdatedAt)
  19917. }
  19918. if m.deleted_at != nil {
  19919. fields = append(fields, msg.FieldDeletedAt)
  19920. }
  19921. if m.status != nil {
  19922. fields = append(fields, msg.FieldStatus)
  19923. }
  19924. if m.fromwxid != nil {
  19925. fields = append(fields, msg.FieldFromwxid)
  19926. }
  19927. if m.toid != nil {
  19928. fields = append(fields, msg.FieldToid)
  19929. }
  19930. if m.msgtype != nil {
  19931. fields = append(fields, msg.FieldMsgtype)
  19932. }
  19933. if m.msg != nil {
  19934. fields = append(fields, msg.FieldMsg)
  19935. }
  19936. if m.batch_no != nil {
  19937. fields = append(fields, msg.FieldBatchNo)
  19938. }
  19939. if m.ctype != nil {
  19940. fields = append(fields, msg.FieldCtype)
  19941. }
  19942. if m.cc != nil {
  19943. fields = append(fields, msg.FieldCc)
  19944. }
  19945. if m.phone != nil {
  19946. fields = append(fields, msg.FieldPhone)
  19947. }
  19948. return fields
  19949. }
  19950. // Field returns the value of a field with the given name. The second boolean
  19951. // return value indicates that this field was not set, or was not defined in the
  19952. // schema.
  19953. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  19954. switch name {
  19955. case msg.FieldCreatedAt:
  19956. return m.CreatedAt()
  19957. case msg.FieldUpdatedAt:
  19958. return m.UpdatedAt()
  19959. case msg.FieldDeletedAt:
  19960. return m.DeletedAt()
  19961. case msg.FieldStatus:
  19962. return m.Status()
  19963. case msg.FieldFromwxid:
  19964. return m.Fromwxid()
  19965. case msg.FieldToid:
  19966. return m.Toid()
  19967. case msg.FieldMsgtype:
  19968. return m.Msgtype()
  19969. case msg.FieldMsg:
  19970. return m.Msg()
  19971. case msg.FieldBatchNo:
  19972. return m.BatchNo()
  19973. case msg.FieldCtype:
  19974. return m.Ctype()
  19975. case msg.FieldCc:
  19976. return m.Cc()
  19977. case msg.FieldPhone:
  19978. return m.Phone()
  19979. }
  19980. return nil, false
  19981. }
  19982. // OldField returns the old value of the field from the database. An error is
  19983. // returned if the mutation operation is not UpdateOne, or the query to the
  19984. // database failed.
  19985. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19986. switch name {
  19987. case msg.FieldCreatedAt:
  19988. return m.OldCreatedAt(ctx)
  19989. case msg.FieldUpdatedAt:
  19990. return m.OldUpdatedAt(ctx)
  19991. case msg.FieldDeletedAt:
  19992. return m.OldDeletedAt(ctx)
  19993. case msg.FieldStatus:
  19994. return m.OldStatus(ctx)
  19995. case msg.FieldFromwxid:
  19996. return m.OldFromwxid(ctx)
  19997. case msg.FieldToid:
  19998. return m.OldToid(ctx)
  19999. case msg.FieldMsgtype:
  20000. return m.OldMsgtype(ctx)
  20001. case msg.FieldMsg:
  20002. return m.OldMsg(ctx)
  20003. case msg.FieldBatchNo:
  20004. return m.OldBatchNo(ctx)
  20005. case msg.FieldCtype:
  20006. return m.OldCtype(ctx)
  20007. case msg.FieldCc:
  20008. return m.OldCc(ctx)
  20009. case msg.FieldPhone:
  20010. return m.OldPhone(ctx)
  20011. }
  20012. return nil, fmt.Errorf("unknown Msg field %s", name)
  20013. }
  20014. // SetField sets the value of a field with the given name. It returns an error if
  20015. // the field is not defined in the schema, or if the type mismatched the field
  20016. // type.
  20017. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  20018. switch name {
  20019. case msg.FieldCreatedAt:
  20020. v, ok := value.(time.Time)
  20021. if !ok {
  20022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20023. }
  20024. m.SetCreatedAt(v)
  20025. return nil
  20026. case msg.FieldUpdatedAt:
  20027. v, ok := value.(time.Time)
  20028. if !ok {
  20029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20030. }
  20031. m.SetUpdatedAt(v)
  20032. return nil
  20033. case msg.FieldDeletedAt:
  20034. v, ok := value.(time.Time)
  20035. if !ok {
  20036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20037. }
  20038. m.SetDeletedAt(v)
  20039. return nil
  20040. case msg.FieldStatus:
  20041. v, ok := value.(uint8)
  20042. if !ok {
  20043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20044. }
  20045. m.SetStatus(v)
  20046. return nil
  20047. case msg.FieldFromwxid:
  20048. v, ok := value.(string)
  20049. if !ok {
  20050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20051. }
  20052. m.SetFromwxid(v)
  20053. return nil
  20054. case msg.FieldToid:
  20055. v, ok := value.(string)
  20056. if !ok {
  20057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20058. }
  20059. m.SetToid(v)
  20060. return nil
  20061. case msg.FieldMsgtype:
  20062. v, ok := value.(int32)
  20063. if !ok {
  20064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20065. }
  20066. m.SetMsgtype(v)
  20067. return nil
  20068. case msg.FieldMsg:
  20069. v, ok := value.(string)
  20070. if !ok {
  20071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20072. }
  20073. m.SetMsg(v)
  20074. return nil
  20075. case msg.FieldBatchNo:
  20076. v, ok := value.(string)
  20077. if !ok {
  20078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20079. }
  20080. m.SetBatchNo(v)
  20081. return nil
  20082. case msg.FieldCtype:
  20083. v, ok := value.(uint64)
  20084. if !ok {
  20085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20086. }
  20087. m.SetCtype(v)
  20088. return nil
  20089. case msg.FieldCc:
  20090. v, ok := value.(string)
  20091. if !ok {
  20092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20093. }
  20094. m.SetCc(v)
  20095. return nil
  20096. case msg.FieldPhone:
  20097. v, ok := value.(string)
  20098. if !ok {
  20099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20100. }
  20101. m.SetPhone(v)
  20102. return nil
  20103. }
  20104. return fmt.Errorf("unknown Msg field %s", name)
  20105. }
  20106. // AddedFields returns all numeric fields that were incremented/decremented during
  20107. // this mutation.
  20108. func (m *MsgMutation) AddedFields() []string {
  20109. var fields []string
  20110. if m.addstatus != nil {
  20111. fields = append(fields, msg.FieldStatus)
  20112. }
  20113. if m.addmsgtype != nil {
  20114. fields = append(fields, msg.FieldMsgtype)
  20115. }
  20116. if m.addctype != nil {
  20117. fields = append(fields, msg.FieldCtype)
  20118. }
  20119. return fields
  20120. }
  20121. // AddedField returns the numeric value that was incremented/decremented on a field
  20122. // with the given name. The second boolean return value indicates that this field
  20123. // was not set, or was not defined in the schema.
  20124. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  20125. switch name {
  20126. case msg.FieldStatus:
  20127. return m.AddedStatus()
  20128. case msg.FieldMsgtype:
  20129. return m.AddedMsgtype()
  20130. case msg.FieldCtype:
  20131. return m.AddedCtype()
  20132. }
  20133. return nil, false
  20134. }
  20135. // AddField adds the value to the field with the given name. It returns an error if
  20136. // the field is not defined in the schema, or if the type mismatched the field
  20137. // type.
  20138. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  20139. switch name {
  20140. case msg.FieldStatus:
  20141. v, ok := value.(int8)
  20142. if !ok {
  20143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20144. }
  20145. m.AddStatus(v)
  20146. return nil
  20147. case msg.FieldMsgtype:
  20148. v, ok := value.(int32)
  20149. if !ok {
  20150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20151. }
  20152. m.AddMsgtype(v)
  20153. return nil
  20154. case msg.FieldCtype:
  20155. v, ok := value.(int64)
  20156. if !ok {
  20157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20158. }
  20159. m.AddCtype(v)
  20160. return nil
  20161. }
  20162. return fmt.Errorf("unknown Msg numeric field %s", name)
  20163. }
  20164. // ClearedFields returns all nullable fields that were cleared during this
  20165. // mutation.
  20166. func (m *MsgMutation) ClearedFields() []string {
  20167. var fields []string
  20168. if m.FieldCleared(msg.FieldDeletedAt) {
  20169. fields = append(fields, msg.FieldDeletedAt)
  20170. }
  20171. if m.FieldCleared(msg.FieldStatus) {
  20172. fields = append(fields, msg.FieldStatus)
  20173. }
  20174. if m.FieldCleared(msg.FieldFromwxid) {
  20175. fields = append(fields, msg.FieldFromwxid)
  20176. }
  20177. if m.FieldCleared(msg.FieldToid) {
  20178. fields = append(fields, msg.FieldToid)
  20179. }
  20180. if m.FieldCleared(msg.FieldMsgtype) {
  20181. fields = append(fields, msg.FieldMsgtype)
  20182. }
  20183. if m.FieldCleared(msg.FieldMsg) {
  20184. fields = append(fields, msg.FieldMsg)
  20185. }
  20186. if m.FieldCleared(msg.FieldBatchNo) {
  20187. fields = append(fields, msg.FieldBatchNo)
  20188. }
  20189. return fields
  20190. }
  20191. // FieldCleared returns a boolean indicating if a field with the given name was
  20192. // cleared in this mutation.
  20193. func (m *MsgMutation) FieldCleared(name string) bool {
  20194. _, ok := m.clearedFields[name]
  20195. return ok
  20196. }
  20197. // ClearField clears the value of the field with the given name. It returns an
  20198. // error if the field is not defined in the schema.
  20199. func (m *MsgMutation) ClearField(name string) error {
  20200. switch name {
  20201. case msg.FieldDeletedAt:
  20202. m.ClearDeletedAt()
  20203. return nil
  20204. case msg.FieldStatus:
  20205. m.ClearStatus()
  20206. return nil
  20207. case msg.FieldFromwxid:
  20208. m.ClearFromwxid()
  20209. return nil
  20210. case msg.FieldToid:
  20211. m.ClearToid()
  20212. return nil
  20213. case msg.FieldMsgtype:
  20214. m.ClearMsgtype()
  20215. return nil
  20216. case msg.FieldMsg:
  20217. m.ClearMsg()
  20218. return nil
  20219. case msg.FieldBatchNo:
  20220. m.ClearBatchNo()
  20221. return nil
  20222. }
  20223. return fmt.Errorf("unknown Msg nullable field %s", name)
  20224. }
  20225. // ResetField resets all changes in the mutation for the field with the given name.
  20226. // It returns an error if the field is not defined in the schema.
  20227. func (m *MsgMutation) ResetField(name string) error {
  20228. switch name {
  20229. case msg.FieldCreatedAt:
  20230. m.ResetCreatedAt()
  20231. return nil
  20232. case msg.FieldUpdatedAt:
  20233. m.ResetUpdatedAt()
  20234. return nil
  20235. case msg.FieldDeletedAt:
  20236. m.ResetDeletedAt()
  20237. return nil
  20238. case msg.FieldStatus:
  20239. m.ResetStatus()
  20240. return nil
  20241. case msg.FieldFromwxid:
  20242. m.ResetFromwxid()
  20243. return nil
  20244. case msg.FieldToid:
  20245. m.ResetToid()
  20246. return nil
  20247. case msg.FieldMsgtype:
  20248. m.ResetMsgtype()
  20249. return nil
  20250. case msg.FieldMsg:
  20251. m.ResetMsg()
  20252. return nil
  20253. case msg.FieldBatchNo:
  20254. m.ResetBatchNo()
  20255. return nil
  20256. case msg.FieldCtype:
  20257. m.ResetCtype()
  20258. return nil
  20259. case msg.FieldCc:
  20260. m.ResetCc()
  20261. return nil
  20262. case msg.FieldPhone:
  20263. m.ResetPhone()
  20264. return nil
  20265. }
  20266. return fmt.Errorf("unknown Msg field %s", name)
  20267. }
  20268. // AddedEdges returns all edge names that were set/added in this mutation.
  20269. func (m *MsgMutation) AddedEdges() []string {
  20270. edges := make([]string, 0, 0)
  20271. return edges
  20272. }
  20273. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20274. // name in this mutation.
  20275. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  20276. return nil
  20277. }
  20278. // RemovedEdges returns all edge names that were removed in this mutation.
  20279. func (m *MsgMutation) RemovedEdges() []string {
  20280. edges := make([]string, 0, 0)
  20281. return edges
  20282. }
  20283. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20284. // the given name in this mutation.
  20285. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  20286. return nil
  20287. }
  20288. // ClearedEdges returns all edge names that were cleared in this mutation.
  20289. func (m *MsgMutation) ClearedEdges() []string {
  20290. edges := make([]string, 0, 0)
  20291. return edges
  20292. }
  20293. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20294. // was cleared in this mutation.
  20295. func (m *MsgMutation) EdgeCleared(name string) bool {
  20296. return false
  20297. }
  20298. // ClearEdge clears the value of the edge with the given name. It returns an error
  20299. // if that edge is not defined in the schema.
  20300. func (m *MsgMutation) ClearEdge(name string) error {
  20301. return fmt.Errorf("unknown Msg unique edge %s", name)
  20302. }
  20303. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20304. // It returns an error if the edge is not defined in the schema.
  20305. func (m *MsgMutation) ResetEdge(name string) error {
  20306. return fmt.Errorf("unknown Msg edge %s", name)
  20307. }
  20308. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  20309. type PayRechargeMutation struct {
  20310. config
  20311. op Op
  20312. typ string
  20313. id *uint64
  20314. created_at *time.Time
  20315. updated_at *time.Time
  20316. deleted_at *time.Time
  20317. user_id *string
  20318. number *float32
  20319. addnumber *float32
  20320. status *int
  20321. addstatus *int
  20322. money *float32
  20323. addmoney *float32
  20324. out_trade_no *string
  20325. organization_id *uint64
  20326. addorganization_id *int64
  20327. clearedFields map[string]struct{}
  20328. done bool
  20329. oldValue func(context.Context) (*PayRecharge, error)
  20330. predicates []predicate.PayRecharge
  20331. }
  20332. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  20333. // payrechargeOption allows management of the mutation configuration using functional options.
  20334. type payrechargeOption func(*PayRechargeMutation)
  20335. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  20336. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  20337. m := &PayRechargeMutation{
  20338. config: c,
  20339. op: op,
  20340. typ: TypePayRecharge,
  20341. clearedFields: make(map[string]struct{}),
  20342. }
  20343. for _, opt := range opts {
  20344. opt(m)
  20345. }
  20346. return m
  20347. }
  20348. // withPayRechargeID sets the ID field of the mutation.
  20349. func withPayRechargeID(id uint64) payrechargeOption {
  20350. return func(m *PayRechargeMutation) {
  20351. var (
  20352. err error
  20353. once sync.Once
  20354. value *PayRecharge
  20355. )
  20356. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  20357. once.Do(func() {
  20358. if m.done {
  20359. err = errors.New("querying old values post mutation is not allowed")
  20360. } else {
  20361. value, err = m.Client().PayRecharge.Get(ctx, id)
  20362. }
  20363. })
  20364. return value, err
  20365. }
  20366. m.id = &id
  20367. }
  20368. }
  20369. // withPayRecharge sets the old PayRecharge of the mutation.
  20370. func withPayRecharge(node *PayRecharge) payrechargeOption {
  20371. return func(m *PayRechargeMutation) {
  20372. m.oldValue = func(context.Context) (*PayRecharge, error) {
  20373. return node, nil
  20374. }
  20375. m.id = &node.ID
  20376. }
  20377. }
  20378. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20379. // executed in a transaction (ent.Tx), a transactional client is returned.
  20380. func (m PayRechargeMutation) Client() *Client {
  20381. client := &Client{config: m.config}
  20382. client.init()
  20383. return client
  20384. }
  20385. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20386. // it returns an error otherwise.
  20387. func (m PayRechargeMutation) Tx() (*Tx, error) {
  20388. if _, ok := m.driver.(*txDriver); !ok {
  20389. return nil, errors.New("ent: mutation is not running in a transaction")
  20390. }
  20391. tx := &Tx{config: m.config}
  20392. tx.init()
  20393. return tx, nil
  20394. }
  20395. // SetID sets the value of the id field. Note that this
  20396. // operation is only accepted on creation of PayRecharge entities.
  20397. func (m *PayRechargeMutation) SetID(id uint64) {
  20398. m.id = &id
  20399. }
  20400. // ID returns the ID value in the mutation. Note that the ID is only available
  20401. // if it was provided to the builder or after it was returned from the database.
  20402. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  20403. if m.id == nil {
  20404. return
  20405. }
  20406. return *m.id, true
  20407. }
  20408. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20409. // That means, if the mutation is applied within a transaction with an isolation level such
  20410. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20411. // or updated by the mutation.
  20412. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20413. switch {
  20414. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20415. id, exists := m.ID()
  20416. if exists {
  20417. return []uint64{id}, nil
  20418. }
  20419. fallthrough
  20420. case m.op.Is(OpUpdate | OpDelete):
  20421. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  20422. default:
  20423. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20424. }
  20425. }
  20426. // SetCreatedAt sets the "created_at" field.
  20427. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  20428. m.created_at = &t
  20429. }
  20430. // CreatedAt returns the value of the "created_at" field in the mutation.
  20431. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  20432. v := m.created_at
  20433. if v == nil {
  20434. return
  20435. }
  20436. return *v, true
  20437. }
  20438. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  20439. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20441. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20442. if !m.op.Is(OpUpdateOne) {
  20443. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20444. }
  20445. if m.id == nil || m.oldValue == nil {
  20446. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20447. }
  20448. oldValue, err := m.oldValue(ctx)
  20449. if err != nil {
  20450. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20451. }
  20452. return oldValue.CreatedAt, nil
  20453. }
  20454. // ResetCreatedAt resets all changes to the "created_at" field.
  20455. func (m *PayRechargeMutation) ResetCreatedAt() {
  20456. m.created_at = nil
  20457. }
  20458. // SetUpdatedAt sets the "updated_at" field.
  20459. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  20460. m.updated_at = &t
  20461. }
  20462. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20463. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  20464. v := m.updated_at
  20465. if v == nil {
  20466. return
  20467. }
  20468. return *v, true
  20469. }
  20470. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  20471. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20473. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20474. if !m.op.Is(OpUpdateOne) {
  20475. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20476. }
  20477. if m.id == nil || m.oldValue == nil {
  20478. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20479. }
  20480. oldValue, err := m.oldValue(ctx)
  20481. if err != nil {
  20482. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20483. }
  20484. return oldValue.UpdatedAt, nil
  20485. }
  20486. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20487. func (m *PayRechargeMutation) ResetUpdatedAt() {
  20488. m.updated_at = nil
  20489. }
  20490. // SetDeletedAt sets the "deleted_at" field.
  20491. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  20492. m.deleted_at = &t
  20493. }
  20494. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20495. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  20496. v := m.deleted_at
  20497. if v == nil {
  20498. return
  20499. }
  20500. return *v, true
  20501. }
  20502. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  20503. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20505. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20506. if !m.op.Is(OpUpdateOne) {
  20507. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20508. }
  20509. if m.id == nil || m.oldValue == nil {
  20510. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20511. }
  20512. oldValue, err := m.oldValue(ctx)
  20513. if err != nil {
  20514. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20515. }
  20516. return oldValue.DeletedAt, nil
  20517. }
  20518. // ClearDeletedAt clears the value of the "deleted_at" field.
  20519. func (m *PayRechargeMutation) ClearDeletedAt() {
  20520. m.deleted_at = nil
  20521. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  20522. }
  20523. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20524. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  20525. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  20526. return ok
  20527. }
  20528. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20529. func (m *PayRechargeMutation) ResetDeletedAt() {
  20530. m.deleted_at = nil
  20531. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  20532. }
  20533. // SetUserID sets the "user_id" field.
  20534. func (m *PayRechargeMutation) SetUserID(s string) {
  20535. m.user_id = &s
  20536. }
  20537. // UserID returns the value of the "user_id" field in the mutation.
  20538. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  20539. v := m.user_id
  20540. if v == nil {
  20541. return
  20542. }
  20543. return *v, true
  20544. }
  20545. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  20546. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20548. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  20549. if !m.op.Is(OpUpdateOne) {
  20550. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  20551. }
  20552. if m.id == nil || m.oldValue == nil {
  20553. return v, errors.New("OldUserID requires an ID field in the mutation")
  20554. }
  20555. oldValue, err := m.oldValue(ctx)
  20556. if err != nil {
  20557. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  20558. }
  20559. return oldValue.UserID, nil
  20560. }
  20561. // ResetUserID resets all changes to the "user_id" field.
  20562. func (m *PayRechargeMutation) ResetUserID() {
  20563. m.user_id = nil
  20564. }
  20565. // SetNumber sets the "number" field.
  20566. func (m *PayRechargeMutation) SetNumber(f float32) {
  20567. m.number = &f
  20568. m.addnumber = nil
  20569. }
  20570. // Number returns the value of the "number" field in the mutation.
  20571. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  20572. v := m.number
  20573. if v == nil {
  20574. return
  20575. }
  20576. return *v, true
  20577. }
  20578. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  20579. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20581. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  20582. if !m.op.Is(OpUpdateOne) {
  20583. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  20584. }
  20585. if m.id == nil || m.oldValue == nil {
  20586. return v, errors.New("OldNumber requires an ID field in the mutation")
  20587. }
  20588. oldValue, err := m.oldValue(ctx)
  20589. if err != nil {
  20590. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  20591. }
  20592. return oldValue.Number, nil
  20593. }
  20594. // AddNumber adds f to the "number" field.
  20595. func (m *PayRechargeMutation) AddNumber(f float32) {
  20596. if m.addnumber != nil {
  20597. *m.addnumber += f
  20598. } else {
  20599. m.addnumber = &f
  20600. }
  20601. }
  20602. // AddedNumber returns the value that was added to the "number" field in this mutation.
  20603. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  20604. v := m.addnumber
  20605. if v == nil {
  20606. return
  20607. }
  20608. return *v, true
  20609. }
  20610. // ResetNumber resets all changes to the "number" field.
  20611. func (m *PayRechargeMutation) ResetNumber() {
  20612. m.number = nil
  20613. m.addnumber = nil
  20614. }
  20615. // SetStatus sets the "status" field.
  20616. func (m *PayRechargeMutation) SetStatus(i int) {
  20617. m.status = &i
  20618. m.addstatus = nil
  20619. }
  20620. // Status returns the value of the "status" field in the mutation.
  20621. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  20622. v := m.status
  20623. if v == nil {
  20624. return
  20625. }
  20626. return *v, true
  20627. }
  20628. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  20629. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20631. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  20632. if !m.op.Is(OpUpdateOne) {
  20633. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20634. }
  20635. if m.id == nil || m.oldValue == nil {
  20636. return v, errors.New("OldStatus requires an ID field in the mutation")
  20637. }
  20638. oldValue, err := m.oldValue(ctx)
  20639. if err != nil {
  20640. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20641. }
  20642. return oldValue.Status, nil
  20643. }
  20644. // AddStatus adds i to the "status" field.
  20645. func (m *PayRechargeMutation) AddStatus(i int) {
  20646. if m.addstatus != nil {
  20647. *m.addstatus += i
  20648. } else {
  20649. m.addstatus = &i
  20650. }
  20651. }
  20652. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20653. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  20654. v := m.addstatus
  20655. if v == nil {
  20656. return
  20657. }
  20658. return *v, true
  20659. }
  20660. // ClearStatus clears the value of the "status" field.
  20661. func (m *PayRechargeMutation) ClearStatus() {
  20662. m.status = nil
  20663. m.addstatus = nil
  20664. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  20665. }
  20666. // StatusCleared returns if the "status" field was cleared in this mutation.
  20667. func (m *PayRechargeMutation) StatusCleared() bool {
  20668. _, ok := m.clearedFields[payrecharge.FieldStatus]
  20669. return ok
  20670. }
  20671. // ResetStatus resets all changes to the "status" field.
  20672. func (m *PayRechargeMutation) ResetStatus() {
  20673. m.status = nil
  20674. m.addstatus = nil
  20675. delete(m.clearedFields, payrecharge.FieldStatus)
  20676. }
  20677. // SetMoney sets the "money" field.
  20678. func (m *PayRechargeMutation) SetMoney(f float32) {
  20679. m.money = &f
  20680. m.addmoney = nil
  20681. }
  20682. // Money returns the value of the "money" field in the mutation.
  20683. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  20684. v := m.money
  20685. if v == nil {
  20686. return
  20687. }
  20688. return *v, true
  20689. }
  20690. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  20691. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20693. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  20694. if !m.op.Is(OpUpdateOne) {
  20695. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  20696. }
  20697. if m.id == nil || m.oldValue == nil {
  20698. return v, errors.New("OldMoney requires an ID field in the mutation")
  20699. }
  20700. oldValue, err := m.oldValue(ctx)
  20701. if err != nil {
  20702. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  20703. }
  20704. return oldValue.Money, nil
  20705. }
  20706. // AddMoney adds f to the "money" field.
  20707. func (m *PayRechargeMutation) AddMoney(f float32) {
  20708. if m.addmoney != nil {
  20709. *m.addmoney += f
  20710. } else {
  20711. m.addmoney = &f
  20712. }
  20713. }
  20714. // AddedMoney returns the value that was added to the "money" field in this mutation.
  20715. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  20716. v := m.addmoney
  20717. if v == nil {
  20718. return
  20719. }
  20720. return *v, true
  20721. }
  20722. // ClearMoney clears the value of the "money" field.
  20723. func (m *PayRechargeMutation) ClearMoney() {
  20724. m.money = nil
  20725. m.addmoney = nil
  20726. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  20727. }
  20728. // MoneyCleared returns if the "money" field was cleared in this mutation.
  20729. func (m *PayRechargeMutation) MoneyCleared() bool {
  20730. _, ok := m.clearedFields[payrecharge.FieldMoney]
  20731. return ok
  20732. }
  20733. // ResetMoney resets all changes to the "money" field.
  20734. func (m *PayRechargeMutation) ResetMoney() {
  20735. m.money = nil
  20736. m.addmoney = nil
  20737. delete(m.clearedFields, payrecharge.FieldMoney)
  20738. }
  20739. // SetOutTradeNo sets the "out_trade_no" field.
  20740. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  20741. m.out_trade_no = &s
  20742. }
  20743. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  20744. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  20745. v := m.out_trade_no
  20746. if v == nil {
  20747. return
  20748. }
  20749. return *v, true
  20750. }
  20751. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  20752. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20754. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  20755. if !m.op.Is(OpUpdateOne) {
  20756. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  20757. }
  20758. if m.id == nil || m.oldValue == nil {
  20759. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  20760. }
  20761. oldValue, err := m.oldValue(ctx)
  20762. if err != nil {
  20763. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  20764. }
  20765. return oldValue.OutTradeNo, nil
  20766. }
  20767. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  20768. func (m *PayRechargeMutation) ClearOutTradeNo() {
  20769. m.out_trade_no = nil
  20770. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  20771. }
  20772. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  20773. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  20774. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  20775. return ok
  20776. }
  20777. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  20778. func (m *PayRechargeMutation) ResetOutTradeNo() {
  20779. m.out_trade_no = nil
  20780. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  20781. }
  20782. // SetOrganizationID sets the "organization_id" field.
  20783. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  20784. m.organization_id = &u
  20785. m.addorganization_id = nil
  20786. }
  20787. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20788. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  20789. v := m.organization_id
  20790. if v == nil {
  20791. return
  20792. }
  20793. return *v, true
  20794. }
  20795. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  20796. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20798. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20799. if !m.op.Is(OpUpdateOne) {
  20800. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20801. }
  20802. if m.id == nil || m.oldValue == nil {
  20803. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20804. }
  20805. oldValue, err := m.oldValue(ctx)
  20806. if err != nil {
  20807. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20808. }
  20809. return oldValue.OrganizationID, nil
  20810. }
  20811. // AddOrganizationID adds u to the "organization_id" field.
  20812. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  20813. if m.addorganization_id != nil {
  20814. *m.addorganization_id += u
  20815. } else {
  20816. m.addorganization_id = &u
  20817. }
  20818. }
  20819. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20820. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  20821. v := m.addorganization_id
  20822. if v == nil {
  20823. return
  20824. }
  20825. return *v, true
  20826. }
  20827. // ResetOrganizationID resets all changes to the "organization_id" field.
  20828. func (m *PayRechargeMutation) ResetOrganizationID() {
  20829. m.organization_id = nil
  20830. m.addorganization_id = nil
  20831. }
  20832. // Where appends a list predicates to the PayRechargeMutation builder.
  20833. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  20834. m.predicates = append(m.predicates, ps...)
  20835. }
  20836. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  20837. // users can use type-assertion to append predicates that do not depend on any generated package.
  20838. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  20839. p := make([]predicate.PayRecharge, len(ps))
  20840. for i := range ps {
  20841. p[i] = ps[i]
  20842. }
  20843. m.Where(p...)
  20844. }
  20845. // Op returns the operation name.
  20846. func (m *PayRechargeMutation) Op() Op {
  20847. return m.op
  20848. }
  20849. // SetOp allows setting the mutation operation.
  20850. func (m *PayRechargeMutation) SetOp(op Op) {
  20851. m.op = op
  20852. }
  20853. // Type returns the node type of this mutation (PayRecharge).
  20854. func (m *PayRechargeMutation) Type() string {
  20855. return m.typ
  20856. }
  20857. // Fields returns all fields that were changed during this mutation. Note that in
  20858. // order to get all numeric fields that were incremented/decremented, call
  20859. // AddedFields().
  20860. func (m *PayRechargeMutation) Fields() []string {
  20861. fields := make([]string, 0, 9)
  20862. if m.created_at != nil {
  20863. fields = append(fields, payrecharge.FieldCreatedAt)
  20864. }
  20865. if m.updated_at != nil {
  20866. fields = append(fields, payrecharge.FieldUpdatedAt)
  20867. }
  20868. if m.deleted_at != nil {
  20869. fields = append(fields, payrecharge.FieldDeletedAt)
  20870. }
  20871. if m.user_id != nil {
  20872. fields = append(fields, payrecharge.FieldUserID)
  20873. }
  20874. if m.number != nil {
  20875. fields = append(fields, payrecharge.FieldNumber)
  20876. }
  20877. if m.status != nil {
  20878. fields = append(fields, payrecharge.FieldStatus)
  20879. }
  20880. if m.money != nil {
  20881. fields = append(fields, payrecharge.FieldMoney)
  20882. }
  20883. if m.out_trade_no != nil {
  20884. fields = append(fields, payrecharge.FieldOutTradeNo)
  20885. }
  20886. if m.organization_id != nil {
  20887. fields = append(fields, payrecharge.FieldOrganizationID)
  20888. }
  20889. return fields
  20890. }
  20891. // Field returns the value of a field with the given name. The second boolean
  20892. // return value indicates that this field was not set, or was not defined in the
  20893. // schema.
  20894. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  20895. switch name {
  20896. case payrecharge.FieldCreatedAt:
  20897. return m.CreatedAt()
  20898. case payrecharge.FieldUpdatedAt:
  20899. return m.UpdatedAt()
  20900. case payrecharge.FieldDeletedAt:
  20901. return m.DeletedAt()
  20902. case payrecharge.FieldUserID:
  20903. return m.UserID()
  20904. case payrecharge.FieldNumber:
  20905. return m.Number()
  20906. case payrecharge.FieldStatus:
  20907. return m.Status()
  20908. case payrecharge.FieldMoney:
  20909. return m.Money()
  20910. case payrecharge.FieldOutTradeNo:
  20911. return m.OutTradeNo()
  20912. case payrecharge.FieldOrganizationID:
  20913. return m.OrganizationID()
  20914. }
  20915. return nil, false
  20916. }
  20917. // OldField returns the old value of the field from the database. An error is
  20918. // returned if the mutation operation is not UpdateOne, or the query to the
  20919. // database failed.
  20920. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20921. switch name {
  20922. case payrecharge.FieldCreatedAt:
  20923. return m.OldCreatedAt(ctx)
  20924. case payrecharge.FieldUpdatedAt:
  20925. return m.OldUpdatedAt(ctx)
  20926. case payrecharge.FieldDeletedAt:
  20927. return m.OldDeletedAt(ctx)
  20928. case payrecharge.FieldUserID:
  20929. return m.OldUserID(ctx)
  20930. case payrecharge.FieldNumber:
  20931. return m.OldNumber(ctx)
  20932. case payrecharge.FieldStatus:
  20933. return m.OldStatus(ctx)
  20934. case payrecharge.FieldMoney:
  20935. return m.OldMoney(ctx)
  20936. case payrecharge.FieldOutTradeNo:
  20937. return m.OldOutTradeNo(ctx)
  20938. case payrecharge.FieldOrganizationID:
  20939. return m.OldOrganizationID(ctx)
  20940. }
  20941. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  20942. }
  20943. // SetField sets the value of a field with the given name. It returns an error if
  20944. // the field is not defined in the schema, or if the type mismatched the field
  20945. // type.
  20946. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  20947. switch name {
  20948. case payrecharge.FieldCreatedAt:
  20949. v, ok := value.(time.Time)
  20950. if !ok {
  20951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20952. }
  20953. m.SetCreatedAt(v)
  20954. return nil
  20955. case payrecharge.FieldUpdatedAt:
  20956. v, ok := value.(time.Time)
  20957. if !ok {
  20958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20959. }
  20960. m.SetUpdatedAt(v)
  20961. return nil
  20962. case payrecharge.FieldDeletedAt:
  20963. v, ok := value.(time.Time)
  20964. if !ok {
  20965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20966. }
  20967. m.SetDeletedAt(v)
  20968. return nil
  20969. case payrecharge.FieldUserID:
  20970. v, ok := value.(string)
  20971. if !ok {
  20972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20973. }
  20974. m.SetUserID(v)
  20975. return nil
  20976. case payrecharge.FieldNumber:
  20977. v, ok := value.(float32)
  20978. if !ok {
  20979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20980. }
  20981. m.SetNumber(v)
  20982. return nil
  20983. case payrecharge.FieldStatus:
  20984. v, ok := value.(int)
  20985. if !ok {
  20986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20987. }
  20988. m.SetStatus(v)
  20989. return nil
  20990. case payrecharge.FieldMoney:
  20991. v, ok := value.(float32)
  20992. if !ok {
  20993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20994. }
  20995. m.SetMoney(v)
  20996. return nil
  20997. case payrecharge.FieldOutTradeNo:
  20998. v, ok := value.(string)
  20999. if !ok {
  21000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21001. }
  21002. m.SetOutTradeNo(v)
  21003. return nil
  21004. case payrecharge.FieldOrganizationID:
  21005. v, ok := value.(uint64)
  21006. if !ok {
  21007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21008. }
  21009. m.SetOrganizationID(v)
  21010. return nil
  21011. }
  21012. return fmt.Errorf("unknown PayRecharge field %s", name)
  21013. }
  21014. // AddedFields returns all numeric fields that were incremented/decremented during
  21015. // this mutation.
  21016. func (m *PayRechargeMutation) AddedFields() []string {
  21017. var fields []string
  21018. if m.addnumber != nil {
  21019. fields = append(fields, payrecharge.FieldNumber)
  21020. }
  21021. if m.addstatus != nil {
  21022. fields = append(fields, payrecharge.FieldStatus)
  21023. }
  21024. if m.addmoney != nil {
  21025. fields = append(fields, payrecharge.FieldMoney)
  21026. }
  21027. if m.addorganization_id != nil {
  21028. fields = append(fields, payrecharge.FieldOrganizationID)
  21029. }
  21030. return fields
  21031. }
  21032. // AddedField returns the numeric value that was incremented/decremented on a field
  21033. // with the given name. The second boolean return value indicates that this field
  21034. // was not set, or was not defined in the schema.
  21035. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  21036. switch name {
  21037. case payrecharge.FieldNumber:
  21038. return m.AddedNumber()
  21039. case payrecharge.FieldStatus:
  21040. return m.AddedStatus()
  21041. case payrecharge.FieldMoney:
  21042. return m.AddedMoney()
  21043. case payrecharge.FieldOrganizationID:
  21044. return m.AddedOrganizationID()
  21045. }
  21046. return nil, false
  21047. }
  21048. // AddField adds the value to the field with the given name. It returns an error if
  21049. // the field is not defined in the schema, or if the type mismatched the field
  21050. // type.
  21051. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  21052. switch name {
  21053. case payrecharge.FieldNumber:
  21054. v, ok := value.(float32)
  21055. if !ok {
  21056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21057. }
  21058. m.AddNumber(v)
  21059. return nil
  21060. case payrecharge.FieldStatus:
  21061. v, ok := value.(int)
  21062. if !ok {
  21063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21064. }
  21065. m.AddStatus(v)
  21066. return nil
  21067. case payrecharge.FieldMoney:
  21068. v, ok := value.(float32)
  21069. if !ok {
  21070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21071. }
  21072. m.AddMoney(v)
  21073. return nil
  21074. case payrecharge.FieldOrganizationID:
  21075. v, ok := value.(int64)
  21076. if !ok {
  21077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21078. }
  21079. m.AddOrganizationID(v)
  21080. return nil
  21081. }
  21082. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  21083. }
  21084. // ClearedFields returns all nullable fields that were cleared during this
  21085. // mutation.
  21086. func (m *PayRechargeMutation) ClearedFields() []string {
  21087. var fields []string
  21088. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  21089. fields = append(fields, payrecharge.FieldDeletedAt)
  21090. }
  21091. if m.FieldCleared(payrecharge.FieldStatus) {
  21092. fields = append(fields, payrecharge.FieldStatus)
  21093. }
  21094. if m.FieldCleared(payrecharge.FieldMoney) {
  21095. fields = append(fields, payrecharge.FieldMoney)
  21096. }
  21097. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  21098. fields = append(fields, payrecharge.FieldOutTradeNo)
  21099. }
  21100. return fields
  21101. }
  21102. // FieldCleared returns a boolean indicating if a field with the given name was
  21103. // cleared in this mutation.
  21104. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  21105. _, ok := m.clearedFields[name]
  21106. return ok
  21107. }
  21108. // ClearField clears the value of the field with the given name. It returns an
  21109. // error if the field is not defined in the schema.
  21110. func (m *PayRechargeMutation) ClearField(name string) error {
  21111. switch name {
  21112. case payrecharge.FieldDeletedAt:
  21113. m.ClearDeletedAt()
  21114. return nil
  21115. case payrecharge.FieldStatus:
  21116. m.ClearStatus()
  21117. return nil
  21118. case payrecharge.FieldMoney:
  21119. m.ClearMoney()
  21120. return nil
  21121. case payrecharge.FieldOutTradeNo:
  21122. m.ClearOutTradeNo()
  21123. return nil
  21124. }
  21125. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  21126. }
  21127. // ResetField resets all changes in the mutation for the field with the given name.
  21128. // It returns an error if the field is not defined in the schema.
  21129. func (m *PayRechargeMutation) ResetField(name string) error {
  21130. switch name {
  21131. case payrecharge.FieldCreatedAt:
  21132. m.ResetCreatedAt()
  21133. return nil
  21134. case payrecharge.FieldUpdatedAt:
  21135. m.ResetUpdatedAt()
  21136. return nil
  21137. case payrecharge.FieldDeletedAt:
  21138. m.ResetDeletedAt()
  21139. return nil
  21140. case payrecharge.FieldUserID:
  21141. m.ResetUserID()
  21142. return nil
  21143. case payrecharge.FieldNumber:
  21144. m.ResetNumber()
  21145. return nil
  21146. case payrecharge.FieldStatus:
  21147. m.ResetStatus()
  21148. return nil
  21149. case payrecharge.FieldMoney:
  21150. m.ResetMoney()
  21151. return nil
  21152. case payrecharge.FieldOutTradeNo:
  21153. m.ResetOutTradeNo()
  21154. return nil
  21155. case payrecharge.FieldOrganizationID:
  21156. m.ResetOrganizationID()
  21157. return nil
  21158. }
  21159. return fmt.Errorf("unknown PayRecharge field %s", name)
  21160. }
  21161. // AddedEdges returns all edge names that were set/added in this mutation.
  21162. func (m *PayRechargeMutation) AddedEdges() []string {
  21163. edges := make([]string, 0, 0)
  21164. return edges
  21165. }
  21166. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21167. // name in this mutation.
  21168. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  21169. return nil
  21170. }
  21171. // RemovedEdges returns all edge names that were removed in this mutation.
  21172. func (m *PayRechargeMutation) RemovedEdges() []string {
  21173. edges := make([]string, 0, 0)
  21174. return edges
  21175. }
  21176. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21177. // the given name in this mutation.
  21178. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  21179. return nil
  21180. }
  21181. // ClearedEdges returns all edge names that were cleared in this mutation.
  21182. func (m *PayRechargeMutation) ClearedEdges() []string {
  21183. edges := make([]string, 0, 0)
  21184. return edges
  21185. }
  21186. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21187. // was cleared in this mutation.
  21188. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  21189. return false
  21190. }
  21191. // ClearEdge clears the value of the edge with the given name. It returns an error
  21192. // if that edge is not defined in the schema.
  21193. func (m *PayRechargeMutation) ClearEdge(name string) error {
  21194. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  21195. }
  21196. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21197. // It returns an error if the edge is not defined in the schema.
  21198. func (m *PayRechargeMutation) ResetEdge(name string) error {
  21199. return fmt.Errorf("unknown PayRecharge edge %s", name)
  21200. }
  21201. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  21202. type ServerMutation struct {
  21203. config
  21204. op Op
  21205. typ string
  21206. id *uint64
  21207. created_at *time.Time
  21208. updated_at *time.Time
  21209. status *uint8
  21210. addstatus *int8
  21211. deleted_at *time.Time
  21212. name *string
  21213. public_ip *string
  21214. private_ip *string
  21215. admin_port *string
  21216. clearedFields map[string]struct{}
  21217. wxs map[uint64]struct{}
  21218. removedwxs map[uint64]struct{}
  21219. clearedwxs bool
  21220. done bool
  21221. oldValue func(context.Context) (*Server, error)
  21222. predicates []predicate.Server
  21223. }
  21224. var _ ent.Mutation = (*ServerMutation)(nil)
  21225. // serverOption allows management of the mutation configuration using functional options.
  21226. type serverOption func(*ServerMutation)
  21227. // newServerMutation creates new mutation for the Server entity.
  21228. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  21229. m := &ServerMutation{
  21230. config: c,
  21231. op: op,
  21232. typ: TypeServer,
  21233. clearedFields: make(map[string]struct{}),
  21234. }
  21235. for _, opt := range opts {
  21236. opt(m)
  21237. }
  21238. return m
  21239. }
  21240. // withServerID sets the ID field of the mutation.
  21241. func withServerID(id uint64) serverOption {
  21242. return func(m *ServerMutation) {
  21243. var (
  21244. err error
  21245. once sync.Once
  21246. value *Server
  21247. )
  21248. m.oldValue = func(ctx context.Context) (*Server, error) {
  21249. once.Do(func() {
  21250. if m.done {
  21251. err = errors.New("querying old values post mutation is not allowed")
  21252. } else {
  21253. value, err = m.Client().Server.Get(ctx, id)
  21254. }
  21255. })
  21256. return value, err
  21257. }
  21258. m.id = &id
  21259. }
  21260. }
  21261. // withServer sets the old Server of the mutation.
  21262. func withServer(node *Server) serverOption {
  21263. return func(m *ServerMutation) {
  21264. m.oldValue = func(context.Context) (*Server, error) {
  21265. return node, nil
  21266. }
  21267. m.id = &node.ID
  21268. }
  21269. }
  21270. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21271. // executed in a transaction (ent.Tx), a transactional client is returned.
  21272. func (m ServerMutation) Client() *Client {
  21273. client := &Client{config: m.config}
  21274. client.init()
  21275. return client
  21276. }
  21277. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21278. // it returns an error otherwise.
  21279. func (m ServerMutation) Tx() (*Tx, error) {
  21280. if _, ok := m.driver.(*txDriver); !ok {
  21281. return nil, errors.New("ent: mutation is not running in a transaction")
  21282. }
  21283. tx := &Tx{config: m.config}
  21284. tx.init()
  21285. return tx, nil
  21286. }
  21287. // SetID sets the value of the id field. Note that this
  21288. // operation is only accepted on creation of Server entities.
  21289. func (m *ServerMutation) SetID(id uint64) {
  21290. m.id = &id
  21291. }
  21292. // ID returns the ID value in the mutation. Note that the ID is only available
  21293. // if it was provided to the builder or after it was returned from the database.
  21294. func (m *ServerMutation) ID() (id uint64, exists bool) {
  21295. if m.id == nil {
  21296. return
  21297. }
  21298. return *m.id, true
  21299. }
  21300. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21301. // That means, if the mutation is applied within a transaction with an isolation level such
  21302. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21303. // or updated by the mutation.
  21304. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  21305. switch {
  21306. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21307. id, exists := m.ID()
  21308. if exists {
  21309. return []uint64{id}, nil
  21310. }
  21311. fallthrough
  21312. case m.op.Is(OpUpdate | OpDelete):
  21313. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  21314. default:
  21315. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21316. }
  21317. }
  21318. // SetCreatedAt sets the "created_at" field.
  21319. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  21320. m.created_at = &t
  21321. }
  21322. // CreatedAt returns the value of the "created_at" field in the mutation.
  21323. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  21324. v := m.created_at
  21325. if v == nil {
  21326. return
  21327. }
  21328. return *v, true
  21329. }
  21330. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  21331. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21333. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21334. if !m.op.Is(OpUpdateOne) {
  21335. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21336. }
  21337. if m.id == nil || m.oldValue == nil {
  21338. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21339. }
  21340. oldValue, err := m.oldValue(ctx)
  21341. if err != nil {
  21342. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21343. }
  21344. return oldValue.CreatedAt, nil
  21345. }
  21346. // ResetCreatedAt resets all changes to the "created_at" field.
  21347. func (m *ServerMutation) ResetCreatedAt() {
  21348. m.created_at = nil
  21349. }
  21350. // SetUpdatedAt sets the "updated_at" field.
  21351. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  21352. m.updated_at = &t
  21353. }
  21354. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21355. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  21356. v := m.updated_at
  21357. if v == nil {
  21358. return
  21359. }
  21360. return *v, true
  21361. }
  21362. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  21363. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21365. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21366. if !m.op.Is(OpUpdateOne) {
  21367. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21368. }
  21369. if m.id == nil || m.oldValue == nil {
  21370. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21371. }
  21372. oldValue, err := m.oldValue(ctx)
  21373. if err != nil {
  21374. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21375. }
  21376. return oldValue.UpdatedAt, nil
  21377. }
  21378. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21379. func (m *ServerMutation) ResetUpdatedAt() {
  21380. m.updated_at = nil
  21381. }
  21382. // SetStatus sets the "status" field.
  21383. func (m *ServerMutation) SetStatus(u uint8) {
  21384. m.status = &u
  21385. m.addstatus = nil
  21386. }
  21387. // Status returns the value of the "status" field in the mutation.
  21388. func (m *ServerMutation) Status() (r uint8, exists bool) {
  21389. v := m.status
  21390. if v == nil {
  21391. return
  21392. }
  21393. return *v, true
  21394. }
  21395. // OldStatus returns the old "status" field's value of the Server entity.
  21396. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21398. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21399. if !m.op.Is(OpUpdateOne) {
  21400. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21401. }
  21402. if m.id == nil || m.oldValue == nil {
  21403. return v, errors.New("OldStatus requires an ID field in the mutation")
  21404. }
  21405. oldValue, err := m.oldValue(ctx)
  21406. if err != nil {
  21407. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21408. }
  21409. return oldValue.Status, nil
  21410. }
  21411. // AddStatus adds u to the "status" field.
  21412. func (m *ServerMutation) AddStatus(u int8) {
  21413. if m.addstatus != nil {
  21414. *m.addstatus += u
  21415. } else {
  21416. m.addstatus = &u
  21417. }
  21418. }
  21419. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21420. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  21421. v := m.addstatus
  21422. if v == nil {
  21423. return
  21424. }
  21425. return *v, true
  21426. }
  21427. // ClearStatus clears the value of the "status" field.
  21428. func (m *ServerMutation) ClearStatus() {
  21429. m.status = nil
  21430. m.addstatus = nil
  21431. m.clearedFields[server.FieldStatus] = struct{}{}
  21432. }
  21433. // StatusCleared returns if the "status" field was cleared in this mutation.
  21434. func (m *ServerMutation) StatusCleared() bool {
  21435. _, ok := m.clearedFields[server.FieldStatus]
  21436. return ok
  21437. }
  21438. // ResetStatus resets all changes to the "status" field.
  21439. func (m *ServerMutation) ResetStatus() {
  21440. m.status = nil
  21441. m.addstatus = nil
  21442. delete(m.clearedFields, server.FieldStatus)
  21443. }
  21444. // SetDeletedAt sets the "deleted_at" field.
  21445. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  21446. m.deleted_at = &t
  21447. }
  21448. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21449. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  21450. v := m.deleted_at
  21451. if v == nil {
  21452. return
  21453. }
  21454. return *v, true
  21455. }
  21456. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  21457. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21459. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21460. if !m.op.Is(OpUpdateOne) {
  21461. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21462. }
  21463. if m.id == nil || m.oldValue == nil {
  21464. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21465. }
  21466. oldValue, err := m.oldValue(ctx)
  21467. if err != nil {
  21468. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21469. }
  21470. return oldValue.DeletedAt, nil
  21471. }
  21472. // ClearDeletedAt clears the value of the "deleted_at" field.
  21473. func (m *ServerMutation) ClearDeletedAt() {
  21474. m.deleted_at = nil
  21475. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  21476. }
  21477. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21478. func (m *ServerMutation) DeletedAtCleared() bool {
  21479. _, ok := m.clearedFields[server.FieldDeletedAt]
  21480. return ok
  21481. }
  21482. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21483. func (m *ServerMutation) ResetDeletedAt() {
  21484. m.deleted_at = nil
  21485. delete(m.clearedFields, server.FieldDeletedAt)
  21486. }
  21487. // SetName sets the "name" field.
  21488. func (m *ServerMutation) SetName(s string) {
  21489. m.name = &s
  21490. }
  21491. // Name returns the value of the "name" field in the mutation.
  21492. func (m *ServerMutation) Name() (r string, exists bool) {
  21493. v := m.name
  21494. if v == nil {
  21495. return
  21496. }
  21497. return *v, true
  21498. }
  21499. // OldName returns the old "name" field's value of the Server entity.
  21500. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21502. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  21503. if !m.op.Is(OpUpdateOne) {
  21504. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21505. }
  21506. if m.id == nil || m.oldValue == nil {
  21507. return v, errors.New("OldName requires an ID field in the mutation")
  21508. }
  21509. oldValue, err := m.oldValue(ctx)
  21510. if err != nil {
  21511. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21512. }
  21513. return oldValue.Name, nil
  21514. }
  21515. // ResetName resets all changes to the "name" field.
  21516. func (m *ServerMutation) ResetName() {
  21517. m.name = nil
  21518. }
  21519. // SetPublicIP sets the "public_ip" field.
  21520. func (m *ServerMutation) SetPublicIP(s string) {
  21521. m.public_ip = &s
  21522. }
  21523. // PublicIP returns the value of the "public_ip" field in the mutation.
  21524. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  21525. v := m.public_ip
  21526. if v == nil {
  21527. return
  21528. }
  21529. return *v, true
  21530. }
  21531. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  21532. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21534. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  21535. if !m.op.Is(OpUpdateOne) {
  21536. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  21537. }
  21538. if m.id == nil || m.oldValue == nil {
  21539. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  21540. }
  21541. oldValue, err := m.oldValue(ctx)
  21542. if err != nil {
  21543. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  21544. }
  21545. return oldValue.PublicIP, nil
  21546. }
  21547. // ResetPublicIP resets all changes to the "public_ip" field.
  21548. func (m *ServerMutation) ResetPublicIP() {
  21549. m.public_ip = nil
  21550. }
  21551. // SetPrivateIP sets the "private_ip" field.
  21552. func (m *ServerMutation) SetPrivateIP(s string) {
  21553. m.private_ip = &s
  21554. }
  21555. // PrivateIP returns the value of the "private_ip" field in the mutation.
  21556. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  21557. v := m.private_ip
  21558. if v == nil {
  21559. return
  21560. }
  21561. return *v, true
  21562. }
  21563. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  21564. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21566. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  21567. if !m.op.Is(OpUpdateOne) {
  21568. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  21569. }
  21570. if m.id == nil || m.oldValue == nil {
  21571. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  21572. }
  21573. oldValue, err := m.oldValue(ctx)
  21574. if err != nil {
  21575. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  21576. }
  21577. return oldValue.PrivateIP, nil
  21578. }
  21579. // ResetPrivateIP resets all changes to the "private_ip" field.
  21580. func (m *ServerMutation) ResetPrivateIP() {
  21581. m.private_ip = nil
  21582. }
  21583. // SetAdminPort sets the "admin_port" field.
  21584. func (m *ServerMutation) SetAdminPort(s string) {
  21585. m.admin_port = &s
  21586. }
  21587. // AdminPort returns the value of the "admin_port" field in the mutation.
  21588. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  21589. v := m.admin_port
  21590. if v == nil {
  21591. return
  21592. }
  21593. return *v, true
  21594. }
  21595. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  21596. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21598. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  21599. if !m.op.Is(OpUpdateOne) {
  21600. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  21601. }
  21602. if m.id == nil || m.oldValue == nil {
  21603. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  21604. }
  21605. oldValue, err := m.oldValue(ctx)
  21606. if err != nil {
  21607. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  21608. }
  21609. return oldValue.AdminPort, nil
  21610. }
  21611. // ResetAdminPort resets all changes to the "admin_port" field.
  21612. func (m *ServerMutation) ResetAdminPort() {
  21613. m.admin_port = nil
  21614. }
  21615. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  21616. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  21617. if m.wxs == nil {
  21618. m.wxs = make(map[uint64]struct{})
  21619. }
  21620. for i := range ids {
  21621. m.wxs[ids[i]] = struct{}{}
  21622. }
  21623. }
  21624. // ClearWxs clears the "wxs" edge to the Wx entity.
  21625. func (m *ServerMutation) ClearWxs() {
  21626. m.clearedwxs = true
  21627. }
  21628. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  21629. func (m *ServerMutation) WxsCleared() bool {
  21630. return m.clearedwxs
  21631. }
  21632. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  21633. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  21634. if m.removedwxs == nil {
  21635. m.removedwxs = make(map[uint64]struct{})
  21636. }
  21637. for i := range ids {
  21638. delete(m.wxs, ids[i])
  21639. m.removedwxs[ids[i]] = struct{}{}
  21640. }
  21641. }
  21642. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  21643. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  21644. for id := range m.removedwxs {
  21645. ids = append(ids, id)
  21646. }
  21647. return
  21648. }
  21649. // WxsIDs returns the "wxs" edge IDs in the mutation.
  21650. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  21651. for id := range m.wxs {
  21652. ids = append(ids, id)
  21653. }
  21654. return
  21655. }
  21656. // ResetWxs resets all changes to the "wxs" edge.
  21657. func (m *ServerMutation) ResetWxs() {
  21658. m.wxs = nil
  21659. m.clearedwxs = false
  21660. m.removedwxs = nil
  21661. }
  21662. // Where appends a list predicates to the ServerMutation builder.
  21663. func (m *ServerMutation) Where(ps ...predicate.Server) {
  21664. m.predicates = append(m.predicates, ps...)
  21665. }
  21666. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  21667. // users can use type-assertion to append predicates that do not depend on any generated package.
  21668. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  21669. p := make([]predicate.Server, len(ps))
  21670. for i := range ps {
  21671. p[i] = ps[i]
  21672. }
  21673. m.Where(p...)
  21674. }
  21675. // Op returns the operation name.
  21676. func (m *ServerMutation) Op() Op {
  21677. return m.op
  21678. }
  21679. // SetOp allows setting the mutation operation.
  21680. func (m *ServerMutation) SetOp(op Op) {
  21681. m.op = op
  21682. }
  21683. // Type returns the node type of this mutation (Server).
  21684. func (m *ServerMutation) Type() string {
  21685. return m.typ
  21686. }
  21687. // Fields returns all fields that were changed during this mutation. Note that in
  21688. // order to get all numeric fields that were incremented/decremented, call
  21689. // AddedFields().
  21690. func (m *ServerMutation) Fields() []string {
  21691. fields := make([]string, 0, 8)
  21692. if m.created_at != nil {
  21693. fields = append(fields, server.FieldCreatedAt)
  21694. }
  21695. if m.updated_at != nil {
  21696. fields = append(fields, server.FieldUpdatedAt)
  21697. }
  21698. if m.status != nil {
  21699. fields = append(fields, server.FieldStatus)
  21700. }
  21701. if m.deleted_at != nil {
  21702. fields = append(fields, server.FieldDeletedAt)
  21703. }
  21704. if m.name != nil {
  21705. fields = append(fields, server.FieldName)
  21706. }
  21707. if m.public_ip != nil {
  21708. fields = append(fields, server.FieldPublicIP)
  21709. }
  21710. if m.private_ip != nil {
  21711. fields = append(fields, server.FieldPrivateIP)
  21712. }
  21713. if m.admin_port != nil {
  21714. fields = append(fields, server.FieldAdminPort)
  21715. }
  21716. return fields
  21717. }
  21718. // Field returns the value of a field with the given name. The second boolean
  21719. // return value indicates that this field was not set, or was not defined in the
  21720. // schema.
  21721. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  21722. switch name {
  21723. case server.FieldCreatedAt:
  21724. return m.CreatedAt()
  21725. case server.FieldUpdatedAt:
  21726. return m.UpdatedAt()
  21727. case server.FieldStatus:
  21728. return m.Status()
  21729. case server.FieldDeletedAt:
  21730. return m.DeletedAt()
  21731. case server.FieldName:
  21732. return m.Name()
  21733. case server.FieldPublicIP:
  21734. return m.PublicIP()
  21735. case server.FieldPrivateIP:
  21736. return m.PrivateIP()
  21737. case server.FieldAdminPort:
  21738. return m.AdminPort()
  21739. }
  21740. return nil, false
  21741. }
  21742. // OldField returns the old value of the field from the database. An error is
  21743. // returned if the mutation operation is not UpdateOne, or the query to the
  21744. // database failed.
  21745. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21746. switch name {
  21747. case server.FieldCreatedAt:
  21748. return m.OldCreatedAt(ctx)
  21749. case server.FieldUpdatedAt:
  21750. return m.OldUpdatedAt(ctx)
  21751. case server.FieldStatus:
  21752. return m.OldStatus(ctx)
  21753. case server.FieldDeletedAt:
  21754. return m.OldDeletedAt(ctx)
  21755. case server.FieldName:
  21756. return m.OldName(ctx)
  21757. case server.FieldPublicIP:
  21758. return m.OldPublicIP(ctx)
  21759. case server.FieldPrivateIP:
  21760. return m.OldPrivateIP(ctx)
  21761. case server.FieldAdminPort:
  21762. return m.OldAdminPort(ctx)
  21763. }
  21764. return nil, fmt.Errorf("unknown Server field %s", name)
  21765. }
  21766. // SetField sets the value of a field with the given name. It returns an error if
  21767. // the field is not defined in the schema, or if the type mismatched the field
  21768. // type.
  21769. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  21770. switch name {
  21771. case server.FieldCreatedAt:
  21772. v, ok := value.(time.Time)
  21773. if !ok {
  21774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21775. }
  21776. m.SetCreatedAt(v)
  21777. return nil
  21778. case server.FieldUpdatedAt:
  21779. v, ok := value.(time.Time)
  21780. if !ok {
  21781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21782. }
  21783. m.SetUpdatedAt(v)
  21784. return nil
  21785. case server.FieldStatus:
  21786. v, ok := value.(uint8)
  21787. if !ok {
  21788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21789. }
  21790. m.SetStatus(v)
  21791. return nil
  21792. case server.FieldDeletedAt:
  21793. v, ok := value.(time.Time)
  21794. if !ok {
  21795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21796. }
  21797. m.SetDeletedAt(v)
  21798. return nil
  21799. case server.FieldName:
  21800. v, ok := value.(string)
  21801. if !ok {
  21802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21803. }
  21804. m.SetName(v)
  21805. return nil
  21806. case server.FieldPublicIP:
  21807. v, ok := value.(string)
  21808. if !ok {
  21809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21810. }
  21811. m.SetPublicIP(v)
  21812. return nil
  21813. case server.FieldPrivateIP:
  21814. v, ok := value.(string)
  21815. if !ok {
  21816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21817. }
  21818. m.SetPrivateIP(v)
  21819. return nil
  21820. case server.FieldAdminPort:
  21821. v, ok := value.(string)
  21822. if !ok {
  21823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21824. }
  21825. m.SetAdminPort(v)
  21826. return nil
  21827. }
  21828. return fmt.Errorf("unknown Server field %s", name)
  21829. }
  21830. // AddedFields returns all numeric fields that were incremented/decremented during
  21831. // this mutation.
  21832. func (m *ServerMutation) AddedFields() []string {
  21833. var fields []string
  21834. if m.addstatus != nil {
  21835. fields = append(fields, server.FieldStatus)
  21836. }
  21837. return fields
  21838. }
  21839. // AddedField returns the numeric value that was incremented/decremented on a field
  21840. // with the given name. The second boolean return value indicates that this field
  21841. // was not set, or was not defined in the schema.
  21842. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  21843. switch name {
  21844. case server.FieldStatus:
  21845. return m.AddedStatus()
  21846. }
  21847. return nil, false
  21848. }
  21849. // AddField adds the value to the field with the given name. It returns an error if
  21850. // the field is not defined in the schema, or if the type mismatched the field
  21851. // type.
  21852. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  21853. switch name {
  21854. case server.FieldStatus:
  21855. v, ok := value.(int8)
  21856. if !ok {
  21857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21858. }
  21859. m.AddStatus(v)
  21860. return nil
  21861. }
  21862. return fmt.Errorf("unknown Server numeric field %s", name)
  21863. }
  21864. // ClearedFields returns all nullable fields that were cleared during this
  21865. // mutation.
  21866. func (m *ServerMutation) ClearedFields() []string {
  21867. var fields []string
  21868. if m.FieldCleared(server.FieldStatus) {
  21869. fields = append(fields, server.FieldStatus)
  21870. }
  21871. if m.FieldCleared(server.FieldDeletedAt) {
  21872. fields = append(fields, server.FieldDeletedAt)
  21873. }
  21874. return fields
  21875. }
  21876. // FieldCleared returns a boolean indicating if a field with the given name was
  21877. // cleared in this mutation.
  21878. func (m *ServerMutation) FieldCleared(name string) bool {
  21879. _, ok := m.clearedFields[name]
  21880. return ok
  21881. }
  21882. // ClearField clears the value of the field with the given name. It returns an
  21883. // error if the field is not defined in the schema.
  21884. func (m *ServerMutation) ClearField(name string) error {
  21885. switch name {
  21886. case server.FieldStatus:
  21887. m.ClearStatus()
  21888. return nil
  21889. case server.FieldDeletedAt:
  21890. m.ClearDeletedAt()
  21891. return nil
  21892. }
  21893. return fmt.Errorf("unknown Server nullable field %s", name)
  21894. }
  21895. // ResetField resets all changes in the mutation for the field with the given name.
  21896. // It returns an error if the field is not defined in the schema.
  21897. func (m *ServerMutation) ResetField(name string) error {
  21898. switch name {
  21899. case server.FieldCreatedAt:
  21900. m.ResetCreatedAt()
  21901. return nil
  21902. case server.FieldUpdatedAt:
  21903. m.ResetUpdatedAt()
  21904. return nil
  21905. case server.FieldStatus:
  21906. m.ResetStatus()
  21907. return nil
  21908. case server.FieldDeletedAt:
  21909. m.ResetDeletedAt()
  21910. return nil
  21911. case server.FieldName:
  21912. m.ResetName()
  21913. return nil
  21914. case server.FieldPublicIP:
  21915. m.ResetPublicIP()
  21916. return nil
  21917. case server.FieldPrivateIP:
  21918. m.ResetPrivateIP()
  21919. return nil
  21920. case server.FieldAdminPort:
  21921. m.ResetAdminPort()
  21922. return nil
  21923. }
  21924. return fmt.Errorf("unknown Server field %s", name)
  21925. }
  21926. // AddedEdges returns all edge names that were set/added in this mutation.
  21927. func (m *ServerMutation) AddedEdges() []string {
  21928. edges := make([]string, 0, 1)
  21929. if m.wxs != nil {
  21930. edges = append(edges, server.EdgeWxs)
  21931. }
  21932. return edges
  21933. }
  21934. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21935. // name in this mutation.
  21936. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  21937. switch name {
  21938. case server.EdgeWxs:
  21939. ids := make([]ent.Value, 0, len(m.wxs))
  21940. for id := range m.wxs {
  21941. ids = append(ids, id)
  21942. }
  21943. return ids
  21944. }
  21945. return nil
  21946. }
  21947. // RemovedEdges returns all edge names that were removed in this mutation.
  21948. func (m *ServerMutation) RemovedEdges() []string {
  21949. edges := make([]string, 0, 1)
  21950. if m.removedwxs != nil {
  21951. edges = append(edges, server.EdgeWxs)
  21952. }
  21953. return edges
  21954. }
  21955. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21956. // the given name in this mutation.
  21957. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  21958. switch name {
  21959. case server.EdgeWxs:
  21960. ids := make([]ent.Value, 0, len(m.removedwxs))
  21961. for id := range m.removedwxs {
  21962. ids = append(ids, id)
  21963. }
  21964. return ids
  21965. }
  21966. return nil
  21967. }
  21968. // ClearedEdges returns all edge names that were cleared in this mutation.
  21969. func (m *ServerMutation) ClearedEdges() []string {
  21970. edges := make([]string, 0, 1)
  21971. if m.clearedwxs {
  21972. edges = append(edges, server.EdgeWxs)
  21973. }
  21974. return edges
  21975. }
  21976. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21977. // was cleared in this mutation.
  21978. func (m *ServerMutation) EdgeCleared(name string) bool {
  21979. switch name {
  21980. case server.EdgeWxs:
  21981. return m.clearedwxs
  21982. }
  21983. return false
  21984. }
  21985. // ClearEdge clears the value of the edge with the given name. It returns an error
  21986. // if that edge is not defined in the schema.
  21987. func (m *ServerMutation) ClearEdge(name string) error {
  21988. switch name {
  21989. }
  21990. return fmt.Errorf("unknown Server unique edge %s", name)
  21991. }
  21992. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21993. // It returns an error if the edge is not defined in the schema.
  21994. func (m *ServerMutation) ResetEdge(name string) error {
  21995. switch name {
  21996. case server.EdgeWxs:
  21997. m.ResetWxs()
  21998. return nil
  21999. }
  22000. return fmt.Errorf("unknown Server edge %s", name)
  22001. }
  22002. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  22003. type SopNodeMutation struct {
  22004. config
  22005. op Op
  22006. typ string
  22007. id *uint64
  22008. created_at *time.Time
  22009. updated_at *time.Time
  22010. status *uint8
  22011. addstatus *int8
  22012. deleted_at *time.Time
  22013. parent_id *uint64
  22014. addparent_id *int64
  22015. name *string
  22016. condition_type *int
  22017. addcondition_type *int
  22018. condition_list *[]string
  22019. appendcondition_list []string
  22020. no_reply_condition *uint64
  22021. addno_reply_condition *int64
  22022. no_reply_unit *string
  22023. action_message *[]custom_types.Action
  22024. appendaction_message []custom_types.Action
  22025. action_label_add *[]uint64
  22026. appendaction_label_add []uint64
  22027. action_label_del *[]uint64
  22028. appendaction_label_del []uint64
  22029. action_forward **custom_types.ActionForward
  22030. clearedFields map[string]struct{}
  22031. sop_stage *uint64
  22032. clearedsop_stage bool
  22033. node_messages map[uint64]struct{}
  22034. removednode_messages map[uint64]struct{}
  22035. clearednode_messages bool
  22036. done bool
  22037. oldValue func(context.Context) (*SopNode, error)
  22038. predicates []predicate.SopNode
  22039. }
  22040. var _ ent.Mutation = (*SopNodeMutation)(nil)
  22041. // sopnodeOption allows management of the mutation configuration using functional options.
  22042. type sopnodeOption func(*SopNodeMutation)
  22043. // newSopNodeMutation creates new mutation for the SopNode entity.
  22044. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  22045. m := &SopNodeMutation{
  22046. config: c,
  22047. op: op,
  22048. typ: TypeSopNode,
  22049. clearedFields: make(map[string]struct{}),
  22050. }
  22051. for _, opt := range opts {
  22052. opt(m)
  22053. }
  22054. return m
  22055. }
  22056. // withSopNodeID sets the ID field of the mutation.
  22057. func withSopNodeID(id uint64) sopnodeOption {
  22058. return func(m *SopNodeMutation) {
  22059. var (
  22060. err error
  22061. once sync.Once
  22062. value *SopNode
  22063. )
  22064. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  22065. once.Do(func() {
  22066. if m.done {
  22067. err = errors.New("querying old values post mutation is not allowed")
  22068. } else {
  22069. value, err = m.Client().SopNode.Get(ctx, id)
  22070. }
  22071. })
  22072. return value, err
  22073. }
  22074. m.id = &id
  22075. }
  22076. }
  22077. // withSopNode sets the old SopNode of the mutation.
  22078. func withSopNode(node *SopNode) sopnodeOption {
  22079. return func(m *SopNodeMutation) {
  22080. m.oldValue = func(context.Context) (*SopNode, error) {
  22081. return node, nil
  22082. }
  22083. m.id = &node.ID
  22084. }
  22085. }
  22086. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22087. // executed in a transaction (ent.Tx), a transactional client is returned.
  22088. func (m SopNodeMutation) Client() *Client {
  22089. client := &Client{config: m.config}
  22090. client.init()
  22091. return client
  22092. }
  22093. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22094. // it returns an error otherwise.
  22095. func (m SopNodeMutation) Tx() (*Tx, error) {
  22096. if _, ok := m.driver.(*txDriver); !ok {
  22097. return nil, errors.New("ent: mutation is not running in a transaction")
  22098. }
  22099. tx := &Tx{config: m.config}
  22100. tx.init()
  22101. return tx, nil
  22102. }
  22103. // SetID sets the value of the id field. Note that this
  22104. // operation is only accepted on creation of SopNode entities.
  22105. func (m *SopNodeMutation) SetID(id uint64) {
  22106. m.id = &id
  22107. }
  22108. // ID returns the ID value in the mutation. Note that the ID is only available
  22109. // if it was provided to the builder or after it was returned from the database.
  22110. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  22111. if m.id == nil {
  22112. return
  22113. }
  22114. return *m.id, true
  22115. }
  22116. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22117. // That means, if the mutation is applied within a transaction with an isolation level such
  22118. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22119. // or updated by the mutation.
  22120. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  22121. switch {
  22122. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22123. id, exists := m.ID()
  22124. if exists {
  22125. return []uint64{id}, nil
  22126. }
  22127. fallthrough
  22128. case m.op.Is(OpUpdate | OpDelete):
  22129. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  22130. default:
  22131. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22132. }
  22133. }
  22134. // SetCreatedAt sets the "created_at" field.
  22135. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  22136. m.created_at = &t
  22137. }
  22138. // CreatedAt returns the value of the "created_at" field in the mutation.
  22139. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  22140. v := m.created_at
  22141. if v == nil {
  22142. return
  22143. }
  22144. return *v, true
  22145. }
  22146. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  22147. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22149. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22150. if !m.op.Is(OpUpdateOne) {
  22151. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22152. }
  22153. if m.id == nil || m.oldValue == nil {
  22154. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22155. }
  22156. oldValue, err := m.oldValue(ctx)
  22157. if err != nil {
  22158. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22159. }
  22160. return oldValue.CreatedAt, nil
  22161. }
  22162. // ResetCreatedAt resets all changes to the "created_at" field.
  22163. func (m *SopNodeMutation) ResetCreatedAt() {
  22164. m.created_at = nil
  22165. }
  22166. // SetUpdatedAt sets the "updated_at" field.
  22167. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  22168. m.updated_at = &t
  22169. }
  22170. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22171. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  22172. v := m.updated_at
  22173. if v == nil {
  22174. return
  22175. }
  22176. return *v, true
  22177. }
  22178. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  22179. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22181. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22182. if !m.op.Is(OpUpdateOne) {
  22183. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22184. }
  22185. if m.id == nil || m.oldValue == nil {
  22186. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22187. }
  22188. oldValue, err := m.oldValue(ctx)
  22189. if err != nil {
  22190. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22191. }
  22192. return oldValue.UpdatedAt, nil
  22193. }
  22194. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22195. func (m *SopNodeMutation) ResetUpdatedAt() {
  22196. m.updated_at = nil
  22197. }
  22198. // SetStatus sets the "status" field.
  22199. func (m *SopNodeMutation) SetStatus(u uint8) {
  22200. m.status = &u
  22201. m.addstatus = nil
  22202. }
  22203. // Status returns the value of the "status" field in the mutation.
  22204. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  22205. v := m.status
  22206. if v == nil {
  22207. return
  22208. }
  22209. return *v, true
  22210. }
  22211. // OldStatus returns the old "status" field's value of the SopNode entity.
  22212. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22214. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22215. if !m.op.Is(OpUpdateOne) {
  22216. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22217. }
  22218. if m.id == nil || m.oldValue == nil {
  22219. return v, errors.New("OldStatus requires an ID field in the mutation")
  22220. }
  22221. oldValue, err := m.oldValue(ctx)
  22222. if err != nil {
  22223. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22224. }
  22225. return oldValue.Status, nil
  22226. }
  22227. // AddStatus adds u to the "status" field.
  22228. func (m *SopNodeMutation) AddStatus(u int8) {
  22229. if m.addstatus != nil {
  22230. *m.addstatus += u
  22231. } else {
  22232. m.addstatus = &u
  22233. }
  22234. }
  22235. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22236. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  22237. v := m.addstatus
  22238. if v == nil {
  22239. return
  22240. }
  22241. return *v, true
  22242. }
  22243. // ClearStatus clears the value of the "status" field.
  22244. func (m *SopNodeMutation) ClearStatus() {
  22245. m.status = nil
  22246. m.addstatus = nil
  22247. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  22248. }
  22249. // StatusCleared returns if the "status" field was cleared in this mutation.
  22250. func (m *SopNodeMutation) StatusCleared() bool {
  22251. _, ok := m.clearedFields[sopnode.FieldStatus]
  22252. return ok
  22253. }
  22254. // ResetStatus resets all changes to the "status" field.
  22255. func (m *SopNodeMutation) ResetStatus() {
  22256. m.status = nil
  22257. m.addstatus = nil
  22258. delete(m.clearedFields, sopnode.FieldStatus)
  22259. }
  22260. // SetDeletedAt sets the "deleted_at" field.
  22261. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  22262. m.deleted_at = &t
  22263. }
  22264. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22265. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  22266. v := m.deleted_at
  22267. if v == nil {
  22268. return
  22269. }
  22270. return *v, true
  22271. }
  22272. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  22273. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22275. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22276. if !m.op.Is(OpUpdateOne) {
  22277. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22278. }
  22279. if m.id == nil || m.oldValue == nil {
  22280. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22281. }
  22282. oldValue, err := m.oldValue(ctx)
  22283. if err != nil {
  22284. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22285. }
  22286. return oldValue.DeletedAt, nil
  22287. }
  22288. // ClearDeletedAt clears the value of the "deleted_at" field.
  22289. func (m *SopNodeMutation) ClearDeletedAt() {
  22290. m.deleted_at = nil
  22291. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  22292. }
  22293. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22294. func (m *SopNodeMutation) DeletedAtCleared() bool {
  22295. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  22296. return ok
  22297. }
  22298. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22299. func (m *SopNodeMutation) ResetDeletedAt() {
  22300. m.deleted_at = nil
  22301. delete(m.clearedFields, sopnode.FieldDeletedAt)
  22302. }
  22303. // SetStageID sets the "stage_id" field.
  22304. func (m *SopNodeMutation) SetStageID(u uint64) {
  22305. m.sop_stage = &u
  22306. }
  22307. // StageID returns the value of the "stage_id" field in the mutation.
  22308. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  22309. v := m.sop_stage
  22310. if v == nil {
  22311. return
  22312. }
  22313. return *v, true
  22314. }
  22315. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  22316. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22318. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  22319. if !m.op.Is(OpUpdateOne) {
  22320. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  22321. }
  22322. if m.id == nil || m.oldValue == nil {
  22323. return v, errors.New("OldStageID requires an ID field in the mutation")
  22324. }
  22325. oldValue, err := m.oldValue(ctx)
  22326. if err != nil {
  22327. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  22328. }
  22329. return oldValue.StageID, nil
  22330. }
  22331. // ResetStageID resets all changes to the "stage_id" field.
  22332. func (m *SopNodeMutation) ResetStageID() {
  22333. m.sop_stage = nil
  22334. }
  22335. // SetParentID sets the "parent_id" field.
  22336. func (m *SopNodeMutation) SetParentID(u uint64) {
  22337. m.parent_id = &u
  22338. m.addparent_id = nil
  22339. }
  22340. // ParentID returns the value of the "parent_id" field in the mutation.
  22341. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  22342. v := m.parent_id
  22343. if v == nil {
  22344. return
  22345. }
  22346. return *v, true
  22347. }
  22348. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  22349. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22351. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  22352. if !m.op.Is(OpUpdateOne) {
  22353. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  22354. }
  22355. if m.id == nil || m.oldValue == nil {
  22356. return v, errors.New("OldParentID requires an ID field in the mutation")
  22357. }
  22358. oldValue, err := m.oldValue(ctx)
  22359. if err != nil {
  22360. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  22361. }
  22362. return oldValue.ParentID, nil
  22363. }
  22364. // AddParentID adds u to the "parent_id" field.
  22365. func (m *SopNodeMutation) AddParentID(u int64) {
  22366. if m.addparent_id != nil {
  22367. *m.addparent_id += u
  22368. } else {
  22369. m.addparent_id = &u
  22370. }
  22371. }
  22372. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  22373. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  22374. v := m.addparent_id
  22375. if v == nil {
  22376. return
  22377. }
  22378. return *v, true
  22379. }
  22380. // ResetParentID resets all changes to the "parent_id" field.
  22381. func (m *SopNodeMutation) ResetParentID() {
  22382. m.parent_id = nil
  22383. m.addparent_id = nil
  22384. }
  22385. // SetName sets the "name" field.
  22386. func (m *SopNodeMutation) SetName(s string) {
  22387. m.name = &s
  22388. }
  22389. // Name returns the value of the "name" field in the mutation.
  22390. func (m *SopNodeMutation) Name() (r string, exists bool) {
  22391. v := m.name
  22392. if v == nil {
  22393. return
  22394. }
  22395. return *v, true
  22396. }
  22397. // OldName returns the old "name" field's value of the SopNode entity.
  22398. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22400. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  22401. if !m.op.Is(OpUpdateOne) {
  22402. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22403. }
  22404. if m.id == nil || m.oldValue == nil {
  22405. return v, errors.New("OldName requires an ID field in the mutation")
  22406. }
  22407. oldValue, err := m.oldValue(ctx)
  22408. if err != nil {
  22409. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22410. }
  22411. return oldValue.Name, nil
  22412. }
  22413. // ResetName resets all changes to the "name" field.
  22414. func (m *SopNodeMutation) ResetName() {
  22415. m.name = nil
  22416. }
  22417. // SetConditionType sets the "condition_type" field.
  22418. func (m *SopNodeMutation) SetConditionType(i int) {
  22419. m.condition_type = &i
  22420. m.addcondition_type = nil
  22421. }
  22422. // ConditionType returns the value of the "condition_type" field in the mutation.
  22423. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  22424. v := m.condition_type
  22425. if v == nil {
  22426. return
  22427. }
  22428. return *v, true
  22429. }
  22430. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  22431. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22433. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22434. if !m.op.Is(OpUpdateOne) {
  22435. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22436. }
  22437. if m.id == nil || m.oldValue == nil {
  22438. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22439. }
  22440. oldValue, err := m.oldValue(ctx)
  22441. if err != nil {
  22442. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22443. }
  22444. return oldValue.ConditionType, nil
  22445. }
  22446. // AddConditionType adds i to the "condition_type" field.
  22447. func (m *SopNodeMutation) AddConditionType(i int) {
  22448. if m.addcondition_type != nil {
  22449. *m.addcondition_type += i
  22450. } else {
  22451. m.addcondition_type = &i
  22452. }
  22453. }
  22454. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22455. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  22456. v := m.addcondition_type
  22457. if v == nil {
  22458. return
  22459. }
  22460. return *v, true
  22461. }
  22462. // ResetConditionType resets all changes to the "condition_type" field.
  22463. func (m *SopNodeMutation) ResetConditionType() {
  22464. m.condition_type = nil
  22465. m.addcondition_type = nil
  22466. }
  22467. // SetConditionList sets the "condition_list" field.
  22468. func (m *SopNodeMutation) SetConditionList(s []string) {
  22469. m.condition_list = &s
  22470. m.appendcondition_list = nil
  22471. }
  22472. // ConditionList returns the value of the "condition_list" field in the mutation.
  22473. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  22474. v := m.condition_list
  22475. if v == nil {
  22476. return
  22477. }
  22478. return *v, true
  22479. }
  22480. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  22481. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22483. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  22484. if !m.op.Is(OpUpdateOne) {
  22485. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22486. }
  22487. if m.id == nil || m.oldValue == nil {
  22488. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22489. }
  22490. oldValue, err := m.oldValue(ctx)
  22491. if err != nil {
  22492. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22493. }
  22494. return oldValue.ConditionList, nil
  22495. }
  22496. // AppendConditionList adds s to the "condition_list" field.
  22497. func (m *SopNodeMutation) AppendConditionList(s []string) {
  22498. m.appendcondition_list = append(m.appendcondition_list, s...)
  22499. }
  22500. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22501. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  22502. if len(m.appendcondition_list) == 0 {
  22503. return nil, false
  22504. }
  22505. return m.appendcondition_list, true
  22506. }
  22507. // ClearConditionList clears the value of the "condition_list" field.
  22508. func (m *SopNodeMutation) ClearConditionList() {
  22509. m.condition_list = nil
  22510. m.appendcondition_list = nil
  22511. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  22512. }
  22513. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  22514. func (m *SopNodeMutation) ConditionListCleared() bool {
  22515. _, ok := m.clearedFields[sopnode.FieldConditionList]
  22516. return ok
  22517. }
  22518. // ResetConditionList resets all changes to the "condition_list" field.
  22519. func (m *SopNodeMutation) ResetConditionList() {
  22520. m.condition_list = nil
  22521. m.appendcondition_list = nil
  22522. delete(m.clearedFields, sopnode.FieldConditionList)
  22523. }
  22524. // SetNoReplyCondition sets the "no_reply_condition" field.
  22525. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  22526. m.no_reply_condition = &u
  22527. m.addno_reply_condition = nil
  22528. }
  22529. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  22530. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  22531. v := m.no_reply_condition
  22532. if v == nil {
  22533. return
  22534. }
  22535. return *v, true
  22536. }
  22537. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  22538. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22540. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  22541. if !m.op.Is(OpUpdateOne) {
  22542. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  22543. }
  22544. if m.id == nil || m.oldValue == nil {
  22545. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  22546. }
  22547. oldValue, err := m.oldValue(ctx)
  22548. if err != nil {
  22549. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  22550. }
  22551. return oldValue.NoReplyCondition, nil
  22552. }
  22553. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  22554. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  22555. if m.addno_reply_condition != nil {
  22556. *m.addno_reply_condition += u
  22557. } else {
  22558. m.addno_reply_condition = &u
  22559. }
  22560. }
  22561. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  22562. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  22563. v := m.addno_reply_condition
  22564. if v == nil {
  22565. return
  22566. }
  22567. return *v, true
  22568. }
  22569. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  22570. func (m *SopNodeMutation) ResetNoReplyCondition() {
  22571. m.no_reply_condition = nil
  22572. m.addno_reply_condition = nil
  22573. }
  22574. // SetNoReplyUnit sets the "no_reply_unit" field.
  22575. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  22576. m.no_reply_unit = &s
  22577. }
  22578. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  22579. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  22580. v := m.no_reply_unit
  22581. if v == nil {
  22582. return
  22583. }
  22584. return *v, true
  22585. }
  22586. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  22587. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22589. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  22590. if !m.op.Is(OpUpdateOne) {
  22591. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  22592. }
  22593. if m.id == nil || m.oldValue == nil {
  22594. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  22595. }
  22596. oldValue, err := m.oldValue(ctx)
  22597. if err != nil {
  22598. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  22599. }
  22600. return oldValue.NoReplyUnit, nil
  22601. }
  22602. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  22603. func (m *SopNodeMutation) ResetNoReplyUnit() {
  22604. m.no_reply_unit = nil
  22605. }
  22606. // SetActionMessage sets the "action_message" field.
  22607. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  22608. m.action_message = &ct
  22609. m.appendaction_message = nil
  22610. }
  22611. // ActionMessage returns the value of the "action_message" field in the mutation.
  22612. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22613. v := m.action_message
  22614. if v == nil {
  22615. return
  22616. }
  22617. return *v, true
  22618. }
  22619. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  22620. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22622. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22623. if !m.op.Is(OpUpdateOne) {
  22624. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22625. }
  22626. if m.id == nil || m.oldValue == nil {
  22627. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22628. }
  22629. oldValue, err := m.oldValue(ctx)
  22630. if err != nil {
  22631. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22632. }
  22633. return oldValue.ActionMessage, nil
  22634. }
  22635. // AppendActionMessage adds ct to the "action_message" field.
  22636. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  22637. m.appendaction_message = append(m.appendaction_message, ct...)
  22638. }
  22639. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22640. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22641. if len(m.appendaction_message) == 0 {
  22642. return nil, false
  22643. }
  22644. return m.appendaction_message, true
  22645. }
  22646. // ClearActionMessage clears the value of the "action_message" field.
  22647. func (m *SopNodeMutation) ClearActionMessage() {
  22648. m.action_message = nil
  22649. m.appendaction_message = nil
  22650. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  22651. }
  22652. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22653. func (m *SopNodeMutation) ActionMessageCleared() bool {
  22654. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  22655. return ok
  22656. }
  22657. // ResetActionMessage resets all changes to the "action_message" field.
  22658. func (m *SopNodeMutation) ResetActionMessage() {
  22659. m.action_message = nil
  22660. m.appendaction_message = nil
  22661. delete(m.clearedFields, sopnode.FieldActionMessage)
  22662. }
  22663. // SetActionLabelAdd sets the "action_label_add" field.
  22664. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  22665. m.action_label_add = &u
  22666. m.appendaction_label_add = nil
  22667. }
  22668. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22669. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22670. v := m.action_label_add
  22671. if v == nil {
  22672. return
  22673. }
  22674. return *v, true
  22675. }
  22676. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  22677. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22679. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22680. if !m.op.Is(OpUpdateOne) {
  22681. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22682. }
  22683. if m.id == nil || m.oldValue == nil {
  22684. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22685. }
  22686. oldValue, err := m.oldValue(ctx)
  22687. if err != nil {
  22688. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22689. }
  22690. return oldValue.ActionLabelAdd, nil
  22691. }
  22692. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22693. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  22694. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22695. }
  22696. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22697. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22698. if len(m.appendaction_label_add) == 0 {
  22699. return nil, false
  22700. }
  22701. return m.appendaction_label_add, true
  22702. }
  22703. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22704. func (m *SopNodeMutation) ClearActionLabelAdd() {
  22705. m.action_label_add = nil
  22706. m.appendaction_label_add = nil
  22707. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  22708. }
  22709. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22710. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  22711. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  22712. return ok
  22713. }
  22714. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22715. func (m *SopNodeMutation) ResetActionLabelAdd() {
  22716. m.action_label_add = nil
  22717. m.appendaction_label_add = nil
  22718. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  22719. }
  22720. // SetActionLabelDel sets the "action_label_del" field.
  22721. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  22722. m.action_label_del = &u
  22723. m.appendaction_label_del = nil
  22724. }
  22725. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22726. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  22727. v := m.action_label_del
  22728. if v == nil {
  22729. return
  22730. }
  22731. return *v, true
  22732. }
  22733. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  22734. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22736. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22737. if !m.op.Is(OpUpdateOne) {
  22738. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22739. }
  22740. if m.id == nil || m.oldValue == nil {
  22741. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22742. }
  22743. oldValue, err := m.oldValue(ctx)
  22744. if err != nil {
  22745. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22746. }
  22747. return oldValue.ActionLabelDel, nil
  22748. }
  22749. // AppendActionLabelDel adds u to the "action_label_del" field.
  22750. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  22751. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22752. }
  22753. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22754. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22755. if len(m.appendaction_label_del) == 0 {
  22756. return nil, false
  22757. }
  22758. return m.appendaction_label_del, true
  22759. }
  22760. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22761. func (m *SopNodeMutation) ClearActionLabelDel() {
  22762. m.action_label_del = nil
  22763. m.appendaction_label_del = nil
  22764. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  22765. }
  22766. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22767. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  22768. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  22769. return ok
  22770. }
  22771. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22772. func (m *SopNodeMutation) ResetActionLabelDel() {
  22773. m.action_label_del = nil
  22774. m.appendaction_label_del = nil
  22775. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  22776. }
  22777. // SetActionForward sets the "action_forward" field.
  22778. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22779. m.action_forward = &ctf
  22780. }
  22781. // ActionForward returns the value of the "action_forward" field in the mutation.
  22782. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22783. v := m.action_forward
  22784. if v == nil {
  22785. return
  22786. }
  22787. return *v, true
  22788. }
  22789. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  22790. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22792. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22793. if !m.op.Is(OpUpdateOne) {
  22794. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22795. }
  22796. if m.id == nil || m.oldValue == nil {
  22797. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22798. }
  22799. oldValue, err := m.oldValue(ctx)
  22800. if err != nil {
  22801. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22802. }
  22803. return oldValue.ActionForward, nil
  22804. }
  22805. // ClearActionForward clears the value of the "action_forward" field.
  22806. func (m *SopNodeMutation) ClearActionForward() {
  22807. m.action_forward = nil
  22808. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  22809. }
  22810. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22811. func (m *SopNodeMutation) ActionForwardCleared() bool {
  22812. _, ok := m.clearedFields[sopnode.FieldActionForward]
  22813. return ok
  22814. }
  22815. // ResetActionForward resets all changes to the "action_forward" field.
  22816. func (m *SopNodeMutation) ResetActionForward() {
  22817. m.action_forward = nil
  22818. delete(m.clearedFields, sopnode.FieldActionForward)
  22819. }
  22820. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  22821. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  22822. m.sop_stage = &id
  22823. }
  22824. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  22825. func (m *SopNodeMutation) ClearSopStage() {
  22826. m.clearedsop_stage = true
  22827. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  22828. }
  22829. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  22830. func (m *SopNodeMutation) SopStageCleared() bool {
  22831. return m.clearedsop_stage
  22832. }
  22833. // SopStageID returns the "sop_stage" edge ID in the mutation.
  22834. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  22835. if m.sop_stage != nil {
  22836. return *m.sop_stage, true
  22837. }
  22838. return
  22839. }
  22840. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  22841. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22842. // SopStageID instead. It exists only for internal usage by the builders.
  22843. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  22844. if id := m.sop_stage; id != nil {
  22845. ids = append(ids, *id)
  22846. }
  22847. return
  22848. }
  22849. // ResetSopStage resets all changes to the "sop_stage" edge.
  22850. func (m *SopNodeMutation) ResetSopStage() {
  22851. m.sop_stage = nil
  22852. m.clearedsop_stage = false
  22853. }
  22854. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  22855. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  22856. if m.node_messages == nil {
  22857. m.node_messages = make(map[uint64]struct{})
  22858. }
  22859. for i := range ids {
  22860. m.node_messages[ids[i]] = struct{}{}
  22861. }
  22862. }
  22863. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  22864. func (m *SopNodeMutation) ClearNodeMessages() {
  22865. m.clearednode_messages = true
  22866. }
  22867. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  22868. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  22869. return m.clearednode_messages
  22870. }
  22871. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  22872. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  22873. if m.removednode_messages == nil {
  22874. m.removednode_messages = make(map[uint64]struct{})
  22875. }
  22876. for i := range ids {
  22877. delete(m.node_messages, ids[i])
  22878. m.removednode_messages[ids[i]] = struct{}{}
  22879. }
  22880. }
  22881. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  22882. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  22883. for id := range m.removednode_messages {
  22884. ids = append(ids, id)
  22885. }
  22886. return
  22887. }
  22888. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  22889. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  22890. for id := range m.node_messages {
  22891. ids = append(ids, id)
  22892. }
  22893. return
  22894. }
  22895. // ResetNodeMessages resets all changes to the "node_messages" edge.
  22896. func (m *SopNodeMutation) ResetNodeMessages() {
  22897. m.node_messages = nil
  22898. m.clearednode_messages = false
  22899. m.removednode_messages = nil
  22900. }
  22901. // Where appends a list predicates to the SopNodeMutation builder.
  22902. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  22903. m.predicates = append(m.predicates, ps...)
  22904. }
  22905. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  22906. // users can use type-assertion to append predicates that do not depend on any generated package.
  22907. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  22908. p := make([]predicate.SopNode, len(ps))
  22909. for i := range ps {
  22910. p[i] = ps[i]
  22911. }
  22912. m.Where(p...)
  22913. }
  22914. // Op returns the operation name.
  22915. func (m *SopNodeMutation) Op() Op {
  22916. return m.op
  22917. }
  22918. // SetOp allows setting the mutation operation.
  22919. func (m *SopNodeMutation) SetOp(op Op) {
  22920. m.op = op
  22921. }
  22922. // Type returns the node type of this mutation (SopNode).
  22923. func (m *SopNodeMutation) Type() string {
  22924. return m.typ
  22925. }
  22926. // Fields returns all fields that were changed during this mutation. Note that in
  22927. // order to get all numeric fields that were incremented/decremented, call
  22928. // AddedFields().
  22929. func (m *SopNodeMutation) Fields() []string {
  22930. fields := make([]string, 0, 15)
  22931. if m.created_at != nil {
  22932. fields = append(fields, sopnode.FieldCreatedAt)
  22933. }
  22934. if m.updated_at != nil {
  22935. fields = append(fields, sopnode.FieldUpdatedAt)
  22936. }
  22937. if m.status != nil {
  22938. fields = append(fields, sopnode.FieldStatus)
  22939. }
  22940. if m.deleted_at != nil {
  22941. fields = append(fields, sopnode.FieldDeletedAt)
  22942. }
  22943. if m.sop_stage != nil {
  22944. fields = append(fields, sopnode.FieldStageID)
  22945. }
  22946. if m.parent_id != nil {
  22947. fields = append(fields, sopnode.FieldParentID)
  22948. }
  22949. if m.name != nil {
  22950. fields = append(fields, sopnode.FieldName)
  22951. }
  22952. if m.condition_type != nil {
  22953. fields = append(fields, sopnode.FieldConditionType)
  22954. }
  22955. if m.condition_list != nil {
  22956. fields = append(fields, sopnode.FieldConditionList)
  22957. }
  22958. if m.no_reply_condition != nil {
  22959. fields = append(fields, sopnode.FieldNoReplyCondition)
  22960. }
  22961. if m.no_reply_unit != nil {
  22962. fields = append(fields, sopnode.FieldNoReplyUnit)
  22963. }
  22964. if m.action_message != nil {
  22965. fields = append(fields, sopnode.FieldActionMessage)
  22966. }
  22967. if m.action_label_add != nil {
  22968. fields = append(fields, sopnode.FieldActionLabelAdd)
  22969. }
  22970. if m.action_label_del != nil {
  22971. fields = append(fields, sopnode.FieldActionLabelDel)
  22972. }
  22973. if m.action_forward != nil {
  22974. fields = append(fields, sopnode.FieldActionForward)
  22975. }
  22976. return fields
  22977. }
  22978. // Field returns the value of a field with the given name. The second boolean
  22979. // return value indicates that this field was not set, or was not defined in the
  22980. // schema.
  22981. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  22982. switch name {
  22983. case sopnode.FieldCreatedAt:
  22984. return m.CreatedAt()
  22985. case sopnode.FieldUpdatedAt:
  22986. return m.UpdatedAt()
  22987. case sopnode.FieldStatus:
  22988. return m.Status()
  22989. case sopnode.FieldDeletedAt:
  22990. return m.DeletedAt()
  22991. case sopnode.FieldStageID:
  22992. return m.StageID()
  22993. case sopnode.FieldParentID:
  22994. return m.ParentID()
  22995. case sopnode.FieldName:
  22996. return m.Name()
  22997. case sopnode.FieldConditionType:
  22998. return m.ConditionType()
  22999. case sopnode.FieldConditionList:
  23000. return m.ConditionList()
  23001. case sopnode.FieldNoReplyCondition:
  23002. return m.NoReplyCondition()
  23003. case sopnode.FieldNoReplyUnit:
  23004. return m.NoReplyUnit()
  23005. case sopnode.FieldActionMessage:
  23006. return m.ActionMessage()
  23007. case sopnode.FieldActionLabelAdd:
  23008. return m.ActionLabelAdd()
  23009. case sopnode.FieldActionLabelDel:
  23010. return m.ActionLabelDel()
  23011. case sopnode.FieldActionForward:
  23012. return m.ActionForward()
  23013. }
  23014. return nil, false
  23015. }
  23016. // OldField returns the old value of the field from the database. An error is
  23017. // returned if the mutation operation is not UpdateOne, or the query to the
  23018. // database failed.
  23019. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23020. switch name {
  23021. case sopnode.FieldCreatedAt:
  23022. return m.OldCreatedAt(ctx)
  23023. case sopnode.FieldUpdatedAt:
  23024. return m.OldUpdatedAt(ctx)
  23025. case sopnode.FieldStatus:
  23026. return m.OldStatus(ctx)
  23027. case sopnode.FieldDeletedAt:
  23028. return m.OldDeletedAt(ctx)
  23029. case sopnode.FieldStageID:
  23030. return m.OldStageID(ctx)
  23031. case sopnode.FieldParentID:
  23032. return m.OldParentID(ctx)
  23033. case sopnode.FieldName:
  23034. return m.OldName(ctx)
  23035. case sopnode.FieldConditionType:
  23036. return m.OldConditionType(ctx)
  23037. case sopnode.FieldConditionList:
  23038. return m.OldConditionList(ctx)
  23039. case sopnode.FieldNoReplyCondition:
  23040. return m.OldNoReplyCondition(ctx)
  23041. case sopnode.FieldNoReplyUnit:
  23042. return m.OldNoReplyUnit(ctx)
  23043. case sopnode.FieldActionMessage:
  23044. return m.OldActionMessage(ctx)
  23045. case sopnode.FieldActionLabelAdd:
  23046. return m.OldActionLabelAdd(ctx)
  23047. case sopnode.FieldActionLabelDel:
  23048. return m.OldActionLabelDel(ctx)
  23049. case sopnode.FieldActionForward:
  23050. return m.OldActionForward(ctx)
  23051. }
  23052. return nil, fmt.Errorf("unknown SopNode field %s", name)
  23053. }
  23054. // SetField sets the value of a field with the given name. It returns an error if
  23055. // the field is not defined in the schema, or if the type mismatched the field
  23056. // type.
  23057. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  23058. switch name {
  23059. case sopnode.FieldCreatedAt:
  23060. v, ok := value.(time.Time)
  23061. if !ok {
  23062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23063. }
  23064. m.SetCreatedAt(v)
  23065. return nil
  23066. case sopnode.FieldUpdatedAt:
  23067. v, ok := value.(time.Time)
  23068. if !ok {
  23069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23070. }
  23071. m.SetUpdatedAt(v)
  23072. return nil
  23073. case sopnode.FieldStatus:
  23074. v, ok := value.(uint8)
  23075. if !ok {
  23076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23077. }
  23078. m.SetStatus(v)
  23079. return nil
  23080. case sopnode.FieldDeletedAt:
  23081. v, ok := value.(time.Time)
  23082. if !ok {
  23083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23084. }
  23085. m.SetDeletedAt(v)
  23086. return nil
  23087. case sopnode.FieldStageID:
  23088. v, ok := value.(uint64)
  23089. if !ok {
  23090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23091. }
  23092. m.SetStageID(v)
  23093. return nil
  23094. case sopnode.FieldParentID:
  23095. v, ok := value.(uint64)
  23096. if !ok {
  23097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23098. }
  23099. m.SetParentID(v)
  23100. return nil
  23101. case sopnode.FieldName:
  23102. v, ok := value.(string)
  23103. if !ok {
  23104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23105. }
  23106. m.SetName(v)
  23107. return nil
  23108. case sopnode.FieldConditionType:
  23109. v, ok := value.(int)
  23110. if !ok {
  23111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23112. }
  23113. m.SetConditionType(v)
  23114. return nil
  23115. case sopnode.FieldConditionList:
  23116. v, ok := value.([]string)
  23117. if !ok {
  23118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23119. }
  23120. m.SetConditionList(v)
  23121. return nil
  23122. case sopnode.FieldNoReplyCondition:
  23123. v, ok := value.(uint64)
  23124. if !ok {
  23125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23126. }
  23127. m.SetNoReplyCondition(v)
  23128. return nil
  23129. case sopnode.FieldNoReplyUnit:
  23130. v, ok := value.(string)
  23131. if !ok {
  23132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23133. }
  23134. m.SetNoReplyUnit(v)
  23135. return nil
  23136. case sopnode.FieldActionMessage:
  23137. v, ok := value.([]custom_types.Action)
  23138. if !ok {
  23139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23140. }
  23141. m.SetActionMessage(v)
  23142. return nil
  23143. case sopnode.FieldActionLabelAdd:
  23144. v, ok := value.([]uint64)
  23145. if !ok {
  23146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23147. }
  23148. m.SetActionLabelAdd(v)
  23149. return nil
  23150. case sopnode.FieldActionLabelDel:
  23151. v, ok := value.([]uint64)
  23152. if !ok {
  23153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23154. }
  23155. m.SetActionLabelDel(v)
  23156. return nil
  23157. case sopnode.FieldActionForward:
  23158. v, ok := value.(*custom_types.ActionForward)
  23159. if !ok {
  23160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23161. }
  23162. m.SetActionForward(v)
  23163. return nil
  23164. }
  23165. return fmt.Errorf("unknown SopNode field %s", name)
  23166. }
  23167. // AddedFields returns all numeric fields that were incremented/decremented during
  23168. // this mutation.
  23169. func (m *SopNodeMutation) AddedFields() []string {
  23170. var fields []string
  23171. if m.addstatus != nil {
  23172. fields = append(fields, sopnode.FieldStatus)
  23173. }
  23174. if m.addparent_id != nil {
  23175. fields = append(fields, sopnode.FieldParentID)
  23176. }
  23177. if m.addcondition_type != nil {
  23178. fields = append(fields, sopnode.FieldConditionType)
  23179. }
  23180. if m.addno_reply_condition != nil {
  23181. fields = append(fields, sopnode.FieldNoReplyCondition)
  23182. }
  23183. return fields
  23184. }
  23185. // AddedField returns the numeric value that was incremented/decremented on a field
  23186. // with the given name. The second boolean return value indicates that this field
  23187. // was not set, or was not defined in the schema.
  23188. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  23189. switch name {
  23190. case sopnode.FieldStatus:
  23191. return m.AddedStatus()
  23192. case sopnode.FieldParentID:
  23193. return m.AddedParentID()
  23194. case sopnode.FieldConditionType:
  23195. return m.AddedConditionType()
  23196. case sopnode.FieldNoReplyCondition:
  23197. return m.AddedNoReplyCondition()
  23198. }
  23199. return nil, false
  23200. }
  23201. // AddField adds the value to the field with the given name. It returns an error if
  23202. // the field is not defined in the schema, or if the type mismatched the field
  23203. // type.
  23204. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  23205. switch name {
  23206. case sopnode.FieldStatus:
  23207. v, ok := value.(int8)
  23208. if !ok {
  23209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23210. }
  23211. m.AddStatus(v)
  23212. return nil
  23213. case sopnode.FieldParentID:
  23214. v, ok := value.(int64)
  23215. if !ok {
  23216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23217. }
  23218. m.AddParentID(v)
  23219. return nil
  23220. case sopnode.FieldConditionType:
  23221. v, ok := value.(int)
  23222. if !ok {
  23223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23224. }
  23225. m.AddConditionType(v)
  23226. return nil
  23227. case sopnode.FieldNoReplyCondition:
  23228. v, ok := value.(int64)
  23229. if !ok {
  23230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23231. }
  23232. m.AddNoReplyCondition(v)
  23233. return nil
  23234. }
  23235. return fmt.Errorf("unknown SopNode numeric field %s", name)
  23236. }
  23237. // ClearedFields returns all nullable fields that were cleared during this
  23238. // mutation.
  23239. func (m *SopNodeMutation) ClearedFields() []string {
  23240. var fields []string
  23241. if m.FieldCleared(sopnode.FieldStatus) {
  23242. fields = append(fields, sopnode.FieldStatus)
  23243. }
  23244. if m.FieldCleared(sopnode.FieldDeletedAt) {
  23245. fields = append(fields, sopnode.FieldDeletedAt)
  23246. }
  23247. if m.FieldCleared(sopnode.FieldConditionList) {
  23248. fields = append(fields, sopnode.FieldConditionList)
  23249. }
  23250. if m.FieldCleared(sopnode.FieldActionMessage) {
  23251. fields = append(fields, sopnode.FieldActionMessage)
  23252. }
  23253. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  23254. fields = append(fields, sopnode.FieldActionLabelAdd)
  23255. }
  23256. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  23257. fields = append(fields, sopnode.FieldActionLabelDel)
  23258. }
  23259. if m.FieldCleared(sopnode.FieldActionForward) {
  23260. fields = append(fields, sopnode.FieldActionForward)
  23261. }
  23262. return fields
  23263. }
  23264. // FieldCleared returns a boolean indicating if a field with the given name was
  23265. // cleared in this mutation.
  23266. func (m *SopNodeMutation) FieldCleared(name string) bool {
  23267. _, ok := m.clearedFields[name]
  23268. return ok
  23269. }
  23270. // ClearField clears the value of the field with the given name. It returns an
  23271. // error if the field is not defined in the schema.
  23272. func (m *SopNodeMutation) ClearField(name string) error {
  23273. switch name {
  23274. case sopnode.FieldStatus:
  23275. m.ClearStatus()
  23276. return nil
  23277. case sopnode.FieldDeletedAt:
  23278. m.ClearDeletedAt()
  23279. return nil
  23280. case sopnode.FieldConditionList:
  23281. m.ClearConditionList()
  23282. return nil
  23283. case sopnode.FieldActionMessage:
  23284. m.ClearActionMessage()
  23285. return nil
  23286. case sopnode.FieldActionLabelAdd:
  23287. m.ClearActionLabelAdd()
  23288. return nil
  23289. case sopnode.FieldActionLabelDel:
  23290. m.ClearActionLabelDel()
  23291. return nil
  23292. case sopnode.FieldActionForward:
  23293. m.ClearActionForward()
  23294. return nil
  23295. }
  23296. return fmt.Errorf("unknown SopNode nullable field %s", name)
  23297. }
  23298. // ResetField resets all changes in the mutation for the field with the given name.
  23299. // It returns an error if the field is not defined in the schema.
  23300. func (m *SopNodeMutation) ResetField(name string) error {
  23301. switch name {
  23302. case sopnode.FieldCreatedAt:
  23303. m.ResetCreatedAt()
  23304. return nil
  23305. case sopnode.FieldUpdatedAt:
  23306. m.ResetUpdatedAt()
  23307. return nil
  23308. case sopnode.FieldStatus:
  23309. m.ResetStatus()
  23310. return nil
  23311. case sopnode.FieldDeletedAt:
  23312. m.ResetDeletedAt()
  23313. return nil
  23314. case sopnode.FieldStageID:
  23315. m.ResetStageID()
  23316. return nil
  23317. case sopnode.FieldParentID:
  23318. m.ResetParentID()
  23319. return nil
  23320. case sopnode.FieldName:
  23321. m.ResetName()
  23322. return nil
  23323. case sopnode.FieldConditionType:
  23324. m.ResetConditionType()
  23325. return nil
  23326. case sopnode.FieldConditionList:
  23327. m.ResetConditionList()
  23328. return nil
  23329. case sopnode.FieldNoReplyCondition:
  23330. m.ResetNoReplyCondition()
  23331. return nil
  23332. case sopnode.FieldNoReplyUnit:
  23333. m.ResetNoReplyUnit()
  23334. return nil
  23335. case sopnode.FieldActionMessage:
  23336. m.ResetActionMessage()
  23337. return nil
  23338. case sopnode.FieldActionLabelAdd:
  23339. m.ResetActionLabelAdd()
  23340. return nil
  23341. case sopnode.FieldActionLabelDel:
  23342. m.ResetActionLabelDel()
  23343. return nil
  23344. case sopnode.FieldActionForward:
  23345. m.ResetActionForward()
  23346. return nil
  23347. }
  23348. return fmt.Errorf("unknown SopNode field %s", name)
  23349. }
  23350. // AddedEdges returns all edge names that were set/added in this mutation.
  23351. func (m *SopNodeMutation) AddedEdges() []string {
  23352. edges := make([]string, 0, 2)
  23353. if m.sop_stage != nil {
  23354. edges = append(edges, sopnode.EdgeSopStage)
  23355. }
  23356. if m.node_messages != nil {
  23357. edges = append(edges, sopnode.EdgeNodeMessages)
  23358. }
  23359. return edges
  23360. }
  23361. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23362. // name in this mutation.
  23363. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  23364. switch name {
  23365. case sopnode.EdgeSopStage:
  23366. if id := m.sop_stage; id != nil {
  23367. return []ent.Value{*id}
  23368. }
  23369. case sopnode.EdgeNodeMessages:
  23370. ids := make([]ent.Value, 0, len(m.node_messages))
  23371. for id := range m.node_messages {
  23372. ids = append(ids, id)
  23373. }
  23374. return ids
  23375. }
  23376. return nil
  23377. }
  23378. // RemovedEdges returns all edge names that were removed in this mutation.
  23379. func (m *SopNodeMutation) RemovedEdges() []string {
  23380. edges := make([]string, 0, 2)
  23381. if m.removednode_messages != nil {
  23382. edges = append(edges, sopnode.EdgeNodeMessages)
  23383. }
  23384. return edges
  23385. }
  23386. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23387. // the given name in this mutation.
  23388. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  23389. switch name {
  23390. case sopnode.EdgeNodeMessages:
  23391. ids := make([]ent.Value, 0, len(m.removednode_messages))
  23392. for id := range m.removednode_messages {
  23393. ids = append(ids, id)
  23394. }
  23395. return ids
  23396. }
  23397. return nil
  23398. }
  23399. // ClearedEdges returns all edge names that were cleared in this mutation.
  23400. func (m *SopNodeMutation) ClearedEdges() []string {
  23401. edges := make([]string, 0, 2)
  23402. if m.clearedsop_stage {
  23403. edges = append(edges, sopnode.EdgeSopStage)
  23404. }
  23405. if m.clearednode_messages {
  23406. edges = append(edges, sopnode.EdgeNodeMessages)
  23407. }
  23408. return edges
  23409. }
  23410. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23411. // was cleared in this mutation.
  23412. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  23413. switch name {
  23414. case sopnode.EdgeSopStage:
  23415. return m.clearedsop_stage
  23416. case sopnode.EdgeNodeMessages:
  23417. return m.clearednode_messages
  23418. }
  23419. return false
  23420. }
  23421. // ClearEdge clears the value of the edge with the given name. It returns an error
  23422. // if that edge is not defined in the schema.
  23423. func (m *SopNodeMutation) ClearEdge(name string) error {
  23424. switch name {
  23425. case sopnode.EdgeSopStage:
  23426. m.ClearSopStage()
  23427. return nil
  23428. }
  23429. return fmt.Errorf("unknown SopNode unique edge %s", name)
  23430. }
  23431. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23432. // It returns an error if the edge is not defined in the schema.
  23433. func (m *SopNodeMutation) ResetEdge(name string) error {
  23434. switch name {
  23435. case sopnode.EdgeSopStage:
  23436. m.ResetSopStage()
  23437. return nil
  23438. case sopnode.EdgeNodeMessages:
  23439. m.ResetNodeMessages()
  23440. return nil
  23441. }
  23442. return fmt.Errorf("unknown SopNode edge %s", name)
  23443. }
  23444. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  23445. type SopStageMutation struct {
  23446. config
  23447. op Op
  23448. typ string
  23449. id *uint64
  23450. created_at *time.Time
  23451. updated_at *time.Time
  23452. status *uint8
  23453. addstatus *int8
  23454. deleted_at *time.Time
  23455. name *string
  23456. condition_type *int
  23457. addcondition_type *int
  23458. condition_operator *int
  23459. addcondition_operator *int
  23460. condition_list *[]custom_types.Condition
  23461. appendcondition_list []custom_types.Condition
  23462. action_message *[]custom_types.Action
  23463. appendaction_message []custom_types.Action
  23464. action_label_add *[]uint64
  23465. appendaction_label_add []uint64
  23466. action_label_del *[]uint64
  23467. appendaction_label_del []uint64
  23468. action_forward **custom_types.ActionForward
  23469. index_sort *int
  23470. addindex_sort *int
  23471. clearedFields map[string]struct{}
  23472. sop_task *uint64
  23473. clearedsop_task bool
  23474. stage_nodes map[uint64]struct{}
  23475. removedstage_nodes map[uint64]struct{}
  23476. clearedstage_nodes bool
  23477. stage_messages map[uint64]struct{}
  23478. removedstage_messages map[uint64]struct{}
  23479. clearedstage_messages bool
  23480. done bool
  23481. oldValue func(context.Context) (*SopStage, error)
  23482. predicates []predicate.SopStage
  23483. }
  23484. var _ ent.Mutation = (*SopStageMutation)(nil)
  23485. // sopstageOption allows management of the mutation configuration using functional options.
  23486. type sopstageOption func(*SopStageMutation)
  23487. // newSopStageMutation creates new mutation for the SopStage entity.
  23488. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  23489. m := &SopStageMutation{
  23490. config: c,
  23491. op: op,
  23492. typ: TypeSopStage,
  23493. clearedFields: make(map[string]struct{}),
  23494. }
  23495. for _, opt := range opts {
  23496. opt(m)
  23497. }
  23498. return m
  23499. }
  23500. // withSopStageID sets the ID field of the mutation.
  23501. func withSopStageID(id uint64) sopstageOption {
  23502. return func(m *SopStageMutation) {
  23503. var (
  23504. err error
  23505. once sync.Once
  23506. value *SopStage
  23507. )
  23508. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  23509. once.Do(func() {
  23510. if m.done {
  23511. err = errors.New("querying old values post mutation is not allowed")
  23512. } else {
  23513. value, err = m.Client().SopStage.Get(ctx, id)
  23514. }
  23515. })
  23516. return value, err
  23517. }
  23518. m.id = &id
  23519. }
  23520. }
  23521. // withSopStage sets the old SopStage of the mutation.
  23522. func withSopStage(node *SopStage) sopstageOption {
  23523. return func(m *SopStageMutation) {
  23524. m.oldValue = func(context.Context) (*SopStage, error) {
  23525. return node, nil
  23526. }
  23527. m.id = &node.ID
  23528. }
  23529. }
  23530. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23531. // executed in a transaction (ent.Tx), a transactional client is returned.
  23532. func (m SopStageMutation) Client() *Client {
  23533. client := &Client{config: m.config}
  23534. client.init()
  23535. return client
  23536. }
  23537. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23538. // it returns an error otherwise.
  23539. func (m SopStageMutation) Tx() (*Tx, error) {
  23540. if _, ok := m.driver.(*txDriver); !ok {
  23541. return nil, errors.New("ent: mutation is not running in a transaction")
  23542. }
  23543. tx := &Tx{config: m.config}
  23544. tx.init()
  23545. return tx, nil
  23546. }
  23547. // SetID sets the value of the id field. Note that this
  23548. // operation is only accepted on creation of SopStage entities.
  23549. func (m *SopStageMutation) SetID(id uint64) {
  23550. m.id = &id
  23551. }
  23552. // ID returns the ID value in the mutation. Note that the ID is only available
  23553. // if it was provided to the builder or after it was returned from the database.
  23554. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  23555. if m.id == nil {
  23556. return
  23557. }
  23558. return *m.id, true
  23559. }
  23560. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23561. // That means, if the mutation is applied within a transaction with an isolation level such
  23562. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23563. // or updated by the mutation.
  23564. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  23565. switch {
  23566. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23567. id, exists := m.ID()
  23568. if exists {
  23569. return []uint64{id}, nil
  23570. }
  23571. fallthrough
  23572. case m.op.Is(OpUpdate | OpDelete):
  23573. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  23574. default:
  23575. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23576. }
  23577. }
  23578. // SetCreatedAt sets the "created_at" field.
  23579. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  23580. m.created_at = &t
  23581. }
  23582. // CreatedAt returns the value of the "created_at" field in the mutation.
  23583. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  23584. v := m.created_at
  23585. if v == nil {
  23586. return
  23587. }
  23588. return *v, true
  23589. }
  23590. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  23591. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23593. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23594. if !m.op.Is(OpUpdateOne) {
  23595. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23596. }
  23597. if m.id == nil || m.oldValue == nil {
  23598. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23599. }
  23600. oldValue, err := m.oldValue(ctx)
  23601. if err != nil {
  23602. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23603. }
  23604. return oldValue.CreatedAt, nil
  23605. }
  23606. // ResetCreatedAt resets all changes to the "created_at" field.
  23607. func (m *SopStageMutation) ResetCreatedAt() {
  23608. m.created_at = nil
  23609. }
  23610. // SetUpdatedAt sets the "updated_at" field.
  23611. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  23612. m.updated_at = &t
  23613. }
  23614. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23615. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  23616. v := m.updated_at
  23617. if v == nil {
  23618. return
  23619. }
  23620. return *v, true
  23621. }
  23622. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  23623. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23625. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23626. if !m.op.Is(OpUpdateOne) {
  23627. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23628. }
  23629. if m.id == nil || m.oldValue == nil {
  23630. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23631. }
  23632. oldValue, err := m.oldValue(ctx)
  23633. if err != nil {
  23634. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23635. }
  23636. return oldValue.UpdatedAt, nil
  23637. }
  23638. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23639. func (m *SopStageMutation) ResetUpdatedAt() {
  23640. m.updated_at = nil
  23641. }
  23642. // SetStatus sets the "status" field.
  23643. func (m *SopStageMutation) SetStatus(u uint8) {
  23644. m.status = &u
  23645. m.addstatus = nil
  23646. }
  23647. // Status returns the value of the "status" field in the mutation.
  23648. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  23649. v := m.status
  23650. if v == nil {
  23651. return
  23652. }
  23653. return *v, true
  23654. }
  23655. // OldStatus returns the old "status" field's value of the SopStage entity.
  23656. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23658. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23659. if !m.op.Is(OpUpdateOne) {
  23660. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23661. }
  23662. if m.id == nil || m.oldValue == nil {
  23663. return v, errors.New("OldStatus requires an ID field in the mutation")
  23664. }
  23665. oldValue, err := m.oldValue(ctx)
  23666. if err != nil {
  23667. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23668. }
  23669. return oldValue.Status, nil
  23670. }
  23671. // AddStatus adds u to the "status" field.
  23672. func (m *SopStageMutation) AddStatus(u int8) {
  23673. if m.addstatus != nil {
  23674. *m.addstatus += u
  23675. } else {
  23676. m.addstatus = &u
  23677. }
  23678. }
  23679. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23680. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  23681. v := m.addstatus
  23682. if v == nil {
  23683. return
  23684. }
  23685. return *v, true
  23686. }
  23687. // ClearStatus clears the value of the "status" field.
  23688. func (m *SopStageMutation) ClearStatus() {
  23689. m.status = nil
  23690. m.addstatus = nil
  23691. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  23692. }
  23693. // StatusCleared returns if the "status" field was cleared in this mutation.
  23694. func (m *SopStageMutation) StatusCleared() bool {
  23695. _, ok := m.clearedFields[sopstage.FieldStatus]
  23696. return ok
  23697. }
  23698. // ResetStatus resets all changes to the "status" field.
  23699. func (m *SopStageMutation) ResetStatus() {
  23700. m.status = nil
  23701. m.addstatus = nil
  23702. delete(m.clearedFields, sopstage.FieldStatus)
  23703. }
  23704. // SetDeletedAt sets the "deleted_at" field.
  23705. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  23706. m.deleted_at = &t
  23707. }
  23708. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23709. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  23710. v := m.deleted_at
  23711. if v == nil {
  23712. return
  23713. }
  23714. return *v, true
  23715. }
  23716. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  23717. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23719. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23720. if !m.op.Is(OpUpdateOne) {
  23721. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23722. }
  23723. if m.id == nil || m.oldValue == nil {
  23724. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23725. }
  23726. oldValue, err := m.oldValue(ctx)
  23727. if err != nil {
  23728. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23729. }
  23730. return oldValue.DeletedAt, nil
  23731. }
  23732. // ClearDeletedAt clears the value of the "deleted_at" field.
  23733. func (m *SopStageMutation) ClearDeletedAt() {
  23734. m.deleted_at = nil
  23735. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  23736. }
  23737. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23738. func (m *SopStageMutation) DeletedAtCleared() bool {
  23739. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  23740. return ok
  23741. }
  23742. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23743. func (m *SopStageMutation) ResetDeletedAt() {
  23744. m.deleted_at = nil
  23745. delete(m.clearedFields, sopstage.FieldDeletedAt)
  23746. }
  23747. // SetTaskID sets the "task_id" field.
  23748. func (m *SopStageMutation) SetTaskID(u uint64) {
  23749. m.sop_task = &u
  23750. }
  23751. // TaskID returns the value of the "task_id" field in the mutation.
  23752. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  23753. v := m.sop_task
  23754. if v == nil {
  23755. return
  23756. }
  23757. return *v, true
  23758. }
  23759. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  23760. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23762. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  23763. if !m.op.Is(OpUpdateOne) {
  23764. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  23765. }
  23766. if m.id == nil || m.oldValue == nil {
  23767. return v, errors.New("OldTaskID requires an ID field in the mutation")
  23768. }
  23769. oldValue, err := m.oldValue(ctx)
  23770. if err != nil {
  23771. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  23772. }
  23773. return oldValue.TaskID, nil
  23774. }
  23775. // ResetTaskID resets all changes to the "task_id" field.
  23776. func (m *SopStageMutation) ResetTaskID() {
  23777. m.sop_task = nil
  23778. }
  23779. // SetName sets the "name" field.
  23780. func (m *SopStageMutation) SetName(s string) {
  23781. m.name = &s
  23782. }
  23783. // Name returns the value of the "name" field in the mutation.
  23784. func (m *SopStageMutation) Name() (r string, exists bool) {
  23785. v := m.name
  23786. if v == nil {
  23787. return
  23788. }
  23789. return *v, true
  23790. }
  23791. // OldName returns the old "name" field's value of the SopStage entity.
  23792. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23794. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  23795. if !m.op.Is(OpUpdateOne) {
  23796. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23797. }
  23798. if m.id == nil || m.oldValue == nil {
  23799. return v, errors.New("OldName requires an ID field in the mutation")
  23800. }
  23801. oldValue, err := m.oldValue(ctx)
  23802. if err != nil {
  23803. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23804. }
  23805. return oldValue.Name, nil
  23806. }
  23807. // ResetName resets all changes to the "name" field.
  23808. func (m *SopStageMutation) ResetName() {
  23809. m.name = nil
  23810. }
  23811. // SetConditionType sets the "condition_type" field.
  23812. func (m *SopStageMutation) SetConditionType(i int) {
  23813. m.condition_type = &i
  23814. m.addcondition_type = nil
  23815. }
  23816. // ConditionType returns the value of the "condition_type" field in the mutation.
  23817. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  23818. v := m.condition_type
  23819. if v == nil {
  23820. return
  23821. }
  23822. return *v, true
  23823. }
  23824. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  23825. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23827. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23828. if !m.op.Is(OpUpdateOne) {
  23829. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23830. }
  23831. if m.id == nil || m.oldValue == nil {
  23832. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23833. }
  23834. oldValue, err := m.oldValue(ctx)
  23835. if err != nil {
  23836. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23837. }
  23838. return oldValue.ConditionType, nil
  23839. }
  23840. // AddConditionType adds i to the "condition_type" field.
  23841. func (m *SopStageMutation) AddConditionType(i int) {
  23842. if m.addcondition_type != nil {
  23843. *m.addcondition_type += i
  23844. } else {
  23845. m.addcondition_type = &i
  23846. }
  23847. }
  23848. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23849. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  23850. v := m.addcondition_type
  23851. if v == nil {
  23852. return
  23853. }
  23854. return *v, true
  23855. }
  23856. // ResetConditionType resets all changes to the "condition_type" field.
  23857. func (m *SopStageMutation) ResetConditionType() {
  23858. m.condition_type = nil
  23859. m.addcondition_type = nil
  23860. }
  23861. // SetConditionOperator sets the "condition_operator" field.
  23862. func (m *SopStageMutation) SetConditionOperator(i int) {
  23863. m.condition_operator = &i
  23864. m.addcondition_operator = nil
  23865. }
  23866. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  23867. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  23868. v := m.condition_operator
  23869. if v == nil {
  23870. return
  23871. }
  23872. return *v, true
  23873. }
  23874. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  23875. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23877. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  23878. if !m.op.Is(OpUpdateOne) {
  23879. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  23880. }
  23881. if m.id == nil || m.oldValue == nil {
  23882. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  23883. }
  23884. oldValue, err := m.oldValue(ctx)
  23885. if err != nil {
  23886. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  23887. }
  23888. return oldValue.ConditionOperator, nil
  23889. }
  23890. // AddConditionOperator adds i to the "condition_operator" field.
  23891. func (m *SopStageMutation) AddConditionOperator(i int) {
  23892. if m.addcondition_operator != nil {
  23893. *m.addcondition_operator += i
  23894. } else {
  23895. m.addcondition_operator = &i
  23896. }
  23897. }
  23898. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  23899. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  23900. v := m.addcondition_operator
  23901. if v == nil {
  23902. return
  23903. }
  23904. return *v, true
  23905. }
  23906. // ResetConditionOperator resets all changes to the "condition_operator" field.
  23907. func (m *SopStageMutation) ResetConditionOperator() {
  23908. m.condition_operator = nil
  23909. m.addcondition_operator = nil
  23910. }
  23911. // SetConditionList sets the "condition_list" field.
  23912. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  23913. m.condition_list = &ct
  23914. m.appendcondition_list = nil
  23915. }
  23916. // ConditionList returns the value of the "condition_list" field in the mutation.
  23917. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  23918. v := m.condition_list
  23919. if v == nil {
  23920. return
  23921. }
  23922. return *v, true
  23923. }
  23924. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  23925. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23927. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  23928. if !m.op.Is(OpUpdateOne) {
  23929. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23930. }
  23931. if m.id == nil || m.oldValue == nil {
  23932. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23933. }
  23934. oldValue, err := m.oldValue(ctx)
  23935. if err != nil {
  23936. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23937. }
  23938. return oldValue.ConditionList, nil
  23939. }
  23940. // AppendConditionList adds ct to the "condition_list" field.
  23941. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  23942. m.appendcondition_list = append(m.appendcondition_list, ct...)
  23943. }
  23944. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23945. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  23946. if len(m.appendcondition_list) == 0 {
  23947. return nil, false
  23948. }
  23949. return m.appendcondition_list, true
  23950. }
  23951. // ResetConditionList resets all changes to the "condition_list" field.
  23952. func (m *SopStageMutation) ResetConditionList() {
  23953. m.condition_list = nil
  23954. m.appendcondition_list = nil
  23955. }
  23956. // SetActionMessage sets the "action_message" field.
  23957. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  23958. m.action_message = &ct
  23959. m.appendaction_message = nil
  23960. }
  23961. // ActionMessage returns the value of the "action_message" field in the mutation.
  23962. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23963. v := m.action_message
  23964. if v == nil {
  23965. return
  23966. }
  23967. return *v, true
  23968. }
  23969. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  23970. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23972. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23973. if !m.op.Is(OpUpdateOne) {
  23974. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23975. }
  23976. if m.id == nil || m.oldValue == nil {
  23977. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23978. }
  23979. oldValue, err := m.oldValue(ctx)
  23980. if err != nil {
  23981. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23982. }
  23983. return oldValue.ActionMessage, nil
  23984. }
  23985. // AppendActionMessage adds ct to the "action_message" field.
  23986. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  23987. m.appendaction_message = append(m.appendaction_message, ct...)
  23988. }
  23989. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23990. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23991. if len(m.appendaction_message) == 0 {
  23992. return nil, false
  23993. }
  23994. return m.appendaction_message, true
  23995. }
  23996. // ClearActionMessage clears the value of the "action_message" field.
  23997. func (m *SopStageMutation) ClearActionMessage() {
  23998. m.action_message = nil
  23999. m.appendaction_message = nil
  24000. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  24001. }
  24002. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  24003. func (m *SopStageMutation) ActionMessageCleared() bool {
  24004. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  24005. return ok
  24006. }
  24007. // ResetActionMessage resets all changes to the "action_message" field.
  24008. func (m *SopStageMutation) ResetActionMessage() {
  24009. m.action_message = nil
  24010. m.appendaction_message = nil
  24011. delete(m.clearedFields, sopstage.FieldActionMessage)
  24012. }
  24013. // SetActionLabelAdd sets the "action_label_add" field.
  24014. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  24015. m.action_label_add = &u
  24016. m.appendaction_label_add = nil
  24017. }
  24018. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  24019. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  24020. v := m.action_label_add
  24021. if v == nil {
  24022. return
  24023. }
  24024. return *v, true
  24025. }
  24026. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  24027. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24029. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  24030. if !m.op.Is(OpUpdateOne) {
  24031. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  24032. }
  24033. if m.id == nil || m.oldValue == nil {
  24034. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  24035. }
  24036. oldValue, err := m.oldValue(ctx)
  24037. if err != nil {
  24038. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  24039. }
  24040. return oldValue.ActionLabelAdd, nil
  24041. }
  24042. // AppendActionLabelAdd adds u to the "action_label_add" field.
  24043. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  24044. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  24045. }
  24046. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  24047. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  24048. if len(m.appendaction_label_add) == 0 {
  24049. return nil, false
  24050. }
  24051. return m.appendaction_label_add, true
  24052. }
  24053. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  24054. func (m *SopStageMutation) ClearActionLabelAdd() {
  24055. m.action_label_add = nil
  24056. m.appendaction_label_add = nil
  24057. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  24058. }
  24059. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  24060. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  24061. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  24062. return ok
  24063. }
  24064. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  24065. func (m *SopStageMutation) ResetActionLabelAdd() {
  24066. m.action_label_add = nil
  24067. m.appendaction_label_add = nil
  24068. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  24069. }
  24070. // SetActionLabelDel sets the "action_label_del" field.
  24071. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  24072. m.action_label_del = &u
  24073. m.appendaction_label_del = nil
  24074. }
  24075. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  24076. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  24077. v := m.action_label_del
  24078. if v == nil {
  24079. return
  24080. }
  24081. return *v, true
  24082. }
  24083. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  24084. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24086. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  24087. if !m.op.Is(OpUpdateOne) {
  24088. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  24089. }
  24090. if m.id == nil || m.oldValue == nil {
  24091. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  24092. }
  24093. oldValue, err := m.oldValue(ctx)
  24094. if err != nil {
  24095. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  24096. }
  24097. return oldValue.ActionLabelDel, nil
  24098. }
  24099. // AppendActionLabelDel adds u to the "action_label_del" field.
  24100. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  24101. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  24102. }
  24103. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  24104. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  24105. if len(m.appendaction_label_del) == 0 {
  24106. return nil, false
  24107. }
  24108. return m.appendaction_label_del, true
  24109. }
  24110. // ClearActionLabelDel clears the value of the "action_label_del" field.
  24111. func (m *SopStageMutation) ClearActionLabelDel() {
  24112. m.action_label_del = nil
  24113. m.appendaction_label_del = nil
  24114. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  24115. }
  24116. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  24117. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  24118. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  24119. return ok
  24120. }
  24121. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  24122. func (m *SopStageMutation) ResetActionLabelDel() {
  24123. m.action_label_del = nil
  24124. m.appendaction_label_del = nil
  24125. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  24126. }
  24127. // SetActionForward sets the "action_forward" field.
  24128. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  24129. m.action_forward = &ctf
  24130. }
  24131. // ActionForward returns the value of the "action_forward" field in the mutation.
  24132. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  24133. v := m.action_forward
  24134. if v == nil {
  24135. return
  24136. }
  24137. return *v, true
  24138. }
  24139. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  24140. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24142. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  24143. if !m.op.Is(OpUpdateOne) {
  24144. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  24145. }
  24146. if m.id == nil || m.oldValue == nil {
  24147. return v, errors.New("OldActionForward requires an ID field in the mutation")
  24148. }
  24149. oldValue, err := m.oldValue(ctx)
  24150. if err != nil {
  24151. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  24152. }
  24153. return oldValue.ActionForward, nil
  24154. }
  24155. // ClearActionForward clears the value of the "action_forward" field.
  24156. func (m *SopStageMutation) ClearActionForward() {
  24157. m.action_forward = nil
  24158. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  24159. }
  24160. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  24161. func (m *SopStageMutation) ActionForwardCleared() bool {
  24162. _, ok := m.clearedFields[sopstage.FieldActionForward]
  24163. return ok
  24164. }
  24165. // ResetActionForward resets all changes to the "action_forward" field.
  24166. func (m *SopStageMutation) ResetActionForward() {
  24167. m.action_forward = nil
  24168. delete(m.clearedFields, sopstage.FieldActionForward)
  24169. }
  24170. // SetIndexSort sets the "index_sort" field.
  24171. func (m *SopStageMutation) SetIndexSort(i int) {
  24172. m.index_sort = &i
  24173. m.addindex_sort = nil
  24174. }
  24175. // IndexSort returns the value of the "index_sort" field in the mutation.
  24176. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  24177. v := m.index_sort
  24178. if v == nil {
  24179. return
  24180. }
  24181. return *v, true
  24182. }
  24183. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  24184. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24186. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  24187. if !m.op.Is(OpUpdateOne) {
  24188. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  24189. }
  24190. if m.id == nil || m.oldValue == nil {
  24191. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  24192. }
  24193. oldValue, err := m.oldValue(ctx)
  24194. if err != nil {
  24195. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  24196. }
  24197. return oldValue.IndexSort, nil
  24198. }
  24199. // AddIndexSort adds i to the "index_sort" field.
  24200. func (m *SopStageMutation) AddIndexSort(i int) {
  24201. if m.addindex_sort != nil {
  24202. *m.addindex_sort += i
  24203. } else {
  24204. m.addindex_sort = &i
  24205. }
  24206. }
  24207. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  24208. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  24209. v := m.addindex_sort
  24210. if v == nil {
  24211. return
  24212. }
  24213. return *v, true
  24214. }
  24215. // ClearIndexSort clears the value of the "index_sort" field.
  24216. func (m *SopStageMutation) ClearIndexSort() {
  24217. m.index_sort = nil
  24218. m.addindex_sort = nil
  24219. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  24220. }
  24221. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  24222. func (m *SopStageMutation) IndexSortCleared() bool {
  24223. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  24224. return ok
  24225. }
  24226. // ResetIndexSort resets all changes to the "index_sort" field.
  24227. func (m *SopStageMutation) ResetIndexSort() {
  24228. m.index_sort = nil
  24229. m.addindex_sort = nil
  24230. delete(m.clearedFields, sopstage.FieldIndexSort)
  24231. }
  24232. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  24233. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  24234. m.sop_task = &id
  24235. }
  24236. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  24237. func (m *SopStageMutation) ClearSopTask() {
  24238. m.clearedsop_task = true
  24239. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  24240. }
  24241. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  24242. func (m *SopStageMutation) SopTaskCleared() bool {
  24243. return m.clearedsop_task
  24244. }
  24245. // SopTaskID returns the "sop_task" edge ID in the mutation.
  24246. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  24247. if m.sop_task != nil {
  24248. return *m.sop_task, true
  24249. }
  24250. return
  24251. }
  24252. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  24253. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24254. // SopTaskID instead. It exists only for internal usage by the builders.
  24255. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  24256. if id := m.sop_task; id != nil {
  24257. ids = append(ids, *id)
  24258. }
  24259. return
  24260. }
  24261. // ResetSopTask resets all changes to the "sop_task" edge.
  24262. func (m *SopStageMutation) ResetSopTask() {
  24263. m.sop_task = nil
  24264. m.clearedsop_task = false
  24265. }
  24266. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  24267. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  24268. if m.stage_nodes == nil {
  24269. m.stage_nodes = make(map[uint64]struct{})
  24270. }
  24271. for i := range ids {
  24272. m.stage_nodes[ids[i]] = struct{}{}
  24273. }
  24274. }
  24275. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  24276. func (m *SopStageMutation) ClearStageNodes() {
  24277. m.clearedstage_nodes = true
  24278. }
  24279. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  24280. func (m *SopStageMutation) StageNodesCleared() bool {
  24281. return m.clearedstage_nodes
  24282. }
  24283. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  24284. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  24285. if m.removedstage_nodes == nil {
  24286. m.removedstage_nodes = make(map[uint64]struct{})
  24287. }
  24288. for i := range ids {
  24289. delete(m.stage_nodes, ids[i])
  24290. m.removedstage_nodes[ids[i]] = struct{}{}
  24291. }
  24292. }
  24293. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  24294. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  24295. for id := range m.removedstage_nodes {
  24296. ids = append(ids, id)
  24297. }
  24298. return
  24299. }
  24300. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  24301. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  24302. for id := range m.stage_nodes {
  24303. ids = append(ids, id)
  24304. }
  24305. return
  24306. }
  24307. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  24308. func (m *SopStageMutation) ResetStageNodes() {
  24309. m.stage_nodes = nil
  24310. m.clearedstage_nodes = false
  24311. m.removedstage_nodes = nil
  24312. }
  24313. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  24314. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  24315. if m.stage_messages == nil {
  24316. m.stage_messages = make(map[uint64]struct{})
  24317. }
  24318. for i := range ids {
  24319. m.stage_messages[ids[i]] = struct{}{}
  24320. }
  24321. }
  24322. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  24323. func (m *SopStageMutation) ClearStageMessages() {
  24324. m.clearedstage_messages = true
  24325. }
  24326. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  24327. func (m *SopStageMutation) StageMessagesCleared() bool {
  24328. return m.clearedstage_messages
  24329. }
  24330. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  24331. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  24332. if m.removedstage_messages == nil {
  24333. m.removedstage_messages = make(map[uint64]struct{})
  24334. }
  24335. for i := range ids {
  24336. delete(m.stage_messages, ids[i])
  24337. m.removedstage_messages[ids[i]] = struct{}{}
  24338. }
  24339. }
  24340. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  24341. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  24342. for id := range m.removedstage_messages {
  24343. ids = append(ids, id)
  24344. }
  24345. return
  24346. }
  24347. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  24348. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  24349. for id := range m.stage_messages {
  24350. ids = append(ids, id)
  24351. }
  24352. return
  24353. }
  24354. // ResetStageMessages resets all changes to the "stage_messages" edge.
  24355. func (m *SopStageMutation) ResetStageMessages() {
  24356. m.stage_messages = nil
  24357. m.clearedstage_messages = false
  24358. m.removedstage_messages = nil
  24359. }
  24360. // Where appends a list predicates to the SopStageMutation builder.
  24361. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  24362. m.predicates = append(m.predicates, ps...)
  24363. }
  24364. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  24365. // users can use type-assertion to append predicates that do not depend on any generated package.
  24366. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  24367. p := make([]predicate.SopStage, len(ps))
  24368. for i := range ps {
  24369. p[i] = ps[i]
  24370. }
  24371. m.Where(p...)
  24372. }
  24373. // Op returns the operation name.
  24374. func (m *SopStageMutation) Op() Op {
  24375. return m.op
  24376. }
  24377. // SetOp allows setting the mutation operation.
  24378. func (m *SopStageMutation) SetOp(op Op) {
  24379. m.op = op
  24380. }
  24381. // Type returns the node type of this mutation (SopStage).
  24382. func (m *SopStageMutation) Type() string {
  24383. return m.typ
  24384. }
  24385. // Fields returns all fields that were changed during this mutation. Note that in
  24386. // order to get all numeric fields that were incremented/decremented, call
  24387. // AddedFields().
  24388. func (m *SopStageMutation) Fields() []string {
  24389. fields := make([]string, 0, 14)
  24390. if m.created_at != nil {
  24391. fields = append(fields, sopstage.FieldCreatedAt)
  24392. }
  24393. if m.updated_at != nil {
  24394. fields = append(fields, sopstage.FieldUpdatedAt)
  24395. }
  24396. if m.status != nil {
  24397. fields = append(fields, sopstage.FieldStatus)
  24398. }
  24399. if m.deleted_at != nil {
  24400. fields = append(fields, sopstage.FieldDeletedAt)
  24401. }
  24402. if m.sop_task != nil {
  24403. fields = append(fields, sopstage.FieldTaskID)
  24404. }
  24405. if m.name != nil {
  24406. fields = append(fields, sopstage.FieldName)
  24407. }
  24408. if m.condition_type != nil {
  24409. fields = append(fields, sopstage.FieldConditionType)
  24410. }
  24411. if m.condition_operator != nil {
  24412. fields = append(fields, sopstage.FieldConditionOperator)
  24413. }
  24414. if m.condition_list != nil {
  24415. fields = append(fields, sopstage.FieldConditionList)
  24416. }
  24417. if m.action_message != nil {
  24418. fields = append(fields, sopstage.FieldActionMessage)
  24419. }
  24420. if m.action_label_add != nil {
  24421. fields = append(fields, sopstage.FieldActionLabelAdd)
  24422. }
  24423. if m.action_label_del != nil {
  24424. fields = append(fields, sopstage.FieldActionLabelDel)
  24425. }
  24426. if m.action_forward != nil {
  24427. fields = append(fields, sopstage.FieldActionForward)
  24428. }
  24429. if m.index_sort != nil {
  24430. fields = append(fields, sopstage.FieldIndexSort)
  24431. }
  24432. return fields
  24433. }
  24434. // Field returns the value of a field with the given name. The second boolean
  24435. // return value indicates that this field was not set, or was not defined in the
  24436. // schema.
  24437. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  24438. switch name {
  24439. case sopstage.FieldCreatedAt:
  24440. return m.CreatedAt()
  24441. case sopstage.FieldUpdatedAt:
  24442. return m.UpdatedAt()
  24443. case sopstage.FieldStatus:
  24444. return m.Status()
  24445. case sopstage.FieldDeletedAt:
  24446. return m.DeletedAt()
  24447. case sopstage.FieldTaskID:
  24448. return m.TaskID()
  24449. case sopstage.FieldName:
  24450. return m.Name()
  24451. case sopstage.FieldConditionType:
  24452. return m.ConditionType()
  24453. case sopstage.FieldConditionOperator:
  24454. return m.ConditionOperator()
  24455. case sopstage.FieldConditionList:
  24456. return m.ConditionList()
  24457. case sopstage.FieldActionMessage:
  24458. return m.ActionMessage()
  24459. case sopstage.FieldActionLabelAdd:
  24460. return m.ActionLabelAdd()
  24461. case sopstage.FieldActionLabelDel:
  24462. return m.ActionLabelDel()
  24463. case sopstage.FieldActionForward:
  24464. return m.ActionForward()
  24465. case sopstage.FieldIndexSort:
  24466. return m.IndexSort()
  24467. }
  24468. return nil, false
  24469. }
  24470. // OldField returns the old value of the field from the database. An error is
  24471. // returned if the mutation operation is not UpdateOne, or the query to the
  24472. // database failed.
  24473. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24474. switch name {
  24475. case sopstage.FieldCreatedAt:
  24476. return m.OldCreatedAt(ctx)
  24477. case sopstage.FieldUpdatedAt:
  24478. return m.OldUpdatedAt(ctx)
  24479. case sopstage.FieldStatus:
  24480. return m.OldStatus(ctx)
  24481. case sopstage.FieldDeletedAt:
  24482. return m.OldDeletedAt(ctx)
  24483. case sopstage.FieldTaskID:
  24484. return m.OldTaskID(ctx)
  24485. case sopstage.FieldName:
  24486. return m.OldName(ctx)
  24487. case sopstage.FieldConditionType:
  24488. return m.OldConditionType(ctx)
  24489. case sopstage.FieldConditionOperator:
  24490. return m.OldConditionOperator(ctx)
  24491. case sopstage.FieldConditionList:
  24492. return m.OldConditionList(ctx)
  24493. case sopstage.FieldActionMessage:
  24494. return m.OldActionMessage(ctx)
  24495. case sopstage.FieldActionLabelAdd:
  24496. return m.OldActionLabelAdd(ctx)
  24497. case sopstage.FieldActionLabelDel:
  24498. return m.OldActionLabelDel(ctx)
  24499. case sopstage.FieldActionForward:
  24500. return m.OldActionForward(ctx)
  24501. case sopstage.FieldIndexSort:
  24502. return m.OldIndexSort(ctx)
  24503. }
  24504. return nil, fmt.Errorf("unknown SopStage field %s", name)
  24505. }
  24506. // SetField sets the value of a field with the given name. It returns an error if
  24507. // the field is not defined in the schema, or if the type mismatched the field
  24508. // type.
  24509. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  24510. switch name {
  24511. case sopstage.FieldCreatedAt:
  24512. v, ok := value.(time.Time)
  24513. if !ok {
  24514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24515. }
  24516. m.SetCreatedAt(v)
  24517. return nil
  24518. case sopstage.FieldUpdatedAt:
  24519. v, ok := value.(time.Time)
  24520. if !ok {
  24521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24522. }
  24523. m.SetUpdatedAt(v)
  24524. return nil
  24525. case sopstage.FieldStatus:
  24526. v, ok := value.(uint8)
  24527. if !ok {
  24528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24529. }
  24530. m.SetStatus(v)
  24531. return nil
  24532. case sopstage.FieldDeletedAt:
  24533. v, ok := value.(time.Time)
  24534. if !ok {
  24535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24536. }
  24537. m.SetDeletedAt(v)
  24538. return nil
  24539. case sopstage.FieldTaskID:
  24540. v, ok := value.(uint64)
  24541. if !ok {
  24542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24543. }
  24544. m.SetTaskID(v)
  24545. return nil
  24546. case sopstage.FieldName:
  24547. v, ok := value.(string)
  24548. if !ok {
  24549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24550. }
  24551. m.SetName(v)
  24552. return nil
  24553. case sopstage.FieldConditionType:
  24554. v, ok := value.(int)
  24555. if !ok {
  24556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24557. }
  24558. m.SetConditionType(v)
  24559. return nil
  24560. case sopstage.FieldConditionOperator:
  24561. v, ok := value.(int)
  24562. if !ok {
  24563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24564. }
  24565. m.SetConditionOperator(v)
  24566. return nil
  24567. case sopstage.FieldConditionList:
  24568. v, ok := value.([]custom_types.Condition)
  24569. if !ok {
  24570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24571. }
  24572. m.SetConditionList(v)
  24573. return nil
  24574. case sopstage.FieldActionMessage:
  24575. v, ok := value.([]custom_types.Action)
  24576. if !ok {
  24577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24578. }
  24579. m.SetActionMessage(v)
  24580. return nil
  24581. case sopstage.FieldActionLabelAdd:
  24582. v, ok := value.([]uint64)
  24583. if !ok {
  24584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24585. }
  24586. m.SetActionLabelAdd(v)
  24587. return nil
  24588. case sopstage.FieldActionLabelDel:
  24589. v, ok := value.([]uint64)
  24590. if !ok {
  24591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24592. }
  24593. m.SetActionLabelDel(v)
  24594. return nil
  24595. case sopstage.FieldActionForward:
  24596. v, ok := value.(*custom_types.ActionForward)
  24597. if !ok {
  24598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24599. }
  24600. m.SetActionForward(v)
  24601. return nil
  24602. case sopstage.FieldIndexSort:
  24603. v, ok := value.(int)
  24604. if !ok {
  24605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24606. }
  24607. m.SetIndexSort(v)
  24608. return nil
  24609. }
  24610. return fmt.Errorf("unknown SopStage field %s", name)
  24611. }
  24612. // AddedFields returns all numeric fields that were incremented/decremented during
  24613. // this mutation.
  24614. func (m *SopStageMutation) AddedFields() []string {
  24615. var fields []string
  24616. if m.addstatus != nil {
  24617. fields = append(fields, sopstage.FieldStatus)
  24618. }
  24619. if m.addcondition_type != nil {
  24620. fields = append(fields, sopstage.FieldConditionType)
  24621. }
  24622. if m.addcondition_operator != nil {
  24623. fields = append(fields, sopstage.FieldConditionOperator)
  24624. }
  24625. if m.addindex_sort != nil {
  24626. fields = append(fields, sopstage.FieldIndexSort)
  24627. }
  24628. return fields
  24629. }
  24630. // AddedField returns the numeric value that was incremented/decremented on a field
  24631. // with the given name. The second boolean return value indicates that this field
  24632. // was not set, or was not defined in the schema.
  24633. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  24634. switch name {
  24635. case sopstage.FieldStatus:
  24636. return m.AddedStatus()
  24637. case sopstage.FieldConditionType:
  24638. return m.AddedConditionType()
  24639. case sopstage.FieldConditionOperator:
  24640. return m.AddedConditionOperator()
  24641. case sopstage.FieldIndexSort:
  24642. return m.AddedIndexSort()
  24643. }
  24644. return nil, false
  24645. }
  24646. // AddField adds the value to the field with the given name. It returns an error if
  24647. // the field is not defined in the schema, or if the type mismatched the field
  24648. // type.
  24649. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  24650. switch name {
  24651. case sopstage.FieldStatus:
  24652. v, ok := value.(int8)
  24653. if !ok {
  24654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24655. }
  24656. m.AddStatus(v)
  24657. return nil
  24658. case sopstage.FieldConditionType:
  24659. v, ok := value.(int)
  24660. if !ok {
  24661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24662. }
  24663. m.AddConditionType(v)
  24664. return nil
  24665. case sopstage.FieldConditionOperator:
  24666. v, ok := value.(int)
  24667. if !ok {
  24668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24669. }
  24670. m.AddConditionOperator(v)
  24671. return nil
  24672. case sopstage.FieldIndexSort:
  24673. v, ok := value.(int)
  24674. if !ok {
  24675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24676. }
  24677. m.AddIndexSort(v)
  24678. return nil
  24679. }
  24680. return fmt.Errorf("unknown SopStage numeric field %s", name)
  24681. }
  24682. // ClearedFields returns all nullable fields that were cleared during this
  24683. // mutation.
  24684. func (m *SopStageMutation) ClearedFields() []string {
  24685. var fields []string
  24686. if m.FieldCleared(sopstage.FieldStatus) {
  24687. fields = append(fields, sopstage.FieldStatus)
  24688. }
  24689. if m.FieldCleared(sopstage.FieldDeletedAt) {
  24690. fields = append(fields, sopstage.FieldDeletedAt)
  24691. }
  24692. if m.FieldCleared(sopstage.FieldActionMessage) {
  24693. fields = append(fields, sopstage.FieldActionMessage)
  24694. }
  24695. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  24696. fields = append(fields, sopstage.FieldActionLabelAdd)
  24697. }
  24698. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  24699. fields = append(fields, sopstage.FieldActionLabelDel)
  24700. }
  24701. if m.FieldCleared(sopstage.FieldActionForward) {
  24702. fields = append(fields, sopstage.FieldActionForward)
  24703. }
  24704. if m.FieldCleared(sopstage.FieldIndexSort) {
  24705. fields = append(fields, sopstage.FieldIndexSort)
  24706. }
  24707. return fields
  24708. }
  24709. // FieldCleared returns a boolean indicating if a field with the given name was
  24710. // cleared in this mutation.
  24711. func (m *SopStageMutation) FieldCleared(name string) bool {
  24712. _, ok := m.clearedFields[name]
  24713. return ok
  24714. }
  24715. // ClearField clears the value of the field with the given name. It returns an
  24716. // error if the field is not defined in the schema.
  24717. func (m *SopStageMutation) ClearField(name string) error {
  24718. switch name {
  24719. case sopstage.FieldStatus:
  24720. m.ClearStatus()
  24721. return nil
  24722. case sopstage.FieldDeletedAt:
  24723. m.ClearDeletedAt()
  24724. return nil
  24725. case sopstage.FieldActionMessage:
  24726. m.ClearActionMessage()
  24727. return nil
  24728. case sopstage.FieldActionLabelAdd:
  24729. m.ClearActionLabelAdd()
  24730. return nil
  24731. case sopstage.FieldActionLabelDel:
  24732. m.ClearActionLabelDel()
  24733. return nil
  24734. case sopstage.FieldActionForward:
  24735. m.ClearActionForward()
  24736. return nil
  24737. case sopstage.FieldIndexSort:
  24738. m.ClearIndexSort()
  24739. return nil
  24740. }
  24741. return fmt.Errorf("unknown SopStage nullable field %s", name)
  24742. }
  24743. // ResetField resets all changes in the mutation for the field with the given name.
  24744. // It returns an error if the field is not defined in the schema.
  24745. func (m *SopStageMutation) ResetField(name string) error {
  24746. switch name {
  24747. case sopstage.FieldCreatedAt:
  24748. m.ResetCreatedAt()
  24749. return nil
  24750. case sopstage.FieldUpdatedAt:
  24751. m.ResetUpdatedAt()
  24752. return nil
  24753. case sopstage.FieldStatus:
  24754. m.ResetStatus()
  24755. return nil
  24756. case sopstage.FieldDeletedAt:
  24757. m.ResetDeletedAt()
  24758. return nil
  24759. case sopstage.FieldTaskID:
  24760. m.ResetTaskID()
  24761. return nil
  24762. case sopstage.FieldName:
  24763. m.ResetName()
  24764. return nil
  24765. case sopstage.FieldConditionType:
  24766. m.ResetConditionType()
  24767. return nil
  24768. case sopstage.FieldConditionOperator:
  24769. m.ResetConditionOperator()
  24770. return nil
  24771. case sopstage.FieldConditionList:
  24772. m.ResetConditionList()
  24773. return nil
  24774. case sopstage.FieldActionMessage:
  24775. m.ResetActionMessage()
  24776. return nil
  24777. case sopstage.FieldActionLabelAdd:
  24778. m.ResetActionLabelAdd()
  24779. return nil
  24780. case sopstage.FieldActionLabelDel:
  24781. m.ResetActionLabelDel()
  24782. return nil
  24783. case sopstage.FieldActionForward:
  24784. m.ResetActionForward()
  24785. return nil
  24786. case sopstage.FieldIndexSort:
  24787. m.ResetIndexSort()
  24788. return nil
  24789. }
  24790. return fmt.Errorf("unknown SopStage field %s", name)
  24791. }
  24792. // AddedEdges returns all edge names that were set/added in this mutation.
  24793. func (m *SopStageMutation) AddedEdges() []string {
  24794. edges := make([]string, 0, 3)
  24795. if m.sop_task != nil {
  24796. edges = append(edges, sopstage.EdgeSopTask)
  24797. }
  24798. if m.stage_nodes != nil {
  24799. edges = append(edges, sopstage.EdgeStageNodes)
  24800. }
  24801. if m.stage_messages != nil {
  24802. edges = append(edges, sopstage.EdgeStageMessages)
  24803. }
  24804. return edges
  24805. }
  24806. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24807. // name in this mutation.
  24808. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  24809. switch name {
  24810. case sopstage.EdgeSopTask:
  24811. if id := m.sop_task; id != nil {
  24812. return []ent.Value{*id}
  24813. }
  24814. case sopstage.EdgeStageNodes:
  24815. ids := make([]ent.Value, 0, len(m.stage_nodes))
  24816. for id := range m.stage_nodes {
  24817. ids = append(ids, id)
  24818. }
  24819. return ids
  24820. case sopstage.EdgeStageMessages:
  24821. ids := make([]ent.Value, 0, len(m.stage_messages))
  24822. for id := range m.stage_messages {
  24823. ids = append(ids, id)
  24824. }
  24825. return ids
  24826. }
  24827. return nil
  24828. }
  24829. // RemovedEdges returns all edge names that were removed in this mutation.
  24830. func (m *SopStageMutation) RemovedEdges() []string {
  24831. edges := make([]string, 0, 3)
  24832. if m.removedstage_nodes != nil {
  24833. edges = append(edges, sopstage.EdgeStageNodes)
  24834. }
  24835. if m.removedstage_messages != nil {
  24836. edges = append(edges, sopstage.EdgeStageMessages)
  24837. }
  24838. return edges
  24839. }
  24840. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24841. // the given name in this mutation.
  24842. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  24843. switch name {
  24844. case sopstage.EdgeStageNodes:
  24845. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  24846. for id := range m.removedstage_nodes {
  24847. ids = append(ids, id)
  24848. }
  24849. return ids
  24850. case sopstage.EdgeStageMessages:
  24851. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  24852. for id := range m.removedstage_messages {
  24853. ids = append(ids, id)
  24854. }
  24855. return ids
  24856. }
  24857. return nil
  24858. }
  24859. // ClearedEdges returns all edge names that were cleared in this mutation.
  24860. func (m *SopStageMutation) ClearedEdges() []string {
  24861. edges := make([]string, 0, 3)
  24862. if m.clearedsop_task {
  24863. edges = append(edges, sopstage.EdgeSopTask)
  24864. }
  24865. if m.clearedstage_nodes {
  24866. edges = append(edges, sopstage.EdgeStageNodes)
  24867. }
  24868. if m.clearedstage_messages {
  24869. edges = append(edges, sopstage.EdgeStageMessages)
  24870. }
  24871. return edges
  24872. }
  24873. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24874. // was cleared in this mutation.
  24875. func (m *SopStageMutation) EdgeCleared(name string) bool {
  24876. switch name {
  24877. case sopstage.EdgeSopTask:
  24878. return m.clearedsop_task
  24879. case sopstage.EdgeStageNodes:
  24880. return m.clearedstage_nodes
  24881. case sopstage.EdgeStageMessages:
  24882. return m.clearedstage_messages
  24883. }
  24884. return false
  24885. }
  24886. // ClearEdge clears the value of the edge with the given name. It returns an error
  24887. // if that edge is not defined in the schema.
  24888. func (m *SopStageMutation) ClearEdge(name string) error {
  24889. switch name {
  24890. case sopstage.EdgeSopTask:
  24891. m.ClearSopTask()
  24892. return nil
  24893. }
  24894. return fmt.Errorf("unknown SopStage unique edge %s", name)
  24895. }
  24896. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24897. // It returns an error if the edge is not defined in the schema.
  24898. func (m *SopStageMutation) ResetEdge(name string) error {
  24899. switch name {
  24900. case sopstage.EdgeSopTask:
  24901. m.ResetSopTask()
  24902. return nil
  24903. case sopstage.EdgeStageNodes:
  24904. m.ResetStageNodes()
  24905. return nil
  24906. case sopstage.EdgeStageMessages:
  24907. m.ResetStageMessages()
  24908. return nil
  24909. }
  24910. return fmt.Errorf("unknown SopStage edge %s", name)
  24911. }
  24912. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  24913. type SopTaskMutation struct {
  24914. config
  24915. op Op
  24916. typ string
  24917. id *uint64
  24918. created_at *time.Time
  24919. updated_at *time.Time
  24920. status *uint8
  24921. addstatus *int8
  24922. deleted_at *time.Time
  24923. name *string
  24924. bot_wxid_list *[]string
  24925. appendbot_wxid_list []string
  24926. _type *int
  24927. add_type *int
  24928. plan_start_time *time.Time
  24929. plan_end_time *time.Time
  24930. creator_id *string
  24931. organization_id *uint64
  24932. addorganization_id *int64
  24933. token *[]string
  24934. appendtoken []string
  24935. clearedFields map[string]struct{}
  24936. task_stages map[uint64]struct{}
  24937. removedtask_stages map[uint64]struct{}
  24938. clearedtask_stages bool
  24939. done bool
  24940. oldValue func(context.Context) (*SopTask, error)
  24941. predicates []predicate.SopTask
  24942. }
  24943. var _ ent.Mutation = (*SopTaskMutation)(nil)
  24944. // soptaskOption allows management of the mutation configuration using functional options.
  24945. type soptaskOption func(*SopTaskMutation)
  24946. // newSopTaskMutation creates new mutation for the SopTask entity.
  24947. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  24948. m := &SopTaskMutation{
  24949. config: c,
  24950. op: op,
  24951. typ: TypeSopTask,
  24952. clearedFields: make(map[string]struct{}),
  24953. }
  24954. for _, opt := range opts {
  24955. opt(m)
  24956. }
  24957. return m
  24958. }
  24959. // withSopTaskID sets the ID field of the mutation.
  24960. func withSopTaskID(id uint64) soptaskOption {
  24961. return func(m *SopTaskMutation) {
  24962. var (
  24963. err error
  24964. once sync.Once
  24965. value *SopTask
  24966. )
  24967. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  24968. once.Do(func() {
  24969. if m.done {
  24970. err = errors.New("querying old values post mutation is not allowed")
  24971. } else {
  24972. value, err = m.Client().SopTask.Get(ctx, id)
  24973. }
  24974. })
  24975. return value, err
  24976. }
  24977. m.id = &id
  24978. }
  24979. }
  24980. // withSopTask sets the old SopTask of the mutation.
  24981. func withSopTask(node *SopTask) soptaskOption {
  24982. return func(m *SopTaskMutation) {
  24983. m.oldValue = func(context.Context) (*SopTask, error) {
  24984. return node, nil
  24985. }
  24986. m.id = &node.ID
  24987. }
  24988. }
  24989. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24990. // executed in a transaction (ent.Tx), a transactional client is returned.
  24991. func (m SopTaskMutation) Client() *Client {
  24992. client := &Client{config: m.config}
  24993. client.init()
  24994. return client
  24995. }
  24996. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24997. // it returns an error otherwise.
  24998. func (m SopTaskMutation) Tx() (*Tx, error) {
  24999. if _, ok := m.driver.(*txDriver); !ok {
  25000. return nil, errors.New("ent: mutation is not running in a transaction")
  25001. }
  25002. tx := &Tx{config: m.config}
  25003. tx.init()
  25004. return tx, nil
  25005. }
  25006. // SetID sets the value of the id field. Note that this
  25007. // operation is only accepted on creation of SopTask entities.
  25008. func (m *SopTaskMutation) SetID(id uint64) {
  25009. m.id = &id
  25010. }
  25011. // ID returns the ID value in the mutation. Note that the ID is only available
  25012. // if it was provided to the builder or after it was returned from the database.
  25013. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  25014. if m.id == nil {
  25015. return
  25016. }
  25017. return *m.id, true
  25018. }
  25019. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25020. // That means, if the mutation is applied within a transaction with an isolation level such
  25021. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25022. // or updated by the mutation.
  25023. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  25024. switch {
  25025. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25026. id, exists := m.ID()
  25027. if exists {
  25028. return []uint64{id}, nil
  25029. }
  25030. fallthrough
  25031. case m.op.Is(OpUpdate | OpDelete):
  25032. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  25033. default:
  25034. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25035. }
  25036. }
  25037. // SetCreatedAt sets the "created_at" field.
  25038. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  25039. m.created_at = &t
  25040. }
  25041. // CreatedAt returns the value of the "created_at" field in the mutation.
  25042. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  25043. v := m.created_at
  25044. if v == nil {
  25045. return
  25046. }
  25047. return *v, true
  25048. }
  25049. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  25050. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25052. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25053. if !m.op.Is(OpUpdateOne) {
  25054. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25055. }
  25056. if m.id == nil || m.oldValue == nil {
  25057. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25058. }
  25059. oldValue, err := m.oldValue(ctx)
  25060. if err != nil {
  25061. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25062. }
  25063. return oldValue.CreatedAt, nil
  25064. }
  25065. // ResetCreatedAt resets all changes to the "created_at" field.
  25066. func (m *SopTaskMutation) ResetCreatedAt() {
  25067. m.created_at = nil
  25068. }
  25069. // SetUpdatedAt sets the "updated_at" field.
  25070. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  25071. m.updated_at = &t
  25072. }
  25073. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25074. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  25075. v := m.updated_at
  25076. if v == nil {
  25077. return
  25078. }
  25079. return *v, true
  25080. }
  25081. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  25082. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25084. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25085. if !m.op.Is(OpUpdateOne) {
  25086. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25087. }
  25088. if m.id == nil || m.oldValue == nil {
  25089. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25090. }
  25091. oldValue, err := m.oldValue(ctx)
  25092. if err != nil {
  25093. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25094. }
  25095. return oldValue.UpdatedAt, nil
  25096. }
  25097. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25098. func (m *SopTaskMutation) ResetUpdatedAt() {
  25099. m.updated_at = nil
  25100. }
  25101. // SetStatus sets the "status" field.
  25102. func (m *SopTaskMutation) SetStatus(u uint8) {
  25103. m.status = &u
  25104. m.addstatus = nil
  25105. }
  25106. // Status returns the value of the "status" field in the mutation.
  25107. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  25108. v := m.status
  25109. if v == nil {
  25110. return
  25111. }
  25112. return *v, true
  25113. }
  25114. // OldStatus returns the old "status" field's value of the SopTask entity.
  25115. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25117. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25118. if !m.op.Is(OpUpdateOne) {
  25119. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25120. }
  25121. if m.id == nil || m.oldValue == nil {
  25122. return v, errors.New("OldStatus requires an ID field in the mutation")
  25123. }
  25124. oldValue, err := m.oldValue(ctx)
  25125. if err != nil {
  25126. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25127. }
  25128. return oldValue.Status, nil
  25129. }
  25130. // AddStatus adds u to the "status" field.
  25131. func (m *SopTaskMutation) AddStatus(u int8) {
  25132. if m.addstatus != nil {
  25133. *m.addstatus += u
  25134. } else {
  25135. m.addstatus = &u
  25136. }
  25137. }
  25138. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25139. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  25140. v := m.addstatus
  25141. if v == nil {
  25142. return
  25143. }
  25144. return *v, true
  25145. }
  25146. // ClearStatus clears the value of the "status" field.
  25147. func (m *SopTaskMutation) ClearStatus() {
  25148. m.status = nil
  25149. m.addstatus = nil
  25150. m.clearedFields[soptask.FieldStatus] = struct{}{}
  25151. }
  25152. // StatusCleared returns if the "status" field was cleared in this mutation.
  25153. func (m *SopTaskMutation) StatusCleared() bool {
  25154. _, ok := m.clearedFields[soptask.FieldStatus]
  25155. return ok
  25156. }
  25157. // ResetStatus resets all changes to the "status" field.
  25158. func (m *SopTaskMutation) ResetStatus() {
  25159. m.status = nil
  25160. m.addstatus = nil
  25161. delete(m.clearedFields, soptask.FieldStatus)
  25162. }
  25163. // SetDeletedAt sets the "deleted_at" field.
  25164. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  25165. m.deleted_at = &t
  25166. }
  25167. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25168. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  25169. v := m.deleted_at
  25170. if v == nil {
  25171. return
  25172. }
  25173. return *v, true
  25174. }
  25175. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  25176. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25178. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25179. if !m.op.Is(OpUpdateOne) {
  25180. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25181. }
  25182. if m.id == nil || m.oldValue == nil {
  25183. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25184. }
  25185. oldValue, err := m.oldValue(ctx)
  25186. if err != nil {
  25187. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25188. }
  25189. return oldValue.DeletedAt, nil
  25190. }
  25191. // ClearDeletedAt clears the value of the "deleted_at" field.
  25192. func (m *SopTaskMutation) ClearDeletedAt() {
  25193. m.deleted_at = nil
  25194. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  25195. }
  25196. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25197. func (m *SopTaskMutation) DeletedAtCleared() bool {
  25198. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  25199. return ok
  25200. }
  25201. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25202. func (m *SopTaskMutation) ResetDeletedAt() {
  25203. m.deleted_at = nil
  25204. delete(m.clearedFields, soptask.FieldDeletedAt)
  25205. }
  25206. // SetName sets the "name" field.
  25207. func (m *SopTaskMutation) SetName(s string) {
  25208. m.name = &s
  25209. }
  25210. // Name returns the value of the "name" field in the mutation.
  25211. func (m *SopTaskMutation) Name() (r string, exists bool) {
  25212. v := m.name
  25213. if v == nil {
  25214. return
  25215. }
  25216. return *v, true
  25217. }
  25218. // OldName returns the old "name" field's value of the SopTask entity.
  25219. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25221. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  25222. if !m.op.Is(OpUpdateOne) {
  25223. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25224. }
  25225. if m.id == nil || m.oldValue == nil {
  25226. return v, errors.New("OldName requires an ID field in the mutation")
  25227. }
  25228. oldValue, err := m.oldValue(ctx)
  25229. if err != nil {
  25230. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25231. }
  25232. return oldValue.Name, nil
  25233. }
  25234. // ResetName resets all changes to the "name" field.
  25235. func (m *SopTaskMutation) ResetName() {
  25236. m.name = nil
  25237. }
  25238. // SetBotWxidList sets the "bot_wxid_list" field.
  25239. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  25240. m.bot_wxid_list = &s
  25241. m.appendbot_wxid_list = nil
  25242. }
  25243. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  25244. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  25245. v := m.bot_wxid_list
  25246. if v == nil {
  25247. return
  25248. }
  25249. return *v, true
  25250. }
  25251. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  25252. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25254. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  25255. if !m.op.Is(OpUpdateOne) {
  25256. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  25257. }
  25258. if m.id == nil || m.oldValue == nil {
  25259. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  25260. }
  25261. oldValue, err := m.oldValue(ctx)
  25262. if err != nil {
  25263. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  25264. }
  25265. return oldValue.BotWxidList, nil
  25266. }
  25267. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  25268. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  25269. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  25270. }
  25271. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  25272. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  25273. if len(m.appendbot_wxid_list) == 0 {
  25274. return nil, false
  25275. }
  25276. return m.appendbot_wxid_list, true
  25277. }
  25278. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  25279. func (m *SopTaskMutation) ClearBotWxidList() {
  25280. m.bot_wxid_list = nil
  25281. m.appendbot_wxid_list = nil
  25282. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  25283. }
  25284. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  25285. func (m *SopTaskMutation) BotWxidListCleared() bool {
  25286. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  25287. return ok
  25288. }
  25289. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  25290. func (m *SopTaskMutation) ResetBotWxidList() {
  25291. m.bot_wxid_list = nil
  25292. m.appendbot_wxid_list = nil
  25293. delete(m.clearedFields, soptask.FieldBotWxidList)
  25294. }
  25295. // SetType sets the "type" field.
  25296. func (m *SopTaskMutation) SetType(i int) {
  25297. m._type = &i
  25298. m.add_type = nil
  25299. }
  25300. // GetType returns the value of the "type" field in the mutation.
  25301. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  25302. v := m._type
  25303. if v == nil {
  25304. return
  25305. }
  25306. return *v, true
  25307. }
  25308. // OldType returns the old "type" field's value of the SopTask entity.
  25309. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25311. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  25312. if !m.op.Is(OpUpdateOne) {
  25313. return v, errors.New("OldType is only allowed on UpdateOne operations")
  25314. }
  25315. if m.id == nil || m.oldValue == nil {
  25316. return v, errors.New("OldType requires an ID field in the mutation")
  25317. }
  25318. oldValue, err := m.oldValue(ctx)
  25319. if err != nil {
  25320. return v, fmt.Errorf("querying old value for OldType: %w", err)
  25321. }
  25322. return oldValue.Type, nil
  25323. }
  25324. // AddType adds i to the "type" field.
  25325. func (m *SopTaskMutation) AddType(i int) {
  25326. if m.add_type != nil {
  25327. *m.add_type += i
  25328. } else {
  25329. m.add_type = &i
  25330. }
  25331. }
  25332. // AddedType returns the value that was added to the "type" field in this mutation.
  25333. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  25334. v := m.add_type
  25335. if v == nil {
  25336. return
  25337. }
  25338. return *v, true
  25339. }
  25340. // ResetType resets all changes to the "type" field.
  25341. func (m *SopTaskMutation) ResetType() {
  25342. m._type = nil
  25343. m.add_type = nil
  25344. }
  25345. // SetPlanStartTime sets the "plan_start_time" field.
  25346. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  25347. m.plan_start_time = &t
  25348. }
  25349. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  25350. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  25351. v := m.plan_start_time
  25352. if v == nil {
  25353. return
  25354. }
  25355. return *v, true
  25356. }
  25357. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  25358. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25360. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  25361. if !m.op.Is(OpUpdateOne) {
  25362. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  25363. }
  25364. if m.id == nil || m.oldValue == nil {
  25365. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  25366. }
  25367. oldValue, err := m.oldValue(ctx)
  25368. if err != nil {
  25369. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  25370. }
  25371. return oldValue.PlanStartTime, nil
  25372. }
  25373. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  25374. func (m *SopTaskMutation) ClearPlanStartTime() {
  25375. m.plan_start_time = nil
  25376. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  25377. }
  25378. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  25379. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  25380. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  25381. return ok
  25382. }
  25383. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  25384. func (m *SopTaskMutation) ResetPlanStartTime() {
  25385. m.plan_start_time = nil
  25386. delete(m.clearedFields, soptask.FieldPlanStartTime)
  25387. }
  25388. // SetPlanEndTime sets the "plan_end_time" field.
  25389. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  25390. m.plan_end_time = &t
  25391. }
  25392. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  25393. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  25394. v := m.plan_end_time
  25395. if v == nil {
  25396. return
  25397. }
  25398. return *v, true
  25399. }
  25400. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  25401. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25403. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  25404. if !m.op.Is(OpUpdateOne) {
  25405. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  25406. }
  25407. if m.id == nil || m.oldValue == nil {
  25408. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  25409. }
  25410. oldValue, err := m.oldValue(ctx)
  25411. if err != nil {
  25412. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  25413. }
  25414. return oldValue.PlanEndTime, nil
  25415. }
  25416. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  25417. func (m *SopTaskMutation) ClearPlanEndTime() {
  25418. m.plan_end_time = nil
  25419. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  25420. }
  25421. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  25422. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  25423. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  25424. return ok
  25425. }
  25426. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  25427. func (m *SopTaskMutation) ResetPlanEndTime() {
  25428. m.plan_end_time = nil
  25429. delete(m.clearedFields, soptask.FieldPlanEndTime)
  25430. }
  25431. // SetCreatorID sets the "creator_id" field.
  25432. func (m *SopTaskMutation) SetCreatorID(s string) {
  25433. m.creator_id = &s
  25434. }
  25435. // CreatorID returns the value of the "creator_id" field in the mutation.
  25436. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  25437. v := m.creator_id
  25438. if v == nil {
  25439. return
  25440. }
  25441. return *v, true
  25442. }
  25443. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  25444. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25446. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  25447. if !m.op.Is(OpUpdateOne) {
  25448. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  25449. }
  25450. if m.id == nil || m.oldValue == nil {
  25451. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  25452. }
  25453. oldValue, err := m.oldValue(ctx)
  25454. if err != nil {
  25455. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  25456. }
  25457. return oldValue.CreatorID, nil
  25458. }
  25459. // ClearCreatorID clears the value of the "creator_id" field.
  25460. func (m *SopTaskMutation) ClearCreatorID() {
  25461. m.creator_id = nil
  25462. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  25463. }
  25464. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  25465. func (m *SopTaskMutation) CreatorIDCleared() bool {
  25466. _, ok := m.clearedFields[soptask.FieldCreatorID]
  25467. return ok
  25468. }
  25469. // ResetCreatorID resets all changes to the "creator_id" field.
  25470. func (m *SopTaskMutation) ResetCreatorID() {
  25471. m.creator_id = nil
  25472. delete(m.clearedFields, soptask.FieldCreatorID)
  25473. }
  25474. // SetOrganizationID sets the "organization_id" field.
  25475. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  25476. m.organization_id = &u
  25477. m.addorganization_id = nil
  25478. }
  25479. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25480. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  25481. v := m.organization_id
  25482. if v == nil {
  25483. return
  25484. }
  25485. return *v, true
  25486. }
  25487. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  25488. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25490. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25491. if !m.op.Is(OpUpdateOne) {
  25492. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25493. }
  25494. if m.id == nil || m.oldValue == nil {
  25495. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25496. }
  25497. oldValue, err := m.oldValue(ctx)
  25498. if err != nil {
  25499. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25500. }
  25501. return oldValue.OrganizationID, nil
  25502. }
  25503. // AddOrganizationID adds u to the "organization_id" field.
  25504. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  25505. if m.addorganization_id != nil {
  25506. *m.addorganization_id += u
  25507. } else {
  25508. m.addorganization_id = &u
  25509. }
  25510. }
  25511. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25512. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  25513. v := m.addorganization_id
  25514. if v == nil {
  25515. return
  25516. }
  25517. return *v, true
  25518. }
  25519. // ClearOrganizationID clears the value of the "organization_id" field.
  25520. func (m *SopTaskMutation) ClearOrganizationID() {
  25521. m.organization_id = nil
  25522. m.addorganization_id = nil
  25523. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  25524. }
  25525. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  25526. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  25527. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  25528. return ok
  25529. }
  25530. // ResetOrganizationID resets all changes to the "organization_id" field.
  25531. func (m *SopTaskMutation) ResetOrganizationID() {
  25532. m.organization_id = nil
  25533. m.addorganization_id = nil
  25534. delete(m.clearedFields, soptask.FieldOrganizationID)
  25535. }
  25536. // SetToken sets the "token" field.
  25537. func (m *SopTaskMutation) SetToken(s []string) {
  25538. m.token = &s
  25539. m.appendtoken = nil
  25540. }
  25541. // Token returns the value of the "token" field in the mutation.
  25542. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  25543. v := m.token
  25544. if v == nil {
  25545. return
  25546. }
  25547. return *v, true
  25548. }
  25549. // OldToken returns the old "token" field's value of the SopTask entity.
  25550. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25552. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  25553. if !m.op.Is(OpUpdateOne) {
  25554. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25555. }
  25556. if m.id == nil || m.oldValue == nil {
  25557. return v, errors.New("OldToken requires an ID field in the mutation")
  25558. }
  25559. oldValue, err := m.oldValue(ctx)
  25560. if err != nil {
  25561. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25562. }
  25563. return oldValue.Token, nil
  25564. }
  25565. // AppendToken adds s to the "token" field.
  25566. func (m *SopTaskMutation) AppendToken(s []string) {
  25567. m.appendtoken = append(m.appendtoken, s...)
  25568. }
  25569. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  25570. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  25571. if len(m.appendtoken) == 0 {
  25572. return nil, false
  25573. }
  25574. return m.appendtoken, true
  25575. }
  25576. // ClearToken clears the value of the "token" field.
  25577. func (m *SopTaskMutation) ClearToken() {
  25578. m.token = nil
  25579. m.appendtoken = nil
  25580. m.clearedFields[soptask.FieldToken] = struct{}{}
  25581. }
  25582. // TokenCleared returns if the "token" field was cleared in this mutation.
  25583. func (m *SopTaskMutation) TokenCleared() bool {
  25584. _, ok := m.clearedFields[soptask.FieldToken]
  25585. return ok
  25586. }
  25587. // ResetToken resets all changes to the "token" field.
  25588. func (m *SopTaskMutation) ResetToken() {
  25589. m.token = nil
  25590. m.appendtoken = nil
  25591. delete(m.clearedFields, soptask.FieldToken)
  25592. }
  25593. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  25594. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  25595. if m.task_stages == nil {
  25596. m.task_stages = make(map[uint64]struct{})
  25597. }
  25598. for i := range ids {
  25599. m.task_stages[ids[i]] = struct{}{}
  25600. }
  25601. }
  25602. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  25603. func (m *SopTaskMutation) ClearTaskStages() {
  25604. m.clearedtask_stages = true
  25605. }
  25606. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  25607. func (m *SopTaskMutation) TaskStagesCleared() bool {
  25608. return m.clearedtask_stages
  25609. }
  25610. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  25611. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  25612. if m.removedtask_stages == nil {
  25613. m.removedtask_stages = make(map[uint64]struct{})
  25614. }
  25615. for i := range ids {
  25616. delete(m.task_stages, ids[i])
  25617. m.removedtask_stages[ids[i]] = struct{}{}
  25618. }
  25619. }
  25620. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  25621. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  25622. for id := range m.removedtask_stages {
  25623. ids = append(ids, id)
  25624. }
  25625. return
  25626. }
  25627. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  25628. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  25629. for id := range m.task_stages {
  25630. ids = append(ids, id)
  25631. }
  25632. return
  25633. }
  25634. // ResetTaskStages resets all changes to the "task_stages" edge.
  25635. func (m *SopTaskMutation) ResetTaskStages() {
  25636. m.task_stages = nil
  25637. m.clearedtask_stages = false
  25638. m.removedtask_stages = nil
  25639. }
  25640. // Where appends a list predicates to the SopTaskMutation builder.
  25641. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  25642. m.predicates = append(m.predicates, ps...)
  25643. }
  25644. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  25645. // users can use type-assertion to append predicates that do not depend on any generated package.
  25646. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  25647. p := make([]predicate.SopTask, len(ps))
  25648. for i := range ps {
  25649. p[i] = ps[i]
  25650. }
  25651. m.Where(p...)
  25652. }
  25653. // Op returns the operation name.
  25654. func (m *SopTaskMutation) Op() Op {
  25655. return m.op
  25656. }
  25657. // SetOp allows setting the mutation operation.
  25658. func (m *SopTaskMutation) SetOp(op Op) {
  25659. m.op = op
  25660. }
  25661. // Type returns the node type of this mutation (SopTask).
  25662. func (m *SopTaskMutation) Type() string {
  25663. return m.typ
  25664. }
  25665. // Fields returns all fields that were changed during this mutation. Note that in
  25666. // order to get all numeric fields that were incremented/decremented, call
  25667. // AddedFields().
  25668. func (m *SopTaskMutation) Fields() []string {
  25669. fields := make([]string, 0, 12)
  25670. if m.created_at != nil {
  25671. fields = append(fields, soptask.FieldCreatedAt)
  25672. }
  25673. if m.updated_at != nil {
  25674. fields = append(fields, soptask.FieldUpdatedAt)
  25675. }
  25676. if m.status != nil {
  25677. fields = append(fields, soptask.FieldStatus)
  25678. }
  25679. if m.deleted_at != nil {
  25680. fields = append(fields, soptask.FieldDeletedAt)
  25681. }
  25682. if m.name != nil {
  25683. fields = append(fields, soptask.FieldName)
  25684. }
  25685. if m.bot_wxid_list != nil {
  25686. fields = append(fields, soptask.FieldBotWxidList)
  25687. }
  25688. if m._type != nil {
  25689. fields = append(fields, soptask.FieldType)
  25690. }
  25691. if m.plan_start_time != nil {
  25692. fields = append(fields, soptask.FieldPlanStartTime)
  25693. }
  25694. if m.plan_end_time != nil {
  25695. fields = append(fields, soptask.FieldPlanEndTime)
  25696. }
  25697. if m.creator_id != nil {
  25698. fields = append(fields, soptask.FieldCreatorID)
  25699. }
  25700. if m.organization_id != nil {
  25701. fields = append(fields, soptask.FieldOrganizationID)
  25702. }
  25703. if m.token != nil {
  25704. fields = append(fields, soptask.FieldToken)
  25705. }
  25706. return fields
  25707. }
  25708. // Field returns the value of a field with the given name. The second boolean
  25709. // return value indicates that this field was not set, or was not defined in the
  25710. // schema.
  25711. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  25712. switch name {
  25713. case soptask.FieldCreatedAt:
  25714. return m.CreatedAt()
  25715. case soptask.FieldUpdatedAt:
  25716. return m.UpdatedAt()
  25717. case soptask.FieldStatus:
  25718. return m.Status()
  25719. case soptask.FieldDeletedAt:
  25720. return m.DeletedAt()
  25721. case soptask.FieldName:
  25722. return m.Name()
  25723. case soptask.FieldBotWxidList:
  25724. return m.BotWxidList()
  25725. case soptask.FieldType:
  25726. return m.GetType()
  25727. case soptask.FieldPlanStartTime:
  25728. return m.PlanStartTime()
  25729. case soptask.FieldPlanEndTime:
  25730. return m.PlanEndTime()
  25731. case soptask.FieldCreatorID:
  25732. return m.CreatorID()
  25733. case soptask.FieldOrganizationID:
  25734. return m.OrganizationID()
  25735. case soptask.FieldToken:
  25736. return m.Token()
  25737. }
  25738. return nil, false
  25739. }
  25740. // OldField returns the old value of the field from the database. An error is
  25741. // returned if the mutation operation is not UpdateOne, or the query to the
  25742. // database failed.
  25743. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25744. switch name {
  25745. case soptask.FieldCreatedAt:
  25746. return m.OldCreatedAt(ctx)
  25747. case soptask.FieldUpdatedAt:
  25748. return m.OldUpdatedAt(ctx)
  25749. case soptask.FieldStatus:
  25750. return m.OldStatus(ctx)
  25751. case soptask.FieldDeletedAt:
  25752. return m.OldDeletedAt(ctx)
  25753. case soptask.FieldName:
  25754. return m.OldName(ctx)
  25755. case soptask.FieldBotWxidList:
  25756. return m.OldBotWxidList(ctx)
  25757. case soptask.FieldType:
  25758. return m.OldType(ctx)
  25759. case soptask.FieldPlanStartTime:
  25760. return m.OldPlanStartTime(ctx)
  25761. case soptask.FieldPlanEndTime:
  25762. return m.OldPlanEndTime(ctx)
  25763. case soptask.FieldCreatorID:
  25764. return m.OldCreatorID(ctx)
  25765. case soptask.FieldOrganizationID:
  25766. return m.OldOrganizationID(ctx)
  25767. case soptask.FieldToken:
  25768. return m.OldToken(ctx)
  25769. }
  25770. return nil, fmt.Errorf("unknown SopTask field %s", name)
  25771. }
  25772. // SetField sets the value of a field with the given name. It returns an error if
  25773. // the field is not defined in the schema, or if the type mismatched the field
  25774. // type.
  25775. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  25776. switch name {
  25777. case soptask.FieldCreatedAt:
  25778. v, ok := value.(time.Time)
  25779. if !ok {
  25780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25781. }
  25782. m.SetCreatedAt(v)
  25783. return nil
  25784. case soptask.FieldUpdatedAt:
  25785. v, ok := value.(time.Time)
  25786. if !ok {
  25787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25788. }
  25789. m.SetUpdatedAt(v)
  25790. return nil
  25791. case soptask.FieldStatus:
  25792. v, ok := value.(uint8)
  25793. if !ok {
  25794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25795. }
  25796. m.SetStatus(v)
  25797. return nil
  25798. case soptask.FieldDeletedAt:
  25799. v, ok := value.(time.Time)
  25800. if !ok {
  25801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25802. }
  25803. m.SetDeletedAt(v)
  25804. return nil
  25805. case soptask.FieldName:
  25806. v, ok := value.(string)
  25807. if !ok {
  25808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25809. }
  25810. m.SetName(v)
  25811. return nil
  25812. case soptask.FieldBotWxidList:
  25813. v, ok := value.([]string)
  25814. if !ok {
  25815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25816. }
  25817. m.SetBotWxidList(v)
  25818. return nil
  25819. case soptask.FieldType:
  25820. v, ok := value.(int)
  25821. if !ok {
  25822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25823. }
  25824. m.SetType(v)
  25825. return nil
  25826. case soptask.FieldPlanStartTime:
  25827. v, ok := value.(time.Time)
  25828. if !ok {
  25829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25830. }
  25831. m.SetPlanStartTime(v)
  25832. return nil
  25833. case soptask.FieldPlanEndTime:
  25834. v, ok := value.(time.Time)
  25835. if !ok {
  25836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25837. }
  25838. m.SetPlanEndTime(v)
  25839. return nil
  25840. case soptask.FieldCreatorID:
  25841. v, ok := value.(string)
  25842. if !ok {
  25843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25844. }
  25845. m.SetCreatorID(v)
  25846. return nil
  25847. case soptask.FieldOrganizationID:
  25848. v, ok := value.(uint64)
  25849. if !ok {
  25850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25851. }
  25852. m.SetOrganizationID(v)
  25853. return nil
  25854. case soptask.FieldToken:
  25855. v, ok := value.([]string)
  25856. if !ok {
  25857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25858. }
  25859. m.SetToken(v)
  25860. return nil
  25861. }
  25862. return fmt.Errorf("unknown SopTask field %s", name)
  25863. }
  25864. // AddedFields returns all numeric fields that were incremented/decremented during
  25865. // this mutation.
  25866. func (m *SopTaskMutation) AddedFields() []string {
  25867. var fields []string
  25868. if m.addstatus != nil {
  25869. fields = append(fields, soptask.FieldStatus)
  25870. }
  25871. if m.add_type != nil {
  25872. fields = append(fields, soptask.FieldType)
  25873. }
  25874. if m.addorganization_id != nil {
  25875. fields = append(fields, soptask.FieldOrganizationID)
  25876. }
  25877. return fields
  25878. }
  25879. // AddedField returns the numeric value that was incremented/decremented on a field
  25880. // with the given name. The second boolean return value indicates that this field
  25881. // was not set, or was not defined in the schema.
  25882. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  25883. switch name {
  25884. case soptask.FieldStatus:
  25885. return m.AddedStatus()
  25886. case soptask.FieldType:
  25887. return m.AddedType()
  25888. case soptask.FieldOrganizationID:
  25889. return m.AddedOrganizationID()
  25890. }
  25891. return nil, false
  25892. }
  25893. // AddField adds the value to the field with the given name. It returns an error if
  25894. // the field is not defined in the schema, or if the type mismatched the field
  25895. // type.
  25896. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  25897. switch name {
  25898. case soptask.FieldStatus:
  25899. v, ok := value.(int8)
  25900. if !ok {
  25901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25902. }
  25903. m.AddStatus(v)
  25904. return nil
  25905. case soptask.FieldType:
  25906. v, ok := value.(int)
  25907. if !ok {
  25908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25909. }
  25910. m.AddType(v)
  25911. return nil
  25912. case soptask.FieldOrganizationID:
  25913. v, ok := value.(int64)
  25914. if !ok {
  25915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25916. }
  25917. m.AddOrganizationID(v)
  25918. return nil
  25919. }
  25920. return fmt.Errorf("unknown SopTask numeric field %s", name)
  25921. }
  25922. // ClearedFields returns all nullable fields that were cleared during this
  25923. // mutation.
  25924. func (m *SopTaskMutation) ClearedFields() []string {
  25925. var fields []string
  25926. if m.FieldCleared(soptask.FieldStatus) {
  25927. fields = append(fields, soptask.FieldStatus)
  25928. }
  25929. if m.FieldCleared(soptask.FieldDeletedAt) {
  25930. fields = append(fields, soptask.FieldDeletedAt)
  25931. }
  25932. if m.FieldCleared(soptask.FieldBotWxidList) {
  25933. fields = append(fields, soptask.FieldBotWxidList)
  25934. }
  25935. if m.FieldCleared(soptask.FieldPlanStartTime) {
  25936. fields = append(fields, soptask.FieldPlanStartTime)
  25937. }
  25938. if m.FieldCleared(soptask.FieldPlanEndTime) {
  25939. fields = append(fields, soptask.FieldPlanEndTime)
  25940. }
  25941. if m.FieldCleared(soptask.FieldCreatorID) {
  25942. fields = append(fields, soptask.FieldCreatorID)
  25943. }
  25944. if m.FieldCleared(soptask.FieldOrganizationID) {
  25945. fields = append(fields, soptask.FieldOrganizationID)
  25946. }
  25947. if m.FieldCleared(soptask.FieldToken) {
  25948. fields = append(fields, soptask.FieldToken)
  25949. }
  25950. return fields
  25951. }
  25952. // FieldCleared returns a boolean indicating if a field with the given name was
  25953. // cleared in this mutation.
  25954. func (m *SopTaskMutation) FieldCleared(name string) bool {
  25955. _, ok := m.clearedFields[name]
  25956. return ok
  25957. }
  25958. // ClearField clears the value of the field with the given name. It returns an
  25959. // error if the field is not defined in the schema.
  25960. func (m *SopTaskMutation) ClearField(name string) error {
  25961. switch name {
  25962. case soptask.FieldStatus:
  25963. m.ClearStatus()
  25964. return nil
  25965. case soptask.FieldDeletedAt:
  25966. m.ClearDeletedAt()
  25967. return nil
  25968. case soptask.FieldBotWxidList:
  25969. m.ClearBotWxidList()
  25970. return nil
  25971. case soptask.FieldPlanStartTime:
  25972. m.ClearPlanStartTime()
  25973. return nil
  25974. case soptask.FieldPlanEndTime:
  25975. m.ClearPlanEndTime()
  25976. return nil
  25977. case soptask.FieldCreatorID:
  25978. m.ClearCreatorID()
  25979. return nil
  25980. case soptask.FieldOrganizationID:
  25981. m.ClearOrganizationID()
  25982. return nil
  25983. case soptask.FieldToken:
  25984. m.ClearToken()
  25985. return nil
  25986. }
  25987. return fmt.Errorf("unknown SopTask nullable field %s", name)
  25988. }
  25989. // ResetField resets all changes in the mutation for the field with the given name.
  25990. // It returns an error if the field is not defined in the schema.
  25991. func (m *SopTaskMutation) ResetField(name string) error {
  25992. switch name {
  25993. case soptask.FieldCreatedAt:
  25994. m.ResetCreatedAt()
  25995. return nil
  25996. case soptask.FieldUpdatedAt:
  25997. m.ResetUpdatedAt()
  25998. return nil
  25999. case soptask.FieldStatus:
  26000. m.ResetStatus()
  26001. return nil
  26002. case soptask.FieldDeletedAt:
  26003. m.ResetDeletedAt()
  26004. return nil
  26005. case soptask.FieldName:
  26006. m.ResetName()
  26007. return nil
  26008. case soptask.FieldBotWxidList:
  26009. m.ResetBotWxidList()
  26010. return nil
  26011. case soptask.FieldType:
  26012. m.ResetType()
  26013. return nil
  26014. case soptask.FieldPlanStartTime:
  26015. m.ResetPlanStartTime()
  26016. return nil
  26017. case soptask.FieldPlanEndTime:
  26018. m.ResetPlanEndTime()
  26019. return nil
  26020. case soptask.FieldCreatorID:
  26021. m.ResetCreatorID()
  26022. return nil
  26023. case soptask.FieldOrganizationID:
  26024. m.ResetOrganizationID()
  26025. return nil
  26026. case soptask.FieldToken:
  26027. m.ResetToken()
  26028. return nil
  26029. }
  26030. return fmt.Errorf("unknown SopTask field %s", name)
  26031. }
  26032. // AddedEdges returns all edge names that were set/added in this mutation.
  26033. func (m *SopTaskMutation) AddedEdges() []string {
  26034. edges := make([]string, 0, 1)
  26035. if m.task_stages != nil {
  26036. edges = append(edges, soptask.EdgeTaskStages)
  26037. }
  26038. return edges
  26039. }
  26040. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26041. // name in this mutation.
  26042. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  26043. switch name {
  26044. case soptask.EdgeTaskStages:
  26045. ids := make([]ent.Value, 0, len(m.task_stages))
  26046. for id := range m.task_stages {
  26047. ids = append(ids, id)
  26048. }
  26049. return ids
  26050. }
  26051. return nil
  26052. }
  26053. // RemovedEdges returns all edge names that were removed in this mutation.
  26054. func (m *SopTaskMutation) RemovedEdges() []string {
  26055. edges := make([]string, 0, 1)
  26056. if m.removedtask_stages != nil {
  26057. edges = append(edges, soptask.EdgeTaskStages)
  26058. }
  26059. return edges
  26060. }
  26061. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26062. // the given name in this mutation.
  26063. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  26064. switch name {
  26065. case soptask.EdgeTaskStages:
  26066. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  26067. for id := range m.removedtask_stages {
  26068. ids = append(ids, id)
  26069. }
  26070. return ids
  26071. }
  26072. return nil
  26073. }
  26074. // ClearedEdges returns all edge names that were cleared in this mutation.
  26075. func (m *SopTaskMutation) ClearedEdges() []string {
  26076. edges := make([]string, 0, 1)
  26077. if m.clearedtask_stages {
  26078. edges = append(edges, soptask.EdgeTaskStages)
  26079. }
  26080. return edges
  26081. }
  26082. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26083. // was cleared in this mutation.
  26084. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  26085. switch name {
  26086. case soptask.EdgeTaskStages:
  26087. return m.clearedtask_stages
  26088. }
  26089. return false
  26090. }
  26091. // ClearEdge clears the value of the edge with the given name. It returns an error
  26092. // if that edge is not defined in the schema.
  26093. func (m *SopTaskMutation) ClearEdge(name string) error {
  26094. switch name {
  26095. }
  26096. return fmt.Errorf("unknown SopTask unique edge %s", name)
  26097. }
  26098. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26099. // It returns an error if the edge is not defined in the schema.
  26100. func (m *SopTaskMutation) ResetEdge(name string) error {
  26101. switch name {
  26102. case soptask.EdgeTaskStages:
  26103. m.ResetTaskStages()
  26104. return nil
  26105. }
  26106. return fmt.Errorf("unknown SopTask edge %s", name)
  26107. }
  26108. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  26109. type TokenMutation struct {
  26110. config
  26111. op Op
  26112. typ string
  26113. id *uint64
  26114. created_at *time.Time
  26115. updated_at *time.Time
  26116. deleted_at *time.Time
  26117. expire_at *time.Time
  26118. token *string
  26119. mac *string
  26120. organization_id *uint64
  26121. addorganization_id *int64
  26122. custom_agent_base *string
  26123. custom_agent_key *string
  26124. openai_base *string
  26125. openai_key *string
  26126. clearedFields map[string]struct{}
  26127. agent *uint64
  26128. clearedagent bool
  26129. done bool
  26130. oldValue func(context.Context) (*Token, error)
  26131. predicates []predicate.Token
  26132. }
  26133. var _ ent.Mutation = (*TokenMutation)(nil)
  26134. // tokenOption allows management of the mutation configuration using functional options.
  26135. type tokenOption func(*TokenMutation)
  26136. // newTokenMutation creates new mutation for the Token entity.
  26137. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  26138. m := &TokenMutation{
  26139. config: c,
  26140. op: op,
  26141. typ: TypeToken,
  26142. clearedFields: make(map[string]struct{}),
  26143. }
  26144. for _, opt := range opts {
  26145. opt(m)
  26146. }
  26147. return m
  26148. }
  26149. // withTokenID sets the ID field of the mutation.
  26150. func withTokenID(id uint64) tokenOption {
  26151. return func(m *TokenMutation) {
  26152. var (
  26153. err error
  26154. once sync.Once
  26155. value *Token
  26156. )
  26157. m.oldValue = func(ctx context.Context) (*Token, error) {
  26158. once.Do(func() {
  26159. if m.done {
  26160. err = errors.New("querying old values post mutation is not allowed")
  26161. } else {
  26162. value, err = m.Client().Token.Get(ctx, id)
  26163. }
  26164. })
  26165. return value, err
  26166. }
  26167. m.id = &id
  26168. }
  26169. }
  26170. // withToken sets the old Token of the mutation.
  26171. func withToken(node *Token) tokenOption {
  26172. return func(m *TokenMutation) {
  26173. m.oldValue = func(context.Context) (*Token, error) {
  26174. return node, nil
  26175. }
  26176. m.id = &node.ID
  26177. }
  26178. }
  26179. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26180. // executed in a transaction (ent.Tx), a transactional client is returned.
  26181. func (m TokenMutation) Client() *Client {
  26182. client := &Client{config: m.config}
  26183. client.init()
  26184. return client
  26185. }
  26186. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26187. // it returns an error otherwise.
  26188. func (m TokenMutation) Tx() (*Tx, error) {
  26189. if _, ok := m.driver.(*txDriver); !ok {
  26190. return nil, errors.New("ent: mutation is not running in a transaction")
  26191. }
  26192. tx := &Tx{config: m.config}
  26193. tx.init()
  26194. return tx, nil
  26195. }
  26196. // SetID sets the value of the id field. Note that this
  26197. // operation is only accepted on creation of Token entities.
  26198. func (m *TokenMutation) SetID(id uint64) {
  26199. m.id = &id
  26200. }
  26201. // ID returns the ID value in the mutation. Note that the ID is only available
  26202. // if it was provided to the builder or after it was returned from the database.
  26203. func (m *TokenMutation) ID() (id uint64, exists bool) {
  26204. if m.id == nil {
  26205. return
  26206. }
  26207. return *m.id, true
  26208. }
  26209. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26210. // That means, if the mutation is applied within a transaction with an isolation level such
  26211. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26212. // or updated by the mutation.
  26213. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  26214. switch {
  26215. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26216. id, exists := m.ID()
  26217. if exists {
  26218. return []uint64{id}, nil
  26219. }
  26220. fallthrough
  26221. case m.op.Is(OpUpdate | OpDelete):
  26222. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  26223. default:
  26224. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26225. }
  26226. }
  26227. // SetCreatedAt sets the "created_at" field.
  26228. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  26229. m.created_at = &t
  26230. }
  26231. // CreatedAt returns the value of the "created_at" field in the mutation.
  26232. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  26233. v := m.created_at
  26234. if v == nil {
  26235. return
  26236. }
  26237. return *v, true
  26238. }
  26239. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  26240. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26242. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26243. if !m.op.Is(OpUpdateOne) {
  26244. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26245. }
  26246. if m.id == nil || m.oldValue == nil {
  26247. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26248. }
  26249. oldValue, err := m.oldValue(ctx)
  26250. if err != nil {
  26251. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26252. }
  26253. return oldValue.CreatedAt, nil
  26254. }
  26255. // ResetCreatedAt resets all changes to the "created_at" field.
  26256. func (m *TokenMutation) ResetCreatedAt() {
  26257. m.created_at = nil
  26258. }
  26259. // SetUpdatedAt sets the "updated_at" field.
  26260. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  26261. m.updated_at = &t
  26262. }
  26263. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26264. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  26265. v := m.updated_at
  26266. if v == nil {
  26267. return
  26268. }
  26269. return *v, true
  26270. }
  26271. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  26272. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26274. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26275. if !m.op.Is(OpUpdateOne) {
  26276. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26277. }
  26278. if m.id == nil || m.oldValue == nil {
  26279. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26280. }
  26281. oldValue, err := m.oldValue(ctx)
  26282. if err != nil {
  26283. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26284. }
  26285. return oldValue.UpdatedAt, nil
  26286. }
  26287. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26288. func (m *TokenMutation) ResetUpdatedAt() {
  26289. m.updated_at = nil
  26290. }
  26291. // SetDeletedAt sets the "deleted_at" field.
  26292. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  26293. m.deleted_at = &t
  26294. }
  26295. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26296. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  26297. v := m.deleted_at
  26298. if v == nil {
  26299. return
  26300. }
  26301. return *v, true
  26302. }
  26303. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  26304. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26306. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26307. if !m.op.Is(OpUpdateOne) {
  26308. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26309. }
  26310. if m.id == nil || m.oldValue == nil {
  26311. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26312. }
  26313. oldValue, err := m.oldValue(ctx)
  26314. if err != nil {
  26315. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26316. }
  26317. return oldValue.DeletedAt, nil
  26318. }
  26319. // ClearDeletedAt clears the value of the "deleted_at" field.
  26320. func (m *TokenMutation) ClearDeletedAt() {
  26321. m.deleted_at = nil
  26322. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  26323. }
  26324. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26325. func (m *TokenMutation) DeletedAtCleared() bool {
  26326. _, ok := m.clearedFields[token.FieldDeletedAt]
  26327. return ok
  26328. }
  26329. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26330. func (m *TokenMutation) ResetDeletedAt() {
  26331. m.deleted_at = nil
  26332. delete(m.clearedFields, token.FieldDeletedAt)
  26333. }
  26334. // SetExpireAt sets the "expire_at" field.
  26335. func (m *TokenMutation) SetExpireAt(t time.Time) {
  26336. m.expire_at = &t
  26337. }
  26338. // ExpireAt returns the value of the "expire_at" field in the mutation.
  26339. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  26340. v := m.expire_at
  26341. if v == nil {
  26342. return
  26343. }
  26344. return *v, true
  26345. }
  26346. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  26347. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26349. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  26350. if !m.op.Is(OpUpdateOne) {
  26351. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  26352. }
  26353. if m.id == nil || m.oldValue == nil {
  26354. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  26355. }
  26356. oldValue, err := m.oldValue(ctx)
  26357. if err != nil {
  26358. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  26359. }
  26360. return oldValue.ExpireAt, nil
  26361. }
  26362. // ClearExpireAt clears the value of the "expire_at" field.
  26363. func (m *TokenMutation) ClearExpireAt() {
  26364. m.expire_at = nil
  26365. m.clearedFields[token.FieldExpireAt] = struct{}{}
  26366. }
  26367. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  26368. func (m *TokenMutation) ExpireAtCleared() bool {
  26369. _, ok := m.clearedFields[token.FieldExpireAt]
  26370. return ok
  26371. }
  26372. // ResetExpireAt resets all changes to the "expire_at" field.
  26373. func (m *TokenMutation) ResetExpireAt() {
  26374. m.expire_at = nil
  26375. delete(m.clearedFields, token.FieldExpireAt)
  26376. }
  26377. // SetToken sets the "token" field.
  26378. func (m *TokenMutation) SetToken(s string) {
  26379. m.token = &s
  26380. }
  26381. // Token returns the value of the "token" field in the mutation.
  26382. func (m *TokenMutation) Token() (r string, exists bool) {
  26383. v := m.token
  26384. if v == nil {
  26385. return
  26386. }
  26387. return *v, true
  26388. }
  26389. // OldToken returns the old "token" field's value of the Token entity.
  26390. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26392. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  26393. if !m.op.Is(OpUpdateOne) {
  26394. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26395. }
  26396. if m.id == nil || m.oldValue == nil {
  26397. return v, errors.New("OldToken requires an ID field in the mutation")
  26398. }
  26399. oldValue, err := m.oldValue(ctx)
  26400. if err != nil {
  26401. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26402. }
  26403. return oldValue.Token, nil
  26404. }
  26405. // ClearToken clears the value of the "token" field.
  26406. func (m *TokenMutation) ClearToken() {
  26407. m.token = nil
  26408. m.clearedFields[token.FieldToken] = struct{}{}
  26409. }
  26410. // TokenCleared returns if the "token" field was cleared in this mutation.
  26411. func (m *TokenMutation) TokenCleared() bool {
  26412. _, ok := m.clearedFields[token.FieldToken]
  26413. return ok
  26414. }
  26415. // ResetToken resets all changes to the "token" field.
  26416. func (m *TokenMutation) ResetToken() {
  26417. m.token = nil
  26418. delete(m.clearedFields, token.FieldToken)
  26419. }
  26420. // SetMAC sets the "mac" field.
  26421. func (m *TokenMutation) SetMAC(s string) {
  26422. m.mac = &s
  26423. }
  26424. // MAC returns the value of the "mac" field in the mutation.
  26425. func (m *TokenMutation) MAC() (r string, exists bool) {
  26426. v := m.mac
  26427. if v == nil {
  26428. return
  26429. }
  26430. return *v, true
  26431. }
  26432. // OldMAC returns the old "mac" field's value of the Token entity.
  26433. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26435. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  26436. if !m.op.Is(OpUpdateOne) {
  26437. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  26438. }
  26439. if m.id == nil || m.oldValue == nil {
  26440. return v, errors.New("OldMAC requires an ID field in the mutation")
  26441. }
  26442. oldValue, err := m.oldValue(ctx)
  26443. if err != nil {
  26444. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  26445. }
  26446. return oldValue.MAC, nil
  26447. }
  26448. // ClearMAC clears the value of the "mac" field.
  26449. func (m *TokenMutation) ClearMAC() {
  26450. m.mac = nil
  26451. m.clearedFields[token.FieldMAC] = struct{}{}
  26452. }
  26453. // MACCleared returns if the "mac" field was cleared in this mutation.
  26454. func (m *TokenMutation) MACCleared() bool {
  26455. _, ok := m.clearedFields[token.FieldMAC]
  26456. return ok
  26457. }
  26458. // ResetMAC resets all changes to the "mac" field.
  26459. func (m *TokenMutation) ResetMAC() {
  26460. m.mac = nil
  26461. delete(m.clearedFields, token.FieldMAC)
  26462. }
  26463. // SetOrganizationID sets the "organization_id" field.
  26464. func (m *TokenMutation) SetOrganizationID(u uint64) {
  26465. m.organization_id = &u
  26466. m.addorganization_id = nil
  26467. }
  26468. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26469. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  26470. v := m.organization_id
  26471. if v == nil {
  26472. return
  26473. }
  26474. return *v, true
  26475. }
  26476. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  26477. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26479. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26480. if !m.op.Is(OpUpdateOne) {
  26481. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26482. }
  26483. if m.id == nil || m.oldValue == nil {
  26484. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26485. }
  26486. oldValue, err := m.oldValue(ctx)
  26487. if err != nil {
  26488. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26489. }
  26490. return oldValue.OrganizationID, nil
  26491. }
  26492. // AddOrganizationID adds u to the "organization_id" field.
  26493. func (m *TokenMutation) AddOrganizationID(u int64) {
  26494. if m.addorganization_id != nil {
  26495. *m.addorganization_id += u
  26496. } else {
  26497. m.addorganization_id = &u
  26498. }
  26499. }
  26500. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26501. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  26502. v := m.addorganization_id
  26503. if v == nil {
  26504. return
  26505. }
  26506. return *v, true
  26507. }
  26508. // ResetOrganizationID resets all changes to the "organization_id" field.
  26509. func (m *TokenMutation) ResetOrganizationID() {
  26510. m.organization_id = nil
  26511. m.addorganization_id = nil
  26512. }
  26513. // SetAgentID sets the "agent_id" field.
  26514. func (m *TokenMutation) SetAgentID(u uint64) {
  26515. m.agent = &u
  26516. }
  26517. // AgentID returns the value of the "agent_id" field in the mutation.
  26518. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  26519. v := m.agent
  26520. if v == nil {
  26521. return
  26522. }
  26523. return *v, true
  26524. }
  26525. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  26526. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26528. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  26529. if !m.op.Is(OpUpdateOne) {
  26530. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  26531. }
  26532. if m.id == nil || m.oldValue == nil {
  26533. return v, errors.New("OldAgentID requires an ID field in the mutation")
  26534. }
  26535. oldValue, err := m.oldValue(ctx)
  26536. if err != nil {
  26537. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  26538. }
  26539. return oldValue.AgentID, nil
  26540. }
  26541. // ResetAgentID resets all changes to the "agent_id" field.
  26542. func (m *TokenMutation) ResetAgentID() {
  26543. m.agent = nil
  26544. }
  26545. // SetCustomAgentBase sets the "custom_agent_base" field.
  26546. func (m *TokenMutation) SetCustomAgentBase(s string) {
  26547. m.custom_agent_base = &s
  26548. }
  26549. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  26550. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  26551. v := m.custom_agent_base
  26552. if v == nil {
  26553. return
  26554. }
  26555. return *v, true
  26556. }
  26557. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  26558. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26560. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  26561. if !m.op.Is(OpUpdateOne) {
  26562. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  26563. }
  26564. if m.id == nil || m.oldValue == nil {
  26565. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  26566. }
  26567. oldValue, err := m.oldValue(ctx)
  26568. if err != nil {
  26569. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  26570. }
  26571. return oldValue.CustomAgentBase, nil
  26572. }
  26573. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  26574. func (m *TokenMutation) ClearCustomAgentBase() {
  26575. m.custom_agent_base = nil
  26576. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  26577. }
  26578. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  26579. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  26580. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  26581. return ok
  26582. }
  26583. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  26584. func (m *TokenMutation) ResetCustomAgentBase() {
  26585. m.custom_agent_base = nil
  26586. delete(m.clearedFields, token.FieldCustomAgentBase)
  26587. }
  26588. // SetCustomAgentKey sets the "custom_agent_key" field.
  26589. func (m *TokenMutation) SetCustomAgentKey(s string) {
  26590. m.custom_agent_key = &s
  26591. }
  26592. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  26593. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  26594. v := m.custom_agent_key
  26595. if v == nil {
  26596. return
  26597. }
  26598. return *v, true
  26599. }
  26600. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  26601. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26603. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  26604. if !m.op.Is(OpUpdateOne) {
  26605. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  26606. }
  26607. if m.id == nil || m.oldValue == nil {
  26608. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  26609. }
  26610. oldValue, err := m.oldValue(ctx)
  26611. if err != nil {
  26612. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  26613. }
  26614. return oldValue.CustomAgentKey, nil
  26615. }
  26616. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  26617. func (m *TokenMutation) ClearCustomAgentKey() {
  26618. m.custom_agent_key = nil
  26619. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  26620. }
  26621. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  26622. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  26623. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  26624. return ok
  26625. }
  26626. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  26627. func (m *TokenMutation) ResetCustomAgentKey() {
  26628. m.custom_agent_key = nil
  26629. delete(m.clearedFields, token.FieldCustomAgentKey)
  26630. }
  26631. // SetOpenaiBase sets the "openai_base" field.
  26632. func (m *TokenMutation) SetOpenaiBase(s string) {
  26633. m.openai_base = &s
  26634. }
  26635. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  26636. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  26637. v := m.openai_base
  26638. if v == nil {
  26639. return
  26640. }
  26641. return *v, true
  26642. }
  26643. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  26644. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26646. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  26647. if !m.op.Is(OpUpdateOne) {
  26648. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  26649. }
  26650. if m.id == nil || m.oldValue == nil {
  26651. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  26652. }
  26653. oldValue, err := m.oldValue(ctx)
  26654. if err != nil {
  26655. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  26656. }
  26657. return oldValue.OpenaiBase, nil
  26658. }
  26659. // ClearOpenaiBase clears the value of the "openai_base" field.
  26660. func (m *TokenMutation) ClearOpenaiBase() {
  26661. m.openai_base = nil
  26662. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  26663. }
  26664. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  26665. func (m *TokenMutation) OpenaiBaseCleared() bool {
  26666. _, ok := m.clearedFields[token.FieldOpenaiBase]
  26667. return ok
  26668. }
  26669. // ResetOpenaiBase resets all changes to the "openai_base" field.
  26670. func (m *TokenMutation) ResetOpenaiBase() {
  26671. m.openai_base = nil
  26672. delete(m.clearedFields, token.FieldOpenaiBase)
  26673. }
  26674. // SetOpenaiKey sets the "openai_key" field.
  26675. func (m *TokenMutation) SetOpenaiKey(s string) {
  26676. m.openai_key = &s
  26677. }
  26678. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  26679. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  26680. v := m.openai_key
  26681. if v == nil {
  26682. return
  26683. }
  26684. return *v, true
  26685. }
  26686. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  26687. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26689. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  26690. if !m.op.Is(OpUpdateOne) {
  26691. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  26692. }
  26693. if m.id == nil || m.oldValue == nil {
  26694. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  26695. }
  26696. oldValue, err := m.oldValue(ctx)
  26697. if err != nil {
  26698. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  26699. }
  26700. return oldValue.OpenaiKey, nil
  26701. }
  26702. // ClearOpenaiKey clears the value of the "openai_key" field.
  26703. func (m *TokenMutation) ClearOpenaiKey() {
  26704. m.openai_key = nil
  26705. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  26706. }
  26707. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  26708. func (m *TokenMutation) OpenaiKeyCleared() bool {
  26709. _, ok := m.clearedFields[token.FieldOpenaiKey]
  26710. return ok
  26711. }
  26712. // ResetOpenaiKey resets all changes to the "openai_key" field.
  26713. func (m *TokenMutation) ResetOpenaiKey() {
  26714. m.openai_key = nil
  26715. delete(m.clearedFields, token.FieldOpenaiKey)
  26716. }
  26717. // ClearAgent clears the "agent" edge to the Agent entity.
  26718. func (m *TokenMutation) ClearAgent() {
  26719. m.clearedagent = true
  26720. m.clearedFields[token.FieldAgentID] = struct{}{}
  26721. }
  26722. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  26723. func (m *TokenMutation) AgentCleared() bool {
  26724. return m.clearedagent
  26725. }
  26726. // AgentIDs returns the "agent" edge IDs in the mutation.
  26727. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26728. // AgentID instead. It exists only for internal usage by the builders.
  26729. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  26730. if id := m.agent; id != nil {
  26731. ids = append(ids, *id)
  26732. }
  26733. return
  26734. }
  26735. // ResetAgent resets all changes to the "agent" edge.
  26736. func (m *TokenMutation) ResetAgent() {
  26737. m.agent = nil
  26738. m.clearedagent = false
  26739. }
  26740. // Where appends a list predicates to the TokenMutation builder.
  26741. func (m *TokenMutation) Where(ps ...predicate.Token) {
  26742. m.predicates = append(m.predicates, ps...)
  26743. }
  26744. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  26745. // users can use type-assertion to append predicates that do not depend on any generated package.
  26746. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  26747. p := make([]predicate.Token, len(ps))
  26748. for i := range ps {
  26749. p[i] = ps[i]
  26750. }
  26751. m.Where(p...)
  26752. }
  26753. // Op returns the operation name.
  26754. func (m *TokenMutation) Op() Op {
  26755. return m.op
  26756. }
  26757. // SetOp allows setting the mutation operation.
  26758. func (m *TokenMutation) SetOp(op Op) {
  26759. m.op = op
  26760. }
  26761. // Type returns the node type of this mutation (Token).
  26762. func (m *TokenMutation) Type() string {
  26763. return m.typ
  26764. }
  26765. // Fields returns all fields that were changed during this mutation. Note that in
  26766. // order to get all numeric fields that were incremented/decremented, call
  26767. // AddedFields().
  26768. func (m *TokenMutation) Fields() []string {
  26769. fields := make([]string, 0, 12)
  26770. if m.created_at != nil {
  26771. fields = append(fields, token.FieldCreatedAt)
  26772. }
  26773. if m.updated_at != nil {
  26774. fields = append(fields, token.FieldUpdatedAt)
  26775. }
  26776. if m.deleted_at != nil {
  26777. fields = append(fields, token.FieldDeletedAt)
  26778. }
  26779. if m.expire_at != nil {
  26780. fields = append(fields, token.FieldExpireAt)
  26781. }
  26782. if m.token != nil {
  26783. fields = append(fields, token.FieldToken)
  26784. }
  26785. if m.mac != nil {
  26786. fields = append(fields, token.FieldMAC)
  26787. }
  26788. if m.organization_id != nil {
  26789. fields = append(fields, token.FieldOrganizationID)
  26790. }
  26791. if m.agent != nil {
  26792. fields = append(fields, token.FieldAgentID)
  26793. }
  26794. if m.custom_agent_base != nil {
  26795. fields = append(fields, token.FieldCustomAgentBase)
  26796. }
  26797. if m.custom_agent_key != nil {
  26798. fields = append(fields, token.FieldCustomAgentKey)
  26799. }
  26800. if m.openai_base != nil {
  26801. fields = append(fields, token.FieldOpenaiBase)
  26802. }
  26803. if m.openai_key != nil {
  26804. fields = append(fields, token.FieldOpenaiKey)
  26805. }
  26806. return fields
  26807. }
  26808. // Field returns the value of a field with the given name. The second boolean
  26809. // return value indicates that this field was not set, or was not defined in the
  26810. // schema.
  26811. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  26812. switch name {
  26813. case token.FieldCreatedAt:
  26814. return m.CreatedAt()
  26815. case token.FieldUpdatedAt:
  26816. return m.UpdatedAt()
  26817. case token.FieldDeletedAt:
  26818. return m.DeletedAt()
  26819. case token.FieldExpireAt:
  26820. return m.ExpireAt()
  26821. case token.FieldToken:
  26822. return m.Token()
  26823. case token.FieldMAC:
  26824. return m.MAC()
  26825. case token.FieldOrganizationID:
  26826. return m.OrganizationID()
  26827. case token.FieldAgentID:
  26828. return m.AgentID()
  26829. case token.FieldCustomAgentBase:
  26830. return m.CustomAgentBase()
  26831. case token.FieldCustomAgentKey:
  26832. return m.CustomAgentKey()
  26833. case token.FieldOpenaiBase:
  26834. return m.OpenaiBase()
  26835. case token.FieldOpenaiKey:
  26836. return m.OpenaiKey()
  26837. }
  26838. return nil, false
  26839. }
  26840. // OldField returns the old value of the field from the database. An error is
  26841. // returned if the mutation operation is not UpdateOne, or the query to the
  26842. // database failed.
  26843. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26844. switch name {
  26845. case token.FieldCreatedAt:
  26846. return m.OldCreatedAt(ctx)
  26847. case token.FieldUpdatedAt:
  26848. return m.OldUpdatedAt(ctx)
  26849. case token.FieldDeletedAt:
  26850. return m.OldDeletedAt(ctx)
  26851. case token.FieldExpireAt:
  26852. return m.OldExpireAt(ctx)
  26853. case token.FieldToken:
  26854. return m.OldToken(ctx)
  26855. case token.FieldMAC:
  26856. return m.OldMAC(ctx)
  26857. case token.FieldOrganizationID:
  26858. return m.OldOrganizationID(ctx)
  26859. case token.FieldAgentID:
  26860. return m.OldAgentID(ctx)
  26861. case token.FieldCustomAgentBase:
  26862. return m.OldCustomAgentBase(ctx)
  26863. case token.FieldCustomAgentKey:
  26864. return m.OldCustomAgentKey(ctx)
  26865. case token.FieldOpenaiBase:
  26866. return m.OldOpenaiBase(ctx)
  26867. case token.FieldOpenaiKey:
  26868. return m.OldOpenaiKey(ctx)
  26869. }
  26870. return nil, fmt.Errorf("unknown Token field %s", name)
  26871. }
  26872. // SetField sets the value of a field with the given name. It returns an error if
  26873. // the field is not defined in the schema, or if the type mismatched the field
  26874. // type.
  26875. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  26876. switch name {
  26877. case token.FieldCreatedAt:
  26878. v, ok := value.(time.Time)
  26879. if !ok {
  26880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26881. }
  26882. m.SetCreatedAt(v)
  26883. return nil
  26884. case token.FieldUpdatedAt:
  26885. v, ok := value.(time.Time)
  26886. if !ok {
  26887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26888. }
  26889. m.SetUpdatedAt(v)
  26890. return nil
  26891. case token.FieldDeletedAt:
  26892. v, ok := value.(time.Time)
  26893. if !ok {
  26894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26895. }
  26896. m.SetDeletedAt(v)
  26897. return nil
  26898. case token.FieldExpireAt:
  26899. v, ok := value.(time.Time)
  26900. if !ok {
  26901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26902. }
  26903. m.SetExpireAt(v)
  26904. return nil
  26905. case token.FieldToken:
  26906. v, ok := value.(string)
  26907. if !ok {
  26908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26909. }
  26910. m.SetToken(v)
  26911. return nil
  26912. case token.FieldMAC:
  26913. v, ok := value.(string)
  26914. if !ok {
  26915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26916. }
  26917. m.SetMAC(v)
  26918. return nil
  26919. case token.FieldOrganizationID:
  26920. v, ok := value.(uint64)
  26921. if !ok {
  26922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26923. }
  26924. m.SetOrganizationID(v)
  26925. return nil
  26926. case token.FieldAgentID:
  26927. v, ok := value.(uint64)
  26928. if !ok {
  26929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26930. }
  26931. m.SetAgentID(v)
  26932. return nil
  26933. case token.FieldCustomAgentBase:
  26934. v, ok := value.(string)
  26935. if !ok {
  26936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26937. }
  26938. m.SetCustomAgentBase(v)
  26939. return nil
  26940. case token.FieldCustomAgentKey:
  26941. v, ok := value.(string)
  26942. if !ok {
  26943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26944. }
  26945. m.SetCustomAgentKey(v)
  26946. return nil
  26947. case token.FieldOpenaiBase:
  26948. v, ok := value.(string)
  26949. if !ok {
  26950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26951. }
  26952. m.SetOpenaiBase(v)
  26953. return nil
  26954. case token.FieldOpenaiKey:
  26955. v, ok := value.(string)
  26956. if !ok {
  26957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26958. }
  26959. m.SetOpenaiKey(v)
  26960. return nil
  26961. }
  26962. return fmt.Errorf("unknown Token field %s", name)
  26963. }
  26964. // AddedFields returns all numeric fields that were incremented/decremented during
  26965. // this mutation.
  26966. func (m *TokenMutation) AddedFields() []string {
  26967. var fields []string
  26968. if m.addorganization_id != nil {
  26969. fields = append(fields, token.FieldOrganizationID)
  26970. }
  26971. return fields
  26972. }
  26973. // AddedField returns the numeric value that was incremented/decremented on a field
  26974. // with the given name. The second boolean return value indicates that this field
  26975. // was not set, or was not defined in the schema.
  26976. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  26977. switch name {
  26978. case token.FieldOrganizationID:
  26979. return m.AddedOrganizationID()
  26980. }
  26981. return nil, false
  26982. }
  26983. // AddField adds the value to the field with the given name. It returns an error if
  26984. // the field is not defined in the schema, or if the type mismatched the field
  26985. // type.
  26986. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  26987. switch name {
  26988. case token.FieldOrganizationID:
  26989. v, ok := value.(int64)
  26990. if !ok {
  26991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26992. }
  26993. m.AddOrganizationID(v)
  26994. return nil
  26995. }
  26996. return fmt.Errorf("unknown Token numeric field %s", name)
  26997. }
  26998. // ClearedFields returns all nullable fields that were cleared during this
  26999. // mutation.
  27000. func (m *TokenMutation) ClearedFields() []string {
  27001. var fields []string
  27002. if m.FieldCleared(token.FieldDeletedAt) {
  27003. fields = append(fields, token.FieldDeletedAt)
  27004. }
  27005. if m.FieldCleared(token.FieldExpireAt) {
  27006. fields = append(fields, token.FieldExpireAt)
  27007. }
  27008. if m.FieldCleared(token.FieldToken) {
  27009. fields = append(fields, token.FieldToken)
  27010. }
  27011. if m.FieldCleared(token.FieldMAC) {
  27012. fields = append(fields, token.FieldMAC)
  27013. }
  27014. if m.FieldCleared(token.FieldCustomAgentBase) {
  27015. fields = append(fields, token.FieldCustomAgentBase)
  27016. }
  27017. if m.FieldCleared(token.FieldCustomAgentKey) {
  27018. fields = append(fields, token.FieldCustomAgentKey)
  27019. }
  27020. if m.FieldCleared(token.FieldOpenaiBase) {
  27021. fields = append(fields, token.FieldOpenaiBase)
  27022. }
  27023. if m.FieldCleared(token.FieldOpenaiKey) {
  27024. fields = append(fields, token.FieldOpenaiKey)
  27025. }
  27026. return fields
  27027. }
  27028. // FieldCleared returns a boolean indicating if a field with the given name was
  27029. // cleared in this mutation.
  27030. func (m *TokenMutation) FieldCleared(name string) bool {
  27031. _, ok := m.clearedFields[name]
  27032. return ok
  27033. }
  27034. // ClearField clears the value of the field with the given name. It returns an
  27035. // error if the field is not defined in the schema.
  27036. func (m *TokenMutation) ClearField(name string) error {
  27037. switch name {
  27038. case token.FieldDeletedAt:
  27039. m.ClearDeletedAt()
  27040. return nil
  27041. case token.FieldExpireAt:
  27042. m.ClearExpireAt()
  27043. return nil
  27044. case token.FieldToken:
  27045. m.ClearToken()
  27046. return nil
  27047. case token.FieldMAC:
  27048. m.ClearMAC()
  27049. return nil
  27050. case token.FieldCustomAgentBase:
  27051. m.ClearCustomAgentBase()
  27052. return nil
  27053. case token.FieldCustomAgentKey:
  27054. m.ClearCustomAgentKey()
  27055. return nil
  27056. case token.FieldOpenaiBase:
  27057. m.ClearOpenaiBase()
  27058. return nil
  27059. case token.FieldOpenaiKey:
  27060. m.ClearOpenaiKey()
  27061. return nil
  27062. }
  27063. return fmt.Errorf("unknown Token nullable field %s", name)
  27064. }
  27065. // ResetField resets all changes in the mutation for the field with the given name.
  27066. // It returns an error if the field is not defined in the schema.
  27067. func (m *TokenMutation) ResetField(name string) error {
  27068. switch name {
  27069. case token.FieldCreatedAt:
  27070. m.ResetCreatedAt()
  27071. return nil
  27072. case token.FieldUpdatedAt:
  27073. m.ResetUpdatedAt()
  27074. return nil
  27075. case token.FieldDeletedAt:
  27076. m.ResetDeletedAt()
  27077. return nil
  27078. case token.FieldExpireAt:
  27079. m.ResetExpireAt()
  27080. return nil
  27081. case token.FieldToken:
  27082. m.ResetToken()
  27083. return nil
  27084. case token.FieldMAC:
  27085. m.ResetMAC()
  27086. return nil
  27087. case token.FieldOrganizationID:
  27088. m.ResetOrganizationID()
  27089. return nil
  27090. case token.FieldAgentID:
  27091. m.ResetAgentID()
  27092. return nil
  27093. case token.FieldCustomAgentBase:
  27094. m.ResetCustomAgentBase()
  27095. return nil
  27096. case token.FieldCustomAgentKey:
  27097. m.ResetCustomAgentKey()
  27098. return nil
  27099. case token.FieldOpenaiBase:
  27100. m.ResetOpenaiBase()
  27101. return nil
  27102. case token.FieldOpenaiKey:
  27103. m.ResetOpenaiKey()
  27104. return nil
  27105. }
  27106. return fmt.Errorf("unknown Token field %s", name)
  27107. }
  27108. // AddedEdges returns all edge names that were set/added in this mutation.
  27109. func (m *TokenMutation) AddedEdges() []string {
  27110. edges := make([]string, 0, 1)
  27111. if m.agent != nil {
  27112. edges = append(edges, token.EdgeAgent)
  27113. }
  27114. return edges
  27115. }
  27116. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27117. // name in this mutation.
  27118. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  27119. switch name {
  27120. case token.EdgeAgent:
  27121. if id := m.agent; id != nil {
  27122. return []ent.Value{*id}
  27123. }
  27124. }
  27125. return nil
  27126. }
  27127. // RemovedEdges returns all edge names that were removed in this mutation.
  27128. func (m *TokenMutation) RemovedEdges() []string {
  27129. edges := make([]string, 0, 1)
  27130. return edges
  27131. }
  27132. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27133. // the given name in this mutation.
  27134. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  27135. return nil
  27136. }
  27137. // ClearedEdges returns all edge names that were cleared in this mutation.
  27138. func (m *TokenMutation) ClearedEdges() []string {
  27139. edges := make([]string, 0, 1)
  27140. if m.clearedagent {
  27141. edges = append(edges, token.EdgeAgent)
  27142. }
  27143. return edges
  27144. }
  27145. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27146. // was cleared in this mutation.
  27147. func (m *TokenMutation) EdgeCleared(name string) bool {
  27148. switch name {
  27149. case token.EdgeAgent:
  27150. return m.clearedagent
  27151. }
  27152. return false
  27153. }
  27154. // ClearEdge clears the value of the edge with the given name. It returns an error
  27155. // if that edge is not defined in the schema.
  27156. func (m *TokenMutation) ClearEdge(name string) error {
  27157. switch name {
  27158. case token.EdgeAgent:
  27159. m.ClearAgent()
  27160. return nil
  27161. }
  27162. return fmt.Errorf("unknown Token unique edge %s", name)
  27163. }
  27164. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27165. // It returns an error if the edge is not defined in the schema.
  27166. func (m *TokenMutation) ResetEdge(name string) error {
  27167. switch name {
  27168. case token.EdgeAgent:
  27169. m.ResetAgent()
  27170. return nil
  27171. }
  27172. return fmt.Errorf("unknown Token edge %s", name)
  27173. }
  27174. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  27175. type TutorialMutation struct {
  27176. config
  27177. op Op
  27178. typ string
  27179. id *uint64
  27180. created_at *time.Time
  27181. updated_at *time.Time
  27182. deleted_at *time.Time
  27183. index *int
  27184. addindex *int
  27185. title *string
  27186. content *string
  27187. organization_id *uint64
  27188. addorganization_id *int64
  27189. clearedFields map[string]struct{}
  27190. employee *uint64
  27191. clearedemployee bool
  27192. done bool
  27193. oldValue func(context.Context) (*Tutorial, error)
  27194. predicates []predicate.Tutorial
  27195. }
  27196. var _ ent.Mutation = (*TutorialMutation)(nil)
  27197. // tutorialOption allows management of the mutation configuration using functional options.
  27198. type tutorialOption func(*TutorialMutation)
  27199. // newTutorialMutation creates new mutation for the Tutorial entity.
  27200. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  27201. m := &TutorialMutation{
  27202. config: c,
  27203. op: op,
  27204. typ: TypeTutorial,
  27205. clearedFields: make(map[string]struct{}),
  27206. }
  27207. for _, opt := range opts {
  27208. opt(m)
  27209. }
  27210. return m
  27211. }
  27212. // withTutorialID sets the ID field of the mutation.
  27213. func withTutorialID(id uint64) tutorialOption {
  27214. return func(m *TutorialMutation) {
  27215. var (
  27216. err error
  27217. once sync.Once
  27218. value *Tutorial
  27219. )
  27220. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  27221. once.Do(func() {
  27222. if m.done {
  27223. err = errors.New("querying old values post mutation is not allowed")
  27224. } else {
  27225. value, err = m.Client().Tutorial.Get(ctx, id)
  27226. }
  27227. })
  27228. return value, err
  27229. }
  27230. m.id = &id
  27231. }
  27232. }
  27233. // withTutorial sets the old Tutorial of the mutation.
  27234. func withTutorial(node *Tutorial) tutorialOption {
  27235. return func(m *TutorialMutation) {
  27236. m.oldValue = func(context.Context) (*Tutorial, error) {
  27237. return node, nil
  27238. }
  27239. m.id = &node.ID
  27240. }
  27241. }
  27242. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27243. // executed in a transaction (ent.Tx), a transactional client is returned.
  27244. func (m TutorialMutation) Client() *Client {
  27245. client := &Client{config: m.config}
  27246. client.init()
  27247. return client
  27248. }
  27249. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27250. // it returns an error otherwise.
  27251. func (m TutorialMutation) Tx() (*Tx, error) {
  27252. if _, ok := m.driver.(*txDriver); !ok {
  27253. return nil, errors.New("ent: mutation is not running in a transaction")
  27254. }
  27255. tx := &Tx{config: m.config}
  27256. tx.init()
  27257. return tx, nil
  27258. }
  27259. // SetID sets the value of the id field. Note that this
  27260. // operation is only accepted on creation of Tutorial entities.
  27261. func (m *TutorialMutation) SetID(id uint64) {
  27262. m.id = &id
  27263. }
  27264. // ID returns the ID value in the mutation. Note that the ID is only available
  27265. // if it was provided to the builder or after it was returned from the database.
  27266. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  27267. if m.id == nil {
  27268. return
  27269. }
  27270. return *m.id, true
  27271. }
  27272. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27273. // That means, if the mutation is applied within a transaction with an isolation level such
  27274. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27275. // or updated by the mutation.
  27276. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  27277. switch {
  27278. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27279. id, exists := m.ID()
  27280. if exists {
  27281. return []uint64{id}, nil
  27282. }
  27283. fallthrough
  27284. case m.op.Is(OpUpdate | OpDelete):
  27285. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  27286. default:
  27287. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27288. }
  27289. }
  27290. // SetCreatedAt sets the "created_at" field.
  27291. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  27292. m.created_at = &t
  27293. }
  27294. // CreatedAt returns the value of the "created_at" field in the mutation.
  27295. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  27296. v := m.created_at
  27297. if v == nil {
  27298. return
  27299. }
  27300. return *v, true
  27301. }
  27302. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  27303. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27305. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27306. if !m.op.Is(OpUpdateOne) {
  27307. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27308. }
  27309. if m.id == nil || m.oldValue == nil {
  27310. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27311. }
  27312. oldValue, err := m.oldValue(ctx)
  27313. if err != nil {
  27314. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27315. }
  27316. return oldValue.CreatedAt, nil
  27317. }
  27318. // ResetCreatedAt resets all changes to the "created_at" field.
  27319. func (m *TutorialMutation) ResetCreatedAt() {
  27320. m.created_at = nil
  27321. }
  27322. // SetUpdatedAt sets the "updated_at" field.
  27323. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  27324. m.updated_at = &t
  27325. }
  27326. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27327. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  27328. v := m.updated_at
  27329. if v == nil {
  27330. return
  27331. }
  27332. return *v, true
  27333. }
  27334. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  27335. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27337. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27338. if !m.op.Is(OpUpdateOne) {
  27339. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27340. }
  27341. if m.id == nil || m.oldValue == nil {
  27342. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27343. }
  27344. oldValue, err := m.oldValue(ctx)
  27345. if err != nil {
  27346. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27347. }
  27348. return oldValue.UpdatedAt, nil
  27349. }
  27350. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27351. func (m *TutorialMutation) ResetUpdatedAt() {
  27352. m.updated_at = nil
  27353. }
  27354. // SetDeletedAt sets the "deleted_at" field.
  27355. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  27356. m.deleted_at = &t
  27357. }
  27358. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27359. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  27360. v := m.deleted_at
  27361. if v == nil {
  27362. return
  27363. }
  27364. return *v, true
  27365. }
  27366. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  27367. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27369. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27370. if !m.op.Is(OpUpdateOne) {
  27371. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27372. }
  27373. if m.id == nil || m.oldValue == nil {
  27374. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27375. }
  27376. oldValue, err := m.oldValue(ctx)
  27377. if err != nil {
  27378. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27379. }
  27380. return oldValue.DeletedAt, nil
  27381. }
  27382. // ClearDeletedAt clears the value of the "deleted_at" field.
  27383. func (m *TutorialMutation) ClearDeletedAt() {
  27384. m.deleted_at = nil
  27385. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  27386. }
  27387. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27388. func (m *TutorialMutation) DeletedAtCleared() bool {
  27389. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  27390. return ok
  27391. }
  27392. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27393. func (m *TutorialMutation) ResetDeletedAt() {
  27394. m.deleted_at = nil
  27395. delete(m.clearedFields, tutorial.FieldDeletedAt)
  27396. }
  27397. // SetEmployeeID sets the "employee_id" field.
  27398. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  27399. m.employee = &u
  27400. }
  27401. // EmployeeID returns the value of the "employee_id" field in the mutation.
  27402. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  27403. v := m.employee
  27404. if v == nil {
  27405. return
  27406. }
  27407. return *v, true
  27408. }
  27409. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  27410. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27412. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  27413. if !m.op.Is(OpUpdateOne) {
  27414. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  27415. }
  27416. if m.id == nil || m.oldValue == nil {
  27417. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  27418. }
  27419. oldValue, err := m.oldValue(ctx)
  27420. if err != nil {
  27421. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  27422. }
  27423. return oldValue.EmployeeID, nil
  27424. }
  27425. // ResetEmployeeID resets all changes to the "employee_id" field.
  27426. func (m *TutorialMutation) ResetEmployeeID() {
  27427. m.employee = nil
  27428. }
  27429. // SetIndex sets the "index" field.
  27430. func (m *TutorialMutation) SetIndex(i int) {
  27431. m.index = &i
  27432. m.addindex = nil
  27433. }
  27434. // Index returns the value of the "index" field in the mutation.
  27435. func (m *TutorialMutation) Index() (r int, exists bool) {
  27436. v := m.index
  27437. if v == nil {
  27438. return
  27439. }
  27440. return *v, true
  27441. }
  27442. // OldIndex returns the old "index" field's value of the Tutorial entity.
  27443. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27445. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  27446. if !m.op.Is(OpUpdateOne) {
  27447. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  27448. }
  27449. if m.id == nil || m.oldValue == nil {
  27450. return v, errors.New("OldIndex requires an ID field in the mutation")
  27451. }
  27452. oldValue, err := m.oldValue(ctx)
  27453. if err != nil {
  27454. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  27455. }
  27456. return oldValue.Index, nil
  27457. }
  27458. // AddIndex adds i to the "index" field.
  27459. func (m *TutorialMutation) AddIndex(i int) {
  27460. if m.addindex != nil {
  27461. *m.addindex += i
  27462. } else {
  27463. m.addindex = &i
  27464. }
  27465. }
  27466. // AddedIndex returns the value that was added to the "index" field in this mutation.
  27467. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  27468. v := m.addindex
  27469. if v == nil {
  27470. return
  27471. }
  27472. return *v, true
  27473. }
  27474. // ResetIndex resets all changes to the "index" field.
  27475. func (m *TutorialMutation) ResetIndex() {
  27476. m.index = nil
  27477. m.addindex = nil
  27478. }
  27479. // SetTitle sets the "title" field.
  27480. func (m *TutorialMutation) SetTitle(s string) {
  27481. m.title = &s
  27482. }
  27483. // Title returns the value of the "title" field in the mutation.
  27484. func (m *TutorialMutation) Title() (r string, exists bool) {
  27485. v := m.title
  27486. if v == nil {
  27487. return
  27488. }
  27489. return *v, true
  27490. }
  27491. // OldTitle returns the old "title" field's value of the Tutorial entity.
  27492. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27494. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  27495. if !m.op.Is(OpUpdateOne) {
  27496. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  27497. }
  27498. if m.id == nil || m.oldValue == nil {
  27499. return v, errors.New("OldTitle requires an ID field in the mutation")
  27500. }
  27501. oldValue, err := m.oldValue(ctx)
  27502. if err != nil {
  27503. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  27504. }
  27505. return oldValue.Title, nil
  27506. }
  27507. // ResetTitle resets all changes to the "title" field.
  27508. func (m *TutorialMutation) ResetTitle() {
  27509. m.title = nil
  27510. }
  27511. // SetContent sets the "content" field.
  27512. func (m *TutorialMutation) SetContent(s string) {
  27513. m.content = &s
  27514. }
  27515. // Content returns the value of the "content" field in the mutation.
  27516. func (m *TutorialMutation) Content() (r string, exists bool) {
  27517. v := m.content
  27518. if v == nil {
  27519. return
  27520. }
  27521. return *v, true
  27522. }
  27523. // OldContent returns the old "content" field's value of the Tutorial entity.
  27524. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27526. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  27527. if !m.op.Is(OpUpdateOne) {
  27528. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  27529. }
  27530. if m.id == nil || m.oldValue == nil {
  27531. return v, errors.New("OldContent requires an ID field in the mutation")
  27532. }
  27533. oldValue, err := m.oldValue(ctx)
  27534. if err != nil {
  27535. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  27536. }
  27537. return oldValue.Content, nil
  27538. }
  27539. // ResetContent resets all changes to the "content" field.
  27540. func (m *TutorialMutation) ResetContent() {
  27541. m.content = nil
  27542. }
  27543. // SetOrganizationID sets the "organization_id" field.
  27544. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  27545. m.organization_id = &u
  27546. m.addorganization_id = nil
  27547. }
  27548. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27549. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  27550. v := m.organization_id
  27551. if v == nil {
  27552. return
  27553. }
  27554. return *v, true
  27555. }
  27556. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  27557. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27559. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27560. if !m.op.Is(OpUpdateOne) {
  27561. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27562. }
  27563. if m.id == nil || m.oldValue == nil {
  27564. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27565. }
  27566. oldValue, err := m.oldValue(ctx)
  27567. if err != nil {
  27568. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27569. }
  27570. return oldValue.OrganizationID, nil
  27571. }
  27572. // AddOrganizationID adds u to the "organization_id" field.
  27573. func (m *TutorialMutation) AddOrganizationID(u int64) {
  27574. if m.addorganization_id != nil {
  27575. *m.addorganization_id += u
  27576. } else {
  27577. m.addorganization_id = &u
  27578. }
  27579. }
  27580. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27581. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  27582. v := m.addorganization_id
  27583. if v == nil {
  27584. return
  27585. }
  27586. return *v, true
  27587. }
  27588. // ResetOrganizationID resets all changes to the "organization_id" field.
  27589. func (m *TutorialMutation) ResetOrganizationID() {
  27590. m.organization_id = nil
  27591. m.addorganization_id = nil
  27592. }
  27593. // ClearEmployee clears the "employee" edge to the Employee entity.
  27594. func (m *TutorialMutation) ClearEmployee() {
  27595. m.clearedemployee = true
  27596. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  27597. }
  27598. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  27599. func (m *TutorialMutation) EmployeeCleared() bool {
  27600. return m.clearedemployee
  27601. }
  27602. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  27603. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27604. // EmployeeID instead. It exists only for internal usage by the builders.
  27605. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  27606. if id := m.employee; id != nil {
  27607. ids = append(ids, *id)
  27608. }
  27609. return
  27610. }
  27611. // ResetEmployee resets all changes to the "employee" edge.
  27612. func (m *TutorialMutation) ResetEmployee() {
  27613. m.employee = nil
  27614. m.clearedemployee = false
  27615. }
  27616. // Where appends a list predicates to the TutorialMutation builder.
  27617. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  27618. m.predicates = append(m.predicates, ps...)
  27619. }
  27620. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  27621. // users can use type-assertion to append predicates that do not depend on any generated package.
  27622. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  27623. p := make([]predicate.Tutorial, len(ps))
  27624. for i := range ps {
  27625. p[i] = ps[i]
  27626. }
  27627. m.Where(p...)
  27628. }
  27629. // Op returns the operation name.
  27630. func (m *TutorialMutation) Op() Op {
  27631. return m.op
  27632. }
  27633. // SetOp allows setting the mutation operation.
  27634. func (m *TutorialMutation) SetOp(op Op) {
  27635. m.op = op
  27636. }
  27637. // Type returns the node type of this mutation (Tutorial).
  27638. func (m *TutorialMutation) Type() string {
  27639. return m.typ
  27640. }
  27641. // Fields returns all fields that were changed during this mutation. Note that in
  27642. // order to get all numeric fields that were incremented/decremented, call
  27643. // AddedFields().
  27644. func (m *TutorialMutation) Fields() []string {
  27645. fields := make([]string, 0, 8)
  27646. if m.created_at != nil {
  27647. fields = append(fields, tutorial.FieldCreatedAt)
  27648. }
  27649. if m.updated_at != nil {
  27650. fields = append(fields, tutorial.FieldUpdatedAt)
  27651. }
  27652. if m.deleted_at != nil {
  27653. fields = append(fields, tutorial.FieldDeletedAt)
  27654. }
  27655. if m.employee != nil {
  27656. fields = append(fields, tutorial.FieldEmployeeID)
  27657. }
  27658. if m.index != nil {
  27659. fields = append(fields, tutorial.FieldIndex)
  27660. }
  27661. if m.title != nil {
  27662. fields = append(fields, tutorial.FieldTitle)
  27663. }
  27664. if m.content != nil {
  27665. fields = append(fields, tutorial.FieldContent)
  27666. }
  27667. if m.organization_id != nil {
  27668. fields = append(fields, tutorial.FieldOrganizationID)
  27669. }
  27670. return fields
  27671. }
  27672. // Field returns the value of a field with the given name. The second boolean
  27673. // return value indicates that this field was not set, or was not defined in the
  27674. // schema.
  27675. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  27676. switch name {
  27677. case tutorial.FieldCreatedAt:
  27678. return m.CreatedAt()
  27679. case tutorial.FieldUpdatedAt:
  27680. return m.UpdatedAt()
  27681. case tutorial.FieldDeletedAt:
  27682. return m.DeletedAt()
  27683. case tutorial.FieldEmployeeID:
  27684. return m.EmployeeID()
  27685. case tutorial.FieldIndex:
  27686. return m.Index()
  27687. case tutorial.FieldTitle:
  27688. return m.Title()
  27689. case tutorial.FieldContent:
  27690. return m.Content()
  27691. case tutorial.FieldOrganizationID:
  27692. return m.OrganizationID()
  27693. }
  27694. return nil, false
  27695. }
  27696. // OldField returns the old value of the field from the database. An error is
  27697. // returned if the mutation operation is not UpdateOne, or the query to the
  27698. // database failed.
  27699. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27700. switch name {
  27701. case tutorial.FieldCreatedAt:
  27702. return m.OldCreatedAt(ctx)
  27703. case tutorial.FieldUpdatedAt:
  27704. return m.OldUpdatedAt(ctx)
  27705. case tutorial.FieldDeletedAt:
  27706. return m.OldDeletedAt(ctx)
  27707. case tutorial.FieldEmployeeID:
  27708. return m.OldEmployeeID(ctx)
  27709. case tutorial.FieldIndex:
  27710. return m.OldIndex(ctx)
  27711. case tutorial.FieldTitle:
  27712. return m.OldTitle(ctx)
  27713. case tutorial.FieldContent:
  27714. return m.OldContent(ctx)
  27715. case tutorial.FieldOrganizationID:
  27716. return m.OldOrganizationID(ctx)
  27717. }
  27718. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  27719. }
  27720. // SetField sets the value of a field with the given name. It returns an error if
  27721. // the field is not defined in the schema, or if the type mismatched the field
  27722. // type.
  27723. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  27724. switch name {
  27725. case tutorial.FieldCreatedAt:
  27726. v, ok := value.(time.Time)
  27727. if !ok {
  27728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27729. }
  27730. m.SetCreatedAt(v)
  27731. return nil
  27732. case tutorial.FieldUpdatedAt:
  27733. v, ok := value.(time.Time)
  27734. if !ok {
  27735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27736. }
  27737. m.SetUpdatedAt(v)
  27738. return nil
  27739. case tutorial.FieldDeletedAt:
  27740. v, ok := value.(time.Time)
  27741. if !ok {
  27742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27743. }
  27744. m.SetDeletedAt(v)
  27745. return nil
  27746. case tutorial.FieldEmployeeID:
  27747. v, ok := value.(uint64)
  27748. if !ok {
  27749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27750. }
  27751. m.SetEmployeeID(v)
  27752. return nil
  27753. case tutorial.FieldIndex:
  27754. v, ok := value.(int)
  27755. if !ok {
  27756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27757. }
  27758. m.SetIndex(v)
  27759. return nil
  27760. case tutorial.FieldTitle:
  27761. v, ok := value.(string)
  27762. if !ok {
  27763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27764. }
  27765. m.SetTitle(v)
  27766. return nil
  27767. case tutorial.FieldContent:
  27768. v, ok := value.(string)
  27769. if !ok {
  27770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27771. }
  27772. m.SetContent(v)
  27773. return nil
  27774. case tutorial.FieldOrganizationID:
  27775. v, ok := value.(uint64)
  27776. if !ok {
  27777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27778. }
  27779. m.SetOrganizationID(v)
  27780. return nil
  27781. }
  27782. return fmt.Errorf("unknown Tutorial field %s", name)
  27783. }
  27784. // AddedFields returns all numeric fields that were incremented/decremented during
  27785. // this mutation.
  27786. func (m *TutorialMutation) AddedFields() []string {
  27787. var fields []string
  27788. if m.addindex != nil {
  27789. fields = append(fields, tutorial.FieldIndex)
  27790. }
  27791. if m.addorganization_id != nil {
  27792. fields = append(fields, tutorial.FieldOrganizationID)
  27793. }
  27794. return fields
  27795. }
  27796. // AddedField returns the numeric value that was incremented/decremented on a field
  27797. // with the given name. The second boolean return value indicates that this field
  27798. // was not set, or was not defined in the schema.
  27799. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  27800. switch name {
  27801. case tutorial.FieldIndex:
  27802. return m.AddedIndex()
  27803. case tutorial.FieldOrganizationID:
  27804. return m.AddedOrganizationID()
  27805. }
  27806. return nil, false
  27807. }
  27808. // AddField adds the value to the field with the given name. It returns an error if
  27809. // the field is not defined in the schema, or if the type mismatched the field
  27810. // type.
  27811. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  27812. switch name {
  27813. case tutorial.FieldIndex:
  27814. v, ok := value.(int)
  27815. if !ok {
  27816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27817. }
  27818. m.AddIndex(v)
  27819. return nil
  27820. case tutorial.FieldOrganizationID:
  27821. v, ok := value.(int64)
  27822. if !ok {
  27823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27824. }
  27825. m.AddOrganizationID(v)
  27826. return nil
  27827. }
  27828. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  27829. }
  27830. // ClearedFields returns all nullable fields that were cleared during this
  27831. // mutation.
  27832. func (m *TutorialMutation) ClearedFields() []string {
  27833. var fields []string
  27834. if m.FieldCleared(tutorial.FieldDeletedAt) {
  27835. fields = append(fields, tutorial.FieldDeletedAt)
  27836. }
  27837. return fields
  27838. }
  27839. // FieldCleared returns a boolean indicating if a field with the given name was
  27840. // cleared in this mutation.
  27841. func (m *TutorialMutation) FieldCleared(name string) bool {
  27842. _, ok := m.clearedFields[name]
  27843. return ok
  27844. }
  27845. // ClearField clears the value of the field with the given name. It returns an
  27846. // error if the field is not defined in the schema.
  27847. func (m *TutorialMutation) ClearField(name string) error {
  27848. switch name {
  27849. case tutorial.FieldDeletedAt:
  27850. m.ClearDeletedAt()
  27851. return nil
  27852. }
  27853. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  27854. }
  27855. // ResetField resets all changes in the mutation for the field with the given name.
  27856. // It returns an error if the field is not defined in the schema.
  27857. func (m *TutorialMutation) ResetField(name string) error {
  27858. switch name {
  27859. case tutorial.FieldCreatedAt:
  27860. m.ResetCreatedAt()
  27861. return nil
  27862. case tutorial.FieldUpdatedAt:
  27863. m.ResetUpdatedAt()
  27864. return nil
  27865. case tutorial.FieldDeletedAt:
  27866. m.ResetDeletedAt()
  27867. return nil
  27868. case tutorial.FieldEmployeeID:
  27869. m.ResetEmployeeID()
  27870. return nil
  27871. case tutorial.FieldIndex:
  27872. m.ResetIndex()
  27873. return nil
  27874. case tutorial.FieldTitle:
  27875. m.ResetTitle()
  27876. return nil
  27877. case tutorial.FieldContent:
  27878. m.ResetContent()
  27879. return nil
  27880. case tutorial.FieldOrganizationID:
  27881. m.ResetOrganizationID()
  27882. return nil
  27883. }
  27884. return fmt.Errorf("unknown Tutorial field %s", name)
  27885. }
  27886. // AddedEdges returns all edge names that were set/added in this mutation.
  27887. func (m *TutorialMutation) AddedEdges() []string {
  27888. edges := make([]string, 0, 1)
  27889. if m.employee != nil {
  27890. edges = append(edges, tutorial.EdgeEmployee)
  27891. }
  27892. return edges
  27893. }
  27894. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27895. // name in this mutation.
  27896. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  27897. switch name {
  27898. case tutorial.EdgeEmployee:
  27899. if id := m.employee; id != nil {
  27900. return []ent.Value{*id}
  27901. }
  27902. }
  27903. return nil
  27904. }
  27905. // RemovedEdges returns all edge names that were removed in this mutation.
  27906. func (m *TutorialMutation) RemovedEdges() []string {
  27907. edges := make([]string, 0, 1)
  27908. return edges
  27909. }
  27910. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27911. // the given name in this mutation.
  27912. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  27913. return nil
  27914. }
  27915. // ClearedEdges returns all edge names that were cleared in this mutation.
  27916. func (m *TutorialMutation) ClearedEdges() []string {
  27917. edges := make([]string, 0, 1)
  27918. if m.clearedemployee {
  27919. edges = append(edges, tutorial.EdgeEmployee)
  27920. }
  27921. return edges
  27922. }
  27923. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27924. // was cleared in this mutation.
  27925. func (m *TutorialMutation) EdgeCleared(name string) bool {
  27926. switch name {
  27927. case tutorial.EdgeEmployee:
  27928. return m.clearedemployee
  27929. }
  27930. return false
  27931. }
  27932. // ClearEdge clears the value of the edge with the given name. It returns an error
  27933. // if that edge is not defined in the schema.
  27934. func (m *TutorialMutation) ClearEdge(name string) error {
  27935. switch name {
  27936. case tutorial.EdgeEmployee:
  27937. m.ClearEmployee()
  27938. return nil
  27939. }
  27940. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  27941. }
  27942. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27943. // It returns an error if the edge is not defined in the schema.
  27944. func (m *TutorialMutation) ResetEdge(name string) error {
  27945. switch name {
  27946. case tutorial.EdgeEmployee:
  27947. m.ResetEmployee()
  27948. return nil
  27949. }
  27950. return fmt.Errorf("unknown Tutorial edge %s", name)
  27951. }
  27952. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  27953. type UsageDetailMutation struct {
  27954. config
  27955. op Op
  27956. typ string
  27957. id *uint64
  27958. created_at *time.Time
  27959. updated_at *time.Time
  27960. status *uint8
  27961. addstatus *int8
  27962. _type *int
  27963. add_type *int
  27964. bot_id *string
  27965. receiver_id *string
  27966. app *int
  27967. addapp *int
  27968. session_id *uint64
  27969. addsession_id *int64
  27970. request *string
  27971. response *string
  27972. original_data *custom_types.OriginalData
  27973. total_tokens *uint64
  27974. addtotal_tokens *int64
  27975. prompt_tokens *uint64
  27976. addprompt_tokens *int64
  27977. completion_tokens *uint64
  27978. addcompletion_tokens *int64
  27979. organization_id *uint64
  27980. addorganization_id *int64
  27981. clearedFields map[string]struct{}
  27982. done bool
  27983. oldValue func(context.Context) (*UsageDetail, error)
  27984. predicates []predicate.UsageDetail
  27985. }
  27986. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  27987. // usagedetailOption allows management of the mutation configuration using functional options.
  27988. type usagedetailOption func(*UsageDetailMutation)
  27989. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  27990. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  27991. m := &UsageDetailMutation{
  27992. config: c,
  27993. op: op,
  27994. typ: TypeUsageDetail,
  27995. clearedFields: make(map[string]struct{}),
  27996. }
  27997. for _, opt := range opts {
  27998. opt(m)
  27999. }
  28000. return m
  28001. }
  28002. // withUsageDetailID sets the ID field of the mutation.
  28003. func withUsageDetailID(id uint64) usagedetailOption {
  28004. return func(m *UsageDetailMutation) {
  28005. var (
  28006. err error
  28007. once sync.Once
  28008. value *UsageDetail
  28009. )
  28010. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  28011. once.Do(func() {
  28012. if m.done {
  28013. err = errors.New("querying old values post mutation is not allowed")
  28014. } else {
  28015. value, err = m.Client().UsageDetail.Get(ctx, id)
  28016. }
  28017. })
  28018. return value, err
  28019. }
  28020. m.id = &id
  28021. }
  28022. }
  28023. // withUsageDetail sets the old UsageDetail of the mutation.
  28024. func withUsageDetail(node *UsageDetail) usagedetailOption {
  28025. return func(m *UsageDetailMutation) {
  28026. m.oldValue = func(context.Context) (*UsageDetail, error) {
  28027. return node, nil
  28028. }
  28029. m.id = &node.ID
  28030. }
  28031. }
  28032. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28033. // executed in a transaction (ent.Tx), a transactional client is returned.
  28034. func (m UsageDetailMutation) Client() *Client {
  28035. client := &Client{config: m.config}
  28036. client.init()
  28037. return client
  28038. }
  28039. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28040. // it returns an error otherwise.
  28041. func (m UsageDetailMutation) Tx() (*Tx, error) {
  28042. if _, ok := m.driver.(*txDriver); !ok {
  28043. return nil, errors.New("ent: mutation is not running in a transaction")
  28044. }
  28045. tx := &Tx{config: m.config}
  28046. tx.init()
  28047. return tx, nil
  28048. }
  28049. // SetID sets the value of the id field. Note that this
  28050. // operation is only accepted on creation of UsageDetail entities.
  28051. func (m *UsageDetailMutation) SetID(id uint64) {
  28052. m.id = &id
  28053. }
  28054. // ID returns the ID value in the mutation. Note that the ID is only available
  28055. // if it was provided to the builder or after it was returned from the database.
  28056. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  28057. if m.id == nil {
  28058. return
  28059. }
  28060. return *m.id, true
  28061. }
  28062. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28063. // That means, if the mutation is applied within a transaction with an isolation level such
  28064. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28065. // or updated by the mutation.
  28066. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  28067. switch {
  28068. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28069. id, exists := m.ID()
  28070. if exists {
  28071. return []uint64{id}, nil
  28072. }
  28073. fallthrough
  28074. case m.op.Is(OpUpdate | OpDelete):
  28075. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  28076. default:
  28077. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28078. }
  28079. }
  28080. // SetCreatedAt sets the "created_at" field.
  28081. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  28082. m.created_at = &t
  28083. }
  28084. // CreatedAt returns the value of the "created_at" field in the mutation.
  28085. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  28086. v := m.created_at
  28087. if v == nil {
  28088. return
  28089. }
  28090. return *v, true
  28091. }
  28092. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  28093. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28095. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28096. if !m.op.Is(OpUpdateOne) {
  28097. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28098. }
  28099. if m.id == nil || m.oldValue == nil {
  28100. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28101. }
  28102. oldValue, err := m.oldValue(ctx)
  28103. if err != nil {
  28104. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28105. }
  28106. return oldValue.CreatedAt, nil
  28107. }
  28108. // ResetCreatedAt resets all changes to the "created_at" field.
  28109. func (m *UsageDetailMutation) ResetCreatedAt() {
  28110. m.created_at = nil
  28111. }
  28112. // SetUpdatedAt sets the "updated_at" field.
  28113. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  28114. m.updated_at = &t
  28115. }
  28116. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28117. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  28118. v := m.updated_at
  28119. if v == nil {
  28120. return
  28121. }
  28122. return *v, true
  28123. }
  28124. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  28125. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28127. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28128. if !m.op.Is(OpUpdateOne) {
  28129. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28130. }
  28131. if m.id == nil || m.oldValue == nil {
  28132. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28133. }
  28134. oldValue, err := m.oldValue(ctx)
  28135. if err != nil {
  28136. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28137. }
  28138. return oldValue.UpdatedAt, nil
  28139. }
  28140. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28141. func (m *UsageDetailMutation) ResetUpdatedAt() {
  28142. m.updated_at = nil
  28143. }
  28144. // SetStatus sets the "status" field.
  28145. func (m *UsageDetailMutation) SetStatus(u uint8) {
  28146. m.status = &u
  28147. m.addstatus = nil
  28148. }
  28149. // Status returns the value of the "status" field in the mutation.
  28150. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  28151. v := m.status
  28152. if v == nil {
  28153. return
  28154. }
  28155. return *v, true
  28156. }
  28157. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  28158. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28160. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28161. if !m.op.Is(OpUpdateOne) {
  28162. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28163. }
  28164. if m.id == nil || m.oldValue == nil {
  28165. return v, errors.New("OldStatus requires an ID field in the mutation")
  28166. }
  28167. oldValue, err := m.oldValue(ctx)
  28168. if err != nil {
  28169. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28170. }
  28171. return oldValue.Status, nil
  28172. }
  28173. // AddStatus adds u to the "status" field.
  28174. func (m *UsageDetailMutation) AddStatus(u int8) {
  28175. if m.addstatus != nil {
  28176. *m.addstatus += u
  28177. } else {
  28178. m.addstatus = &u
  28179. }
  28180. }
  28181. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28182. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  28183. v := m.addstatus
  28184. if v == nil {
  28185. return
  28186. }
  28187. return *v, true
  28188. }
  28189. // ClearStatus clears the value of the "status" field.
  28190. func (m *UsageDetailMutation) ClearStatus() {
  28191. m.status = nil
  28192. m.addstatus = nil
  28193. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  28194. }
  28195. // StatusCleared returns if the "status" field was cleared in this mutation.
  28196. func (m *UsageDetailMutation) StatusCleared() bool {
  28197. _, ok := m.clearedFields[usagedetail.FieldStatus]
  28198. return ok
  28199. }
  28200. // ResetStatus resets all changes to the "status" field.
  28201. func (m *UsageDetailMutation) ResetStatus() {
  28202. m.status = nil
  28203. m.addstatus = nil
  28204. delete(m.clearedFields, usagedetail.FieldStatus)
  28205. }
  28206. // SetType sets the "type" field.
  28207. func (m *UsageDetailMutation) SetType(i int) {
  28208. m._type = &i
  28209. m.add_type = nil
  28210. }
  28211. // GetType returns the value of the "type" field in the mutation.
  28212. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  28213. v := m._type
  28214. if v == nil {
  28215. return
  28216. }
  28217. return *v, true
  28218. }
  28219. // OldType returns the old "type" field's value of the UsageDetail entity.
  28220. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28222. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  28223. if !m.op.Is(OpUpdateOne) {
  28224. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28225. }
  28226. if m.id == nil || m.oldValue == nil {
  28227. return v, errors.New("OldType requires an ID field in the mutation")
  28228. }
  28229. oldValue, err := m.oldValue(ctx)
  28230. if err != nil {
  28231. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28232. }
  28233. return oldValue.Type, nil
  28234. }
  28235. // AddType adds i to the "type" field.
  28236. func (m *UsageDetailMutation) AddType(i int) {
  28237. if m.add_type != nil {
  28238. *m.add_type += i
  28239. } else {
  28240. m.add_type = &i
  28241. }
  28242. }
  28243. // AddedType returns the value that was added to the "type" field in this mutation.
  28244. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  28245. v := m.add_type
  28246. if v == nil {
  28247. return
  28248. }
  28249. return *v, true
  28250. }
  28251. // ClearType clears the value of the "type" field.
  28252. func (m *UsageDetailMutation) ClearType() {
  28253. m._type = nil
  28254. m.add_type = nil
  28255. m.clearedFields[usagedetail.FieldType] = struct{}{}
  28256. }
  28257. // TypeCleared returns if the "type" field was cleared in this mutation.
  28258. func (m *UsageDetailMutation) TypeCleared() bool {
  28259. _, ok := m.clearedFields[usagedetail.FieldType]
  28260. return ok
  28261. }
  28262. // ResetType resets all changes to the "type" field.
  28263. func (m *UsageDetailMutation) ResetType() {
  28264. m._type = nil
  28265. m.add_type = nil
  28266. delete(m.clearedFields, usagedetail.FieldType)
  28267. }
  28268. // SetBotID sets the "bot_id" field.
  28269. func (m *UsageDetailMutation) SetBotID(s string) {
  28270. m.bot_id = &s
  28271. }
  28272. // BotID returns the value of the "bot_id" field in the mutation.
  28273. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  28274. v := m.bot_id
  28275. if v == nil {
  28276. return
  28277. }
  28278. return *v, true
  28279. }
  28280. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  28281. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28283. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  28284. if !m.op.Is(OpUpdateOne) {
  28285. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28286. }
  28287. if m.id == nil || m.oldValue == nil {
  28288. return v, errors.New("OldBotID requires an ID field in the mutation")
  28289. }
  28290. oldValue, err := m.oldValue(ctx)
  28291. if err != nil {
  28292. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28293. }
  28294. return oldValue.BotID, nil
  28295. }
  28296. // ResetBotID resets all changes to the "bot_id" field.
  28297. func (m *UsageDetailMutation) ResetBotID() {
  28298. m.bot_id = nil
  28299. }
  28300. // SetReceiverID sets the "receiver_id" field.
  28301. func (m *UsageDetailMutation) SetReceiverID(s string) {
  28302. m.receiver_id = &s
  28303. }
  28304. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  28305. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  28306. v := m.receiver_id
  28307. if v == nil {
  28308. return
  28309. }
  28310. return *v, true
  28311. }
  28312. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  28313. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28315. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  28316. if !m.op.Is(OpUpdateOne) {
  28317. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  28318. }
  28319. if m.id == nil || m.oldValue == nil {
  28320. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  28321. }
  28322. oldValue, err := m.oldValue(ctx)
  28323. if err != nil {
  28324. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  28325. }
  28326. return oldValue.ReceiverID, nil
  28327. }
  28328. // ResetReceiverID resets all changes to the "receiver_id" field.
  28329. func (m *UsageDetailMutation) ResetReceiverID() {
  28330. m.receiver_id = nil
  28331. }
  28332. // SetApp sets the "app" field.
  28333. func (m *UsageDetailMutation) SetApp(i int) {
  28334. m.app = &i
  28335. m.addapp = nil
  28336. }
  28337. // App returns the value of the "app" field in the mutation.
  28338. func (m *UsageDetailMutation) App() (r int, exists bool) {
  28339. v := m.app
  28340. if v == nil {
  28341. return
  28342. }
  28343. return *v, true
  28344. }
  28345. // OldApp returns the old "app" field's value of the UsageDetail entity.
  28346. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28348. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  28349. if !m.op.Is(OpUpdateOne) {
  28350. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  28351. }
  28352. if m.id == nil || m.oldValue == nil {
  28353. return v, errors.New("OldApp requires an ID field in the mutation")
  28354. }
  28355. oldValue, err := m.oldValue(ctx)
  28356. if err != nil {
  28357. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  28358. }
  28359. return oldValue.App, nil
  28360. }
  28361. // AddApp adds i to the "app" field.
  28362. func (m *UsageDetailMutation) AddApp(i int) {
  28363. if m.addapp != nil {
  28364. *m.addapp += i
  28365. } else {
  28366. m.addapp = &i
  28367. }
  28368. }
  28369. // AddedApp returns the value that was added to the "app" field in this mutation.
  28370. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  28371. v := m.addapp
  28372. if v == nil {
  28373. return
  28374. }
  28375. return *v, true
  28376. }
  28377. // ClearApp clears the value of the "app" field.
  28378. func (m *UsageDetailMutation) ClearApp() {
  28379. m.app = nil
  28380. m.addapp = nil
  28381. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  28382. }
  28383. // AppCleared returns if the "app" field was cleared in this mutation.
  28384. func (m *UsageDetailMutation) AppCleared() bool {
  28385. _, ok := m.clearedFields[usagedetail.FieldApp]
  28386. return ok
  28387. }
  28388. // ResetApp resets all changes to the "app" field.
  28389. func (m *UsageDetailMutation) ResetApp() {
  28390. m.app = nil
  28391. m.addapp = nil
  28392. delete(m.clearedFields, usagedetail.FieldApp)
  28393. }
  28394. // SetSessionID sets the "session_id" field.
  28395. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  28396. m.session_id = &u
  28397. m.addsession_id = nil
  28398. }
  28399. // SessionID returns the value of the "session_id" field in the mutation.
  28400. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  28401. v := m.session_id
  28402. if v == nil {
  28403. return
  28404. }
  28405. return *v, true
  28406. }
  28407. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  28408. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28410. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  28411. if !m.op.Is(OpUpdateOne) {
  28412. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  28413. }
  28414. if m.id == nil || m.oldValue == nil {
  28415. return v, errors.New("OldSessionID requires an ID field in the mutation")
  28416. }
  28417. oldValue, err := m.oldValue(ctx)
  28418. if err != nil {
  28419. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  28420. }
  28421. return oldValue.SessionID, nil
  28422. }
  28423. // AddSessionID adds u to the "session_id" field.
  28424. func (m *UsageDetailMutation) AddSessionID(u int64) {
  28425. if m.addsession_id != nil {
  28426. *m.addsession_id += u
  28427. } else {
  28428. m.addsession_id = &u
  28429. }
  28430. }
  28431. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  28432. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  28433. v := m.addsession_id
  28434. if v == nil {
  28435. return
  28436. }
  28437. return *v, true
  28438. }
  28439. // ClearSessionID clears the value of the "session_id" field.
  28440. func (m *UsageDetailMutation) ClearSessionID() {
  28441. m.session_id = nil
  28442. m.addsession_id = nil
  28443. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  28444. }
  28445. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  28446. func (m *UsageDetailMutation) SessionIDCleared() bool {
  28447. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  28448. return ok
  28449. }
  28450. // ResetSessionID resets all changes to the "session_id" field.
  28451. func (m *UsageDetailMutation) ResetSessionID() {
  28452. m.session_id = nil
  28453. m.addsession_id = nil
  28454. delete(m.clearedFields, usagedetail.FieldSessionID)
  28455. }
  28456. // SetRequest sets the "request" field.
  28457. func (m *UsageDetailMutation) SetRequest(s string) {
  28458. m.request = &s
  28459. }
  28460. // Request returns the value of the "request" field in the mutation.
  28461. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  28462. v := m.request
  28463. if v == nil {
  28464. return
  28465. }
  28466. return *v, true
  28467. }
  28468. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  28469. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28471. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  28472. if !m.op.Is(OpUpdateOne) {
  28473. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  28474. }
  28475. if m.id == nil || m.oldValue == nil {
  28476. return v, errors.New("OldRequest requires an ID field in the mutation")
  28477. }
  28478. oldValue, err := m.oldValue(ctx)
  28479. if err != nil {
  28480. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  28481. }
  28482. return oldValue.Request, nil
  28483. }
  28484. // ResetRequest resets all changes to the "request" field.
  28485. func (m *UsageDetailMutation) ResetRequest() {
  28486. m.request = nil
  28487. }
  28488. // SetResponse sets the "response" field.
  28489. func (m *UsageDetailMutation) SetResponse(s string) {
  28490. m.response = &s
  28491. }
  28492. // Response returns the value of the "response" field in the mutation.
  28493. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  28494. v := m.response
  28495. if v == nil {
  28496. return
  28497. }
  28498. return *v, true
  28499. }
  28500. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  28501. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28503. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  28504. if !m.op.Is(OpUpdateOne) {
  28505. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  28506. }
  28507. if m.id == nil || m.oldValue == nil {
  28508. return v, errors.New("OldResponse requires an ID field in the mutation")
  28509. }
  28510. oldValue, err := m.oldValue(ctx)
  28511. if err != nil {
  28512. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  28513. }
  28514. return oldValue.Response, nil
  28515. }
  28516. // ResetResponse resets all changes to the "response" field.
  28517. func (m *UsageDetailMutation) ResetResponse() {
  28518. m.response = nil
  28519. }
  28520. // SetOriginalData sets the "original_data" field.
  28521. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  28522. m.original_data = &ctd
  28523. }
  28524. // OriginalData returns the value of the "original_data" field in the mutation.
  28525. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  28526. v := m.original_data
  28527. if v == nil {
  28528. return
  28529. }
  28530. return *v, true
  28531. }
  28532. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  28533. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28535. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  28536. if !m.op.Is(OpUpdateOne) {
  28537. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  28538. }
  28539. if m.id == nil || m.oldValue == nil {
  28540. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  28541. }
  28542. oldValue, err := m.oldValue(ctx)
  28543. if err != nil {
  28544. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  28545. }
  28546. return oldValue.OriginalData, nil
  28547. }
  28548. // ResetOriginalData resets all changes to the "original_data" field.
  28549. func (m *UsageDetailMutation) ResetOriginalData() {
  28550. m.original_data = nil
  28551. }
  28552. // SetTotalTokens sets the "total_tokens" field.
  28553. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  28554. m.total_tokens = &u
  28555. m.addtotal_tokens = nil
  28556. }
  28557. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  28558. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  28559. v := m.total_tokens
  28560. if v == nil {
  28561. return
  28562. }
  28563. return *v, true
  28564. }
  28565. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  28566. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28568. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  28569. if !m.op.Is(OpUpdateOne) {
  28570. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  28571. }
  28572. if m.id == nil || m.oldValue == nil {
  28573. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  28574. }
  28575. oldValue, err := m.oldValue(ctx)
  28576. if err != nil {
  28577. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  28578. }
  28579. return oldValue.TotalTokens, nil
  28580. }
  28581. // AddTotalTokens adds u to the "total_tokens" field.
  28582. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  28583. if m.addtotal_tokens != nil {
  28584. *m.addtotal_tokens += u
  28585. } else {
  28586. m.addtotal_tokens = &u
  28587. }
  28588. }
  28589. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  28590. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  28591. v := m.addtotal_tokens
  28592. if v == nil {
  28593. return
  28594. }
  28595. return *v, true
  28596. }
  28597. // ClearTotalTokens clears the value of the "total_tokens" field.
  28598. func (m *UsageDetailMutation) ClearTotalTokens() {
  28599. m.total_tokens = nil
  28600. m.addtotal_tokens = nil
  28601. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  28602. }
  28603. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  28604. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  28605. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  28606. return ok
  28607. }
  28608. // ResetTotalTokens resets all changes to the "total_tokens" field.
  28609. func (m *UsageDetailMutation) ResetTotalTokens() {
  28610. m.total_tokens = nil
  28611. m.addtotal_tokens = nil
  28612. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  28613. }
  28614. // SetPromptTokens sets the "prompt_tokens" field.
  28615. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  28616. m.prompt_tokens = &u
  28617. m.addprompt_tokens = nil
  28618. }
  28619. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  28620. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  28621. v := m.prompt_tokens
  28622. if v == nil {
  28623. return
  28624. }
  28625. return *v, true
  28626. }
  28627. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  28628. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28630. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  28631. if !m.op.Is(OpUpdateOne) {
  28632. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  28633. }
  28634. if m.id == nil || m.oldValue == nil {
  28635. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  28636. }
  28637. oldValue, err := m.oldValue(ctx)
  28638. if err != nil {
  28639. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  28640. }
  28641. return oldValue.PromptTokens, nil
  28642. }
  28643. // AddPromptTokens adds u to the "prompt_tokens" field.
  28644. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  28645. if m.addprompt_tokens != nil {
  28646. *m.addprompt_tokens += u
  28647. } else {
  28648. m.addprompt_tokens = &u
  28649. }
  28650. }
  28651. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  28652. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  28653. v := m.addprompt_tokens
  28654. if v == nil {
  28655. return
  28656. }
  28657. return *v, true
  28658. }
  28659. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  28660. func (m *UsageDetailMutation) ClearPromptTokens() {
  28661. m.prompt_tokens = nil
  28662. m.addprompt_tokens = nil
  28663. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  28664. }
  28665. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  28666. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  28667. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  28668. return ok
  28669. }
  28670. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  28671. func (m *UsageDetailMutation) ResetPromptTokens() {
  28672. m.prompt_tokens = nil
  28673. m.addprompt_tokens = nil
  28674. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  28675. }
  28676. // SetCompletionTokens sets the "completion_tokens" field.
  28677. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  28678. m.completion_tokens = &u
  28679. m.addcompletion_tokens = nil
  28680. }
  28681. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  28682. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  28683. v := m.completion_tokens
  28684. if v == nil {
  28685. return
  28686. }
  28687. return *v, true
  28688. }
  28689. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  28690. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28692. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  28693. if !m.op.Is(OpUpdateOne) {
  28694. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  28695. }
  28696. if m.id == nil || m.oldValue == nil {
  28697. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  28698. }
  28699. oldValue, err := m.oldValue(ctx)
  28700. if err != nil {
  28701. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  28702. }
  28703. return oldValue.CompletionTokens, nil
  28704. }
  28705. // AddCompletionTokens adds u to the "completion_tokens" field.
  28706. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  28707. if m.addcompletion_tokens != nil {
  28708. *m.addcompletion_tokens += u
  28709. } else {
  28710. m.addcompletion_tokens = &u
  28711. }
  28712. }
  28713. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  28714. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  28715. v := m.addcompletion_tokens
  28716. if v == nil {
  28717. return
  28718. }
  28719. return *v, true
  28720. }
  28721. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  28722. func (m *UsageDetailMutation) ClearCompletionTokens() {
  28723. m.completion_tokens = nil
  28724. m.addcompletion_tokens = nil
  28725. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  28726. }
  28727. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  28728. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  28729. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  28730. return ok
  28731. }
  28732. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  28733. func (m *UsageDetailMutation) ResetCompletionTokens() {
  28734. m.completion_tokens = nil
  28735. m.addcompletion_tokens = nil
  28736. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  28737. }
  28738. // SetOrganizationID sets the "organization_id" field.
  28739. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  28740. m.organization_id = &u
  28741. m.addorganization_id = nil
  28742. }
  28743. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28744. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  28745. v := m.organization_id
  28746. if v == nil {
  28747. return
  28748. }
  28749. return *v, true
  28750. }
  28751. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  28752. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28754. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28755. if !m.op.Is(OpUpdateOne) {
  28756. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28757. }
  28758. if m.id == nil || m.oldValue == nil {
  28759. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28760. }
  28761. oldValue, err := m.oldValue(ctx)
  28762. if err != nil {
  28763. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28764. }
  28765. return oldValue.OrganizationID, nil
  28766. }
  28767. // AddOrganizationID adds u to the "organization_id" field.
  28768. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  28769. if m.addorganization_id != nil {
  28770. *m.addorganization_id += u
  28771. } else {
  28772. m.addorganization_id = &u
  28773. }
  28774. }
  28775. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28776. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  28777. v := m.addorganization_id
  28778. if v == nil {
  28779. return
  28780. }
  28781. return *v, true
  28782. }
  28783. // ClearOrganizationID clears the value of the "organization_id" field.
  28784. func (m *UsageDetailMutation) ClearOrganizationID() {
  28785. m.organization_id = nil
  28786. m.addorganization_id = nil
  28787. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  28788. }
  28789. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28790. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  28791. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  28792. return ok
  28793. }
  28794. // ResetOrganizationID resets all changes to the "organization_id" field.
  28795. func (m *UsageDetailMutation) ResetOrganizationID() {
  28796. m.organization_id = nil
  28797. m.addorganization_id = nil
  28798. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  28799. }
  28800. // Where appends a list predicates to the UsageDetailMutation builder.
  28801. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  28802. m.predicates = append(m.predicates, ps...)
  28803. }
  28804. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  28805. // users can use type-assertion to append predicates that do not depend on any generated package.
  28806. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  28807. p := make([]predicate.UsageDetail, len(ps))
  28808. for i := range ps {
  28809. p[i] = ps[i]
  28810. }
  28811. m.Where(p...)
  28812. }
  28813. // Op returns the operation name.
  28814. func (m *UsageDetailMutation) Op() Op {
  28815. return m.op
  28816. }
  28817. // SetOp allows setting the mutation operation.
  28818. func (m *UsageDetailMutation) SetOp(op Op) {
  28819. m.op = op
  28820. }
  28821. // Type returns the node type of this mutation (UsageDetail).
  28822. func (m *UsageDetailMutation) Type() string {
  28823. return m.typ
  28824. }
  28825. // Fields returns all fields that were changed during this mutation. Note that in
  28826. // order to get all numeric fields that were incremented/decremented, call
  28827. // AddedFields().
  28828. func (m *UsageDetailMutation) Fields() []string {
  28829. fields := make([]string, 0, 15)
  28830. if m.created_at != nil {
  28831. fields = append(fields, usagedetail.FieldCreatedAt)
  28832. }
  28833. if m.updated_at != nil {
  28834. fields = append(fields, usagedetail.FieldUpdatedAt)
  28835. }
  28836. if m.status != nil {
  28837. fields = append(fields, usagedetail.FieldStatus)
  28838. }
  28839. if m._type != nil {
  28840. fields = append(fields, usagedetail.FieldType)
  28841. }
  28842. if m.bot_id != nil {
  28843. fields = append(fields, usagedetail.FieldBotID)
  28844. }
  28845. if m.receiver_id != nil {
  28846. fields = append(fields, usagedetail.FieldReceiverID)
  28847. }
  28848. if m.app != nil {
  28849. fields = append(fields, usagedetail.FieldApp)
  28850. }
  28851. if m.session_id != nil {
  28852. fields = append(fields, usagedetail.FieldSessionID)
  28853. }
  28854. if m.request != nil {
  28855. fields = append(fields, usagedetail.FieldRequest)
  28856. }
  28857. if m.response != nil {
  28858. fields = append(fields, usagedetail.FieldResponse)
  28859. }
  28860. if m.original_data != nil {
  28861. fields = append(fields, usagedetail.FieldOriginalData)
  28862. }
  28863. if m.total_tokens != nil {
  28864. fields = append(fields, usagedetail.FieldTotalTokens)
  28865. }
  28866. if m.prompt_tokens != nil {
  28867. fields = append(fields, usagedetail.FieldPromptTokens)
  28868. }
  28869. if m.completion_tokens != nil {
  28870. fields = append(fields, usagedetail.FieldCompletionTokens)
  28871. }
  28872. if m.organization_id != nil {
  28873. fields = append(fields, usagedetail.FieldOrganizationID)
  28874. }
  28875. return fields
  28876. }
  28877. // Field returns the value of a field with the given name. The second boolean
  28878. // return value indicates that this field was not set, or was not defined in the
  28879. // schema.
  28880. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  28881. switch name {
  28882. case usagedetail.FieldCreatedAt:
  28883. return m.CreatedAt()
  28884. case usagedetail.FieldUpdatedAt:
  28885. return m.UpdatedAt()
  28886. case usagedetail.FieldStatus:
  28887. return m.Status()
  28888. case usagedetail.FieldType:
  28889. return m.GetType()
  28890. case usagedetail.FieldBotID:
  28891. return m.BotID()
  28892. case usagedetail.FieldReceiverID:
  28893. return m.ReceiverID()
  28894. case usagedetail.FieldApp:
  28895. return m.App()
  28896. case usagedetail.FieldSessionID:
  28897. return m.SessionID()
  28898. case usagedetail.FieldRequest:
  28899. return m.Request()
  28900. case usagedetail.FieldResponse:
  28901. return m.Response()
  28902. case usagedetail.FieldOriginalData:
  28903. return m.OriginalData()
  28904. case usagedetail.FieldTotalTokens:
  28905. return m.TotalTokens()
  28906. case usagedetail.FieldPromptTokens:
  28907. return m.PromptTokens()
  28908. case usagedetail.FieldCompletionTokens:
  28909. return m.CompletionTokens()
  28910. case usagedetail.FieldOrganizationID:
  28911. return m.OrganizationID()
  28912. }
  28913. return nil, false
  28914. }
  28915. // OldField returns the old value of the field from the database. An error is
  28916. // returned if the mutation operation is not UpdateOne, or the query to the
  28917. // database failed.
  28918. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28919. switch name {
  28920. case usagedetail.FieldCreatedAt:
  28921. return m.OldCreatedAt(ctx)
  28922. case usagedetail.FieldUpdatedAt:
  28923. return m.OldUpdatedAt(ctx)
  28924. case usagedetail.FieldStatus:
  28925. return m.OldStatus(ctx)
  28926. case usagedetail.FieldType:
  28927. return m.OldType(ctx)
  28928. case usagedetail.FieldBotID:
  28929. return m.OldBotID(ctx)
  28930. case usagedetail.FieldReceiverID:
  28931. return m.OldReceiverID(ctx)
  28932. case usagedetail.FieldApp:
  28933. return m.OldApp(ctx)
  28934. case usagedetail.FieldSessionID:
  28935. return m.OldSessionID(ctx)
  28936. case usagedetail.FieldRequest:
  28937. return m.OldRequest(ctx)
  28938. case usagedetail.FieldResponse:
  28939. return m.OldResponse(ctx)
  28940. case usagedetail.FieldOriginalData:
  28941. return m.OldOriginalData(ctx)
  28942. case usagedetail.FieldTotalTokens:
  28943. return m.OldTotalTokens(ctx)
  28944. case usagedetail.FieldPromptTokens:
  28945. return m.OldPromptTokens(ctx)
  28946. case usagedetail.FieldCompletionTokens:
  28947. return m.OldCompletionTokens(ctx)
  28948. case usagedetail.FieldOrganizationID:
  28949. return m.OldOrganizationID(ctx)
  28950. }
  28951. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  28952. }
  28953. // SetField sets the value of a field with the given name. It returns an error if
  28954. // the field is not defined in the schema, or if the type mismatched the field
  28955. // type.
  28956. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  28957. switch name {
  28958. case usagedetail.FieldCreatedAt:
  28959. v, ok := value.(time.Time)
  28960. if !ok {
  28961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28962. }
  28963. m.SetCreatedAt(v)
  28964. return nil
  28965. case usagedetail.FieldUpdatedAt:
  28966. v, ok := value.(time.Time)
  28967. if !ok {
  28968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28969. }
  28970. m.SetUpdatedAt(v)
  28971. return nil
  28972. case usagedetail.FieldStatus:
  28973. v, ok := value.(uint8)
  28974. if !ok {
  28975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28976. }
  28977. m.SetStatus(v)
  28978. return nil
  28979. case usagedetail.FieldType:
  28980. v, ok := value.(int)
  28981. if !ok {
  28982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28983. }
  28984. m.SetType(v)
  28985. return nil
  28986. case usagedetail.FieldBotID:
  28987. v, ok := value.(string)
  28988. if !ok {
  28989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28990. }
  28991. m.SetBotID(v)
  28992. return nil
  28993. case usagedetail.FieldReceiverID:
  28994. v, ok := value.(string)
  28995. if !ok {
  28996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28997. }
  28998. m.SetReceiverID(v)
  28999. return nil
  29000. case usagedetail.FieldApp:
  29001. v, ok := value.(int)
  29002. if !ok {
  29003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29004. }
  29005. m.SetApp(v)
  29006. return nil
  29007. case usagedetail.FieldSessionID:
  29008. v, ok := value.(uint64)
  29009. if !ok {
  29010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29011. }
  29012. m.SetSessionID(v)
  29013. return nil
  29014. case usagedetail.FieldRequest:
  29015. v, ok := value.(string)
  29016. if !ok {
  29017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29018. }
  29019. m.SetRequest(v)
  29020. return nil
  29021. case usagedetail.FieldResponse:
  29022. v, ok := value.(string)
  29023. if !ok {
  29024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29025. }
  29026. m.SetResponse(v)
  29027. return nil
  29028. case usagedetail.FieldOriginalData:
  29029. v, ok := value.(custom_types.OriginalData)
  29030. if !ok {
  29031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29032. }
  29033. m.SetOriginalData(v)
  29034. return nil
  29035. case usagedetail.FieldTotalTokens:
  29036. v, ok := value.(uint64)
  29037. if !ok {
  29038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29039. }
  29040. m.SetTotalTokens(v)
  29041. return nil
  29042. case usagedetail.FieldPromptTokens:
  29043. v, ok := value.(uint64)
  29044. if !ok {
  29045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29046. }
  29047. m.SetPromptTokens(v)
  29048. return nil
  29049. case usagedetail.FieldCompletionTokens:
  29050. v, ok := value.(uint64)
  29051. if !ok {
  29052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29053. }
  29054. m.SetCompletionTokens(v)
  29055. return nil
  29056. case usagedetail.FieldOrganizationID:
  29057. v, ok := value.(uint64)
  29058. if !ok {
  29059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29060. }
  29061. m.SetOrganizationID(v)
  29062. return nil
  29063. }
  29064. return fmt.Errorf("unknown UsageDetail field %s", name)
  29065. }
  29066. // AddedFields returns all numeric fields that were incremented/decremented during
  29067. // this mutation.
  29068. func (m *UsageDetailMutation) AddedFields() []string {
  29069. var fields []string
  29070. if m.addstatus != nil {
  29071. fields = append(fields, usagedetail.FieldStatus)
  29072. }
  29073. if m.add_type != nil {
  29074. fields = append(fields, usagedetail.FieldType)
  29075. }
  29076. if m.addapp != nil {
  29077. fields = append(fields, usagedetail.FieldApp)
  29078. }
  29079. if m.addsession_id != nil {
  29080. fields = append(fields, usagedetail.FieldSessionID)
  29081. }
  29082. if m.addtotal_tokens != nil {
  29083. fields = append(fields, usagedetail.FieldTotalTokens)
  29084. }
  29085. if m.addprompt_tokens != nil {
  29086. fields = append(fields, usagedetail.FieldPromptTokens)
  29087. }
  29088. if m.addcompletion_tokens != nil {
  29089. fields = append(fields, usagedetail.FieldCompletionTokens)
  29090. }
  29091. if m.addorganization_id != nil {
  29092. fields = append(fields, usagedetail.FieldOrganizationID)
  29093. }
  29094. return fields
  29095. }
  29096. // AddedField returns the numeric value that was incremented/decremented on a field
  29097. // with the given name. The second boolean return value indicates that this field
  29098. // was not set, or was not defined in the schema.
  29099. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  29100. switch name {
  29101. case usagedetail.FieldStatus:
  29102. return m.AddedStatus()
  29103. case usagedetail.FieldType:
  29104. return m.AddedType()
  29105. case usagedetail.FieldApp:
  29106. return m.AddedApp()
  29107. case usagedetail.FieldSessionID:
  29108. return m.AddedSessionID()
  29109. case usagedetail.FieldTotalTokens:
  29110. return m.AddedTotalTokens()
  29111. case usagedetail.FieldPromptTokens:
  29112. return m.AddedPromptTokens()
  29113. case usagedetail.FieldCompletionTokens:
  29114. return m.AddedCompletionTokens()
  29115. case usagedetail.FieldOrganizationID:
  29116. return m.AddedOrganizationID()
  29117. }
  29118. return nil, false
  29119. }
  29120. // AddField adds the value to the field with the given name. It returns an error if
  29121. // the field is not defined in the schema, or if the type mismatched the field
  29122. // type.
  29123. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  29124. switch name {
  29125. case usagedetail.FieldStatus:
  29126. v, ok := value.(int8)
  29127. if !ok {
  29128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29129. }
  29130. m.AddStatus(v)
  29131. return nil
  29132. case usagedetail.FieldType:
  29133. v, ok := value.(int)
  29134. if !ok {
  29135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29136. }
  29137. m.AddType(v)
  29138. return nil
  29139. case usagedetail.FieldApp:
  29140. v, ok := value.(int)
  29141. if !ok {
  29142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29143. }
  29144. m.AddApp(v)
  29145. return nil
  29146. case usagedetail.FieldSessionID:
  29147. v, ok := value.(int64)
  29148. if !ok {
  29149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29150. }
  29151. m.AddSessionID(v)
  29152. return nil
  29153. case usagedetail.FieldTotalTokens:
  29154. v, ok := value.(int64)
  29155. if !ok {
  29156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29157. }
  29158. m.AddTotalTokens(v)
  29159. return nil
  29160. case usagedetail.FieldPromptTokens:
  29161. v, ok := value.(int64)
  29162. if !ok {
  29163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29164. }
  29165. m.AddPromptTokens(v)
  29166. return nil
  29167. case usagedetail.FieldCompletionTokens:
  29168. v, ok := value.(int64)
  29169. if !ok {
  29170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29171. }
  29172. m.AddCompletionTokens(v)
  29173. return nil
  29174. case usagedetail.FieldOrganizationID:
  29175. v, ok := value.(int64)
  29176. if !ok {
  29177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29178. }
  29179. m.AddOrganizationID(v)
  29180. return nil
  29181. }
  29182. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  29183. }
  29184. // ClearedFields returns all nullable fields that were cleared during this
  29185. // mutation.
  29186. func (m *UsageDetailMutation) ClearedFields() []string {
  29187. var fields []string
  29188. if m.FieldCleared(usagedetail.FieldStatus) {
  29189. fields = append(fields, usagedetail.FieldStatus)
  29190. }
  29191. if m.FieldCleared(usagedetail.FieldType) {
  29192. fields = append(fields, usagedetail.FieldType)
  29193. }
  29194. if m.FieldCleared(usagedetail.FieldApp) {
  29195. fields = append(fields, usagedetail.FieldApp)
  29196. }
  29197. if m.FieldCleared(usagedetail.FieldSessionID) {
  29198. fields = append(fields, usagedetail.FieldSessionID)
  29199. }
  29200. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  29201. fields = append(fields, usagedetail.FieldTotalTokens)
  29202. }
  29203. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  29204. fields = append(fields, usagedetail.FieldPromptTokens)
  29205. }
  29206. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  29207. fields = append(fields, usagedetail.FieldCompletionTokens)
  29208. }
  29209. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  29210. fields = append(fields, usagedetail.FieldOrganizationID)
  29211. }
  29212. return fields
  29213. }
  29214. // FieldCleared returns a boolean indicating if a field with the given name was
  29215. // cleared in this mutation.
  29216. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  29217. _, ok := m.clearedFields[name]
  29218. return ok
  29219. }
  29220. // ClearField clears the value of the field with the given name. It returns an
  29221. // error if the field is not defined in the schema.
  29222. func (m *UsageDetailMutation) ClearField(name string) error {
  29223. switch name {
  29224. case usagedetail.FieldStatus:
  29225. m.ClearStatus()
  29226. return nil
  29227. case usagedetail.FieldType:
  29228. m.ClearType()
  29229. return nil
  29230. case usagedetail.FieldApp:
  29231. m.ClearApp()
  29232. return nil
  29233. case usagedetail.FieldSessionID:
  29234. m.ClearSessionID()
  29235. return nil
  29236. case usagedetail.FieldTotalTokens:
  29237. m.ClearTotalTokens()
  29238. return nil
  29239. case usagedetail.FieldPromptTokens:
  29240. m.ClearPromptTokens()
  29241. return nil
  29242. case usagedetail.FieldCompletionTokens:
  29243. m.ClearCompletionTokens()
  29244. return nil
  29245. case usagedetail.FieldOrganizationID:
  29246. m.ClearOrganizationID()
  29247. return nil
  29248. }
  29249. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  29250. }
  29251. // ResetField resets all changes in the mutation for the field with the given name.
  29252. // It returns an error if the field is not defined in the schema.
  29253. func (m *UsageDetailMutation) ResetField(name string) error {
  29254. switch name {
  29255. case usagedetail.FieldCreatedAt:
  29256. m.ResetCreatedAt()
  29257. return nil
  29258. case usagedetail.FieldUpdatedAt:
  29259. m.ResetUpdatedAt()
  29260. return nil
  29261. case usagedetail.FieldStatus:
  29262. m.ResetStatus()
  29263. return nil
  29264. case usagedetail.FieldType:
  29265. m.ResetType()
  29266. return nil
  29267. case usagedetail.FieldBotID:
  29268. m.ResetBotID()
  29269. return nil
  29270. case usagedetail.FieldReceiverID:
  29271. m.ResetReceiverID()
  29272. return nil
  29273. case usagedetail.FieldApp:
  29274. m.ResetApp()
  29275. return nil
  29276. case usagedetail.FieldSessionID:
  29277. m.ResetSessionID()
  29278. return nil
  29279. case usagedetail.FieldRequest:
  29280. m.ResetRequest()
  29281. return nil
  29282. case usagedetail.FieldResponse:
  29283. m.ResetResponse()
  29284. return nil
  29285. case usagedetail.FieldOriginalData:
  29286. m.ResetOriginalData()
  29287. return nil
  29288. case usagedetail.FieldTotalTokens:
  29289. m.ResetTotalTokens()
  29290. return nil
  29291. case usagedetail.FieldPromptTokens:
  29292. m.ResetPromptTokens()
  29293. return nil
  29294. case usagedetail.FieldCompletionTokens:
  29295. m.ResetCompletionTokens()
  29296. return nil
  29297. case usagedetail.FieldOrganizationID:
  29298. m.ResetOrganizationID()
  29299. return nil
  29300. }
  29301. return fmt.Errorf("unknown UsageDetail field %s", name)
  29302. }
  29303. // AddedEdges returns all edge names that were set/added in this mutation.
  29304. func (m *UsageDetailMutation) AddedEdges() []string {
  29305. edges := make([]string, 0, 0)
  29306. return edges
  29307. }
  29308. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29309. // name in this mutation.
  29310. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  29311. return nil
  29312. }
  29313. // RemovedEdges returns all edge names that were removed in this mutation.
  29314. func (m *UsageDetailMutation) RemovedEdges() []string {
  29315. edges := make([]string, 0, 0)
  29316. return edges
  29317. }
  29318. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29319. // the given name in this mutation.
  29320. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  29321. return nil
  29322. }
  29323. // ClearedEdges returns all edge names that were cleared in this mutation.
  29324. func (m *UsageDetailMutation) ClearedEdges() []string {
  29325. edges := make([]string, 0, 0)
  29326. return edges
  29327. }
  29328. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29329. // was cleared in this mutation.
  29330. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  29331. return false
  29332. }
  29333. // ClearEdge clears the value of the edge with the given name. It returns an error
  29334. // if that edge is not defined in the schema.
  29335. func (m *UsageDetailMutation) ClearEdge(name string) error {
  29336. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  29337. }
  29338. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29339. // It returns an error if the edge is not defined in the schema.
  29340. func (m *UsageDetailMutation) ResetEdge(name string) error {
  29341. return fmt.Errorf("unknown UsageDetail edge %s", name)
  29342. }
  29343. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  29344. type UsageStatisticDayMutation struct {
  29345. config
  29346. op Op
  29347. typ string
  29348. id *uint64
  29349. created_at *time.Time
  29350. updated_at *time.Time
  29351. status *uint8
  29352. addstatus *int8
  29353. deleted_at *time.Time
  29354. addtime *uint64
  29355. addaddtime *int64
  29356. _type *int
  29357. add_type *int
  29358. bot_id *string
  29359. organization_id *uint64
  29360. addorganization_id *int64
  29361. ai_response *uint64
  29362. addai_response *int64
  29363. sop_run *uint64
  29364. addsop_run *int64
  29365. total_friend *uint64
  29366. addtotal_friend *int64
  29367. total_group *uint64
  29368. addtotal_group *int64
  29369. account_balance *uint64
  29370. addaccount_balance *int64
  29371. consume_token *uint64
  29372. addconsume_token *int64
  29373. active_user *uint64
  29374. addactive_user *int64
  29375. new_user *int64
  29376. addnew_user *int64
  29377. label_dist *[]custom_types.LabelDist
  29378. appendlabel_dist []custom_types.LabelDist
  29379. clearedFields map[string]struct{}
  29380. done bool
  29381. oldValue func(context.Context) (*UsageStatisticDay, error)
  29382. predicates []predicate.UsageStatisticDay
  29383. }
  29384. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  29385. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  29386. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  29387. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  29388. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  29389. m := &UsageStatisticDayMutation{
  29390. config: c,
  29391. op: op,
  29392. typ: TypeUsageStatisticDay,
  29393. clearedFields: make(map[string]struct{}),
  29394. }
  29395. for _, opt := range opts {
  29396. opt(m)
  29397. }
  29398. return m
  29399. }
  29400. // withUsageStatisticDayID sets the ID field of the mutation.
  29401. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  29402. return func(m *UsageStatisticDayMutation) {
  29403. var (
  29404. err error
  29405. once sync.Once
  29406. value *UsageStatisticDay
  29407. )
  29408. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  29409. once.Do(func() {
  29410. if m.done {
  29411. err = errors.New("querying old values post mutation is not allowed")
  29412. } else {
  29413. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  29414. }
  29415. })
  29416. return value, err
  29417. }
  29418. m.id = &id
  29419. }
  29420. }
  29421. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  29422. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  29423. return func(m *UsageStatisticDayMutation) {
  29424. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  29425. return node, nil
  29426. }
  29427. m.id = &node.ID
  29428. }
  29429. }
  29430. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29431. // executed in a transaction (ent.Tx), a transactional client is returned.
  29432. func (m UsageStatisticDayMutation) Client() *Client {
  29433. client := &Client{config: m.config}
  29434. client.init()
  29435. return client
  29436. }
  29437. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29438. // it returns an error otherwise.
  29439. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  29440. if _, ok := m.driver.(*txDriver); !ok {
  29441. return nil, errors.New("ent: mutation is not running in a transaction")
  29442. }
  29443. tx := &Tx{config: m.config}
  29444. tx.init()
  29445. return tx, nil
  29446. }
  29447. // SetID sets the value of the id field. Note that this
  29448. // operation is only accepted on creation of UsageStatisticDay entities.
  29449. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  29450. m.id = &id
  29451. }
  29452. // ID returns the ID value in the mutation. Note that the ID is only available
  29453. // if it was provided to the builder or after it was returned from the database.
  29454. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  29455. if m.id == nil {
  29456. return
  29457. }
  29458. return *m.id, true
  29459. }
  29460. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29461. // That means, if the mutation is applied within a transaction with an isolation level such
  29462. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29463. // or updated by the mutation.
  29464. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  29465. switch {
  29466. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29467. id, exists := m.ID()
  29468. if exists {
  29469. return []uint64{id}, nil
  29470. }
  29471. fallthrough
  29472. case m.op.Is(OpUpdate | OpDelete):
  29473. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  29474. default:
  29475. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29476. }
  29477. }
  29478. // SetCreatedAt sets the "created_at" field.
  29479. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  29480. m.created_at = &t
  29481. }
  29482. // CreatedAt returns the value of the "created_at" field in the mutation.
  29483. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  29484. v := m.created_at
  29485. if v == nil {
  29486. return
  29487. }
  29488. return *v, true
  29489. }
  29490. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  29491. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29493. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29494. if !m.op.Is(OpUpdateOne) {
  29495. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29496. }
  29497. if m.id == nil || m.oldValue == nil {
  29498. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29499. }
  29500. oldValue, err := m.oldValue(ctx)
  29501. if err != nil {
  29502. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29503. }
  29504. return oldValue.CreatedAt, nil
  29505. }
  29506. // ResetCreatedAt resets all changes to the "created_at" field.
  29507. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  29508. m.created_at = nil
  29509. }
  29510. // SetUpdatedAt sets the "updated_at" field.
  29511. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  29512. m.updated_at = &t
  29513. }
  29514. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29515. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  29516. v := m.updated_at
  29517. if v == nil {
  29518. return
  29519. }
  29520. return *v, true
  29521. }
  29522. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  29523. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29525. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29526. if !m.op.Is(OpUpdateOne) {
  29527. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29528. }
  29529. if m.id == nil || m.oldValue == nil {
  29530. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29531. }
  29532. oldValue, err := m.oldValue(ctx)
  29533. if err != nil {
  29534. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29535. }
  29536. return oldValue.UpdatedAt, nil
  29537. }
  29538. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29539. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  29540. m.updated_at = nil
  29541. }
  29542. // SetStatus sets the "status" field.
  29543. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  29544. m.status = &u
  29545. m.addstatus = nil
  29546. }
  29547. // Status returns the value of the "status" field in the mutation.
  29548. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  29549. v := m.status
  29550. if v == nil {
  29551. return
  29552. }
  29553. return *v, true
  29554. }
  29555. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  29556. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29558. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29559. if !m.op.Is(OpUpdateOne) {
  29560. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29561. }
  29562. if m.id == nil || m.oldValue == nil {
  29563. return v, errors.New("OldStatus requires an ID field in the mutation")
  29564. }
  29565. oldValue, err := m.oldValue(ctx)
  29566. if err != nil {
  29567. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29568. }
  29569. return oldValue.Status, nil
  29570. }
  29571. // AddStatus adds u to the "status" field.
  29572. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  29573. if m.addstatus != nil {
  29574. *m.addstatus += u
  29575. } else {
  29576. m.addstatus = &u
  29577. }
  29578. }
  29579. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29580. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  29581. v := m.addstatus
  29582. if v == nil {
  29583. return
  29584. }
  29585. return *v, true
  29586. }
  29587. // ClearStatus clears the value of the "status" field.
  29588. func (m *UsageStatisticDayMutation) ClearStatus() {
  29589. m.status = nil
  29590. m.addstatus = nil
  29591. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  29592. }
  29593. // StatusCleared returns if the "status" field was cleared in this mutation.
  29594. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  29595. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  29596. return ok
  29597. }
  29598. // ResetStatus resets all changes to the "status" field.
  29599. func (m *UsageStatisticDayMutation) ResetStatus() {
  29600. m.status = nil
  29601. m.addstatus = nil
  29602. delete(m.clearedFields, usagestatisticday.FieldStatus)
  29603. }
  29604. // SetDeletedAt sets the "deleted_at" field.
  29605. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  29606. m.deleted_at = &t
  29607. }
  29608. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29609. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  29610. v := m.deleted_at
  29611. if v == nil {
  29612. return
  29613. }
  29614. return *v, true
  29615. }
  29616. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  29617. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29619. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29620. if !m.op.Is(OpUpdateOne) {
  29621. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29622. }
  29623. if m.id == nil || m.oldValue == nil {
  29624. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29625. }
  29626. oldValue, err := m.oldValue(ctx)
  29627. if err != nil {
  29628. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29629. }
  29630. return oldValue.DeletedAt, nil
  29631. }
  29632. // ClearDeletedAt clears the value of the "deleted_at" field.
  29633. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  29634. m.deleted_at = nil
  29635. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  29636. }
  29637. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29638. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  29639. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  29640. return ok
  29641. }
  29642. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29643. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  29644. m.deleted_at = nil
  29645. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  29646. }
  29647. // SetAddtime sets the "addtime" field.
  29648. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  29649. m.addtime = &u
  29650. m.addaddtime = nil
  29651. }
  29652. // Addtime returns the value of the "addtime" field in the mutation.
  29653. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  29654. v := m.addtime
  29655. if v == nil {
  29656. return
  29657. }
  29658. return *v, true
  29659. }
  29660. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  29661. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29663. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29664. if !m.op.Is(OpUpdateOne) {
  29665. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29666. }
  29667. if m.id == nil || m.oldValue == nil {
  29668. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29669. }
  29670. oldValue, err := m.oldValue(ctx)
  29671. if err != nil {
  29672. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29673. }
  29674. return oldValue.Addtime, nil
  29675. }
  29676. // AddAddtime adds u to the "addtime" field.
  29677. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  29678. if m.addaddtime != nil {
  29679. *m.addaddtime += u
  29680. } else {
  29681. m.addaddtime = &u
  29682. }
  29683. }
  29684. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29685. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  29686. v := m.addaddtime
  29687. if v == nil {
  29688. return
  29689. }
  29690. return *v, true
  29691. }
  29692. // ResetAddtime resets all changes to the "addtime" field.
  29693. func (m *UsageStatisticDayMutation) ResetAddtime() {
  29694. m.addtime = nil
  29695. m.addaddtime = nil
  29696. }
  29697. // SetType sets the "type" field.
  29698. func (m *UsageStatisticDayMutation) SetType(i int) {
  29699. m._type = &i
  29700. m.add_type = nil
  29701. }
  29702. // GetType returns the value of the "type" field in the mutation.
  29703. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  29704. v := m._type
  29705. if v == nil {
  29706. return
  29707. }
  29708. return *v, true
  29709. }
  29710. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  29711. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29713. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  29714. if !m.op.Is(OpUpdateOne) {
  29715. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29716. }
  29717. if m.id == nil || m.oldValue == nil {
  29718. return v, errors.New("OldType requires an ID field in the mutation")
  29719. }
  29720. oldValue, err := m.oldValue(ctx)
  29721. if err != nil {
  29722. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29723. }
  29724. return oldValue.Type, nil
  29725. }
  29726. // AddType adds i to the "type" field.
  29727. func (m *UsageStatisticDayMutation) AddType(i int) {
  29728. if m.add_type != nil {
  29729. *m.add_type += i
  29730. } else {
  29731. m.add_type = &i
  29732. }
  29733. }
  29734. // AddedType returns the value that was added to the "type" field in this mutation.
  29735. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  29736. v := m.add_type
  29737. if v == nil {
  29738. return
  29739. }
  29740. return *v, true
  29741. }
  29742. // ResetType resets all changes to the "type" field.
  29743. func (m *UsageStatisticDayMutation) ResetType() {
  29744. m._type = nil
  29745. m.add_type = nil
  29746. }
  29747. // SetBotID sets the "bot_id" field.
  29748. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  29749. m.bot_id = &s
  29750. }
  29751. // BotID returns the value of the "bot_id" field in the mutation.
  29752. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  29753. v := m.bot_id
  29754. if v == nil {
  29755. return
  29756. }
  29757. return *v, true
  29758. }
  29759. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  29760. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29762. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  29763. if !m.op.Is(OpUpdateOne) {
  29764. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29765. }
  29766. if m.id == nil || m.oldValue == nil {
  29767. return v, errors.New("OldBotID requires an ID field in the mutation")
  29768. }
  29769. oldValue, err := m.oldValue(ctx)
  29770. if err != nil {
  29771. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29772. }
  29773. return oldValue.BotID, nil
  29774. }
  29775. // ClearBotID clears the value of the "bot_id" field.
  29776. func (m *UsageStatisticDayMutation) ClearBotID() {
  29777. m.bot_id = nil
  29778. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  29779. }
  29780. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  29781. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  29782. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  29783. return ok
  29784. }
  29785. // ResetBotID resets all changes to the "bot_id" field.
  29786. func (m *UsageStatisticDayMutation) ResetBotID() {
  29787. m.bot_id = nil
  29788. delete(m.clearedFields, usagestatisticday.FieldBotID)
  29789. }
  29790. // SetOrganizationID sets the "organization_id" field.
  29791. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  29792. m.organization_id = &u
  29793. m.addorganization_id = nil
  29794. }
  29795. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29796. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  29797. v := m.organization_id
  29798. if v == nil {
  29799. return
  29800. }
  29801. return *v, true
  29802. }
  29803. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  29804. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29806. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29807. if !m.op.Is(OpUpdateOne) {
  29808. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29809. }
  29810. if m.id == nil || m.oldValue == nil {
  29811. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29812. }
  29813. oldValue, err := m.oldValue(ctx)
  29814. if err != nil {
  29815. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29816. }
  29817. return oldValue.OrganizationID, nil
  29818. }
  29819. // AddOrganizationID adds u to the "organization_id" field.
  29820. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  29821. if m.addorganization_id != nil {
  29822. *m.addorganization_id += u
  29823. } else {
  29824. m.addorganization_id = &u
  29825. }
  29826. }
  29827. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29828. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  29829. v := m.addorganization_id
  29830. if v == nil {
  29831. return
  29832. }
  29833. return *v, true
  29834. }
  29835. // ClearOrganizationID clears the value of the "organization_id" field.
  29836. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  29837. m.organization_id = nil
  29838. m.addorganization_id = nil
  29839. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  29840. }
  29841. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29842. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  29843. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  29844. return ok
  29845. }
  29846. // ResetOrganizationID resets all changes to the "organization_id" field.
  29847. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  29848. m.organization_id = nil
  29849. m.addorganization_id = nil
  29850. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  29851. }
  29852. // SetAiResponse sets the "ai_response" field.
  29853. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  29854. m.ai_response = &u
  29855. m.addai_response = nil
  29856. }
  29857. // AiResponse returns the value of the "ai_response" field in the mutation.
  29858. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  29859. v := m.ai_response
  29860. if v == nil {
  29861. return
  29862. }
  29863. return *v, true
  29864. }
  29865. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  29866. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29868. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  29869. if !m.op.Is(OpUpdateOne) {
  29870. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  29871. }
  29872. if m.id == nil || m.oldValue == nil {
  29873. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  29874. }
  29875. oldValue, err := m.oldValue(ctx)
  29876. if err != nil {
  29877. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  29878. }
  29879. return oldValue.AiResponse, nil
  29880. }
  29881. // AddAiResponse adds u to the "ai_response" field.
  29882. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  29883. if m.addai_response != nil {
  29884. *m.addai_response += u
  29885. } else {
  29886. m.addai_response = &u
  29887. }
  29888. }
  29889. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  29890. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  29891. v := m.addai_response
  29892. if v == nil {
  29893. return
  29894. }
  29895. return *v, true
  29896. }
  29897. // ResetAiResponse resets all changes to the "ai_response" field.
  29898. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  29899. m.ai_response = nil
  29900. m.addai_response = nil
  29901. }
  29902. // SetSopRun sets the "sop_run" field.
  29903. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  29904. m.sop_run = &u
  29905. m.addsop_run = nil
  29906. }
  29907. // SopRun returns the value of the "sop_run" field in the mutation.
  29908. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  29909. v := m.sop_run
  29910. if v == nil {
  29911. return
  29912. }
  29913. return *v, true
  29914. }
  29915. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  29916. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29918. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  29919. if !m.op.Is(OpUpdateOne) {
  29920. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  29921. }
  29922. if m.id == nil || m.oldValue == nil {
  29923. return v, errors.New("OldSopRun requires an ID field in the mutation")
  29924. }
  29925. oldValue, err := m.oldValue(ctx)
  29926. if err != nil {
  29927. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  29928. }
  29929. return oldValue.SopRun, nil
  29930. }
  29931. // AddSopRun adds u to the "sop_run" field.
  29932. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  29933. if m.addsop_run != nil {
  29934. *m.addsop_run += u
  29935. } else {
  29936. m.addsop_run = &u
  29937. }
  29938. }
  29939. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  29940. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  29941. v := m.addsop_run
  29942. if v == nil {
  29943. return
  29944. }
  29945. return *v, true
  29946. }
  29947. // ResetSopRun resets all changes to the "sop_run" field.
  29948. func (m *UsageStatisticDayMutation) ResetSopRun() {
  29949. m.sop_run = nil
  29950. m.addsop_run = nil
  29951. }
  29952. // SetTotalFriend sets the "total_friend" field.
  29953. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  29954. m.total_friend = &u
  29955. m.addtotal_friend = nil
  29956. }
  29957. // TotalFriend returns the value of the "total_friend" field in the mutation.
  29958. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  29959. v := m.total_friend
  29960. if v == nil {
  29961. return
  29962. }
  29963. return *v, true
  29964. }
  29965. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  29966. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29968. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  29969. if !m.op.Is(OpUpdateOne) {
  29970. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  29971. }
  29972. if m.id == nil || m.oldValue == nil {
  29973. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  29974. }
  29975. oldValue, err := m.oldValue(ctx)
  29976. if err != nil {
  29977. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  29978. }
  29979. return oldValue.TotalFriend, nil
  29980. }
  29981. // AddTotalFriend adds u to the "total_friend" field.
  29982. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  29983. if m.addtotal_friend != nil {
  29984. *m.addtotal_friend += u
  29985. } else {
  29986. m.addtotal_friend = &u
  29987. }
  29988. }
  29989. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  29990. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  29991. v := m.addtotal_friend
  29992. if v == nil {
  29993. return
  29994. }
  29995. return *v, true
  29996. }
  29997. // ResetTotalFriend resets all changes to the "total_friend" field.
  29998. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  29999. m.total_friend = nil
  30000. m.addtotal_friend = nil
  30001. }
  30002. // SetTotalGroup sets the "total_group" field.
  30003. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  30004. m.total_group = &u
  30005. m.addtotal_group = nil
  30006. }
  30007. // TotalGroup returns the value of the "total_group" field in the mutation.
  30008. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  30009. v := m.total_group
  30010. if v == nil {
  30011. return
  30012. }
  30013. return *v, true
  30014. }
  30015. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  30016. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30018. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30019. if !m.op.Is(OpUpdateOne) {
  30020. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30021. }
  30022. if m.id == nil || m.oldValue == nil {
  30023. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30024. }
  30025. oldValue, err := m.oldValue(ctx)
  30026. if err != nil {
  30027. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30028. }
  30029. return oldValue.TotalGroup, nil
  30030. }
  30031. // AddTotalGroup adds u to the "total_group" field.
  30032. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  30033. if m.addtotal_group != nil {
  30034. *m.addtotal_group += u
  30035. } else {
  30036. m.addtotal_group = &u
  30037. }
  30038. }
  30039. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30040. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  30041. v := m.addtotal_group
  30042. if v == nil {
  30043. return
  30044. }
  30045. return *v, true
  30046. }
  30047. // ResetTotalGroup resets all changes to the "total_group" field.
  30048. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  30049. m.total_group = nil
  30050. m.addtotal_group = nil
  30051. }
  30052. // SetAccountBalance sets the "account_balance" field.
  30053. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  30054. m.account_balance = &u
  30055. m.addaccount_balance = nil
  30056. }
  30057. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30058. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  30059. v := m.account_balance
  30060. if v == nil {
  30061. return
  30062. }
  30063. return *v, true
  30064. }
  30065. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  30066. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30068. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30069. if !m.op.Is(OpUpdateOne) {
  30070. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30071. }
  30072. if m.id == nil || m.oldValue == nil {
  30073. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30074. }
  30075. oldValue, err := m.oldValue(ctx)
  30076. if err != nil {
  30077. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30078. }
  30079. return oldValue.AccountBalance, nil
  30080. }
  30081. // AddAccountBalance adds u to the "account_balance" field.
  30082. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  30083. if m.addaccount_balance != nil {
  30084. *m.addaccount_balance += u
  30085. } else {
  30086. m.addaccount_balance = &u
  30087. }
  30088. }
  30089. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30090. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  30091. v := m.addaccount_balance
  30092. if v == nil {
  30093. return
  30094. }
  30095. return *v, true
  30096. }
  30097. // ResetAccountBalance resets all changes to the "account_balance" field.
  30098. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  30099. m.account_balance = nil
  30100. m.addaccount_balance = nil
  30101. }
  30102. // SetConsumeToken sets the "consume_token" field.
  30103. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  30104. m.consume_token = &u
  30105. m.addconsume_token = nil
  30106. }
  30107. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  30108. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  30109. v := m.consume_token
  30110. if v == nil {
  30111. return
  30112. }
  30113. return *v, true
  30114. }
  30115. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  30116. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30118. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  30119. if !m.op.Is(OpUpdateOne) {
  30120. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  30121. }
  30122. if m.id == nil || m.oldValue == nil {
  30123. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  30124. }
  30125. oldValue, err := m.oldValue(ctx)
  30126. if err != nil {
  30127. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  30128. }
  30129. return oldValue.ConsumeToken, nil
  30130. }
  30131. // AddConsumeToken adds u to the "consume_token" field.
  30132. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  30133. if m.addconsume_token != nil {
  30134. *m.addconsume_token += u
  30135. } else {
  30136. m.addconsume_token = &u
  30137. }
  30138. }
  30139. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  30140. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  30141. v := m.addconsume_token
  30142. if v == nil {
  30143. return
  30144. }
  30145. return *v, true
  30146. }
  30147. // ResetConsumeToken resets all changes to the "consume_token" field.
  30148. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  30149. m.consume_token = nil
  30150. m.addconsume_token = nil
  30151. }
  30152. // SetActiveUser sets the "active_user" field.
  30153. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  30154. m.active_user = &u
  30155. m.addactive_user = nil
  30156. }
  30157. // ActiveUser returns the value of the "active_user" field in the mutation.
  30158. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  30159. v := m.active_user
  30160. if v == nil {
  30161. return
  30162. }
  30163. return *v, true
  30164. }
  30165. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  30166. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30168. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  30169. if !m.op.Is(OpUpdateOne) {
  30170. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30171. }
  30172. if m.id == nil || m.oldValue == nil {
  30173. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30174. }
  30175. oldValue, err := m.oldValue(ctx)
  30176. if err != nil {
  30177. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30178. }
  30179. return oldValue.ActiveUser, nil
  30180. }
  30181. // AddActiveUser adds u to the "active_user" field.
  30182. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  30183. if m.addactive_user != nil {
  30184. *m.addactive_user += u
  30185. } else {
  30186. m.addactive_user = &u
  30187. }
  30188. }
  30189. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30190. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  30191. v := m.addactive_user
  30192. if v == nil {
  30193. return
  30194. }
  30195. return *v, true
  30196. }
  30197. // ResetActiveUser resets all changes to the "active_user" field.
  30198. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  30199. m.active_user = nil
  30200. m.addactive_user = nil
  30201. }
  30202. // SetNewUser sets the "new_user" field.
  30203. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  30204. m.new_user = &i
  30205. m.addnew_user = nil
  30206. }
  30207. // NewUser returns the value of the "new_user" field in the mutation.
  30208. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  30209. v := m.new_user
  30210. if v == nil {
  30211. return
  30212. }
  30213. return *v, true
  30214. }
  30215. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  30216. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30218. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30219. if !m.op.Is(OpUpdateOne) {
  30220. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30221. }
  30222. if m.id == nil || m.oldValue == nil {
  30223. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30224. }
  30225. oldValue, err := m.oldValue(ctx)
  30226. if err != nil {
  30227. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30228. }
  30229. return oldValue.NewUser, nil
  30230. }
  30231. // AddNewUser adds i to the "new_user" field.
  30232. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  30233. if m.addnew_user != nil {
  30234. *m.addnew_user += i
  30235. } else {
  30236. m.addnew_user = &i
  30237. }
  30238. }
  30239. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30240. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  30241. v := m.addnew_user
  30242. if v == nil {
  30243. return
  30244. }
  30245. return *v, true
  30246. }
  30247. // ResetNewUser resets all changes to the "new_user" field.
  30248. func (m *UsageStatisticDayMutation) ResetNewUser() {
  30249. m.new_user = nil
  30250. m.addnew_user = nil
  30251. }
  30252. // SetLabelDist sets the "label_dist" field.
  30253. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30254. m.label_dist = &ctd
  30255. m.appendlabel_dist = nil
  30256. }
  30257. // LabelDist returns the value of the "label_dist" field in the mutation.
  30258. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30259. v := m.label_dist
  30260. if v == nil {
  30261. return
  30262. }
  30263. return *v, true
  30264. }
  30265. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  30266. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30268. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30269. if !m.op.Is(OpUpdateOne) {
  30270. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30271. }
  30272. if m.id == nil || m.oldValue == nil {
  30273. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30274. }
  30275. oldValue, err := m.oldValue(ctx)
  30276. if err != nil {
  30277. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30278. }
  30279. return oldValue.LabelDist, nil
  30280. }
  30281. // AppendLabelDist adds ctd to the "label_dist" field.
  30282. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30283. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30284. }
  30285. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30286. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30287. if len(m.appendlabel_dist) == 0 {
  30288. return nil, false
  30289. }
  30290. return m.appendlabel_dist, true
  30291. }
  30292. // ResetLabelDist resets all changes to the "label_dist" field.
  30293. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  30294. m.label_dist = nil
  30295. m.appendlabel_dist = nil
  30296. }
  30297. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  30298. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  30299. m.predicates = append(m.predicates, ps...)
  30300. }
  30301. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  30302. // users can use type-assertion to append predicates that do not depend on any generated package.
  30303. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  30304. p := make([]predicate.UsageStatisticDay, len(ps))
  30305. for i := range ps {
  30306. p[i] = ps[i]
  30307. }
  30308. m.Where(p...)
  30309. }
  30310. // Op returns the operation name.
  30311. func (m *UsageStatisticDayMutation) Op() Op {
  30312. return m.op
  30313. }
  30314. // SetOp allows setting the mutation operation.
  30315. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  30316. m.op = op
  30317. }
  30318. // Type returns the node type of this mutation (UsageStatisticDay).
  30319. func (m *UsageStatisticDayMutation) Type() string {
  30320. return m.typ
  30321. }
  30322. // Fields returns all fields that were changed during this mutation. Note that in
  30323. // order to get all numeric fields that were incremented/decremented, call
  30324. // AddedFields().
  30325. func (m *UsageStatisticDayMutation) Fields() []string {
  30326. fields := make([]string, 0, 17)
  30327. if m.created_at != nil {
  30328. fields = append(fields, usagestatisticday.FieldCreatedAt)
  30329. }
  30330. if m.updated_at != nil {
  30331. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  30332. }
  30333. if m.status != nil {
  30334. fields = append(fields, usagestatisticday.FieldStatus)
  30335. }
  30336. if m.deleted_at != nil {
  30337. fields = append(fields, usagestatisticday.FieldDeletedAt)
  30338. }
  30339. if m.addtime != nil {
  30340. fields = append(fields, usagestatisticday.FieldAddtime)
  30341. }
  30342. if m._type != nil {
  30343. fields = append(fields, usagestatisticday.FieldType)
  30344. }
  30345. if m.bot_id != nil {
  30346. fields = append(fields, usagestatisticday.FieldBotID)
  30347. }
  30348. if m.organization_id != nil {
  30349. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30350. }
  30351. if m.ai_response != nil {
  30352. fields = append(fields, usagestatisticday.FieldAiResponse)
  30353. }
  30354. if m.sop_run != nil {
  30355. fields = append(fields, usagestatisticday.FieldSopRun)
  30356. }
  30357. if m.total_friend != nil {
  30358. fields = append(fields, usagestatisticday.FieldTotalFriend)
  30359. }
  30360. if m.total_group != nil {
  30361. fields = append(fields, usagestatisticday.FieldTotalGroup)
  30362. }
  30363. if m.account_balance != nil {
  30364. fields = append(fields, usagestatisticday.FieldAccountBalance)
  30365. }
  30366. if m.consume_token != nil {
  30367. fields = append(fields, usagestatisticday.FieldConsumeToken)
  30368. }
  30369. if m.active_user != nil {
  30370. fields = append(fields, usagestatisticday.FieldActiveUser)
  30371. }
  30372. if m.new_user != nil {
  30373. fields = append(fields, usagestatisticday.FieldNewUser)
  30374. }
  30375. if m.label_dist != nil {
  30376. fields = append(fields, usagestatisticday.FieldLabelDist)
  30377. }
  30378. return fields
  30379. }
  30380. // Field returns the value of a field with the given name. The second boolean
  30381. // return value indicates that this field was not set, or was not defined in the
  30382. // schema.
  30383. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  30384. switch name {
  30385. case usagestatisticday.FieldCreatedAt:
  30386. return m.CreatedAt()
  30387. case usagestatisticday.FieldUpdatedAt:
  30388. return m.UpdatedAt()
  30389. case usagestatisticday.FieldStatus:
  30390. return m.Status()
  30391. case usagestatisticday.FieldDeletedAt:
  30392. return m.DeletedAt()
  30393. case usagestatisticday.FieldAddtime:
  30394. return m.Addtime()
  30395. case usagestatisticday.FieldType:
  30396. return m.GetType()
  30397. case usagestatisticday.FieldBotID:
  30398. return m.BotID()
  30399. case usagestatisticday.FieldOrganizationID:
  30400. return m.OrganizationID()
  30401. case usagestatisticday.FieldAiResponse:
  30402. return m.AiResponse()
  30403. case usagestatisticday.FieldSopRun:
  30404. return m.SopRun()
  30405. case usagestatisticday.FieldTotalFriend:
  30406. return m.TotalFriend()
  30407. case usagestatisticday.FieldTotalGroup:
  30408. return m.TotalGroup()
  30409. case usagestatisticday.FieldAccountBalance:
  30410. return m.AccountBalance()
  30411. case usagestatisticday.FieldConsumeToken:
  30412. return m.ConsumeToken()
  30413. case usagestatisticday.FieldActiveUser:
  30414. return m.ActiveUser()
  30415. case usagestatisticday.FieldNewUser:
  30416. return m.NewUser()
  30417. case usagestatisticday.FieldLabelDist:
  30418. return m.LabelDist()
  30419. }
  30420. return nil, false
  30421. }
  30422. // OldField returns the old value of the field from the database. An error is
  30423. // returned if the mutation operation is not UpdateOne, or the query to the
  30424. // database failed.
  30425. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30426. switch name {
  30427. case usagestatisticday.FieldCreatedAt:
  30428. return m.OldCreatedAt(ctx)
  30429. case usagestatisticday.FieldUpdatedAt:
  30430. return m.OldUpdatedAt(ctx)
  30431. case usagestatisticday.FieldStatus:
  30432. return m.OldStatus(ctx)
  30433. case usagestatisticday.FieldDeletedAt:
  30434. return m.OldDeletedAt(ctx)
  30435. case usagestatisticday.FieldAddtime:
  30436. return m.OldAddtime(ctx)
  30437. case usagestatisticday.FieldType:
  30438. return m.OldType(ctx)
  30439. case usagestatisticday.FieldBotID:
  30440. return m.OldBotID(ctx)
  30441. case usagestatisticday.FieldOrganizationID:
  30442. return m.OldOrganizationID(ctx)
  30443. case usagestatisticday.FieldAiResponse:
  30444. return m.OldAiResponse(ctx)
  30445. case usagestatisticday.FieldSopRun:
  30446. return m.OldSopRun(ctx)
  30447. case usagestatisticday.FieldTotalFriend:
  30448. return m.OldTotalFriend(ctx)
  30449. case usagestatisticday.FieldTotalGroup:
  30450. return m.OldTotalGroup(ctx)
  30451. case usagestatisticday.FieldAccountBalance:
  30452. return m.OldAccountBalance(ctx)
  30453. case usagestatisticday.FieldConsumeToken:
  30454. return m.OldConsumeToken(ctx)
  30455. case usagestatisticday.FieldActiveUser:
  30456. return m.OldActiveUser(ctx)
  30457. case usagestatisticday.FieldNewUser:
  30458. return m.OldNewUser(ctx)
  30459. case usagestatisticday.FieldLabelDist:
  30460. return m.OldLabelDist(ctx)
  30461. }
  30462. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30463. }
  30464. // SetField sets the value of a field with the given name. It returns an error if
  30465. // the field is not defined in the schema, or if the type mismatched the field
  30466. // type.
  30467. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  30468. switch name {
  30469. case usagestatisticday.FieldCreatedAt:
  30470. v, ok := value.(time.Time)
  30471. if !ok {
  30472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30473. }
  30474. m.SetCreatedAt(v)
  30475. return nil
  30476. case usagestatisticday.FieldUpdatedAt:
  30477. v, ok := value.(time.Time)
  30478. if !ok {
  30479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30480. }
  30481. m.SetUpdatedAt(v)
  30482. return nil
  30483. case usagestatisticday.FieldStatus:
  30484. v, ok := value.(uint8)
  30485. if !ok {
  30486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30487. }
  30488. m.SetStatus(v)
  30489. return nil
  30490. case usagestatisticday.FieldDeletedAt:
  30491. v, ok := value.(time.Time)
  30492. if !ok {
  30493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30494. }
  30495. m.SetDeletedAt(v)
  30496. return nil
  30497. case usagestatisticday.FieldAddtime:
  30498. v, ok := value.(uint64)
  30499. if !ok {
  30500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30501. }
  30502. m.SetAddtime(v)
  30503. return nil
  30504. case usagestatisticday.FieldType:
  30505. v, ok := value.(int)
  30506. if !ok {
  30507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30508. }
  30509. m.SetType(v)
  30510. return nil
  30511. case usagestatisticday.FieldBotID:
  30512. v, ok := value.(string)
  30513. if !ok {
  30514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30515. }
  30516. m.SetBotID(v)
  30517. return nil
  30518. case usagestatisticday.FieldOrganizationID:
  30519. v, ok := value.(uint64)
  30520. if !ok {
  30521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30522. }
  30523. m.SetOrganizationID(v)
  30524. return nil
  30525. case usagestatisticday.FieldAiResponse:
  30526. v, ok := value.(uint64)
  30527. if !ok {
  30528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30529. }
  30530. m.SetAiResponse(v)
  30531. return nil
  30532. case usagestatisticday.FieldSopRun:
  30533. v, ok := value.(uint64)
  30534. if !ok {
  30535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30536. }
  30537. m.SetSopRun(v)
  30538. return nil
  30539. case usagestatisticday.FieldTotalFriend:
  30540. v, ok := value.(uint64)
  30541. if !ok {
  30542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30543. }
  30544. m.SetTotalFriend(v)
  30545. return nil
  30546. case usagestatisticday.FieldTotalGroup:
  30547. v, ok := value.(uint64)
  30548. if !ok {
  30549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30550. }
  30551. m.SetTotalGroup(v)
  30552. return nil
  30553. case usagestatisticday.FieldAccountBalance:
  30554. v, ok := value.(uint64)
  30555. if !ok {
  30556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30557. }
  30558. m.SetAccountBalance(v)
  30559. return nil
  30560. case usagestatisticday.FieldConsumeToken:
  30561. v, ok := value.(uint64)
  30562. if !ok {
  30563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30564. }
  30565. m.SetConsumeToken(v)
  30566. return nil
  30567. case usagestatisticday.FieldActiveUser:
  30568. v, ok := value.(uint64)
  30569. if !ok {
  30570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30571. }
  30572. m.SetActiveUser(v)
  30573. return nil
  30574. case usagestatisticday.FieldNewUser:
  30575. v, ok := value.(int64)
  30576. if !ok {
  30577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30578. }
  30579. m.SetNewUser(v)
  30580. return nil
  30581. case usagestatisticday.FieldLabelDist:
  30582. v, ok := value.([]custom_types.LabelDist)
  30583. if !ok {
  30584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30585. }
  30586. m.SetLabelDist(v)
  30587. return nil
  30588. }
  30589. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30590. }
  30591. // AddedFields returns all numeric fields that were incremented/decremented during
  30592. // this mutation.
  30593. func (m *UsageStatisticDayMutation) AddedFields() []string {
  30594. var fields []string
  30595. if m.addstatus != nil {
  30596. fields = append(fields, usagestatisticday.FieldStatus)
  30597. }
  30598. if m.addaddtime != nil {
  30599. fields = append(fields, usagestatisticday.FieldAddtime)
  30600. }
  30601. if m.add_type != nil {
  30602. fields = append(fields, usagestatisticday.FieldType)
  30603. }
  30604. if m.addorganization_id != nil {
  30605. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30606. }
  30607. if m.addai_response != nil {
  30608. fields = append(fields, usagestatisticday.FieldAiResponse)
  30609. }
  30610. if m.addsop_run != nil {
  30611. fields = append(fields, usagestatisticday.FieldSopRun)
  30612. }
  30613. if m.addtotal_friend != nil {
  30614. fields = append(fields, usagestatisticday.FieldTotalFriend)
  30615. }
  30616. if m.addtotal_group != nil {
  30617. fields = append(fields, usagestatisticday.FieldTotalGroup)
  30618. }
  30619. if m.addaccount_balance != nil {
  30620. fields = append(fields, usagestatisticday.FieldAccountBalance)
  30621. }
  30622. if m.addconsume_token != nil {
  30623. fields = append(fields, usagestatisticday.FieldConsumeToken)
  30624. }
  30625. if m.addactive_user != nil {
  30626. fields = append(fields, usagestatisticday.FieldActiveUser)
  30627. }
  30628. if m.addnew_user != nil {
  30629. fields = append(fields, usagestatisticday.FieldNewUser)
  30630. }
  30631. return fields
  30632. }
  30633. // AddedField returns the numeric value that was incremented/decremented on a field
  30634. // with the given name. The second boolean return value indicates that this field
  30635. // was not set, or was not defined in the schema.
  30636. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  30637. switch name {
  30638. case usagestatisticday.FieldStatus:
  30639. return m.AddedStatus()
  30640. case usagestatisticday.FieldAddtime:
  30641. return m.AddedAddtime()
  30642. case usagestatisticday.FieldType:
  30643. return m.AddedType()
  30644. case usagestatisticday.FieldOrganizationID:
  30645. return m.AddedOrganizationID()
  30646. case usagestatisticday.FieldAiResponse:
  30647. return m.AddedAiResponse()
  30648. case usagestatisticday.FieldSopRun:
  30649. return m.AddedSopRun()
  30650. case usagestatisticday.FieldTotalFriend:
  30651. return m.AddedTotalFriend()
  30652. case usagestatisticday.FieldTotalGroup:
  30653. return m.AddedTotalGroup()
  30654. case usagestatisticday.FieldAccountBalance:
  30655. return m.AddedAccountBalance()
  30656. case usagestatisticday.FieldConsumeToken:
  30657. return m.AddedConsumeToken()
  30658. case usagestatisticday.FieldActiveUser:
  30659. return m.AddedActiveUser()
  30660. case usagestatisticday.FieldNewUser:
  30661. return m.AddedNewUser()
  30662. }
  30663. return nil, false
  30664. }
  30665. // AddField adds the value to the field with the given name. It returns an error if
  30666. // the field is not defined in the schema, or if the type mismatched the field
  30667. // type.
  30668. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  30669. switch name {
  30670. case usagestatisticday.FieldStatus:
  30671. v, ok := value.(int8)
  30672. if !ok {
  30673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30674. }
  30675. m.AddStatus(v)
  30676. return nil
  30677. case usagestatisticday.FieldAddtime:
  30678. v, ok := value.(int64)
  30679. if !ok {
  30680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30681. }
  30682. m.AddAddtime(v)
  30683. return nil
  30684. case usagestatisticday.FieldType:
  30685. v, ok := value.(int)
  30686. if !ok {
  30687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30688. }
  30689. m.AddType(v)
  30690. return nil
  30691. case usagestatisticday.FieldOrganizationID:
  30692. v, ok := value.(int64)
  30693. if !ok {
  30694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30695. }
  30696. m.AddOrganizationID(v)
  30697. return nil
  30698. case usagestatisticday.FieldAiResponse:
  30699. v, ok := value.(int64)
  30700. if !ok {
  30701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30702. }
  30703. m.AddAiResponse(v)
  30704. return nil
  30705. case usagestatisticday.FieldSopRun:
  30706. v, ok := value.(int64)
  30707. if !ok {
  30708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30709. }
  30710. m.AddSopRun(v)
  30711. return nil
  30712. case usagestatisticday.FieldTotalFriend:
  30713. v, ok := value.(int64)
  30714. if !ok {
  30715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30716. }
  30717. m.AddTotalFriend(v)
  30718. return nil
  30719. case usagestatisticday.FieldTotalGroup:
  30720. v, ok := value.(int64)
  30721. if !ok {
  30722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30723. }
  30724. m.AddTotalGroup(v)
  30725. return nil
  30726. case usagestatisticday.FieldAccountBalance:
  30727. v, ok := value.(int64)
  30728. if !ok {
  30729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30730. }
  30731. m.AddAccountBalance(v)
  30732. return nil
  30733. case usagestatisticday.FieldConsumeToken:
  30734. v, ok := value.(int64)
  30735. if !ok {
  30736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30737. }
  30738. m.AddConsumeToken(v)
  30739. return nil
  30740. case usagestatisticday.FieldActiveUser:
  30741. v, ok := value.(int64)
  30742. if !ok {
  30743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30744. }
  30745. m.AddActiveUser(v)
  30746. return nil
  30747. case usagestatisticday.FieldNewUser:
  30748. v, ok := value.(int64)
  30749. if !ok {
  30750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30751. }
  30752. m.AddNewUser(v)
  30753. return nil
  30754. }
  30755. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  30756. }
  30757. // ClearedFields returns all nullable fields that were cleared during this
  30758. // mutation.
  30759. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  30760. var fields []string
  30761. if m.FieldCleared(usagestatisticday.FieldStatus) {
  30762. fields = append(fields, usagestatisticday.FieldStatus)
  30763. }
  30764. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  30765. fields = append(fields, usagestatisticday.FieldDeletedAt)
  30766. }
  30767. if m.FieldCleared(usagestatisticday.FieldBotID) {
  30768. fields = append(fields, usagestatisticday.FieldBotID)
  30769. }
  30770. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  30771. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30772. }
  30773. return fields
  30774. }
  30775. // FieldCleared returns a boolean indicating if a field with the given name was
  30776. // cleared in this mutation.
  30777. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  30778. _, ok := m.clearedFields[name]
  30779. return ok
  30780. }
  30781. // ClearField clears the value of the field with the given name. It returns an
  30782. // error if the field is not defined in the schema.
  30783. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  30784. switch name {
  30785. case usagestatisticday.FieldStatus:
  30786. m.ClearStatus()
  30787. return nil
  30788. case usagestatisticday.FieldDeletedAt:
  30789. m.ClearDeletedAt()
  30790. return nil
  30791. case usagestatisticday.FieldBotID:
  30792. m.ClearBotID()
  30793. return nil
  30794. case usagestatisticday.FieldOrganizationID:
  30795. m.ClearOrganizationID()
  30796. return nil
  30797. }
  30798. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  30799. }
  30800. // ResetField resets all changes in the mutation for the field with the given name.
  30801. // It returns an error if the field is not defined in the schema.
  30802. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  30803. switch name {
  30804. case usagestatisticday.FieldCreatedAt:
  30805. m.ResetCreatedAt()
  30806. return nil
  30807. case usagestatisticday.FieldUpdatedAt:
  30808. m.ResetUpdatedAt()
  30809. return nil
  30810. case usagestatisticday.FieldStatus:
  30811. m.ResetStatus()
  30812. return nil
  30813. case usagestatisticday.FieldDeletedAt:
  30814. m.ResetDeletedAt()
  30815. return nil
  30816. case usagestatisticday.FieldAddtime:
  30817. m.ResetAddtime()
  30818. return nil
  30819. case usagestatisticday.FieldType:
  30820. m.ResetType()
  30821. return nil
  30822. case usagestatisticday.FieldBotID:
  30823. m.ResetBotID()
  30824. return nil
  30825. case usagestatisticday.FieldOrganizationID:
  30826. m.ResetOrganizationID()
  30827. return nil
  30828. case usagestatisticday.FieldAiResponse:
  30829. m.ResetAiResponse()
  30830. return nil
  30831. case usagestatisticday.FieldSopRun:
  30832. m.ResetSopRun()
  30833. return nil
  30834. case usagestatisticday.FieldTotalFriend:
  30835. m.ResetTotalFriend()
  30836. return nil
  30837. case usagestatisticday.FieldTotalGroup:
  30838. m.ResetTotalGroup()
  30839. return nil
  30840. case usagestatisticday.FieldAccountBalance:
  30841. m.ResetAccountBalance()
  30842. return nil
  30843. case usagestatisticday.FieldConsumeToken:
  30844. m.ResetConsumeToken()
  30845. return nil
  30846. case usagestatisticday.FieldActiveUser:
  30847. m.ResetActiveUser()
  30848. return nil
  30849. case usagestatisticday.FieldNewUser:
  30850. m.ResetNewUser()
  30851. return nil
  30852. case usagestatisticday.FieldLabelDist:
  30853. m.ResetLabelDist()
  30854. return nil
  30855. }
  30856. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30857. }
  30858. // AddedEdges returns all edge names that were set/added in this mutation.
  30859. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  30860. edges := make([]string, 0, 0)
  30861. return edges
  30862. }
  30863. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30864. // name in this mutation.
  30865. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  30866. return nil
  30867. }
  30868. // RemovedEdges returns all edge names that were removed in this mutation.
  30869. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  30870. edges := make([]string, 0, 0)
  30871. return edges
  30872. }
  30873. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30874. // the given name in this mutation.
  30875. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  30876. return nil
  30877. }
  30878. // ClearedEdges returns all edge names that were cleared in this mutation.
  30879. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  30880. edges := make([]string, 0, 0)
  30881. return edges
  30882. }
  30883. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30884. // was cleared in this mutation.
  30885. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  30886. return false
  30887. }
  30888. // ClearEdge clears the value of the edge with the given name. It returns an error
  30889. // if that edge is not defined in the schema.
  30890. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  30891. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  30892. }
  30893. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30894. // It returns an error if the edge is not defined in the schema.
  30895. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  30896. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  30897. }
  30898. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  30899. type UsageStatisticHourMutation struct {
  30900. config
  30901. op Op
  30902. typ string
  30903. id *uint64
  30904. created_at *time.Time
  30905. updated_at *time.Time
  30906. status *uint8
  30907. addstatus *int8
  30908. deleted_at *time.Time
  30909. addtime *uint64
  30910. addaddtime *int64
  30911. _type *int
  30912. add_type *int
  30913. bot_id *string
  30914. organization_id *uint64
  30915. addorganization_id *int64
  30916. ai_response *uint64
  30917. addai_response *int64
  30918. sop_run *uint64
  30919. addsop_run *int64
  30920. total_friend *uint64
  30921. addtotal_friend *int64
  30922. total_group *uint64
  30923. addtotal_group *int64
  30924. account_balance *uint64
  30925. addaccount_balance *int64
  30926. consume_token *uint64
  30927. addconsume_token *int64
  30928. active_user *uint64
  30929. addactive_user *int64
  30930. new_user *int64
  30931. addnew_user *int64
  30932. label_dist *[]custom_types.LabelDist
  30933. appendlabel_dist []custom_types.LabelDist
  30934. clearedFields map[string]struct{}
  30935. done bool
  30936. oldValue func(context.Context) (*UsageStatisticHour, error)
  30937. predicates []predicate.UsageStatisticHour
  30938. }
  30939. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  30940. // usagestatistichourOption allows management of the mutation configuration using functional options.
  30941. type usagestatistichourOption func(*UsageStatisticHourMutation)
  30942. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  30943. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  30944. m := &UsageStatisticHourMutation{
  30945. config: c,
  30946. op: op,
  30947. typ: TypeUsageStatisticHour,
  30948. clearedFields: make(map[string]struct{}),
  30949. }
  30950. for _, opt := range opts {
  30951. opt(m)
  30952. }
  30953. return m
  30954. }
  30955. // withUsageStatisticHourID sets the ID field of the mutation.
  30956. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  30957. return func(m *UsageStatisticHourMutation) {
  30958. var (
  30959. err error
  30960. once sync.Once
  30961. value *UsageStatisticHour
  30962. )
  30963. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  30964. once.Do(func() {
  30965. if m.done {
  30966. err = errors.New("querying old values post mutation is not allowed")
  30967. } else {
  30968. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  30969. }
  30970. })
  30971. return value, err
  30972. }
  30973. m.id = &id
  30974. }
  30975. }
  30976. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  30977. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  30978. return func(m *UsageStatisticHourMutation) {
  30979. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  30980. return node, nil
  30981. }
  30982. m.id = &node.ID
  30983. }
  30984. }
  30985. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30986. // executed in a transaction (ent.Tx), a transactional client is returned.
  30987. func (m UsageStatisticHourMutation) Client() *Client {
  30988. client := &Client{config: m.config}
  30989. client.init()
  30990. return client
  30991. }
  30992. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30993. // it returns an error otherwise.
  30994. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  30995. if _, ok := m.driver.(*txDriver); !ok {
  30996. return nil, errors.New("ent: mutation is not running in a transaction")
  30997. }
  30998. tx := &Tx{config: m.config}
  30999. tx.init()
  31000. return tx, nil
  31001. }
  31002. // SetID sets the value of the id field. Note that this
  31003. // operation is only accepted on creation of UsageStatisticHour entities.
  31004. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  31005. m.id = &id
  31006. }
  31007. // ID returns the ID value in the mutation. Note that the ID is only available
  31008. // if it was provided to the builder or after it was returned from the database.
  31009. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  31010. if m.id == nil {
  31011. return
  31012. }
  31013. return *m.id, true
  31014. }
  31015. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31016. // That means, if the mutation is applied within a transaction with an isolation level such
  31017. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31018. // or updated by the mutation.
  31019. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  31020. switch {
  31021. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31022. id, exists := m.ID()
  31023. if exists {
  31024. return []uint64{id}, nil
  31025. }
  31026. fallthrough
  31027. case m.op.Is(OpUpdate | OpDelete):
  31028. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  31029. default:
  31030. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31031. }
  31032. }
  31033. // SetCreatedAt sets the "created_at" field.
  31034. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  31035. m.created_at = &t
  31036. }
  31037. // CreatedAt returns the value of the "created_at" field in the mutation.
  31038. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  31039. v := m.created_at
  31040. if v == nil {
  31041. return
  31042. }
  31043. return *v, true
  31044. }
  31045. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  31046. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31048. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31049. if !m.op.Is(OpUpdateOne) {
  31050. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31051. }
  31052. if m.id == nil || m.oldValue == nil {
  31053. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31054. }
  31055. oldValue, err := m.oldValue(ctx)
  31056. if err != nil {
  31057. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31058. }
  31059. return oldValue.CreatedAt, nil
  31060. }
  31061. // ResetCreatedAt resets all changes to the "created_at" field.
  31062. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  31063. m.created_at = nil
  31064. }
  31065. // SetUpdatedAt sets the "updated_at" field.
  31066. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  31067. m.updated_at = &t
  31068. }
  31069. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31070. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  31071. v := m.updated_at
  31072. if v == nil {
  31073. return
  31074. }
  31075. return *v, true
  31076. }
  31077. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  31078. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31080. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31081. if !m.op.Is(OpUpdateOne) {
  31082. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31083. }
  31084. if m.id == nil || m.oldValue == nil {
  31085. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31086. }
  31087. oldValue, err := m.oldValue(ctx)
  31088. if err != nil {
  31089. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31090. }
  31091. return oldValue.UpdatedAt, nil
  31092. }
  31093. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31094. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  31095. m.updated_at = nil
  31096. }
  31097. // SetStatus sets the "status" field.
  31098. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  31099. m.status = &u
  31100. m.addstatus = nil
  31101. }
  31102. // Status returns the value of the "status" field in the mutation.
  31103. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  31104. v := m.status
  31105. if v == nil {
  31106. return
  31107. }
  31108. return *v, true
  31109. }
  31110. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  31111. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31113. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31114. if !m.op.Is(OpUpdateOne) {
  31115. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31116. }
  31117. if m.id == nil || m.oldValue == nil {
  31118. return v, errors.New("OldStatus requires an ID field in the mutation")
  31119. }
  31120. oldValue, err := m.oldValue(ctx)
  31121. if err != nil {
  31122. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31123. }
  31124. return oldValue.Status, nil
  31125. }
  31126. // AddStatus adds u to the "status" field.
  31127. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  31128. if m.addstatus != nil {
  31129. *m.addstatus += u
  31130. } else {
  31131. m.addstatus = &u
  31132. }
  31133. }
  31134. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31135. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  31136. v := m.addstatus
  31137. if v == nil {
  31138. return
  31139. }
  31140. return *v, true
  31141. }
  31142. // ClearStatus clears the value of the "status" field.
  31143. func (m *UsageStatisticHourMutation) ClearStatus() {
  31144. m.status = nil
  31145. m.addstatus = nil
  31146. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  31147. }
  31148. // StatusCleared returns if the "status" field was cleared in this mutation.
  31149. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  31150. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  31151. return ok
  31152. }
  31153. // ResetStatus resets all changes to the "status" field.
  31154. func (m *UsageStatisticHourMutation) ResetStatus() {
  31155. m.status = nil
  31156. m.addstatus = nil
  31157. delete(m.clearedFields, usagestatistichour.FieldStatus)
  31158. }
  31159. // SetDeletedAt sets the "deleted_at" field.
  31160. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  31161. m.deleted_at = &t
  31162. }
  31163. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31164. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  31165. v := m.deleted_at
  31166. if v == nil {
  31167. return
  31168. }
  31169. return *v, true
  31170. }
  31171. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  31172. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31174. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31175. if !m.op.Is(OpUpdateOne) {
  31176. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31177. }
  31178. if m.id == nil || m.oldValue == nil {
  31179. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31180. }
  31181. oldValue, err := m.oldValue(ctx)
  31182. if err != nil {
  31183. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31184. }
  31185. return oldValue.DeletedAt, nil
  31186. }
  31187. // ClearDeletedAt clears the value of the "deleted_at" field.
  31188. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  31189. m.deleted_at = nil
  31190. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  31191. }
  31192. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31193. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  31194. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  31195. return ok
  31196. }
  31197. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31198. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  31199. m.deleted_at = nil
  31200. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  31201. }
  31202. // SetAddtime sets the "addtime" field.
  31203. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  31204. m.addtime = &u
  31205. m.addaddtime = nil
  31206. }
  31207. // Addtime returns the value of the "addtime" field in the mutation.
  31208. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  31209. v := m.addtime
  31210. if v == nil {
  31211. return
  31212. }
  31213. return *v, true
  31214. }
  31215. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  31216. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31218. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31219. if !m.op.Is(OpUpdateOne) {
  31220. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31221. }
  31222. if m.id == nil || m.oldValue == nil {
  31223. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31224. }
  31225. oldValue, err := m.oldValue(ctx)
  31226. if err != nil {
  31227. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31228. }
  31229. return oldValue.Addtime, nil
  31230. }
  31231. // AddAddtime adds u to the "addtime" field.
  31232. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  31233. if m.addaddtime != nil {
  31234. *m.addaddtime += u
  31235. } else {
  31236. m.addaddtime = &u
  31237. }
  31238. }
  31239. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31240. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  31241. v := m.addaddtime
  31242. if v == nil {
  31243. return
  31244. }
  31245. return *v, true
  31246. }
  31247. // ResetAddtime resets all changes to the "addtime" field.
  31248. func (m *UsageStatisticHourMutation) ResetAddtime() {
  31249. m.addtime = nil
  31250. m.addaddtime = nil
  31251. }
  31252. // SetType sets the "type" field.
  31253. func (m *UsageStatisticHourMutation) SetType(i int) {
  31254. m._type = &i
  31255. m.add_type = nil
  31256. }
  31257. // GetType returns the value of the "type" field in the mutation.
  31258. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  31259. v := m._type
  31260. if v == nil {
  31261. return
  31262. }
  31263. return *v, true
  31264. }
  31265. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  31266. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31268. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  31269. if !m.op.Is(OpUpdateOne) {
  31270. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31271. }
  31272. if m.id == nil || m.oldValue == nil {
  31273. return v, errors.New("OldType requires an ID field in the mutation")
  31274. }
  31275. oldValue, err := m.oldValue(ctx)
  31276. if err != nil {
  31277. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31278. }
  31279. return oldValue.Type, nil
  31280. }
  31281. // AddType adds i to the "type" field.
  31282. func (m *UsageStatisticHourMutation) AddType(i int) {
  31283. if m.add_type != nil {
  31284. *m.add_type += i
  31285. } else {
  31286. m.add_type = &i
  31287. }
  31288. }
  31289. // AddedType returns the value that was added to the "type" field in this mutation.
  31290. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  31291. v := m.add_type
  31292. if v == nil {
  31293. return
  31294. }
  31295. return *v, true
  31296. }
  31297. // ResetType resets all changes to the "type" field.
  31298. func (m *UsageStatisticHourMutation) ResetType() {
  31299. m._type = nil
  31300. m.add_type = nil
  31301. }
  31302. // SetBotID sets the "bot_id" field.
  31303. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  31304. m.bot_id = &s
  31305. }
  31306. // BotID returns the value of the "bot_id" field in the mutation.
  31307. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  31308. v := m.bot_id
  31309. if v == nil {
  31310. return
  31311. }
  31312. return *v, true
  31313. }
  31314. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  31315. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31317. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  31318. if !m.op.Is(OpUpdateOne) {
  31319. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31320. }
  31321. if m.id == nil || m.oldValue == nil {
  31322. return v, errors.New("OldBotID requires an ID field in the mutation")
  31323. }
  31324. oldValue, err := m.oldValue(ctx)
  31325. if err != nil {
  31326. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31327. }
  31328. return oldValue.BotID, nil
  31329. }
  31330. // ClearBotID clears the value of the "bot_id" field.
  31331. func (m *UsageStatisticHourMutation) ClearBotID() {
  31332. m.bot_id = nil
  31333. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  31334. }
  31335. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31336. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  31337. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  31338. return ok
  31339. }
  31340. // ResetBotID resets all changes to the "bot_id" field.
  31341. func (m *UsageStatisticHourMutation) ResetBotID() {
  31342. m.bot_id = nil
  31343. delete(m.clearedFields, usagestatistichour.FieldBotID)
  31344. }
  31345. // SetOrganizationID sets the "organization_id" field.
  31346. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  31347. m.organization_id = &u
  31348. m.addorganization_id = nil
  31349. }
  31350. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31351. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  31352. v := m.organization_id
  31353. if v == nil {
  31354. return
  31355. }
  31356. return *v, true
  31357. }
  31358. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  31359. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31361. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31362. if !m.op.Is(OpUpdateOne) {
  31363. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31364. }
  31365. if m.id == nil || m.oldValue == nil {
  31366. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31367. }
  31368. oldValue, err := m.oldValue(ctx)
  31369. if err != nil {
  31370. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31371. }
  31372. return oldValue.OrganizationID, nil
  31373. }
  31374. // AddOrganizationID adds u to the "organization_id" field.
  31375. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  31376. if m.addorganization_id != nil {
  31377. *m.addorganization_id += u
  31378. } else {
  31379. m.addorganization_id = &u
  31380. }
  31381. }
  31382. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31383. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  31384. v := m.addorganization_id
  31385. if v == nil {
  31386. return
  31387. }
  31388. return *v, true
  31389. }
  31390. // ClearOrganizationID clears the value of the "organization_id" field.
  31391. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  31392. m.organization_id = nil
  31393. m.addorganization_id = nil
  31394. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  31395. }
  31396. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31397. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  31398. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  31399. return ok
  31400. }
  31401. // ResetOrganizationID resets all changes to the "organization_id" field.
  31402. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  31403. m.organization_id = nil
  31404. m.addorganization_id = nil
  31405. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  31406. }
  31407. // SetAiResponse sets the "ai_response" field.
  31408. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  31409. m.ai_response = &u
  31410. m.addai_response = nil
  31411. }
  31412. // AiResponse returns the value of the "ai_response" field in the mutation.
  31413. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  31414. v := m.ai_response
  31415. if v == nil {
  31416. return
  31417. }
  31418. return *v, true
  31419. }
  31420. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  31421. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31423. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31424. if !m.op.Is(OpUpdateOne) {
  31425. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31426. }
  31427. if m.id == nil || m.oldValue == nil {
  31428. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31429. }
  31430. oldValue, err := m.oldValue(ctx)
  31431. if err != nil {
  31432. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31433. }
  31434. return oldValue.AiResponse, nil
  31435. }
  31436. // AddAiResponse adds u to the "ai_response" field.
  31437. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  31438. if m.addai_response != nil {
  31439. *m.addai_response += u
  31440. } else {
  31441. m.addai_response = &u
  31442. }
  31443. }
  31444. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31445. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  31446. v := m.addai_response
  31447. if v == nil {
  31448. return
  31449. }
  31450. return *v, true
  31451. }
  31452. // ResetAiResponse resets all changes to the "ai_response" field.
  31453. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  31454. m.ai_response = nil
  31455. m.addai_response = nil
  31456. }
  31457. // SetSopRun sets the "sop_run" field.
  31458. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  31459. m.sop_run = &u
  31460. m.addsop_run = nil
  31461. }
  31462. // SopRun returns the value of the "sop_run" field in the mutation.
  31463. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  31464. v := m.sop_run
  31465. if v == nil {
  31466. return
  31467. }
  31468. return *v, true
  31469. }
  31470. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  31471. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31473. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31474. if !m.op.Is(OpUpdateOne) {
  31475. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31476. }
  31477. if m.id == nil || m.oldValue == nil {
  31478. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31479. }
  31480. oldValue, err := m.oldValue(ctx)
  31481. if err != nil {
  31482. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31483. }
  31484. return oldValue.SopRun, nil
  31485. }
  31486. // AddSopRun adds u to the "sop_run" field.
  31487. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  31488. if m.addsop_run != nil {
  31489. *m.addsop_run += u
  31490. } else {
  31491. m.addsop_run = &u
  31492. }
  31493. }
  31494. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31495. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  31496. v := m.addsop_run
  31497. if v == nil {
  31498. return
  31499. }
  31500. return *v, true
  31501. }
  31502. // ResetSopRun resets all changes to the "sop_run" field.
  31503. func (m *UsageStatisticHourMutation) ResetSopRun() {
  31504. m.sop_run = nil
  31505. m.addsop_run = nil
  31506. }
  31507. // SetTotalFriend sets the "total_friend" field.
  31508. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  31509. m.total_friend = &u
  31510. m.addtotal_friend = nil
  31511. }
  31512. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31513. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  31514. v := m.total_friend
  31515. if v == nil {
  31516. return
  31517. }
  31518. return *v, true
  31519. }
  31520. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  31521. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31523. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31524. if !m.op.Is(OpUpdateOne) {
  31525. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31526. }
  31527. if m.id == nil || m.oldValue == nil {
  31528. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31529. }
  31530. oldValue, err := m.oldValue(ctx)
  31531. if err != nil {
  31532. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31533. }
  31534. return oldValue.TotalFriend, nil
  31535. }
  31536. // AddTotalFriend adds u to the "total_friend" field.
  31537. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  31538. if m.addtotal_friend != nil {
  31539. *m.addtotal_friend += u
  31540. } else {
  31541. m.addtotal_friend = &u
  31542. }
  31543. }
  31544. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31545. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  31546. v := m.addtotal_friend
  31547. if v == nil {
  31548. return
  31549. }
  31550. return *v, true
  31551. }
  31552. // ResetTotalFriend resets all changes to the "total_friend" field.
  31553. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  31554. m.total_friend = nil
  31555. m.addtotal_friend = nil
  31556. }
  31557. // SetTotalGroup sets the "total_group" field.
  31558. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  31559. m.total_group = &u
  31560. m.addtotal_group = nil
  31561. }
  31562. // TotalGroup returns the value of the "total_group" field in the mutation.
  31563. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  31564. v := m.total_group
  31565. if v == nil {
  31566. return
  31567. }
  31568. return *v, true
  31569. }
  31570. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  31571. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31573. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31574. if !m.op.Is(OpUpdateOne) {
  31575. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31576. }
  31577. if m.id == nil || m.oldValue == nil {
  31578. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31579. }
  31580. oldValue, err := m.oldValue(ctx)
  31581. if err != nil {
  31582. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31583. }
  31584. return oldValue.TotalGroup, nil
  31585. }
  31586. // AddTotalGroup adds u to the "total_group" field.
  31587. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  31588. if m.addtotal_group != nil {
  31589. *m.addtotal_group += u
  31590. } else {
  31591. m.addtotal_group = &u
  31592. }
  31593. }
  31594. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31595. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  31596. v := m.addtotal_group
  31597. if v == nil {
  31598. return
  31599. }
  31600. return *v, true
  31601. }
  31602. // ResetTotalGroup resets all changes to the "total_group" field.
  31603. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  31604. m.total_group = nil
  31605. m.addtotal_group = nil
  31606. }
  31607. // SetAccountBalance sets the "account_balance" field.
  31608. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  31609. m.account_balance = &u
  31610. m.addaccount_balance = nil
  31611. }
  31612. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31613. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  31614. v := m.account_balance
  31615. if v == nil {
  31616. return
  31617. }
  31618. return *v, true
  31619. }
  31620. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  31621. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31623. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31624. if !m.op.Is(OpUpdateOne) {
  31625. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31626. }
  31627. if m.id == nil || m.oldValue == nil {
  31628. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31629. }
  31630. oldValue, err := m.oldValue(ctx)
  31631. if err != nil {
  31632. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31633. }
  31634. return oldValue.AccountBalance, nil
  31635. }
  31636. // AddAccountBalance adds u to the "account_balance" field.
  31637. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  31638. if m.addaccount_balance != nil {
  31639. *m.addaccount_balance += u
  31640. } else {
  31641. m.addaccount_balance = &u
  31642. }
  31643. }
  31644. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31645. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  31646. v := m.addaccount_balance
  31647. if v == nil {
  31648. return
  31649. }
  31650. return *v, true
  31651. }
  31652. // ResetAccountBalance resets all changes to the "account_balance" field.
  31653. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  31654. m.account_balance = nil
  31655. m.addaccount_balance = nil
  31656. }
  31657. // SetConsumeToken sets the "consume_token" field.
  31658. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  31659. m.consume_token = &u
  31660. m.addconsume_token = nil
  31661. }
  31662. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31663. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  31664. v := m.consume_token
  31665. if v == nil {
  31666. return
  31667. }
  31668. return *v, true
  31669. }
  31670. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  31671. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31673. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31674. if !m.op.Is(OpUpdateOne) {
  31675. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31676. }
  31677. if m.id == nil || m.oldValue == nil {
  31678. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31679. }
  31680. oldValue, err := m.oldValue(ctx)
  31681. if err != nil {
  31682. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31683. }
  31684. return oldValue.ConsumeToken, nil
  31685. }
  31686. // AddConsumeToken adds u to the "consume_token" field.
  31687. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  31688. if m.addconsume_token != nil {
  31689. *m.addconsume_token += u
  31690. } else {
  31691. m.addconsume_token = &u
  31692. }
  31693. }
  31694. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31695. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  31696. v := m.addconsume_token
  31697. if v == nil {
  31698. return
  31699. }
  31700. return *v, true
  31701. }
  31702. // ResetConsumeToken resets all changes to the "consume_token" field.
  31703. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  31704. m.consume_token = nil
  31705. m.addconsume_token = nil
  31706. }
  31707. // SetActiveUser sets the "active_user" field.
  31708. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  31709. m.active_user = &u
  31710. m.addactive_user = nil
  31711. }
  31712. // ActiveUser returns the value of the "active_user" field in the mutation.
  31713. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  31714. v := m.active_user
  31715. if v == nil {
  31716. return
  31717. }
  31718. return *v, true
  31719. }
  31720. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  31721. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31723. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31724. if !m.op.Is(OpUpdateOne) {
  31725. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31726. }
  31727. if m.id == nil || m.oldValue == nil {
  31728. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31729. }
  31730. oldValue, err := m.oldValue(ctx)
  31731. if err != nil {
  31732. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31733. }
  31734. return oldValue.ActiveUser, nil
  31735. }
  31736. // AddActiveUser adds u to the "active_user" field.
  31737. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  31738. if m.addactive_user != nil {
  31739. *m.addactive_user += u
  31740. } else {
  31741. m.addactive_user = &u
  31742. }
  31743. }
  31744. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31745. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  31746. v := m.addactive_user
  31747. if v == nil {
  31748. return
  31749. }
  31750. return *v, true
  31751. }
  31752. // ResetActiveUser resets all changes to the "active_user" field.
  31753. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  31754. m.active_user = nil
  31755. m.addactive_user = nil
  31756. }
  31757. // SetNewUser sets the "new_user" field.
  31758. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  31759. m.new_user = &i
  31760. m.addnew_user = nil
  31761. }
  31762. // NewUser returns the value of the "new_user" field in the mutation.
  31763. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  31764. v := m.new_user
  31765. if v == nil {
  31766. return
  31767. }
  31768. return *v, true
  31769. }
  31770. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  31771. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31773. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31774. if !m.op.Is(OpUpdateOne) {
  31775. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31776. }
  31777. if m.id == nil || m.oldValue == nil {
  31778. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31779. }
  31780. oldValue, err := m.oldValue(ctx)
  31781. if err != nil {
  31782. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31783. }
  31784. return oldValue.NewUser, nil
  31785. }
  31786. // AddNewUser adds i to the "new_user" field.
  31787. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  31788. if m.addnew_user != nil {
  31789. *m.addnew_user += i
  31790. } else {
  31791. m.addnew_user = &i
  31792. }
  31793. }
  31794. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31795. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  31796. v := m.addnew_user
  31797. if v == nil {
  31798. return
  31799. }
  31800. return *v, true
  31801. }
  31802. // ResetNewUser resets all changes to the "new_user" field.
  31803. func (m *UsageStatisticHourMutation) ResetNewUser() {
  31804. m.new_user = nil
  31805. m.addnew_user = nil
  31806. }
  31807. // SetLabelDist sets the "label_dist" field.
  31808. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31809. m.label_dist = &ctd
  31810. m.appendlabel_dist = nil
  31811. }
  31812. // LabelDist returns the value of the "label_dist" field in the mutation.
  31813. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31814. v := m.label_dist
  31815. if v == nil {
  31816. return
  31817. }
  31818. return *v, true
  31819. }
  31820. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  31821. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31823. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31824. if !m.op.Is(OpUpdateOne) {
  31825. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31826. }
  31827. if m.id == nil || m.oldValue == nil {
  31828. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31829. }
  31830. oldValue, err := m.oldValue(ctx)
  31831. if err != nil {
  31832. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31833. }
  31834. return oldValue.LabelDist, nil
  31835. }
  31836. // AppendLabelDist adds ctd to the "label_dist" field.
  31837. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31838. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31839. }
  31840. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31841. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31842. if len(m.appendlabel_dist) == 0 {
  31843. return nil, false
  31844. }
  31845. return m.appendlabel_dist, true
  31846. }
  31847. // ResetLabelDist resets all changes to the "label_dist" field.
  31848. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  31849. m.label_dist = nil
  31850. m.appendlabel_dist = nil
  31851. }
  31852. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  31853. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  31854. m.predicates = append(m.predicates, ps...)
  31855. }
  31856. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  31857. // users can use type-assertion to append predicates that do not depend on any generated package.
  31858. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  31859. p := make([]predicate.UsageStatisticHour, len(ps))
  31860. for i := range ps {
  31861. p[i] = ps[i]
  31862. }
  31863. m.Where(p...)
  31864. }
  31865. // Op returns the operation name.
  31866. func (m *UsageStatisticHourMutation) Op() Op {
  31867. return m.op
  31868. }
  31869. // SetOp allows setting the mutation operation.
  31870. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  31871. m.op = op
  31872. }
  31873. // Type returns the node type of this mutation (UsageStatisticHour).
  31874. func (m *UsageStatisticHourMutation) Type() string {
  31875. return m.typ
  31876. }
  31877. // Fields returns all fields that were changed during this mutation. Note that in
  31878. // order to get all numeric fields that were incremented/decremented, call
  31879. // AddedFields().
  31880. func (m *UsageStatisticHourMutation) Fields() []string {
  31881. fields := make([]string, 0, 17)
  31882. if m.created_at != nil {
  31883. fields = append(fields, usagestatistichour.FieldCreatedAt)
  31884. }
  31885. if m.updated_at != nil {
  31886. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  31887. }
  31888. if m.status != nil {
  31889. fields = append(fields, usagestatistichour.FieldStatus)
  31890. }
  31891. if m.deleted_at != nil {
  31892. fields = append(fields, usagestatistichour.FieldDeletedAt)
  31893. }
  31894. if m.addtime != nil {
  31895. fields = append(fields, usagestatistichour.FieldAddtime)
  31896. }
  31897. if m._type != nil {
  31898. fields = append(fields, usagestatistichour.FieldType)
  31899. }
  31900. if m.bot_id != nil {
  31901. fields = append(fields, usagestatistichour.FieldBotID)
  31902. }
  31903. if m.organization_id != nil {
  31904. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31905. }
  31906. if m.ai_response != nil {
  31907. fields = append(fields, usagestatistichour.FieldAiResponse)
  31908. }
  31909. if m.sop_run != nil {
  31910. fields = append(fields, usagestatistichour.FieldSopRun)
  31911. }
  31912. if m.total_friend != nil {
  31913. fields = append(fields, usagestatistichour.FieldTotalFriend)
  31914. }
  31915. if m.total_group != nil {
  31916. fields = append(fields, usagestatistichour.FieldTotalGroup)
  31917. }
  31918. if m.account_balance != nil {
  31919. fields = append(fields, usagestatistichour.FieldAccountBalance)
  31920. }
  31921. if m.consume_token != nil {
  31922. fields = append(fields, usagestatistichour.FieldConsumeToken)
  31923. }
  31924. if m.active_user != nil {
  31925. fields = append(fields, usagestatistichour.FieldActiveUser)
  31926. }
  31927. if m.new_user != nil {
  31928. fields = append(fields, usagestatistichour.FieldNewUser)
  31929. }
  31930. if m.label_dist != nil {
  31931. fields = append(fields, usagestatistichour.FieldLabelDist)
  31932. }
  31933. return fields
  31934. }
  31935. // Field returns the value of a field with the given name. The second boolean
  31936. // return value indicates that this field was not set, or was not defined in the
  31937. // schema.
  31938. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  31939. switch name {
  31940. case usagestatistichour.FieldCreatedAt:
  31941. return m.CreatedAt()
  31942. case usagestatistichour.FieldUpdatedAt:
  31943. return m.UpdatedAt()
  31944. case usagestatistichour.FieldStatus:
  31945. return m.Status()
  31946. case usagestatistichour.FieldDeletedAt:
  31947. return m.DeletedAt()
  31948. case usagestatistichour.FieldAddtime:
  31949. return m.Addtime()
  31950. case usagestatistichour.FieldType:
  31951. return m.GetType()
  31952. case usagestatistichour.FieldBotID:
  31953. return m.BotID()
  31954. case usagestatistichour.FieldOrganizationID:
  31955. return m.OrganizationID()
  31956. case usagestatistichour.FieldAiResponse:
  31957. return m.AiResponse()
  31958. case usagestatistichour.FieldSopRun:
  31959. return m.SopRun()
  31960. case usagestatistichour.FieldTotalFriend:
  31961. return m.TotalFriend()
  31962. case usagestatistichour.FieldTotalGroup:
  31963. return m.TotalGroup()
  31964. case usagestatistichour.FieldAccountBalance:
  31965. return m.AccountBalance()
  31966. case usagestatistichour.FieldConsumeToken:
  31967. return m.ConsumeToken()
  31968. case usagestatistichour.FieldActiveUser:
  31969. return m.ActiveUser()
  31970. case usagestatistichour.FieldNewUser:
  31971. return m.NewUser()
  31972. case usagestatistichour.FieldLabelDist:
  31973. return m.LabelDist()
  31974. }
  31975. return nil, false
  31976. }
  31977. // OldField returns the old value of the field from the database. An error is
  31978. // returned if the mutation operation is not UpdateOne, or the query to the
  31979. // database failed.
  31980. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31981. switch name {
  31982. case usagestatistichour.FieldCreatedAt:
  31983. return m.OldCreatedAt(ctx)
  31984. case usagestatistichour.FieldUpdatedAt:
  31985. return m.OldUpdatedAt(ctx)
  31986. case usagestatistichour.FieldStatus:
  31987. return m.OldStatus(ctx)
  31988. case usagestatistichour.FieldDeletedAt:
  31989. return m.OldDeletedAt(ctx)
  31990. case usagestatistichour.FieldAddtime:
  31991. return m.OldAddtime(ctx)
  31992. case usagestatistichour.FieldType:
  31993. return m.OldType(ctx)
  31994. case usagestatistichour.FieldBotID:
  31995. return m.OldBotID(ctx)
  31996. case usagestatistichour.FieldOrganizationID:
  31997. return m.OldOrganizationID(ctx)
  31998. case usagestatistichour.FieldAiResponse:
  31999. return m.OldAiResponse(ctx)
  32000. case usagestatistichour.FieldSopRun:
  32001. return m.OldSopRun(ctx)
  32002. case usagestatistichour.FieldTotalFriend:
  32003. return m.OldTotalFriend(ctx)
  32004. case usagestatistichour.FieldTotalGroup:
  32005. return m.OldTotalGroup(ctx)
  32006. case usagestatistichour.FieldAccountBalance:
  32007. return m.OldAccountBalance(ctx)
  32008. case usagestatistichour.FieldConsumeToken:
  32009. return m.OldConsumeToken(ctx)
  32010. case usagestatistichour.FieldActiveUser:
  32011. return m.OldActiveUser(ctx)
  32012. case usagestatistichour.FieldNewUser:
  32013. return m.OldNewUser(ctx)
  32014. case usagestatistichour.FieldLabelDist:
  32015. return m.OldLabelDist(ctx)
  32016. }
  32017. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  32018. }
  32019. // SetField sets the value of a field with the given name. It returns an error if
  32020. // the field is not defined in the schema, or if the type mismatched the field
  32021. // type.
  32022. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  32023. switch name {
  32024. case usagestatistichour.FieldCreatedAt:
  32025. v, ok := value.(time.Time)
  32026. if !ok {
  32027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32028. }
  32029. m.SetCreatedAt(v)
  32030. return nil
  32031. case usagestatistichour.FieldUpdatedAt:
  32032. v, ok := value.(time.Time)
  32033. if !ok {
  32034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32035. }
  32036. m.SetUpdatedAt(v)
  32037. return nil
  32038. case usagestatistichour.FieldStatus:
  32039. v, ok := value.(uint8)
  32040. if !ok {
  32041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32042. }
  32043. m.SetStatus(v)
  32044. return nil
  32045. case usagestatistichour.FieldDeletedAt:
  32046. v, ok := value.(time.Time)
  32047. if !ok {
  32048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32049. }
  32050. m.SetDeletedAt(v)
  32051. return nil
  32052. case usagestatistichour.FieldAddtime:
  32053. v, ok := value.(uint64)
  32054. if !ok {
  32055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32056. }
  32057. m.SetAddtime(v)
  32058. return nil
  32059. case usagestatistichour.FieldType:
  32060. v, ok := value.(int)
  32061. if !ok {
  32062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32063. }
  32064. m.SetType(v)
  32065. return nil
  32066. case usagestatistichour.FieldBotID:
  32067. v, ok := value.(string)
  32068. if !ok {
  32069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32070. }
  32071. m.SetBotID(v)
  32072. return nil
  32073. case usagestatistichour.FieldOrganizationID:
  32074. v, ok := value.(uint64)
  32075. if !ok {
  32076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32077. }
  32078. m.SetOrganizationID(v)
  32079. return nil
  32080. case usagestatistichour.FieldAiResponse:
  32081. v, ok := value.(uint64)
  32082. if !ok {
  32083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32084. }
  32085. m.SetAiResponse(v)
  32086. return nil
  32087. case usagestatistichour.FieldSopRun:
  32088. v, ok := value.(uint64)
  32089. if !ok {
  32090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32091. }
  32092. m.SetSopRun(v)
  32093. return nil
  32094. case usagestatistichour.FieldTotalFriend:
  32095. v, ok := value.(uint64)
  32096. if !ok {
  32097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32098. }
  32099. m.SetTotalFriend(v)
  32100. return nil
  32101. case usagestatistichour.FieldTotalGroup:
  32102. v, ok := value.(uint64)
  32103. if !ok {
  32104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32105. }
  32106. m.SetTotalGroup(v)
  32107. return nil
  32108. case usagestatistichour.FieldAccountBalance:
  32109. v, ok := value.(uint64)
  32110. if !ok {
  32111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32112. }
  32113. m.SetAccountBalance(v)
  32114. return nil
  32115. case usagestatistichour.FieldConsumeToken:
  32116. v, ok := value.(uint64)
  32117. if !ok {
  32118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32119. }
  32120. m.SetConsumeToken(v)
  32121. return nil
  32122. case usagestatistichour.FieldActiveUser:
  32123. v, ok := value.(uint64)
  32124. if !ok {
  32125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32126. }
  32127. m.SetActiveUser(v)
  32128. return nil
  32129. case usagestatistichour.FieldNewUser:
  32130. v, ok := value.(int64)
  32131. if !ok {
  32132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32133. }
  32134. m.SetNewUser(v)
  32135. return nil
  32136. case usagestatistichour.FieldLabelDist:
  32137. v, ok := value.([]custom_types.LabelDist)
  32138. if !ok {
  32139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32140. }
  32141. m.SetLabelDist(v)
  32142. return nil
  32143. }
  32144. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  32145. }
  32146. // AddedFields returns all numeric fields that were incremented/decremented during
  32147. // this mutation.
  32148. func (m *UsageStatisticHourMutation) AddedFields() []string {
  32149. var fields []string
  32150. if m.addstatus != nil {
  32151. fields = append(fields, usagestatistichour.FieldStatus)
  32152. }
  32153. if m.addaddtime != nil {
  32154. fields = append(fields, usagestatistichour.FieldAddtime)
  32155. }
  32156. if m.add_type != nil {
  32157. fields = append(fields, usagestatistichour.FieldType)
  32158. }
  32159. if m.addorganization_id != nil {
  32160. fields = append(fields, usagestatistichour.FieldOrganizationID)
  32161. }
  32162. if m.addai_response != nil {
  32163. fields = append(fields, usagestatistichour.FieldAiResponse)
  32164. }
  32165. if m.addsop_run != nil {
  32166. fields = append(fields, usagestatistichour.FieldSopRun)
  32167. }
  32168. if m.addtotal_friend != nil {
  32169. fields = append(fields, usagestatistichour.FieldTotalFriend)
  32170. }
  32171. if m.addtotal_group != nil {
  32172. fields = append(fields, usagestatistichour.FieldTotalGroup)
  32173. }
  32174. if m.addaccount_balance != nil {
  32175. fields = append(fields, usagestatistichour.FieldAccountBalance)
  32176. }
  32177. if m.addconsume_token != nil {
  32178. fields = append(fields, usagestatistichour.FieldConsumeToken)
  32179. }
  32180. if m.addactive_user != nil {
  32181. fields = append(fields, usagestatistichour.FieldActiveUser)
  32182. }
  32183. if m.addnew_user != nil {
  32184. fields = append(fields, usagestatistichour.FieldNewUser)
  32185. }
  32186. return fields
  32187. }
  32188. // AddedField returns the numeric value that was incremented/decremented on a field
  32189. // with the given name. The second boolean return value indicates that this field
  32190. // was not set, or was not defined in the schema.
  32191. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  32192. switch name {
  32193. case usagestatistichour.FieldStatus:
  32194. return m.AddedStatus()
  32195. case usagestatistichour.FieldAddtime:
  32196. return m.AddedAddtime()
  32197. case usagestatistichour.FieldType:
  32198. return m.AddedType()
  32199. case usagestatistichour.FieldOrganizationID:
  32200. return m.AddedOrganizationID()
  32201. case usagestatistichour.FieldAiResponse:
  32202. return m.AddedAiResponse()
  32203. case usagestatistichour.FieldSopRun:
  32204. return m.AddedSopRun()
  32205. case usagestatistichour.FieldTotalFriend:
  32206. return m.AddedTotalFriend()
  32207. case usagestatistichour.FieldTotalGroup:
  32208. return m.AddedTotalGroup()
  32209. case usagestatistichour.FieldAccountBalance:
  32210. return m.AddedAccountBalance()
  32211. case usagestatistichour.FieldConsumeToken:
  32212. return m.AddedConsumeToken()
  32213. case usagestatistichour.FieldActiveUser:
  32214. return m.AddedActiveUser()
  32215. case usagestatistichour.FieldNewUser:
  32216. return m.AddedNewUser()
  32217. }
  32218. return nil, false
  32219. }
  32220. // AddField adds the value to the field with the given name. It returns an error if
  32221. // the field is not defined in the schema, or if the type mismatched the field
  32222. // type.
  32223. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  32224. switch name {
  32225. case usagestatistichour.FieldStatus:
  32226. v, ok := value.(int8)
  32227. if !ok {
  32228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32229. }
  32230. m.AddStatus(v)
  32231. return nil
  32232. case usagestatistichour.FieldAddtime:
  32233. v, ok := value.(int64)
  32234. if !ok {
  32235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32236. }
  32237. m.AddAddtime(v)
  32238. return nil
  32239. case usagestatistichour.FieldType:
  32240. v, ok := value.(int)
  32241. if !ok {
  32242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32243. }
  32244. m.AddType(v)
  32245. return nil
  32246. case usagestatistichour.FieldOrganizationID:
  32247. v, ok := value.(int64)
  32248. if !ok {
  32249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32250. }
  32251. m.AddOrganizationID(v)
  32252. return nil
  32253. case usagestatistichour.FieldAiResponse:
  32254. v, ok := value.(int64)
  32255. if !ok {
  32256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32257. }
  32258. m.AddAiResponse(v)
  32259. return nil
  32260. case usagestatistichour.FieldSopRun:
  32261. v, ok := value.(int64)
  32262. if !ok {
  32263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32264. }
  32265. m.AddSopRun(v)
  32266. return nil
  32267. case usagestatistichour.FieldTotalFriend:
  32268. v, ok := value.(int64)
  32269. if !ok {
  32270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32271. }
  32272. m.AddTotalFriend(v)
  32273. return nil
  32274. case usagestatistichour.FieldTotalGroup:
  32275. v, ok := value.(int64)
  32276. if !ok {
  32277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32278. }
  32279. m.AddTotalGroup(v)
  32280. return nil
  32281. case usagestatistichour.FieldAccountBalance:
  32282. v, ok := value.(int64)
  32283. if !ok {
  32284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32285. }
  32286. m.AddAccountBalance(v)
  32287. return nil
  32288. case usagestatistichour.FieldConsumeToken:
  32289. v, ok := value.(int64)
  32290. if !ok {
  32291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32292. }
  32293. m.AddConsumeToken(v)
  32294. return nil
  32295. case usagestatistichour.FieldActiveUser:
  32296. v, ok := value.(int64)
  32297. if !ok {
  32298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32299. }
  32300. m.AddActiveUser(v)
  32301. return nil
  32302. case usagestatistichour.FieldNewUser:
  32303. v, ok := value.(int64)
  32304. if !ok {
  32305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32306. }
  32307. m.AddNewUser(v)
  32308. return nil
  32309. }
  32310. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  32311. }
  32312. // ClearedFields returns all nullable fields that were cleared during this
  32313. // mutation.
  32314. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  32315. var fields []string
  32316. if m.FieldCleared(usagestatistichour.FieldStatus) {
  32317. fields = append(fields, usagestatistichour.FieldStatus)
  32318. }
  32319. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  32320. fields = append(fields, usagestatistichour.FieldDeletedAt)
  32321. }
  32322. if m.FieldCleared(usagestatistichour.FieldBotID) {
  32323. fields = append(fields, usagestatistichour.FieldBotID)
  32324. }
  32325. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  32326. fields = append(fields, usagestatistichour.FieldOrganizationID)
  32327. }
  32328. return fields
  32329. }
  32330. // FieldCleared returns a boolean indicating if a field with the given name was
  32331. // cleared in this mutation.
  32332. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  32333. _, ok := m.clearedFields[name]
  32334. return ok
  32335. }
  32336. // ClearField clears the value of the field with the given name. It returns an
  32337. // error if the field is not defined in the schema.
  32338. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  32339. switch name {
  32340. case usagestatistichour.FieldStatus:
  32341. m.ClearStatus()
  32342. return nil
  32343. case usagestatistichour.FieldDeletedAt:
  32344. m.ClearDeletedAt()
  32345. return nil
  32346. case usagestatistichour.FieldBotID:
  32347. m.ClearBotID()
  32348. return nil
  32349. case usagestatistichour.FieldOrganizationID:
  32350. m.ClearOrganizationID()
  32351. return nil
  32352. }
  32353. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  32354. }
  32355. // ResetField resets all changes in the mutation for the field with the given name.
  32356. // It returns an error if the field is not defined in the schema.
  32357. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  32358. switch name {
  32359. case usagestatistichour.FieldCreatedAt:
  32360. m.ResetCreatedAt()
  32361. return nil
  32362. case usagestatistichour.FieldUpdatedAt:
  32363. m.ResetUpdatedAt()
  32364. return nil
  32365. case usagestatistichour.FieldStatus:
  32366. m.ResetStatus()
  32367. return nil
  32368. case usagestatistichour.FieldDeletedAt:
  32369. m.ResetDeletedAt()
  32370. return nil
  32371. case usagestatistichour.FieldAddtime:
  32372. m.ResetAddtime()
  32373. return nil
  32374. case usagestatistichour.FieldType:
  32375. m.ResetType()
  32376. return nil
  32377. case usagestatistichour.FieldBotID:
  32378. m.ResetBotID()
  32379. return nil
  32380. case usagestatistichour.FieldOrganizationID:
  32381. m.ResetOrganizationID()
  32382. return nil
  32383. case usagestatistichour.FieldAiResponse:
  32384. m.ResetAiResponse()
  32385. return nil
  32386. case usagestatistichour.FieldSopRun:
  32387. m.ResetSopRun()
  32388. return nil
  32389. case usagestatistichour.FieldTotalFriend:
  32390. m.ResetTotalFriend()
  32391. return nil
  32392. case usagestatistichour.FieldTotalGroup:
  32393. m.ResetTotalGroup()
  32394. return nil
  32395. case usagestatistichour.FieldAccountBalance:
  32396. m.ResetAccountBalance()
  32397. return nil
  32398. case usagestatistichour.FieldConsumeToken:
  32399. m.ResetConsumeToken()
  32400. return nil
  32401. case usagestatistichour.FieldActiveUser:
  32402. m.ResetActiveUser()
  32403. return nil
  32404. case usagestatistichour.FieldNewUser:
  32405. m.ResetNewUser()
  32406. return nil
  32407. case usagestatistichour.FieldLabelDist:
  32408. m.ResetLabelDist()
  32409. return nil
  32410. }
  32411. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  32412. }
  32413. // AddedEdges returns all edge names that were set/added in this mutation.
  32414. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  32415. edges := make([]string, 0, 0)
  32416. return edges
  32417. }
  32418. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32419. // name in this mutation.
  32420. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  32421. return nil
  32422. }
  32423. // RemovedEdges returns all edge names that were removed in this mutation.
  32424. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  32425. edges := make([]string, 0, 0)
  32426. return edges
  32427. }
  32428. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32429. // the given name in this mutation.
  32430. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  32431. return nil
  32432. }
  32433. // ClearedEdges returns all edge names that were cleared in this mutation.
  32434. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  32435. edges := make([]string, 0, 0)
  32436. return edges
  32437. }
  32438. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32439. // was cleared in this mutation.
  32440. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  32441. return false
  32442. }
  32443. // ClearEdge clears the value of the edge with the given name. It returns an error
  32444. // if that edge is not defined in the schema.
  32445. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  32446. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  32447. }
  32448. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32449. // It returns an error if the edge is not defined in the schema.
  32450. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  32451. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  32452. }
  32453. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  32454. type UsageStatisticMonthMutation struct {
  32455. config
  32456. op Op
  32457. typ string
  32458. id *uint64
  32459. created_at *time.Time
  32460. updated_at *time.Time
  32461. status *uint8
  32462. addstatus *int8
  32463. deleted_at *time.Time
  32464. addtime *uint64
  32465. addaddtime *int64
  32466. _type *int
  32467. add_type *int
  32468. bot_id *string
  32469. organization_id *uint64
  32470. addorganization_id *int64
  32471. ai_response *uint64
  32472. addai_response *int64
  32473. sop_run *uint64
  32474. addsop_run *int64
  32475. total_friend *uint64
  32476. addtotal_friend *int64
  32477. total_group *uint64
  32478. addtotal_group *int64
  32479. account_balance *uint64
  32480. addaccount_balance *int64
  32481. consume_token *uint64
  32482. addconsume_token *int64
  32483. active_user *uint64
  32484. addactive_user *int64
  32485. new_user *int64
  32486. addnew_user *int64
  32487. label_dist *[]custom_types.LabelDist
  32488. appendlabel_dist []custom_types.LabelDist
  32489. clearedFields map[string]struct{}
  32490. done bool
  32491. oldValue func(context.Context) (*UsageStatisticMonth, error)
  32492. predicates []predicate.UsageStatisticMonth
  32493. }
  32494. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  32495. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  32496. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  32497. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  32498. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  32499. m := &UsageStatisticMonthMutation{
  32500. config: c,
  32501. op: op,
  32502. typ: TypeUsageStatisticMonth,
  32503. clearedFields: make(map[string]struct{}),
  32504. }
  32505. for _, opt := range opts {
  32506. opt(m)
  32507. }
  32508. return m
  32509. }
  32510. // withUsageStatisticMonthID sets the ID field of the mutation.
  32511. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  32512. return func(m *UsageStatisticMonthMutation) {
  32513. var (
  32514. err error
  32515. once sync.Once
  32516. value *UsageStatisticMonth
  32517. )
  32518. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  32519. once.Do(func() {
  32520. if m.done {
  32521. err = errors.New("querying old values post mutation is not allowed")
  32522. } else {
  32523. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  32524. }
  32525. })
  32526. return value, err
  32527. }
  32528. m.id = &id
  32529. }
  32530. }
  32531. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  32532. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  32533. return func(m *UsageStatisticMonthMutation) {
  32534. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  32535. return node, nil
  32536. }
  32537. m.id = &node.ID
  32538. }
  32539. }
  32540. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32541. // executed in a transaction (ent.Tx), a transactional client is returned.
  32542. func (m UsageStatisticMonthMutation) Client() *Client {
  32543. client := &Client{config: m.config}
  32544. client.init()
  32545. return client
  32546. }
  32547. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32548. // it returns an error otherwise.
  32549. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  32550. if _, ok := m.driver.(*txDriver); !ok {
  32551. return nil, errors.New("ent: mutation is not running in a transaction")
  32552. }
  32553. tx := &Tx{config: m.config}
  32554. tx.init()
  32555. return tx, nil
  32556. }
  32557. // SetID sets the value of the id field. Note that this
  32558. // operation is only accepted on creation of UsageStatisticMonth entities.
  32559. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  32560. m.id = &id
  32561. }
  32562. // ID returns the ID value in the mutation. Note that the ID is only available
  32563. // if it was provided to the builder or after it was returned from the database.
  32564. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  32565. if m.id == nil {
  32566. return
  32567. }
  32568. return *m.id, true
  32569. }
  32570. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32571. // That means, if the mutation is applied within a transaction with an isolation level such
  32572. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32573. // or updated by the mutation.
  32574. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  32575. switch {
  32576. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32577. id, exists := m.ID()
  32578. if exists {
  32579. return []uint64{id}, nil
  32580. }
  32581. fallthrough
  32582. case m.op.Is(OpUpdate | OpDelete):
  32583. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  32584. default:
  32585. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32586. }
  32587. }
  32588. // SetCreatedAt sets the "created_at" field.
  32589. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  32590. m.created_at = &t
  32591. }
  32592. // CreatedAt returns the value of the "created_at" field in the mutation.
  32593. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  32594. v := m.created_at
  32595. if v == nil {
  32596. return
  32597. }
  32598. return *v, true
  32599. }
  32600. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  32601. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32603. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32604. if !m.op.Is(OpUpdateOne) {
  32605. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32606. }
  32607. if m.id == nil || m.oldValue == nil {
  32608. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32609. }
  32610. oldValue, err := m.oldValue(ctx)
  32611. if err != nil {
  32612. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32613. }
  32614. return oldValue.CreatedAt, nil
  32615. }
  32616. // ResetCreatedAt resets all changes to the "created_at" field.
  32617. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  32618. m.created_at = nil
  32619. }
  32620. // SetUpdatedAt sets the "updated_at" field.
  32621. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  32622. m.updated_at = &t
  32623. }
  32624. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32625. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  32626. v := m.updated_at
  32627. if v == nil {
  32628. return
  32629. }
  32630. return *v, true
  32631. }
  32632. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  32633. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32635. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32636. if !m.op.Is(OpUpdateOne) {
  32637. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32638. }
  32639. if m.id == nil || m.oldValue == nil {
  32640. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32641. }
  32642. oldValue, err := m.oldValue(ctx)
  32643. if err != nil {
  32644. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32645. }
  32646. return oldValue.UpdatedAt, nil
  32647. }
  32648. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32649. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  32650. m.updated_at = nil
  32651. }
  32652. // SetStatus sets the "status" field.
  32653. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  32654. m.status = &u
  32655. m.addstatus = nil
  32656. }
  32657. // Status returns the value of the "status" field in the mutation.
  32658. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  32659. v := m.status
  32660. if v == nil {
  32661. return
  32662. }
  32663. return *v, true
  32664. }
  32665. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  32666. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32668. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32669. if !m.op.Is(OpUpdateOne) {
  32670. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32671. }
  32672. if m.id == nil || m.oldValue == nil {
  32673. return v, errors.New("OldStatus requires an ID field in the mutation")
  32674. }
  32675. oldValue, err := m.oldValue(ctx)
  32676. if err != nil {
  32677. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32678. }
  32679. return oldValue.Status, nil
  32680. }
  32681. // AddStatus adds u to the "status" field.
  32682. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  32683. if m.addstatus != nil {
  32684. *m.addstatus += u
  32685. } else {
  32686. m.addstatus = &u
  32687. }
  32688. }
  32689. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32690. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  32691. v := m.addstatus
  32692. if v == nil {
  32693. return
  32694. }
  32695. return *v, true
  32696. }
  32697. // ClearStatus clears the value of the "status" field.
  32698. func (m *UsageStatisticMonthMutation) ClearStatus() {
  32699. m.status = nil
  32700. m.addstatus = nil
  32701. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  32702. }
  32703. // StatusCleared returns if the "status" field was cleared in this mutation.
  32704. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  32705. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  32706. return ok
  32707. }
  32708. // ResetStatus resets all changes to the "status" field.
  32709. func (m *UsageStatisticMonthMutation) ResetStatus() {
  32710. m.status = nil
  32711. m.addstatus = nil
  32712. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  32713. }
  32714. // SetDeletedAt sets the "deleted_at" field.
  32715. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  32716. m.deleted_at = &t
  32717. }
  32718. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32719. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  32720. v := m.deleted_at
  32721. if v == nil {
  32722. return
  32723. }
  32724. return *v, true
  32725. }
  32726. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  32727. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32729. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32730. if !m.op.Is(OpUpdateOne) {
  32731. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32732. }
  32733. if m.id == nil || m.oldValue == nil {
  32734. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32735. }
  32736. oldValue, err := m.oldValue(ctx)
  32737. if err != nil {
  32738. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32739. }
  32740. return oldValue.DeletedAt, nil
  32741. }
  32742. // ClearDeletedAt clears the value of the "deleted_at" field.
  32743. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  32744. m.deleted_at = nil
  32745. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  32746. }
  32747. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32748. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  32749. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  32750. return ok
  32751. }
  32752. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32753. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  32754. m.deleted_at = nil
  32755. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  32756. }
  32757. // SetAddtime sets the "addtime" field.
  32758. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  32759. m.addtime = &u
  32760. m.addaddtime = nil
  32761. }
  32762. // Addtime returns the value of the "addtime" field in the mutation.
  32763. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  32764. v := m.addtime
  32765. if v == nil {
  32766. return
  32767. }
  32768. return *v, true
  32769. }
  32770. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  32771. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32773. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32774. if !m.op.Is(OpUpdateOne) {
  32775. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32776. }
  32777. if m.id == nil || m.oldValue == nil {
  32778. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32779. }
  32780. oldValue, err := m.oldValue(ctx)
  32781. if err != nil {
  32782. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32783. }
  32784. return oldValue.Addtime, nil
  32785. }
  32786. // AddAddtime adds u to the "addtime" field.
  32787. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  32788. if m.addaddtime != nil {
  32789. *m.addaddtime += u
  32790. } else {
  32791. m.addaddtime = &u
  32792. }
  32793. }
  32794. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32795. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  32796. v := m.addaddtime
  32797. if v == nil {
  32798. return
  32799. }
  32800. return *v, true
  32801. }
  32802. // ResetAddtime resets all changes to the "addtime" field.
  32803. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  32804. m.addtime = nil
  32805. m.addaddtime = nil
  32806. }
  32807. // SetType sets the "type" field.
  32808. func (m *UsageStatisticMonthMutation) SetType(i int) {
  32809. m._type = &i
  32810. m.add_type = nil
  32811. }
  32812. // GetType returns the value of the "type" field in the mutation.
  32813. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  32814. v := m._type
  32815. if v == nil {
  32816. return
  32817. }
  32818. return *v, true
  32819. }
  32820. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  32821. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32823. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  32824. if !m.op.Is(OpUpdateOne) {
  32825. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32826. }
  32827. if m.id == nil || m.oldValue == nil {
  32828. return v, errors.New("OldType requires an ID field in the mutation")
  32829. }
  32830. oldValue, err := m.oldValue(ctx)
  32831. if err != nil {
  32832. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32833. }
  32834. return oldValue.Type, nil
  32835. }
  32836. // AddType adds i to the "type" field.
  32837. func (m *UsageStatisticMonthMutation) AddType(i int) {
  32838. if m.add_type != nil {
  32839. *m.add_type += i
  32840. } else {
  32841. m.add_type = &i
  32842. }
  32843. }
  32844. // AddedType returns the value that was added to the "type" field in this mutation.
  32845. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  32846. v := m.add_type
  32847. if v == nil {
  32848. return
  32849. }
  32850. return *v, true
  32851. }
  32852. // ResetType resets all changes to the "type" field.
  32853. func (m *UsageStatisticMonthMutation) ResetType() {
  32854. m._type = nil
  32855. m.add_type = nil
  32856. }
  32857. // SetBotID sets the "bot_id" field.
  32858. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  32859. m.bot_id = &s
  32860. }
  32861. // BotID returns the value of the "bot_id" field in the mutation.
  32862. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  32863. v := m.bot_id
  32864. if v == nil {
  32865. return
  32866. }
  32867. return *v, true
  32868. }
  32869. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  32870. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32872. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  32873. if !m.op.Is(OpUpdateOne) {
  32874. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32875. }
  32876. if m.id == nil || m.oldValue == nil {
  32877. return v, errors.New("OldBotID requires an ID field in the mutation")
  32878. }
  32879. oldValue, err := m.oldValue(ctx)
  32880. if err != nil {
  32881. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32882. }
  32883. return oldValue.BotID, nil
  32884. }
  32885. // ClearBotID clears the value of the "bot_id" field.
  32886. func (m *UsageStatisticMonthMutation) ClearBotID() {
  32887. m.bot_id = nil
  32888. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  32889. }
  32890. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32891. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  32892. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  32893. return ok
  32894. }
  32895. // ResetBotID resets all changes to the "bot_id" field.
  32896. func (m *UsageStatisticMonthMutation) ResetBotID() {
  32897. m.bot_id = nil
  32898. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  32899. }
  32900. // SetOrganizationID sets the "organization_id" field.
  32901. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  32902. m.organization_id = &u
  32903. m.addorganization_id = nil
  32904. }
  32905. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32906. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  32907. v := m.organization_id
  32908. if v == nil {
  32909. return
  32910. }
  32911. return *v, true
  32912. }
  32913. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  32914. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32916. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32917. if !m.op.Is(OpUpdateOne) {
  32918. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32919. }
  32920. if m.id == nil || m.oldValue == nil {
  32921. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32922. }
  32923. oldValue, err := m.oldValue(ctx)
  32924. if err != nil {
  32925. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32926. }
  32927. return oldValue.OrganizationID, nil
  32928. }
  32929. // AddOrganizationID adds u to the "organization_id" field.
  32930. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  32931. if m.addorganization_id != nil {
  32932. *m.addorganization_id += u
  32933. } else {
  32934. m.addorganization_id = &u
  32935. }
  32936. }
  32937. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32938. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  32939. v := m.addorganization_id
  32940. if v == nil {
  32941. return
  32942. }
  32943. return *v, true
  32944. }
  32945. // ClearOrganizationID clears the value of the "organization_id" field.
  32946. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  32947. m.organization_id = nil
  32948. m.addorganization_id = nil
  32949. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  32950. }
  32951. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32952. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  32953. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  32954. return ok
  32955. }
  32956. // ResetOrganizationID resets all changes to the "organization_id" field.
  32957. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  32958. m.organization_id = nil
  32959. m.addorganization_id = nil
  32960. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  32961. }
  32962. // SetAiResponse sets the "ai_response" field.
  32963. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  32964. m.ai_response = &u
  32965. m.addai_response = nil
  32966. }
  32967. // AiResponse returns the value of the "ai_response" field in the mutation.
  32968. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  32969. v := m.ai_response
  32970. if v == nil {
  32971. return
  32972. }
  32973. return *v, true
  32974. }
  32975. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  32976. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32978. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32979. if !m.op.Is(OpUpdateOne) {
  32980. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32981. }
  32982. if m.id == nil || m.oldValue == nil {
  32983. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32984. }
  32985. oldValue, err := m.oldValue(ctx)
  32986. if err != nil {
  32987. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32988. }
  32989. return oldValue.AiResponse, nil
  32990. }
  32991. // AddAiResponse adds u to the "ai_response" field.
  32992. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  32993. if m.addai_response != nil {
  32994. *m.addai_response += u
  32995. } else {
  32996. m.addai_response = &u
  32997. }
  32998. }
  32999. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  33000. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  33001. v := m.addai_response
  33002. if v == nil {
  33003. return
  33004. }
  33005. return *v, true
  33006. }
  33007. // ResetAiResponse resets all changes to the "ai_response" field.
  33008. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  33009. m.ai_response = nil
  33010. m.addai_response = nil
  33011. }
  33012. // SetSopRun sets the "sop_run" field.
  33013. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  33014. m.sop_run = &u
  33015. m.addsop_run = nil
  33016. }
  33017. // SopRun returns the value of the "sop_run" field in the mutation.
  33018. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  33019. v := m.sop_run
  33020. if v == nil {
  33021. return
  33022. }
  33023. return *v, true
  33024. }
  33025. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  33026. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33028. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  33029. if !m.op.Is(OpUpdateOne) {
  33030. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  33031. }
  33032. if m.id == nil || m.oldValue == nil {
  33033. return v, errors.New("OldSopRun requires an ID field in the mutation")
  33034. }
  33035. oldValue, err := m.oldValue(ctx)
  33036. if err != nil {
  33037. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  33038. }
  33039. return oldValue.SopRun, nil
  33040. }
  33041. // AddSopRun adds u to the "sop_run" field.
  33042. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  33043. if m.addsop_run != nil {
  33044. *m.addsop_run += u
  33045. } else {
  33046. m.addsop_run = &u
  33047. }
  33048. }
  33049. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  33050. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  33051. v := m.addsop_run
  33052. if v == nil {
  33053. return
  33054. }
  33055. return *v, true
  33056. }
  33057. // ResetSopRun resets all changes to the "sop_run" field.
  33058. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  33059. m.sop_run = nil
  33060. m.addsop_run = nil
  33061. }
  33062. // SetTotalFriend sets the "total_friend" field.
  33063. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  33064. m.total_friend = &u
  33065. m.addtotal_friend = nil
  33066. }
  33067. // TotalFriend returns the value of the "total_friend" field in the mutation.
  33068. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  33069. v := m.total_friend
  33070. if v == nil {
  33071. return
  33072. }
  33073. return *v, true
  33074. }
  33075. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  33076. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33078. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  33079. if !m.op.Is(OpUpdateOne) {
  33080. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  33081. }
  33082. if m.id == nil || m.oldValue == nil {
  33083. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  33084. }
  33085. oldValue, err := m.oldValue(ctx)
  33086. if err != nil {
  33087. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  33088. }
  33089. return oldValue.TotalFriend, nil
  33090. }
  33091. // AddTotalFriend adds u to the "total_friend" field.
  33092. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  33093. if m.addtotal_friend != nil {
  33094. *m.addtotal_friend += u
  33095. } else {
  33096. m.addtotal_friend = &u
  33097. }
  33098. }
  33099. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  33100. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  33101. v := m.addtotal_friend
  33102. if v == nil {
  33103. return
  33104. }
  33105. return *v, true
  33106. }
  33107. // ResetTotalFriend resets all changes to the "total_friend" field.
  33108. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  33109. m.total_friend = nil
  33110. m.addtotal_friend = nil
  33111. }
  33112. // SetTotalGroup sets the "total_group" field.
  33113. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  33114. m.total_group = &u
  33115. m.addtotal_group = nil
  33116. }
  33117. // TotalGroup returns the value of the "total_group" field in the mutation.
  33118. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  33119. v := m.total_group
  33120. if v == nil {
  33121. return
  33122. }
  33123. return *v, true
  33124. }
  33125. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  33126. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33128. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  33129. if !m.op.Is(OpUpdateOne) {
  33130. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  33131. }
  33132. if m.id == nil || m.oldValue == nil {
  33133. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  33134. }
  33135. oldValue, err := m.oldValue(ctx)
  33136. if err != nil {
  33137. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  33138. }
  33139. return oldValue.TotalGroup, nil
  33140. }
  33141. // AddTotalGroup adds u to the "total_group" field.
  33142. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  33143. if m.addtotal_group != nil {
  33144. *m.addtotal_group += u
  33145. } else {
  33146. m.addtotal_group = &u
  33147. }
  33148. }
  33149. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  33150. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  33151. v := m.addtotal_group
  33152. if v == nil {
  33153. return
  33154. }
  33155. return *v, true
  33156. }
  33157. // ResetTotalGroup resets all changes to the "total_group" field.
  33158. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  33159. m.total_group = nil
  33160. m.addtotal_group = nil
  33161. }
  33162. // SetAccountBalance sets the "account_balance" field.
  33163. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  33164. m.account_balance = &u
  33165. m.addaccount_balance = nil
  33166. }
  33167. // AccountBalance returns the value of the "account_balance" field in the mutation.
  33168. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  33169. v := m.account_balance
  33170. if v == nil {
  33171. return
  33172. }
  33173. return *v, true
  33174. }
  33175. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  33176. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33178. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  33179. if !m.op.Is(OpUpdateOne) {
  33180. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  33181. }
  33182. if m.id == nil || m.oldValue == nil {
  33183. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  33184. }
  33185. oldValue, err := m.oldValue(ctx)
  33186. if err != nil {
  33187. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  33188. }
  33189. return oldValue.AccountBalance, nil
  33190. }
  33191. // AddAccountBalance adds u to the "account_balance" field.
  33192. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  33193. if m.addaccount_balance != nil {
  33194. *m.addaccount_balance += u
  33195. } else {
  33196. m.addaccount_balance = &u
  33197. }
  33198. }
  33199. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  33200. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  33201. v := m.addaccount_balance
  33202. if v == nil {
  33203. return
  33204. }
  33205. return *v, true
  33206. }
  33207. // ResetAccountBalance resets all changes to the "account_balance" field.
  33208. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  33209. m.account_balance = nil
  33210. m.addaccount_balance = nil
  33211. }
  33212. // SetConsumeToken sets the "consume_token" field.
  33213. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  33214. m.consume_token = &u
  33215. m.addconsume_token = nil
  33216. }
  33217. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  33218. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  33219. v := m.consume_token
  33220. if v == nil {
  33221. return
  33222. }
  33223. return *v, true
  33224. }
  33225. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  33226. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33228. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  33229. if !m.op.Is(OpUpdateOne) {
  33230. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  33231. }
  33232. if m.id == nil || m.oldValue == nil {
  33233. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  33234. }
  33235. oldValue, err := m.oldValue(ctx)
  33236. if err != nil {
  33237. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  33238. }
  33239. return oldValue.ConsumeToken, nil
  33240. }
  33241. // AddConsumeToken adds u to the "consume_token" field.
  33242. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  33243. if m.addconsume_token != nil {
  33244. *m.addconsume_token += u
  33245. } else {
  33246. m.addconsume_token = &u
  33247. }
  33248. }
  33249. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  33250. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  33251. v := m.addconsume_token
  33252. if v == nil {
  33253. return
  33254. }
  33255. return *v, true
  33256. }
  33257. // ResetConsumeToken resets all changes to the "consume_token" field.
  33258. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  33259. m.consume_token = nil
  33260. m.addconsume_token = nil
  33261. }
  33262. // SetActiveUser sets the "active_user" field.
  33263. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  33264. m.active_user = &u
  33265. m.addactive_user = nil
  33266. }
  33267. // ActiveUser returns the value of the "active_user" field in the mutation.
  33268. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  33269. v := m.active_user
  33270. if v == nil {
  33271. return
  33272. }
  33273. return *v, true
  33274. }
  33275. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  33276. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33278. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  33279. if !m.op.Is(OpUpdateOne) {
  33280. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  33281. }
  33282. if m.id == nil || m.oldValue == nil {
  33283. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  33284. }
  33285. oldValue, err := m.oldValue(ctx)
  33286. if err != nil {
  33287. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  33288. }
  33289. return oldValue.ActiveUser, nil
  33290. }
  33291. // AddActiveUser adds u to the "active_user" field.
  33292. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  33293. if m.addactive_user != nil {
  33294. *m.addactive_user += u
  33295. } else {
  33296. m.addactive_user = &u
  33297. }
  33298. }
  33299. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  33300. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  33301. v := m.addactive_user
  33302. if v == nil {
  33303. return
  33304. }
  33305. return *v, true
  33306. }
  33307. // ResetActiveUser resets all changes to the "active_user" field.
  33308. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  33309. m.active_user = nil
  33310. m.addactive_user = nil
  33311. }
  33312. // SetNewUser sets the "new_user" field.
  33313. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  33314. m.new_user = &i
  33315. m.addnew_user = nil
  33316. }
  33317. // NewUser returns the value of the "new_user" field in the mutation.
  33318. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  33319. v := m.new_user
  33320. if v == nil {
  33321. return
  33322. }
  33323. return *v, true
  33324. }
  33325. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  33326. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33328. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  33329. if !m.op.Is(OpUpdateOne) {
  33330. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  33331. }
  33332. if m.id == nil || m.oldValue == nil {
  33333. return v, errors.New("OldNewUser requires an ID field in the mutation")
  33334. }
  33335. oldValue, err := m.oldValue(ctx)
  33336. if err != nil {
  33337. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  33338. }
  33339. return oldValue.NewUser, nil
  33340. }
  33341. // AddNewUser adds i to the "new_user" field.
  33342. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  33343. if m.addnew_user != nil {
  33344. *m.addnew_user += i
  33345. } else {
  33346. m.addnew_user = &i
  33347. }
  33348. }
  33349. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  33350. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  33351. v := m.addnew_user
  33352. if v == nil {
  33353. return
  33354. }
  33355. return *v, true
  33356. }
  33357. // ResetNewUser resets all changes to the "new_user" field.
  33358. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  33359. m.new_user = nil
  33360. m.addnew_user = nil
  33361. }
  33362. // SetLabelDist sets the "label_dist" field.
  33363. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  33364. m.label_dist = &ctd
  33365. m.appendlabel_dist = nil
  33366. }
  33367. // LabelDist returns the value of the "label_dist" field in the mutation.
  33368. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  33369. v := m.label_dist
  33370. if v == nil {
  33371. return
  33372. }
  33373. return *v, true
  33374. }
  33375. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  33376. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33378. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33379. if !m.op.Is(OpUpdateOne) {
  33380. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33381. }
  33382. if m.id == nil || m.oldValue == nil {
  33383. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  33384. }
  33385. oldValue, err := m.oldValue(ctx)
  33386. if err != nil {
  33387. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  33388. }
  33389. return oldValue.LabelDist, nil
  33390. }
  33391. // AppendLabelDist adds ctd to the "label_dist" field.
  33392. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33393. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33394. }
  33395. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33396. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33397. if len(m.appendlabel_dist) == 0 {
  33398. return nil, false
  33399. }
  33400. return m.appendlabel_dist, true
  33401. }
  33402. // ResetLabelDist resets all changes to the "label_dist" field.
  33403. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  33404. m.label_dist = nil
  33405. m.appendlabel_dist = nil
  33406. }
  33407. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  33408. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  33409. m.predicates = append(m.predicates, ps...)
  33410. }
  33411. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  33412. // users can use type-assertion to append predicates that do not depend on any generated package.
  33413. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  33414. p := make([]predicate.UsageStatisticMonth, len(ps))
  33415. for i := range ps {
  33416. p[i] = ps[i]
  33417. }
  33418. m.Where(p...)
  33419. }
  33420. // Op returns the operation name.
  33421. func (m *UsageStatisticMonthMutation) Op() Op {
  33422. return m.op
  33423. }
  33424. // SetOp allows setting the mutation operation.
  33425. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  33426. m.op = op
  33427. }
  33428. // Type returns the node type of this mutation (UsageStatisticMonth).
  33429. func (m *UsageStatisticMonthMutation) Type() string {
  33430. return m.typ
  33431. }
  33432. // Fields returns all fields that were changed during this mutation. Note that in
  33433. // order to get all numeric fields that were incremented/decremented, call
  33434. // AddedFields().
  33435. func (m *UsageStatisticMonthMutation) Fields() []string {
  33436. fields := make([]string, 0, 17)
  33437. if m.created_at != nil {
  33438. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  33439. }
  33440. if m.updated_at != nil {
  33441. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  33442. }
  33443. if m.status != nil {
  33444. fields = append(fields, usagestatisticmonth.FieldStatus)
  33445. }
  33446. if m.deleted_at != nil {
  33447. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  33448. }
  33449. if m.addtime != nil {
  33450. fields = append(fields, usagestatisticmonth.FieldAddtime)
  33451. }
  33452. if m._type != nil {
  33453. fields = append(fields, usagestatisticmonth.FieldType)
  33454. }
  33455. if m.bot_id != nil {
  33456. fields = append(fields, usagestatisticmonth.FieldBotID)
  33457. }
  33458. if m.organization_id != nil {
  33459. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33460. }
  33461. if m.ai_response != nil {
  33462. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  33463. }
  33464. if m.sop_run != nil {
  33465. fields = append(fields, usagestatisticmonth.FieldSopRun)
  33466. }
  33467. if m.total_friend != nil {
  33468. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  33469. }
  33470. if m.total_group != nil {
  33471. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  33472. }
  33473. if m.account_balance != nil {
  33474. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  33475. }
  33476. if m.consume_token != nil {
  33477. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  33478. }
  33479. if m.active_user != nil {
  33480. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  33481. }
  33482. if m.new_user != nil {
  33483. fields = append(fields, usagestatisticmonth.FieldNewUser)
  33484. }
  33485. if m.label_dist != nil {
  33486. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  33487. }
  33488. return fields
  33489. }
  33490. // Field returns the value of a field with the given name. The second boolean
  33491. // return value indicates that this field was not set, or was not defined in the
  33492. // schema.
  33493. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  33494. switch name {
  33495. case usagestatisticmonth.FieldCreatedAt:
  33496. return m.CreatedAt()
  33497. case usagestatisticmonth.FieldUpdatedAt:
  33498. return m.UpdatedAt()
  33499. case usagestatisticmonth.FieldStatus:
  33500. return m.Status()
  33501. case usagestatisticmonth.FieldDeletedAt:
  33502. return m.DeletedAt()
  33503. case usagestatisticmonth.FieldAddtime:
  33504. return m.Addtime()
  33505. case usagestatisticmonth.FieldType:
  33506. return m.GetType()
  33507. case usagestatisticmonth.FieldBotID:
  33508. return m.BotID()
  33509. case usagestatisticmonth.FieldOrganizationID:
  33510. return m.OrganizationID()
  33511. case usagestatisticmonth.FieldAiResponse:
  33512. return m.AiResponse()
  33513. case usagestatisticmonth.FieldSopRun:
  33514. return m.SopRun()
  33515. case usagestatisticmonth.FieldTotalFriend:
  33516. return m.TotalFriend()
  33517. case usagestatisticmonth.FieldTotalGroup:
  33518. return m.TotalGroup()
  33519. case usagestatisticmonth.FieldAccountBalance:
  33520. return m.AccountBalance()
  33521. case usagestatisticmonth.FieldConsumeToken:
  33522. return m.ConsumeToken()
  33523. case usagestatisticmonth.FieldActiveUser:
  33524. return m.ActiveUser()
  33525. case usagestatisticmonth.FieldNewUser:
  33526. return m.NewUser()
  33527. case usagestatisticmonth.FieldLabelDist:
  33528. return m.LabelDist()
  33529. }
  33530. return nil, false
  33531. }
  33532. // OldField returns the old value of the field from the database. An error is
  33533. // returned if the mutation operation is not UpdateOne, or the query to the
  33534. // database failed.
  33535. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33536. switch name {
  33537. case usagestatisticmonth.FieldCreatedAt:
  33538. return m.OldCreatedAt(ctx)
  33539. case usagestatisticmonth.FieldUpdatedAt:
  33540. return m.OldUpdatedAt(ctx)
  33541. case usagestatisticmonth.FieldStatus:
  33542. return m.OldStatus(ctx)
  33543. case usagestatisticmonth.FieldDeletedAt:
  33544. return m.OldDeletedAt(ctx)
  33545. case usagestatisticmonth.FieldAddtime:
  33546. return m.OldAddtime(ctx)
  33547. case usagestatisticmonth.FieldType:
  33548. return m.OldType(ctx)
  33549. case usagestatisticmonth.FieldBotID:
  33550. return m.OldBotID(ctx)
  33551. case usagestatisticmonth.FieldOrganizationID:
  33552. return m.OldOrganizationID(ctx)
  33553. case usagestatisticmonth.FieldAiResponse:
  33554. return m.OldAiResponse(ctx)
  33555. case usagestatisticmonth.FieldSopRun:
  33556. return m.OldSopRun(ctx)
  33557. case usagestatisticmonth.FieldTotalFriend:
  33558. return m.OldTotalFriend(ctx)
  33559. case usagestatisticmonth.FieldTotalGroup:
  33560. return m.OldTotalGroup(ctx)
  33561. case usagestatisticmonth.FieldAccountBalance:
  33562. return m.OldAccountBalance(ctx)
  33563. case usagestatisticmonth.FieldConsumeToken:
  33564. return m.OldConsumeToken(ctx)
  33565. case usagestatisticmonth.FieldActiveUser:
  33566. return m.OldActiveUser(ctx)
  33567. case usagestatisticmonth.FieldNewUser:
  33568. return m.OldNewUser(ctx)
  33569. case usagestatisticmonth.FieldLabelDist:
  33570. return m.OldLabelDist(ctx)
  33571. }
  33572. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33573. }
  33574. // SetField sets the value of a field with the given name. It returns an error if
  33575. // the field is not defined in the schema, or if the type mismatched the field
  33576. // type.
  33577. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  33578. switch name {
  33579. case usagestatisticmonth.FieldCreatedAt:
  33580. v, ok := value.(time.Time)
  33581. if !ok {
  33582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33583. }
  33584. m.SetCreatedAt(v)
  33585. return nil
  33586. case usagestatisticmonth.FieldUpdatedAt:
  33587. v, ok := value.(time.Time)
  33588. if !ok {
  33589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33590. }
  33591. m.SetUpdatedAt(v)
  33592. return nil
  33593. case usagestatisticmonth.FieldStatus:
  33594. v, ok := value.(uint8)
  33595. if !ok {
  33596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33597. }
  33598. m.SetStatus(v)
  33599. return nil
  33600. case usagestatisticmonth.FieldDeletedAt:
  33601. v, ok := value.(time.Time)
  33602. if !ok {
  33603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33604. }
  33605. m.SetDeletedAt(v)
  33606. return nil
  33607. case usagestatisticmonth.FieldAddtime:
  33608. v, ok := value.(uint64)
  33609. if !ok {
  33610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33611. }
  33612. m.SetAddtime(v)
  33613. return nil
  33614. case usagestatisticmonth.FieldType:
  33615. v, ok := value.(int)
  33616. if !ok {
  33617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33618. }
  33619. m.SetType(v)
  33620. return nil
  33621. case usagestatisticmonth.FieldBotID:
  33622. v, ok := value.(string)
  33623. if !ok {
  33624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33625. }
  33626. m.SetBotID(v)
  33627. return nil
  33628. case usagestatisticmonth.FieldOrganizationID:
  33629. v, ok := value.(uint64)
  33630. if !ok {
  33631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33632. }
  33633. m.SetOrganizationID(v)
  33634. return nil
  33635. case usagestatisticmonth.FieldAiResponse:
  33636. v, ok := value.(uint64)
  33637. if !ok {
  33638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33639. }
  33640. m.SetAiResponse(v)
  33641. return nil
  33642. case usagestatisticmonth.FieldSopRun:
  33643. v, ok := value.(uint64)
  33644. if !ok {
  33645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33646. }
  33647. m.SetSopRun(v)
  33648. return nil
  33649. case usagestatisticmonth.FieldTotalFriend:
  33650. v, ok := value.(uint64)
  33651. if !ok {
  33652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33653. }
  33654. m.SetTotalFriend(v)
  33655. return nil
  33656. case usagestatisticmonth.FieldTotalGroup:
  33657. v, ok := value.(uint64)
  33658. if !ok {
  33659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33660. }
  33661. m.SetTotalGroup(v)
  33662. return nil
  33663. case usagestatisticmonth.FieldAccountBalance:
  33664. v, ok := value.(uint64)
  33665. if !ok {
  33666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33667. }
  33668. m.SetAccountBalance(v)
  33669. return nil
  33670. case usagestatisticmonth.FieldConsumeToken:
  33671. v, ok := value.(uint64)
  33672. if !ok {
  33673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33674. }
  33675. m.SetConsumeToken(v)
  33676. return nil
  33677. case usagestatisticmonth.FieldActiveUser:
  33678. v, ok := value.(uint64)
  33679. if !ok {
  33680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33681. }
  33682. m.SetActiveUser(v)
  33683. return nil
  33684. case usagestatisticmonth.FieldNewUser:
  33685. v, ok := value.(int64)
  33686. if !ok {
  33687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33688. }
  33689. m.SetNewUser(v)
  33690. return nil
  33691. case usagestatisticmonth.FieldLabelDist:
  33692. v, ok := value.([]custom_types.LabelDist)
  33693. if !ok {
  33694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33695. }
  33696. m.SetLabelDist(v)
  33697. return nil
  33698. }
  33699. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33700. }
  33701. // AddedFields returns all numeric fields that were incremented/decremented during
  33702. // this mutation.
  33703. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  33704. var fields []string
  33705. if m.addstatus != nil {
  33706. fields = append(fields, usagestatisticmonth.FieldStatus)
  33707. }
  33708. if m.addaddtime != nil {
  33709. fields = append(fields, usagestatisticmonth.FieldAddtime)
  33710. }
  33711. if m.add_type != nil {
  33712. fields = append(fields, usagestatisticmonth.FieldType)
  33713. }
  33714. if m.addorganization_id != nil {
  33715. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33716. }
  33717. if m.addai_response != nil {
  33718. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  33719. }
  33720. if m.addsop_run != nil {
  33721. fields = append(fields, usagestatisticmonth.FieldSopRun)
  33722. }
  33723. if m.addtotal_friend != nil {
  33724. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  33725. }
  33726. if m.addtotal_group != nil {
  33727. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  33728. }
  33729. if m.addaccount_balance != nil {
  33730. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  33731. }
  33732. if m.addconsume_token != nil {
  33733. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  33734. }
  33735. if m.addactive_user != nil {
  33736. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  33737. }
  33738. if m.addnew_user != nil {
  33739. fields = append(fields, usagestatisticmonth.FieldNewUser)
  33740. }
  33741. return fields
  33742. }
  33743. // AddedField returns the numeric value that was incremented/decremented on a field
  33744. // with the given name. The second boolean return value indicates that this field
  33745. // was not set, or was not defined in the schema.
  33746. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  33747. switch name {
  33748. case usagestatisticmonth.FieldStatus:
  33749. return m.AddedStatus()
  33750. case usagestatisticmonth.FieldAddtime:
  33751. return m.AddedAddtime()
  33752. case usagestatisticmonth.FieldType:
  33753. return m.AddedType()
  33754. case usagestatisticmonth.FieldOrganizationID:
  33755. return m.AddedOrganizationID()
  33756. case usagestatisticmonth.FieldAiResponse:
  33757. return m.AddedAiResponse()
  33758. case usagestatisticmonth.FieldSopRun:
  33759. return m.AddedSopRun()
  33760. case usagestatisticmonth.FieldTotalFriend:
  33761. return m.AddedTotalFriend()
  33762. case usagestatisticmonth.FieldTotalGroup:
  33763. return m.AddedTotalGroup()
  33764. case usagestatisticmonth.FieldAccountBalance:
  33765. return m.AddedAccountBalance()
  33766. case usagestatisticmonth.FieldConsumeToken:
  33767. return m.AddedConsumeToken()
  33768. case usagestatisticmonth.FieldActiveUser:
  33769. return m.AddedActiveUser()
  33770. case usagestatisticmonth.FieldNewUser:
  33771. return m.AddedNewUser()
  33772. }
  33773. return nil, false
  33774. }
  33775. // AddField adds the value to the field with the given name. It returns an error if
  33776. // the field is not defined in the schema, or if the type mismatched the field
  33777. // type.
  33778. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  33779. switch name {
  33780. case usagestatisticmonth.FieldStatus:
  33781. v, ok := value.(int8)
  33782. if !ok {
  33783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33784. }
  33785. m.AddStatus(v)
  33786. return nil
  33787. case usagestatisticmonth.FieldAddtime:
  33788. v, ok := value.(int64)
  33789. if !ok {
  33790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33791. }
  33792. m.AddAddtime(v)
  33793. return nil
  33794. case usagestatisticmonth.FieldType:
  33795. v, ok := value.(int)
  33796. if !ok {
  33797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33798. }
  33799. m.AddType(v)
  33800. return nil
  33801. case usagestatisticmonth.FieldOrganizationID:
  33802. v, ok := value.(int64)
  33803. if !ok {
  33804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33805. }
  33806. m.AddOrganizationID(v)
  33807. return nil
  33808. case usagestatisticmonth.FieldAiResponse:
  33809. v, ok := value.(int64)
  33810. if !ok {
  33811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33812. }
  33813. m.AddAiResponse(v)
  33814. return nil
  33815. case usagestatisticmonth.FieldSopRun:
  33816. v, ok := value.(int64)
  33817. if !ok {
  33818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33819. }
  33820. m.AddSopRun(v)
  33821. return nil
  33822. case usagestatisticmonth.FieldTotalFriend:
  33823. v, ok := value.(int64)
  33824. if !ok {
  33825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33826. }
  33827. m.AddTotalFriend(v)
  33828. return nil
  33829. case usagestatisticmonth.FieldTotalGroup:
  33830. v, ok := value.(int64)
  33831. if !ok {
  33832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33833. }
  33834. m.AddTotalGroup(v)
  33835. return nil
  33836. case usagestatisticmonth.FieldAccountBalance:
  33837. v, ok := value.(int64)
  33838. if !ok {
  33839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33840. }
  33841. m.AddAccountBalance(v)
  33842. return nil
  33843. case usagestatisticmonth.FieldConsumeToken:
  33844. v, ok := value.(int64)
  33845. if !ok {
  33846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33847. }
  33848. m.AddConsumeToken(v)
  33849. return nil
  33850. case usagestatisticmonth.FieldActiveUser:
  33851. v, ok := value.(int64)
  33852. if !ok {
  33853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33854. }
  33855. m.AddActiveUser(v)
  33856. return nil
  33857. case usagestatisticmonth.FieldNewUser:
  33858. v, ok := value.(int64)
  33859. if !ok {
  33860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33861. }
  33862. m.AddNewUser(v)
  33863. return nil
  33864. }
  33865. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  33866. }
  33867. // ClearedFields returns all nullable fields that were cleared during this
  33868. // mutation.
  33869. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  33870. var fields []string
  33871. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  33872. fields = append(fields, usagestatisticmonth.FieldStatus)
  33873. }
  33874. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  33875. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  33876. }
  33877. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  33878. fields = append(fields, usagestatisticmonth.FieldBotID)
  33879. }
  33880. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  33881. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33882. }
  33883. return fields
  33884. }
  33885. // FieldCleared returns a boolean indicating if a field with the given name was
  33886. // cleared in this mutation.
  33887. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  33888. _, ok := m.clearedFields[name]
  33889. return ok
  33890. }
  33891. // ClearField clears the value of the field with the given name. It returns an
  33892. // error if the field is not defined in the schema.
  33893. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  33894. switch name {
  33895. case usagestatisticmonth.FieldStatus:
  33896. m.ClearStatus()
  33897. return nil
  33898. case usagestatisticmonth.FieldDeletedAt:
  33899. m.ClearDeletedAt()
  33900. return nil
  33901. case usagestatisticmonth.FieldBotID:
  33902. m.ClearBotID()
  33903. return nil
  33904. case usagestatisticmonth.FieldOrganizationID:
  33905. m.ClearOrganizationID()
  33906. return nil
  33907. }
  33908. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  33909. }
  33910. // ResetField resets all changes in the mutation for the field with the given name.
  33911. // It returns an error if the field is not defined in the schema.
  33912. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  33913. switch name {
  33914. case usagestatisticmonth.FieldCreatedAt:
  33915. m.ResetCreatedAt()
  33916. return nil
  33917. case usagestatisticmonth.FieldUpdatedAt:
  33918. m.ResetUpdatedAt()
  33919. return nil
  33920. case usagestatisticmonth.FieldStatus:
  33921. m.ResetStatus()
  33922. return nil
  33923. case usagestatisticmonth.FieldDeletedAt:
  33924. m.ResetDeletedAt()
  33925. return nil
  33926. case usagestatisticmonth.FieldAddtime:
  33927. m.ResetAddtime()
  33928. return nil
  33929. case usagestatisticmonth.FieldType:
  33930. m.ResetType()
  33931. return nil
  33932. case usagestatisticmonth.FieldBotID:
  33933. m.ResetBotID()
  33934. return nil
  33935. case usagestatisticmonth.FieldOrganizationID:
  33936. m.ResetOrganizationID()
  33937. return nil
  33938. case usagestatisticmonth.FieldAiResponse:
  33939. m.ResetAiResponse()
  33940. return nil
  33941. case usagestatisticmonth.FieldSopRun:
  33942. m.ResetSopRun()
  33943. return nil
  33944. case usagestatisticmonth.FieldTotalFriend:
  33945. m.ResetTotalFriend()
  33946. return nil
  33947. case usagestatisticmonth.FieldTotalGroup:
  33948. m.ResetTotalGroup()
  33949. return nil
  33950. case usagestatisticmonth.FieldAccountBalance:
  33951. m.ResetAccountBalance()
  33952. return nil
  33953. case usagestatisticmonth.FieldConsumeToken:
  33954. m.ResetConsumeToken()
  33955. return nil
  33956. case usagestatisticmonth.FieldActiveUser:
  33957. m.ResetActiveUser()
  33958. return nil
  33959. case usagestatisticmonth.FieldNewUser:
  33960. m.ResetNewUser()
  33961. return nil
  33962. case usagestatisticmonth.FieldLabelDist:
  33963. m.ResetLabelDist()
  33964. return nil
  33965. }
  33966. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33967. }
  33968. // AddedEdges returns all edge names that were set/added in this mutation.
  33969. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  33970. edges := make([]string, 0, 0)
  33971. return edges
  33972. }
  33973. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33974. // name in this mutation.
  33975. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  33976. return nil
  33977. }
  33978. // RemovedEdges returns all edge names that were removed in this mutation.
  33979. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  33980. edges := make([]string, 0, 0)
  33981. return edges
  33982. }
  33983. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33984. // the given name in this mutation.
  33985. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  33986. return nil
  33987. }
  33988. // ClearedEdges returns all edge names that were cleared in this mutation.
  33989. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  33990. edges := make([]string, 0, 0)
  33991. return edges
  33992. }
  33993. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33994. // was cleared in this mutation.
  33995. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  33996. return false
  33997. }
  33998. // ClearEdge clears the value of the edge with the given name. It returns an error
  33999. // if that edge is not defined in the schema.
  34000. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  34001. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  34002. }
  34003. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34004. // It returns an error if the edge is not defined in the schema.
  34005. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  34006. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  34007. }
  34008. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  34009. type UsageTotalMutation struct {
  34010. config
  34011. op Op
  34012. typ string
  34013. id *uint64
  34014. created_at *time.Time
  34015. updated_at *time.Time
  34016. status *uint8
  34017. addstatus *int8
  34018. _type *int
  34019. add_type *int
  34020. bot_id *string
  34021. total_tokens *uint64
  34022. addtotal_tokens *int64
  34023. start_index *uint64
  34024. addstart_index *int64
  34025. end_index *uint64
  34026. addend_index *int64
  34027. organization_id *uint64
  34028. addorganization_id *int64
  34029. clearedFields map[string]struct{}
  34030. done bool
  34031. oldValue func(context.Context) (*UsageTotal, error)
  34032. predicates []predicate.UsageTotal
  34033. }
  34034. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  34035. // usagetotalOption allows management of the mutation configuration using functional options.
  34036. type usagetotalOption func(*UsageTotalMutation)
  34037. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  34038. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  34039. m := &UsageTotalMutation{
  34040. config: c,
  34041. op: op,
  34042. typ: TypeUsageTotal,
  34043. clearedFields: make(map[string]struct{}),
  34044. }
  34045. for _, opt := range opts {
  34046. opt(m)
  34047. }
  34048. return m
  34049. }
  34050. // withUsageTotalID sets the ID field of the mutation.
  34051. func withUsageTotalID(id uint64) usagetotalOption {
  34052. return func(m *UsageTotalMutation) {
  34053. var (
  34054. err error
  34055. once sync.Once
  34056. value *UsageTotal
  34057. )
  34058. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  34059. once.Do(func() {
  34060. if m.done {
  34061. err = errors.New("querying old values post mutation is not allowed")
  34062. } else {
  34063. value, err = m.Client().UsageTotal.Get(ctx, id)
  34064. }
  34065. })
  34066. return value, err
  34067. }
  34068. m.id = &id
  34069. }
  34070. }
  34071. // withUsageTotal sets the old UsageTotal of the mutation.
  34072. func withUsageTotal(node *UsageTotal) usagetotalOption {
  34073. return func(m *UsageTotalMutation) {
  34074. m.oldValue = func(context.Context) (*UsageTotal, error) {
  34075. return node, nil
  34076. }
  34077. m.id = &node.ID
  34078. }
  34079. }
  34080. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34081. // executed in a transaction (ent.Tx), a transactional client is returned.
  34082. func (m UsageTotalMutation) Client() *Client {
  34083. client := &Client{config: m.config}
  34084. client.init()
  34085. return client
  34086. }
  34087. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34088. // it returns an error otherwise.
  34089. func (m UsageTotalMutation) Tx() (*Tx, error) {
  34090. if _, ok := m.driver.(*txDriver); !ok {
  34091. return nil, errors.New("ent: mutation is not running in a transaction")
  34092. }
  34093. tx := &Tx{config: m.config}
  34094. tx.init()
  34095. return tx, nil
  34096. }
  34097. // SetID sets the value of the id field. Note that this
  34098. // operation is only accepted on creation of UsageTotal entities.
  34099. func (m *UsageTotalMutation) SetID(id uint64) {
  34100. m.id = &id
  34101. }
  34102. // ID returns the ID value in the mutation. Note that the ID is only available
  34103. // if it was provided to the builder or after it was returned from the database.
  34104. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  34105. if m.id == nil {
  34106. return
  34107. }
  34108. return *m.id, true
  34109. }
  34110. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34111. // That means, if the mutation is applied within a transaction with an isolation level such
  34112. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34113. // or updated by the mutation.
  34114. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  34115. switch {
  34116. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34117. id, exists := m.ID()
  34118. if exists {
  34119. return []uint64{id}, nil
  34120. }
  34121. fallthrough
  34122. case m.op.Is(OpUpdate | OpDelete):
  34123. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  34124. default:
  34125. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34126. }
  34127. }
  34128. // SetCreatedAt sets the "created_at" field.
  34129. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  34130. m.created_at = &t
  34131. }
  34132. // CreatedAt returns the value of the "created_at" field in the mutation.
  34133. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  34134. v := m.created_at
  34135. if v == nil {
  34136. return
  34137. }
  34138. return *v, true
  34139. }
  34140. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  34141. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34143. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34144. if !m.op.Is(OpUpdateOne) {
  34145. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34146. }
  34147. if m.id == nil || m.oldValue == nil {
  34148. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34149. }
  34150. oldValue, err := m.oldValue(ctx)
  34151. if err != nil {
  34152. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34153. }
  34154. return oldValue.CreatedAt, nil
  34155. }
  34156. // ResetCreatedAt resets all changes to the "created_at" field.
  34157. func (m *UsageTotalMutation) ResetCreatedAt() {
  34158. m.created_at = nil
  34159. }
  34160. // SetUpdatedAt sets the "updated_at" field.
  34161. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  34162. m.updated_at = &t
  34163. }
  34164. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34165. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  34166. v := m.updated_at
  34167. if v == nil {
  34168. return
  34169. }
  34170. return *v, true
  34171. }
  34172. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  34173. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34175. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34176. if !m.op.Is(OpUpdateOne) {
  34177. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34178. }
  34179. if m.id == nil || m.oldValue == nil {
  34180. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34181. }
  34182. oldValue, err := m.oldValue(ctx)
  34183. if err != nil {
  34184. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34185. }
  34186. return oldValue.UpdatedAt, nil
  34187. }
  34188. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34189. func (m *UsageTotalMutation) ResetUpdatedAt() {
  34190. m.updated_at = nil
  34191. }
  34192. // SetStatus sets the "status" field.
  34193. func (m *UsageTotalMutation) SetStatus(u uint8) {
  34194. m.status = &u
  34195. m.addstatus = nil
  34196. }
  34197. // Status returns the value of the "status" field in the mutation.
  34198. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  34199. v := m.status
  34200. if v == nil {
  34201. return
  34202. }
  34203. return *v, true
  34204. }
  34205. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  34206. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34208. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34209. if !m.op.Is(OpUpdateOne) {
  34210. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34211. }
  34212. if m.id == nil || m.oldValue == nil {
  34213. return v, errors.New("OldStatus requires an ID field in the mutation")
  34214. }
  34215. oldValue, err := m.oldValue(ctx)
  34216. if err != nil {
  34217. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34218. }
  34219. return oldValue.Status, nil
  34220. }
  34221. // AddStatus adds u to the "status" field.
  34222. func (m *UsageTotalMutation) AddStatus(u int8) {
  34223. if m.addstatus != nil {
  34224. *m.addstatus += u
  34225. } else {
  34226. m.addstatus = &u
  34227. }
  34228. }
  34229. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34230. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  34231. v := m.addstatus
  34232. if v == nil {
  34233. return
  34234. }
  34235. return *v, true
  34236. }
  34237. // ClearStatus clears the value of the "status" field.
  34238. func (m *UsageTotalMutation) ClearStatus() {
  34239. m.status = nil
  34240. m.addstatus = nil
  34241. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  34242. }
  34243. // StatusCleared returns if the "status" field was cleared in this mutation.
  34244. func (m *UsageTotalMutation) StatusCleared() bool {
  34245. _, ok := m.clearedFields[usagetotal.FieldStatus]
  34246. return ok
  34247. }
  34248. // ResetStatus resets all changes to the "status" field.
  34249. func (m *UsageTotalMutation) ResetStatus() {
  34250. m.status = nil
  34251. m.addstatus = nil
  34252. delete(m.clearedFields, usagetotal.FieldStatus)
  34253. }
  34254. // SetType sets the "type" field.
  34255. func (m *UsageTotalMutation) SetType(i int) {
  34256. m._type = &i
  34257. m.add_type = nil
  34258. }
  34259. // GetType returns the value of the "type" field in the mutation.
  34260. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  34261. v := m._type
  34262. if v == nil {
  34263. return
  34264. }
  34265. return *v, true
  34266. }
  34267. // OldType returns the old "type" field's value of the UsageTotal entity.
  34268. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34270. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  34271. if !m.op.Is(OpUpdateOne) {
  34272. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34273. }
  34274. if m.id == nil || m.oldValue == nil {
  34275. return v, errors.New("OldType requires an ID field in the mutation")
  34276. }
  34277. oldValue, err := m.oldValue(ctx)
  34278. if err != nil {
  34279. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34280. }
  34281. return oldValue.Type, nil
  34282. }
  34283. // AddType adds i to the "type" field.
  34284. func (m *UsageTotalMutation) AddType(i int) {
  34285. if m.add_type != nil {
  34286. *m.add_type += i
  34287. } else {
  34288. m.add_type = &i
  34289. }
  34290. }
  34291. // AddedType returns the value that was added to the "type" field in this mutation.
  34292. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  34293. v := m.add_type
  34294. if v == nil {
  34295. return
  34296. }
  34297. return *v, true
  34298. }
  34299. // ClearType clears the value of the "type" field.
  34300. func (m *UsageTotalMutation) ClearType() {
  34301. m._type = nil
  34302. m.add_type = nil
  34303. m.clearedFields[usagetotal.FieldType] = struct{}{}
  34304. }
  34305. // TypeCleared returns if the "type" field was cleared in this mutation.
  34306. func (m *UsageTotalMutation) TypeCleared() bool {
  34307. _, ok := m.clearedFields[usagetotal.FieldType]
  34308. return ok
  34309. }
  34310. // ResetType resets all changes to the "type" field.
  34311. func (m *UsageTotalMutation) ResetType() {
  34312. m._type = nil
  34313. m.add_type = nil
  34314. delete(m.clearedFields, usagetotal.FieldType)
  34315. }
  34316. // SetBotID sets the "bot_id" field.
  34317. func (m *UsageTotalMutation) SetBotID(s string) {
  34318. m.bot_id = &s
  34319. }
  34320. // BotID returns the value of the "bot_id" field in the mutation.
  34321. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  34322. v := m.bot_id
  34323. if v == nil {
  34324. return
  34325. }
  34326. return *v, true
  34327. }
  34328. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  34329. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34331. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  34332. if !m.op.Is(OpUpdateOne) {
  34333. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34334. }
  34335. if m.id == nil || m.oldValue == nil {
  34336. return v, errors.New("OldBotID requires an ID field in the mutation")
  34337. }
  34338. oldValue, err := m.oldValue(ctx)
  34339. if err != nil {
  34340. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34341. }
  34342. return oldValue.BotID, nil
  34343. }
  34344. // ResetBotID resets all changes to the "bot_id" field.
  34345. func (m *UsageTotalMutation) ResetBotID() {
  34346. m.bot_id = nil
  34347. }
  34348. // SetTotalTokens sets the "total_tokens" field.
  34349. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  34350. m.total_tokens = &u
  34351. m.addtotal_tokens = nil
  34352. }
  34353. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  34354. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  34355. v := m.total_tokens
  34356. if v == nil {
  34357. return
  34358. }
  34359. return *v, true
  34360. }
  34361. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  34362. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34364. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  34365. if !m.op.Is(OpUpdateOne) {
  34366. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  34367. }
  34368. if m.id == nil || m.oldValue == nil {
  34369. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  34370. }
  34371. oldValue, err := m.oldValue(ctx)
  34372. if err != nil {
  34373. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  34374. }
  34375. return oldValue.TotalTokens, nil
  34376. }
  34377. // AddTotalTokens adds u to the "total_tokens" field.
  34378. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  34379. if m.addtotal_tokens != nil {
  34380. *m.addtotal_tokens += u
  34381. } else {
  34382. m.addtotal_tokens = &u
  34383. }
  34384. }
  34385. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  34386. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  34387. v := m.addtotal_tokens
  34388. if v == nil {
  34389. return
  34390. }
  34391. return *v, true
  34392. }
  34393. // ClearTotalTokens clears the value of the "total_tokens" field.
  34394. func (m *UsageTotalMutation) ClearTotalTokens() {
  34395. m.total_tokens = nil
  34396. m.addtotal_tokens = nil
  34397. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  34398. }
  34399. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  34400. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  34401. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  34402. return ok
  34403. }
  34404. // ResetTotalTokens resets all changes to the "total_tokens" field.
  34405. func (m *UsageTotalMutation) ResetTotalTokens() {
  34406. m.total_tokens = nil
  34407. m.addtotal_tokens = nil
  34408. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  34409. }
  34410. // SetStartIndex sets the "start_index" field.
  34411. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  34412. m.start_index = &u
  34413. m.addstart_index = nil
  34414. }
  34415. // StartIndex returns the value of the "start_index" field in the mutation.
  34416. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  34417. v := m.start_index
  34418. if v == nil {
  34419. return
  34420. }
  34421. return *v, true
  34422. }
  34423. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  34424. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34426. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  34427. if !m.op.Is(OpUpdateOne) {
  34428. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  34429. }
  34430. if m.id == nil || m.oldValue == nil {
  34431. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  34432. }
  34433. oldValue, err := m.oldValue(ctx)
  34434. if err != nil {
  34435. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  34436. }
  34437. return oldValue.StartIndex, nil
  34438. }
  34439. // AddStartIndex adds u to the "start_index" field.
  34440. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  34441. if m.addstart_index != nil {
  34442. *m.addstart_index += u
  34443. } else {
  34444. m.addstart_index = &u
  34445. }
  34446. }
  34447. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  34448. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  34449. v := m.addstart_index
  34450. if v == nil {
  34451. return
  34452. }
  34453. return *v, true
  34454. }
  34455. // ClearStartIndex clears the value of the "start_index" field.
  34456. func (m *UsageTotalMutation) ClearStartIndex() {
  34457. m.start_index = nil
  34458. m.addstart_index = nil
  34459. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  34460. }
  34461. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  34462. func (m *UsageTotalMutation) StartIndexCleared() bool {
  34463. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  34464. return ok
  34465. }
  34466. // ResetStartIndex resets all changes to the "start_index" field.
  34467. func (m *UsageTotalMutation) ResetStartIndex() {
  34468. m.start_index = nil
  34469. m.addstart_index = nil
  34470. delete(m.clearedFields, usagetotal.FieldStartIndex)
  34471. }
  34472. // SetEndIndex sets the "end_index" field.
  34473. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  34474. m.end_index = &u
  34475. m.addend_index = nil
  34476. }
  34477. // EndIndex returns the value of the "end_index" field in the mutation.
  34478. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  34479. v := m.end_index
  34480. if v == nil {
  34481. return
  34482. }
  34483. return *v, true
  34484. }
  34485. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  34486. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34488. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  34489. if !m.op.Is(OpUpdateOne) {
  34490. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  34491. }
  34492. if m.id == nil || m.oldValue == nil {
  34493. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  34494. }
  34495. oldValue, err := m.oldValue(ctx)
  34496. if err != nil {
  34497. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  34498. }
  34499. return oldValue.EndIndex, nil
  34500. }
  34501. // AddEndIndex adds u to the "end_index" field.
  34502. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  34503. if m.addend_index != nil {
  34504. *m.addend_index += u
  34505. } else {
  34506. m.addend_index = &u
  34507. }
  34508. }
  34509. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  34510. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  34511. v := m.addend_index
  34512. if v == nil {
  34513. return
  34514. }
  34515. return *v, true
  34516. }
  34517. // ClearEndIndex clears the value of the "end_index" field.
  34518. func (m *UsageTotalMutation) ClearEndIndex() {
  34519. m.end_index = nil
  34520. m.addend_index = nil
  34521. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  34522. }
  34523. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  34524. func (m *UsageTotalMutation) EndIndexCleared() bool {
  34525. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  34526. return ok
  34527. }
  34528. // ResetEndIndex resets all changes to the "end_index" field.
  34529. func (m *UsageTotalMutation) ResetEndIndex() {
  34530. m.end_index = nil
  34531. m.addend_index = nil
  34532. delete(m.clearedFields, usagetotal.FieldEndIndex)
  34533. }
  34534. // SetOrganizationID sets the "organization_id" field.
  34535. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  34536. m.organization_id = &u
  34537. m.addorganization_id = nil
  34538. }
  34539. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34540. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  34541. v := m.organization_id
  34542. if v == nil {
  34543. return
  34544. }
  34545. return *v, true
  34546. }
  34547. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  34548. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34550. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34551. if !m.op.Is(OpUpdateOne) {
  34552. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34553. }
  34554. if m.id == nil || m.oldValue == nil {
  34555. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34556. }
  34557. oldValue, err := m.oldValue(ctx)
  34558. if err != nil {
  34559. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34560. }
  34561. return oldValue.OrganizationID, nil
  34562. }
  34563. // AddOrganizationID adds u to the "organization_id" field.
  34564. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  34565. if m.addorganization_id != nil {
  34566. *m.addorganization_id += u
  34567. } else {
  34568. m.addorganization_id = &u
  34569. }
  34570. }
  34571. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34572. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  34573. v := m.addorganization_id
  34574. if v == nil {
  34575. return
  34576. }
  34577. return *v, true
  34578. }
  34579. // ClearOrganizationID clears the value of the "organization_id" field.
  34580. func (m *UsageTotalMutation) ClearOrganizationID() {
  34581. m.organization_id = nil
  34582. m.addorganization_id = nil
  34583. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  34584. }
  34585. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34586. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  34587. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  34588. return ok
  34589. }
  34590. // ResetOrganizationID resets all changes to the "organization_id" field.
  34591. func (m *UsageTotalMutation) ResetOrganizationID() {
  34592. m.organization_id = nil
  34593. m.addorganization_id = nil
  34594. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  34595. }
  34596. // Where appends a list predicates to the UsageTotalMutation builder.
  34597. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  34598. m.predicates = append(m.predicates, ps...)
  34599. }
  34600. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  34601. // users can use type-assertion to append predicates that do not depend on any generated package.
  34602. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  34603. p := make([]predicate.UsageTotal, len(ps))
  34604. for i := range ps {
  34605. p[i] = ps[i]
  34606. }
  34607. m.Where(p...)
  34608. }
  34609. // Op returns the operation name.
  34610. func (m *UsageTotalMutation) Op() Op {
  34611. return m.op
  34612. }
  34613. // SetOp allows setting the mutation operation.
  34614. func (m *UsageTotalMutation) SetOp(op Op) {
  34615. m.op = op
  34616. }
  34617. // Type returns the node type of this mutation (UsageTotal).
  34618. func (m *UsageTotalMutation) Type() string {
  34619. return m.typ
  34620. }
  34621. // Fields returns all fields that were changed during this mutation. Note that in
  34622. // order to get all numeric fields that were incremented/decremented, call
  34623. // AddedFields().
  34624. func (m *UsageTotalMutation) Fields() []string {
  34625. fields := make([]string, 0, 9)
  34626. if m.created_at != nil {
  34627. fields = append(fields, usagetotal.FieldCreatedAt)
  34628. }
  34629. if m.updated_at != nil {
  34630. fields = append(fields, usagetotal.FieldUpdatedAt)
  34631. }
  34632. if m.status != nil {
  34633. fields = append(fields, usagetotal.FieldStatus)
  34634. }
  34635. if m._type != nil {
  34636. fields = append(fields, usagetotal.FieldType)
  34637. }
  34638. if m.bot_id != nil {
  34639. fields = append(fields, usagetotal.FieldBotID)
  34640. }
  34641. if m.total_tokens != nil {
  34642. fields = append(fields, usagetotal.FieldTotalTokens)
  34643. }
  34644. if m.start_index != nil {
  34645. fields = append(fields, usagetotal.FieldStartIndex)
  34646. }
  34647. if m.end_index != nil {
  34648. fields = append(fields, usagetotal.FieldEndIndex)
  34649. }
  34650. if m.organization_id != nil {
  34651. fields = append(fields, usagetotal.FieldOrganizationID)
  34652. }
  34653. return fields
  34654. }
  34655. // Field returns the value of a field with the given name. The second boolean
  34656. // return value indicates that this field was not set, or was not defined in the
  34657. // schema.
  34658. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  34659. switch name {
  34660. case usagetotal.FieldCreatedAt:
  34661. return m.CreatedAt()
  34662. case usagetotal.FieldUpdatedAt:
  34663. return m.UpdatedAt()
  34664. case usagetotal.FieldStatus:
  34665. return m.Status()
  34666. case usagetotal.FieldType:
  34667. return m.GetType()
  34668. case usagetotal.FieldBotID:
  34669. return m.BotID()
  34670. case usagetotal.FieldTotalTokens:
  34671. return m.TotalTokens()
  34672. case usagetotal.FieldStartIndex:
  34673. return m.StartIndex()
  34674. case usagetotal.FieldEndIndex:
  34675. return m.EndIndex()
  34676. case usagetotal.FieldOrganizationID:
  34677. return m.OrganizationID()
  34678. }
  34679. return nil, false
  34680. }
  34681. // OldField returns the old value of the field from the database. An error is
  34682. // returned if the mutation operation is not UpdateOne, or the query to the
  34683. // database failed.
  34684. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34685. switch name {
  34686. case usagetotal.FieldCreatedAt:
  34687. return m.OldCreatedAt(ctx)
  34688. case usagetotal.FieldUpdatedAt:
  34689. return m.OldUpdatedAt(ctx)
  34690. case usagetotal.FieldStatus:
  34691. return m.OldStatus(ctx)
  34692. case usagetotal.FieldType:
  34693. return m.OldType(ctx)
  34694. case usagetotal.FieldBotID:
  34695. return m.OldBotID(ctx)
  34696. case usagetotal.FieldTotalTokens:
  34697. return m.OldTotalTokens(ctx)
  34698. case usagetotal.FieldStartIndex:
  34699. return m.OldStartIndex(ctx)
  34700. case usagetotal.FieldEndIndex:
  34701. return m.OldEndIndex(ctx)
  34702. case usagetotal.FieldOrganizationID:
  34703. return m.OldOrganizationID(ctx)
  34704. }
  34705. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  34706. }
  34707. // SetField sets the value of a field with the given name. It returns an error if
  34708. // the field is not defined in the schema, or if the type mismatched the field
  34709. // type.
  34710. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  34711. switch name {
  34712. case usagetotal.FieldCreatedAt:
  34713. v, ok := value.(time.Time)
  34714. if !ok {
  34715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34716. }
  34717. m.SetCreatedAt(v)
  34718. return nil
  34719. case usagetotal.FieldUpdatedAt:
  34720. v, ok := value.(time.Time)
  34721. if !ok {
  34722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34723. }
  34724. m.SetUpdatedAt(v)
  34725. return nil
  34726. case usagetotal.FieldStatus:
  34727. v, ok := value.(uint8)
  34728. if !ok {
  34729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34730. }
  34731. m.SetStatus(v)
  34732. return nil
  34733. case usagetotal.FieldType:
  34734. v, ok := value.(int)
  34735. if !ok {
  34736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34737. }
  34738. m.SetType(v)
  34739. return nil
  34740. case usagetotal.FieldBotID:
  34741. v, ok := value.(string)
  34742. if !ok {
  34743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34744. }
  34745. m.SetBotID(v)
  34746. return nil
  34747. case usagetotal.FieldTotalTokens:
  34748. v, ok := value.(uint64)
  34749. if !ok {
  34750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34751. }
  34752. m.SetTotalTokens(v)
  34753. return nil
  34754. case usagetotal.FieldStartIndex:
  34755. v, ok := value.(uint64)
  34756. if !ok {
  34757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34758. }
  34759. m.SetStartIndex(v)
  34760. return nil
  34761. case usagetotal.FieldEndIndex:
  34762. v, ok := value.(uint64)
  34763. if !ok {
  34764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34765. }
  34766. m.SetEndIndex(v)
  34767. return nil
  34768. case usagetotal.FieldOrganizationID:
  34769. v, ok := value.(uint64)
  34770. if !ok {
  34771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34772. }
  34773. m.SetOrganizationID(v)
  34774. return nil
  34775. }
  34776. return fmt.Errorf("unknown UsageTotal field %s", name)
  34777. }
  34778. // AddedFields returns all numeric fields that were incremented/decremented during
  34779. // this mutation.
  34780. func (m *UsageTotalMutation) AddedFields() []string {
  34781. var fields []string
  34782. if m.addstatus != nil {
  34783. fields = append(fields, usagetotal.FieldStatus)
  34784. }
  34785. if m.add_type != nil {
  34786. fields = append(fields, usagetotal.FieldType)
  34787. }
  34788. if m.addtotal_tokens != nil {
  34789. fields = append(fields, usagetotal.FieldTotalTokens)
  34790. }
  34791. if m.addstart_index != nil {
  34792. fields = append(fields, usagetotal.FieldStartIndex)
  34793. }
  34794. if m.addend_index != nil {
  34795. fields = append(fields, usagetotal.FieldEndIndex)
  34796. }
  34797. if m.addorganization_id != nil {
  34798. fields = append(fields, usagetotal.FieldOrganizationID)
  34799. }
  34800. return fields
  34801. }
  34802. // AddedField returns the numeric value that was incremented/decremented on a field
  34803. // with the given name. The second boolean return value indicates that this field
  34804. // was not set, or was not defined in the schema.
  34805. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  34806. switch name {
  34807. case usagetotal.FieldStatus:
  34808. return m.AddedStatus()
  34809. case usagetotal.FieldType:
  34810. return m.AddedType()
  34811. case usagetotal.FieldTotalTokens:
  34812. return m.AddedTotalTokens()
  34813. case usagetotal.FieldStartIndex:
  34814. return m.AddedStartIndex()
  34815. case usagetotal.FieldEndIndex:
  34816. return m.AddedEndIndex()
  34817. case usagetotal.FieldOrganizationID:
  34818. return m.AddedOrganizationID()
  34819. }
  34820. return nil, false
  34821. }
  34822. // AddField adds the value to the field with the given name. It returns an error if
  34823. // the field is not defined in the schema, or if the type mismatched the field
  34824. // type.
  34825. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  34826. switch name {
  34827. case usagetotal.FieldStatus:
  34828. v, ok := value.(int8)
  34829. if !ok {
  34830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34831. }
  34832. m.AddStatus(v)
  34833. return nil
  34834. case usagetotal.FieldType:
  34835. v, ok := value.(int)
  34836. if !ok {
  34837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34838. }
  34839. m.AddType(v)
  34840. return nil
  34841. case usagetotal.FieldTotalTokens:
  34842. v, ok := value.(int64)
  34843. if !ok {
  34844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34845. }
  34846. m.AddTotalTokens(v)
  34847. return nil
  34848. case usagetotal.FieldStartIndex:
  34849. v, ok := value.(int64)
  34850. if !ok {
  34851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34852. }
  34853. m.AddStartIndex(v)
  34854. return nil
  34855. case usagetotal.FieldEndIndex:
  34856. v, ok := value.(int64)
  34857. if !ok {
  34858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34859. }
  34860. m.AddEndIndex(v)
  34861. return nil
  34862. case usagetotal.FieldOrganizationID:
  34863. v, ok := value.(int64)
  34864. if !ok {
  34865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34866. }
  34867. m.AddOrganizationID(v)
  34868. return nil
  34869. }
  34870. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  34871. }
  34872. // ClearedFields returns all nullable fields that were cleared during this
  34873. // mutation.
  34874. func (m *UsageTotalMutation) ClearedFields() []string {
  34875. var fields []string
  34876. if m.FieldCleared(usagetotal.FieldStatus) {
  34877. fields = append(fields, usagetotal.FieldStatus)
  34878. }
  34879. if m.FieldCleared(usagetotal.FieldType) {
  34880. fields = append(fields, usagetotal.FieldType)
  34881. }
  34882. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  34883. fields = append(fields, usagetotal.FieldTotalTokens)
  34884. }
  34885. if m.FieldCleared(usagetotal.FieldStartIndex) {
  34886. fields = append(fields, usagetotal.FieldStartIndex)
  34887. }
  34888. if m.FieldCleared(usagetotal.FieldEndIndex) {
  34889. fields = append(fields, usagetotal.FieldEndIndex)
  34890. }
  34891. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  34892. fields = append(fields, usagetotal.FieldOrganizationID)
  34893. }
  34894. return fields
  34895. }
  34896. // FieldCleared returns a boolean indicating if a field with the given name was
  34897. // cleared in this mutation.
  34898. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  34899. _, ok := m.clearedFields[name]
  34900. return ok
  34901. }
  34902. // ClearField clears the value of the field with the given name. It returns an
  34903. // error if the field is not defined in the schema.
  34904. func (m *UsageTotalMutation) ClearField(name string) error {
  34905. switch name {
  34906. case usagetotal.FieldStatus:
  34907. m.ClearStatus()
  34908. return nil
  34909. case usagetotal.FieldType:
  34910. m.ClearType()
  34911. return nil
  34912. case usagetotal.FieldTotalTokens:
  34913. m.ClearTotalTokens()
  34914. return nil
  34915. case usagetotal.FieldStartIndex:
  34916. m.ClearStartIndex()
  34917. return nil
  34918. case usagetotal.FieldEndIndex:
  34919. m.ClearEndIndex()
  34920. return nil
  34921. case usagetotal.FieldOrganizationID:
  34922. m.ClearOrganizationID()
  34923. return nil
  34924. }
  34925. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  34926. }
  34927. // ResetField resets all changes in the mutation for the field with the given name.
  34928. // It returns an error if the field is not defined in the schema.
  34929. func (m *UsageTotalMutation) ResetField(name string) error {
  34930. switch name {
  34931. case usagetotal.FieldCreatedAt:
  34932. m.ResetCreatedAt()
  34933. return nil
  34934. case usagetotal.FieldUpdatedAt:
  34935. m.ResetUpdatedAt()
  34936. return nil
  34937. case usagetotal.FieldStatus:
  34938. m.ResetStatus()
  34939. return nil
  34940. case usagetotal.FieldType:
  34941. m.ResetType()
  34942. return nil
  34943. case usagetotal.FieldBotID:
  34944. m.ResetBotID()
  34945. return nil
  34946. case usagetotal.FieldTotalTokens:
  34947. m.ResetTotalTokens()
  34948. return nil
  34949. case usagetotal.FieldStartIndex:
  34950. m.ResetStartIndex()
  34951. return nil
  34952. case usagetotal.FieldEndIndex:
  34953. m.ResetEndIndex()
  34954. return nil
  34955. case usagetotal.FieldOrganizationID:
  34956. m.ResetOrganizationID()
  34957. return nil
  34958. }
  34959. return fmt.Errorf("unknown UsageTotal field %s", name)
  34960. }
  34961. // AddedEdges returns all edge names that were set/added in this mutation.
  34962. func (m *UsageTotalMutation) AddedEdges() []string {
  34963. edges := make([]string, 0, 0)
  34964. return edges
  34965. }
  34966. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34967. // name in this mutation.
  34968. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  34969. return nil
  34970. }
  34971. // RemovedEdges returns all edge names that were removed in this mutation.
  34972. func (m *UsageTotalMutation) RemovedEdges() []string {
  34973. edges := make([]string, 0, 0)
  34974. return edges
  34975. }
  34976. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34977. // the given name in this mutation.
  34978. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  34979. return nil
  34980. }
  34981. // ClearedEdges returns all edge names that were cleared in this mutation.
  34982. func (m *UsageTotalMutation) ClearedEdges() []string {
  34983. edges := make([]string, 0, 0)
  34984. return edges
  34985. }
  34986. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34987. // was cleared in this mutation.
  34988. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  34989. return false
  34990. }
  34991. // ClearEdge clears the value of the edge with the given name. It returns an error
  34992. // if that edge is not defined in the schema.
  34993. func (m *UsageTotalMutation) ClearEdge(name string) error {
  34994. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  34995. }
  34996. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34997. // It returns an error if the edge is not defined in the schema.
  34998. func (m *UsageTotalMutation) ResetEdge(name string) error {
  34999. return fmt.Errorf("unknown UsageTotal edge %s", name)
  35000. }
  35001. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  35002. type WhatsappMutation struct {
  35003. config
  35004. op Op
  35005. typ string
  35006. id *uint64
  35007. created_at *time.Time
  35008. updated_at *time.Time
  35009. status *uint8
  35010. addstatus *int8
  35011. deleted_at *time.Time
  35012. wa_id *string
  35013. wa_name *string
  35014. callback *string
  35015. account *string
  35016. cc *string
  35017. phone *string
  35018. cc_phone *string
  35019. phone_name *string
  35020. phone_status *int8
  35021. addphone_status *int8
  35022. organization_id *uint64
  35023. addorganization_id *int64
  35024. api_base *string
  35025. api_key *string
  35026. allow_list *[]string
  35027. appendallow_list []string
  35028. group_allow_list *[]string
  35029. appendgroup_allow_list []string
  35030. block_list *[]string
  35031. appendblock_list []string
  35032. group_block_list *[]string
  35033. appendgroup_block_list []string
  35034. clearedFields map[string]struct{}
  35035. agent *uint64
  35036. clearedagent bool
  35037. done bool
  35038. oldValue func(context.Context) (*Whatsapp, error)
  35039. predicates []predicate.Whatsapp
  35040. }
  35041. var _ ent.Mutation = (*WhatsappMutation)(nil)
  35042. // whatsappOption allows management of the mutation configuration using functional options.
  35043. type whatsappOption func(*WhatsappMutation)
  35044. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  35045. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  35046. m := &WhatsappMutation{
  35047. config: c,
  35048. op: op,
  35049. typ: TypeWhatsapp,
  35050. clearedFields: make(map[string]struct{}),
  35051. }
  35052. for _, opt := range opts {
  35053. opt(m)
  35054. }
  35055. return m
  35056. }
  35057. // withWhatsappID sets the ID field of the mutation.
  35058. func withWhatsappID(id uint64) whatsappOption {
  35059. return func(m *WhatsappMutation) {
  35060. var (
  35061. err error
  35062. once sync.Once
  35063. value *Whatsapp
  35064. )
  35065. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  35066. once.Do(func() {
  35067. if m.done {
  35068. err = errors.New("querying old values post mutation is not allowed")
  35069. } else {
  35070. value, err = m.Client().Whatsapp.Get(ctx, id)
  35071. }
  35072. })
  35073. return value, err
  35074. }
  35075. m.id = &id
  35076. }
  35077. }
  35078. // withWhatsapp sets the old Whatsapp of the mutation.
  35079. func withWhatsapp(node *Whatsapp) whatsappOption {
  35080. return func(m *WhatsappMutation) {
  35081. m.oldValue = func(context.Context) (*Whatsapp, error) {
  35082. return node, nil
  35083. }
  35084. m.id = &node.ID
  35085. }
  35086. }
  35087. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35088. // executed in a transaction (ent.Tx), a transactional client is returned.
  35089. func (m WhatsappMutation) Client() *Client {
  35090. client := &Client{config: m.config}
  35091. client.init()
  35092. return client
  35093. }
  35094. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35095. // it returns an error otherwise.
  35096. func (m WhatsappMutation) Tx() (*Tx, error) {
  35097. if _, ok := m.driver.(*txDriver); !ok {
  35098. return nil, errors.New("ent: mutation is not running in a transaction")
  35099. }
  35100. tx := &Tx{config: m.config}
  35101. tx.init()
  35102. return tx, nil
  35103. }
  35104. // SetID sets the value of the id field. Note that this
  35105. // operation is only accepted on creation of Whatsapp entities.
  35106. func (m *WhatsappMutation) SetID(id uint64) {
  35107. m.id = &id
  35108. }
  35109. // ID returns the ID value in the mutation. Note that the ID is only available
  35110. // if it was provided to the builder or after it was returned from the database.
  35111. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  35112. if m.id == nil {
  35113. return
  35114. }
  35115. return *m.id, true
  35116. }
  35117. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35118. // That means, if the mutation is applied within a transaction with an isolation level such
  35119. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35120. // or updated by the mutation.
  35121. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  35122. switch {
  35123. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35124. id, exists := m.ID()
  35125. if exists {
  35126. return []uint64{id}, nil
  35127. }
  35128. fallthrough
  35129. case m.op.Is(OpUpdate | OpDelete):
  35130. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  35131. default:
  35132. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35133. }
  35134. }
  35135. // SetCreatedAt sets the "created_at" field.
  35136. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  35137. m.created_at = &t
  35138. }
  35139. // CreatedAt returns the value of the "created_at" field in the mutation.
  35140. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  35141. v := m.created_at
  35142. if v == nil {
  35143. return
  35144. }
  35145. return *v, true
  35146. }
  35147. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  35148. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35150. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35151. if !m.op.Is(OpUpdateOne) {
  35152. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35153. }
  35154. if m.id == nil || m.oldValue == nil {
  35155. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35156. }
  35157. oldValue, err := m.oldValue(ctx)
  35158. if err != nil {
  35159. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35160. }
  35161. return oldValue.CreatedAt, nil
  35162. }
  35163. // ResetCreatedAt resets all changes to the "created_at" field.
  35164. func (m *WhatsappMutation) ResetCreatedAt() {
  35165. m.created_at = nil
  35166. }
  35167. // SetUpdatedAt sets the "updated_at" field.
  35168. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  35169. m.updated_at = &t
  35170. }
  35171. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35172. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  35173. v := m.updated_at
  35174. if v == nil {
  35175. return
  35176. }
  35177. return *v, true
  35178. }
  35179. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  35180. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35182. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35183. if !m.op.Is(OpUpdateOne) {
  35184. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35185. }
  35186. if m.id == nil || m.oldValue == nil {
  35187. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35188. }
  35189. oldValue, err := m.oldValue(ctx)
  35190. if err != nil {
  35191. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35192. }
  35193. return oldValue.UpdatedAt, nil
  35194. }
  35195. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35196. func (m *WhatsappMutation) ResetUpdatedAt() {
  35197. m.updated_at = nil
  35198. }
  35199. // SetStatus sets the "status" field.
  35200. func (m *WhatsappMutation) SetStatus(u uint8) {
  35201. m.status = &u
  35202. m.addstatus = nil
  35203. }
  35204. // Status returns the value of the "status" field in the mutation.
  35205. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  35206. v := m.status
  35207. if v == nil {
  35208. return
  35209. }
  35210. return *v, true
  35211. }
  35212. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  35213. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35215. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35216. if !m.op.Is(OpUpdateOne) {
  35217. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35218. }
  35219. if m.id == nil || m.oldValue == nil {
  35220. return v, errors.New("OldStatus requires an ID field in the mutation")
  35221. }
  35222. oldValue, err := m.oldValue(ctx)
  35223. if err != nil {
  35224. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35225. }
  35226. return oldValue.Status, nil
  35227. }
  35228. // AddStatus adds u to the "status" field.
  35229. func (m *WhatsappMutation) AddStatus(u int8) {
  35230. if m.addstatus != nil {
  35231. *m.addstatus += u
  35232. } else {
  35233. m.addstatus = &u
  35234. }
  35235. }
  35236. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35237. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  35238. v := m.addstatus
  35239. if v == nil {
  35240. return
  35241. }
  35242. return *v, true
  35243. }
  35244. // ClearStatus clears the value of the "status" field.
  35245. func (m *WhatsappMutation) ClearStatus() {
  35246. m.status = nil
  35247. m.addstatus = nil
  35248. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  35249. }
  35250. // StatusCleared returns if the "status" field was cleared in this mutation.
  35251. func (m *WhatsappMutation) StatusCleared() bool {
  35252. _, ok := m.clearedFields[whatsapp.FieldStatus]
  35253. return ok
  35254. }
  35255. // ResetStatus resets all changes to the "status" field.
  35256. func (m *WhatsappMutation) ResetStatus() {
  35257. m.status = nil
  35258. m.addstatus = nil
  35259. delete(m.clearedFields, whatsapp.FieldStatus)
  35260. }
  35261. // SetDeletedAt sets the "deleted_at" field.
  35262. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  35263. m.deleted_at = &t
  35264. }
  35265. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35266. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  35267. v := m.deleted_at
  35268. if v == nil {
  35269. return
  35270. }
  35271. return *v, true
  35272. }
  35273. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  35274. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35276. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35277. if !m.op.Is(OpUpdateOne) {
  35278. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35279. }
  35280. if m.id == nil || m.oldValue == nil {
  35281. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35282. }
  35283. oldValue, err := m.oldValue(ctx)
  35284. if err != nil {
  35285. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35286. }
  35287. return oldValue.DeletedAt, nil
  35288. }
  35289. // ClearDeletedAt clears the value of the "deleted_at" field.
  35290. func (m *WhatsappMutation) ClearDeletedAt() {
  35291. m.deleted_at = nil
  35292. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  35293. }
  35294. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35295. func (m *WhatsappMutation) DeletedAtCleared() bool {
  35296. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  35297. return ok
  35298. }
  35299. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35300. func (m *WhatsappMutation) ResetDeletedAt() {
  35301. m.deleted_at = nil
  35302. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  35303. }
  35304. // SetWaID sets the "wa_id" field.
  35305. func (m *WhatsappMutation) SetWaID(s string) {
  35306. m.wa_id = &s
  35307. }
  35308. // WaID returns the value of the "wa_id" field in the mutation.
  35309. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  35310. v := m.wa_id
  35311. if v == nil {
  35312. return
  35313. }
  35314. return *v, true
  35315. }
  35316. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  35317. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35319. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  35320. if !m.op.Is(OpUpdateOne) {
  35321. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  35322. }
  35323. if m.id == nil || m.oldValue == nil {
  35324. return v, errors.New("OldWaID requires an ID field in the mutation")
  35325. }
  35326. oldValue, err := m.oldValue(ctx)
  35327. if err != nil {
  35328. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  35329. }
  35330. return oldValue.WaID, nil
  35331. }
  35332. // ClearWaID clears the value of the "wa_id" field.
  35333. func (m *WhatsappMutation) ClearWaID() {
  35334. m.wa_id = nil
  35335. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  35336. }
  35337. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  35338. func (m *WhatsappMutation) WaIDCleared() bool {
  35339. _, ok := m.clearedFields[whatsapp.FieldWaID]
  35340. return ok
  35341. }
  35342. // ResetWaID resets all changes to the "wa_id" field.
  35343. func (m *WhatsappMutation) ResetWaID() {
  35344. m.wa_id = nil
  35345. delete(m.clearedFields, whatsapp.FieldWaID)
  35346. }
  35347. // SetWaName sets the "wa_name" field.
  35348. func (m *WhatsappMutation) SetWaName(s string) {
  35349. m.wa_name = &s
  35350. }
  35351. // WaName returns the value of the "wa_name" field in the mutation.
  35352. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  35353. v := m.wa_name
  35354. if v == nil {
  35355. return
  35356. }
  35357. return *v, true
  35358. }
  35359. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  35360. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35362. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  35363. if !m.op.Is(OpUpdateOne) {
  35364. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  35365. }
  35366. if m.id == nil || m.oldValue == nil {
  35367. return v, errors.New("OldWaName requires an ID field in the mutation")
  35368. }
  35369. oldValue, err := m.oldValue(ctx)
  35370. if err != nil {
  35371. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  35372. }
  35373. return oldValue.WaName, nil
  35374. }
  35375. // ClearWaName clears the value of the "wa_name" field.
  35376. func (m *WhatsappMutation) ClearWaName() {
  35377. m.wa_name = nil
  35378. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  35379. }
  35380. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  35381. func (m *WhatsappMutation) WaNameCleared() bool {
  35382. _, ok := m.clearedFields[whatsapp.FieldWaName]
  35383. return ok
  35384. }
  35385. // ResetWaName resets all changes to the "wa_name" field.
  35386. func (m *WhatsappMutation) ResetWaName() {
  35387. m.wa_name = nil
  35388. delete(m.clearedFields, whatsapp.FieldWaName)
  35389. }
  35390. // SetCallback sets the "callback" field.
  35391. func (m *WhatsappMutation) SetCallback(s string) {
  35392. m.callback = &s
  35393. }
  35394. // Callback returns the value of the "callback" field in the mutation.
  35395. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  35396. v := m.callback
  35397. if v == nil {
  35398. return
  35399. }
  35400. return *v, true
  35401. }
  35402. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  35403. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35405. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  35406. if !m.op.Is(OpUpdateOne) {
  35407. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  35408. }
  35409. if m.id == nil || m.oldValue == nil {
  35410. return v, errors.New("OldCallback requires an ID field in the mutation")
  35411. }
  35412. oldValue, err := m.oldValue(ctx)
  35413. if err != nil {
  35414. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  35415. }
  35416. return oldValue.Callback, nil
  35417. }
  35418. // ClearCallback clears the value of the "callback" field.
  35419. func (m *WhatsappMutation) ClearCallback() {
  35420. m.callback = nil
  35421. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  35422. }
  35423. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  35424. func (m *WhatsappMutation) CallbackCleared() bool {
  35425. _, ok := m.clearedFields[whatsapp.FieldCallback]
  35426. return ok
  35427. }
  35428. // ResetCallback resets all changes to the "callback" field.
  35429. func (m *WhatsappMutation) ResetCallback() {
  35430. m.callback = nil
  35431. delete(m.clearedFields, whatsapp.FieldCallback)
  35432. }
  35433. // SetAgentID sets the "agent_id" field.
  35434. func (m *WhatsappMutation) SetAgentID(u uint64) {
  35435. m.agent = &u
  35436. }
  35437. // AgentID returns the value of the "agent_id" field in the mutation.
  35438. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  35439. v := m.agent
  35440. if v == nil {
  35441. return
  35442. }
  35443. return *v, true
  35444. }
  35445. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  35446. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35448. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  35449. if !m.op.Is(OpUpdateOne) {
  35450. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  35451. }
  35452. if m.id == nil || m.oldValue == nil {
  35453. return v, errors.New("OldAgentID requires an ID field in the mutation")
  35454. }
  35455. oldValue, err := m.oldValue(ctx)
  35456. if err != nil {
  35457. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  35458. }
  35459. return oldValue.AgentID, nil
  35460. }
  35461. // ResetAgentID resets all changes to the "agent_id" field.
  35462. func (m *WhatsappMutation) ResetAgentID() {
  35463. m.agent = nil
  35464. }
  35465. // SetAccount sets the "account" field.
  35466. func (m *WhatsappMutation) SetAccount(s string) {
  35467. m.account = &s
  35468. }
  35469. // Account returns the value of the "account" field in the mutation.
  35470. func (m *WhatsappMutation) Account() (r string, exists bool) {
  35471. v := m.account
  35472. if v == nil {
  35473. return
  35474. }
  35475. return *v, true
  35476. }
  35477. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  35478. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35480. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  35481. if !m.op.Is(OpUpdateOne) {
  35482. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  35483. }
  35484. if m.id == nil || m.oldValue == nil {
  35485. return v, errors.New("OldAccount requires an ID field in the mutation")
  35486. }
  35487. oldValue, err := m.oldValue(ctx)
  35488. if err != nil {
  35489. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  35490. }
  35491. return oldValue.Account, nil
  35492. }
  35493. // ClearAccount clears the value of the "account" field.
  35494. func (m *WhatsappMutation) ClearAccount() {
  35495. m.account = nil
  35496. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  35497. }
  35498. // AccountCleared returns if the "account" field was cleared in this mutation.
  35499. func (m *WhatsappMutation) AccountCleared() bool {
  35500. _, ok := m.clearedFields[whatsapp.FieldAccount]
  35501. return ok
  35502. }
  35503. // ResetAccount resets all changes to the "account" field.
  35504. func (m *WhatsappMutation) ResetAccount() {
  35505. m.account = nil
  35506. delete(m.clearedFields, whatsapp.FieldAccount)
  35507. }
  35508. // SetCc sets the "cc" field.
  35509. func (m *WhatsappMutation) SetCc(s string) {
  35510. m.cc = &s
  35511. }
  35512. // Cc returns the value of the "cc" field in the mutation.
  35513. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  35514. v := m.cc
  35515. if v == nil {
  35516. return
  35517. }
  35518. return *v, true
  35519. }
  35520. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  35521. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35523. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  35524. if !m.op.Is(OpUpdateOne) {
  35525. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  35526. }
  35527. if m.id == nil || m.oldValue == nil {
  35528. return v, errors.New("OldCc requires an ID field in the mutation")
  35529. }
  35530. oldValue, err := m.oldValue(ctx)
  35531. if err != nil {
  35532. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  35533. }
  35534. return oldValue.Cc, nil
  35535. }
  35536. // ResetCc resets all changes to the "cc" field.
  35537. func (m *WhatsappMutation) ResetCc() {
  35538. m.cc = nil
  35539. }
  35540. // SetPhone sets the "phone" field.
  35541. func (m *WhatsappMutation) SetPhone(s string) {
  35542. m.phone = &s
  35543. }
  35544. // Phone returns the value of the "phone" field in the mutation.
  35545. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  35546. v := m.phone
  35547. if v == nil {
  35548. return
  35549. }
  35550. return *v, true
  35551. }
  35552. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  35553. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35555. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  35556. if !m.op.Is(OpUpdateOne) {
  35557. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  35558. }
  35559. if m.id == nil || m.oldValue == nil {
  35560. return v, errors.New("OldPhone requires an ID field in the mutation")
  35561. }
  35562. oldValue, err := m.oldValue(ctx)
  35563. if err != nil {
  35564. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  35565. }
  35566. return oldValue.Phone, nil
  35567. }
  35568. // ResetPhone resets all changes to the "phone" field.
  35569. func (m *WhatsappMutation) ResetPhone() {
  35570. m.phone = nil
  35571. }
  35572. // SetCcPhone sets the "cc_phone" field.
  35573. func (m *WhatsappMutation) SetCcPhone(s string) {
  35574. m.cc_phone = &s
  35575. }
  35576. // CcPhone returns the value of the "cc_phone" field in the mutation.
  35577. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  35578. v := m.cc_phone
  35579. if v == nil {
  35580. return
  35581. }
  35582. return *v, true
  35583. }
  35584. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  35585. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35587. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  35588. if !m.op.Is(OpUpdateOne) {
  35589. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  35590. }
  35591. if m.id == nil || m.oldValue == nil {
  35592. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  35593. }
  35594. oldValue, err := m.oldValue(ctx)
  35595. if err != nil {
  35596. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  35597. }
  35598. return oldValue.CcPhone, nil
  35599. }
  35600. // ResetCcPhone resets all changes to the "cc_phone" field.
  35601. func (m *WhatsappMutation) ResetCcPhone() {
  35602. m.cc_phone = nil
  35603. }
  35604. // SetPhoneName sets the "phone_name" field.
  35605. func (m *WhatsappMutation) SetPhoneName(s string) {
  35606. m.phone_name = &s
  35607. }
  35608. // PhoneName returns the value of the "phone_name" field in the mutation.
  35609. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  35610. v := m.phone_name
  35611. if v == nil {
  35612. return
  35613. }
  35614. return *v, true
  35615. }
  35616. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  35617. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35619. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  35620. if !m.op.Is(OpUpdateOne) {
  35621. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  35622. }
  35623. if m.id == nil || m.oldValue == nil {
  35624. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  35625. }
  35626. oldValue, err := m.oldValue(ctx)
  35627. if err != nil {
  35628. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  35629. }
  35630. return oldValue.PhoneName, nil
  35631. }
  35632. // ResetPhoneName resets all changes to the "phone_name" field.
  35633. func (m *WhatsappMutation) ResetPhoneName() {
  35634. m.phone_name = nil
  35635. }
  35636. // SetPhoneStatus sets the "phone_status" field.
  35637. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  35638. m.phone_status = &i
  35639. m.addphone_status = nil
  35640. }
  35641. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  35642. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  35643. v := m.phone_status
  35644. if v == nil {
  35645. return
  35646. }
  35647. return *v, true
  35648. }
  35649. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  35650. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35652. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  35653. if !m.op.Is(OpUpdateOne) {
  35654. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  35655. }
  35656. if m.id == nil || m.oldValue == nil {
  35657. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  35658. }
  35659. oldValue, err := m.oldValue(ctx)
  35660. if err != nil {
  35661. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  35662. }
  35663. return oldValue.PhoneStatus, nil
  35664. }
  35665. // AddPhoneStatus adds i to the "phone_status" field.
  35666. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  35667. if m.addphone_status != nil {
  35668. *m.addphone_status += i
  35669. } else {
  35670. m.addphone_status = &i
  35671. }
  35672. }
  35673. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  35674. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  35675. v := m.addphone_status
  35676. if v == nil {
  35677. return
  35678. }
  35679. return *v, true
  35680. }
  35681. // ResetPhoneStatus resets all changes to the "phone_status" field.
  35682. func (m *WhatsappMutation) ResetPhoneStatus() {
  35683. m.phone_status = nil
  35684. m.addphone_status = nil
  35685. }
  35686. // SetOrganizationID sets the "organization_id" field.
  35687. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  35688. m.organization_id = &u
  35689. m.addorganization_id = nil
  35690. }
  35691. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35692. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  35693. v := m.organization_id
  35694. if v == nil {
  35695. return
  35696. }
  35697. return *v, true
  35698. }
  35699. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  35700. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35702. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35703. if !m.op.Is(OpUpdateOne) {
  35704. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35705. }
  35706. if m.id == nil || m.oldValue == nil {
  35707. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35708. }
  35709. oldValue, err := m.oldValue(ctx)
  35710. if err != nil {
  35711. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35712. }
  35713. return oldValue.OrganizationID, nil
  35714. }
  35715. // AddOrganizationID adds u to the "organization_id" field.
  35716. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  35717. if m.addorganization_id != nil {
  35718. *m.addorganization_id += u
  35719. } else {
  35720. m.addorganization_id = &u
  35721. }
  35722. }
  35723. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35724. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  35725. v := m.addorganization_id
  35726. if v == nil {
  35727. return
  35728. }
  35729. return *v, true
  35730. }
  35731. // ClearOrganizationID clears the value of the "organization_id" field.
  35732. func (m *WhatsappMutation) ClearOrganizationID() {
  35733. m.organization_id = nil
  35734. m.addorganization_id = nil
  35735. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  35736. }
  35737. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35738. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  35739. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  35740. return ok
  35741. }
  35742. // ResetOrganizationID resets all changes to the "organization_id" field.
  35743. func (m *WhatsappMutation) ResetOrganizationID() {
  35744. m.organization_id = nil
  35745. m.addorganization_id = nil
  35746. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  35747. }
  35748. // SetAPIBase sets the "api_base" field.
  35749. func (m *WhatsappMutation) SetAPIBase(s string) {
  35750. m.api_base = &s
  35751. }
  35752. // APIBase returns the value of the "api_base" field in the mutation.
  35753. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  35754. v := m.api_base
  35755. if v == nil {
  35756. return
  35757. }
  35758. return *v, true
  35759. }
  35760. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  35761. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35763. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  35764. if !m.op.Is(OpUpdateOne) {
  35765. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  35766. }
  35767. if m.id == nil || m.oldValue == nil {
  35768. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  35769. }
  35770. oldValue, err := m.oldValue(ctx)
  35771. if err != nil {
  35772. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  35773. }
  35774. return oldValue.APIBase, nil
  35775. }
  35776. // ClearAPIBase clears the value of the "api_base" field.
  35777. func (m *WhatsappMutation) ClearAPIBase() {
  35778. m.api_base = nil
  35779. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  35780. }
  35781. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  35782. func (m *WhatsappMutation) APIBaseCleared() bool {
  35783. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  35784. return ok
  35785. }
  35786. // ResetAPIBase resets all changes to the "api_base" field.
  35787. func (m *WhatsappMutation) ResetAPIBase() {
  35788. m.api_base = nil
  35789. delete(m.clearedFields, whatsapp.FieldAPIBase)
  35790. }
  35791. // SetAPIKey sets the "api_key" field.
  35792. func (m *WhatsappMutation) SetAPIKey(s string) {
  35793. m.api_key = &s
  35794. }
  35795. // APIKey returns the value of the "api_key" field in the mutation.
  35796. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  35797. v := m.api_key
  35798. if v == nil {
  35799. return
  35800. }
  35801. return *v, true
  35802. }
  35803. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  35804. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35806. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  35807. if !m.op.Is(OpUpdateOne) {
  35808. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  35809. }
  35810. if m.id == nil || m.oldValue == nil {
  35811. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  35812. }
  35813. oldValue, err := m.oldValue(ctx)
  35814. if err != nil {
  35815. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  35816. }
  35817. return oldValue.APIKey, nil
  35818. }
  35819. // ClearAPIKey clears the value of the "api_key" field.
  35820. func (m *WhatsappMutation) ClearAPIKey() {
  35821. m.api_key = nil
  35822. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  35823. }
  35824. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  35825. func (m *WhatsappMutation) APIKeyCleared() bool {
  35826. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  35827. return ok
  35828. }
  35829. // ResetAPIKey resets all changes to the "api_key" field.
  35830. func (m *WhatsappMutation) ResetAPIKey() {
  35831. m.api_key = nil
  35832. delete(m.clearedFields, whatsapp.FieldAPIKey)
  35833. }
  35834. // SetAllowList sets the "allow_list" field.
  35835. func (m *WhatsappMutation) SetAllowList(s []string) {
  35836. m.allow_list = &s
  35837. m.appendallow_list = nil
  35838. }
  35839. // AllowList returns the value of the "allow_list" field in the mutation.
  35840. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  35841. v := m.allow_list
  35842. if v == nil {
  35843. return
  35844. }
  35845. return *v, true
  35846. }
  35847. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  35848. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35850. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  35851. if !m.op.Is(OpUpdateOne) {
  35852. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  35853. }
  35854. if m.id == nil || m.oldValue == nil {
  35855. return v, errors.New("OldAllowList requires an ID field in the mutation")
  35856. }
  35857. oldValue, err := m.oldValue(ctx)
  35858. if err != nil {
  35859. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  35860. }
  35861. return oldValue.AllowList, nil
  35862. }
  35863. // AppendAllowList adds s to the "allow_list" field.
  35864. func (m *WhatsappMutation) AppendAllowList(s []string) {
  35865. m.appendallow_list = append(m.appendallow_list, s...)
  35866. }
  35867. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  35868. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  35869. if len(m.appendallow_list) == 0 {
  35870. return nil, false
  35871. }
  35872. return m.appendallow_list, true
  35873. }
  35874. // ClearAllowList clears the value of the "allow_list" field.
  35875. func (m *WhatsappMutation) ClearAllowList() {
  35876. m.allow_list = nil
  35877. m.appendallow_list = nil
  35878. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  35879. }
  35880. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  35881. func (m *WhatsappMutation) AllowListCleared() bool {
  35882. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  35883. return ok
  35884. }
  35885. // ResetAllowList resets all changes to the "allow_list" field.
  35886. func (m *WhatsappMutation) ResetAllowList() {
  35887. m.allow_list = nil
  35888. m.appendallow_list = nil
  35889. delete(m.clearedFields, whatsapp.FieldAllowList)
  35890. }
  35891. // SetGroupAllowList sets the "group_allow_list" field.
  35892. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  35893. m.group_allow_list = &s
  35894. m.appendgroup_allow_list = nil
  35895. }
  35896. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  35897. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  35898. v := m.group_allow_list
  35899. if v == nil {
  35900. return
  35901. }
  35902. return *v, true
  35903. }
  35904. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  35905. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35907. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  35908. if !m.op.Is(OpUpdateOne) {
  35909. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  35910. }
  35911. if m.id == nil || m.oldValue == nil {
  35912. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  35913. }
  35914. oldValue, err := m.oldValue(ctx)
  35915. if err != nil {
  35916. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  35917. }
  35918. return oldValue.GroupAllowList, nil
  35919. }
  35920. // AppendGroupAllowList adds s to the "group_allow_list" field.
  35921. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  35922. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  35923. }
  35924. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  35925. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  35926. if len(m.appendgroup_allow_list) == 0 {
  35927. return nil, false
  35928. }
  35929. return m.appendgroup_allow_list, true
  35930. }
  35931. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  35932. func (m *WhatsappMutation) ClearGroupAllowList() {
  35933. m.group_allow_list = nil
  35934. m.appendgroup_allow_list = nil
  35935. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  35936. }
  35937. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  35938. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  35939. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  35940. return ok
  35941. }
  35942. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  35943. func (m *WhatsappMutation) ResetGroupAllowList() {
  35944. m.group_allow_list = nil
  35945. m.appendgroup_allow_list = nil
  35946. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  35947. }
  35948. // SetBlockList sets the "block_list" field.
  35949. func (m *WhatsappMutation) SetBlockList(s []string) {
  35950. m.block_list = &s
  35951. m.appendblock_list = nil
  35952. }
  35953. // BlockList returns the value of the "block_list" field in the mutation.
  35954. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  35955. v := m.block_list
  35956. if v == nil {
  35957. return
  35958. }
  35959. return *v, true
  35960. }
  35961. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  35962. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35964. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  35965. if !m.op.Is(OpUpdateOne) {
  35966. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  35967. }
  35968. if m.id == nil || m.oldValue == nil {
  35969. return v, errors.New("OldBlockList requires an ID field in the mutation")
  35970. }
  35971. oldValue, err := m.oldValue(ctx)
  35972. if err != nil {
  35973. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  35974. }
  35975. return oldValue.BlockList, nil
  35976. }
  35977. // AppendBlockList adds s to the "block_list" field.
  35978. func (m *WhatsappMutation) AppendBlockList(s []string) {
  35979. m.appendblock_list = append(m.appendblock_list, s...)
  35980. }
  35981. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  35982. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  35983. if len(m.appendblock_list) == 0 {
  35984. return nil, false
  35985. }
  35986. return m.appendblock_list, true
  35987. }
  35988. // ClearBlockList clears the value of the "block_list" field.
  35989. func (m *WhatsappMutation) ClearBlockList() {
  35990. m.block_list = nil
  35991. m.appendblock_list = nil
  35992. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  35993. }
  35994. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  35995. func (m *WhatsappMutation) BlockListCleared() bool {
  35996. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  35997. return ok
  35998. }
  35999. // ResetBlockList resets all changes to the "block_list" field.
  36000. func (m *WhatsappMutation) ResetBlockList() {
  36001. m.block_list = nil
  36002. m.appendblock_list = nil
  36003. delete(m.clearedFields, whatsapp.FieldBlockList)
  36004. }
  36005. // SetGroupBlockList sets the "group_block_list" field.
  36006. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  36007. m.group_block_list = &s
  36008. m.appendgroup_block_list = nil
  36009. }
  36010. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  36011. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  36012. v := m.group_block_list
  36013. if v == nil {
  36014. return
  36015. }
  36016. return *v, true
  36017. }
  36018. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  36019. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36021. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  36022. if !m.op.Is(OpUpdateOne) {
  36023. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  36024. }
  36025. if m.id == nil || m.oldValue == nil {
  36026. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  36027. }
  36028. oldValue, err := m.oldValue(ctx)
  36029. if err != nil {
  36030. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  36031. }
  36032. return oldValue.GroupBlockList, nil
  36033. }
  36034. // AppendGroupBlockList adds s to the "group_block_list" field.
  36035. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  36036. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  36037. }
  36038. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  36039. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  36040. if len(m.appendgroup_block_list) == 0 {
  36041. return nil, false
  36042. }
  36043. return m.appendgroup_block_list, true
  36044. }
  36045. // ClearGroupBlockList clears the value of the "group_block_list" field.
  36046. func (m *WhatsappMutation) ClearGroupBlockList() {
  36047. m.group_block_list = nil
  36048. m.appendgroup_block_list = nil
  36049. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  36050. }
  36051. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  36052. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  36053. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  36054. return ok
  36055. }
  36056. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  36057. func (m *WhatsappMutation) ResetGroupBlockList() {
  36058. m.group_block_list = nil
  36059. m.appendgroup_block_list = nil
  36060. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  36061. }
  36062. // ClearAgent clears the "agent" edge to the Agent entity.
  36063. func (m *WhatsappMutation) ClearAgent() {
  36064. m.clearedagent = true
  36065. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  36066. }
  36067. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  36068. func (m *WhatsappMutation) AgentCleared() bool {
  36069. return m.clearedagent
  36070. }
  36071. // AgentIDs returns the "agent" edge IDs in the mutation.
  36072. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  36073. // AgentID instead. It exists only for internal usage by the builders.
  36074. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  36075. if id := m.agent; id != nil {
  36076. ids = append(ids, *id)
  36077. }
  36078. return
  36079. }
  36080. // ResetAgent resets all changes to the "agent" edge.
  36081. func (m *WhatsappMutation) ResetAgent() {
  36082. m.agent = nil
  36083. m.clearedagent = false
  36084. }
  36085. // Where appends a list predicates to the WhatsappMutation builder.
  36086. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  36087. m.predicates = append(m.predicates, ps...)
  36088. }
  36089. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  36090. // users can use type-assertion to append predicates that do not depend on any generated package.
  36091. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  36092. p := make([]predicate.Whatsapp, len(ps))
  36093. for i := range ps {
  36094. p[i] = ps[i]
  36095. }
  36096. m.Where(p...)
  36097. }
  36098. // Op returns the operation name.
  36099. func (m *WhatsappMutation) Op() Op {
  36100. return m.op
  36101. }
  36102. // SetOp allows setting the mutation operation.
  36103. func (m *WhatsappMutation) SetOp(op Op) {
  36104. m.op = op
  36105. }
  36106. // Type returns the node type of this mutation (Whatsapp).
  36107. func (m *WhatsappMutation) Type() string {
  36108. return m.typ
  36109. }
  36110. // Fields returns all fields that were changed during this mutation. Note that in
  36111. // order to get all numeric fields that were incremented/decremented, call
  36112. // AddedFields().
  36113. func (m *WhatsappMutation) Fields() []string {
  36114. fields := make([]string, 0, 21)
  36115. if m.created_at != nil {
  36116. fields = append(fields, whatsapp.FieldCreatedAt)
  36117. }
  36118. if m.updated_at != nil {
  36119. fields = append(fields, whatsapp.FieldUpdatedAt)
  36120. }
  36121. if m.status != nil {
  36122. fields = append(fields, whatsapp.FieldStatus)
  36123. }
  36124. if m.deleted_at != nil {
  36125. fields = append(fields, whatsapp.FieldDeletedAt)
  36126. }
  36127. if m.wa_id != nil {
  36128. fields = append(fields, whatsapp.FieldWaID)
  36129. }
  36130. if m.wa_name != nil {
  36131. fields = append(fields, whatsapp.FieldWaName)
  36132. }
  36133. if m.callback != nil {
  36134. fields = append(fields, whatsapp.FieldCallback)
  36135. }
  36136. if m.agent != nil {
  36137. fields = append(fields, whatsapp.FieldAgentID)
  36138. }
  36139. if m.account != nil {
  36140. fields = append(fields, whatsapp.FieldAccount)
  36141. }
  36142. if m.cc != nil {
  36143. fields = append(fields, whatsapp.FieldCc)
  36144. }
  36145. if m.phone != nil {
  36146. fields = append(fields, whatsapp.FieldPhone)
  36147. }
  36148. if m.cc_phone != nil {
  36149. fields = append(fields, whatsapp.FieldCcPhone)
  36150. }
  36151. if m.phone_name != nil {
  36152. fields = append(fields, whatsapp.FieldPhoneName)
  36153. }
  36154. if m.phone_status != nil {
  36155. fields = append(fields, whatsapp.FieldPhoneStatus)
  36156. }
  36157. if m.organization_id != nil {
  36158. fields = append(fields, whatsapp.FieldOrganizationID)
  36159. }
  36160. if m.api_base != nil {
  36161. fields = append(fields, whatsapp.FieldAPIBase)
  36162. }
  36163. if m.api_key != nil {
  36164. fields = append(fields, whatsapp.FieldAPIKey)
  36165. }
  36166. if m.allow_list != nil {
  36167. fields = append(fields, whatsapp.FieldAllowList)
  36168. }
  36169. if m.group_allow_list != nil {
  36170. fields = append(fields, whatsapp.FieldGroupAllowList)
  36171. }
  36172. if m.block_list != nil {
  36173. fields = append(fields, whatsapp.FieldBlockList)
  36174. }
  36175. if m.group_block_list != nil {
  36176. fields = append(fields, whatsapp.FieldGroupBlockList)
  36177. }
  36178. return fields
  36179. }
  36180. // Field returns the value of a field with the given name. The second boolean
  36181. // return value indicates that this field was not set, or was not defined in the
  36182. // schema.
  36183. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  36184. switch name {
  36185. case whatsapp.FieldCreatedAt:
  36186. return m.CreatedAt()
  36187. case whatsapp.FieldUpdatedAt:
  36188. return m.UpdatedAt()
  36189. case whatsapp.FieldStatus:
  36190. return m.Status()
  36191. case whatsapp.FieldDeletedAt:
  36192. return m.DeletedAt()
  36193. case whatsapp.FieldWaID:
  36194. return m.WaID()
  36195. case whatsapp.FieldWaName:
  36196. return m.WaName()
  36197. case whatsapp.FieldCallback:
  36198. return m.Callback()
  36199. case whatsapp.FieldAgentID:
  36200. return m.AgentID()
  36201. case whatsapp.FieldAccount:
  36202. return m.Account()
  36203. case whatsapp.FieldCc:
  36204. return m.Cc()
  36205. case whatsapp.FieldPhone:
  36206. return m.Phone()
  36207. case whatsapp.FieldCcPhone:
  36208. return m.CcPhone()
  36209. case whatsapp.FieldPhoneName:
  36210. return m.PhoneName()
  36211. case whatsapp.FieldPhoneStatus:
  36212. return m.PhoneStatus()
  36213. case whatsapp.FieldOrganizationID:
  36214. return m.OrganizationID()
  36215. case whatsapp.FieldAPIBase:
  36216. return m.APIBase()
  36217. case whatsapp.FieldAPIKey:
  36218. return m.APIKey()
  36219. case whatsapp.FieldAllowList:
  36220. return m.AllowList()
  36221. case whatsapp.FieldGroupAllowList:
  36222. return m.GroupAllowList()
  36223. case whatsapp.FieldBlockList:
  36224. return m.BlockList()
  36225. case whatsapp.FieldGroupBlockList:
  36226. return m.GroupBlockList()
  36227. }
  36228. return nil, false
  36229. }
  36230. // OldField returns the old value of the field from the database. An error is
  36231. // returned if the mutation operation is not UpdateOne, or the query to the
  36232. // database failed.
  36233. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36234. switch name {
  36235. case whatsapp.FieldCreatedAt:
  36236. return m.OldCreatedAt(ctx)
  36237. case whatsapp.FieldUpdatedAt:
  36238. return m.OldUpdatedAt(ctx)
  36239. case whatsapp.FieldStatus:
  36240. return m.OldStatus(ctx)
  36241. case whatsapp.FieldDeletedAt:
  36242. return m.OldDeletedAt(ctx)
  36243. case whatsapp.FieldWaID:
  36244. return m.OldWaID(ctx)
  36245. case whatsapp.FieldWaName:
  36246. return m.OldWaName(ctx)
  36247. case whatsapp.FieldCallback:
  36248. return m.OldCallback(ctx)
  36249. case whatsapp.FieldAgentID:
  36250. return m.OldAgentID(ctx)
  36251. case whatsapp.FieldAccount:
  36252. return m.OldAccount(ctx)
  36253. case whatsapp.FieldCc:
  36254. return m.OldCc(ctx)
  36255. case whatsapp.FieldPhone:
  36256. return m.OldPhone(ctx)
  36257. case whatsapp.FieldCcPhone:
  36258. return m.OldCcPhone(ctx)
  36259. case whatsapp.FieldPhoneName:
  36260. return m.OldPhoneName(ctx)
  36261. case whatsapp.FieldPhoneStatus:
  36262. return m.OldPhoneStatus(ctx)
  36263. case whatsapp.FieldOrganizationID:
  36264. return m.OldOrganizationID(ctx)
  36265. case whatsapp.FieldAPIBase:
  36266. return m.OldAPIBase(ctx)
  36267. case whatsapp.FieldAPIKey:
  36268. return m.OldAPIKey(ctx)
  36269. case whatsapp.FieldAllowList:
  36270. return m.OldAllowList(ctx)
  36271. case whatsapp.FieldGroupAllowList:
  36272. return m.OldGroupAllowList(ctx)
  36273. case whatsapp.FieldBlockList:
  36274. return m.OldBlockList(ctx)
  36275. case whatsapp.FieldGroupBlockList:
  36276. return m.OldGroupBlockList(ctx)
  36277. }
  36278. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  36279. }
  36280. // SetField sets the value of a field with the given name. It returns an error if
  36281. // the field is not defined in the schema, or if the type mismatched the field
  36282. // type.
  36283. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  36284. switch name {
  36285. case whatsapp.FieldCreatedAt:
  36286. v, ok := value.(time.Time)
  36287. if !ok {
  36288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36289. }
  36290. m.SetCreatedAt(v)
  36291. return nil
  36292. case whatsapp.FieldUpdatedAt:
  36293. v, ok := value.(time.Time)
  36294. if !ok {
  36295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36296. }
  36297. m.SetUpdatedAt(v)
  36298. return nil
  36299. case whatsapp.FieldStatus:
  36300. v, ok := value.(uint8)
  36301. if !ok {
  36302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36303. }
  36304. m.SetStatus(v)
  36305. return nil
  36306. case whatsapp.FieldDeletedAt:
  36307. v, ok := value.(time.Time)
  36308. if !ok {
  36309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36310. }
  36311. m.SetDeletedAt(v)
  36312. return nil
  36313. case whatsapp.FieldWaID:
  36314. v, ok := value.(string)
  36315. if !ok {
  36316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36317. }
  36318. m.SetWaID(v)
  36319. return nil
  36320. case whatsapp.FieldWaName:
  36321. v, ok := value.(string)
  36322. if !ok {
  36323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36324. }
  36325. m.SetWaName(v)
  36326. return nil
  36327. case whatsapp.FieldCallback:
  36328. v, ok := value.(string)
  36329. if !ok {
  36330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36331. }
  36332. m.SetCallback(v)
  36333. return nil
  36334. case whatsapp.FieldAgentID:
  36335. v, ok := value.(uint64)
  36336. if !ok {
  36337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36338. }
  36339. m.SetAgentID(v)
  36340. return nil
  36341. case whatsapp.FieldAccount:
  36342. v, ok := value.(string)
  36343. if !ok {
  36344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36345. }
  36346. m.SetAccount(v)
  36347. return nil
  36348. case whatsapp.FieldCc:
  36349. v, ok := value.(string)
  36350. if !ok {
  36351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36352. }
  36353. m.SetCc(v)
  36354. return nil
  36355. case whatsapp.FieldPhone:
  36356. v, ok := value.(string)
  36357. if !ok {
  36358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36359. }
  36360. m.SetPhone(v)
  36361. return nil
  36362. case whatsapp.FieldCcPhone:
  36363. v, ok := value.(string)
  36364. if !ok {
  36365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36366. }
  36367. m.SetCcPhone(v)
  36368. return nil
  36369. case whatsapp.FieldPhoneName:
  36370. v, ok := value.(string)
  36371. if !ok {
  36372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36373. }
  36374. m.SetPhoneName(v)
  36375. return nil
  36376. case whatsapp.FieldPhoneStatus:
  36377. v, ok := value.(int8)
  36378. if !ok {
  36379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36380. }
  36381. m.SetPhoneStatus(v)
  36382. return nil
  36383. case whatsapp.FieldOrganizationID:
  36384. v, ok := value.(uint64)
  36385. if !ok {
  36386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36387. }
  36388. m.SetOrganizationID(v)
  36389. return nil
  36390. case whatsapp.FieldAPIBase:
  36391. v, ok := value.(string)
  36392. if !ok {
  36393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36394. }
  36395. m.SetAPIBase(v)
  36396. return nil
  36397. case whatsapp.FieldAPIKey:
  36398. v, ok := value.(string)
  36399. if !ok {
  36400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36401. }
  36402. m.SetAPIKey(v)
  36403. return nil
  36404. case whatsapp.FieldAllowList:
  36405. v, ok := value.([]string)
  36406. if !ok {
  36407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36408. }
  36409. m.SetAllowList(v)
  36410. return nil
  36411. case whatsapp.FieldGroupAllowList:
  36412. v, ok := value.([]string)
  36413. if !ok {
  36414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36415. }
  36416. m.SetGroupAllowList(v)
  36417. return nil
  36418. case whatsapp.FieldBlockList:
  36419. v, ok := value.([]string)
  36420. if !ok {
  36421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36422. }
  36423. m.SetBlockList(v)
  36424. return nil
  36425. case whatsapp.FieldGroupBlockList:
  36426. v, ok := value.([]string)
  36427. if !ok {
  36428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36429. }
  36430. m.SetGroupBlockList(v)
  36431. return nil
  36432. }
  36433. return fmt.Errorf("unknown Whatsapp field %s", name)
  36434. }
  36435. // AddedFields returns all numeric fields that were incremented/decremented during
  36436. // this mutation.
  36437. func (m *WhatsappMutation) AddedFields() []string {
  36438. var fields []string
  36439. if m.addstatus != nil {
  36440. fields = append(fields, whatsapp.FieldStatus)
  36441. }
  36442. if m.addphone_status != nil {
  36443. fields = append(fields, whatsapp.FieldPhoneStatus)
  36444. }
  36445. if m.addorganization_id != nil {
  36446. fields = append(fields, whatsapp.FieldOrganizationID)
  36447. }
  36448. return fields
  36449. }
  36450. // AddedField returns the numeric value that was incremented/decremented on a field
  36451. // with the given name. The second boolean return value indicates that this field
  36452. // was not set, or was not defined in the schema.
  36453. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  36454. switch name {
  36455. case whatsapp.FieldStatus:
  36456. return m.AddedStatus()
  36457. case whatsapp.FieldPhoneStatus:
  36458. return m.AddedPhoneStatus()
  36459. case whatsapp.FieldOrganizationID:
  36460. return m.AddedOrganizationID()
  36461. }
  36462. return nil, false
  36463. }
  36464. // AddField adds the value to the field with the given name. It returns an error if
  36465. // the field is not defined in the schema, or if the type mismatched the field
  36466. // type.
  36467. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  36468. switch name {
  36469. case whatsapp.FieldStatus:
  36470. v, ok := value.(int8)
  36471. if !ok {
  36472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36473. }
  36474. m.AddStatus(v)
  36475. return nil
  36476. case whatsapp.FieldPhoneStatus:
  36477. v, ok := value.(int8)
  36478. if !ok {
  36479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36480. }
  36481. m.AddPhoneStatus(v)
  36482. return nil
  36483. case whatsapp.FieldOrganizationID:
  36484. v, ok := value.(int64)
  36485. if !ok {
  36486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36487. }
  36488. m.AddOrganizationID(v)
  36489. return nil
  36490. }
  36491. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  36492. }
  36493. // ClearedFields returns all nullable fields that were cleared during this
  36494. // mutation.
  36495. func (m *WhatsappMutation) ClearedFields() []string {
  36496. var fields []string
  36497. if m.FieldCleared(whatsapp.FieldStatus) {
  36498. fields = append(fields, whatsapp.FieldStatus)
  36499. }
  36500. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  36501. fields = append(fields, whatsapp.FieldDeletedAt)
  36502. }
  36503. if m.FieldCleared(whatsapp.FieldWaID) {
  36504. fields = append(fields, whatsapp.FieldWaID)
  36505. }
  36506. if m.FieldCleared(whatsapp.FieldWaName) {
  36507. fields = append(fields, whatsapp.FieldWaName)
  36508. }
  36509. if m.FieldCleared(whatsapp.FieldCallback) {
  36510. fields = append(fields, whatsapp.FieldCallback)
  36511. }
  36512. if m.FieldCleared(whatsapp.FieldAccount) {
  36513. fields = append(fields, whatsapp.FieldAccount)
  36514. }
  36515. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  36516. fields = append(fields, whatsapp.FieldOrganizationID)
  36517. }
  36518. if m.FieldCleared(whatsapp.FieldAPIBase) {
  36519. fields = append(fields, whatsapp.FieldAPIBase)
  36520. }
  36521. if m.FieldCleared(whatsapp.FieldAPIKey) {
  36522. fields = append(fields, whatsapp.FieldAPIKey)
  36523. }
  36524. if m.FieldCleared(whatsapp.FieldAllowList) {
  36525. fields = append(fields, whatsapp.FieldAllowList)
  36526. }
  36527. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  36528. fields = append(fields, whatsapp.FieldGroupAllowList)
  36529. }
  36530. if m.FieldCleared(whatsapp.FieldBlockList) {
  36531. fields = append(fields, whatsapp.FieldBlockList)
  36532. }
  36533. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  36534. fields = append(fields, whatsapp.FieldGroupBlockList)
  36535. }
  36536. return fields
  36537. }
  36538. // FieldCleared returns a boolean indicating if a field with the given name was
  36539. // cleared in this mutation.
  36540. func (m *WhatsappMutation) FieldCleared(name string) bool {
  36541. _, ok := m.clearedFields[name]
  36542. return ok
  36543. }
  36544. // ClearField clears the value of the field with the given name. It returns an
  36545. // error if the field is not defined in the schema.
  36546. func (m *WhatsappMutation) ClearField(name string) error {
  36547. switch name {
  36548. case whatsapp.FieldStatus:
  36549. m.ClearStatus()
  36550. return nil
  36551. case whatsapp.FieldDeletedAt:
  36552. m.ClearDeletedAt()
  36553. return nil
  36554. case whatsapp.FieldWaID:
  36555. m.ClearWaID()
  36556. return nil
  36557. case whatsapp.FieldWaName:
  36558. m.ClearWaName()
  36559. return nil
  36560. case whatsapp.FieldCallback:
  36561. m.ClearCallback()
  36562. return nil
  36563. case whatsapp.FieldAccount:
  36564. m.ClearAccount()
  36565. return nil
  36566. case whatsapp.FieldOrganizationID:
  36567. m.ClearOrganizationID()
  36568. return nil
  36569. case whatsapp.FieldAPIBase:
  36570. m.ClearAPIBase()
  36571. return nil
  36572. case whatsapp.FieldAPIKey:
  36573. m.ClearAPIKey()
  36574. return nil
  36575. case whatsapp.FieldAllowList:
  36576. m.ClearAllowList()
  36577. return nil
  36578. case whatsapp.FieldGroupAllowList:
  36579. m.ClearGroupAllowList()
  36580. return nil
  36581. case whatsapp.FieldBlockList:
  36582. m.ClearBlockList()
  36583. return nil
  36584. case whatsapp.FieldGroupBlockList:
  36585. m.ClearGroupBlockList()
  36586. return nil
  36587. }
  36588. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  36589. }
  36590. // ResetField resets all changes in the mutation for the field with the given name.
  36591. // It returns an error if the field is not defined in the schema.
  36592. func (m *WhatsappMutation) ResetField(name string) error {
  36593. switch name {
  36594. case whatsapp.FieldCreatedAt:
  36595. m.ResetCreatedAt()
  36596. return nil
  36597. case whatsapp.FieldUpdatedAt:
  36598. m.ResetUpdatedAt()
  36599. return nil
  36600. case whatsapp.FieldStatus:
  36601. m.ResetStatus()
  36602. return nil
  36603. case whatsapp.FieldDeletedAt:
  36604. m.ResetDeletedAt()
  36605. return nil
  36606. case whatsapp.FieldWaID:
  36607. m.ResetWaID()
  36608. return nil
  36609. case whatsapp.FieldWaName:
  36610. m.ResetWaName()
  36611. return nil
  36612. case whatsapp.FieldCallback:
  36613. m.ResetCallback()
  36614. return nil
  36615. case whatsapp.FieldAgentID:
  36616. m.ResetAgentID()
  36617. return nil
  36618. case whatsapp.FieldAccount:
  36619. m.ResetAccount()
  36620. return nil
  36621. case whatsapp.FieldCc:
  36622. m.ResetCc()
  36623. return nil
  36624. case whatsapp.FieldPhone:
  36625. m.ResetPhone()
  36626. return nil
  36627. case whatsapp.FieldCcPhone:
  36628. m.ResetCcPhone()
  36629. return nil
  36630. case whatsapp.FieldPhoneName:
  36631. m.ResetPhoneName()
  36632. return nil
  36633. case whatsapp.FieldPhoneStatus:
  36634. m.ResetPhoneStatus()
  36635. return nil
  36636. case whatsapp.FieldOrganizationID:
  36637. m.ResetOrganizationID()
  36638. return nil
  36639. case whatsapp.FieldAPIBase:
  36640. m.ResetAPIBase()
  36641. return nil
  36642. case whatsapp.FieldAPIKey:
  36643. m.ResetAPIKey()
  36644. return nil
  36645. case whatsapp.FieldAllowList:
  36646. m.ResetAllowList()
  36647. return nil
  36648. case whatsapp.FieldGroupAllowList:
  36649. m.ResetGroupAllowList()
  36650. return nil
  36651. case whatsapp.FieldBlockList:
  36652. m.ResetBlockList()
  36653. return nil
  36654. case whatsapp.FieldGroupBlockList:
  36655. m.ResetGroupBlockList()
  36656. return nil
  36657. }
  36658. return fmt.Errorf("unknown Whatsapp field %s", name)
  36659. }
  36660. // AddedEdges returns all edge names that were set/added in this mutation.
  36661. func (m *WhatsappMutation) AddedEdges() []string {
  36662. edges := make([]string, 0, 1)
  36663. if m.agent != nil {
  36664. edges = append(edges, whatsapp.EdgeAgent)
  36665. }
  36666. return edges
  36667. }
  36668. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36669. // name in this mutation.
  36670. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  36671. switch name {
  36672. case whatsapp.EdgeAgent:
  36673. if id := m.agent; id != nil {
  36674. return []ent.Value{*id}
  36675. }
  36676. }
  36677. return nil
  36678. }
  36679. // RemovedEdges returns all edge names that were removed in this mutation.
  36680. func (m *WhatsappMutation) RemovedEdges() []string {
  36681. edges := make([]string, 0, 1)
  36682. return edges
  36683. }
  36684. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36685. // the given name in this mutation.
  36686. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  36687. return nil
  36688. }
  36689. // ClearedEdges returns all edge names that were cleared in this mutation.
  36690. func (m *WhatsappMutation) ClearedEdges() []string {
  36691. edges := make([]string, 0, 1)
  36692. if m.clearedagent {
  36693. edges = append(edges, whatsapp.EdgeAgent)
  36694. }
  36695. return edges
  36696. }
  36697. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36698. // was cleared in this mutation.
  36699. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  36700. switch name {
  36701. case whatsapp.EdgeAgent:
  36702. return m.clearedagent
  36703. }
  36704. return false
  36705. }
  36706. // ClearEdge clears the value of the edge with the given name. It returns an error
  36707. // if that edge is not defined in the schema.
  36708. func (m *WhatsappMutation) ClearEdge(name string) error {
  36709. switch name {
  36710. case whatsapp.EdgeAgent:
  36711. m.ClearAgent()
  36712. return nil
  36713. }
  36714. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  36715. }
  36716. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36717. // It returns an error if the edge is not defined in the schema.
  36718. func (m *WhatsappMutation) ResetEdge(name string) error {
  36719. switch name {
  36720. case whatsapp.EdgeAgent:
  36721. m.ResetAgent()
  36722. return nil
  36723. }
  36724. return fmt.Errorf("unknown Whatsapp edge %s", name)
  36725. }
  36726. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  36727. type WhatsappChannelMutation struct {
  36728. config
  36729. op Op
  36730. typ string
  36731. id *uint64
  36732. created_at *time.Time
  36733. updated_at *time.Time
  36734. status *uint8
  36735. addstatus *int8
  36736. deleted_at *time.Time
  36737. ak *string
  36738. sk *string
  36739. wa_id *string
  36740. wa_name *string
  36741. waba_id *uint64
  36742. addwaba_id *int64
  36743. business_id *uint64
  36744. addbusiness_id *int64
  36745. organization_id *uint64
  36746. addorganization_id *int64
  36747. verify_account *string
  36748. clearedFields map[string]struct{}
  36749. done bool
  36750. oldValue func(context.Context) (*WhatsappChannel, error)
  36751. predicates []predicate.WhatsappChannel
  36752. }
  36753. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  36754. // whatsappchannelOption allows management of the mutation configuration using functional options.
  36755. type whatsappchannelOption func(*WhatsappChannelMutation)
  36756. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  36757. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  36758. m := &WhatsappChannelMutation{
  36759. config: c,
  36760. op: op,
  36761. typ: TypeWhatsappChannel,
  36762. clearedFields: make(map[string]struct{}),
  36763. }
  36764. for _, opt := range opts {
  36765. opt(m)
  36766. }
  36767. return m
  36768. }
  36769. // withWhatsappChannelID sets the ID field of the mutation.
  36770. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  36771. return func(m *WhatsappChannelMutation) {
  36772. var (
  36773. err error
  36774. once sync.Once
  36775. value *WhatsappChannel
  36776. )
  36777. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  36778. once.Do(func() {
  36779. if m.done {
  36780. err = errors.New("querying old values post mutation is not allowed")
  36781. } else {
  36782. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  36783. }
  36784. })
  36785. return value, err
  36786. }
  36787. m.id = &id
  36788. }
  36789. }
  36790. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  36791. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  36792. return func(m *WhatsappChannelMutation) {
  36793. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  36794. return node, nil
  36795. }
  36796. m.id = &node.ID
  36797. }
  36798. }
  36799. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36800. // executed in a transaction (ent.Tx), a transactional client is returned.
  36801. func (m WhatsappChannelMutation) Client() *Client {
  36802. client := &Client{config: m.config}
  36803. client.init()
  36804. return client
  36805. }
  36806. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36807. // it returns an error otherwise.
  36808. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  36809. if _, ok := m.driver.(*txDriver); !ok {
  36810. return nil, errors.New("ent: mutation is not running in a transaction")
  36811. }
  36812. tx := &Tx{config: m.config}
  36813. tx.init()
  36814. return tx, nil
  36815. }
  36816. // SetID sets the value of the id field. Note that this
  36817. // operation is only accepted on creation of WhatsappChannel entities.
  36818. func (m *WhatsappChannelMutation) SetID(id uint64) {
  36819. m.id = &id
  36820. }
  36821. // ID returns the ID value in the mutation. Note that the ID is only available
  36822. // if it was provided to the builder or after it was returned from the database.
  36823. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  36824. if m.id == nil {
  36825. return
  36826. }
  36827. return *m.id, true
  36828. }
  36829. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36830. // That means, if the mutation is applied within a transaction with an isolation level such
  36831. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36832. // or updated by the mutation.
  36833. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  36834. switch {
  36835. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36836. id, exists := m.ID()
  36837. if exists {
  36838. return []uint64{id}, nil
  36839. }
  36840. fallthrough
  36841. case m.op.Is(OpUpdate | OpDelete):
  36842. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  36843. default:
  36844. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36845. }
  36846. }
  36847. // SetCreatedAt sets the "created_at" field.
  36848. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  36849. m.created_at = &t
  36850. }
  36851. // CreatedAt returns the value of the "created_at" field in the mutation.
  36852. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  36853. v := m.created_at
  36854. if v == nil {
  36855. return
  36856. }
  36857. return *v, true
  36858. }
  36859. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  36860. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36862. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36863. if !m.op.Is(OpUpdateOne) {
  36864. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36865. }
  36866. if m.id == nil || m.oldValue == nil {
  36867. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36868. }
  36869. oldValue, err := m.oldValue(ctx)
  36870. if err != nil {
  36871. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36872. }
  36873. return oldValue.CreatedAt, nil
  36874. }
  36875. // ResetCreatedAt resets all changes to the "created_at" field.
  36876. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  36877. m.created_at = nil
  36878. }
  36879. // SetUpdatedAt sets the "updated_at" field.
  36880. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  36881. m.updated_at = &t
  36882. }
  36883. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36884. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  36885. v := m.updated_at
  36886. if v == nil {
  36887. return
  36888. }
  36889. return *v, true
  36890. }
  36891. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  36892. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36894. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36895. if !m.op.Is(OpUpdateOne) {
  36896. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36897. }
  36898. if m.id == nil || m.oldValue == nil {
  36899. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36900. }
  36901. oldValue, err := m.oldValue(ctx)
  36902. if err != nil {
  36903. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36904. }
  36905. return oldValue.UpdatedAt, nil
  36906. }
  36907. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36908. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  36909. m.updated_at = nil
  36910. }
  36911. // SetStatus sets the "status" field.
  36912. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  36913. m.status = &u
  36914. m.addstatus = nil
  36915. }
  36916. // Status returns the value of the "status" field in the mutation.
  36917. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  36918. v := m.status
  36919. if v == nil {
  36920. return
  36921. }
  36922. return *v, true
  36923. }
  36924. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  36925. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36927. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36928. if !m.op.Is(OpUpdateOne) {
  36929. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36930. }
  36931. if m.id == nil || m.oldValue == nil {
  36932. return v, errors.New("OldStatus requires an ID field in the mutation")
  36933. }
  36934. oldValue, err := m.oldValue(ctx)
  36935. if err != nil {
  36936. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36937. }
  36938. return oldValue.Status, nil
  36939. }
  36940. // AddStatus adds u to the "status" field.
  36941. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  36942. if m.addstatus != nil {
  36943. *m.addstatus += u
  36944. } else {
  36945. m.addstatus = &u
  36946. }
  36947. }
  36948. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36949. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  36950. v := m.addstatus
  36951. if v == nil {
  36952. return
  36953. }
  36954. return *v, true
  36955. }
  36956. // ClearStatus clears the value of the "status" field.
  36957. func (m *WhatsappChannelMutation) ClearStatus() {
  36958. m.status = nil
  36959. m.addstatus = nil
  36960. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  36961. }
  36962. // StatusCleared returns if the "status" field was cleared in this mutation.
  36963. func (m *WhatsappChannelMutation) StatusCleared() bool {
  36964. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  36965. return ok
  36966. }
  36967. // ResetStatus resets all changes to the "status" field.
  36968. func (m *WhatsappChannelMutation) ResetStatus() {
  36969. m.status = nil
  36970. m.addstatus = nil
  36971. delete(m.clearedFields, whatsappchannel.FieldStatus)
  36972. }
  36973. // SetDeletedAt sets the "deleted_at" field.
  36974. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  36975. m.deleted_at = &t
  36976. }
  36977. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36978. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  36979. v := m.deleted_at
  36980. if v == nil {
  36981. return
  36982. }
  36983. return *v, true
  36984. }
  36985. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  36986. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36988. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36989. if !m.op.Is(OpUpdateOne) {
  36990. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36991. }
  36992. if m.id == nil || m.oldValue == nil {
  36993. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36994. }
  36995. oldValue, err := m.oldValue(ctx)
  36996. if err != nil {
  36997. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36998. }
  36999. return oldValue.DeletedAt, nil
  37000. }
  37001. // ClearDeletedAt clears the value of the "deleted_at" field.
  37002. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  37003. m.deleted_at = nil
  37004. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  37005. }
  37006. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37007. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  37008. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  37009. return ok
  37010. }
  37011. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37012. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  37013. m.deleted_at = nil
  37014. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  37015. }
  37016. // SetAk sets the "ak" field.
  37017. func (m *WhatsappChannelMutation) SetAk(s string) {
  37018. m.ak = &s
  37019. }
  37020. // Ak returns the value of the "ak" field in the mutation.
  37021. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  37022. v := m.ak
  37023. if v == nil {
  37024. return
  37025. }
  37026. return *v, true
  37027. }
  37028. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  37029. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37031. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  37032. if !m.op.Is(OpUpdateOne) {
  37033. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  37034. }
  37035. if m.id == nil || m.oldValue == nil {
  37036. return v, errors.New("OldAk requires an ID field in the mutation")
  37037. }
  37038. oldValue, err := m.oldValue(ctx)
  37039. if err != nil {
  37040. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  37041. }
  37042. return oldValue.Ak, nil
  37043. }
  37044. // ClearAk clears the value of the "ak" field.
  37045. func (m *WhatsappChannelMutation) ClearAk() {
  37046. m.ak = nil
  37047. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  37048. }
  37049. // AkCleared returns if the "ak" field was cleared in this mutation.
  37050. func (m *WhatsappChannelMutation) AkCleared() bool {
  37051. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  37052. return ok
  37053. }
  37054. // ResetAk resets all changes to the "ak" field.
  37055. func (m *WhatsappChannelMutation) ResetAk() {
  37056. m.ak = nil
  37057. delete(m.clearedFields, whatsappchannel.FieldAk)
  37058. }
  37059. // SetSk sets the "sk" field.
  37060. func (m *WhatsappChannelMutation) SetSk(s string) {
  37061. m.sk = &s
  37062. }
  37063. // Sk returns the value of the "sk" field in the mutation.
  37064. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  37065. v := m.sk
  37066. if v == nil {
  37067. return
  37068. }
  37069. return *v, true
  37070. }
  37071. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  37072. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37074. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  37075. if !m.op.Is(OpUpdateOne) {
  37076. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  37077. }
  37078. if m.id == nil || m.oldValue == nil {
  37079. return v, errors.New("OldSk requires an ID field in the mutation")
  37080. }
  37081. oldValue, err := m.oldValue(ctx)
  37082. if err != nil {
  37083. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  37084. }
  37085. return oldValue.Sk, nil
  37086. }
  37087. // ResetSk resets all changes to the "sk" field.
  37088. func (m *WhatsappChannelMutation) ResetSk() {
  37089. m.sk = nil
  37090. }
  37091. // SetWaID sets the "wa_id" field.
  37092. func (m *WhatsappChannelMutation) SetWaID(s string) {
  37093. m.wa_id = &s
  37094. }
  37095. // WaID returns the value of the "wa_id" field in the mutation.
  37096. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  37097. v := m.wa_id
  37098. if v == nil {
  37099. return
  37100. }
  37101. return *v, true
  37102. }
  37103. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  37104. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37106. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  37107. if !m.op.Is(OpUpdateOne) {
  37108. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  37109. }
  37110. if m.id == nil || m.oldValue == nil {
  37111. return v, errors.New("OldWaID requires an ID field in the mutation")
  37112. }
  37113. oldValue, err := m.oldValue(ctx)
  37114. if err != nil {
  37115. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  37116. }
  37117. return oldValue.WaID, nil
  37118. }
  37119. // ClearWaID clears the value of the "wa_id" field.
  37120. func (m *WhatsappChannelMutation) ClearWaID() {
  37121. m.wa_id = nil
  37122. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  37123. }
  37124. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  37125. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  37126. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  37127. return ok
  37128. }
  37129. // ResetWaID resets all changes to the "wa_id" field.
  37130. func (m *WhatsappChannelMutation) ResetWaID() {
  37131. m.wa_id = nil
  37132. delete(m.clearedFields, whatsappchannel.FieldWaID)
  37133. }
  37134. // SetWaName sets the "wa_name" field.
  37135. func (m *WhatsappChannelMutation) SetWaName(s string) {
  37136. m.wa_name = &s
  37137. }
  37138. // WaName returns the value of the "wa_name" field in the mutation.
  37139. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  37140. v := m.wa_name
  37141. if v == nil {
  37142. return
  37143. }
  37144. return *v, true
  37145. }
  37146. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  37147. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37149. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  37150. if !m.op.Is(OpUpdateOne) {
  37151. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  37152. }
  37153. if m.id == nil || m.oldValue == nil {
  37154. return v, errors.New("OldWaName requires an ID field in the mutation")
  37155. }
  37156. oldValue, err := m.oldValue(ctx)
  37157. if err != nil {
  37158. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  37159. }
  37160. return oldValue.WaName, nil
  37161. }
  37162. // ClearWaName clears the value of the "wa_name" field.
  37163. func (m *WhatsappChannelMutation) ClearWaName() {
  37164. m.wa_name = nil
  37165. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  37166. }
  37167. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  37168. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  37169. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  37170. return ok
  37171. }
  37172. // ResetWaName resets all changes to the "wa_name" field.
  37173. func (m *WhatsappChannelMutation) ResetWaName() {
  37174. m.wa_name = nil
  37175. delete(m.clearedFields, whatsappchannel.FieldWaName)
  37176. }
  37177. // SetWabaID sets the "waba_id" field.
  37178. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  37179. m.waba_id = &u
  37180. m.addwaba_id = nil
  37181. }
  37182. // WabaID returns the value of the "waba_id" field in the mutation.
  37183. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  37184. v := m.waba_id
  37185. if v == nil {
  37186. return
  37187. }
  37188. return *v, true
  37189. }
  37190. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  37191. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37193. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  37194. if !m.op.Is(OpUpdateOne) {
  37195. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  37196. }
  37197. if m.id == nil || m.oldValue == nil {
  37198. return v, errors.New("OldWabaID requires an ID field in the mutation")
  37199. }
  37200. oldValue, err := m.oldValue(ctx)
  37201. if err != nil {
  37202. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  37203. }
  37204. return oldValue.WabaID, nil
  37205. }
  37206. // AddWabaID adds u to the "waba_id" field.
  37207. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  37208. if m.addwaba_id != nil {
  37209. *m.addwaba_id += u
  37210. } else {
  37211. m.addwaba_id = &u
  37212. }
  37213. }
  37214. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  37215. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  37216. v := m.addwaba_id
  37217. if v == nil {
  37218. return
  37219. }
  37220. return *v, true
  37221. }
  37222. // ResetWabaID resets all changes to the "waba_id" field.
  37223. func (m *WhatsappChannelMutation) ResetWabaID() {
  37224. m.waba_id = nil
  37225. m.addwaba_id = nil
  37226. }
  37227. // SetBusinessID sets the "business_id" field.
  37228. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  37229. m.business_id = &u
  37230. m.addbusiness_id = nil
  37231. }
  37232. // BusinessID returns the value of the "business_id" field in the mutation.
  37233. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  37234. v := m.business_id
  37235. if v == nil {
  37236. return
  37237. }
  37238. return *v, true
  37239. }
  37240. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  37241. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37243. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  37244. if !m.op.Is(OpUpdateOne) {
  37245. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  37246. }
  37247. if m.id == nil || m.oldValue == nil {
  37248. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  37249. }
  37250. oldValue, err := m.oldValue(ctx)
  37251. if err != nil {
  37252. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  37253. }
  37254. return oldValue.BusinessID, nil
  37255. }
  37256. // AddBusinessID adds u to the "business_id" field.
  37257. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  37258. if m.addbusiness_id != nil {
  37259. *m.addbusiness_id += u
  37260. } else {
  37261. m.addbusiness_id = &u
  37262. }
  37263. }
  37264. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  37265. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  37266. v := m.addbusiness_id
  37267. if v == nil {
  37268. return
  37269. }
  37270. return *v, true
  37271. }
  37272. // ResetBusinessID resets all changes to the "business_id" field.
  37273. func (m *WhatsappChannelMutation) ResetBusinessID() {
  37274. m.business_id = nil
  37275. m.addbusiness_id = nil
  37276. }
  37277. // SetOrganizationID sets the "organization_id" field.
  37278. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  37279. m.organization_id = &u
  37280. m.addorganization_id = nil
  37281. }
  37282. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37283. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  37284. v := m.organization_id
  37285. if v == nil {
  37286. return
  37287. }
  37288. return *v, true
  37289. }
  37290. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  37291. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37293. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37294. if !m.op.Is(OpUpdateOne) {
  37295. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37296. }
  37297. if m.id == nil || m.oldValue == nil {
  37298. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37299. }
  37300. oldValue, err := m.oldValue(ctx)
  37301. if err != nil {
  37302. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37303. }
  37304. return oldValue.OrganizationID, nil
  37305. }
  37306. // AddOrganizationID adds u to the "organization_id" field.
  37307. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  37308. if m.addorganization_id != nil {
  37309. *m.addorganization_id += u
  37310. } else {
  37311. m.addorganization_id = &u
  37312. }
  37313. }
  37314. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37315. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  37316. v := m.addorganization_id
  37317. if v == nil {
  37318. return
  37319. }
  37320. return *v, true
  37321. }
  37322. // ClearOrganizationID clears the value of the "organization_id" field.
  37323. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  37324. m.organization_id = nil
  37325. m.addorganization_id = nil
  37326. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  37327. }
  37328. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37329. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  37330. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  37331. return ok
  37332. }
  37333. // ResetOrganizationID resets all changes to the "organization_id" field.
  37334. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  37335. m.organization_id = nil
  37336. m.addorganization_id = nil
  37337. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  37338. }
  37339. // SetVerifyAccount sets the "verify_account" field.
  37340. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  37341. m.verify_account = &s
  37342. }
  37343. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  37344. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  37345. v := m.verify_account
  37346. if v == nil {
  37347. return
  37348. }
  37349. return *v, true
  37350. }
  37351. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  37352. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37354. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  37355. if !m.op.Is(OpUpdateOne) {
  37356. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  37357. }
  37358. if m.id == nil || m.oldValue == nil {
  37359. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  37360. }
  37361. oldValue, err := m.oldValue(ctx)
  37362. if err != nil {
  37363. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  37364. }
  37365. return oldValue.VerifyAccount, nil
  37366. }
  37367. // ResetVerifyAccount resets all changes to the "verify_account" field.
  37368. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  37369. m.verify_account = nil
  37370. }
  37371. // Where appends a list predicates to the WhatsappChannelMutation builder.
  37372. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  37373. m.predicates = append(m.predicates, ps...)
  37374. }
  37375. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  37376. // users can use type-assertion to append predicates that do not depend on any generated package.
  37377. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  37378. p := make([]predicate.WhatsappChannel, len(ps))
  37379. for i := range ps {
  37380. p[i] = ps[i]
  37381. }
  37382. m.Where(p...)
  37383. }
  37384. // Op returns the operation name.
  37385. func (m *WhatsappChannelMutation) Op() Op {
  37386. return m.op
  37387. }
  37388. // SetOp allows setting the mutation operation.
  37389. func (m *WhatsappChannelMutation) SetOp(op Op) {
  37390. m.op = op
  37391. }
  37392. // Type returns the node type of this mutation (WhatsappChannel).
  37393. func (m *WhatsappChannelMutation) Type() string {
  37394. return m.typ
  37395. }
  37396. // Fields returns all fields that were changed during this mutation. Note that in
  37397. // order to get all numeric fields that were incremented/decremented, call
  37398. // AddedFields().
  37399. func (m *WhatsappChannelMutation) Fields() []string {
  37400. fields := make([]string, 0, 12)
  37401. if m.created_at != nil {
  37402. fields = append(fields, whatsappchannel.FieldCreatedAt)
  37403. }
  37404. if m.updated_at != nil {
  37405. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  37406. }
  37407. if m.status != nil {
  37408. fields = append(fields, whatsappchannel.FieldStatus)
  37409. }
  37410. if m.deleted_at != nil {
  37411. fields = append(fields, whatsappchannel.FieldDeletedAt)
  37412. }
  37413. if m.ak != nil {
  37414. fields = append(fields, whatsappchannel.FieldAk)
  37415. }
  37416. if m.sk != nil {
  37417. fields = append(fields, whatsappchannel.FieldSk)
  37418. }
  37419. if m.wa_id != nil {
  37420. fields = append(fields, whatsappchannel.FieldWaID)
  37421. }
  37422. if m.wa_name != nil {
  37423. fields = append(fields, whatsappchannel.FieldWaName)
  37424. }
  37425. if m.waba_id != nil {
  37426. fields = append(fields, whatsappchannel.FieldWabaID)
  37427. }
  37428. if m.business_id != nil {
  37429. fields = append(fields, whatsappchannel.FieldBusinessID)
  37430. }
  37431. if m.organization_id != nil {
  37432. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37433. }
  37434. if m.verify_account != nil {
  37435. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  37436. }
  37437. return fields
  37438. }
  37439. // Field returns the value of a field with the given name. The second boolean
  37440. // return value indicates that this field was not set, or was not defined in the
  37441. // schema.
  37442. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  37443. switch name {
  37444. case whatsappchannel.FieldCreatedAt:
  37445. return m.CreatedAt()
  37446. case whatsappchannel.FieldUpdatedAt:
  37447. return m.UpdatedAt()
  37448. case whatsappchannel.FieldStatus:
  37449. return m.Status()
  37450. case whatsappchannel.FieldDeletedAt:
  37451. return m.DeletedAt()
  37452. case whatsappchannel.FieldAk:
  37453. return m.Ak()
  37454. case whatsappchannel.FieldSk:
  37455. return m.Sk()
  37456. case whatsappchannel.FieldWaID:
  37457. return m.WaID()
  37458. case whatsappchannel.FieldWaName:
  37459. return m.WaName()
  37460. case whatsappchannel.FieldWabaID:
  37461. return m.WabaID()
  37462. case whatsappchannel.FieldBusinessID:
  37463. return m.BusinessID()
  37464. case whatsappchannel.FieldOrganizationID:
  37465. return m.OrganizationID()
  37466. case whatsappchannel.FieldVerifyAccount:
  37467. return m.VerifyAccount()
  37468. }
  37469. return nil, false
  37470. }
  37471. // OldField returns the old value of the field from the database. An error is
  37472. // returned if the mutation operation is not UpdateOne, or the query to the
  37473. // database failed.
  37474. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37475. switch name {
  37476. case whatsappchannel.FieldCreatedAt:
  37477. return m.OldCreatedAt(ctx)
  37478. case whatsappchannel.FieldUpdatedAt:
  37479. return m.OldUpdatedAt(ctx)
  37480. case whatsappchannel.FieldStatus:
  37481. return m.OldStatus(ctx)
  37482. case whatsappchannel.FieldDeletedAt:
  37483. return m.OldDeletedAt(ctx)
  37484. case whatsappchannel.FieldAk:
  37485. return m.OldAk(ctx)
  37486. case whatsappchannel.FieldSk:
  37487. return m.OldSk(ctx)
  37488. case whatsappchannel.FieldWaID:
  37489. return m.OldWaID(ctx)
  37490. case whatsappchannel.FieldWaName:
  37491. return m.OldWaName(ctx)
  37492. case whatsappchannel.FieldWabaID:
  37493. return m.OldWabaID(ctx)
  37494. case whatsappchannel.FieldBusinessID:
  37495. return m.OldBusinessID(ctx)
  37496. case whatsappchannel.FieldOrganizationID:
  37497. return m.OldOrganizationID(ctx)
  37498. case whatsappchannel.FieldVerifyAccount:
  37499. return m.OldVerifyAccount(ctx)
  37500. }
  37501. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  37502. }
  37503. // SetField sets the value of a field with the given name. It returns an error if
  37504. // the field is not defined in the schema, or if the type mismatched the field
  37505. // type.
  37506. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  37507. switch name {
  37508. case whatsappchannel.FieldCreatedAt:
  37509. v, ok := value.(time.Time)
  37510. if !ok {
  37511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37512. }
  37513. m.SetCreatedAt(v)
  37514. return nil
  37515. case whatsappchannel.FieldUpdatedAt:
  37516. v, ok := value.(time.Time)
  37517. if !ok {
  37518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37519. }
  37520. m.SetUpdatedAt(v)
  37521. return nil
  37522. case whatsappchannel.FieldStatus:
  37523. v, ok := value.(uint8)
  37524. if !ok {
  37525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37526. }
  37527. m.SetStatus(v)
  37528. return nil
  37529. case whatsappchannel.FieldDeletedAt:
  37530. v, ok := value.(time.Time)
  37531. if !ok {
  37532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37533. }
  37534. m.SetDeletedAt(v)
  37535. return nil
  37536. case whatsappchannel.FieldAk:
  37537. v, ok := value.(string)
  37538. if !ok {
  37539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37540. }
  37541. m.SetAk(v)
  37542. return nil
  37543. case whatsappchannel.FieldSk:
  37544. v, ok := value.(string)
  37545. if !ok {
  37546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37547. }
  37548. m.SetSk(v)
  37549. return nil
  37550. case whatsappchannel.FieldWaID:
  37551. v, ok := value.(string)
  37552. if !ok {
  37553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37554. }
  37555. m.SetWaID(v)
  37556. return nil
  37557. case whatsappchannel.FieldWaName:
  37558. v, ok := value.(string)
  37559. if !ok {
  37560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37561. }
  37562. m.SetWaName(v)
  37563. return nil
  37564. case whatsappchannel.FieldWabaID:
  37565. v, ok := value.(uint64)
  37566. if !ok {
  37567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37568. }
  37569. m.SetWabaID(v)
  37570. return nil
  37571. case whatsappchannel.FieldBusinessID:
  37572. v, ok := value.(uint64)
  37573. if !ok {
  37574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37575. }
  37576. m.SetBusinessID(v)
  37577. return nil
  37578. case whatsappchannel.FieldOrganizationID:
  37579. v, ok := value.(uint64)
  37580. if !ok {
  37581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37582. }
  37583. m.SetOrganizationID(v)
  37584. return nil
  37585. case whatsappchannel.FieldVerifyAccount:
  37586. v, ok := value.(string)
  37587. if !ok {
  37588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37589. }
  37590. m.SetVerifyAccount(v)
  37591. return nil
  37592. }
  37593. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  37594. }
  37595. // AddedFields returns all numeric fields that were incremented/decremented during
  37596. // this mutation.
  37597. func (m *WhatsappChannelMutation) AddedFields() []string {
  37598. var fields []string
  37599. if m.addstatus != nil {
  37600. fields = append(fields, whatsappchannel.FieldStatus)
  37601. }
  37602. if m.addwaba_id != nil {
  37603. fields = append(fields, whatsappchannel.FieldWabaID)
  37604. }
  37605. if m.addbusiness_id != nil {
  37606. fields = append(fields, whatsappchannel.FieldBusinessID)
  37607. }
  37608. if m.addorganization_id != nil {
  37609. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37610. }
  37611. return fields
  37612. }
  37613. // AddedField returns the numeric value that was incremented/decremented on a field
  37614. // with the given name. The second boolean return value indicates that this field
  37615. // was not set, or was not defined in the schema.
  37616. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  37617. switch name {
  37618. case whatsappchannel.FieldStatus:
  37619. return m.AddedStatus()
  37620. case whatsappchannel.FieldWabaID:
  37621. return m.AddedWabaID()
  37622. case whatsappchannel.FieldBusinessID:
  37623. return m.AddedBusinessID()
  37624. case whatsappchannel.FieldOrganizationID:
  37625. return m.AddedOrganizationID()
  37626. }
  37627. return nil, false
  37628. }
  37629. // AddField adds the value to the field with the given name. It returns an error if
  37630. // the field is not defined in the schema, or if the type mismatched the field
  37631. // type.
  37632. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  37633. switch name {
  37634. case whatsappchannel.FieldStatus:
  37635. v, ok := value.(int8)
  37636. if !ok {
  37637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37638. }
  37639. m.AddStatus(v)
  37640. return nil
  37641. case whatsappchannel.FieldWabaID:
  37642. v, ok := value.(int64)
  37643. if !ok {
  37644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37645. }
  37646. m.AddWabaID(v)
  37647. return nil
  37648. case whatsappchannel.FieldBusinessID:
  37649. v, ok := value.(int64)
  37650. if !ok {
  37651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37652. }
  37653. m.AddBusinessID(v)
  37654. return nil
  37655. case whatsappchannel.FieldOrganizationID:
  37656. v, ok := value.(int64)
  37657. if !ok {
  37658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37659. }
  37660. m.AddOrganizationID(v)
  37661. return nil
  37662. }
  37663. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  37664. }
  37665. // ClearedFields returns all nullable fields that were cleared during this
  37666. // mutation.
  37667. func (m *WhatsappChannelMutation) ClearedFields() []string {
  37668. var fields []string
  37669. if m.FieldCleared(whatsappchannel.FieldStatus) {
  37670. fields = append(fields, whatsappchannel.FieldStatus)
  37671. }
  37672. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  37673. fields = append(fields, whatsappchannel.FieldDeletedAt)
  37674. }
  37675. if m.FieldCleared(whatsappchannel.FieldAk) {
  37676. fields = append(fields, whatsappchannel.FieldAk)
  37677. }
  37678. if m.FieldCleared(whatsappchannel.FieldWaID) {
  37679. fields = append(fields, whatsappchannel.FieldWaID)
  37680. }
  37681. if m.FieldCleared(whatsappchannel.FieldWaName) {
  37682. fields = append(fields, whatsappchannel.FieldWaName)
  37683. }
  37684. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  37685. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37686. }
  37687. return fields
  37688. }
  37689. // FieldCleared returns a boolean indicating if a field with the given name was
  37690. // cleared in this mutation.
  37691. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  37692. _, ok := m.clearedFields[name]
  37693. return ok
  37694. }
  37695. // ClearField clears the value of the field with the given name. It returns an
  37696. // error if the field is not defined in the schema.
  37697. func (m *WhatsappChannelMutation) ClearField(name string) error {
  37698. switch name {
  37699. case whatsappchannel.FieldStatus:
  37700. m.ClearStatus()
  37701. return nil
  37702. case whatsappchannel.FieldDeletedAt:
  37703. m.ClearDeletedAt()
  37704. return nil
  37705. case whatsappchannel.FieldAk:
  37706. m.ClearAk()
  37707. return nil
  37708. case whatsappchannel.FieldWaID:
  37709. m.ClearWaID()
  37710. return nil
  37711. case whatsappchannel.FieldWaName:
  37712. m.ClearWaName()
  37713. return nil
  37714. case whatsappchannel.FieldOrganizationID:
  37715. m.ClearOrganizationID()
  37716. return nil
  37717. }
  37718. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  37719. }
  37720. // ResetField resets all changes in the mutation for the field with the given name.
  37721. // It returns an error if the field is not defined in the schema.
  37722. func (m *WhatsappChannelMutation) ResetField(name string) error {
  37723. switch name {
  37724. case whatsappchannel.FieldCreatedAt:
  37725. m.ResetCreatedAt()
  37726. return nil
  37727. case whatsappchannel.FieldUpdatedAt:
  37728. m.ResetUpdatedAt()
  37729. return nil
  37730. case whatsappchannel.FieldStatus:
  37731. m.ResetStatus()
  37732. return nil
  37733. case whatsappchannel.FieldDeletedAt:
  37734. m.ResetDeletedAt()
  37735. return nil
  37736. case whatsappchannel.FieldAk:
  37737. m.ResetAk()
  37738. return nil
  37739. case whatsappchannel.FieldSk:
  37740. m.ResetSk()
  37741. return nil
  37742. case whatsappchannel.FieldWaID:
  37743. m.ResetWaID()
  37744. return nil
  37745. case whatsappchannel.FieldWaName:
  37746. m.ResetWaName()
  37747. return nil
  37748. case whatsappchannel.FieldWabaID:
  37749. m.ResetWabaID()
  37750. return nil
  37751. case whatsappchannel.FieldBusinessID:
  37752. m.ResetBusinessID()
  37753. return nil
  37754. case whatsappchannel.FieldOrganizationID:
  37755. m.ResetOrganizationID()
  37756. return nil
  37757. case whatsappchannel.FieldVerifyAccount:
  37758. m.ResetVerifyAccount()
  37759. return nil
  37760. }
  37761. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  37762. }
  37763. // AddedEdges returns all edge names that were set/added in this mutation.
  37764. func (m *WhatsappChannelMutation) AddedEdges() []string {
  37765. edges := make([]string, 0, 0)
  37766. return edges
  37767. }
  37768. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37769. // name in this mutation.
  37770. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  37771. return nil
  37772. }
  37773. // RemovedEdges returns all edge names that were removed in this mutation.
  37774. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  37775. edges := make([]string, 0, 0)
  37776. return edges
  37777. }
  37778. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37779. // the given name in this mutation.
  37780. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  37781. return nil
  37782. }
  37783. // ClearedEdges returns all edge names that were cleared in this mutation.
  37784. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  37785. edges := make([]string, 0, 0)
  37786. return edges
  37787. }
  37788. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37789. // was cleared in this mutation.
  37790. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  37791. return false
  37792. }
  37793. // ClearEdge clears the value of the edge with the given name. It returns an error
  37794. // if that edge is not defined in the schema.
  37795. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  37796. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  37797. }
  37798. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37799. // It returns an error if the edge is not defined in the schema.
  37800. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  37801. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  37802. }
  37803. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  37804. type WorkExperienceMutation struct {
  37805. config
  37806. op Op
  37807. typ string
  37808. id *uint64
  37809. created_at *time.Time
  37810. updated_at *time.Time
  37811. deleted_at *time.Time
  37812. start_date *time.Time
  37813. end_date *time.Time
  37814. company *string
  37815. experience *string
  37816. organization_id *uint64
  37817. addorganization_id *int64
  37818. clearedFields map[string]struct{}
  37819. employee *uint64
  37820. clearedemployee bool
  37821. done bool
  37822. oldValue func(context.Context) (*WorkExperience, error)
  37823. predicates []predicate.WorkExperience
  37824. }
  37825. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  37826. // workexperienceOption allows management of the mutation configuration using functional options.
  37827. type workexperienceOption func(*WorkExperienceMutation)
  37828. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  37829. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  37830. m := &WorkExperienceMutation{
  37831. config: c,
  37832. op: op,
  37833. typ: TypeWorkExperience,
  37834. clearedFields: make(map[string]struct{}),
  37835. }
  37836. for _, opt := range opts {
  37837. opt(m)
  37838. }
  37839. return m
  37840. }
  37841. // withWorkExperienceID sets the ID field of the mutation.
  37842. func withWorkExperienceID(id uint64) workexperienceOption {
  37843. return func(m *WorkExperienceMutation) {
  37844. var (
  37845. err error
  37846. once sync.Once
  37847. value *WorkExperience
  37848. )
  37849. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  37850. once.Do(func() {
  37851. if m.done {
  37852. err = errors.New("querying old values post mutation is not allowed")
  37853. } else {
  37854. value, err = m.Client().WorkExperience.Get(ctx, id)
  37855. }
  37856. })
  37857. return value, err
  37858. }
  37859. m.id = &id
  37860. }
  37861. }
  37862. // withWorkExperience sets the old WorkExperience of the mutation.
  37863. func withWorkExperience(node *WorkExperience) workexperienceOption {
  37864. return func(m *WorkExperienceMutation) {
  37865. m.oldValue = func(context.Context) (*WorkExperience, error) {
  37866. return node, nil
  37867. }
  37868. m.id = &node.ID
  37869. }
  37870. }
  37871. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37872. // executed in a transaction (ent.Tx), a transactional client is returned.
  37873. func (m WorkExperienceMutation) Client() *Client {
  37874. client := &Client{config: m.config}
  37875. client.init()
  37876. return client
  37877. }
  37878. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37879. // it returns an error otherwise.
  37880. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  37881. if _, ok := m.driver.(*txDriver); !ok {
  37882. return nil, errors.New("ent: mutation is not running in a transaction")
  37883. }
  37884. tx := &Tx{config: m.config}
  37885. tx.init()
  37886. return tx, nil
  37887. }
  37888. // SetID sets the value of the id field. Note that this
  37889. // operation is only accepted on creation of WorkExperience entities.
  37890. func (m *WorkExperienceMutation) SetID(id uint64) {
  37891. m.id = &id
  37892. }
  37893. // ID returns the ID value in the mutation. Note that the ID is only available
  37894. // if it was provided to the builder or after it was returned from the database.
  37895. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  37896. if m.id == nil {
  37897. return
  37898. }
  37899. return *m.id, true
  37900. }
  37901. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37902. // That means, if the mutation is applied within a transaction with an isolation level such
  37903. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37904. // or updated by the mutation.
  37905. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  37906. switch {
  37907. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37908. id, exists := m.ID()
  37909. if exists {
  37910. return []uint64{id}, nil
  37911. }
  37912. fallthrough
  37913. case m.op.Is(OpUpdate | OpDelete):
  37914. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  37915. default:
  37916. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37917. }
  37918. }
  37919. // SetCreatedAt sets the "created_at" field.
  37920. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  37921. m.created_at = &t
  37922. }
  37923. // CreatedAt returns the value of the "created_at" field in the mutation.
  37924. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  37925. v := m.created_at
  37926. if v == nil {
  37927. return
  37928. }
  37929. return *v, true
  37930. }
  37931. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  37932. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37934. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37935. if !m.op.Is(OpUpdateOne) {
  37936. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37937. }
  37938. if m.id == nil || m.oldValue == nil {
  37939. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37940. }
  37941. oldValue, err := m.oldValue(ctx)
  37942. if err != nil {
  37943. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37944. }
  37945. return oldValue.CreatedAt, nil
  37946. }
  37947. // ResetCreatedAt resets all changes to the "created_at" field.
  37948. func (m *WorkExperienceMutation) ResetCreatedAt() {
  37949. m.created_at = nil
  37950. }
  37951. // SetUpdatedAt sets the "updated_at" field.
  37952. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  37953. m.updated_at = &t
  37954. }
  37955. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37956. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  37957. v := m.updated_at
  37958. if v == nil {
  37959. return
  37960. }
  37961. return *v, true
  37962. }
  37963. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  37964. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37966. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37967. if !m.op.Is(OpUpdateOne) {
  37968. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37969. }
  37970. if m.id == nil || m.oldValue == nil {
  37971. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37972. }
  37973. oldValue, err := m.oldValue(ctx)
  37974. if err != nil {
  37975. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37976. }
  37977. return oldValue.UpdatedAt, nil
  37978. }
  37979. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37980. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  37981. m.updated_at = nil
  37982. }
  37983. // SetDeletedAt sets the "deleted_at" field.
  37984. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  37985. m.deleted_at = &t
  37986. }
  37987. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37988. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  37989. v := m.deleted_at
  37990. if v == nil {
  37991. return
  37992. }
  37993. return *v, true
  37994. }
  37995. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  37996. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37998. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37999. if !m.op.Is(OpUpdateOne) {
  38000. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38001. }
  38002. if m.id == nil || m.oldValue == nil {
  38003. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38004. }
  38005. oldValue, err := m.oldValue(ctx)
  38006. if err != nil {
  38007. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38008. }
  38009. return oldValue.DeletedAt, nil
  38010. }
  38011. // ClearDeletedAt clears the value of the "deleted_at" field.
  38012. func (m *WorkExperienceMutation) ClearDeletedAt() {
  38013. m.deleted_at = nil
  38014. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  38015. }
  38016. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38017. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  38018. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  38019. return ok
  38020. }
  38021. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38022. func (m *WorkExperienceMutation) ResetDeletedAt() {
  38023. m.deleted_at = nil
  38024. delete(m.clearedFields, workexperience.FieldDeletedAt)
  38025. }
  38026. // SetEmployeeID sets the "employee_id" field.
  38027. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  38028. m.employee = &u
  38029. }
  38030. // EmployeeID returns the value of the "employee_id" field in the mutation.
  38031. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  38032. v := m.employee
  38033. if v == nil {
  38034. return
  38035. }
  38036. return *v, true
  38037. }
  38038. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  38039. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38041. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  38042. if !m.op.Is(OpUpdateOne) {
  38043. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  38044. }
  38045. if m.id == nil || m.oldValue == nil {
  38046. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  38047. }
  38048. oldValue, err := m.oldValue(ctx)
  38049. if err != nil {
  38050. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  38051. }
  38052. return oldValue.EmployeeID, nil
  38053. }
  38054. // ResetEmployeeID resets all changes to the "employee_id" field.
  38055. func (m *WorkExperienceMutation) ResetEmployeeID() {
  38056. m.employee = nil
  38057. }
  38058. // SetStartDate sets the "start_date" field.
  38059. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  38060. m.start_date = &t
  38061. }
  38062. // StartDate returns the value of the "start_date" field in the mutation.
  38063. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  38064. v := m.start_date
  38065. if v == nil {
  38066. return
  38067. }
  38068. return *v, true
  38069. }
  38070. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  38071. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38073. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  38074. if !m.op.Is(OpUpdateOne) {
  38075. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  38076. }
  38077. if m.id == nil || m.oldValue == nil {
  38078. return v, errors.New("OldStartDate requires an ID field in the mutation")
  38079. }
  38080. oldValue, err := m.oldValue(ctx)
  38081. if err != nil {
  38082. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  38083. }
  38084. return oldValue.StartDate, nil
  38085. }
  38086. // ResetStartDate resets all changes to the "start_date" field.
  38087. func (m *WorkExperienceMutation) ResetStartDate() {
  38088. m.start_date = nil
  38089. }
  38090. // SetEndDate sets the "end_date" field.
  38091. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  38092. m.end_date = &t
  38093. }
  38094. // EndDate returns the value of the "end_date" field in the mutation.
  38095. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  38096. v := m.end_date
  38097. if v == nil {
  38098. return
  38099. }
  38100. return *v, true
  38101. }
  38102. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  38103. // If the WorkExperience 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 *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  38106. if !m.op.Is(OpUpdateOne) {
  38107. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  38108. }
  38109. if m.id == nil || m.oldValue == nil {
  38110. return v, errors.New("OldEndDate 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 OldEndDate: %w", err)
  38115. }
  38116. return oldValue.EndDate, nil
  38117. }
  38118. // ResetEndDate resets all changes to the "end_date" field.
  38119. func (m *WorkExperienceMutation) ResetEndDate() {
  38120. m.end_date = nil
  38121. }
  38122. // SetCompany sets the "company" field.
  38123. func (m *WorkExperienceMutation) SetCompany(s string) {
  38124. m.company = &s
  38125. }
  38126. // Company returns the value of the "company" field in the mutation.
  38127. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  38128. v := m.company
  38129. if v == nil {
  38130. return
  38131. }
  38132. return *v, true
  38133. }
  38134. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  38135. // If the WorkExperience 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 *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  38138. if !m.op.Is(OpUpdateOne) {
  38139. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  38140. }
  38141. if m.id == nil || m.oldValue == nil {
  38142. return v, errors.New("OldCompany 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 OldCompany: %w", err)
  38147. }
  38148. return oldValue.Company, nil
  38149. }
  38150. // ResetCompany resets all changes to the "company" field.
  38151. func (m *WorkExperienceMutation) ResetCompany() {
  38152. m.company = nil
  38153. }
  38154. // SetExperience sets the "experience" field.
  38155. func (m *WorkExperienceMutation) SetExperience(s string) {
  38156. m.experience = &s
  38157. }
  38158. // Experience returns the value of the "experience" field in the mutation.
  38159. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  38160. v := m.experience
  38161. if v == nil {
  38162. return
  38163. }
  38164. return *v, true
  38165. }
  38166. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  38167. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38169. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  38170. if !m.op.Is(OpUpdateOne) {
  38171. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  38172. }
  38173. if m.id == nil || m.oldValue == nil {
  38174. return v, errors.New("OldExperience requires an ID field in the mutation")
  38175. }
  38176. oldValue, err := m.oldValue(ctx)
  38177. if err != nil {
  38178. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  38179. }
  38180. return oldValue.Experience, nil
  38181. }
  38182. // ResetExperience resets all changes to the "experience" field.
  38183. func (m *WorkExperienceMutation) ResetExperience() {
  38184. m.experience = nil
  38185. }
  38186. // SetOrganizationID sets the "organization_id" field.
  38187. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  38188. m.organization_id = &u
  38189. m.addorganization_id = nil
  38190. }
  38191. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38192. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  38193. v := m.organization_id
  38194. if v == nil {
  38195. return
  38196. }
  38197. return *v, true
  38198. }
  38199. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  38200. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38202. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38203. if !m.op.Is(OpUpdateOne) {
  38204. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38205. }
  38206. if m.id == nil || m.oldValue == nil {
  38207. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38208. }
  38209. oldValue, err := m.oldValue(ctx)
  38210. if err != nil {
  38211. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38212. }
  38213. return oldValue.OrganizationID, nil
  38214. }
  38215. // AddOrganizationID adds u to the "organization_id" field.
  38216. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  38217. if m.addorganization_id != nil {
  38218. *m.addorganization_id += u
  38219. } else {
  38220. m.addorganization_id = &u
  38221. }
  38222. }
  38223. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38224. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  38225. v := m.addorganization_id
  38226. if v == nil {
  38227. return
  38228. }
  38229. return *v, true
  38230. }
  38231. // ResetOrganizationID resets all changes to the "organization_id" field.
  38232. func (m *WorkExperienceMutation) ResetOrganizationID() {
  38233. m.organization_id = nil
  38234. m.addorganization_id = nil
  38235. }
  38236. // ClearEmployee clears the "employee" edge to the Employee entity.
  38237. func (m *WorkExperienceMutation) ClearEmployee() {
  38238. m.clearedemployee = true
  38239. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  38240. }
  38241. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  38242. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  38243. return m.clearedemployee
  38244. }
  38245. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  38246. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38247. // EmployeeID instead. It exists only for internal usage by the builders.
  38248. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  38249. if id := m.employee; id != nil {
  38250. ids = append(ids, *id)
  38251. }
  38252. return
  38253. }
  38254. // ResetEmployee resets all changes to the "employee" edge.
  38255. func (m *WorkExperienceMutation) ResetEmployee() {
  38256. m.employee = nil
  38257. m.clearedemployee = false
  38258. }
  38259. // Where appends a list predicates to the WorkExperienceMutation builder.
  38260. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  38261. m.predicates = append(m.predicates, ps...)
  38262. }
  38263. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  38264. // users can use type-assertion to append predicates that do not depend on any generated package.
  38265. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  38266. p := make([]predicate.WorkExperience, len(ps))
  38267. for i := range ps {
  38268. p[i] = ps[i]
  38269. }
  38270. m.Where(p...)
  38271. }
  38272. // Op returns the operation name.
  38273. func (m *WorkExperienceMutation) Op() Op {
  38274. return m.op
  38275. }
  38276. // SetOp allows setting the mutation operation.
  38277. func (m *WorkExperienceMutation) SetOp(op Op) {
  38278. m.op = op
  38279. }
  38280. // Type returns the node type of this mutation (WorkExperience).
  38281. func (m *WorkExperienceMutation) Type() string {
  38282. return m.typ
  38283. }
  38284. // Fields returns all fields that were changed during this mutation. Note that in
  38285. // order to get all numeric fields that were incremented/decremented, call
  38286. // AddedFields().
  38287. func (m *WorkExperienceMutation) Fields() []string {
  38288. fields := make([]string, 0, 9)
  38289. if m.created_at != nil {
  38290. fields = append(fields, workexperience.FieldCreatedAt)
  38291. }
  38292. if m.updated_at != nil {
  38293. fields = append(fields, workexperience.FieldUpdatedAt)
  38294. }
  38295. if m.deleted_at != nil {
  38296. fields = append(fields, workexperience.FieldDeletedAt)
  38297. }
  38298. if m.employee != nil {
  38299. fields = append(fields, workexperience.FieldEmployeeID)
  38300. }
  38301. if m.start_date != nil {
  38302. fields = append(fields, workexperience.FieldStartDate)
  38303. }
  38304. if m.end_date != nil {
  38305. fields = append(fields, workexperience.FieldEndDate)
  38306. }
  38307. if m.company != nil {
  38308. fields = append(fields, workexperience.FieldCompany)
  38309. }
  38310. if m.experience != nil {
  38311. fields = append(fields, workexperience.FieldExperience)
  38312. }
  38313. if m.organization_id != nil {
  38314. fields = append(fields, workexperience.FieldOrganizationID)
  38315. }
  38316. return fields
  38317. }
  38318. // Field returns the value of a field with the given name. The second boolean
  38319. // return value indicates that this field was not set, or was not defined in the
  38320. // schema.
  38321. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  38322. switch name {
  38323. case workexperience.FieldCreatedAt:
  38324. return m.CreatedAt()
  38325. case workexperience.FieldUpdatedAt:
  38326. return m.UpdatedAt()
  38327. case workexperience.FieldDeletedAt:
  38328. return m.DeletedAt()
  38329. case workexperience.FieldEmployeeID:
  38330. return m.EmployeeID()
  38331. case workexperience.FieldStartDate:
  38332. return m.StartDate()
  38333. case workexperience.FieldEndDate:
  38334. return m.EndDate()
  38335. case workexperience.FieldCompany:
  38336. return m.Company()
  38337. case workexperience.FieldExperience:
  38338. return m.Experience()
  38339. case workexperience.FieldOrganizationID:
  38340. return m.OrganizationID()
  38341. }
  38342. return nil, false
  38343. }
  38344. // OldField returns the old value of the field from the database. An error is
  38345. // returned if the mutation operation is not UpdateOne, or the query to the
  38346. // database failed.
  38347. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38348. switch name {
  38349. case workexperience.FieldCreatedAt:
  38350. return m.OldCreatedAt(ctx)
  38351. case workexperience.FieldUpdatedAt:
  38352. return m.OldUpdatedAt(ctx)
  38353. case workexperience.FieldDeletedAt:
  38354. return m.OldDeletedAt(ctx)
  38355. case workexperience.FieldEmployeeID:
  38356. return m.OldEmployeeID(ctx)
  38357. case workexperience.FieldStartDate:
  38358. return m.OldStartDate(ctx)
  38359. case workexperience.FieldEndDate:
  38360. return m.OldEndDate(ctx)
  38361. case workexperience.FieldCompany:
  38362. return m.OldCompany(ctx)
  38363. case workexperience.FieldExperience:
  38364. return m.OldExperience(ctx)
  38365. case workexperience.FieldOrganizationID:
  38366. return m.OldOrganizationID(ctx)
  38367. }
  38368. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  38369. }
  38370. // SetField sets the value of a field with the given name. It returns an error if
  38371. // the field is not defined in the schema, or if the type mismatched the field
  38372. // type.
  38373. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  38374. switch name {
  38375. case workexperience.FieldCreatedAt:
  38376. v, ok := value.(time.Time)
  38377. if !ok {
  38378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38379. }
  38380. m.SetCreatedAt(v)
  38381. return nil
  38382. case workexperience.FieldUpdatedAt:
  38383. v, ok := value.(time.Time)
  38384. if !ok {
  38385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38386. }
  38387. m.SetUpdatedAt(v)
  38388. return nil
  38389. case workexperience.FieldDeletedAt:
  38390. v, ok := value.(time.Time)
  38391. if !ok {
  38392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38393. }
  38394. m.SetDeletedAt(v)
  38395. return nil
  38396. case workexperience.FieldEmployeeID:
  38397. v, ok := value.(uint64)
  38398. if !ok {
  38399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38400. }
  38401. m.SetEmployeeID(v)
  38402. return nil
  38403. case workexperience.FieldStartDate:
  38404. v, ok := value.(time.Time)
  38405. if !ok {
  38406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38407. }
  38408. m.SetStartDate(v)
  38409. return nil
  38410. case workexperience.FieldEndDate:
  38411. v, ok := value.(time.Time)
  38412. if !ok {
  38413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38414. }
  38415. m.SetEndDate(v)
  38416. return nil
  38417. case workexperience.FieldCompany:
  38418. v, ok := value.(string)
  38419. if !ok {
  38420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38421. }
  38422. m.SetCompany(v)
  38423. return nil
  38424. case workexperience.FieldExperience:
  38425. v, ok := value.(string)
  38426. if !ok {
  38427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38428. }
  38429. m.SetExperience(v)
  38430. return nil
  38431. case workexperience.FieldOrganizationID:
  38432. v, ok := value.(uint64)
  38433. if !ok {
  38434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38435. }
  38436. m.SetOrganizationID(v)
  38437. return nil
  38438. }
  38439. return fmt.Errorf("unknown WorkExperience field %s", name)
  38440. }
  38441. // AddedFields returns all numeric fields that were incremented/decremented during
  38442. // this mutation.
  38443. func (m *WorkExperienceMutation) AddedFields() []string {
  38444. var fields []string
  38445. if m.addorganization_id != nil {
  38446. fields = append(fields, workexperience.FieldOrganizationID)
  38447. }
  38448. return fields
  38449. }
  38450. // AddedField returns the numeric value that was incremented/decremented on a field
  38451. // with the given name. The second boolean return value indicates that this field
  38452. // was not set, or was not defined in the schema.
  38453. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  38454. switch name {
  38455. case workexperience.FieldOrganizationID:
  38456. return m.AddedOrganizationID()
  38457. }
  38458. return nil, false
  38459. }
  38460. // AddField adds the value to the field with the given name. It returns an error if
  38461. // the field is not defined in the schema, or if the type mismatched the field
  38462. // type.
  38463. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  38464. switch name {
  38465. case workexperience.FieldOrganizationID:
  38466. v, ok := value.(int64)
  38467. if !ok {
  38468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38469. }
  38470. m.AddOrganizationID(v)
  38471. return nil
  38472. }
  38473. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  38474. }
  38475. // ClearedFields returns all nullable fields that were cleared during this
  38476. // mutation.
  38477. func (m *WorkExperienceMutation) ClearedFields() []string {
  38478. var fields []string
  38479. if m.FieldCleared(workexperience.FieldDeletedAt) {
  38480. fields = append(fields, workexperience.FieldDeletedAt)
  38481. }
  38482. return fields
  38483. }
  38484. // FieldCleared returns a boolean indicating if a field with the given name was
  38485. // cleared in this mutation.
  38486. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  38487. _, ok := m.clearedFields[name]
  38488. return ok
  38489. }
  38490. // ClearField clears the value of the field with the given name. It returns an
  38491. // error if the field is not defined in the schema.
  38492. func (m *WorkExperienceMutation) ClearField(name string) error {
  38493. switch name {
  38494. case workexperience.FieldDeletedAt:
  38495. m.ClearDeletedAt()
  38496. return nil
  38497. }
  38498. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  38499. }
  38500. // ResetField resets all changes in the mutation for the field with the given name.
  38501. // It returns an error if the field is not defined in the schema.
  38502. func (m *WorkExperienceMutation) ResetField(name string) error {
  38503. switch name {
  38504. case workexperience.FieldCreatedAt:
  38505. m.ResetCreatedAt()
  38506. return nil
  38507. case workexperience.FieldUpdatedAt:
  38508. m.ResetUpdatedAt()
  38509. return nil
  38510. case workexperience.FieldDeletedAt:
  38511. m.ResetDeletedAt()
  38512. return nil
  38513. case workexperience.FieldEmployeeID:
  38514. m.ResetEmployeeID()
  38515. return nil
  38516. case workexperience.FieldStartDate:
  38517. m.ResetStartDate()
  38518. return nil
  38519. case workexperience.FieldEndDate:
  38520. m.ResetEndDate()
  38521. return nil
  38522. case workexperience.FieldCompany:
  38523. m.ResetCompany()
  38524. return nil
  38525. case workexperience.FieldExperience:
  38526. m.ResetExperience()
  38527. return nil
  38528. case workexperience.FieldOrganizationID:
  38529. m.ResetOrganizationID()
  38530. return nil
  38531. }
  38532. return fmt.Errorf("unknown WorkExperience field %s", name)
  38533. }
  38534. // AddedEdges returns all edge names that were set/added in this mutation.
  38535. func (m *WorkExperienceMutation) AddedEdges() []string {
  38536. edges := make([]string, 0, 1)
  38537. if m.employee != nil {
  38538. edges = append(edges, workexperience.EdgeEmployee)
  38539. }
  38540. return edges
  38541. }
  38542. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38543. // name in this mutation.
  38544. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  38545. switch name {
  38546. case workexperience.EdgeEmployee:
  38547. if id := m.employee; id != nil {
  38548. return []ent.Value{*id}
  38549. }
  38550. }
  38551. return nil
  38552. }
  38553. // RemovedEdges returns all edge names that were removed in this mutation.
  38554. func (m *WorkExperienceMutation) RemovedEdges() []string {
  38555. edges := make([]string, 0, 1)
  38556. return edges
  38557. }
  38558. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38559. // the given name in this mutation.
  38560. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  38561. return nil
  38562. }
  38563. // ClearedEdges returns all edge names that were cleared in this mutation.
  38564. func (m *WorkExperienceMutation) ClearedEdges() []string {
  38565. edges := make([]string, 0, 1)
  38566. if m.clearedemployee {
  38567. edges = append(edges, workexperience.EdgeEmployee)
  38568. }
  38569. return edges
  38570. }
  38571. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38572. // was cleared in this mutation.
  38573. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  38574. switch name {
  38575. case workexperience.EdgeEmployee:
  38576. return m.clearedemployee
  38577. }
  38578. return false
  38579. }
  38580. // ClearEdge clears the value of the edge with the given name. It returns an error
  38581. // if that edge is not defined in the schema.
  38582. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  38583. switch name {
  38584. case workexperience.EdgeEmployee:
  38585. m.ClearEmployee()
  38586. return nil
  38587. }
  38588. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  38589. }
  38590. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38591. // It returns an error if the edge is not defined in the schema.
  38592. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  38593. switch name {
  38594. case workexperience.EdgeEmployee:
  38595. m.ResetEmployee()
  38596. return nil
  38597. }
  38598. return fmt.Errorf("unknown WorkExperience edge %s", name)
  38599. }
  38600. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  38601. type WpChatroomMutation struct {
  38602. config
  38603. op Op
  38604. typ string
  38605. id *uint64
  38606. created_at *time.Time
  38607. updated_at *time.Time
  38608. status *uint8
  38609. addstatus *int8
  38610. wx_wxid *string
  38611. chatroom_id *string
  38612. nickname *string
  38613. owner *string
  38614. avatar *string
  38615. member_list *[]string
  38616. appendmember_list []string
  38617. clearedFields map[string]struct{}
  38618. done bool
  38619. oldValue func(context.Context) (*WpChatroom, error)
  38620. predicates []predicate.WpChatroom
  38621. }
  38622. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  38623. // wpchatroomOption allows management of the mutation configuration using functional options.
  38624. type wpchatroomOption func(*WpChatroomMutation)
  38625. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  38626. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  38627. m := &WpChatroomMutation{
  38628. config: c,
  38629. op: op,
  38630. typ: TypeWpChatroom,
  38631. clearedFields: make(map[string]struct{}),
  38632. }
  38633. for _, opt := range opts {
  38634. opt(m)
  38635. }
  38636. return m
  38637. }
  38638. // withWpChatroomID sets the ID field of the mutation.
  38639. func withWpChatroomID(id uint64) wpchatroomOption {
  38640. return func(m *WpChatroomMutation) {
  38641. var (
  38642. err error
  38643. once sync.Once
  38644. value *WpChatroom
  38645. )
  38646. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  38647. once.Do(func() {
  38648. if m.done {
  38649. err = errors.New("querying old values post mutation is not allowed")
  38650. } else {
  38651. value, err = m.Client().WpChatroom.Get(ctx, id)
  38652. }
  38653. })
  38654. return value, err
  38655. }
  38656. m.id = &id
  38657. }
  38658. }
  38659. // withWpChatroom sets the old WpChatroom of the mutation.
  38660. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  38661. return func(m *WpChatroomMutation) {
  38662. m.oldValue = func(context.Context) (*WpChatroom, error) {
  38663. return node, nil
  38664. }
  38665. m.id = &node.ID
  38666. }
  38667. }
  38668. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38669. // executed in a transaction (ent.Tx), a transactional client is returned.
  38670. func (m WpChatroomMutation) Client() *Client {
  38671. client := &Client{config: m.config}
  38672. client.init()
  38673. return client
  38674. }
  38675. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38676. // it returns an error otherwise.
  38677. func (m WpChatroomMutation) Tx() (*Tx, error) {
  38678. if _, ok := m.driver.(*txDriver); !ok {
  38679. return nil, errors.New("ent: mutation is not running in a transaction")
  38680. }
  38681. tx := &Tx{config: m.config}
  38682. tx.init()
  38683. return tx, nil
  38684. }
  38685. // SetID sets the value of the id field. Note that this
  38686. // operation is only accepted on creation of WpChatroom entities.
  38687. func (m *WpChatroomMutation) SetID(id uint64) {
  38688. m.id = &id
  38689. }
  38690. // ID returns the ID value in the mutation. Note that the ID is only available
  38691. // if it was provided to the builder or after it was returned from the database.
  38692. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  38693. if m.id == nil {
  38694. return
  38695. }
  38696. return *m.id, true
  38697. }
  38698. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38699. // That means, if the mutation is applied within a transaction with an isolation level such
  38700. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38701. // or updated by the mutation.
  38702. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  38703. switch {
  38704. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38705. id, exists := m.ID()
  38706. if exists {
  38707. return []uint64{id}, nil
  38708. }
  38709. fallthrough
  38710. case m.op.Is(OpUpdate | OpDelete):
  38711. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  38712. default:
  38713. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38714. }
  38715. }
  38716. // SetCreatedAt sets the "created_at" field.
  38717. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  38718. m.created_at = &t
  38719. }
  38720. // CreatedAt returns the value of the "created_at" field in the mutation.
  38721. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  38722. v := m.created_at
  38723. if v == nil {
  38724. return
  38725. }
  38726. return *v, true
  38727. }
  38728. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  38729. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38731. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38732. if !m.op.Is(OpUpdateOne) {
  38733. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38734. }
  38735. if m.id == nil || m.oldValue == nil {
  38736. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38737. }
  38738. oldValue, err := m.oldValue(ctx)
  38739. if err != nil {
  38740. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38741. }
  38742. return oldValue.CreatedAt, nil
  38743. }
  38744. // ResetCreatedAt resets all changes to the "created_at" field.
  38745. func (m *WpChatroomMutation) ResetCreatedAt() {
  38746. m.created_at = nil
  38747. }
  38748. // SetUpdatedAt sets the "updated_at" field.
  38749. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  38750. m.updated_at = &t
  38751. }
  38752. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38753. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  38754. v := m.updated_at
  38755. if v == nil {
  38756. return
  38757. }
  38758. return *v, true
  38759. }
  38760. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  38761. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38763. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38764. if !m.op.Is(OpUpdateOne) {
  38765. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38766. }
  38767. if m.id == nil || m.oldValue == nil {
  38768. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38769. }
  38770. oldValue, err := m.oldValue(ctx)
  38771. if err != nil {
  38772. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38773. }
  38774. return oldValue.UpdatedAt, nil
  38775. }
  38776. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38777. func (m *WpChatroomMutation) ResetUpdatedAt() {
  38778. m.updated_at = nil
  38779. }
  38780. // SetStatus sets the "status" field.
  38781. func (m *WpChatroomMutation) SetStatus(u uint8) {
  38782. m.status = &u
  38783. m.addstatus = nil
  38784. }
  38785. // Status returns the value of the "status" field in the mutation.
  38786. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  38787. v := m.status
  38788. if v == nil {
  38789. return
  38790. }
  38791. return *v, true
  38792. }
  38793. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  38794. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38796. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38797. if !m.op.Is(OpUpdateOne) {
  38798. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38799. }
  38800. if m.id == nil || m.oldValue == nil {
  38801. return v, errors.New("OldStatus requires an ID field in the mutation")
  38802. }
  38803. oldValue, err := m.oldValue(ctx)
  38804. if err != nil {
  38805. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38806. }
  38807. return oldValue.Status, nil
  38808. }
  38809. // AddStatus adds u to the "status" field.
  38810. func (m *WpChatroomMutation) AddStatus(u int8) {
  38811. if m.addstatus != nil {
  38812. *m.addstatus += u
  38813. } else {
  38814. m.addstatus = &u
  38815. }
  38816. }
  38817. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38818. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  38819. v := m.addstatus
  38820. if v == nil {
  38821. return
  38822. }
  38823. return *v, true
  38824. }
  38825. // ClearStatus clears the value of the "status" field.
  38826. func (m *WpChatroomMutation) ClearStatus() {
  38827. m.status = nil
  38828. m.addstatus = nil
  38829. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  38830. }
  38831. // StatusCleared returns if the "status" field was cleared in this mutation.
  38832. func (m *WpChatroomMutation) StatusCleared() bool {
  38833. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  38834. return ok
  38835. }
  38836. // ResetStatus resets all changes to the "status" field.
  38837. func (m *WpChatroomMutation) ResetStatus() {
  38838. m.status = nil
  38839. m.addstatus = nil
  38840. delete(m.clearedFields, wpchatroom.FieldStatus)
  38841. }
  38842. // SetWxWxid sets the "wx_wxid" field.
  38843. func (m *WpChatroomMutation) SetWxWxid(s string) {
  38844. m.wx_wxid = &s
  38845. }
  38846. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  38847. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  38848. v := m.wx_wxid
  38849. if v == nil {
  38850. return
  38851. }
  38852. return *v, true
  38853. }
  38854. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  38855. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38857. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  38858. if !m.op.Is(OpUpdateOne) {
  38859. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  38860. }
  38861. if m.id == nil || m.oldValue == nil {
  38862. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  38863. }
  38864. oldValue, err := m.oldValue(ctx)
  38865. if err != nil {
  38866. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  38867. }
  38868. return oldValue.WxWxid, nil
  38869. }
  38870. // ResetWxWxid resets all changes to the "wx_wxid" field.
  38871. func (m *WpChatroomMutation) ResetWxWxid() {
  38872. m.wx_wxid = nil
  38873. }
  38874. // SetChatroomID sets the "chatroom_id" field.
  38875. func (m *WpChatroomMutation) SetChatroomID(s string) {
  38876. m.chatroom_id = &s
  38877. }
  38878. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  38879. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  38880. v := m.chatroom_id
  38881. if v == nil {
  38882. return
  38883. }
  38884. return *v, true
  38885. }
  38886. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  38887. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38889. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  38890. if !m.op.Is(OpUpdateOne) {
  38891. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  38892. }
  38893. if m.id == nil || m.oldValue == nil {
  38894. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  38895. }
  38896. oldValue, err := m.oldValue(ctx)
  38897. if err != nil {
  38898. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  38899. }
  38900. return oldValue.ChatroomID, nil
  38901. }
  38902. // ResetChatroomID resets all changes to the "chatroom_id" field.
  38903. func (m *WpChatroomMutation) ResetChatroomID() {
  38904. m.chatroom_id = nil
  38905. }
  38906. // SetNickname sets the "nickname" field.
  38907. func (m *WpChatroomMutation) SetNickname(s string) {
  38908. m.nickname = &s
  38909. }
  38910. // Nickname returns the value of the "nickname" field in the mutation.
  38911. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  38912. v := m.nickname
  38913. if v == nil {
  38914. return
  38915. }
  38916. return *v, true
  38917. }
  38918. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  38919. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38921. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  38922. if !m.op.Is(OpUpdateOne) {
  38923. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  38924. }
  38925. if m.id == nil || m.oldValue == nil {
  38926. return v, errors.New("OldNickname requires an ID field in the mutation")
  38927. }
  38928. oldValue, err := m.oldValue(ctx)
  38929. if err != nil {
  38930. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  38931. }
  38932. return oldValue.Nickname, nil
  38933. }
  38934. // ResetNickname resets all changes to the "nickname" field.
  38935. func (m *WpChatroomMutation) ResetNickname() {
  38936. m.nickname = nil
  38937. }
  38938. // SetOwner sets the "owner" field.
  38939. func (m *WpChatroomMutation) SetOwner(s string) {
  38940. m.owner = &s
  38941. }
  38942. // Owner returns the value of the "owner" field in the mutation.
  38943. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  38944. v := m.owner
  38945. if v == nil {
  38946. return
  38947. }
  38948. return *v, true
  38949. }
  38950. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  38951. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38953. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  38954. if !m.op.Is(OpUpdateOne) {
  38955. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  38956. }
  38957. if m.id == nil || m.oldValue == nil {
  38958. return v, errors.New("OldOwner requires an ID field in the mutation")
  38959. }
  38960. oldValue, err := m.oldValue(ctx)
  38961. if err != nil {
  38962. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  38963. }
  38964. return oldValue.Owner, nil
  38965. }
  38966. // ResetOwner resets all changes to the "owner" field.
  38967. func (m *WpChatroomMutation) ResetOwner() {
  38968. m.owner = nil
  38969. }
  38970. // SetAvatar sets the "avatar" field.
  38971. func (m *WpChatroomMutation) SetAvatar(s string) {
  38972. m.avatar = &s
  38973. }
  38974. // Avatar returns the value of the "avatar" field in the mutation.
  38975. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  38976. v := m.avatar
  38977. if v == nil {
  38978. return
  38979. }
  38980. return *v, true
  38981. }
  38982. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  38983. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38985. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  38986. if !m.op.Is(OpUpdateOne) {
  38987. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  38988. }
  38989. if m.id == nil || m.oldValue == nil {
  38990. return v, errors.New("OldAvatar requires an ID field in the mutation")
  38991. }
  38992. oldValue, err := m.oldValue(ctx)
  38993. if err != nil {
  38994. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  38995. }
  38996. return oldValue.Avatar, nil
  38997. }
  38998. // ResetAvatar resets all changes to the "avatar" field.
  38999. func (m *WpChatroomMutation) ResetAvatar() {
  39000. m.avatar = nil
  39001. }
  39002. // SetMemberList sets the "member_list" field.
  39003. func (m *WpChatroomMutation) SetMemberList(s []string) {
  39004. m.member_list = &s
  39005. m.appendmember_list = nil
  39006. }
  39007. // MemberList returns the value of the "member_list" field in the mutation.
  39008. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  39009. v := m.member_list
  39010. if v == nil {
  39011. return
  39012. }
  39013. return *v, true
  39014. }
  39015. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  39016. // If the WpChatroom 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 *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  39019. if !m.op.Is(OpUpdateOne) {
  39020. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  39021. }
  39022. if m.id == nil || m.oldValue == nil {
  39023. return v, errors.New("OldMemberList 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 OldMemberList: %w", err)
  39028. }
  39029. return oldValue.MemberList, nil
  39030. }
  39031. // AppendMemberList adds s to the "member_list" field.
  39032. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  39033. m.appendmember_list = append(m.appendmember_list, s...)
  39034. }
  39035. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  39036. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  39037. if len(m.appendmember_list) == 0 {
  39038. return nil, false
  39039. }
  39040. return m.appendmember_list, true
  39041. }
  39042. // ResetMemberList resets all changes to the "member_list" field.
  39043. func (m *WpChatroomMutation) ResetMemberList() {
  39044. m.member_list = nil
  39045. m.appendmember_list = nil
  39046. }
  39047. // Where appends a list predicates to the WpChatroomMutation builder.
  39048. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  39049. m.predicates = append(m.predicates, ps...)
  39050. }
  39051. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  39052. // users can use type-assertion to append predicates that do not depend on any generated package.
  39053. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  39054. p := make([]predicate.WpChatroom, len(ps))
  39055. for i := range ps {
  39056. p[i] = ps[i]
  39057. }
  39058. m.Where(p...)
  39059. }
  39060. // Op returns the operation name.
  39061. func (m *WpChatroomMutation) Op() Op {
  39062. return m.op
  39063. }
  39064. // SetOp allows setting the mutation operation.
  39065. func (m *WpChatroomMutation) SetOp(op Op) {
  39066. m.op = op
  39067. }
  39068. // Type returns the node type of this mutation (WpChatroom).
  39069. func (m *WpChatroomMutation) Type() string {
  39070. return m.typ
  39071. }
  39072. // Fields returns all fields that were changed during this mutation. Note that in
  39073. // order to get all numeric fields that were incremented/decremented, call
  39074. // AddedFields().
  39075. func (m *WpChatroomMutation) Fields() []string {
  39076. fields := make([]string, 0, 9)
  39077. if m.created_at != nil {
  39078. fields = append(fields, wpchatroom.FieldCreatedAt)
  39079. }
  39080. if m.updated_at != nil {
  39081. fields = append(fields, wpchatroom.FieldUpdatedAt)
  39082. }
  39083. if m.status != nil {
  39084. fields = append(fields, wpchatroom.FieldStatus)
  39085. }
  39086. if m.wx_wxid != nil {
  39087. fields = append(fields, wpchatroom.FieldWxWxid)
  39088. }
  39089. if m.chatroom_id != nil {
  39090. fields = append(fields, wpchatroom.FieldChatroomID)
  39091. }
  39092. if m.nickname != nil {
  39093. fields = append(fields, wpchatroom.FieldNickname)
  39094. }
  39095. if m.owner != nil {
  39096. fields = append(fields, wpchatroom.FieldOwner)
  39097. }
  39098. if m.avatar != nil {
  39099. fields = append(fields, wpchatroom.FieldAvatar)
  39100. }
  39101. if m.member_list != nil {
  39102. fields = append(fields, wpchatroom.FieldMemberList)
  39103. }
  39104. return fields
  39105. }
  39106. // Field returns the value of a field with the given name. The second boolean
  39107. // return value indicates that this field was not set, or was not defined in the
  39108. // schema.
  39109. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  39110. switch name {
  39111. case wpchatroom.FieldCreatedAt:
  39112. return m.CreatedAt()
  39113. case wpchatroom.FieldUpdatedAt:
  39114. return m.UpdatedAt()
  39115. case wpchatroom.FieldStatus:
  39116. return m.Status()
  39117. case wpchatroom.FieldWxWxid:
  39118. return m.WxWxid()
  39119. case wpchatroom.FieldChatroomID:
  39120. return m.ChatroomID()
  39121. case wpchatroom.FieldNickname:
  39122. return m.Nickname()
  39123. case wpchatroom.FieldOwner:
  39124. return m.Owner()
  39125. case wpchatroom.FieldAvatar:
  39126. return m.Avatar()
  39127. case wpchatroom.FieldMemberList:
  39128. return m.MemberList()
  39129. }
  39130. return nil, false
  39131. }
  39132. // OldField returns the old value of the field from the database. An error is
  39133. // returned if the mutation operation is not UpdateOne, or the query to the
  39134. // database failed.
  39135. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39136. switch name {
  39137. case wpchatroom.FieldCreatedAt:
  39138. return m.OldCreatedAt(ctx)
  39139. case wpchatroom.FieldUpdatedAt:
  39140. return m.OldUpdatedAt(ctx)
  39141. case wpchatroom.FieldStatus:
  39142. return m.OldStatus(ctx)
  39143. case wpchatroom.FieldWxWxid:
  39144. return m.OldWxWxid(ctx)
  39145. case wpchatroom.FieldChatroomID:
  39146. return m.OldChatroomID(ctx)
  39147. case wpchatroom.FieldNickname:
  39148. return m.OldNickname(ctx)
  39149. case wpchatroom.FieldOwner:
  39150. return m.OldOwner(ctx)
  39151. case wpchatroom.FieldAvatar:
  39152. return m.OldAvatar(ctx)
  39153. case wpchatroom.FieldMemberList:
  39154. return m.OldMemberList(ctx)
  39155. }
  39156. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  39157. }
  39158. // SetField sets the value of a field with the given name. It returns an error if
  39159. // the field is not defined in the schema, or if the type mismatched the field
  39160. // type.
  39161. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  39162. switch name {
  39163. case wpchatroom.FieldCreatedAt:
  39164. v, ok := value.(time.Time)
  39165. if !ok {
  39166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39167. }
  39168. m.SetCreatedAt(v)
  39169. return nil
  39170. case wpchatroom.FieldUpdatedAt:
  39171. v, ok := value.(time.Time)
  39172. if !ok {
  39173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39174. }
  39175. m.SetUpdatedAt(v)
  39176. return nil
  39177. case wpchatroom.FieldStatus:
  39178. v, ok := value.(uint8)
  39179. if !ok {
  39180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39181. }
  39182. m.SetStatus(v)
  39183. return nil
  39184. case wpchatroom.FieldWxWxid:
  39185. v, ok := value.(string)
  39186. if !ok {
  39187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39188. }
  39189. m.SetWxWxid(v)
  39190. return nil
  39191. case wpchatroom.FieldChatroomID:
  39192. v, ok := value.(string)
  39193. if !ok {
  39194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39195. }
  39196. m.SetChatroomID(v)
  39197. return nil
  39198. case wpchatroom.FieldNickname:
  39199. v, ok := value.(string)
  39200. if !ok {
  39201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39202. }
  39203. m.SetNickname(v)
  39204. return nil
  39205. case wpchatroom.FieldOwner:
  39206. v, ok := value.(string)
  39207. if !ok {
  39208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39209. }
  39210. m.SetOwner(v)
  39211. return nil
  39212. case wpchatroom.FieldAvatar:
  39213. v, ok := value.(string)
  39214. if !ok {
  39215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39216. }
  39217. m.SetAvatar(v)
  39218. return nil
  39219. case wpchatroom.FieldMemberList:
  39220. v, ok := value.([]string)
  39221. if !ok {
  39222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39223. }
  39224. m.SetMemberList(v)
  39225. return nil
  39226. }
  39227. return fmt.Errorf("unknown WpChatroom field %s", name)
  39228. }
  39229. // AddedFields returns all numeric fields that were incremented/decremented during
  39230. // this mutation.
  39231. func (m *WpChatroomMutation) AddedFields() []string {
  39232. var fields []string
  39233. if m.addstatus != nil {
  39234. fields = append(fields, wpchatroom.FieldStatus)
  39235. }
  39236. return fields
  39237. }
  39238. // AddedField returns the numeric value that was incremented/decremented on a field
  39239. // with the given name. The second boolean return value indicates that this field
  39240. // was not set, or was not defined in the schema.
  39241. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  39242. switch name {
  39243. case wpchatroom.FieldStatus:
  39244. return m.AddedStatus()
  39245. }
  39246. return nil, false
  39247. }
  39248. // AddField adds the value to the field with the given name. It returns an error if
  39249. // the field is not defined in the schema, or if the type mismatched the field
  39250. // type.
  39251. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  39252. switch name {
  39253. case wpchatroom.FieldStatus:
  39254. v, ok := value.(int8)
  39255. if !ok {
  39256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39257. }
  39258. m.AddStatus(v)
  39259. return nil
  39260. }
  39261. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  39262. }
  39263. // ClearedFields returns all nullable fields that were cleared during this
  39264. // mutation.
  39265. func (m *WpChatroomMutation) ClearedFields() []string {
  39266. var fields []string
  39267. if m.FieldCleared(wpchatroom.FieldStatus) {
  39268. fields = append(fields, wpchatroom.FieldStatus)
  39269. }
  39270. return fields
  39271. }
  39272. // FieldCleared returns a boolean indicating if a field with the given name was
  39273. // cleared in this mutation.
  39274. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  39275. _, ok := m.clearedFields[name]
  39276. return ok
  39277. }
  39278. // ClearField clears the value of the field with the given name. It returns an
  39279. // error if the field is not defined in the schema.
  39280. func (m *WpChatroomMutation) ClearField(name string) error {
  39281. switch name {
  39282. case wpchatroom.FieldStatus:
  39283. m.ClearStatus()
  39284. return nil
  39285. }
  39286. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  39287. }
  39288. // ResetField resets all changes in the mutation for the field with the given name.
  39289. // It returns an error if the field is not defined in the schema.
  39290. func (m *WpChatroomMutation) ResetField(name string) error {
  39291. switch name {
  39292. case wpchatroom.FieldCreatedAt:
  39293. m.ResetCreatedAt()
  39294. return nil
  39295. case wpchatroom.FieldUpdatedAt:
  39296. m.ResetUpdatedAt()
  39297. return nil
  39298. case wpchatroom.FieldStatus:
  39299. m.ResetStatus()
  39300. return nil
  39301. case wpchatroom.FieldWxWxid:
  39302. m.ResetWxWxid()
  39303. return nil
  39304. case wpchatroom.FieldChatroomID:
  39305. m.ResetChatroomID()
  39306. return nil
  39307. case wpchatroom.FieldNickname:
  39308. m.ResetNickname()
  39309. return nil
  39310. case wpchatroom.FieldOwner:
  39311. m.ResetOwner()
  39312. return nil
  39313. case wpchatroom.FieldAvatar:
  39314. m.ResetAvatar()
  39315. return nil
  39316. case wpchatroom.FieldMemberList:
  39317. m.ResetMemberList()
  39318. return nil
  39319. }
  39320. return fmt.Errorf("unknown WpChatroom field %s", name)
  39321. }
  39322. // AddedEdges returns all edge names that were set/added in this mutation.
  39323. func (m *WpChatroomMutation) AddedEdges() []string {
  39324. edges := make([]string, 0, 0)
  39325. return edges
  39326. }
  39327. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39328. // name in this mutation.
  39329. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  39330. return nil
  39331. }
  39332. // RemovedEdges returns all edge names that were removed in this mutation.
  39333. func (m *WpChatroomMutation) RemovedEdges() []string {
  39334. edges := make([]string, 0, 0)
  39335. return edges
  39336. }
  39337. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39338. // the given name in this mutation.
  39339. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  39340. return nil
  39341. }
  39342. // ClearedEdges returns all edge names that were cleared in this mutation.
  39343. func (m *WpChatroomMutation) ClearedEdges() []string {
  39344. edges := make([]string, 0, 0)
  39345. return edges
  39346. }
  39347. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39348. // was cleared in this mutation.
  39349. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  39350. return false
  39351. }
  39352. // ClearEdge clears the value of the edge with the given name. It returns an error
  39353. // if that edge is not defined in the schema.
  39354. func (m *WpChatroomMutation) ClearEdge(name string) error {
  39355. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  39356. }
  39357. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39358. // It returns an error if the edge is not defined in the schema.
  39359. func (m *WpChatroomMutation) ResetEdge(name string) error {
  39360. return fmt.Errorf("unknown WpChatroom edge %s", name)
  39361. }
  39362. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  39363. type WpChatroomMemberMutation struct {
  39364. config
  39365. op Op
  39366. typ string
  39367. id *uint64
  39368. created_at *time.Time
  39369. updated_at *time.Time
  39370. status *uint8
  39371. addstatus *int8
  39372. wx_wxid *string
  39373. wxid *string
  39374. nickname *string
  39375. avatar *string
  39376. clearedFields map[string]struct{}
  39377. done bool
  39378. oldValue func(context.Context) (*WpChatroomMember, error)
  39379. predicates []predicate.WpChatroomMember
  39380. }
  39381. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  39382. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  39383. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  39384. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  39385. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  39386. m := &WpChatroomMemberMutation{
  39387. config: c,
  39388. op: op,
  39389. typ: TypeWpChatroomMember,
  39390. clearedFields: make(map[string]struct{}),
  39391. }
  39392. for _, opt := range opts {
  39393. opt(m)
  39394. }
  39395. return m
  39396. }
  39397. // withWpChatroomMemberID sets the ID field of the mutation.
  39398. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  39399. return func(m *WpChatroomMemberMutation) {
  39400. var (
  39401. err error
  39402. once sync.Once
  39403. value *WpChatroomMember
  39404. )
  39405. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  39406. once.Do(func() {
  39407. if m.done {
  39408. err = errors.New("querying old values post mutation is not allowed")
  39409. } else {
  39410. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  39411. }
  39412. })
  39413. return value, err
  39414. }
  39415. m.id = &id
  39416. }
  39417. }
  39418. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  39419. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  39420. return func(m *WpChatroomMemberMutation) {
  39421. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  39422. return node, nil
  39423. }
  39424. m.id = &node.ID
  39425. }
  39426. }
  39427. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39428. // executed in a transaction (ent.Tx), a transactional client is returned.
  39429. func (m WpChatroomMemberMutation) Client() *Client {
  39430. client := &Client{config: m.config}
  39431. client.init()
  39432. return client
  39433. }
  39434. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39435. // it returns an error otherwise.
  39436. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  39437. if _, ok := m.driver.(*txDriver); !ok {
  39438. return nil, errors.New("ent: mutation is not running in a transaction")
  39439. }
  39440. tx := &Tx{config: m.config}
  39441. tx.init()
  39442. return tx, nil
  39443. }
  39444. // SetID sets the value of the id field. Note that this
  39445. // operation is only accepted on creation of WpChatroomMember entities.
  39446. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  39447. m.id = &id
  39448. }
  39449. // ID returns the ID value in the mutation. Note that the ID is only available
  39450. // if it was provided to the builder or after it was returned from the database.
  39451. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  39452. if m.id == nil {
  39453. return
  39454. }
  39455. return *m.id, true
  39456. }
  39457. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39458. // That means, if the mutation is applied within a transaction with an isolation level such
  39459. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39460. // or updated by the mutation.
  39461. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  39462. switch {
  39463. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39464. id, exists := m.ID()
  39465. if exists {
  39466. return []uint64{id}, nil
  39467. }
  39468. fallthrough
  39469. case m.op.Is(OpUpdate | OpDelete):
  39470. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  39471. default:
  39472. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39473. }
  39474. }
  39475. // SetCreatedAt sets the "created_at" field.
  39476. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  39477. m.created_at = &t
  39478. }
  39479. // CreatedAt returns the value of the "created_at" field in the mutation.
  39480. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  39481. v := m.created_at
  39482. if v == nil {
  39483. return
  39484. }
  39485. return *v, true
  39486. }
  39487. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  39488. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39490. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39491. if !m.op.Is(OpUpdateOne) {
  39492. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39493. }
  39494. if m.id == nil || m.oldValue == nil {
  39495. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39496. }
  39497. oldValue, err := m.oldValue(ctx)
  39498. if err != nil {
  39499. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39500. }
  39501. return oldValue.CreatedAt, nil
  39502. }
  39503. // ResetCreatedAt resets all changes to the "created_at" field.
  39504. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  39505. m.created_at = nil
  39506. }
  39507. // SetUpdatedAt sets the "updated_at" field.
  39508. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  39509. m.updated_at = &t
  39510. }
  39511. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39512. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  39513. v := m.updated_at
  39514. if v == nil {
  39515. return
  39516. }
  39517. return *v, true
  39518. }
  39519. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  39520. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39522. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39523. if !m.op.Is(OpUpdateOne) {
  39524. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39525. }
  39526. if m.id == nil || m.oldValue == nil {
  39527. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39528. }
  39529. oldValue, err := m.oldValue(ctx)
  39530. if err != nil {
  39531. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39532. }
  39533. return oldValue.UpdatedAt, nil
  39534. }
  39535. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39536. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  39537. m.updated_at = nil
  39538. }
  39539. // SetStatus sets the "status" field.
  39540. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  39541. m.status = &u
  39542. m.addstatus = nil
  39543. }
  39544. // Status returns the value of the "status" field in the mutation.
  39545. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  39546. v := m.status
  39547. if v == nil {
  39548. return
  39549. }
  39550. return *v, true
  39551. }
  39552. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  39553. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39555. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39556. if !m.op.Is(OpUpdateOne) {
  39557. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39558. }
  39559. if m.id == nil || m.oldValue == nil {
  39560. return v, errors.New("OldStatus requires an ID field in the mutation")
  39561. }
  39562. oldValue, err := m.oldValue(ctx)
  39563. if err != nil {
  39564. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39565. }
  39566. return oldValue.Status, nil
  39567. }
  39568. // AddStatus adds u to the "status" field.
  39569. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  39570. if m.addstatus != nil {
  39571. *m.addstatus += u
  39572. } else {
  39573. m.addstatus = &u
  39574. }
  39575. }
  39576. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39577. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  39578. v := m.addstatus
  39579. if v == nil {
  39580. return
  39581. }
  39582. return *v, true
  39583. }
  39584. // ClearStatus clears the value of the "status" field.
  39585. func (m *WpChatroomMemberMutation) ClearStatus() {
  39586. m.status = nil
  39587. m.addstatus = nil
  39588. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  39589. }
  39590. // StatusCleared returns if the "status" field was cleared in this mutation.
  39591. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  39592. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  39593. return ok
  39594. }
  39595. // ResetStatus resets all changes to the "status" field.
  39596. func (m *WpChatroomMemberMutation) ResetStatus() {
  39597. m.status = nil
  39598. m.addstatus = nil
  39599. delete(m.clearedFields, wpchatroommember.FieldStatus)
  39600. }
  39601. // SetWxWxid sets the "wx_wxid" field.
  39602. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  39603. m.wx_wxid = &s
  39604. }
  39605. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  39606. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  39607. v := m.wx_wxid
  39608. if v == nil {
  39609. return
  39610. }
  39611. return *v, true
  39612. }
  39613. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  39614. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39616. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  39617. if !m.op.Is(OpUpdateOne) {
  39618. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  39619. }
  39620. if m.id == nil || m.oldValue == nil {
  39621. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  39622. }
  39623. oldValue, err := m.oldValue(ctx)
  39624. if err != nil {
  39625. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  39626. }
  39627. return oldValue.WxWxid, nil
  39628. }
  39629. // ResetWxWxid resets all changes to the "wx_wxid" field.
  39630. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  39631. m.wx_wxid = nil
  39632. }
  39633. // SetWxid sets the "wxid" field.
  39634. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  39635. m.wxid = &s
  39636. }
  39637. // Wxid returns the value of the "wxid" field in the mutation.
  39638. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  39639. v := m.wxid
  39640. if v == nil {
  39641. return
  39642. }
  39643. return *v, true
  39644. }
  39645. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  39646. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39648. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  39649. if !m.op.Is(OpUpdateOne) {
  39650. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  39651. }
  39652. if m.id == nil || m.oldValue == nil {
  39653. return v, errors.New("OldWxid requires an ID field in the mutation")
  39654. }
  39655. oldValue, err := m.oldValue(ctx)
  39656. if err != nil {
  39657. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  39658. }
  39659. return oldValue.Wxid, nil
  39660. }
  39661. // ResetWxid resets all changes to the "wxid" field.
  39662. func (m *WpChatroomMemberMutation) ResetWxid() {
  39663. m.wxid = nil
  39664. }
  39665. // SetNickname sets the "nickname" field.
  39666. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  39667. m.nickname = &s
  39668. }
  39669. // Nickname returns the value of the "nickname" field in the mutation.
  39670. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  39671. v := m.nickname
  39672. if v == nil {
  39673. return
  39674. }
  39675. return *v, true
  39676. }
  39677. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  39678. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39680. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  39681. if !m.op.Is(OpUpdateOne) {
  39682. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39683. }
  39684. if m.id == nil || m.oldValue == nil {
  39685. return v, errors.New("OldNickname requires an ID field in the mutation")
  39686. }
  39687. oldValue, err := m.oldValue(ctx)
  39688. if err != nil {
  39689. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39690. }
  39691. return oldValue.Nickname, nil
  39692. }
  39693. // ResetNickname resets all changes to the "nickname" field.
  39694. func (m *WpChatroomMemberMutation) ResetNickname() {
  39695. m.nickname = nil
  39696. }
  39697. // SetAvatar sets the "avatar" field.
  39698. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  39699. m.avatar = &s
  39700. }
  39701. // Avatar returns the value of the "avatar" field in the mutation.
  39702. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  39703. v := m.avatar
  39704. if v == nil {
  39705. return
  39706. }
  39707. return *v, true
  39708. }
  39709. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  39710. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39712. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39713. if !m.op.Is(OpUpdateOne) {
  39714. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39715. }
  39716. if m.id == nil || m.oldValue == nil {
  39717. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39718. }
  39719. oldValue, err := m.oldValue(ctx)
  39720. if err != nil {
  39721. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39722. }
  39723. return oldValue.Avatar, nil
  39724. }
  39725. // ResetAvatar resets all changes to the "avatar" field.
  39726. func (m *WpChatroomMemberMutation) ResetAvatar() {
  39727. m.avatar = nil
  39728. }
  39729. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  39730. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  39731. m.predicates = append(m.predicates, ps...)
  39732. }
  39733. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  39734. // users can use type-assertion to append predicates that do not depend on any generated package.
  39735. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  39736. p := make([]predicate.WpChatroomMember, len(ps))
  39737. for i := range ps {
  39738. p[i] = ps[i]
  39739. }
  39740. m.Where(p...)
  39741. }
  39742. // Op returns the operation name.
  39743. func (m *WpChatroomMemberMutation) Op() Op {
  39744. return m.op
  39745. }
  39746. // SetOp allows setting the mutation operation.
  39747. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  39748. m.op = op
  39749. }
  39750. // Type returns the node type of this mutation (WpChatroomMember).
  39751. func (m *WpChatroomMemberMutation) Type() string {
  39752. return m.typ
  39753. }
  39754. // Fields returns all fields that were changed during this mutation. Note that in
  39755. // order to get all numeric fields that were incremented/decremented, call
  39756. // AddedFields().
  39757. func (m *WpChatroomMemberMutation) Fields() []string {
  39758. fields := make([]string, 0, 7)
  39759. if m.created_at != nil {
  39760. fields = append(fields, wpchatroommember.FieldCreatedAt)
  39761. }
  39762. if m.updated_at != nil {
  39763. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  39764. }
  39765. if m.status != nil {
  39766. fields = append(fields, wpchatroommember.FieldStatus)
  39767. }
  39768. if m.wx_wxid != nil {
  39769. fields = append(fields, wpchatroommember.FieldWxWxid)
  39770. }
  39771. if m.wxid != nil {
  39772. fields = append(fields, wpchatroommember.FieldWxid)
  39773. }
  39774. if m.nickname != nil {
  39775. fields = append(fields, wpchatroommember.FieldNickname)
  39776. }
  39777. if m.avatar != nil {
  39778. fields = append(fields, wpchatroommember.FieldAvatar)
  39779. }
  39780. return fields
  39781. }
  39782. // Field returns the value of a field with the given name. The second boolean
  39783. // return value indicates that this field was not set, or was not defined in the
  39784. // schema.
  39785. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  39786. switch name {
  39787. case wpchatroommember.FieldCreatedAt:
  39788. return m.CreatedAt()
  39789. case wpchatroommember.FieldUpdatedAt:
  39790. return m.UpdatedAt()
  39791. case wpchatroommember.FieldStatus:
  39792. return m.Status()
  39793. case wpchatroommember.FieldWxWxid:
  39794. return m.WxWxid()
  39795. case wpchatroommember.FieldWxid:
  39796. return m.Wxid()
  39797. case wpchatroommember.FieldNickname:
  39798. return m.Nickname()
  39799. case wpchatroommember.FieldAvatar:
  39800. return m.Avatar()
  39801. }
  39802. return nil, false
  39803. }
  39804. // OldField returns the old value of the field from the database. An error is
  39805. // returned if the mutation operation is not UpdateOne, or the query to the
  39806. // database failed.
  39807. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39808. switch name {
  39809. case wpchatroommember.FieldCreatedAt:
  39810. return m.OldCreatedAt(ctx)
  39811. case wpchatroommember.FieldUpdatedAt:
  39812. return m.OldUpdatedAt(ctx)
  39813. case wpchatroommember.FieldStatus:
  39814. return m.OldStatus(ctx)
  39815. case wpchatroommember.FieldWxWxid:
  39816. return m.OldWxWxid(ctx)
  39817. case wpchatroommember.FieldWxid:
  39818. return m.OldWxid(ctx)
  39819. case wpchatroommember.FieldNickname:
  39820. return m.OldNickname(ctx)
  39821. case wpchatroommember.FieldAvatar:
  39822. return m.OldAvatar(ctx)
  39823. }
  39824. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  39825. }
  39826. // SetField sets the value of a field with the given name. It returns an error if
  39827. // the field is not defined in the schema, or if the type mismatched the field
  39828. // type.
  39829. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  39830. switch name {
  39831. case wpchatroommember.FieldCreatedAt:
  39832. v, ok := value.(time.Time)
  39833. if !ok {
  39834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39835. }
  39836. m.SetCreatedAt(v)
  39837. return nil
  39838. case wpchatroommember.FieldUpdatedAt:
  39839. v, ok := value.(time.Time)
  39840. if !ok {
  39841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39842. }
  39843. m.SetUpdatedAt(v)
  39844. return nil
  39845. case wpchatroommember.FieldStatus:
  39846. v, ok := value.(uint8)
  39847. if !ok {
  39848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39849. }
  39850. m.SetStatus(v)
  39851. return nil
  39852. case wpchatroommember.FieldWxWxid:
  39853. v, ok := value.(string)
  39854. if !ok {
  39855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39856. }
  39857. m.SetWxWxid(v)
  39858. return nil
  39859. case wpchatroommember.FieldWxid:
  39860. v, ok := value.(string)
  39861. if !ok {
  39862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39863. }
  39864. m.SetWxid(v)
  39865. return nil
  39866. case wpchatroommember.FieldNickname:
  39867. v, ok := value.(string)
  39868. if !ok {
  39869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39870. }
  39871. m.SetNickname(v)
  39872. return nil
  39873. case wpchatroommember.FieldAvatar:
  39874. v, ok := value.(string)
  39875. if !ok {
  39876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39877. }
  39878. m.SetAvatar(v)
  39879. return nil
  39880. }
  39881. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  39882. }
  39883. // AddedFields returns all numeric fields that were incremented/decremented during
  39884. // this mutation.
  39885. func (m *WpChatroomMemberMutation) AddedFields() []string {
  39886. var fields []string
  39887. if m.addstatus != nil {
  39888. fields = append(fields, wpchatroommember.FieldStatus)
  39889. }
  39890. return fields
  39891. }
  39892. // AddedField returns the numeric value that was incremented/decremented on a field
  39893. // with the given name. The second boolean return value indicates that this field
  39894. // was not set, or was not defined in the schema.
  39895. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  39896. switch name {
  39897. case wpchatroommember.FieldStatus:
  39898. return m.AddedStatus()
  39899. }
  39900. return nil, false
  39901. }
  39902. // AddField adds the value to the field with the given name. It returns an error if
  39903. // the field is not defined in the schema, or if the type mismatched the field
  39904. // type.
  39905. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  39906. switch name {
  39907. case wpchatroommember.FieldStatus:
  39908. v, ok := value.(int8)
  39909. if !ok {
  39910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39911. }
  39912. m.AddStatus(v)
  39913. return nil
  39914. }
  39915. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  39916. }
  39917. // ClearedFields returns all nullable fields that were cleared during this
  39918. // mutation.
  39919. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  39920. var fields []string
  39921. if m.FieldCleared(wpchatroommember.FieldStatus) {
  39922. fields = append(fields, wpchatroommember.FieldStatus)
  39923. }
  39924. return fields
  39925. }
  39926. // FieldCleared returns a boolean indicating if a field with the given name was
  39927. // cleared in this mutation.
  39928. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  39929. _, ok := m.clearedFields[name]
  39930. return ok
  39931. }
  39932. // ClearField clears the value of the field with the given name. It returns an
  39933. // error if the field is not defined in the schema.
  39934. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  39935. switch name {
  39936. case wpchatroommember.FieldStatus:
  39937. m.ClearStatus()
  39938. return nil
  39939. }
  39940. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  39941. }
  39942. // ResetField resets all changes in the mutation for the field with the given name.
  39943. // It returns an error if the field is not defined in the schema.
  39944. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  39945. switch name {
  39946. case wpchatroommember.FieldCreatedAt:
  39947. m.ResetCreatedAt()
  39948. return nil
  39949. case wpchatroommember.FieldUpdatedAt:
  39950. m.ResetUpdatedAt()
  39951. return nil
  39952. case wpchatroommember.FieldStatus:
  39953. m.ResetStatus()
  39954. return nil
  39955. case wpchatroommember.FieldWxWxid:
  39956. m.ResetWxWxid()
  39957. return nil
  39958. case wpchatroommember.FieldWxid:
  39959. m.ResetWxid()
  39960. return nil
  39961. case wpchatroommember.FieldNickname:
  39962. m.ResetNickname()
  39963. return nil
  39964. case wpchatroommember.FieldAvatar:
  39965. m.ResetAvatar()
  39966. return nil
  39967. }
  39968. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  39969. }
  39970. // AddedEdges returns all edge names that were set/added in this mutation.
  39971. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  39972. edges := make([]string, 0, 0)
  39973. return edges
  39974. }
  39975. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39976. // name in this mutation.
  39977. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  39978. return nil
  39979. }
  39980. // RemovedEdges returns all edge names that were removed in this mutation.
  39981. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  39982. edges := make([]string, 0, 0)
  39983. return edges
  39984. }
  39985. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39986. // the given name in this mutation.
  39987. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  39988. return nil
  39989. }
  39990. // ClearedEdges returns all edge names that were cleared in this mutation.
  39991. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  39992. edges := make([]string, 0, 0)
  39993. return edges
  39994. }
  39995. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39996. // was cleared in this mutation.
  39997. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  39998. return false
  39999. }
  40000. // ClearEdge clears the value of the edge with the given name. It returns an error
  40001. // if that edge is not defined in the schema.
  40002. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  40003. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  40004. }
  40005. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40006. // It returns an error if the edge is not defined in the schema.
  40007. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  40008. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  40009. }
  40010. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  40011. type WxMutation struct {
  40012. config
  40013. op Op
  40014. typ string
  40015. id *uint64
  40016. created_at *time.Time
  40017. updated_at *time.Time
  40018. status *uint8
  40019. addstatus *int8
  40020. deleted_at *time.Time
  40021. port *string
  40022. process_id *string
  40023. callback *string
  40024. wxid *string
  40025. account *string
  40026. nickname *string
  40027. tel *string
  40028. head_big *string
  40029. organization_id *uint64
  40030. addorganization_id *int64
  40031. api_base *string
  40032. api_key *string
  40033. allow_list *[]string
  40034. appendallow_list []string
  40035. group_allow_list *[]string
  40036. appendgroup_allow_list []string
  40037. block_list *[]string
  40038. appendblock_list []string
  40039. group_block_list *[]string
  40040. appendgroup_block_list []string
  40041. clearedFields map[string]struct{}
  40042. server *uint64
  40043. clearedserver bool
  40044. agent *uint64
  40045. clearedagent bool
  40046. done bool
  40047. oldValue func(context.Context) (*Wx, error)
  40048. predicates []predicate.Wx
  40049. }
  40050. var _ ent.Mutation = (*WxMutation)(nil)
  40051. // wxOption allows management of the mutation configuration using functional options.
  40052. type wxOption func(*WxMutation)
  40053. // newWxMutation creates new mutation for the Wx entity.
  40054. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  40055. m := &WxMutation{
  40056. config: c,
  40057. op: op,
  40058. typ: TypeWx,
  40059. clearedFields: make(map[string]struct{}),
  40060. }
  40061. for _, opt := range opts {
  40062. opt(m)
  40063. }
  40064. return m
  40065. }
  40066. // withWxID sets the ID field of the mutation.
  40067. func withWxID(id uint64) wxOption {
  40068. return func(m *WxMutation) {
  40069. var (
  40070. err error
  40071. once sync.Once
  40072. value *Wx
  40073. )
  40074. m.oldValue = func(ctx context.Context) (*Wx, error) {
  40075. once.Do(func() {
  40076. if m.done {
  40077. err = errors.New("querying old values post mutation is not allowed")
  40078. } else {
  40079. value, err = m.Client().Wx.Get(ctx, id)
  40080. }
  40081. })
  40082. return value, err
  40083. }
  40084. m.id = &id
  40085. }
  40086. }
  40087. // withWx sets the old Wx of the mutation.
  40088. func withWx(node *Wx) wxOption {
  40089. return func(m *WxMutation) {
  40090. m.oldValue = func(context.Context) (*Wx, error) {
  40091. return node, nil
  40092. }
  40093. m.id = &node.ID
  40094. }
  40095. }
  40096. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40097. // executed in a transaction (ent.Tx), a transactional client is returned.
  40098. func (m WxMutation) Client() *Client {
  40099. client := &Client{config: m.config}
  40100. client.init()
  40101. return client
  40102. }
  40103. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40104. // it returns an error otherwise.
  40105. func (m WxMutation) Tx() (*Tx, error) {
  40106. if _, ok := m.driver.(*txDriver); !ok {
  40107. return nil, errors.New("ent: mutation is not running in a transaction")
  40108. }
  40109. tx := &Tx{config: m.config}
  40110. tx.init()
  40111. return tx, nil
  40112. }
  40113. // SetID sets the value of the id field. Note that this
  40114. // operation is only accepted on creation of Wx entities.
  40115. func (m *WxMutation) SetID(id uint64) {
  40116. m.id = &id
  40117. }
  40118. // ID returns the ID value in the mutation. Note that the ID is only available
  40119. // if it was provided to the builder or after it was returned from the database.
  40120. func (m *WxMutation) ID() (id uint64, exists bool) {
  40121. if m.id == nil {
  40122. return
  40123. }
  40124. return *m.id, true
  40125. }
  40126. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40127. // That means, if the mutation is applied within a transaction with an isolation level such
  40128. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40129. // or updated by the mutation.
  40130. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  40131. switch {
  40132. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40133. id, exists := m.ID()
  40134. if exists {
  40135. return []uint64{id}, nil
  40136. }
  40137. fallthrough
  40138. case m.op.Is(OpUpdate | OpDelete):
  40139. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  40140. default:
  40141. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40142. }
  40143. }
  40144. // SetCreatedAt sets the "created_at" field.
  40145. func (m *WxMutation) SetCreatedAt(t time.Time) {
  40146. m.created_at = &t
  40147. }
  40148. // CreatedAt returns the value of the "created_at" field in the mutation.
  40149. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  40150. v := m.created_at
  40151. if v == nil {
  40152. return
  40153. }
  40154. return *v, true
  40155. }
  40156. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  40157. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40159. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40160. if !m.op.Is(OpUpdateOne) {
  40161. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40162. }
  40163. if m.id == nil || m.oldValue == nil {
  40164. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40165. }
  40166. oldValue, err := m.oldValue(ctx)
  40167. if err != nil {
  40168. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40169. }
  40170. return oldValue.CreatedAt, nil
  40171. }
  40172. // ResetCreatedAt resets all changes to the "created_at" field.
  40173. func (m *WxMutation) ResetCreatedAt() {
  40174. m.created_at = nil
  40175. }
  40176. // SetUpdatedAt sets the "updated_at" field.
  40177. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  40178. m.updated_at = &t
  40179. }
  40180. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40181. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  40182. v := m.updated_at
  40183. if v == nil {
  40184. return
  40185. }
  40186. return *v, true
  40187. }
  40188. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  40189. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40191. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40192. if !m.op.Is(OpUpdateOne) {
  40193. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40194. }
  40195. if m.id == nil || m.oldValue == nil {
  40196. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40197. }
  40198. oldValue, err := m.oldValue(ctx)
  40199. if err != nil {
  40200. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40201. }
  40202. return oldValue.UpdatedAt, nil
  40203. }
  40204. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40205. func (m *WxMutation) ResetUpdatedAt() {
  40206. m.updated_at = nil
  40207. }
  40208. // SetStatus sets the "status" field.
  40209. func (m *WxMutation) SetStatus(u uint8) {
  40210. m.status = &u
  40211. m.addstatus = nil
  40212. }
  40213. // Status returns the value of the "status" field in the mutation.
  40214. func (m *WxMutation) Status() (r uint8, exists bool) {
  40215. v := m.status
  40216. if v == nil {
  40217. return
  40218. }
  40219. return *v, true
  40220. }
  40221. // OldStatus returns the old "status" field's value of the Wx entity.
  40222. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40224. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40225. if !m.op.Is(OpUpdateOne) {
  40226. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40227. }
  40228. if m.id == nil || m.oldValue == nil {
  40229. return v, errors.New("OldStatus requires an ID field in the mutation")
  40230. }
  40231. oldValue, err := m.oldValue(ctx)
  40232. if err != nil {
  40233. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40234. }
  40235. return oldValue.Status, nil
  40236. }
  40237. // AddStatus adds u to the "status" field.
  40238. func (m *WxMutation) AddStatus(u int8) {
  40239. if m.addstatus != nil {
  40240. *m.addstatus += u
  40241. } else {
  40242. m.addstatus = &u
  40243. }
  40244. }
  40245. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40246. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  40247. v := m.addstatus
  40248. if v == nil {
  40249. return
  40250. }
  40251. return *v, true
  40252. }
  40253. // ClearStatus clears the value of the "status" field.
  40254. func (m *WxMutation) ClearStatus() {
  40255. m.status = nil
  40256. m.addstatus = nil
  40257. m.clearedFields[wx.FieldStatus] = struct{}{}
  40258. }
  40259. // StatusCleared returns if the "status" field was cleared in this mutation.
  40260. func (m *WxMutation) StatusCleared() bool {
  40261. _, ok := m.clearedFields[wx.FieldStatus]
  40262. return ok
  40263. }
  40264. // ResetStatus resets all changes to the "status" field.
  40265. func (m *WxMutation) ResetStatus() {
  40266. m.status = nil
  40267. m.addstatus = nil
  40268. delete(m.clearedFields, wx.FieldStatus)
  40269. }
  40270. // SetDeletedAt sets the "deleted_at" field.
  40271. func (m *WxMutation) SetDeletedAt(t time.Time) {
  40272. m.deleted_at = &t
  40273. }
  40274. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40275. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  40276. v := m.deleted_at
  40277. if v == nil {
  40278. return
  40279. }
  40280. return *v, true
  40281. }
  40282. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  40283. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40285. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40286. if !m.op.Is(OpUpdateOne) {
  40287. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40288. }
  40289. if m.id == nil || m.oldValue == nil {
  40290. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40291. }
  40292. oldValue, err := m.oldValue(ctx)
  40293. if err != nil {
  40294. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40295. }
  40296. return oldValue.DeletedAt, nil
  40297. }
  40298. // ClearDeletedAt clears the value of the "deleted_at" field.
  40299. func (m *WxMutation) ClearDeletedAt() {
  40300. m.deleted_at = nil
  40301. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  40302. }
  40303. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40304. func (m *WxMutation) DeletedAtCleared() bool {
  40305. _, ok := m.clearedFields[wx.FieldDeletedAt]
  40306. return ok
  40307. }
  40308. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40309. func (m *WxMutation) ResetDeletedAt() {
  40310. m.deleted_at = nil
  40311. delete(m.clearedFields, wx.FieldDeletedAt)
  40312. }
  40313. // SetServerID sets the "server_id" field.
  40314. func (m *WxMutation) SetServerID(u uint64) {
  40315. m.server = &u
  40316. }
  40317. // ServerID returns the value of the "server_id" field in the mutation.
  40318. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  40319. v := m.server
  40320. if v == nil {
  40321. return
  40322. }
  40323. return *v, true
  40324. }
  40325. // OldServerID returns the old "server_id" field's value of the Wx entity.
  40326. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40328. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  40329. if !m.op.Is(OpUpdateOne) {
  40330. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  40331. }
  40332. if m.id == nil || m.oldValue == nil {
  40333. return v, errors.New("OldServerID requires an ID field in the mutation")
  40334. }
  40335. oldValue, err := m.oldValue(ctx)
  40336. if err != nil {
  40337. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  40338. }
  40339. return oldValue.ServerID, nil
  40340. }
  40341. // ClearServerID clears the value of the "server_id" field.
  40342. func (m *WxMutation) ClearServerID() {
  40343. m.server = nil
  40344. m.clearedFields[wx.FieldServerID] = struct{}{}
  40345. }
  40346. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  40347. func (m *WxMutation) ServerIDCleared() bool {
  40348. _, ok := m.clearedFields[wx.FieldServerID]
  40349. return ok
  40350. }
  40351. // ResetServerID resets all changes to the "server_id" field.
  40352. func (m *WxMutation) ResetServerID() {
  40353. m.server = nil
  40354. delete(m.clearedFields, wx.FieldServerID)
  40355. }
  40356. // SetPort sets the "port" field.
  40357. func (m *WxMutation) SetPort(s string) {
  40358. m.port = &s
  40359. }
  40360. // Port returns the value of the "port" field in the mutation.
  40361. func (m *WxMutation) Port() (r string, exists bool) {
  40362. v := m.port
  40363. if v == nil {
  40364. return
  40365. }
  40366. return *v, true
  40367. }
  40368. // OldPort returns the old "port" field's value of the Wx entity.
  40369. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40371. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  40372. if !m.op.Is(OpUpdateOne) {
  40373. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  40374. }
  40375. if m.id == nil || m.oldValue == nil {
  40376. return v, errors.New("OldPort requires an ID field in the mutation")
  40377. }
  40378. oldValue, err := m.oldValue(ctx)
  40379. if err != nil {
  40380. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  40381. }
  40382. return oldValue.Port, nil
  40383. }
  40384. // ResetPort resets all changes to the "port" field.
  40385. func (m *WxMutation) ResetPort() {
  40386. m.port = nil
  40387. }
  40388. // SetProcessID sets the "process_id" field.
  40389. func (m *WxMutation) SetProcessID(s string) {
  40390. m.process_id = &s
  40391. }
  40392. // ProcessID returns the value of the "process_id" field in the mutation.
  40393. func (m *WxMutation) ProcessID() (r string, exists bool) {
  40394. v := m.process_id
  40395. if v == nil {
  40396. return
  40397. }
  40398. return *v, true
  40399. }
  40400. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  40401. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40403. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  40404. if !m.op.Is(OpUpdateOne) {
  40405. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  40406. }
  40407. if m.id == nil || m.oldValue == nil {
  40408. return v, errors.New("OldProcessID requires an ID field in the mutation")
  40409. }
  40410. oldValue, err := m.oldValue(ctx)
  40411. if err != nil {
  40412. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  40413. }
  40414. return oldValue.ProcessID, nil
  40415. }
  40416. // ResetProcessID resets all changes to the "process_id" field.
  40417. func (m *WxMutation) ResetProcessID() {
  40418. m.process_id = nil
  40419. }
  40420. // SetCallback sets the "callback" field.
  40421. func (m *WxMutation) SetCallback(s string) {
  40422. m.callback = &s
  40423. }
  40424. // Callback returns the value of the "callback" field in the mutation.
  40425. func (m *WxMutation) Callback() (r string, exists bool) {
  40426. v := m.callback
  40427. if v == nil {
  40428. return
  40429. }
  40430. return *v, true
  40431. }
  40432. // OldCallback returns the old "callback" field's value of the Wx entity.
  40433. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40435. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  40436. if !m.op.Is(OpUpdateOne) {
  40437. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  40438. }
  40439. if m.id == nil || m.oldValue == nil {
  40440. return v, errors.New("OldCallback requires an ID field in the mutation")
  40441. }
  40442. oldValue, err := m.oldValue(ctx)
  40443. if err != nil {
  40444. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  40445. }
  40446. return oldValue.Callback, nil
  40447. }
  40448. // ResetCallback resets all changes to the "callback" field.
  40449. func (m *WxMutation) ResetCallback() {
  40450. m.callback = nil
  40451. }
  40452. // SetWxid sets the "wxid" field.
  40453. func (m *WxMutation) SetWxid(s string) {
  40454. m.wxid = &s
  40455. }
  40456. // Wxid returns the value of the "wxid" field in the mutation.
  40457. func (m *WxMutation) Wxid() (r string, exists bool) {
  40458. v := m.wxid
  40459. if v == nil {
  40460. return
  40461. }
  40462. return *v, true
  40463. }
  40464. // OldWxid returns the old "wxid" field's value of the Wx entity.
  40465. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40467. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  40468. if !m.op.Is(OpUpdateOne) {
  40469. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40470. }
  40471. if m.id == nil || m.oldValue == nil {
  40472. return v, errors.New("OldWxid requires an ID field in the mutation")
  40473. }
  40474. oldValue, err := m.oldValue(ctx)
  40475. if err != nil {
  40476. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40477. }
  40478. return oldValue.Wxid, nil
  40479. }
  40480. // ResetWxid resets all changes to the "wxid" field.
  40481. func (m *WxMutation) ResetWxid() {
  40482. m.wxid = nil
  40483. }
  40484. // SetAccount sets the "account" field.
  40485. func (m *WxMutation) SetAccount(s string) {
  40486. m.account = &s
  40487. }
  40488. // Account returns the value of the "account" field in the mutation.
  40489. func (m *WxMutation) Account() (r string, exists bool) {
  40490. v := m.account
  40491. if v == nil {
  40492. return
  40493. }
  40494. return *v, true
  40495. }
  40496. // OldAccount returns the old "account" field's value of the Wx entity.
  40497. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40499. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  40500. if !m.op.Is(OpUpdateOne) {
  40501. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  40502. }
  40503. if m.id == nil || m.oldValue == nil {
  40504. return v, errors.New("OldAccount requires an ID field in the mutation")
  40505. }
  40506. oldValue, err := m.oldValue(ctx)
  40507. if err != nil {
  40508. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  40509. }
  40510. return oldValue.Account, nil
  40511. }
  40512. // ResetAccount resets all changes to the "account" field.
  40513. func (m *WxMutation) ResetAccount() {
  40514. m.account = nil
  40515. }
  40516. // SetNickname sets the "nickname" field.
  40517. func (m *WxMutation) SetNickname(s string) {
  40518. m.nickname = &s
  40519. }
  40520. // Nickname returns the value of the "nickname" field in the mutation.
  40521. func (m *WxMutation) Nickname() (r string, exists bool) {
  40522. v := m.nickname
  40523. if v == nil {
  40524. return
  40525. }
  40526. return *v, true
  40527. }
  40528. // OldNickname returns the old "nickname" field's value of the Wx entity.
  40529. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40531. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  40532. if !m.op.Is(OpUpdateOne) {
  40533. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40534. }
  40535. if m.id == nil || m.oldValue == nil {
  40536. return v, errors.New("OldNickname requires an ID field in the mutation")
  40537. }
  40538. oldValue, err := m.oldValue(ctx)
  40539. if err != nil {
  40540. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40541. }
  40542. return oldValue.Nickname, nil
  40543. }
  40544. // ResetNickname resets all changes to the "nickname" field.
  40545. func (m *WxMutation) ResetNickname() {
  40546. m.nickname = nil
  40547. }
  40548. // SetTel sets the "tel" field.
  40549. func (m *WxMutation) SetTel(s string) {
  40550. m.tel = &s
  40551. }
  40552. // Tel returns the value of the "tel" field in the mutation.
  40553. func (m *WxMutation) Tel() (r string, exists bool) {
  40554. v := m.tel
  40555. if v == nil {
  40556. return
  40557. }
  40558. return *v, true
  40559. }
  40560. // OldTel returns the old "tel" field's value of the Wx entity.
  40561. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40563. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  40564. if !m.op.Is(OpUpdateOne) {
  40565. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  40566. }
  40567. if m.id == nil || m.oldValue == nil {
  40568. return v, errors.New("OldTel requires an ID field in the mutation")
  40569. }
  40570. oldValue, err := m.oldValue(ctx)
  40571. if err != nil {
  40572. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  40573. }
  40574. return oldValue.Tel, nil
  40575. }
  40576. // ResetTel resets all changes to the "tel" field.
  40577. func (m *WxMutation) ResetTel() {
  40578. m.tel = nil
  40579. }
  40580. // SetHeadBig sets the "head_big" field.
  40581. func (m *WxMutation) SetHeadBig(s string) {
  40582. m.head_big = &s
  40583. }
  40584. // HeadBig returns the value of the "head_big" field in the mutation.
  40585. func (m *WxMutation) HeadBig() (r string, exists bool) {
  40586. v := m.head_big
  40587. if v == nil {
  40588. return
  40589. }
  40590. return *v, true
  40591. }
  40592. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  40593. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40595. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  40596. if !m.op.Is(OpUpdateOne) {
  40597. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  40598. }
  40599. if m.id == nil || m.oldValue == nil {
  40600. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  40601. }
  40602. oldValue, err := m.oldValue(ctx)
  40603. if err != nil {
  40604. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  40605. }
  40606. return oldValue.HeadBig, nil
  40607. }
  40608. // ResetHeadBig resets all changes to the "head_big" field.
  40609. func (m *WxMutation) ResetHeadBig() {
  40610. m.head_big = nil
  40611. }
  40612. // SetOrganizationID sets the "organization_id" field.
  40613. func (m *WxMutation) SetOrganizationID(u uint64) {
  40614. m.organization_id = &u
  40615. m.addorganization_id = nil
  40616. }
  40617. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40618. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  40619. v := m.organization_id
  40620. if v == nil {
  40621. return
  40622. }
  40623. return *v, true
  40624. }
  40625. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  40626. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40628. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40629. if !m.op.Is(OpUpdateOne) {
  40630. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40631. }
  40632. if m.id == nil || m.oldValue == nil {
  40633. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40634. }
  40635. oldValue, err := m.oldValue(ctx)
  40636. if err != nil {
  40637. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40638. }
  40639. return oldValue.OrganizationID, nil
  40640. }
  40641. // AddOrganizationID adds u to the "organization_id" field.
  40642. func (m *WxMutation) AddOrganizationID(u int64) {
  40643. if m.addorganization_id != nil {
  40644. *m.addorganization_id += u
  40645. } else {
  40646. m.addorganization_id = &u
  40647. }
  40648. }
  40649. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40650. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  40651. v := m.addorganization_id
  40652. if v == nil {
  40653. return
  40654. }
  40655. return *v, true
  40656. }
  40657. // ClearOrganizationID clears the value of the "organization_id" field.
  40658. func (m *WxMutation) ClearOrganizationID() {
  40659. m.organization_id = nil
  40660. m.addorganization_id = nil
  40661. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  40662. }
  40663. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40664. func (m *WxMutation) OrganizationIDCleared() bool {
  40665. _, ok := m.clearedFields[wx.FieldOrganizationID]
  40666. return ok
  40667. }
  40668. // ResetOrganizationID resets all changes to the "organization_id" field.
  40669. func (m *WxMutation) ResetOrganizationID() {
  40670. m.organization_id = nil
  40671. m.addorganization_id = nil
  40672. delete(m.clearedFields, wx.FieldOrganizationID)
  40673. }
  40674. // SetAgentID sets the "agent_id" field.
  40675. func (m *WxMutation) SetAgentID(u uint64) {
  40676. m.agent = &u
  40677. }
  40678. // AgentID returns the value of the "agent_id" field in the mutation.
  40679. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  40680. v := m.agent
  40681. if v == nil {
  40682. return
  40683. }
  40684. return *v, true
  40685. }
  40686. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  40687. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40689. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  40690. if !m.op.Is(OpUpdateOne) {
  40691. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  40692. }
  40693. if m.id == nil || m.oldValue == nil {
  40694. return v, errors.New("OldAgentID requires an ID field in the mutation")
  40695. }
  40696. oldValue, err := m.oldValue(ctx)
  40697. if err != nil {
  40698. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  40699. }
  40700. return oldValue.AgentID, nil
  40701. }
  40702. // ResetAgentID resets all changes to the "agent_id" field.
  40703. func (m *WxMutation) ResetAgentID() {
  40704. m.agent = nil
  40705. }
  40706. // SetAPIBase sets the "api_base" field.
  40707. func (m *WxMutation) SetAPIBase(s string) {
  40708. m.api_base = &s
  40709. }
  40710. // APIBase returns the value of the "api_base" field in the mutation.
  40711. func (m *WxMutation) APIBase() (r string, exists bool) {
  40712. v := m.api_base
  40713. if v == nil {
  40714. return
  40715. }
  40716. return *v, true
  40717. }
  40718. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  40719. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40721. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  40722. if !m.op.Is(OpUpdateOne) {
  40723. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  40724. }
  40725. if m.id == nil || m.oldValue == nil {
  40726. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  40727. }
  40728. oldValue, err := m.oldValue(ctx)
  40729. if err != nil {
  40730. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  40731. }
  40732. return oldValue.APIBase, nil
  40733. }
  40734. // ClearAPIBase clears the value of the "api_base" field.
  40735. func (m *WxMutation) ClearAPIBase() {
  40736. m.api_base = nil
  40737. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  40738. }
  40739. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  40740. func (m *WxMutation) APIBaseCleared() bool {
  40741. _, ok := m.clearedFields[wx.FieldAPIBase]
  40742. return ok
  40743. }
  40744. // ResetAPIBase resets all changes to the "api_base" field.
  40745. func (m *WxMutation) ResetAPIBase() {
  40746. m.api_base = nil
  40747. delete(m.clearedFields, wx.FieldAPIBase)
  40748. }
  40749. // SetAPIKey sets the "api_key" field.
  40750. func (m *WxMutation) SetAPIKey(s string) {
  40751. m.api_key = &s
  40752. }
  40753. // APIKey returns the value of the "api_key" field in the mutation.
  40754. func (m *WxMutation) APIKey() (r string, exists bool) {
  40755. v := m.api_key
  40756. if v == nil {
  40757. return
  40758. }
  40759. return *v, true
  40760. }
  40761. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  40762. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40764. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  40765. if !m.op.Is(OpUpdateOne) {
  40766. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  40767. }
  40768. if m.id == nil || m.oldValue == nil {
  40769. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  40770. }
  40771. oldValue, err := m.oldValue(ctx)
  40772. if err != nil {
  40773. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  40774. }
  40775. return oldValue.APIKey, nil
  40776. }
  40777. // ClearAPIKey clears the value of the "api_key" field.
  40778. func (m *WxMutation) ClearAPIKey() {
  40779. m.api_key = nil
  40780. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  40781. }
  40782. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  40783. func (m *WxMutation) APIKeyCleared() bool {
  40784. _, ok := m.clearedFields[wx.FieldAPIKey]
  40785. return ok
  40786. }
  40787. // ResetAPIKey resets all changes to the "api_key" field.
  40788. func (m *WxMutation) ResetAPIKey() {
  40789. m.api_key = nil
  40790. delete(m.clearedFields, wx.FieldAPIKey)
  40791. }
  40792. // SetAllowList sets the "allow_list" field.
  40793. func (m *WxMutation) SetAllowList(s []string) {
  40794. m.allow_list = &s
  40795. m.appendallow_list = nil
  40796. }
  40797. // AllowList returns the value of the "allow_list" field in the mutation.
  40798. func (m *WxMutation) AllowList() (r []string, exists bool) {
  40799. v := m.allow_list
  40800. if v == nil {
  40801. return
  40802. }
  40803. return *v, true
  40804. }
  40805. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  40806. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40808. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  40809. if !m.op.Is(OpUpdateOne) {
  40810. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  40811. }
  40812. if m.id == nil || m.oldValue == nil {
  40813. return v, errors.New("OldAllowList requires an ID field in the mutation")
  40814. }
  40815. oldValue, err := m.oldValue(ctx)
  40816. if err != nil {
  40817. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  40818. }
  40819. return oldValue.AllowList, nil
  40820. }
  40821. // AppendAllowList adds s to the "allow_list" field.
  40822. func (m *WxMutation) AppendAllowList(s []string) {
  40823. m.appendallow_list = append(m.appendallow_list, s...)
  40824. }
  40825. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  40826. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  40827. if len(m.appendallow_list) == 0 {
  40828. return nil, false
  40829. }
  40830. return m.appendallow_list, true
  40831. }
  40832. // ResetAllowList resets all changes to the "allow_list" field.
  40833. func (m *WxMutation) ResetAllowList() {
  40834. m.allow_list = nil
  40835. m.appendallow_list = nil
  40836. }
  40837. // SetGroupAllowList sets the "group_allow_list" field.
  40838. func (m *WxMutation) SetGroupAllowList(s []string) {
  40839. m.group_allow_list = &s
  40840. m.appendgroup_allow_list = nil
  40841. }
  40842. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  40843. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  40844. v := m.group_allow_list
  40845. if v == nil {
  40846. return
  40847. }
  40848. return *v, true
  40849. }
  40850. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  40851. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40853. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  40854. if !m.op.Is(OpUpdateOne) {
  40855. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  40856. }
  40857. if m.id == nil || m.oldValue == nil {
  40858. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  40859. }
  40860. oldValue, err := m.oldValue(ctx)
  40861. if err != nil {
  40862. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  40863. }
  40864. return oldValue.GroupAllowList, nil
  40865. }
  40866. // AppendGroupAllowList adds s to the "group_allow_list" field.
  40867. func (m *WxMutation) AppendGroupAllowList(s []string) {
  40868. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  40869. }
  40870. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  40871. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  40872. if len(m.appendgroup_allow_list) == 0 {
  40873. return nil, false
  40874. }
  40875. return m.appendgroup_allow_list, true
  40876. }
  40877. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  40878. func (m *WxMutation) ResetGroupAllowList() {
  40879. m.group_allow_list = nil
  40880. m.appendgroup_allow_list = nil
  40881. }
  40882. // SetBlockList sets the "block_list" field.
  40883. func (m *WxMutation) SetBlockList(s []string) {
  40884. m.block_list = &s
  40885. m.appendblock_list = nil
  40886. }
  40887. // BlockList returns the value of the "block_list" field in the mutation.
  40888. func (m *WxMutation) BlockList() (r []string, exists bool) {
  40889. v := m.block_list
  40890. if v == nil {
  40891. return
  40892. }
  40893. return *v, true
  40894. }
  40895. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  40896. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40898. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  40899. if !m.op.Is(OpUpdateOne) {
  40900. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  40901. }
  40902. if m.id == nil || m.oldValue == nil {
  40903. return v, errors.New("OldBlockList requires an ID field in the mutation")
  40904. }
  40905. oldValue, err := m.oldValue(ctx)
  40906. if err != nil {
  40907. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  40908. }
  40909. return oldValue.BlockList, nil
  40910. }
  40911. // AppendBlockList adds s to the "block_list" field.
  40912. func (m *WxMutation) AppendBlockList(s []string) {
  40913. m.appendblock_list = append(m.appendblock_list, s...)
  40914. }
  40915. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  40916. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  40917. if len(m.appendblock_list) == 0 {
  40918. return nil, false
  40919. }
  40920. return m.appendblock_list, true
  40921. }
  40922. // ResetBlockList resets all changes to the "block_list" field.
  40923. func (m *WxMutation) ResetBlockList() {
  40924. m.block_list = nil
  40925. m.appendblock_list = nil
  40926. }
  40927. // SetGroupBlockList sets the "group_block_list" field.
  40928. func (m *WxMutation) SetGroupBlockList(s []string) {
  40929. m.group_block_list = &s
  40930. m.appendgroup_block_list = nil
  40931. }
  40932. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  40933. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  40934. v := m.group_block_list
  40935. if v == nil {
  40936. return
  40937. }
  40938. return *v, true
  40939. }
  40940. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  40941. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40943. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  40944. if !m.op.Is(OpUpdateOne) {
  40945. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  40946. }
  40947. if m.id == nil || m.oldValue == nil {
  40948. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  40949. }
  40950. oldValue, err := m.oldValue(ctx)
  40951. if err != nil {
  40952. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  40953. }
  40954. return oldValue.GroupBlockList, nil
  40955. }
  40956. // AppendGroupBlockList adds s to the "group_block_list" field.
  40957. func (m *WxMutation) AppendGroupBlockList(s []string) {
  40958. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  40959. }
  40960. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  40961. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  40962. if len(m.appendgroup_block_list) == 0 {
  40963. return nil, false
  40964. }
  40965. return m.appendgroup_block_list, true
  40966. }
  40967. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  40968. func (m *WxMutation) ResetGroupBlockList() {
  40969. m.group_block_list = nil
  40970. m.appendgroup_block_list = nil
  40971. }
  40972. // ClearServer clears the "server" edge to the Server entity.
  40973. func (m *WxMutation) ClearServer() {
  40974. m.clearedserver = true
  40975. m.clearedFields[wx.FieldServerID] = struct{}{}
  40976. }
  40977. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  40978. func (m *WxMutation) ServerCleared() bool {
  40979. return m.ServerIDCleared() || m.clearedserver
  40980. }
  40981. // ServerIDs returns the "server" edge IDs in the mutation.
  40982. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40983. // ServerID instead. It exists only for internal usage by the builders.
  40984. func (m *WxMutation) ServerIDs() (ids []uint64) {
  40985. if id := m.server; id != nil {
  40986. ids = append(ids, *id)
  40987. }
  40988. return
  40989. }
  40990. // ResetServer resets all changes to the "server" edge.
  40991. func (m *WxMutation) ResetServer() {
  40992. m.server = nil
  40993. m.clearedserver = false
  40994. }
  40995. // ClearAgent clears the "agent" edge to the Agent entity.
  40996. func (m *WxMutation) ClearAgent() {
  40997. m.clearedagent = true
  40998. m.clearedFields[wx.FieldAgentID] = struct{}{}
  40999. }
  41000. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  41001. func (m *WxMutation) AgentCleared() bool {
  41002. return m.clearedagent
  41003. }
  41004. // AgentIDs returns the "agent" edge IDs in the mutation.
  41005. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  41006. // AgentID instead. It exists only for internal usage by the builders.
  41007. func (m *WxMutation) AgentIDs() (ids []uint64) {
  41008. if id := m.agent; id != nil {
  41009. ids = append(ids, *id)
  41010. }
  41011. return
  41012. }
  41013. // ResetAgent resets all changes to the "agent" edge.
  41014. func (m *WxMutation) ResetAgent() {
  41015. m.agent = nil
  41016. m.clearedagent = false
  41017. }
  41018. // Where appends a list predicates to the WxMutation builder.
  41019. func (m *WxMutation) Where(ps ...predicate.Wx) {
  41020. m.predicates = append(m.predicates, ps...)
  41021. }
  41022. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  41023. // users can use type-assertion to append predicates that do not depend on any generated package.
  41024. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  41025. p := make([]predicate.Wx, len(ps))
  41026. for i := range ps {
  41027. p[i] = ps[i]
  41028. }
  41029. m.Where(p...)
  41030. }
  41031. // Op returns the operation name.
  41032. func (m *WxMutation) Op() Op {
  41033. return m.op
  41034. }
  41035. // SetOp allows setting the mutation operation.
  41036. func (m *WxMutation) SetOp(op Op) {
  41037. m.op = op
  41038. }
  41039. // Type returns the node type of this mutation (Wx).
  41040. func (m *WxMutation) Type() string {
  41041. return m.typ
  41042. }
  41043. // Fields returns all fields that were changed during this mutation. Note that in
  41044. // order to get all numeric fields that were incremented/decremented, call
  41045. // AddedFields().
  41046. func (m *WxMutation) Fields() []string {
  41047. fields := make([]string, 0, 21)
  41048. if m.created_at != nil {
  41049. fields = append(fields, wx.FieldCreatedAt)
  41050. }
  41051. if m.updated_at != nil {
  41052. fields = append(fields, wx.FieldUpdatedAt)
  41053. }
  41054. if m.status != nil {
  41055. fields = append(fields, wx.FieldStatus)
  41056. }
  41057. if m.deleted_at != nil {
  41058. fields = append(fields, wx.FieldDeletedAt)
  41059. }
  41060. if m.server != nil {
  41061. fields = append(fields, wx.FieldServerID)
  41062. }
  41063. if m.port != nil {
  41064. fields = append(fields, wx.FieldPort)
  41065. }
  41066. if m.process_id != nil {
  41067. fields = append(fields, wx.FieldProcessID)
  41068. }
  41069. if m.callback != nil {
  41070. fields = append(fields, wx.FieldCallback)
  41071. }
  41072. if m.wxid != nil {
  41073. fields = append(fields, wx.FieldWxid)
  41074. }
  41075. if m.account != nil {
  41076. fields = append(fields, wx.FieldAccount)
  41077. }
  41078. if m.nickname != nil {
  41079. fields = append(fields, wx.FieldNickname)
  41080. }
  41081. if m.tel != nil {
  41082. fields = append(fields, wx.FieldTel)
  41083. }
  41084. if m.head_big != nil {
  41085. fields = append(fields, wx.FieldHeadBig)
  41086. }
  41087. if m.organization_id != nil {
  41088. fields = append(fields, wx.FieldOrganizationID)
  41089. }
  41090. if m.agent != nil {
  41091. fields = append(fields, wx.FieldAgentID)
  41092. }
  41093. if m.api_base != nil {
  41094. fields = append(fields, wx.FieldAPIBase)
  41095. }
  41096. if m.api_key != nil {
  41097. fields = append(fields, wx.FieldAPIKey)
  41098. }
  41099. if m.allow_list != nil {
  41100. fields = append(fields, wx.FieldAllowList)
  41101. }
  41102. if m.group_allow_list != nil {
  41103. fields = append(fields, wx.FieldGroupAllowList)
  41104. }
  41105. if m.block_list != nil {
  41106. fields = append(fields, wx.FieldBlockList)
  41107. }
  41108. if m.group_block_list != nil {
  41109. fields = append(fields, wx.FieldGroupBlockList)
  41110. }
  41111. return fields
  41112. }
  41113. // Field returns the value of a field with the given name. The second boolean
  41114. // return value indicates that this field was not set, or was not defined in the
  41115. // schema.
  41116. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  41117. switch name {
  41118. case wx.FieldCreatedAt:
  41119. return m.CreatedAt()
  41120. case wx.FieldUpdatedAt:
  41121. return m.UpdatedAt()
  41122. case wx.FieldStatus:
  41123. return m.Status()
  41124. case wx.FieldDeletedAt:
  41125. return m.DeletedAt()
  41126. case wx.FieldServerID:
  41127. return m.ServerID()
  41128. case wx.FieldPort:
  41129. return m.Port()
  41130. case wx.FieldProcessID:
  41131. return m.ProcessID()
  41132. case wx.FieldCallback:
  41133. return m.Callback()
  41134. case wx.FieldWxid:
  41135. return m.Wxid()
  41136. case wx.FieldAccount:
  41137. return m.Account()
  41138. case wx.FieldNickname:
  41139. return m.Nickname()
  41140. case wx.FieldTel:
  41141. return m.Tel()
  41142. case wx.FieldHeadBig:
  41143. return m.HeadBig()
  41144. case wx.FieldOrganizationID:
  41145. return m.OrganizationID()
  41146. case wx.FieldAgentID:
  41147. return m.AgentID()
  41148. case wx.FieldAPIBase:
  41149. return m.APIBase()
  41150. case wx.FieldAPIKey:
  41151. return m.APIKey()
  41152. case wx.FieldAllowList:
  41153. return m.AllowList()
  41154. case wx.FieldGroupAllowList:
  41155. return m.GroupAllowList()
  41156. case wx.FieldBlockList:
  41157. return m.BlockList()
  41158. case wx.FieldGroupBlockList:
  41159. return m.GroupBlockList()
  41160. }
  41161. return nil, false
  41162. }
  41163. // OldField returns the old value of the field from the database. An error is
  41164. // returned if the mutation operation is not UpdateOne, or the query to the
  41165. // database failed.
  41166. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41167. switch name {
  41168. case wx.FieldCreatedAt:
  41169. return m.OldCreatedAt(ctx)
  41170. case wx.FieldUpdatedAt:
  41171. return m.OldUpdatedAt(ctx)
  41172. case wx.FieldStatus:
  41173. return m.OldStatus(ctx)
  41174. case wx.FieldDeletedAt:
  41175. return m.OldDeletedAt(ctx)
  41176. case wx.FieldServerID:
  41177. return m.OldServerID(ctx)
  41178. case wx.FieldPort:
  41179. return m.OldPort(ctx)
  41180. case wx.FieldProcessID:
  41181. return m.OldProcessID(ctx)
  41182. case wx.FieldCallback:
  41183. return m.OldCallback(ctx)
  41184. case wx.FieldWxid:
  41185. return m.OldWxid(ctx)
  41186. case wx.FieldAccount:
  41187. return m.OldAccount(ctx)
  41188. case wx.FieldNickname:
  41189. return m.OldNickname(ctx)
  41190. case wx.FieldTel:
  41191. return m.OldTel(ctx)
  41192. case wx.FieldHeadBig:
  41193. return m.OldHeadBig(ctx)
  41194. case wx.FieldOrganizationID:
  41195. return m.OldOrganizationID(ctx)
  41196. case wx.FieldAgentID:
  41197. return m.OldAgentID(ctx)
  41198. case wx.FieldAPIBase:
  41199. return m.OldAPIBase(ctx)
  41200. case wx.FieldAPIKey:
  41201. return m.OldAPIKey(ctx)
  41202. case wx.FieldAllowList:
  41203. return m.OldAllowList(ctx)
  41204. case wx.FieldGroupAllowList:
  41205. return m.OldGroupAllowList(ctx)
  41206. case wx.FieldBlockList:
  41207. return m.OldBlockList(ctx)
  41208. case wx.FieldGroupBlockList:
  41209. return m.OldGroupBlockList(ctx)
  41210. }
  41211. return nil, fmt.Errorf("unknown Wx field %s", name)
  41212. }
  41213. // SetField sets the value of a field with the given name. It returns an error if
  41214. // the field is not defined in the schema, or if the type mismatched the field
  41215. // type.
  41216. func (m *WxMutation) SetField(name string, value ent.Value) error {
  41217. switch name {
  41218. case wx.FieldCreatedAt:
  41219. v, ok := value.(time.Time)
  41220. if !ok {
  41221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41222. }
  41223. m.SetCreatedAt(v)
  41224. return nil
  41225. case wx.FieldUpdatedAt:
  41226. v, ok := value.(time.Time)
  41227. if !ok {
  41228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41229. }
  41230. m.SetUpdatedAt(v)
  41231. return nil
  41232. case wx.FieldStatus:
  41233. v, ok := value.(uint8)
  41234. if !ok {
  41235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41236. }
  41237. m.SetStatus(v)
  41238. return nil
  41239. case wx.FieldDeletedAt:
  41240. v, ok := value.(time.Time)
  41241. if !ok {
  41242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41243. }
  41244. m.SetDeletedAt(v)
  41245. return nil
  41246. case wx.FieldServerID:
  41247. v, ok := value.(uint64)
  41248. if !ok {
  41249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41250. }
  41251. m.SetServerID(v)
  41252. return nil
  41253. case wx.FieldPort:
  41254. v, ok := value.(string)
  41255. if !ok {
  41256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41257. }
  41258. m.SetPort(v)
  41259. return nil
  41260. case wx.FieldProcessID:
  41261. v, ok := value.(string)
  41262. if !ok {
  41263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41264. }
  41265. m.SetProcessID(v)
  41266. return nil
  41267. case wx.FieldCallback:
  41268. v, ok := value.(string)
  41269. if !ok {
  41270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41271. }
  41272. m.SetCallback(v)
  41273. return nil
  41274. case wx.FieldWxid:
  41275. v, ok := value.(string)
  41276. if !ok {
  41277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41278. }
  41279. m.SetWxid(v)
  41280. return nil
  41281. case wx.FieldAccount:
  41282. v, ok := value.(string)
  41283. if !ok {
  41284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41285. }
  41286. m.SetAccount(v)
  41287. return nil
  41288. case wx.FieldNickname:
  41289. v, ok := value.(string)
  41290. if !ok {
  41291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41292. }
  41293. m.SetNickname(v)
  41294. return nil
  41295. case wx.FieldTel:
  41296. v, ok := value.(string)
  41297. if !ok {
  41298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41299. }
  41300. m.SetTel(v)
  41301. return nil
  41302. case wx.FieldHeadBig:
  41303. v, ok := value.(string)
  41304. if !ok {
  41305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41306. }
  41307. m.SetHeadBig(v)
  41308. return nil
  41309. case wx.FieldOrganizationID:
  41310. v, ok := value.(uint64)
  41311. if !ok {
  41312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41313. }
  41314. m.SetOrganizationID(v)
  41315. return nil
  41316. case wx.FieldAgentID:
  41317. v, ok := value.(uint64)
  41318. if !ok {
  41319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41320. }
  41321. m.SetAgentID(v)
  41322. return nil
  41323. case wx.FieldAPIBase:
  41324. v, ok := value.(string)
  41325. if !ok {
  41326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41327. }
  41328. m.SetAPIBase(v)
  41329. return nil
  41330. case wx.FieldAPIKey:
  41331. v, ok := value.(string)
  41332. if !ok {
  41333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41334. }
  41335. m.SetAPIKey(v)
  41336. return nil
  41337. case wx.FieldAllowList:
  41338. v, ok := value.([]string)
  41339. if !ok {
  41340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41341. }
  41342. m.SetAllowList(v)
  41343. return nil
  41344. case wx.FieldGroupAllowList:
  41345. v, ok := value.([]string)
  41346. if !ok {
  41347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41348. }
  41349. m.SetGroupAllowList(v)
  41350. return nil
  41351. case wx.FieldBlockList:
  41352. v, ok := value.([]string)
  41353. if !ok {
  41354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41355. }
  41356. m.SetBlockList(v)
  41357. return nil
  41358. case wx.FieldGroupBlockList:
  41359. v, ok := value.([]string)
  41360. if !ok {
  41361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41362. }
  41363. m.SetGroupBlockList(v)
  41364. return nil
  41365. }
  41366. return fmt.Errorf("unknown Wx field %s", name)
  41367. }
  41368. // AddedFields returns all numeric fields that were incremented/decremented during
  41369. // this mutation.
  41370. func (m *WxMutation) AddedFields() []string {
  41371. var fields []string
  41372. if m.addstatus != nil {
  41373. fields = append(fields, wx.FieldStatus)
  41374. }
  41375. if m.addorganization_id != nil {
  41376. fields = append(fields, wx.FieldOrganizationID)
  41377. }
  41378. return fields
  41379. }
  41380. // AddedField returns the numeric value that was incremented/decremented on a field
  41381. // with the given name. The second boolean return value indicates that this field
  41382. // was not set, or was not defined in the schema.
  41383. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  41384. switch name {
  41385. case wx.FieldStatus:
  41386. return m.AddedStatus()
  41387. case wx.FieldOrganizationID:
  41388. return m.AddedOrganizationID()
  41389. }
  41390. return nil, false
  41391. }
  41392. // AddField adds the value to the field with the given name. It returns an error if
  41393. // the field is not defined in the schema, or if the type mismatched the field
  41394. // type.
  41395. func (m *WxMutation) AddField(name string, value ent.Value) error {
  41396. switch name {
  41397. case wx.FieldStatus:
  41398. v, ok := value.(int8)
  41399. if !ok {
  41400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41401. }
  41402. m.AddStatus(v)
  41403. return nil
  41404. case wx.FieldOrganizationID:
  41405. v, ok := value.(int64)
  41406. if !ok {
  41407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41408. }
  41409. m.AddOrganizationID(v)
  41410. return nil
  41411. }
  41412. return fmt.Errorf("unknown Wx numeric field %s", name)
  41413. }
  41414. // ClearedFields returns all nullable fields that were cleared during this
  41415. // mutation.
  41416. func (m *WxMutation) ClearedFields() []string {
  41417. var fields []string
  41418. if m.FieldCleared(wx.FieldStatus) {
  41419. fields = append(fields, wx.FieldStatus)
  41420. }
  41421. if m.FieldCleared(wx.FieldDeletedAt) {
  41422. fields = append(fields, wx.FieldDeletedAt)
  41423. }
  41424. if m.FieldCleared(wx.FieldServerID) {
  41425. fields = append(fields, wx.FieldServerID)
  41426. }
  41427. if m.FieldCleared(wx.FieldOrganizationID) {
  41428. fields = append(fields, wx.FieldOrganizationID)
  41429. }
  41430. if m.FieldCleared(wx.FieldAPIBase) {
  41431. fields = append(fields, wx.FieldAPIBase)
  41432. }
  41433. if m.FieldCleared(wx.FieldAPIKey) {
  41434. fields = append(fields, wx.FieldAPIKey)
  41435. }
  41436. return fields
  41437. }
  41438. // FieldCleared returns a boolean indicating if a field with the given name was
  41439. // cleared in this mutation.
  41440. func (m *WxMutation) FieldCleared(name string) bool {
  41441. _, ok := m.clearedFields[name]
  41442. return ok
  41443. }
  41444. // ClearField clears the value of the field with the given name. It returns an
  41445. // error if the field is not defined in the schema.
  41446. func (m *WxMutation) ClearField(name string) error {
  41447. switch name {
  41448. case wx.FieldStatus:
  41449. m.ClearStatus()
  41450. return nil
  41451. case wx.FieldDeletedAt:
  41452. m.ClearDeletedAt()
  41453. return nil
  41454. case wx.FieldServerID:
  41455. m.ClearServerID()
  41456. return nil
  41457. case wx.FieldOrganizationID:
  41458. m.ClearOrganizationID()
  41459. return nil
  41460. case wx.FieldAPIBase:
  41461. m.ClearAPIBase()
  41462. return nil
  41463. case wx.FieldAPIKey:
  41464. m.ClearAPIKey()
  41465. return nil
  41466. }
  41467. return fmt.Errorf("unknown Wx nullable field %s", name)
  41468. }
  41469. // ResetField resets all changes in the mutation for the field with the given name.
  41470. // It returns an error if the field is not defined in the schema.
  41471. func (m *WxMutation) ResetField(name string) error {
  41472. switch name {
  41473. case wx.FieldCreatedAt:
  41474. m.ResetCreatedAt()
  41475. return nil
  41476. case wx.FieldUpdatedAt:
  41477. m.ResetUpdatedAt()
  41478. return nil
  41479. case wx.FieldStatus:
  41480. m.ResetStatus()
  41481. return nil
  41482. case wx.FieldDeletedAt:
  41483. m.ResetDeletedAt()
  41484. return nil
  41485. case wx.FieldServerID:
  41486. m.ResetServerID()
  41487. return nil
  41488. case wx.FieldPort:
  41489. m.ResetPort()
  41490. return nil
  41491. case wx.FieldProcessID:
  41492. m.ResetProcessID()
  41493. return nil
  41494. case wx.FieldCallback:
  41495. m.ResetCallback()
  41496. return nil
  41497. case wx.FieldWxid:
  41498. m.ResetWxid()
  41499. return nil
  41500. case wx.FieldAccount:
  41501. m.ResetAccount()
  41502. return nil
  41503. case wx.FieldNickname:
  41504. m.ResetNickname()
  41505. return nil
  41506. case wx.FieldTel:
  41507. m.ResetTel()
  41508. return nil
  41509. case wx.FieldHeadBig:
  41510. m.ResetHeadBig()
  41511. return nil
  41512. case wx.FieldOrganizationID:
  41513. m.ResetOrganizationID()
  41514. return nil
  41515. case wx.FieldAgentID:
  41516. m.ResetAgentID()
  41517. return nil
  41518. case wx.FieldAPIBase:
  41519. m.ResetAPIBase()
  41520. return nil
  41521. case wx.FieldAPIKey:
  41522. m.ResetAPIKey()
  41523. return nil
  41524. case wx.FieldAllowList:
  41525. m.ResetAllowList()
  41526. return nil
  41527. case wx.FieldGroupAllowList:
  41528. m.ResetGroupAllowList()
  41529. return nil
  41530. case wx.FieldBlockList:
  41531. m.ResetBlockList()
  41532. return nil
  41533. case wx.FieldGroupBlockList:
  41534. m.ResetGroupBlockList()
  41535. return nil
  41536. }
  41537. return fmt.Errorf("unknown Wx field %s", name)
  41538. }
  41539. // AddedEdges returns all edge names that were set/added in this mutation.
  41540. func (m *WxMutation) AddedEdges() []string {
  41541. edges := make([]string, 0, 2)
  41542. if m.server != nil {
  41543. edges = append(edges, wx.EdgeServer)
  41544. }
  41545. if m.agent != nil {
  41546. edges = append(edges, wx.EdgeAgent)
  41547. }
  41548. return edges
  41549. }
  41550. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41551. // name in this mutation.
  41552. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  41553. switch name {
  41554. case wx.EdgeServer:
  41555. if id := m.server; id != nil {
  41556. return []ent.Value{*id}
  41557. }
  41558. case wx.EdgeAgent:
  41559. if id := m.agent; id != nil {
  41560. return []ent.Value{*id}
  41561. }
  41562. }
  41563. return nil
  41564. }
  41565. // RemovedEdges returns all edge names that were removed in this mutation.
  41566. func (m *WxMutation) RemovedEdges() []string {
  41567. edges := make([]string, 0, 2)
  41568. return edges
  41569. }
  41570. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41571. // the given name in this mutation.
  41572. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  41573. return nil
  41574. }
  41575. // ClearedEdges returns all edge names that were cleared in this mutation.
  41576. func (m *WxMutation) ClearedEdges() []string {
  41577. edges := make([]string, 0, 2)
  41578. if m.clearedserver {
  41579. edges = append(edges, wx.EdgeServer)
  41580. }
  41581. if m.clearedagent {
  41582. edges = append(edges, wx.EdgeAgent)
  41583. }
  41584. return edges
  41585. }
  41586. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41587. // was cleared in this mutation.
  41588. func (m *WxMutation) EdgeCleared(name string) bool {
  41589. switch name {
  41590. case wx.EdgeServer:
  41591. return m.clearedserver
  41592. case wx.EdgeAgent:
  41593. return m.clearedagent
  41594. }
  41595. return false
  41596. }
  41597. // ClearEdge clears the value of the edge with the given name. It returns an error
  41598. // if that edge is not defined in the schema.
  41599. func (m *WxMutation) ClearEdge(name string) error {
  41600. switch name {
  41601. case wx.EdgeServer:
  41602. m.ClearServer()
  41603. return nil
  41604. case wx.EdgeAgent:
  41605. m.ClearAgent()
  41606. return nil
  41607. }
  41608. return fmt.Errorf("unknown Wx unique edge %s", name)
  41609. }
  41610. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41611. // It returns an error if the edge is not defined in the schema.
  41612. func (m *WxMutation) ResetEdge(name string) error {
  41613. switch name {
  41614. case wx.EdgeServer:
  41615. m.ResetServer()
  41616. return nil
  41617. case wx.EdgeAgent:
  41618. m.ResetAgent()
  41619. return nil
  41620. }
  41621. return fmt.Errorf("unknown Wx edge %s", name)
  41622. }
  41623. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  41624. type WxCardMutation struct {
  41625. config
  41626. op Op
  41627. typ string
  41628. id *uint64
  41629. created_at *time.Time
  41630. updated_at *time.Time
  41631. deleted_at *time.Time
  41632. user_id *uint64
  41633. adduser_id *int64
  41634. wx_user_id *uint64
  41635. addwx_user_id *int64
  41636. avatar *string
  41637. logo *string
  41638. name *string
  41639. company *string
  41640. address *string
  41641. phone *string
  41642. official_account *string
  41643. wechat_account *string
  41644. email *string
  41645. api_base *string
  41646. api_key *string
  41647. ai_info *string
  41648. intro *string
  41649. clearedFields map[string]struct{}
  41650. done bool
  41651. oldValue func(context.Context) (*WxCard, error)
  41652. predicates []predicate.WxCard
  41653. }
  41654. var _ ent.Mutation = (*WxCardMutation)(nil)
  41655. // wxcardOption allows management of the mutation configuration using functional options.
  41656. type wxcardOption func(*WxCardMutation)
  41657. // newWxCardMutation creates new mutation for the WxCard entity.
  41658. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  41659. m := &WxCardMutation{
  41660. config: c,
  41661. op: op,
  41662. typ: TypeWxCard,
  41663. clearedFields: make(map[string]struct{}),
  41664. }
  41665. for _, opt := range opts {
  41666. opt(m)
  41667. }
  41668. return m
  41669. }
  41670. // withWxCardID sets the ID field of the mutation.
  41671. func withWxCardID(id uint64) wxcardOption {
  41672. return func(m *WxCardMutation) {
  41673. var (
  41674. err error
  41675. once sync.Once
  41676. value *WxCard
  41677. )
  41678. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  41679. once.Do(func() {
  41680. if m.done {
  41681. err = errors.New("querying old values post mutation is not allowed")
  41682. } else {
  41683. value, err = m.Client().WxCard.Get(ctx, id)
  41684. }
  41685. })
  41686. return value, err
  41687. }
  41688. m.id = &id
  41689. }
  41690. }
  41691. // withWxCard sets the old WxCard of the mutation.
  41692. func withWxCard(node *WxCard) wxcardOption {
  41693. return func(m *WxCardMutation) {
  41694. m.oldValue = func(context.Context) (*WxCard, error) {
  41695. return node, nil
  41696. }
  41697. m.id = &node.ID
  41698. }
  41699. }
  41700. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41701. // executed in a transaction (ent.Tx), a transactional client is returned.
  41702. func (m WxCardMutation) Client() *Client {
  41703. client := &Client{config: m.config}
  41704. client.init()
  41705. return client
  41706. }
  41707. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41708. // it returns an error otherwise.
  41709. func (m WxCardMutation) Tx() (*Tx, error) {
  41710. if _, ok := m.driver.(*txDriver); !ok {
  41711. return nil, errors.New("ent: mutation is not running in a transaction")
  41712. }
  41713. tx := &Tx{config: m.config}
  41714. tx.init()
  41715. return tx, nil
  41716. }
  41717. // SetID sets the value of the id field. Note that this
  41718. // operation is only accepted on creation of WxCard entities.
  41719. func (m *WxCardMutation) SetID(id uint64) {
  41720. m.id = &id
  41721. }
  41722. // ID returns the ID value in the mutation. Note that the ID is only available
  41723. // if it was provided to the builder or after it was returned from the database.
  41724. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  41725. if m.id == nil {
  41726. return
  41727. }
  41728. return *m.id, true
  41729. }
  41730. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41731. // That means, if the mutation is applied within a transaction with an isolation level such
  41732. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41733. // or updated by the mutation.
  41734. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  41735. switch {
  41736. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41737. id, exists := m.ID()
  41738. if exists {
  41739. return []uint64{id}, nil
  41740. }
  41741. fallthrough
  41742. case m.op.Is(OpUpdate | OpDelete):
  41743. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  41744. default:
  41745. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41746. }
  41747. }
  41748. // SetCreatedAt sets the "created_at" field.
  41749. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  41750. m.created_at = &t
  41751. }
  41752. // CreatedAt returns the value of the "created_at" field in the mutation.
  41753. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  41754. v := m.created_at
  41755. if v == nil {
  41756. return
  41757. }
  41758. return *v, true
  41759. }
  41760. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  41761. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41763. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41764. if !m.op.Is(OpUpdateOne) {
  41765. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41766. }
  41767. if m.id == nil || m.oldValue == nil {
  41768. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41769. }
  41770. oldValue, err := m.oldValue(ctx)
  41771. if err != nil {
  41772. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41773. }
  41774. return oldValue.CreatedAt, nil
  41775. }
  41776. // ResetCreatedAt resets all changes to the "created_at" field.
  41777. func (m *WxCardMutation) ResetCreatedAt() {
  41778. m.created_at = nil
  41779. }
  41780. // SetUpdatedAt sets the "updated_at" field.
  41781. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  41782. m.updated_at = &t
  41783. }
  41784. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41785. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  41786. v := m.updated_at
  41787. if v == nil {
  41788. return
  41789. }
  41790. return *v, true
  41791. }
  41792. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  41793. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41795. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41796. if !m.op.Is(OpUpdateOne) {
  41797. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41798. }
  41799. if m.id == nil || m.oldValue == nil {
  41800. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41801. }
  41802. oldValue, err := m.oldValue(ctx)
  41803. if err != nil {
  41804. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41805. }
  41806. return oldValue.UpdatedAt, nil
  41807. }
  41808. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41809. func (m *WxCardMutation) ResetUpdatedAt() {
  41810. m.updated_at = nil
  41811. }
  41812. // SetDeletedAt sets the "deleted_at" field.
  41813. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  41814. m.deleted_at = &t
  41815. }
  41816. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41817. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  41818. v := m.deleted_at
  41819. if v == nil {
  41820. return
  41821. }
  41822. return *v, true
  41823. }
  41824. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  41825. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41827. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41828. if !m.op.Is(OpUpdateOne) {
  41829. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41830. }
  41831. if m.id == nil || m.oldValue == nil {
  41832. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41833. }
  41834. oldValue, err := m.oldValue(ctx)
  41835. if err != nil {
  41836. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41837. }
  41838. return oldValue.DeletedAt, nil
  41839. }
  41840. // ClearDeletedAt clears the value of the "deleted_at" field.
  41841. func (m *WxCardMutation) ClearDeletedAt() {
  41842. m.deleted_at = nil
  41843. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  41844. }
  41845. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41846. func (m *WxCardMutation) DeletedAtCleared() bool {
  41847. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  41848. return ok
  41849. }
  41850. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41851. func (m *WxCardMutation) ResetDeletedAt() {
  41852. m.deleted_at = nil
  41853. delete(m.clearedFields, wxcard.FieldDeletedAt)
  41854. }
  41855. // SetUserID sets the "user_id" field.
  41856. func (m *WxCardMutation) SetUserID(u uint64) {
  41857. m.user_id = &u
  41858. m.adduser_id = nil
  41859. }
  41860. // UserID returns the value of the "user_id" field in the mutation.
  41861. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  41862. v := m.user_id
  41863. if v == nil {
  41864. return
  41865. }
  41866. return *v, true
  41867. }
  41868. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  41869. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41871. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  41872. if !m.op.Is(OpUpdateOne) {
  41873. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  41874. }
  41875. if m.id == nil || m.oldValue == nil {
  41876. return v, errors.New("OldUserID requires an ID field in the mutation")
  41877. }
  41878. oldValue, err := m.oldValue(ctx)
  41879. if err != nil {
  41880. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  41881. }
  41882. return oldValue.UserID, nil
  41883. }
  41884. // AddUserID adds u to the "user_id" field.
  41885. func (m *WxCardMutation) AddUserID(u int64) {
  41886. if m.adduser_id != nil {
  41887. *m.adduser_id += u
  41888. } else {
  41889. m.adduser_id = &u
  41890. }
  41891. }
  41892. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  41893. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  41894. v := m.adduser_id
  41895. if v == nil {
  41896. return
  41897. }
  41898. return *v, true
  41899. }
  41900. // ClearUserID clears the value of the "user_id" field.
  41901. func (m *WxCardMutation) ClearUserID() {
  41902. m.user_id = nil
  41903. m.adduser_id = nil
  41904. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  41905. }
  41906. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  41907. func (m *WxCardMutation) UserIDCleared() bool {
  41908. _, ok := m.clearedFields[wxcard.FieldUserID]
  41909. return ok
  41910. }
  41911. // ResetUserID resets all changes to the "user_id" field.
  41912. func (m *WxCardMutation) ResetUserID() {
  41913. m.user_id = nil
  41914. m.adduser_id = nil
  41915. delete(m.clearedFields, wxcard.FieldUserID)
  41916. }
  41917. // SetWxUserID sets the "wx_user_id" field.
  41918. func (m *WxCardMutation) SetWxUserID(u uint64) {
  41919. m.wx_user_id = &u
  41920. m.addwx_user_id = nil
  41921. }
  41922. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  41923. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  41924. v := m.wx_user_id
  41925. if v == nil {
  41926. return
  41927. }
  41928. return *v, true
  41929. }
  41930. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  41931. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41933. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  41934. if !m.op.Is(OpUpdateOne) {
  41935. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  41936. }
  41937. if m.id == nil || m.oldValue == nil {
  41938. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  41939. }
  41940. oldValue, err := m.oldValue(ctx)
  41941. if err != nil {
  41942. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  41943. }
  41944. return oldValue.WxUserID, nil
  41945. }
  41946. // AddWxUserID adds u to the "wx_user_id" field.
  41947. func (m *WxCardMutation) AddWxUserID(u int64) {
  41948. if m.addwx_user_id != nil {
  41949. *m.addwx_user_id += u
  41950. } else {
  41951. m.addwx_user_id = &u
  41952. }
  41953. }
  41954. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  41955. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  41956. v := m.addwx_user_id
  41957. if v == nil {
  41958. return
  41959. }
  41960. return *v, true
  41961. }
  41962. // ClearWxUserID clears the value of the "wx_user_id" field.
  41963. func (m *WxCardMutation) ClearWxUserID() {
  41964. m.wx_user_id = nil
  41965. m.addwx_user_id = nil
  41966. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  41967. }
  41968. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  41969. func (m *WxCardMutation) WxUserIDCleared() bool {
  41970. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  41971. return ok
  41972. }
  41973. // ResetWxUserID resets all changes to the "wx_user_id" field.
  41974. func (m *WxCardMutation) ResetWxUserID() {
  41975. m.wx_user_id = nil
  41976. m.addwx_user_id = nil
  41977. delete(m.clearedFields, wxcard.FieldWxUserID)
  41978. }
  41979. // SetAvatar sets the "avatar" field.
  41980. func (m *WxCardMutation) SetAvatar(s string) {
  41981. m.avatar = &s
  41982. }
  41983. // Avatar returns the value of the "avatar" field in the mutation.
  41984. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  41985. v := m.avatar
  41986. if v == nil {
  41987. return
  41988. }
  41989. return *v, true
  41990. }
  41991. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  41992. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41994. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41995. if !m.op.Is(OpUpdateOne) {
  41996. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41997. }
  41998. if m.id == nil || m.oldValue == nil {
  41999. return v, errors.New("OldAvatar requires an ID field in the mutation")
  42000. }
  42001. oldValue, err := m.oldValue(ctx)
  42002. if err != nil {
  42003. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  42004. }
  42005. return oldValue.Avatar, nil
  42006. }
  42007. // ResetAvatar resets all changes to the "avatar" field.
  42008. func (m *WxCardMutation) ResetAvatar() {
  42009. m.avatar = nil
  42010. }
  42011. // SetLogo sets the "logo" field.
  42012. func (m *WxCardMutation) SetLogo(s string) {
  42013. m.logo = &s
  42014. }
  42015. // Logo returns the value of the "logo" field in the mutation.
  42016. func (m *WxCardMutation) Logo() (r string, exists bool) {
  42017. v := m.logo
  42018. if v == nil {
  42019. return
  42020. }
  42021. return *v, true
  42022. }
  42023. // OldLogo returns the old "logo" field's value of the WxCard entity.
  42024. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42026. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  42027. if !m.op.Is(OpUpdateOne) {
  42028. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  42029. }
  42030. if m.id == nil || m.oldValue == nil {
  42031. return v, errors.New("OldLogo requires an ID field in the mutation")
  42032. }
  42033. oldValue, err := m.oldValue(ctx)
  42034. if err != nil {
  42035. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  42036. }
  42037. return oldValue.Logo, nil
  42038. }
  42039. // ResetLogo resets all changes to the "logo" field.
  42040. func (m *WxCardMutation) ResetLogo() {
  42041. m.logo = nil
  42042. }
  42043. // SetName sets the "name" field.
  42044. func (m *WxCardMutation) SetName(s string) {
  42045. m.name = &s
  42046. }
  42047. // Name returns the value of the "name" field in the mutation.
  42048. func (m *WxCardMutation) Name() (r string, exists bool) {
  42049. v := m.name
  42050. if v == nil {
  42051. return
  42052. }
  42053. return *v, true
  42054. }
  42055. // OldName returns the old "name" field's value of the WxCard entity.
  42056. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42058. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  42059. if !m.op.Is(OpUpdateOne) {
  42060. return v, errors.New("OldName is only allowed on UpdateOne operations")
  42061. }
  42062. if m.id == nil || m.oldValue == nil {
  42063. return v, errors.New("OldName requires an ID field in the mutation")
  42064. }
  42065. oldValue, err := m.oldValue(ctx)
  42066. if err != nil {
  42067. return v, fmt.Errorf("querying old value for OldName: %w", err)
  42068. }
  42069. return oldValue.Name, nil
  42070. }
  42071. // ResetName resets all changes to the "name" field.
  42072. func (m *WxCardMutation) ResetName() {
  42073. m.name = nil
  42074. }
  42075. // SetCompany sets the "company" field.
  42076. func (m *WxCardMutation) SetCompany(s string) {
  42077. m.company = &s
  42078. }
  42079. // Company returns the value of the "company" field in the mutation.
  42080. func (m *WxCardMutation) Company() (r string, exists bool) {
  42081. v := m.company
  42082. if v == nil {
  42083. return
  42084. }
  42085. return *v, true
  42086. }
  42087. // OldCompany returns the old "company" field's value of the WxCard entity.
  42088. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42090. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  42091. if !m.op.Is(OpUpdateOne) {
  42092. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  42093. }
  42094. if m.id == nil || m.oldValue == nil {
  42095. return v, errors.New("OldCompany requires an ID field in the mutation")
  42096. }
  42097. oldValue, err := m.oldValue(ctx)
  42098. if err != nil {
  42099. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  42100. }
  42101. return oldValue.Company, nil
  42102. }
  42103. // ResetCompany resets all changes to the "company" field.
  42104. func (m *WxCardMutation) ResetCompany() {
  42105. m.company = nil
  42106. }
  42107. // SetAddress sets the "address" field.
  42108. func (m *WxCardMutation) SetAddress(s string) {
  42109. m.address = &s
  42110. }
  42111. // Address returns the value of the "address" field in the mutation.
  42112. func (m *WxCardMutation) Address() (r string, exists bool) {
  42113. v := m.address
  42114. if v == nil {
  42115. return
  42116. }
  42117. return *v, true
  42118. }
  42119. // OldAddress returns the old "address" field's value of the WxCard entity.
  42120. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42122. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  42123. if !m.op.Is(OpUpdateOne) {
  42124. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  42125. }
  42126. if m.id == nil || m.oldValue == nil {
  42127. return v, errors.New("OldAddress requires an ID field in the mutation")
  42128. }
  42129. oldValue, err := m.oldValue(ctx)
  42130. if err != nil {
  42131. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  42132. }
  42133. return oldValue.Address, nil
  42134. }
  42135. // ResetAddress resets all changes to the "address" field.
  42136. func (m *WxCardMutation) ResetAddress() {
  42137. m.address = nil
  42138. }
  42139. // SetPhone sets the "phone" field.
  42140. func (m *WxCardMutation) SetPhone(s string) {
  42141. m.phone = &s
  42142. }
  42143. // Phone returns the value of the "phone" field in the mutation.
  42144. func (m *WxCardMutation) Phone() (r string, exists bool) {
  42145. v := m.phone
  42146. if v == nil {
  42147. return
  42148. }
  42149. return *v, true
  42150. }
  42151. // OldPhone returns the old "phone" field's value of the WxCard entity.
  42152. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42154. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  42155. if !m.op.Is(OpUpdateOne) {
  42156. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  42157. }
  42158. if m.id == nil || m.oldValue == nil {
  42159. return v, errors.New("OldPhone requires an ID field in the mutation")
  42160. }
  42161. oldValue, err := m.oldValue(ctx)
  42162. if err != nil {
  42163. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  42164. }
  42165. return oldValue.Phone, nil
  42166. }
  42167. // ResetPhone resets all changes to the "phone" field.
  42168. func (m *WxCardMutation) ResetPhone() {
  42169. m.phone = nil
  42170. }
  42171. // SetOfficialAccount sets the "official_account" field.
  42172. func (m *WxCardMutation) SetOfficialAccount(s string) {
  42173. m.official_account = &s
  42174. }
  42175. // OfficialAccount returns the value of the "official_account" field in the mutation.
  42176. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  42177. v := m.official_account
  42178. if v == nil {
  42179. return
  42180. }
  42181. return *v, true
  42182. }
  42183. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  42184. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42186. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  42187. if !m.op.Is(OpUpdateOne) {
  42188. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  42189. }
  42190. if m.id == nil || m.oldValue == nil {
  42191. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  42192. }
  42193. oldValue, err := m.oldValue(ctx)
  42194. if err != nil {
  42195. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  42196. }
  42197. return oldValue.OfficialAccount, nil
  42198. }
  42199. // ResetOfficialAccount resets all changes to the "official_account" field.
  42200. func (m *WxCardMutation) ResetOfficialAccount() {
  42201. m.official_account = nil
  42202. }
  42203. // SetWechatAccount sets the "wechat_account" field.
  42204. func (m *WxCardMutation) SetWechatAccount(s string) {
  42205. m.wechat_account = &s
  42206. }
  42207. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  42208. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  42209. v := m.wechat_account
  42210. if v == nil {
  42211. return
  42212. }
  42213. return *v, true
  42214. }
  42215. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  42216. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42218. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  42219. if !m.op.Is(OpUpdateOne) {
  42220. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  42221. }
  42222. if m.id == nil || m.oldValue == nil {
  42223. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  42224. }
  42225. oldValue, err := m.oldValue(ctx)
  42226. if err != nil {
  42227. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  42228. }
  42229. return oldValue.WechatAccount, nil
  42230. }
  42231. // ResetWechatAccount resets all changes to the "wechat_account" field.
  42232. func (m *WxCardMutation) ResetWechatAccount() {
  42233. m.wechat_account = nil
  42234. }
  42235. // SetEmail sets the "email" field.
  42236. func (m *WxCardMutation) SetEmail(s string) {
  42237. m.email = &s
  42238. }
  42239. // Email returns the value of the "email" field in the mutation.
  42240. func (m *WxCardMutation) Email() (r string, exists bool) {
  42241. v := m.email
  42242. if v == nil {
  42243. return
  42244. }
  42245. return *v, true
  42246. }
  42247. // OldEmail returns the old "email" field's value of the WxCard entity.
  42248. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42250. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  42251. if !m.op.Is(OpUpdateOne) {
  42252. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  42253. }
  42254. if m.id == nil || m.oldValue == nil {
  42255. return v, errors.New("OldEmail requires an ID field in the mutation")
  42256. }
  42257. oldValue, err := m.oldValue(ctx)
  42258. if err != nil {
  42259. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  42260. }
  42261. return oldValue.Email, nil
  42262. }
  42263. // ClearEmail clears the value of the "email" field.
  42264. func (m *WxCardMutation) ClearEmail() {
  42265. m.email = nil
  42266. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  42267. }
  42268. // EmailCleared returns if the "email" field was cleared in this mutation.
  42269. func (m *WxCardMutation) EmailCleared() bool {
  42270. _, ok := m.clearedFields[wxcard.FieldEmail]
  42271. return ok
  42272. }
  42273. // ResetEmail resets all changes to the "email" field.
  42274. func (m *WxCardMutation) ResetEmail() {
  42275. m.email = nil
  42276. delete(m.clearedFields, wxcard.FieldEmail)
  42277. }
  42278. // SetAPIBase sets the "api_base" field.
  42279. func (m *WxCardMutation) SetAPIBase(s string) {
  42280. m.api_base = &s
  42281. }
  42282. // APIBase returns the value of the "api_base" field in the mutation.
  42283. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  42284. v := m.api_base
  42285. if v == nil {
  42286. return
  42287. }
  42288. return *v, true
  42289. }
  42290. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  42291. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42293. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42294. if !m.op.Is(OpUpdateOne) {
  42295. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42296. }
  42297. if m.id == nil || m.oldValue == nil {
  42298. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42299. }
  42300. oldValue, err := m.oldValue(ctx)
  42301. if err != nil {
  42302. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42303. }
  42304. return oldValue.APIBase, nil
  42305. }
  42306. // ClearAPIBase clears the value of the "api_base" field.
  42307. func (m *WxCardMutation) ClearAPIBase() {
  42308. m.api_base = nil
  42309. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  42310. }
  42311. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42312. func (m *WxCardMutation) APIBaseCleared() bool {
  42313. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  42314. return ok
  42315. }
  42316. // ResetAPIBase resets all changes to the "api_base" field.
  42317. func (m *WxCardMutation) ResetAPIBase() {
  42318. m.api_base = nil
  42319. delete(m.clearedFields, wxcard.FieldAPIBase)
  42320. }
  42321. // SetAPIKey sets the "api_key" field.
  42322. func (m *WxCardMutation) SetAPIKey(s string) {
  42323. m.api_key = &s
  42324. }
  42325. // APIKey returns the value of the "api_key" field in the mutation.
  42326. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  42327. v := m.api_key
  42328. if v == nil {
  42329. return
  42330. }
  42331. return *v, true
  42332. }
  42333. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  42334. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42336. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42337. if !m.op.Is(OpUpdateOne) {
  42338. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42339. }
  42340. if m.id == nil || m.oldValue == nil {
  42341. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42342. }
  42343. oldValue, err := m.oldValue(ctx)
  42344. if err != nil {
  42345. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42346. }
  42347. return oldValue.APIKey, nil
  42348. }
  42349. // ClearAPIKey clears the value of the "api_key" field.
  42350. func (m *WxCardMutation) ClearAPIKey() {
  42351. m.api_key = nil
  42352. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  42353. }
  42354. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42355. func (m *WxCardMutation) APIKeyCleared() bool {
  42356. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  42357. return ok
  42358. }
  42359. // ResetAPIKey resets all changes to the "api_key" field.
  42360. func (m *WxCardMutation) ResetAPIKey() {
  42361. m.api_key = nil
  42362. delete(m.clearedFields, wxcard.FieldAPIKey)
  42363. }
  42364. // SetAiInfo sets the "ai_info" field.
  42365. func (m *WxCardMutation) SetAiInfo(s string) {
  42366. m.ai_info = &s
  42367. }
  42368. // AiInfo returns the value of the "ai_info" field in the mutation.
  42369. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  42370. v := m.ai_info
  42371. if v == nil {
  42372. return
  42373. }
  42374. return *v, true
  42375. }
  42376. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  42377. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42379. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  42380. if !m.op.Is(OpUpdateOne) {
  42381. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  42382. }
  42383. if m.id == nil || m.oldValue == nil {
  42384. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  42385. }
  42386. oldValue, err := m.oldValue(ctx)
  42387. if err != nil {
  42388. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  42389. }
  42390. return oldValue.AiInfo, nil
  42391. }
  42392. // ClearAiInfo clears the value of the "ai_info" field.
  42393. func (m *WxCardMutation) ClearAiInfo() {
  42394. m.ai_info = nil
  42395. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  42396. }
  42397. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  42398. func (m *WxCardMutation) AiInfoCleared() bool {
  42399. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  42400. return ok
  42401. }
  42402. // ResetAiInfo resets all changes to the "ai_info" field.
  42403. func (m *WxCardMutation) ResetAiInfo() {
  42404. m.ai_info = nil
  42405. delete(m.clearedFields, wxcard.FieldAiInfo)
  42406. }
  42407. // SetIntro sets the "intro" field.
  42408. func (m *WxCardMutation) SetIntro(s string) {
  42409. m.intro = &s
  42410. }
  42411. // Intro returns the value of the "intro" field in the mutation.
  42412. func (m *WxCardMutation) Intro() (r string, exists bool) {
  42413. v := m.intro
  42414. if v == nil {
  42415. return
  42416. }
  42417. return *v, true
  42418. }
  42419. // OldIntro returns the old "intro" field's value of the WxCard entity.
  42420. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42422. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  42423. if !m.op.Is(OpUpdateOne) {
  42424. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  42425. }
  42426. if m.id == nil || m.oldValue == nil {
  42427. return v, errors.New("OldIntro requires an ID field in the mutation")
  42428. }
  42429. oldValue, err := m.oldValue(ctx)
  42430. if err != nil {
  42431. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  42432. }
  42433. return oldValue.Intro, nil
  42434. }
  42435. // ClearIntro clears the value of the "intro" field.
  42436. func (m *WxCardMutation) ClearIntro() {
  42437. m.intro = nil
  42438. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  42439. }
  42440. // IntroCleared returns if the "intro" field was cleared in this mutation.
  42441. func (m *WxCardMutation) IntroCleared() bool {
  42442. _, ok := m.clearedFields[wxcard.FieldIntro]
  42443. return ok
  42444. }
  42445. // ResetIntro resets all changes to the "intro" field.
  42446. func (m *WxCardMutation) ResetIntro() {
  42447. m.intro = nil
  42448. delete(m.clearedFields, wxcard.FieldIntro)
  42449. }
  42450. // Where appends a list predicates to the WxCardMutation builder.
  42451. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  42452. m.predicates = append(m.predicates, ps...)
  42453. }
  42454. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  42455. // users can use type-assertion to append predicates that do not depend on any generated package.
  42456. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  42457. p := make([]predicate.WxCard, len(ps))
  42458. for i := range ps {
  42459. p[i] = ps[i]
  42460. }
  42461. m.Where(p...)
  42462. }
  42463. // Op returns the operation name.
  42464. func (m *WxCardMutation) Op() Op {
  42465. return m.op
  42466. }
  42467. // SetOp allows setting the mutation operation.
  42468. func (m *WxCardMutation) SetOp(op Op) {
  42469. m.op = op
  42470. }
  42471. // Type returns the node type of this mutation (WxCard).
  42472. func (m *WxCardMutation) Type() string {
  42473. return m.typ
  42474. }
  42475. // Fields returns all fields that were changed during this mutation. Note that in
  42476. // order to get all numeric fields that were incremented/decremented, call
  42477. // AddedFields().
  42478. func (m *WxCardMutation) Fields() []string {
  42479. fields := make([]string, 0, 18)
  42480. if m.created_at != nil {
  42481. fields = append(fields, wxcard.FieldCreatedAt)
  42482. }
  42483. if m.updated_at != nil {
  42484. fields = append(fields, wxcard.FieldUpdatedAt)
  42485. }
  42486. if m.deleted_at != nil {
  42487. fields = append(fields, wxcard.FieldDeletedAt)
  42488. }
  42489. if m.user_id != nil {
  42490. fields = append(fields, wxcard.FieldUserID)
  42491. }
  42492. if m.wx_user_id != nil {
  42493. fields = append(fields, wxcard.FieldWxUserID)
  42494. }
  42495. if m.avatar != nil {
  42496. fields = append(fields, wxcard.FieldAvatar)
  42497. }
  42498. if m.logo != nil {
  42499. fields = append(fields, wxcard.FieldLogo)
  42500. }
  42501. if m.name != nil {
  42502. fields = append(fields, wxcard.FieldName)
  42503. }
  42504. if m.company != nil {
  42505. fields = append(fields, wxcard.FieldCompany)
  42506. }
  42507. if m.address != nil {
  42508. fields = append(fields, wxcard.FieldAddress)
  42509. }
  42510. if m.phone != nil {
  42511. fields = append(fields, wxcard.FieldPhone)
  42512. }
  42513. if m.official_account != nil {
  42514. fields = append(fields, wxcard.FieldOfficialAccount)
  42515. }
  42516. if m.wechat_account != nil {
  42517. fields = append(fields, wxcard.FieldWechatAccount)
  42518. }
  42519. if m.email != nil {
  42520. fields = append(fields, wxcard.FieldEmail)
  42521. }
  42522. if m.api_base != nil {
  42523. fields = append(fields, wxcard.FieldAPIBase)
  42524. }
  42525. if m.api_key != nil {
  42526. fields = append(fields, wxcard.FieldAPIKey)
  42527. }
  42528. if m.ai_info != nil {
  42529. fields = append(fields, wxcard.FieldAiInfo)
  42530. }
  42531. if m.intro != nil {
  42532. fields = append(fields, wxcard.FieldIntro)
  42533. }
  42534. return fields
  42535. }
  42536. // Field returns the value of a field with the given name. The second boolean
  42537. // return value indicates that this field was not set, or was not defined in the
  42538. // schema.
  42539. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  42540. switch name {
  42541. case wxcard.FieldCreatedAt:
  42542. return m.CreatedAt()
  42543. case wxcard.FieldUpdatedAt:
  42544. return m.UpdatedAt()
  42545. case wxcard.FieldDeletedAt:
  42546. return m.DeletedAt()
  42547. case wxcard.FieldUserID:
  42548. return m.UserID()
  42549. case wxcard.FieldWxUserID:
  42550. return m.WxUserID()
  42551. case wxcard.FieldAvatar:
  42552. return m.Avatar()
  42553. case wxcard.FieldLogo:
  42554. return m.Logo()
  42555. case wxcard.FieldName:
  42556. return m.Name()
  42557. case wxcard.FieldCompany:
  42558. return m.Company()
  42559. case wxcard.FieldAddress:
  42560. return m.Address()
  42561. case wxcard.FieldPhone:
  42562. return m.Phone()
  42563. case wxcard.FieldOfficialAccount:
  42564. return m.OfficialAccount()
  42565. case wxcard.FieldWechatAccount:
  42566. return m.WechatAccount()
  42567. case wxcard.FieldEmail:
  42568. return m.Email()
  42569. case wxcard.FieldAPIBase:
  42570. return m.APIBase()
  42571. case wxcard.FieldAPIKey:
  42572. return m.APIKey()
  42573. case wxcard.FieldAiInfo:
  42574. return m.AiInfo()
  42575. case wxcard.FieldIntro:
  42576. return m.Intro()
  42577. }
  42578. return nil, false
  42579. }
  42580. // OldField returns the old value of the field from the database. An error is
  42581. // returned if the mutation operation is not UpdateOne, or the query to the
  42582. // database failed.
  42583. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42584. switch name {
  42585. case wxcard.FieldCreatedAt:
  42586. return m.OldCreatedAt(ctx)
  42587. case wxcard.FieldUpdatedAt:
  42588. return m.OldUpdatedAt(ctx)
  42589. case wxcard.FieldDeletedAt:
  42590. return m.OldDeletedAt(ctx)
  42591. case wxcard.FieldUserID:
  42592. return m.OldUserID(ctx)
  42593. case wxcard.FieldWxUserID:
  42594. return m.OldWxUserID(ctx)
  42595. case wxcard.FieldAvatar:
  42596. return m.OldAvatar(ctx)
  42597. case wxcard.FieldLogo:
  42598. return m.OldLogo(ctx)
  42599. case wxcard.FieldName:
  42600. return m.OldName(ctx)
  42601. case wxcard.FieldCompany:
  42602. return m.OldCompany(ctx)
  42603. case wxcard.FieldAddress:
  42604. return m.OldAddress(ctx)
  42605. case wxcard.FieldPhone:
  42606. return m.OldPhone(ctx)
  42607. case wxcard.FieldOfficialAccount:
  42608. return m.OldOfficialAccount(ctx)
  42609. case wxcard.FieldWechatAccount:
  42610. return m.OldWechatAccount(ctx)
  42611. case wxcard.FieldEmail:
  42612. return m.OldEmail(ctx)
  42613. case wxcard.FieldAPIBase:
  42614. return m.OldAPIBase(ctx)
  42615. case wxcard.FieldAPIKey:
  42616. return m.OldAPIKey(ctx)
  42617. case wxcard.FieldAiInfo:
  42618. return m.OldAiInfo(ctx)
  42619. case wxcard.FieldIntro:
  42620. return m.OldIntro(ctx)
  42621. }
  42622. return nil, fmt.Errorf("unknown WxCard field %s", name)
  42623. }
  42624. // SetField sets the value of a field with the given name. It returns an error if
  42625. // the field is not defined in the schema, or if the type mismatched the field
  42626. // type.
  42627. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  42628. switch name {
  42629. case wxcard.FieldCreatedAt:
  42630. v, ok := value.(time.Time)
  42631. if !ok {
  42632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42633. }
  42634. m.SetCreatedAt(v)
  42635. return nil
  42636. case wxcard.FieldUpdatedAt:
  42637. v, ok := value.(time.Time)
  42638. if !ok {
  42639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42640. }
  42641. m.SetUpdatedAt(v)
  42642. return nil
  42643. case wxcard.FieldDeletedAt:
  42644. v, ok := value.(time.Time)
  42645. if !ok {
  42646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42647. }
  42648. m.SetDeletedAt(v)
  42649. return nil
  42650. case wxcard.FieldUserID:
  42651. v, ok := value.(uint64)
  42652. if !ok {
  42653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42654. }
  42655. m.SetUserID(v)
  42656. return nil
  42657. case wxcard.FieldWxUserID:
  42658. v, ok := value.(uint64)
  42659. if !ok {
  42660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42661. }
  42662. m.SetWxUserID(v)
  42663. return nil
  42664. case wxcard.FieldAvatar:
  42665. v, ok := value.(string)
  42666. if !ok {
  42667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42668. }
  42669. m.SetAvatar(v)
  42670. return nil
  42671. case wxcard.FieldLogo:
  42672. v, ok := value.(string)
  42673. if !ok {
  42674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42675. }
  42676. m.SetLogo(v)
  42677. return nil
  42678. case wxcard.FieldName:
  42679. v, ok := value.(string)
  42680. if !ok {
  42681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42682. }
  42683. m.SetName(v)
  42684. return nil
  42685. case wxcard.FieldCompany:
  42686. v, ok := value.(string)
  42687. if !ok {
  42688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42689. }
  42690. m.SetCompany(v)
  42691. return nil
  42692. case wxcard.FieldAddress:
  42693. v, ok := value.(string)
  42694. if !ok {
  42695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42696. }
  42697. m.SetAddress(v)
  42698. return nil
  42699. case wxcard.FieldPhone:
  42700. v, ok := value.(string)
  42701. if !ok {
  42702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42703. }
  42704. m.SetPhone(v)
  42705. return nil
  42706. case wxcard.FieldOfficialAccount:
  42707. v, ok := value.(string)
  42708. if !ok {
  42709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42710. }
  42711. m.SetOfficialAccount(v)
  42712. return nil
  42713. case wxcard.FieldWechatAccount:
  42714. v, ok := value.(string)
  42715. if !ok {
  42716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42717. }
  42718. m.SetWechatAccount(v)
  42719. return nil
  42720. case wxcard.FieldEmail:
  42721. v, ok := value.(string)
  42722. if !ok {
  42723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42724. }
  42725. m.SetEmail(v)
  42726. return nil
  42727. case wxcard.FieldAPIBase:
  42728. v, ok := value.(string)
  42729. if !ok {
  42730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42731. }
  42732. m.SetAPIBase(v)
  42733. return nil
  42734. case wxcard.FieldAPIKey:
  42735. v, ok := value.(string)
  42736. if !ok {
  42737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42738. }
  42739. m.SetAPIKey(v)
  42740. return nil
  42741. case wxcard.FieldAiInfo:
  42742. v, ok := value.(string)
  42743. if !ok {
  42744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42745. }
  42746. m.SetAiInfo(v)
  42747. return nil
  42748. case wxcard.FieldIntro:
  42749. v, ok := value.(string)
  42750. if !ok {
  42751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42752. }
  42753. m.SetIntro(v)
  42754. return nil
  42755. }
  42756. return fmt.Errorf("unknown WxCard field %s", name)
  42757. }
  42758. // AddedFields returns all numeric fields that were incremented/decremented during
  42759. // this mutation.
  42760. func (m *WxCardMutation) AddedFields() []string {
  42761. var fields []string
  42762. if m.adduser_id != nil {
  42763. fields = append(fields, wxcard.FieldUserID)
  42764. }
  42765. if m.addwx_user_id != nil {
  42766. fields = append(fields, wxcard.FieldWxUserID)
  42767. }
  42768. return fields
  42769. }
  42770. // AddedField returns the numeric value that was incremented/decremented on a field
  42771. // with the given name. The second boolean return value indicates that this field
  42772. // was not set, or was not defined in the schema.
  42773. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  42774. switch name {
  42775. case wxcard.FieldUserID:
  42776. return m.AddedUserID()
  42777. case wxcard.FieldWxUserID:
  42778. return m.AddedWxUserID()
  42779. }
  42780. return nil, false
  42781. }
  42782. // AddField adds the value to the field with the given name. It returns an error if
  42783. // the field is not defined in the schema, or if the type mismatched the field
  42784. // type.
  42785. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  42786. switch name {
  42787. case wxcard.FieldUserID:
  42788. v, ok := value.(int64)
  42789. if !ok {
  42790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42791. }
  42792. m.AddUserID(v)
  42793. return nil
  42794. case wxcard.FieldWxUserID:
  42795. v, ok := value.(int64)
  42796. if !ok {
  42797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42798. }
  42799. m.AddWxUserID(v)
  42800. return nil
  42801. }
  42802. return fmt.Errorf("unknown WxCard numeric field %s", name)
  42803. }
  42804. // ClearedFields returns all nullable fields that were cleared during this
  42805. // mutation.
  42806. func (m *WxCardMutation) ClearedFields() []string {
  42807. var fields []string
  42808. if m.FieldCleared(wxcard.FieldDeletedAt) {
  42809. fields = append(fields, wxcard.FieldDeletedAt)
  42810. }
  42811. if m.FieldCleared(wxcard.FieldUserID) {
  42812. fields = append(fields, wxcard.FieldUserID)
  42813. }
  42814. if m.FieldCleared(wxcard.FieldWxUserID) {
  42815. fields = append(fields, wxcard.FieldWxUserID)
  42816. }
  42817. if m.FieldCleared(wxcard.FieldEmail) {
  42818. fields = append(fields, wxcard.FieldEmail)
  42819. }
  42820. if m.FieldCleared(wxcard.FieldAPIBase) {
  42821. fields = append(fields, wxcard.FieldAPIBase)
  42822. }
  42823. if m.FieldCleared(wxcard.FieldAPIKey) {
  42824. fields = append(fields, wxcard.FieldAPIKey)
  42825. }
  42826. if m.FieldCleared(wxcard.FieldAiInfo) {
  42827. fields = append(fields, wxcard.FieldAiInfo)
  42828. }
  42829. if m.FieldCleared(wxcard.FieldIntro) {
  42830. fields = append(fields, wxcard.FieldIntro)
  42831. }
  42832. return fields
  42833. }
  42834. // FieldCleared returns a boolean indicating if a field with the given name was
  42835. // cleared in this mutation.
  42836. func (m *WxCardMutation) FieldCleared(name string) bool {
  42837. _, ok := m.clearedFields[name]
  42838. return ok
  42839. }
  42840. // ClearField clears the value of the field with the given name. It returns an
  42841. // error if the field is not defined in the schema.
  42842. func (m *WxCardMutation) ClearField(name string) error {
  42843. switch name {
  42844. case wxcard.FieldDeletedAt:
  42845. m.ClearDeletedAt()
  42846. return nil
  42847. case wxcard.FieldUserID:
  42848. m.ClearUserID()
  42849. return nil
  42850. case wxcard.FieldWxUserID:
  42851. m.ClearWxUserID()
  42852. return nil
  42853. case wxcard.FieldEmail:
  42854. m.ClearEmail()
  42855. return nil
  42856. case wxcard.FieldAPIBase:
  42857. m.ClearAPIBase()
  42858. return nil
  42859. case wxcard.FieldAPIKey:
  42860. m.ClearAPIKey()
  42861. return nil
  42862. case wxcard.FieldAiInfo:
  42863. m.ClearAiInfo()
  42864. return nil
  42865. case wxcard.FieldIntro:
  42866. m.ClearIntro()
  42867. return nil
  42868. }
  42869. return fmt.Errorf("unknown WxCard nullable field %s", name)
  42870. }
  42871. // ResetField resets all changes in the mutation for the field with the given name.
  42872. // It returns an error if the field is not defined in the schema.
  42873. func (m *WxCardMutation) ResetField(name string) error {
  42874. switch name {
  42875. case wxcard.FieldCreatedAt:
  42876. m.ResetCreatedAt()
  42877. return nil
  42878. case wxcard.FieldUpdatedAt:
  42879. m.ResetUpdatedAt()
  42880. return nil
  42881. case wxcard.FieldDeletedAt:
  42882. m.ResetDeletedAt()
  42883. return nil
  42884. case wxcard.FieldUserID:
  42885. m.ResetUserID()
  42886. return nil
  42887. case wxcard.FieldWxUserID:
  42888. m.ResetWxUserID()
  42889. return nil
  42890. case wxcard.FieldAvatar:
  42891. m.ResetAvatar()
  42892. return nil
  42893. case wxcard.FieldLogo:
  42894. m.ResetLogo()
  42895. return nil
  42896. case wxcard.FieldName:
  42897. m.ResetName()
  42898. return nil
  42899. case wxcard.FieldCompany:
  42900. m.ResetCompany()
  42901. return nil
  42902. case wxcard.FieldAddress:
  42903. m.ResetAddress()
  42904. return nil
  42905. case wxcard.FieldPhone:
  42906. m.ResetPhone()
  42907. return nil
  42908. case wxcard.FieldOfficialAccount:
  42909. m.ResetOfficialAccount()
  42910. return nil
  42911. case wxcard.FieldWechatAccount:
  42912. m.ResetWechatAccount()
  42913. return nil
  42914. case wxcard.FieldEmail:
  42915. m.ResetEmail()
  42916. return nil
  42917. case wxcard.FieldAPIBase:
  42918. m.ResetAPIBase()
  42919. return nil
  42920. case wxcard.FieldAPIKey:
  42921. m.ResetAPIKey()
  42922. return nil
  42923. case wxcard.FieldAiInfo:
  42924. m.ResetAiInfo()
  42925. return nil
  42926. case wxcard.FieldIntro:
  42927. m.ResetIntro()
  42928. return nil
  42929. }
  42930. return fmt.Errorf("unknown WxCard field %s", name)
  42931. }
  42932. // AddedEdges returns all edge names that were set/added in this mutation.
  42933. func (m *WxCardMutation) AddedEdges() []string {
  42934. edges := make([]string, 0, 0)
  42935. return edges
  42936. }
  42937. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42938. // name in this mutation.
  42939. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  42940. return nil
  42941. }
  42942. // RemovedEdges returns all edge names that were removed in this mutation.
  42943. func (m *WxCardMutation) RemovedEdges() []string {
  42944. edges := make([]string, 0, 0)
  42945. return edges
  42946. }
  42947. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42948. // the given name in this mutation.
  42949. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  42950. return nil
  42951. }
  42952. // ClearedEdges returns all edge names that were cleared in this mutation.
  42953. func (m *WxCardMutation) ClearedEdges() []string {
  42954. edges := make([]string, 0, 0)
  42955. return edges
  42956. }
  42957. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42958. // was cleared in this mutation.
  42959. func (m *WxCardMutation) EdgeCleared(name string) bool {
  42960. return false
  42961. }
  42962. // ClearEdge clears the value of the edge with the given name. It returns an error
  42963. // if that edge is not defined in the schema.
  42964. func (m *WxCardMutation) ClearEdge(name string) error {
  42965. return fmt.Errorf("unknown WxCard unique edge %s", name)
  42966. }
  42967. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42968. // It returns an error if the edge is not defined in the schema.
  42969. func (m *WxCardMutation) ResetEdge(name string) error {
  42970. return fmt.Errorf("unknown WxCard edge %s", name)
  42971. }
  42972. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  42973. type WxCardUserMutation struct {
  42974. config
  42975. op Op
  42976. typ string
  42977. id *uint64
  42978. created_at *time.Time
  42979. updated_at *time.Time
  42980. deleted_at *time.Time
  42981. wxid *string
  42982. account *string
  42983. avatar *string
  42984. nickname *string
  42985. remark *string
  42986. phone *string
  42987. open_id *string
  42988. union_id *string
  42989. session_key *string
  42990. is_vip *int
  42991. addis_vip *int
  42992. clearedFields map[string]struct{}
  42993. done bool
  42994. oldValue func(context.Context) (*WxCardUser, error)
  42995. predicates []predicate.WxCardUser
  42996. }
  42997. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  42998. // wxcarduserOption allows management of the mutation configuration using functional options.
  42999. type wxcarduserOption func(*WxCardUserMutation)
  43000. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  43001. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  43002. m := &WxCardUserMutation{
  43003. config: c,
  43004. op: op,
  43005. typ: TypeWxCardUser,
  43006. clearedFields: make(map[string]struct{}),
  43007. }
  43008. for _, opt := range opts {
  43009. opt(m)
  43010. }
  43011. return m
  43012. }
  43013. // withWxCardUserID sets the ID field of the mutation.
  43014. func withWxCardUserID(id uint64) wxcarduserOption {
  43015. return func(m *WxCardUserMutation) {
  43016. var (
  43017. err error
  43018. once sync.Once
  43019. value *WxCardUser
  43020. )
  43021. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  43022. once.Do(func() {
  43023. if m.done {
  43024. err = errors.New("querying old values post mutation is not allowed")
  43025. } else {
  43026. value, err = m.Client().WxCardUser.Get(ctx, id)
  43027. }
  43028. })
  43029. return value, err
  43030. }
  43031. m.id = &id
  43032. }
  43033. }
  43034. // withWxCardUser sets the old WxCardUser of the mutation.
  43035. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  43036. return func(m *WxCardUserMutation) {
  43037. m.oldValue = func(context.Context) (*WxCardUser, error) {
  43038. return node, nil
  43039. }
  43040. m.id = &node.ID
  43041. }
  43042. }
  43043. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43044. // executed in a transaction (ent.Tx), a transactional client is returned.
  43045. func (m WxCardUserMutation) Client() *Client {
  43046. client := &Client{config: m.config}
  43047. client.init()
  43048. return client
  43049. }
  43050. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43051. // it returns an error otherwise.
  43052. func (m WxCardUserMutation) Tx() (*Tx, error) {
  43053. if _, ok := m.driver.(*txDriver); !ok {
  43054. return nil, errors.New("ent: mutation is not running in a transaction")
  43055. }
  43056. tx := &Tx{config: m.config}
  43057. tx.init()
  43058. return tx, nil
  43059. }
  43060. // SetID sets the value of the id field. Note that this
  43061. // operation is only accepted on creation of WxCardUser entities.
  43062. func (m *WxCardUserMutation) SetID(id uint64) {
  43063. m.id = &id
  43064. }
  43065. // ID returns the ID value in the mutation. Note that the ID is only available
  43066. // if it was provided to the builder or after it was returned from the database.
  43067. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  43068. if m.id == nil {
  43069. return
  43070. }
  43071. return *m.id, true
  43072. }
  43073. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43074. // That means, if the mutation is applied within a transaction with an isolation level such
  43075. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43076. // or updated by the mutation.
  43077. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  43078. switch {
  43079. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43080. id, exists := m.ID()
  43081. if exists {
  43082. return []uint64{id}, nil
  43083. }
  43084. fallthrough
  43085. case m.op.Is(OpUpdate | OpDelete):
  43086. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  43087. default:
  43088. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43089. }
  43090. }
  43091. // SetCreatedAt sets the "created_at" field.
  43092. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  43093. m.created_at = &t
  43094. }
  43095. // CreatedAt returns the value of the "created_at" field in the mutation.
  43096. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  43097. v := m.created_at
  43098. if v == nil {
  43099. return
  43100. }
  43101. return *v, true
  43102. }
  43103. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  43104. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43106. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43107. if !m.op.Is(OpUpdateOne) {
  43108. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43109. }
  43110. if m.id == nil || m.oldValue == nil {
  43111. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43112. }
  43113. oldValue, err := m.oldValue(ctx)
  43114. if err != nil {
  43115. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43116. }
  43117. return oldValue.CreatedAt, nil
  43118. }
  43119. // ResetCreatedAt resets all changes to the "created_at" field.
  43120. func (m *WxCardUserMutation) ResetCreatedAt() {
  43121. m.created_at = nil
  43122. }
  43123. // SetUpdatedAt sets the "updated_at" field.
  43124. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  43125. m.updated_at = &t
  43126. }
  43127. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43128. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  43129. v := m.updated_at
  43130. if v == nil {
  43131. return
  43132. }
  43133. return *v, true
  43134. }
  43135. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  43136. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43138. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43139. if !m.op.Is(OpUpdateOne) {
  43140. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43141. }
  43142. if m.id == nil || m.oldValue == nil {
  43143. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43144. }
  43145. oldValue, err := m.oldValue(ctx)
  43146. if err != nil {
  43147. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43148. }
  43149. return oldValue.UpdatedAt, nil
  43150. }
  43151. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43152. func (m *WxCardUserMutation) ResetUpdatedAt() {
  43153. m.updated_at = nil
  43154. }
  43155. // SetDeletedAt sets the "deleted_at" field.
  43156. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  43157. m.deleted_at = &t
  43158. }
  43159. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43160. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  43161. v := m.deleted_at
  43162. if v == nil {
  43163. return
  43164. }
  43165. return *v, true
  43166. }
  43167. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  43168. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43170. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43171. if !m.op.Is(OpUpdateOne) {
  43172. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43173. }
  43174. if m.id == nil || m.oldValue == nil {
  43175. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43176. }
  43177. oldValue, err := m.oldValue(ctx)
  43178. if err != nil {
  43179. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43180. }
  43181. return oldValue.DeletedAt, nil
  43182. }
  43183. // ClearDeletedAt clears the value of the "deleted_at" field.
  43184. func (m *WxCardUserMutation) ClearDeletedAt() {
  43185. m.deleted_at = nil
  43186. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  43187. }
  43188. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43189. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  43190. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  43191. return ok
  43192. }
  43193. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43194. func (m *WxCardUserMutation) ResetDeletedAt() {
  43195. m.deleted_at = nil
  43196. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  43197. }
  43198. // SetWxid sets the "wxid" field.
  43199. func (m *WxCardUserMutation) SetWxid(s string) {
  43200. m.wxid = &s
  43201. }
  43202. // Wxid returns the value of the "wxid" field in the mutation.
  43203. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  43204. v := m.wxid
  43205. if v == nil {
  43206. return
  43207. }
  43208. return *v, true
  43209. }
  43210. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  43211. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43213. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  43214. if !m.op.Is(OpUpdateOne) {
  43215. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  43216. }
  43217. if m.id == nil || m.oldValue == nil {
  43218. return v, errors.New("OldWxid requires an ID field in the mutation")
  43219. }
  43220. oldValue, err := m.oldValue(ctx)
  43221. if err != nil {
  43222. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  43223. }
  43224. return oldValue.Wxid, nil
  43225. }
  43226. // ResetWxid resets all changes to the "wxid" field.
  43227. func (m *WxCardUserMutation) ResetWxid() {
  43228. m.wxid = nil
  43229. }
  43230. // SetAccount sets the "account" field.
  43231. func (m *WxCardUserMutation) SetAccount(s string) {
  43232. m.account = &s
  43233. }
  43234. // Account returns the value of the "account" field in the mutation.
  43235. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  43236. v := m.account
  43237. if v == nil {
  43238. return
  43239. }
  43240. return *v, true
  43241. }
  43242. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  43243. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43245. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  43246. if !m.op.Is(OpUpdateOne) {
  43247. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  43248. }
  43249. if m.id == nil || m.oldValue == nil {
  43250. return v, errors.New("OldAccount requires an ID field in the mutation")
  43251. }
  43252. oldValue, err := m.oldValue(ctx)
  43253. if err != nil {
  43254. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  43255. }
  43256. return oldValue.Account, nil
  43257. }
  43258. // ResetAccount resets all changes to the "account" field.
  43259. func (m *WxCardUserMutation) ResetAccount() {
  43260. m.account = nil
  43261. }
  43262. // SetAvatar sets the "avatar" field.
  43263. func (m *WxCardUserMutation) SetAvatar(s string) {
  43264. m.avatar = &s
  43265. }
  43266. // Avatar returns the value of the "avatar" field in the mutation.
  43267. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  43268. v := m.avatar
  43269. if v == nil {
  43270. return
  43271. }
  43272. return *v, true
  43273. }
  43274. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  43275. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43277. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43278. if !m.op.Is(OpUpdateOne) {
  43279. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43280. }
  43281. if m.id == nil || m.oldValue == nil {
  43282. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43283. }
  43284. oldValue, err := m.oldValue(ctx)
  43285. if err != nil {
  43286. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43287. }
  43288. return oldValue.Avatar, nil
  43289. }
  43290. // ResetAvatar resets all changes to the "avatar" field.
  43291. func (m *WxCardUserMutation) ResetAvatar() {
  43292. m.avatar = nil
  43293. }
  43294. // SetNickname sets the "nickname" field.
  43295. func (m *WxCardUserMutation) SetNickname(s string) {
  43296. m.nickname = &s
  43297. }
  43298. // Nickname returns the value of the "nickname" field in the mutation.
  43299. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  43300. v := m.nickname
  43301. if v == nil {
  43302. return
  43303. }
  43304. return *v, true
  43305. }
  43306. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  43307. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43309. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  43310. if !m.op.Is(OpUpdateOne) {
  43311. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  43312. }
  43313. if m.id == nil || m.oldValue == nil {
  43314. return v, errors.New("OldNickname requires an ID field in the mutation")
  43315. }
  43316. oldValue, err := m.oldValue(ctx)
  43317. if err != nil {
  43318. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  43319. }
  43320. return oldValue.Nickname, nil
  43321. }
  43322. // ResetNickname resets all changes to the "nickname" field.
  43323. func (m *WxCardUserMutation) ResetNickname() {
  43324. m.nickname = nil
  43325. }
  43326. // SetRemark sets the "remark" field.
  43327. func (m *WxCardUserMutation) SetRemark(s string) {
  43328. m.remark = &s
  43329. }
  43330. // Remark returns the value of the "remark" field in the mutation.
  43331. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  43332. v := m.remark
  43333. if v == nil {
  43334. return
  43335. }
  43336. return *v, true
  43337. }
  43338. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  43339. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43341. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  43342. if !m.op.Is(OpUpdateOne) {
  43343. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  43344. }
  43345. if m.id == nil || m.oldValue == nil {
  43346. return v, errors.New("OldRemark requires an ID field in the mutation")
  43347. }
  43348. oldValue, err := m.oldValue(ctx)
  43349. if err != nil {
  43350. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  43351. }
  43352. return oldValue.Remark, nil
  43353. }
  43354. // ResetRemark resets all changes to the "remark" field.
  43355. func (m *WxCardUserMutation) ResetRemark() {
  43356. m.remark = nil
  43357. }
  43358. // SetPhone sets the "phone" field.
  43359. func (m *WxCardUserMutation) SetPhone(s string) {
  43360. m.phone = &s
  43361. }
  43362. // Phone returns the value of the "phone" field in the mutation.
  43363. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  43364. v := m.phone
  43365. if v == nil {
  43366. return
  43367. }
  43368. return *v, true
  43369. }
  43370. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  43371. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43373. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  43374. if !m.op.Is(OpUpdateOne) {
  43375. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43376. }
  43377. if m.id == nil || m.oldValue == nil {
  43378. return v, errors.New("OldPhone requires an ID field in the mutation")
  43379. }
  43380. oldValue, err := m.oldValue(ctx)
  43381. if err != nil {
  43382. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43383. }
  43384. return oldValue.Phone, nil
  43385. }
  43386. // ResetPhone resets all changes to the "phone" field.
  43387. func (m *WxCardUserMutation) ResetPhone() {
  43388. m.phone = nil
  43389. }
  43390. // SetOpenID sets the "open_id" field.
  43391. func (m *WxCardUserMutation) SetOpenID(s string) {
  43392. m.open_id = &s
  43393. }
  43394. // OpenID returns the value of the "open_id" field in the mutation.
  43395. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  43396. v := m.open_id
  43397. if v == nil {
  43398. return
  43399. }
  43400. return *v, true
  43401. }
  43402. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  43403. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43405. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  43406. if !m.op.Is(OpUpdateOne) {
  43407. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  43408. }
  43409. if m.id == nil || m.oldValue == nil {
  43410. return v, errors.New("OldOpenID requires an ID field in the mutation")
  43411. }
  43412. oldValue, err := m.oldValue(ctx)
  43413. if err != nil {
  43414. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  43415. }
  43416. return oldValue.OpenID, nil
  43417. }
  43418. // ResetOpenID resets all changes to the "open_id" field.
  43419. func (m *WxCardUserMutation) ResetOpenID() {
  43420. m.open_id = nil
  43421. }
  43422. // SetUnionID sets the "union_id" field.
  43423. func (m *WxCardUserMutation) SetUnionID(s string) {
  43424. m.union_id = &s
  43425. }
  43426. // UnionID returns the value of the "union_id" field in the mutation.
  43427. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  43428. v := m.union_id
  43429. if v == nil {
  43430. return
  43431. }
  43432. return *v, true
  43433. }
  43434. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  43435. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43437. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  43438. if !m.op.Is(OpUpdateOne) {
  43439. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  43440. }
  43441. if m.id == nil || m.oldValue == nil {
  43442. return v, errors.New("OldUnionID requires an ID field in the mutation")
  43443. }
  43444. oldValue, err := m.oldValue(ctx)
  43445. if err != nil {
  43446. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  43447. }
  43448. return oldValue.UnionID, nil
  43449. }
  43450. // ResetUnionID resets all changes to the "union_id" field.
  43451. func (m *WxCardUserMutation) ResetUnionID() {
  43452. m.union_id = nil
  43453. }
  43454. // SetSessionKey sets the "session_key" field.
  43455. func (m *WxCardUserMutation) SetSessionKey(s string) {
  43456. m.session_key = &s
  43457. }
  43458. // SessionKey returns the value of the "session_key" field in the mutation.
  43459. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  43460. v := m.session_key
  43461. if v == nil {
  43462. return
  43463. }
  43464. return *v, true
  43465. }
  43466. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  43467. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43469. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  43470. if !m.op.Is(OpUpdateOne) {
  43471. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  43472. }
  43473. if m.id == nil || m.oldValue == nil {
  43474. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  43475. }
  43476. oldValue, err := m.oldValue(ctx)
  43477. if err != nil {
  43478. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  43479. }
  43480. return oldValue.SessionKey, nil
  43481. }
  43482. // ResetSessionKey resets all changes to the "session_key" field.
  43483. func (m *WxCardUserMutation) ResetSessionKey() {
  43484. m.session_key = nil
  43485. }
  43486. // SetIsVip sets the "is_vip" field.
  43487. func (m *WxCardUserMutation) SetIsVip(i int) {
  43488. m.is_vip = &i
  43489. m.addis_vip = nil
  43490. }
  43491. // IsVip returns the value of the "is_vip" field in the mutation.
  43492. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  43493. v := m.is_vip
  43494. if v == nil {
  43495. return
  43496. }
  43497. return *v, true
  43498. }
  43499. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  43500. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43502. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  43503. if !m.op.Is(OpUpdateOne) {
  43504. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  43505. }
  43506. if m.id == nil || m.oldValue == nil {
  43507. return v, errors.New("OldIsVip requires an ID field in the mutation")
  43508. }
  43509. oldValue, err := m.oldValue(ctx)
  43510. if err != nil {
  43511. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  43512. }
  43513. return oldValue.IsVip, nil
  43514. }
  43515. // AddIsVip adds i to the "is_vip" field.
  43516. func (m *WxCardUserMutation) AddIsVip(i int) {
  43517. if m.addis_vip != nil {
  43518. *m.addis_vip += i
  43519. } else {
  43520. m.addis_vip = &i
  43521. }
  43522. }
  43523. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  43524. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  43525. v := m.addis_vip
  43526. if v == nil {
  43527. return
  43528. }
  43529. return *v, true
  43530. }
  43531. // ResetIsVip resets all changes to the "is_vip" field.
  43532. func (m *WxCardUserMutation) ResetIsVip() {
  43533. m.is_vip = nil
  43534. m.addis_vip = nil
  43535. }
  43536. // Where appends a list predicates to the WxCardUserMutation builder.
  43537. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  43538. m.predicates = append(m.predicates, ps...)
  43539. }
  43540. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  43541. // users can use type-assertion to append predicates that do not depend on any generated package.
  43542. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  43543. p := make([]predicate.WxCardUser, len(ps))
  43544. for i := range ps {
  43545. p[i] = ps[i]
  43546. }
  43547. m.Where(p...)
  43548. }
  43549. // Op returns the operation name.
  43550. func (m *WxCardUserMutation) Op() Op {
  43551. return m.op
  43552. }
  43553. // SetOp allows setting the mutation operation.
  43554. func (m *WxCardUserMutation) SetOp(op Op) {
  43555. m.op = op
  43556. }
  43557. // Type returns the node type of this mutation (WxCardUser).
  43558. func (m *WxCardUserMutation) Type() string {
  43559. return m.typ
  43560. }
  43561. // Fields returns all fields that were changed during this mutation. Note that in
  43562. // order to get all numeric fields that were incremented/decremented, call
  43563. // AddedFields().
  43564. func (m *WxCardUserMutation) Fields() []string {
  43565. fields := make([]string, 0, 13)
  43566. if m.created_at != nil {
  43567. fields = append(fields, wxcarduser.FieldCreatedAt)
  43568. }
  43569. if m.updated_at != nil {
  43570. fields = append(fields, wxcarduser.FieldUpdatedAt)
  43571. }
  43572. if m.deleted_at != nil {
  43573. fields = append(fields, wxcarduser.FieldDeletedAt)
  43574. }
  43575. if m.wxid != nil {
  43576. fields = append(fields, wxcarduser.FieldWxid)
  43577. }
  43578. if m.account != nil {
  43579. fields = append(fields, wxcarduser.FieldAccount)
  43580. }
  43581. if m.avatar != nil {
  43582. fields = append(fields, wxcarduser.FieldAvatar)
  43583. }
  43584. if m.nickname != nil {
  43585. fields = append(fields, wxcarduser.FieldNickname)
  43586. }
  43587. if m.remark != nil {
  43588. fields = append(fields, wxcarduser.FieldRemark)
  43589. }
  43590. if m.phone != nil {
  43591. fields = append(fields, wxcarduser.FieldPhone)
  43592. }
  43593. if m.open_id != nil {
  43594. fields = append(fields, wxcarduser.FieldOpenID)
  43595. }
  43596. if m.union_id != nil {
  43597. fields = append(fields, wxcarduser.FieldUnionID)
  43598. }
  43599. if m.session_key != nil {
  43600. fields = append(fields, wxcarduser.FieldSessionKey)
  43601. }
  43602. if m.is_vip != nil {
  43603. fields = append(fields, wxcarduser.FieldIsVip)
  43604. }
  43605. return fields
  43606. }
  43607. // Field returns the value of a field with the given name. The second boolean
  43608. // return value indicates that this field was not set, or was not defined in the
  43609. // schema.
  43610. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  43611. switch name {
  43612. case wxcarduser.FieldCreatedAt:
  43613. return m.CreatedAt()
  43614. case wxcarduser.FieldUpdatedAt:
  43615. return m.UpdatedAt()
  43616. case wxcarduser.FieldDeletedAt:
  43617. return m.DeletedAt()
  43618. case wxcarduser.FieldWxid:
  43619. return m.Wxid()
  43620. case wxcarduser.FieldAccount:
  43621. return m.Account()
  43622. case wxcarduser.FieldAvatar:
  43623. return m.Avatar()
  43624. case wxcarduser.FieldNickname:
  43625. return m.Nickname()
  43626. case wxcarduser.FieldRemark:
  43627. return m.Remark()
  43628. case wxcarduser.FieldPhone:
  43629. return m.Phone()
  43630. case wxcarduser.FieldOpenID:
  43631. return m.OpenID()
  43632. case wxcarduser.FieldUnionID:
  43633. return m.UnionID()
  43634. case wxcarduser.FieldSessionKey:
  43635. return m.SessionKey()
  43636. case wxcarduser.FieldIsVip:
  43637. return m.IsVip()
  43638. }
  43639. return nil, false
  43640. }
  43641. // OldField returns the old value of the field from the database. An error is
  43642. // returned if the mutation operation is not UpdateOne, or the query to the
  43643. // database failed.
  43644. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43645. switch name {
  43646. case wxcarduser.FieldCreatedAt:
  43647. return m.OldCreatedAt(ctx)
  43648. case wxcarduser.FieldUpdatedAt:
  43649. return m.OldUpdatedAt(ctx)
  43650. case wxcarduser.FieldDeletedAt:
  43651. return m.OldDeletedAt(ctx)
  43652. case wxcarduser.FieldWxid:
  43653. return m.OldWxid(ctx)
  43654. case wxcarduser.FieldAccount:
  43655. return m.OldAccount(ctx)
  43656. case wxcarduser.FieldAvatar:
  43657. return m.OldAvatar(ctx)
  43658. case wxcarduser.FieldNickname:
  43659. return m.OldNickname(ctx)
  43660. case wxcarduser.FieldRemark:
  43661. return m.OldRemark(ctx)
  43662. case wxcarduser.FieldPhone:
  43663. return m.OldPhone(ctx)
  43664. case wxcarduser.FieldOpenID:
  43665. return m.OldOpenID(ctx)
  43666. case wxcarduser.FieldUnionID:
  43667. return m.OldUnionID(ctx)
  43668. case wxcarduser.FieldSessionKey:
  43669. return m.OldSessionKey(ctx)
  43670. case wxcarduser.FieldIsVip:
  43671. return m.OldIsVip(ctx)
  43672. }
  43673. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  43674. }
  43675. // SetField sets the value of a field with the given name. It returns an error if
  43676. // the field is not defined in the schema, or if the type mismatched the field
  43677. // type.
  43678. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  43679. switch name {
  43680. case wxcarduser.FieldCreatedAt:
  43681. v, ok := value.(time.Time)
  43682. if !ok {
  43683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43684. }
  43685. m.SetCreatedAt(v)
  43686. return nil
  43687. case wxcarduser.FieldUpdatedAt:
  43688. v, ok := value.(time.Time)
  43689. if !ok {
  43690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43691. }
  43692. m.SetUpdatedAt(v)
  43693. return nil
  43694. case wxcarduser.FieldDeletedAt:
  43695. v, ok := value.(time.Time)
  43696. if !ok {
  43697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43698. }
  43699. m.SetDeletedAt(v)
  43700. return nil
  43701. case wxcarduser.FieldWxid:
  43702. v, ok := value.(string)
  43703. if !ok {
  43704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43705. }
  43706. m.SetWxid(v)
  43707. return nil
  43708. case wxcarduser.FieldAccount:
  43709. v, ok := value.(string)
  43710. if !ok {
  43711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43712. }
  43713. m.SetAccount(v)
  43714. return nil
  43715. case wxcarduser.FieldAvatar:
  43716. v, ok := value.(string)
  43717. if !ok {
  43718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43719. }
  43720. m.SetAvatar(v)
  43721. return nil
  43722. case wxcarduser.FieldNickname:
  43723. v, ok := value.(string)
  43724. if !ok {
  43725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43726. }
  43727. m.SetNickname(v)
  43728. return nil
  43729. case wxcarduser.FieldRemark:
  43730. v, ok := value.(string)
  43731. if !ok {
  43732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43733. }
  43734. m.SetRemark(v)
  43735. return nil
  43736. case wxcarduser.FieldPhone:
  43737. v, ok := value.(string)
  43738. if !ok {
  43739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43740. }
  43741. m.SetPhone(v)
  43742. return nil
  43743. case wxcarduser.FieldOpenID:
  43744. v, ok := value.(string)
  43745. if !ok {
  43746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43747. }
  43748. m.SetOpenID(v)
  43749. return nil
  43750. case wxcarduser.FieldUnionID:
  43751. v, ok := value.(string)
  43752. if !ok {
  43753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43754. }
  43755. m.SetUnionID(v)
  43756. return nil
  43757. case wxcarduser.FieldSessionKey:
  43758. v, ok := value.(string)
  43759. if !ok {
  43760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43761. }
  43762. m.SetSessionKey(v)
  43763. return nil
  43764. case wxcarduser.FieldIsVip:
  43765. v, ok := value.(int)
  43766. if !ok {
  43767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43768. }
  43769. m.SetIsVip(v)
  43770. return nil
  43771. }
  43772. return fmt.Errorf("unknown WxCardUser field %s", name)
  43773. }
  43774. // AddedFields returns all numeric fields that were incremented/decremented during
  43775. // this mutation.
  43776. func (m *WxCardUserMutation) AddedFields() []string {
  43777. var fields []string
  43778. if m.addis_vip != nil {
  43779. fields = append(fields, wxcarduser.FieldIsVip)
  43780. }
  43781. return fields
  43782. }
  43783. // AddedField returns the numeric value that was incremented/decremented on a field
  43784. // with the given name. The second boolean return value indicates that this field
  43785. // was not set, or was not defined in the schema.
  43786. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  43787. switch name {
  43788. case wxcarduser.FieldIsVip:
  43789. return m.AddedIsVip()
  43790. }
  43791. return nil, false
  43792. }
  43793. // AddField adds the value to the field with the given name. It returns an error if
  43794. // the field is not defined in the schema, or if the type mismatched the field
  43795. // type.
  43796. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  43797. switch name {
  43798. case wxcarduser.FieldIsVip:
  43799. v, ok := value.(int)
  43800. if !ok {
  43801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43802. }
  43803. m.AddIsVip(v)
  43804. return nil
  43805. }
  43806. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  43807. }
  43808. // ClearedFields returns all nullable fields that were cleared during this
  43809. // mutation.
  43810. func (m *WxCardUserMutation) ClearedFields() []string {
  43811. var fields []string
  43812. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  43813. fields = append(fields, wxcarduser.FieldDeletedAt)
  43814. }
  43815. return fields
  43816. }
  43817. // FieldCleared returns a boolean indicating if a field with the given name was
  43818. // cleared in this mutation.
  43819. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  43820. _, ok := m.clearedFields[name]
  43821. return ok
  43822. }
  43823. // ClearField clears the value of the field with the given name. It returns an
  43824. // error if the field is not defined in the schema.
  43825. func (m *WxCardUserMutation) ClearField(name string) error {
  43826. switch name {
  43827. case wxcarduser.FieldDeletedAt:
  43828. m.ClearDeletedAt()
  43829. return nil
  43830. }
  43831. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  43832. }
  43833. // ResetField resets all changes in the mutation for the field with the given name.
  43834. // It returns an error if the field is not defined in the schema.
  43835. func (m *WxCardUserMutation) ResetField(name string) error {
  43836. switch name {
  43837. case wxcarduser.FieldCreatedAt:
  43838. m.ResetCreatedAt()
  43839. return nil
  43840. case wxcarduser.FieldUpdatedAt:
  43841. m.ResetUpdatedAt()
  43842. return nil
  43843. case wxcarduser.FieldDeletedAt:
  43844. m.ResetDeletedAt()
  43845. return nil
  43846. case wxcarduser.FieldWxid:
  43847. m.ResetWxid()
  43848. return nil
  43849. case wxcarduser.FieldAccount:
  43850. m.ResetAccount()
  43851. return nil
  43852. case wxcarduser.FieldAvatar:
  43853. m.ResetAvatar()
  43854. return nil
  43855. case wxcarduser.FieldNickname:
  43856. m.ResetNickname()
  43857. return nil
  43858. case wxcarduser.FieldRemark:
  43859. m.ResetRemark()
  43860. return nil
  43861. case wxcarduser.FieldPhone:
  43862. m.ResetPhone()
  43863. return nil
  43864. case wxcarduser.FieldOpenID:
  43865. m.ResetOpenID()
  43866. return nil
  43867. case wxcarduser.FieldUnionID:
  43868. m.ResetUnionID()
  43869. return nil
  43870. case wxcarduser.FieldSessionKey:
  43871. m.ResetSessionKey()
  43872. return nil
  43873. case wxcarduser.FieldIsVip:
  43874. m.ResetIsVip()
  43875. return nil
  43876. }
  43877. return fmt.Errorf("unknown WxCardUser field %s", name)
  43878. }
  43879. // AddedEdges returns all edge names that were set/added in this mutation.
  43880. func (m *WxCardUserMutation) AddedEdges() []string {
  43881. edges := make([]string, 0, 0)
  43882. return edges
  43883. }
  43884. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43885. // name in this mutation.
  43886. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  43887. return nil
  43888. }
  43889. // RemovedEdges returns all edge names that were removed in this mutation.
  43890. func (m *WxCardUserMutation) RemovedEdges() []string {
  43891. edges := make([]string, 0, 0)
  43892. return edges
  43893. }
  43894. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43895. // the given name in this mutation.
  43896. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  43897. return nil
  43898. }
  43899. // ClearedEdges returns all edge names that were cleared in this mutation.
  43900. func (m *WxCardUserMutation) ClearedEdges() []string {
  43901. edges := make([]string, 0, 0)
  43902. return edges
  43903. }
  43904. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43905. // was cleared in this mutation.
  43906. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  43907. return false
  43908. }
  43909. // ClearEdge clears the value of the edge with the given name. It returns an error
  43910. // if that edge is not defined in the schema.
  43911. func (m *WxCardUserMutation) ClearEdge(name string) error {
  43912. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  43913. }
  43914. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43915. // It returns an error if the edge is not defined in the schema.
  43916. func (m *WxCardUserMutation) ResetEdge(name string) error {
  43917. return fmt.Errorf("unknown WxCardUser edge %s", name)
  43918. }
  43919. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  43920. type WxCardVisitMutation struct {
  43921. config
  43922. op Op
  43923. typ string
  43924. id *uint64
  43925. created_at *time.Time
  43926. updated_at *time.Time
  43927. deleted_at *time.Time
  43928. user_id *uint64
  43929. adduser_id *int64
  43930. bot_id *uint64
  43931. addbot_id *int64
  43932. bot_type *uint8
  43933. addbot_type *int8
  43934. clearedFields map[string]struct{}
  43935. done bool
  43936. oldValue func(context.Context) (*WxCardVisit, error)
  43937. predicates []predicate.WxCardVisit
  43938. }
  43939. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  43940. // wxcardvisitOption allows management of the mutation configuration using functional options.
  43941. type wxcardvisitOption func(*WxCardVisitMutation)
  43942. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  43943. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  43944. m := &WxCardVisitMutation{
  43945. config: c,
  43946. op: op,
  43947. typ: TypeWxCardVisit,
  43948. clearedFields: make(map[string]struct{}),
  43949. }
  43950. for _, opt := range opts {
  43951. opt(m)
  43952. }
  43953. return m
  43954. }
  43955. // withWxCardVisitID sets the ID field of the mutation.
  43956. func withWxCardVisitID(id uint64) wxcardvisitOption {
  43957. return func(m *WxCardVisitMutation) {
  43958. var (
  43959. err error
  43960. once sync.Once
  43961. value *WxCardVisit
  43962. )
  43963. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  43964. once.Do(func() {
  43965. if m.done {
  43966. err = errors.New("querying old values post mutation is not allowed")
  43967. } else {
  43968. value, err = m.Client().WxCardVisit.Get(ctx, id)
  43969. }
  43970. })
  43971. return value, err
  43972. }
  43973. m.id = &id
  43974. }
  43975. }
  43976. // withWxCardVisit sets the old WxCardVisit of the mutation.
  43977. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  43978. return func(m *WxCardVisitMutation) {
  43979. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  43980. return node, nil
  43981. }
  43982. m.id = &node.ID
  43983. }
  43984. }
  43985. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43986. // executed in a transaction (ent.Tx), a transactional client is returned.
  43987. func (m WxCardVisitMutation) Client() *Client {
  43988. client := &Client{config: m.config}
  43989. client.init()
  43990. return client
  43991. }
  43992. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43993. // it returns an error otherwise.
  43994. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  43995. if _, ok := m.driver.(*txDriver); !ok {
  43996. return nil, errors.New("ent: mutation is not running in a transaction")
  43997. }
  43998. tx := &Tx{config: m.config}
  43999. tx.init()
  44000. return tx, nil
  44001. }
  44002. // SetID sets the value of the id field. Note that this
  44003. // operation is only accepted on creation of WxCardVisit entities.
  44004. func (m *WxCardVisitMutation) SetID(id uint64) {
  44005. m.id = &id
  44006. }
  44007. // ID returns the ID value in the mutation. Note that the ID is only available
  44008. // if it was provided to the builder or after it was returned from the database.
  44009. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  44010. if m.id == nil {
  44011. return
  44012. }
  44013. return *m.id, true
  44014. }
  44015. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44016. // That means, if the mutation is applied within a transaction with an isolation level such
  44017. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44018. // or updated by the mutation.
  44019. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  44020. switch {
  44021. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44022. id, exists := m.ID()
  44023. if exists {
  44024. return []uint64{id}, nil
  44025. }
  44026. fallthrough
  44027. case m.op.Is(OpUpdate | OpDelete):
  44028. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  44029. default:
  44030. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44031. }
  44032. }
  44033. // SetCreatedAt sets the "created_at" field.
  44034. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  44035. m.created_at = &t
  44036. }
  44037. // CreatedAt returns the value of the "created_at" field in the mutation.
  44038. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  44039. v := m.created_at
  44040. if v == nil {
  44041. return
  44042. }
  44043. return *v, true
  44044. }
  44045. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  44046. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44048. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44049. if !m.op.Is(OpUpdateOne) {
  44050. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44051. }
  44052. if m.id == nil || m.oldValue == nil {
  44053. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44054. }
  44055. oldValue, err := m.oldValue(ctx)
  44056. if err != nil {
  44057. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44058. }
  44059. return oldValue.CreatedAt, nil
  44060. }
  44061. // ResetCreatedAt resets all changes to the "created_at" field.
  44062. func (m *WxCardVisitMutation) ResetCreatedAt() {
  44063. m.created_at = nil
  44064. }
  44065. // SetUpdatedAt sets the "updated_at" field.
  44066. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  44067. m.updated_at = &t
  44068. }
  44069. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44070. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  44071. v := m.updated_at
  44072. if v == nil {
  44073. return
  44074. }
  44075. return *v, true
  44076. }
  44077. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  44078. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44080. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44081. if !m.op.Is(OpUpdateOne) {
  44082. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44083. }
  44084. if m.id == nil || m.oldValue == nil {
  44085. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44086. }
  44087. oldValue, err := m.oldValue(ctx)
  44088. if err != nil {
  44089. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44090. }
  44091. return oldValue.UpdatedAt, nil
  44092. }
  44093. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44094. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  44095. m.updated_at = nil
  44096. }
  44097. // SetDeletedAt sets the "deleted_at" field.
  44098. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  44099. m.deleted_at = &t
  44100. }
  44101. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44102. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  44103. v := m.deleted_at
  44104. if v == nil {
  44105. return
  44106. }
  44107. return *v, true
  44108. }
  44109. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  44110. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44112. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44113. if !m.op.Is(OpUpdateOne) {
  44114. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44115. }
  44116. if m.id == nil || m.oldValue == nil {
  44117. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44118. }
  44119. oldValue, err := m.oldValue(ctx)
  44120. if err != nil {
  44121. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44122. }
  44123. return oldValue.DeletedAt, nil
  44124. }
  44125. // ClearDeletedAt clears the value of the "deleted_at" field.
  44126. func (m *WxCardVisitMutation) ClearDeletedAt() {
  44127. m.deleted_at = nil
  44128. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  44129. }
  44130. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44131. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  44132. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  44133. return ok
  44134. }
  44135. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44136. func (m *WxCardVisitMutation) ResetDeletedAt() {
  44137. m.deleted_at = nil
  44138. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  44139. }
  44140. // SetUserID sets the "user_id" field.
  44141. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  44142. m.user_id = &u
  44143. m.adduser_id = nil
  44144. }
  44145. // UserID returns the value of the "user_id" field in the mutation.
  44146. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  44147. v := m.user_id
  44148. if v == nil {
  44149. return
  44150. }
  44151. return *v, true
  44152. }
  44153. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  44154. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44156. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  44157. if !m.op.Is(OpUpdateOne) {
  44158. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  44159. }
  44160. if m.id == nil || m.oldValue == nil {
  44161. return v, errors.New("OldUserID requires an ID field in the mutation")
  44162. }
  44163. oldValue, err := m.oldValue(ctx)
  44164. if err != nil {
  44165. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  44166. }
  44167. return oldValue.UserID, nil
  44168. }
  44169. // AddUserID adds u to the "user_id" field.
  44170. func (m *WxCardVisitMutation) AddUserID(u int64) {
  44171. if m.adduser_id != nil {
  44172. *m.adduser_id += u
  44173. } else {
  44174. m.adduser_id = &u
  44175. }
  44176. }
  44177. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  44178. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  44179. v := m.adduser_id
  44180. if v == nil {
  44181. return
  44182. }
  44183. return *v, true
  44184. }
  44185. // ClearUserID clears the value of the "user_id" field.
  44186. func (m *WxCardVisitMutation) ClearUserID() {
  44187. m.user_id = nil
  44188. m.adduser_id = nil
  44189. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  44190. }
  44191. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  44192. func (m *WxCardVisitMutation) UserIDCleared() bool {
  44193. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  44194. return ok
  44195. }
  44196. // ResetUserID resets all changes to the "user_id" field.
  44197. func (m *WxCardVisitMutation) ResetUserID() {
  44198. m.user_id = nil
  44199. m.adduser_id = nil
  44200. delete(m.clearedFields, wxcardvisit.FieldUserID)
  44201. }
  44202. // SetBotID sets the "bot_id" field.
  44203. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  44204. m.bot_id = &u
  44205. m.addbot_id = nil
  44206. }
  44207. // BotID returns the value of the "bot_id" field in the mutation.
  44208. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  44209. v := m.bot_id
  44210. if v == nil {
  44211. return
  44212. }
  44213. return *v, true
  44214. }
  44215. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  44216. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44218. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  44219. if !m.op.Is(OpUpdateOne) {
  44220. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  44221. }
  44222. if m.id == nil || m.oldValue == nil {
  44223. return v, errors.New("OldBotID requires an ID field in the mutation")
  44224. }
  44225. oldValue, err := m.oldValue(ctx)
  44226. if err != nil {
  44227. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  44228. }
  44229. return oldValue.BotID, nil
  44230. }
  44231. // AddBotID adds u to the "bot_id" field.
  44232. func (m *WxCardVisitMutation) AddBotID(u int64) {
  44233. if m.addbot_id != nil {
  44234. *m.addbot_id += u
  44235. } else {
  44236. m.addbot_id = &u
  44237. }
  44238. }
  44239. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  44240. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  44241. v := m.addbot_id
  44242. if v == nil {
  44243. return
  44244. }
  44245. return *v, true
  44246. }
  44247. // ResetBotID resets all changes to the "bot_id" field.
  44248. func (m *WxCardVisitMutation) ResetBotID() {
  44249. m.bot_id = nil
  44250. m.addbot_id = nil
  44251. }
  44252. // SetBotType sets the "bot_type" field.
  44253. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  44254. m.bot_type = &u
  44255. m.addbot_type = nil
  44256. }
  44257. // BotType returns the value of the "bot_type" field in the mutation.
  44258. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  44259. v := m.bot_type
  44260. if v == nil {
  44261. return
  44262. }
  44263. return *v, true
  44264. }
  44265. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  44266. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44268. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  44269. if !m.op.Is(OpUpdateOne) {
  44270. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  44271. }
  44272. if m.id == nil || m.oldValue == nil {
  44273. return v, errors.New("OldBotType requires an ID field in the mutation")
  44274. }
  44275. oldValue, err := m.oldValue(ctx)
  44276. if err != nil {
  44277. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  44278. }
  44279. return oldValue.BotType, nil
  44280. }
  44281. // AddBotType adds u to the "bot_type" field.
  44282. func (m *WxCardVisitMutation) AddBotType(u int8) {
  44283. if m.addbot_type != nil {
  44284. *m.addbot_type += u
  44285. } else {
  44286. m.addbot_type = &u
  44287. }
  44288. }
  44289. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  44290. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  44291. v := m.addbot_type
  44292. if v == nil {
  44293. return
  44294. }
  44295. return *v, true
  44296. }
  44297. // ResetBotType resets all changes to the "bot_type" field.
  44298. func (m *WxCardVisitMutation) ResetBotType() {
  44299. m.bot_type = nil
  44300. m.addbot_type = nil
  44301. }
  44302. // Where appends a list predicates to the WxCardVisitMutation builder.
  44303. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  44304. m.predicates = append(m.predicates, ps...)
  44305. }
  44306. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  44307. // users can use type-assertion to append predicates that do not depend on any generated package.
  44308. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  44309. p := make([]predicate.WxCardVisit, len(ps))
  44310. for i := range ps {
  44311. p[i] = ps[i]
  44312. }
  44313. m.Where(p...)
  44314. }
  44315. // Op returns the operation name.
  44316. func (m *WxCardVisitMutation) Op() Op {
  44317. return m.op
  44318. }
  44319. // SetOp allows setting the mutation operation.
  44320. func (m *WxCardVisitMutation) SetOp(op Op) {
  44321. m.op = op
  44322. }
  44323. // Type returns the node type of this mutation (WxCardVisit).
  44324. func (m *WxCardVisitMutation) Type() string {
  44325. return m.typ
  44326. }
  44327. // Fields returns all fields that were changed during this mutation. Note that in
  44328. // order to get all numeric fields that were incremented/decremented, call
  44329. // AddedFields().
  44330. func (m *WxCardVisitMutation) Fields() []string {
  44331. fields := make([]string, 0, 6)
  44332. if m.created_at != nil {
  44333. fields = append(fields, wxcardvisit.FieldCreatedAt)
  44334. }
  44335. if m.updated_at != nil {
  44336. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  44337. }
  44338. if m.deleted_at != nil {
  44339. fields = append(fields, wxcardvisit.FieldDeletedAt)
  44340. }
  44341. if m.user_id != nil {
  44342. fields = append(fields, wxcardvisit.FieldUserID)
  44343. }
  44344. if m.bot_id != nil {
  44345. fields = append(fields, wxcardvisit.FieldBotID)
  44346. }
  44347. if m.bot_type != nil {
  44348. fields = append(fields, wxcardvisit.FieldBotType)
  44349. }
  44350. return fields
  44351. }
  44352. // Field returns the value of a field with the given name. The second boolean
  44353. // return value indicates that this field was not set, or was not defined in the
  44354. // schema.
  44355. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  44356. switch name {
  44357. case wxcardvisit.FieldCreatedAt:
  44358. return m.CreatedAt()
  44359. case wxcardvisit.FieldUpdatedAt:
  44360. return m.UpdatedAt()
  44361. case wxcardvisit.FieldDeletedAt:
  44362. return m.DeletedAt()
  44363. case wxcardvisit.FieldUserID:
  44364. return m.UserID()
  44365. case wxcardvisit.FieldBotID:
  44366. return m.BotID()
  44367. case wxcardvisit.FieldBotType:
  44368. return m.BotType()
  44369. }
  44370. return nil, false
  44371. }
  44372. // OldField returns the old value of the field from the database. An error is
  44373. // returned if the mutation operation is not UpdateOne, or the query to the
  44374. // database failed.
  44375. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44376. switch name {
  44377. case wxcardvisit.FieldCreatedAt:
  44378. return m.OldCreatedAt(ctx)
  44379. case wxcardvisit.FieldUpdatedAt:
  44380. return m.OldUpdatedAt(ctx)
  44381. case wxcardvisit.FieldDeletedAt:
  44382. return m.OldDeletedAt(ctx)
  44383. case wxcardvisit.FieldUserID:
  44384. return m.OldUserID(ctx)
  44385. case wxcardvisit.FieldBotID:
  44386. return m.OldBotID(ctx)
  44387. case wxcardvisit.FieldBotType:
  44388. return m.OldBotType(ctx)
  44389. }
  44390. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  44391. }
  44392. // SetField sets the value of a field with the given name. It returns an error if
  44393. // the field is not defined in the schema, or if the type mismatched the field
  44394. // type.
  44395. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  44396. switch name {
  44397. case wxcardvisit.FieldCreatedAt:
  44398. v, ok := value.(time.Time)
  44399. if !ok {
  44400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44401. }
  44402. m.SetCreatedAt(v)
  44403. return nil
  44404. case wxcardvisit.FieldUpdatedAt:
  44405. v, ok := value.(time.Time)
  44406. if !ok {
  44407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44408. }
  44409. m.SetUpdatedAt(v)
  44410. return nil
  44411. case wxcardvisit.FieldDeletedAt:
  44412. v, ok := value.(time.Time)
  44413. if !ok {
  44414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44415. }
  44416. m.SetDeletedAt(v)
  44417. return nil
  44418. case wxcardvisit.FieldUserID:
  44419. v, ok := value.(uint64)
  44420. if !ok {
  44421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44422. }
  44423. m.SetUserID(v)
  44424. return nil
  44425. case wxcardvisit.FieldBotID:
  44426. v, ok := value.(uint64)
  44427. if !ok {
  44428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44429. }
  44430. m.SetBotID(v)
  44431. return nil
  44432. case wxcardvisit.FieldBotType:
  44433. v, ok := value.(uint8)
  44434. if !ok {
  44435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44436. }
  44437. m.SetBotType(v)
  44438. return nil
  44439. }
  44440. return fmt.Errorf("unknown WxCardVisit field %s", name)
  44441. }
  44442. // AddedFields returns all numeric fields that were incremented/decremented during
  44443. // this mutation.
  44444. func (m *WxCardVisitMutation) AddedFields() []string {
  44445. var fields []string
  44446. if m.adduser_id != nil {
  44447. fields = append(fields, wxcardvisit.FieldUserID)
  44448. }
  44449. if m.addbot_id != nil {
  44450. fields = append(fields, wxcardvisit.FieldBotID)
  44451. }
  44452. if m.addbot_type != nil {
  44453. fields = append(fields, wxcardvisit.FieldBotType)
  44454. }
  44455. return fields
  44456. }
  44457. // AddedField returns the numeric value that was incremented/decremented on a field
  44458. // with the given name. The second boolean return value indicates that this field
  44459. // was not set, or was not defined in the schema.
  44460. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  44461. switch name {
  44462. case wxcardvisit.FieldUserID:
  44463. return m.AddedUserID()
  44464. case wxcardvisit.FieldBotID:
  44465. return m.AddedBotID()
  44466. case wxcardvisit.FieldBotType:
  44467. return m.AddedBotType()
  44468. }
  44469. return nil, false
  44470. }
  44471. // AddField adds the value to the field with the given name. It returns an error if
  44472. // the field is not defined in the schema, or if the type mismatched the field
  44473. // type.
  44474. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  44475. switch name {
  44476. case wxcardvisit.FieldUserID:
  44477. v, ok := value.(int64)
  44478. if !ok {
  44479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44480. }
  44481. m.AddUserID(v)
  44482. return nil
  44483. case wxcardvisit.FieldBotID:
  44484. v, ok := value.(int64)
  44485. if !ok {
  44486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44487. }
  44488. m.AddBotID(v)
  44489. return nil
  44490. case wxcardvisit.FieldBotType:
  44491. v, ok := value.(int8)
  44492. if !ok {
  44493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44494. }
  44495. m.AddBotType(v)
  44496. return nil
  44497. }
  44498. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  44499. }
  44500. // ClearedFields returns all nullable fields that were cleared during this
  44501. // mutation.
  44502. func (m *WxCardVisitMutation) ClearedFields() []string {
  44503. var fields []string
  44504. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  44505. fields = append(fields, wxcardvisit.FieldDeletedAt)
  44506. }
  44507. if m.FieldCleared(wxcardvisit.FieldUserID) {
  44508. fields = append(fields, wxcardvisit.FieldUserID)
  44509. }
  44510. return fields
  44511. }
  44512. // FieldCleared returns a boolean indicating if a field with the given name was
  44513. // cleared in this mutation.
  44514. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  44515. _, ok := m.clearedFields[name]
  44516. return ok
  44517. }
  44518. // ClearField clears the value of the field with the given name. It returns an
  44519. // error if the field is not defined in the schema.
  44520. func (m *WxCardVisitMutation) ClearField(name string) error {
  44521. switch name {
  44522. case wxcardvisit.FieldDeletedAt:
  44523. m.ClearDeletedAt()
  44524. return nil
  44525. case wxcardvisit.FieldUserID:
  44526. m.ClearUserID()
  44527. return nil
  44528. }
  44529. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  44530. }
  44531. // ResetField resets all changes in the mutation for the field with the given name.
  44532. // It returns an error if the field is not defined in the schema.
  44533. func (m *WxCardVisitMutation) ResetField(name string) error {
  44534. switch name {
  44535. case wxcardvisit.FieldCreatedAt:
  44536. m.ResetCreatedAt()
  44537. return nil
  44538. case wxcardvisit.FieldUpdatedAt:
  44539. m.ResetUpdatedAt()
  44540. return nil
  44541. case wxcardvisit.FieldDeletedAt:
  44542. m.ResetDeletedAt()
  44543. return nil
  44544. case wxcardvisit.FieldUserID:
  44545. m.ResetUserID()
  44546. return nil
  44547. case wxcardvisit.FieldBotID:
  44548. m.ResetBotID()
  44549. return nil
  44550. case wxcardvisit.FieldBotType:
  44551. m.ResetBotType()
  44552. return nil
  44553. }
  44554. return fmt.Errorf("unknown WxCardVisit field %s", name)
  44555. }
  44556. // AddedEdges returns all edge names that were set/added in this mutation.
  44557. func (m *WxCardVisitMutation) AddedEdges() []string {
  44558. edges := make([]string, 0, 0)
  44559. return edges
  44560. }
  44561. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44562. // name in this mutation.
  44563. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  44564. return nil
  44565. }
  44566. // RemovedEdges returns all edge names that were removed in this mutation.
  44567. func (m *WxCardVisitMutation) RemovedEdges() []string {
  44568. edges := make([]string, 0, 0)
  44569. return edges
  44570. }
  44571. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44572. // the given name in this mutation.
  44573. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  44574. return nil
  44575. }
  44576. // ClearedEdges returns all edge names that were cleared in this mutation.
  44577. func (m *WxCardVisitMutation) ClearedEdges() []string {
  44578. edges := make([]string, 0, 0)
  44579. return edges
  44580. }
  44581. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44582. // was cleared in this mutation.
  44583. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  44584. return false
  44585. }
  44586. // ClearEdge clears the value of the edge with the given name. It returns an error
  44587. // if that edge is not defined in the schema.
  44588. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  44589. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  44590. }
  44591. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44592. // It returns an error if the edge is not defined in the schema.
  44593. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  44594. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  44595. }