mutation.go 1.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/batchmsg"
  14. "wechat-api/ent/category"
  15. "wechat-api/ent/chatrecords"
  16. "wechat-api/ent/chatsession"
  17. "wechat-api/ent/contact"
  18. "wechat-api/ent/creditbalance"
  19. "wechat-api/ent/creditusage"
  20. "wechat-api/ent/custom_types"
  21. "wechat-api/ent/employee"
  22. "wechat-api/ent/employeeconfig"
  23. "wechat-api/ent/label"
  24. "wechat-api/ent/labelrelationship"
  25. "wechat-api/ent/labeltagging"
  26. "wechat-api/ent/message"
  27. "wechat-api/ent/messagerecords"
  28. "wechat-api/ent/msg"
  29. "wechat-api/ent/payrecharge"
  30. "wechat-api/ent/predicate"
  31. "wechat-api/ent/server"
  32. "wechat-api/ent/sopnode"
  33. "wechat-api/ent/sopstage"
  34. "wechat-api/ent/soptask"
  35. "wechat-api/ent/token"
  36. "wechat-api/ent/tutorial"
  37. "wechat-api/ent/usagedetail"
  38. "wechat-api/ent/usagestatisticday"
  39. "wechat-api/ent/usagestatistichour"
  40. "wechat-api/ent/usagestatisticmonth"
  41. "wechat-api/ent/usagetotal"
  42. "wechat-api/ent/whatsapp"
  43. "wechat-api/ent/whatsappchannel"
  44. "wechat-api/ent/workexperience"
  45. "wechat-api/ent/wpchatroom"
  46. "wechat-api/ent/wpchatroommember"
  47. "wechat-api/ent/wx"
  48. "wechat-api/ent/wxcard"
  49. "wechat-api/ent/wxcarduser"
  50. "wechat-api/ent/wxcardvisit"
  51. "entgo.io/ent"
  52. "entgo.io/ent/dialect/sql"
  53. )
  54. const (
  55. // Operation types.
  56. OpCreate = ent.OpCreate
  57. OpDelete = ent.OpDelete
  58. OpDeleteOne = ent.OpDeleteOne
  59. OpUpdate = ent.OpUpdate
  60. OpUpdateOne = ent.OpUpdateOne
  61. // Node types.
  62. TypeAgent = "Agent"
  63. TypeAgentBase = "AgentBase"
  64. TypeAliyunAvatar = "AliyunAvatar"
  65. TypeAllocAgent = "AllocAgent"
  66. TypeBatchMsg = "BatchMsg"
  67. TypeCategory = "Category"
  68. TypeChatRecords = "ChatRecords"
  69. TypeChatSession = "ChatSession"
  70. TypeContact = "Contact"
  71. TypeCreditBalance = "CreditBalance"
  72. TypeCreditUsage = "CreditUsage"
  73. TypeEmployee = "Employee"
  74. TypeEmployeeConfig = "EmployeeConfig"
  75. TypeLabel = "Label"
  76. TypeLabelRelationship = "LabelRelationship"
  77. TypeLabelTagging = "LabelTagging"
  78. TypeMessage = "Message"
  79. TypeMessageRecords = "MessageRecords"
  80. TypeMsg = "Msg"
  81. TypePayRecharge = "PayRecharge"
  82. TypeServer = "Server"
  83. TypeSopNode = "SopNode"
  84. TypeSopStage = "SopStage"
  85. TypeSopTask = "SopTask"
  86. TypeToken = "Token"
  87. TypeTutorial = "Tutorial"
  88. TypeUsageDetail = "UsageDetail"
  89. TypeUsageStatisticDay = "UsageStatisticDay"
  90. TypeUsageStatisticHour = "UsageStatisticHour"
  91. TypeUsageStatisticMonth = "UsageStatisticMonth"
  92. TypeUsageTotal = "UsageTotal"
  93. TypeWhatsapp = "Whatsapp"
  94. TypeWhatsappChannel = "WhatsappChannel"
  95. TypeWorkExperience = "WorkExperience"
  96. TypeWpChatroom = "WpChatroom"
  97. TypeWpChatroomMember = "WpChatroomMember"
  98. TypeWx = "Wx"
  99. TypeWxCard = "WxCard"
  100. TypeWxCardUser = "WxCardUser"
  101. TypeWxCardVisit = "WxCardVisit"
  102. )
  103. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  104. type AgentMutation struct {
  105. config
  106. op Op
  107. typ string
  108. id *uint64
  109. created_at *time.Time
  110. updated_at *time.Time
  111. deleted_at *time.Time
  112. name *string
  113. role *string
  114. status *int
  115. addstatus *int
  116. background *string
  117. examples *string
  118. organization_id *uint64
  119. addorganization_id *int64
  120. dataset_id *string
  121. collection_id *string
  122. clearedFields map[string]struct{}
  123. wx_agent map[uint64]struct{}
  124. removedwx_agent map[uint64]struct{}
  125. clearedwx_agent bool
  126. token_agent map[uint64]struct{}
  127. removedtoken_agent map[uint64]struct{}
  128. clearedtoken_agent bool
  129. wa_agent map[uint64]struct{}
  130. removedwa_agent map[uint64]struct{}
  131. clearedwa_agent bool
  132. done bool
  133. oldValue func(context.Context) (*Agent, error)
  134. predicates []predicate.Agent
  135. }
  136. var _ ent.Mutation = (*AgentMutation)(nil)
  137. // agentOption allows management of the mutation configuration using functional options.
  138. type agentOption func(*AgentMutation)
  139. // newAgentMutation creates new mutation for the Agent entity.
  140. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  141. m := &AgentMutation{
  142. config: c,
  143. op: op,
  144. typ: TypeAgent,
  145. clearedFields: make(map[string]struct{}),
  146. }
  147. for _, opt := range opts {
  148. opt(m)
  149. }
  150. return m
  151. }
  152. // withAgentID sets the ID field of the mutation.
  153. func withAgentID(id uint64) agentOption {
  154. return func(m *AgentMutation) {
  155. var (
  156. err error
  157. once sync.Once
  158. value *Agent
  159. )
  160. m.oldValue = func(ctx context.Context) (*Agent, error) {
  161. once.Do(func() {
  162. if m.done {
  163. err = errors.New("querying old values post mutation is not allowed")
  164. } else {
  165. value, err = m.Client().Agent.Get(ctx, id)
  166. }
  167. })
  168. return value, err
  169. }
  170. m.id = &id
  171. }
  172. }
  173. // withAgent sets the old Agent of the mutation.
  174. func withAgent(node *Agent) agentOption {
  175. return func(m *AgentMutation) {
  176. m.oldValue = func(context.Context) (*Agent, error) {
  177. return node, nil
  178. }
  179. m.id = &node.ID
  180. }
  181. }
  182. // Client returns a new `ent.Client` from the mutation. If the mutation was
  183. // executed in a transaction (ent.Tx), a transactional client is returned.
  184. func (m AgentMutation) Client() *Client {
  185. client := &Client{config: m.config}
  186. client.init()
  187. return client
  188. }
  189. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  190. // it returns an error otherwise.
  191. func (m AgentMutation) Tx() (*Tx, error) {
  192. if _, ok := m.driver.(*txDriver); !ok {
  193. return nil, errors.New("ent: mutation is not running in a transaction")
  194. }
  195. tx := &Tx{config: m.config}
  196. tx.init()
  197. return tx, nil
  198. }
  199. // SetID sets the value of the id field. Note that this
  200. // operation is only accepted on creation of Agent entities.
  201. func (m *AgentMutation) SetID(id uint64) {
  202. m.id = &id
  203. }
  204. // ID returns the ID value in the mutation. Note that the ID is only available
  205. // if it was provided to the builder or after it was returned from the database.
  206. func (m *AgentMutation) ID() (id uint64, exists bool) {
  207. if m.id == nil {
  208. return
  209. }
  210. return *m.id, true
  211. }
  212. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  213. // That means, if the mutation is applied within a transaction with an isolation level such
  214. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  215. // or updated by the mutation.
  216. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  217. switch {
  218. case m.op.Is(OpUpdateOne | OpDeleteOne):
  219. id, exists := m.ID()
  220. if exists {
  221. return []uint64{id}, nil
  222. }
  223. fallthrough
  224. case m.op.Is(OpUpdate | OpDelete):
  225. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  226. default:
  227. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  228. }
  229. }
  230. // SetCreatedAt sets the "created_at" field.
  231. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  232. m.created_at = &t
  233. }
  234. // CreatedAt returns the value of the "created_at" field in the mutation.
  235. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  236. v := m.created_at
  237. if v == nil {
  238. return
  239. }
  240. return *v, true
  241. }
  242. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  243. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  245. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  246. if !m.op.Is(OpUpdateOne) {
  247. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  248. }
  249. if m.id == nil || m.oldValue == nil {
  250. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  251. }
  252. oldValue, err := m.oldValue(ctx)
  253. if err != nil {
  254. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  255. }
  256. return oldValue.CreatedAt, nil
  257. }
  258. // ResetCreatedAt resets all changes to the "created_at" field.
  259. func (m *AgentMutation) ResetCreatedAt() {
  260. m.created_at = nil
  261. }
  262. // SetUpdatedAt sets the "updated_at" field.
  263. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  264. m.updated_at = &t
  265. }
  266. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  267. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  268. v := m.updated_at
  269. if v == nil {
  270. return
  271. }
  272. return *v, true
  273. }
  274. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  275. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  277. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  278. if !m.op.Is(OpUpdateOne) {
  279. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  280. }
  281. if m.id == nil || m.oldValue == nil {
  282. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  283. }
  284. oldValue, err := m.oldValue(ctx)
  285. if err != nil {
  286. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  287. }
  288. return oldValue.UpdatedAt, nil
  289. }
  290. // ResetUpdatedAt resets all changes to the "updated_at" field.
  291. func (m *AgentMutation) ResetUpdatedAt() {
  292. m.updated_at = nil
  293. }
  294. // SetDeletedAt sets the "deleted_at" field.
  295. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  296. m.deleted_at = &t
  297. }
  298. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  299. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  300. v := m.deleted_at
  301. if v == nil {
  302. return
  303. }
  304. return *v, true
  305. }
  306. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  307. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  309. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  310. if !m.op.Is(OpUpdateOne) {
  311. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  312. }
  313. if m.id == nil || m.oldValue == nil {
  314. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  315. }
  316. oldValue, err := m.oldValue(ctx)
  317. if err != nil {
  318. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  319. }
  320. return oldValue.DeletedAt, nil
  321. }
  322. // ClearDeletedAt clears the value of the "deleted_at" field.
  323. func (m *AgentMutation) ClearDeletedAt() {
  324. m.deleted_at = nil
  325. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  326. }
  327. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  328. func (m *AgentMutation) DeletedAtCleared() bool {
  329. _, ok := m.clearedFields[agent.FieldDeletedAt]
  330. return ok
  331. }
  332. // ResetDeletedAt resets all changes to the "deleted_at" field.
  333. func (m *AgentMutation) ResetDeletedAt() {
  334. m.deleted_at = nil
  335. delete(m.clearedFields, agent.FieldDeletedAt)
  336. }
  337. // SetName sets the "name" field.
  338. func (m *AgentMutation) SetName(s string) {
  339. m.name = &s
  340. }
  341. // Name returns the value of the "name" field in the mutation.
  342. func (m *AgentMutation) Name() (r string, exists bool) {
  343. v := m.name
  344. if v == nil {
  345. return
  346. }
  347. return *v, true
  348. }
  349. // OldName returns the old "name" field's value of the Agent entity.
  350. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  352. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  353. if !m.op.Is(OpUpdateOne) {
  354. return v, errors.New("OldName is only allowed on UpdateOne operations")
  355. }
  356. if m.id == nil || m.oldValue == nil {
  357. return v, errors.New("OldName requires an ID field in the mutation")
  358. }
  359. oldValue, err := m.oldValue(ctx)
  360. if err != nil {
  361. return v, fmt.Errorf("querying old value for OldName: %w", err)
  362. }
  363. return oldValue.Name, nil
  364. }
  365. // ResetName resets all changes to the "name" field.
  366. func (m *AgentMutation) ResetName() {
  367. m.name = nil
  368. }
  369. // SetRole sets the "role" field.
  370. func (m *AgentMutation) SetRole(s string) {
  371. m.role = &s
  372. }
  373. // Role returns the value of the "role" field in the mutation.
  374. func (m *AgentMutation) Role() (r string, exists bool) {
  375. v := m.role
  376. if v == nil {
  377. return
  378. }
  379. return *v, true
  380. }
  381. // OldRole returns the old "role" field's value of the Agent entity.
  382. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  384. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  385. if !m.op.Is(OpUpdateOne) {
  386. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  387. }
  388. if m.id == nil || m.oldValue == nil {
  389. return v, errors.New("OldRole requires an ID field in the mutation")
  390. }
  391. oldValue, err := m.oldValue(ctx)
  392. if err != nil {
  393. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  394. }
  395. return oldValue.Role, nil
  396. }
  397. // ResetRole resets all changes to the "role" field.
  398. func (m *AgentMutation) ResetRole() {
  399. m.role = nil
  400. }
  401. // SetStatus sets the "status" field.
  402. func (m *AgentMutation) SetStatus(i int) {
  403. m.status = &i
  404. m.addstatus = nil
  405. }
  406. // Status returns the value of the "status" field in the mutation.
  407. func (m *AgentMutation) Status() (r int, exists bool) {
  408. v := m.status
  409. if v == nil {
  410. return
  411. }
  412. return *v, true
  413. }
  414. // OldStatus returns the old "status" field's value of the Agent entity.
  415. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  417. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  418. if !m.op.Is(OpUpdateOne) {
  419. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  420. }
  421. if m.id == nil || m.oldValue == nil {
  422. return v, errors.New("OldStatus requires an ID field in the mutation")
  423. }
  424. oldValue, err := m.oldValue(ctx)
  425. if err != nil {
  426. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  427. }
  428. return oldValue.Status, nil
  429. }
  430. // AddStatus adds i to the "status" field.
  431. func (m *AgentMutation) AddStatus(i int) {
  432. if m.addstatus != nil {
  433. *m.addstatus += i
  434. } else {
  435. m.addstatus = &i
  436. }
  437. }
  438. // AddedStatus returns the value that was added to the "status" field in this mutation.
  439. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  440. v := m.addstatus
  441. if v == nil {
  442. return
  443. }
  444. return *v, true
  445. }
  446. // ClearStatus clears the value of the "status" field.
  447. func (m *AgentMutation) ClearStatus() {
  448. m.status = nil
  449. m.addstatus = nil
  450. m.clearedFields[agent.FieldStatus] = struct{}{}
  451. }
  452. // StatusCleared returns if the "status" field was cleared in this mutation.
  453. func (m *AgentMutation) StatusCleared() bool {
  454. _, ok := m.clearedFields[agent.FieldStatus]
  455. return ok
  456. }
  457. // ResetStatus resets all changes to the "status" field.
  458. func (m *AgentMutation) ResetStatus() {
  459. m.status = nil
  460. m.addstatus = nil
  461. delete(m.clearedFields, agent.FieldStatus)
  462. }
  463. // SetBackground sets the "background" field.
  464. func (m *AgentMutation) SetBackground(s string) {
  465. m.background = &s
  466. }
  467. // Background returns the value of the "background" field in the mutation.
  468. func (m *AgentMutation) Background() (r string, exists bool) {
  469. v := m.background
  470. if v == nil {
  471. return
  472. }
  473. return *v, true
  474. }
  475. // OldBackground returns the old "background" field's value of the Agent entity.
  476. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  478. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  479. if !m.op.Is(OpUpdateOne) {
  480. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  481. }
  482. if m.id == nil || m.oldValue == nil {
  483. return v, errors.New("OldBackground requires an ID field in the mutation")
  484. }
  485. oldValue, err := m.oldValue(ctx)
  486. if err != nil {
  487. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  488. }
  489. return oldValue.Background, nil
  490. }
  491. // ClearBackground clears the value of the "background" field.
  492. func (m *AgentMutation) ClearBackground() {
  493. m.background = nil
  494. m.clearedFields[agent.FieldBackground] = struct{}{}
  495. }
  496. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  497. func (m *AgentMutation) BackgroundCleared() bool {
  498. _, ok := m.clearedFields[agent.FieldBackground]
  499. return ok
  500. }
  501. // ResetBackground resets all changes to the "background" field.
  502. func (m *AgentMutation) ResetBackground() {
  503. m.background = nil
  504. delete(m.clearedFields, agent.FieldBackground)
  505. }
  506. // SetExamples sets the "examples" field.
  507. func (m *AgentMutation) SetExamples(s string) {
  508. m.examples = &s
  509. }
  510. // Examples returns the value of the "examples" field in the mutation.
  511. func (m *AgentMutation) Examples() (r string, exists bool) {
  512. v := m.examples
  513. if v == nil {
  514. return
  515. }
  516. return *v, true
  517. }
  518. // OldExamples returns the old "examples" field's value of the Agent entity.
  519. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  521. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  522. if !m.op.Is(OpUpdateOne) {
  523. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  524. }
  525. if m.id == nil || m.oldValue == nil {
  526. return v, errors.New("OldExamples requires an ID field in the mutation")
  527. }
  528. oldValue, err := m.oldValue(ctx)
  529. if err != nil {
  530. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  531. }
  532. return oldValue.Examples, nil
  533. }
  534. // ClearExamples clears the value of the "examples" field.
  535. func (m *AgentMutation) ClearExamples() {
  536. m.examples = nil
  537. m.clearedFields[agent.FieldExamples] = struct{}{}
  538. }
  539. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  540. func (m *AgentMutation) ExamplesCleared() bool {
  541. _, ok := m.clearedFields[agent.FieldExamples]
  542. return ok
  543. }
  544. // ResetExamples resets all changes to the "examples" field.
  545. func (m *AgentMutation) ResetExamples() {
  546. m.examples = nil
  547. delete(m.clearedFields, agent.FieldExamples)
  548. }
  549. // SetOrganizationID sets the "organization_id" field.
  550. func (m *AgentMutation) SetOrganizationID(u uint64) {
  551. m.organization_id = &u
  552. m.addorganization_id = nil
  553. }
  554. // OrganizationID returns the value of the "organization_id" field in the mutation.
  555. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  556. v := m.organization_id
  557. if v == nil {
  558. return
  559. }
  560. return *v, true
  561. }
  562. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  563. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  565. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  566. if !m.op.Is(OpUpdateOne) {
  567. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  568. }
  569. if m.id == nil || m.oldValue == nil {
  570. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  571. }
  572. oldValue, err := m.oldValue(ctx)
  573. if err != nil {
  574. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  575. }
  576. return oldValue.OrganizationID, nil
  577. }
  578. // AddOrganizationID adds u to the "organization_id" field.
  579. func (m *AgentMutation) AddOrganizationID(u int64) {
  580. if m.addorganization_id != nil {
  581. *m.addorganization_id += u
  582. } else {
  583. m.addorganization_id = &u
  584. }
  585. }
  586. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  587. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  588. v := m.addorganization_id
  589. if v == nil {
  590. return
  591. }
  592. return *v, true
  593. }
  594. // ResetOrganizationID resets all changes to the "organization_id" field.
  595. func (m *AgentMutation) ResetOrganizationID() {
  596. m.organization_id = nil
  597. m.addorganization_id = nil
  598. }
  599. // SetDatasetID sets the "dataset_id" field.
  600. func (m *AgentMutation) SetDatasetID(s string) {
  601. m.dataset_id = &s
  602. }
  603. // DatasetID returns the value of the "dataset_id" field in the mutation.
  604. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  605. v := m.dataset_id
  606. if v == nil {
  607. return
  608. }
  609. return *v, true
  610. }
  611. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  612. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  614. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  615. if !m.op.Is(OpUpdateOne) {
  616. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  617. }
  618. if m.id == nil || m.oldValue == nil {
  619. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  620. }
  621. oldValue, err := m.oldValue(ctx)
  622. if err != nil {
  623. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  624. }
  625. return oldValue.DatasetID, nil
  626. }
  627. // ResetDatasetID resets all changes to the "dataset_id" field.
  628. func (m *AgentMutation) ResetDatasetID() {
  629. m.dataset_id = nil
  630. }
  631. // SetCollectionID sets the "collection_id" field.
  632. func (m *AgentMutation) SetCollectionID(s string) {
  633. m.collection_id = &s
  634. }
  635. // CollectionID returns the value of the "collection_id" field in the mutation.
  636. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  637. v := m.collection_id
  638. if v == nil {
  639. return
  640. }
  641. return *v, true
  642. }
  643. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  644. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  646. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  647. if !m.op.Is(OpUpdateOne) {
  648. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  649. }
  650. if m.id == nil || m.oldValue == nil {
  651. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  652. }
  653. oldValue, err := m.oldValue(ctx)
  654. if err != nil {
  655. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  656. }
  657. return oldValue.CollectionID, nil
  658. }
  659. // ResetCollectionID resets all changes to the "collection_id" field.
  660. func (m *AgentMutation) ResetCollectionID() {
  661. m.collection_id = nil
  662. }
  663. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  664. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  665. if m.wx_agent == nil {
  666. m.wx_agent = make(map[uint64]struct{})
  667. }
  668. for i := range ids {
  669. m.wx_agent[ids[i]] = struct{}{}
  670. }
  671. }
  672. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  673. func (m *AgentMutation) ClearWxAgent() {
  674. m.clearedwx_agent = true
  675. }
  676. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  677. func (m *AgentMutation) WxAgentCleared() bool {
  678. return m.clearedwx_agent
  679. }
  680. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  681. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  682. if m.removedwx_agent == nil {
  683. m.removedwx_agent = make(map[uint64]struct{})
  684. }
  685. for i := range ids {
  686. delete(m.wx_agent, ids[i])
  687. m.removedwx_agent[ids[i]] = struct{}{}
  688. }
  689. }
  690. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  691. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  692. for id := range m.removedwx_agent {
  693. ids = append(ids, id)
  694. }
  695. return
  696. }
  697. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  698. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  699. for id := range m.wx_agent {
  700. ids = append(ids, id)
  701. }
  702. return
  703. }
  704. // ResetWxAgent resets all changes to the "wx_agent" edge.
  705. func (m *AgentMutation) ResetWxAgent() {
  706. m.wx_agent = nil
  707. m.clearedwx_agent = false
  708. m.removedwx_agent = nil
  709. }
  710. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  711. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  712. if m.token_agent == nil {
  713. m.token_agent = make(map[uint64]struct{})
  714. }
  715. for i := range ids {
  716. m.token_agent[ids[i]] = struct{}{}
  717. }
  718. }
  719. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  720. func (m *AgentMutation) ClearTokenAgent() {
  721. m.clearedtoken_agent = true
  722. }
  723. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  724. func (m *AgentMutation) TokenAgentCleared() bool {
  725. return m.clearedtoken_agent
  726. }
  727. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  728. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  729. if m.removedtoken_agent == nil {
  730. m.removedtoken_agent = make(map[uint64]struct{})
  731. }
  732. for i := range ids {
  733. delete(m.token_agent, ids[i])
  734. m.removedtoken_agent[ids[i]] = struct{}{}
  735. }
  736. }
  737. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  738. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  739. for id := range m.removedtoken_agent {
  740. ids = append(ids, id)
  741. }
  742. return
  743. }
  744. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  745. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  746. for id := range m.token_agent {
  747. ids = append(ids, id)
  748. }
  749. return
  750. }
  751. // ResetTokenAgent resets all changes to the "token_agent" edge.
  752. func (m *AgentMutation) ResetTokenAgent() {
  753. m.token_agent = nil
  754. m.clearedtoken_agent = false
  755. m.removedtoken_agent = nil
  756. }
  757. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  758. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  759. if m.wa_agent == nil {
  760. m.wa_agent = make(map[uint64]struct{})
  761. }
  762. for i := range ids {
  763. m.wa_agent[ids[i]] = struct{}{}
  764. }
  765. }
  766. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  767. func (m *AgentMutation) ClearWaAgent() {
  768. m.clearedwa_agent = true
  769. }
  770. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  771. func (m *AgentMutation) WaAgentCleared() bool {
  772. return m.clearedwa_agent
  773. }
  774. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  775. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  776. if m.removedwa_agent == nil {
  777. m.removedwa_agent = make(map[uint64]struct{})
  778. }
  779. for i := range ids {
  780. delete(m.wa_agent, ids[i])
  781. m.removedwa_agent[ids[i]] = struct{}{}
  782. }
  783. }
  784. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  785. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  786. for id := range m.removedwa_agent {
  787. ids = append(ids, id)
  788. }
  789. return
  790. }
  791. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  792. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  793. for id := range m.wa_agent {
  794. ids = append(ids, id)
  795. }
  796. return
  797. }
  798. // ResetWaAgent resets all changes to the "wa_agent" edge.
  799. func (m *AgentMutation) ResetWaAgent() {
  800. m.wa_agent = nil
  801. m.clearedwa_agent = false
  802. m.removedwa_agent = nil
  803. }
  804. // Where appends a list predicates to the AgentMutation builder.
  805. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  806. m.predicates = append(m.predicates, ps...)
  807. }
  808. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  809. // users can use type-assertion to append predicates that do not depend on any generated package.
  810. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  811. p := make([]predicate.Agent, len(ps))
  812. for i := range ps {
  813. p[i] = ps[i]
  814. }
  815. m.Where(p...)
  816. }
  817. // Op returns the operation name.
  818. func (m *AgentMutation) Op() Op {
  819. return m.op
  820. }
  821. // SetOp allows setting the mutation operation.
  822. func (m *AgentMutation) SetOp(op Op) {
  823. m.op = op
  824. }
  825. // Type returns the node type of this mutation (Agent).
  826. func (m *AgentMutation) Type() string {
  827. return m.typ
  828. }
  829. // Fields returns all fields that were changed during this mutation. Note that in
  830. // order to get all numeric fields that were incremented/decremented, call
  831. // AddedFields().
  832. func (m *AgentMutation) Fields() []string {
  833. fields := make([]string, 0, 11)
  834. if m.created_at != nil {
  835. fields = append(fields, agent.FieldCreatedAt)
  836. }
  837. if m.updated_at != nil {
  838. fields = append(fields, agent.FieldUpdatedAt)
  839. }
  840. if m.deleted_at != nil {
  841. fields = append(fields, agent.FieldDeletedAt)
  842. }
  843. if m.name != nil {
  844. fields = append(fields, agent.FieldName)
  845. }
  846. if m.role != nil {
  847. fields = append(fields, agent.FieldRole)
  848. }
  849. if m.status != nil {
  850. fields = append(fields, agent.FieldStatus)
  851. }
  852. if m.background != nil {
  853. fields = append(fields, agent.FieldBackground)
  854. }
  855. if m.examples != nil {
  856. fields = append(fields, agent.FieldExamples)
  857. }
  858. if m.organization_id != nil {
  859. fields = append(fields, agent.FieldOrganizationID)
  860. }
  861. if m.dataset_id != nil {
  862. fields = append(fields, agent.FieldDatasetID)
  863. }
  864. if m.collection_id != nil {
  865. fields = append(fields, agent.FieldCollectionID)
  866. }
  867. return fields
  868. }
  869. // Field returns the value of a field with the given name. The second boolean
  870. // return value indicates that this field was not set, or was not defined in the
  871. // schema.
  872. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  873. switch name {
  874. case agent.FieldCreatedAt:
  875. return m.CreatedAt()
  876. case agent.FieldUpdatedAt:
  877. return m.UpdatedAt()
  878. case agent.FieldDeletedAt:
  879. return m.DeletedAt()
  880. case agent.FieldName:
  881. return m.Name()
  882. case agent.FieldRole:
  883. return m.Role()
  884. case agent.FieldStatus:
  885. return m.Status()
  886. case agent.FieldBackground:
  887. return m.Background()
  888. case agent.FieldExamples:
  889. return m.Examples()
  890. case agent.FieldOrganizationID:
  891. return m.OrganizationID()
  892. case agent.FieldDatasetID:
  893. return m.DatasetID()
  894. case agent.FieldCollectionID:
  895. return m.CollectionID()
  896. }
  897. return nil, false
  898. }
  899. // OldField returns the old value of the field from the database. An error is
  900. // returned if the mutation operation is not UpdateOne, or the query to the
  901. // database failed.
  902. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  903. switch name {
  904. case agent.FieldCreatedAt:
  905. return m.OldCreatedAt(ctx)
  906. case agent.FieldUpdatedAt:
  907. return m.OldUpdatedAt(ctx)
  908. case agent.FieldDeletedAt:
  909. return m.OldDeletedAt(ctx)
  910. case agent.FieldName:
  911. return m.OldName(ctx)
  912. case agent.FieldRole:
  913. return m.OldRole(ctx)
  914. case agent.FieldStatus:
  915. return m.OldStatus(ctx)
  916. case agent.FieldBackground:
  917. return m.OldBackground(ctx)
  918. case agent.FieldExamples:
  919. return m.OldExamples(ctx)
  920. case agent.FieldOrganizationID:
  921. return m.OldOrganizationID(ctx)
  922. case agent.FieldDatasetID:
  923. return m.OldDatasetID(ctx)
  924. case agent.FieldCollectionID:
  925. return m.OldCollectionID(ctx)
  926. }
  927. return nil, fmt.Errorf("unknown Agent field %s", name)
  928. }
  929. // SetField sets the value of a field with the given name. It returns an error if
  930. // the field is not defined in the schema, or if the type mismatched the field
  931. // type.
  932. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  933. switch name {
  934. case agent.FieldCreatedAt:
  935. v, ok := value.(time.Time)
  936. if !ok {
  937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  938. }
  939. m.SetCreatedAt(v)
  940. return nil
  941. case agent.FieldUpdatedAt:
  942. v, ok := value.(time.Time)
  943. if !ok {
  944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  945. }
  946. m.SetUpdatedAt(v)
  947. return nil
  948. case agent.FieldDeletedAt:
  949. v, ok := value.(time.Time)
  950. if !ok {
  951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  952. }
  953. m.SetDeletedAt(v)
  954. return nil
  955. case agent.FieldName:
  956. v, ok := value.(string)
  957. if !ok {
  958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  959. }
  960. m.SetName(v)
  961. return nil
  962. case agent.FieldRole:
  963. v, ok := value.(string)
  964. if !ok {
  965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  966. }
  967. m.SetRole(v)
  968. return nil
  969. case agent.FieldStatus:
  970. v, ok := value.(int)
  971. if !ok {
  972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  973. }
  974. m.SetStatus(v)
  975. return nil
  976. case agent.FieldBackground:
  977. v, ok := value.(string)
  978. if !ok {
  979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  980. }
  981. m.SetBackground(v)
  982. return nil
  983. case agent.FieldExamples:
  984. v, ok := value.(string)
  985. if !ok {
  986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  987. }
  988. m.SetExamples(v)
  989. return nil
  990. case agent.FieldOrganizationID:
  991. v, ok := value.(uint64)
  992. if !ok {
  993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  994. }
  995. m.SetOrganizationID(v)
  996. return nil
  997. case agent.FieldDatasetID:
  998. v, ok := value.(string)
  999. if !ok {
  1000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1001. }
  1002. m.SetDatasetID(v)
  1003. return nil
  1004. case agent.FieldCollectionID:
  1005. v, ok := value.(string)
  1006. if !ok {
  1007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1008. }
  1009. m.SetCollectionID(v)
  1010. return nil
  1011. }
  1012. return fmt.Errorf("unknown Agent field %s", name)
  1013. }
  1014. // AddedFields returns all numeric fields that were incremented/decremented during
  1015. // this mutation.
  1016. func (m *AgentMutation) AddedFields() []string {
  1017. var fields []string
  1018. if m.addstatus != nil {
  1019. fields = append(fields, agent.FieldStatus)
  1020. }
  1021. if m.addorganization_id != nil {
  1022. fields = append(fields, agent.FieldOrganizationID)
  1023. }
  1024. return fields
  1025. }
  1026. // AddedField returns the numeric value that was incremented/decremented on a field
  1027. // with the given name. The second boolean return value indicates that this field
  1028. // was not set, or was not defined in the schema.
  1029. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1030. switch name {
  1031. case agent.FieldStatus:
  1032. return m.AddedStatus()
  1033. case agent.FieldOrganizationID:
  1034. return m.AddedOrganizationID()
  1035. }
  1036. return nil, false
  1037. }
  1038. // AddField adds the value to the field with the given name. It returns an error if
  1039. // the field is not defined in the schema, or if the type mismatched the field
  1040. // type.
  1041. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1042. switch name {
  1043. case agent.FieldStatus:
  1044. v, ok := value.(int)
  1045. if !ok {
  1046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1047. }
  1048. m.AddStatus(v)
  1049. return nil
  1050. case agent.FieldOrganizationID:
  1051. v, ok := value.(int64)
  1052. if !ok {
  1053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1054. }
  1055. m.AddOrganizationID(v)
  1056. return nil
  1057. }
  1058. return fmt.Errorf("unknown Agent numeric field %s", name)
  1059. }
  1060. // ClearedFields returns all nullable fields that were cleared during this
  1061. // mutation.
  1062. func (m *AgentMutation) ClearedFields() []string {
  1063. var fields []string
  1064. if m.FieldCleared(agent.FieldDeletedAt) {
  1065. fields = append(fields, agent.FieldDeletedAt)
  1066. }
  1067. if m.FieldCleared(agent.FieldStatus) {
  1068. fields = append(fields, agent.FieldStatus)
  1069. }
  1070. if m.FieldCleared(agent.FieldBackground) {
  1071. fields = append(fields, agent.FieldBackground)
  1072. }
  1073. if m.FieldCleared(agent.FieldExamples) {
  1074. fields = append(fields, agent.FieldExamples)
  1075. }
  1076. return fields
  1077. }
  1078. // FieldCleared returns a boolean indicating if a field with the given name was
  1079. // cleared in this mutation.
  1080. func (m *AgentMutation) FieldCleared(name string) bool {
  1081. _, ok := m.clearedFields[name]
  1082. return ok
  1083. }
  1084. // ClearField clears the value of the field with the given name. It returns an
  1085. // error if the field is not defined in the schema.
  1086. func (m *AgentMutation) ClearField(name string) error {
  1087. switch name {
  1088. case agent.FieldDeletedAt:
  1089. m.ClearDeletedAt()
  1090. return nil
  1091. case agent.FieldStatus:
  1092. m.ClearStatus()
  1093. return nil
  1094. case agent.FieldBackground:
  1095. m.ClearBackground()
  1096. return nil
  1097. case agent.FieldExamples:
  1098. m.ClearExamples()
  1099. return nil
  1100. }
  1101. return fmt.Errorf("unknown Agent nullable field %s", name)
  1102. }
  1103. // ResetField resets all changes in the mutation for the field with the given name.
  1104. // It returns an error if the field is not defined in the schema.
  1105. func (m *AgentMutation) ResetField(name string) error {
  1106. switch name {
  1107. case agent.FieldCreatedAt:
  1108. m.ResetCreatedAt()
  1109. return nil
  1110. case agent.FieldUpdatedAt:
  1111. m.ResetUpdatedAt()
  1112. return nil
  1113. case agent.FieldDeletedAt:
  1114. m.ResetDeletedAt()
  1115. return nil
  1116. case agent.FieldName:
  1117. m.ResetName()
  1118. return nil
  1119. case agent.FieldRole:
  1120. m.ResetRole()
  1121. return nil
  1122. case agent.FieldStatus:
  1123. m.ResetStatus()
  1124. return nil
  1125. case agent.FieldBackground:
  1126. m.ResetBackground()
  1127. return nil
  1128. case agent.FieldExamples:
  1129. m.ResetExamples()
  1130. return nil
  1131. case agent.FieldOrganizationID:
  1132. m.ResetOrganizationID()
  1133. return nil
  1134. case agent.FieldDatasetID:
  1135. m.ResetDatasetID()
  1136. return nil
  1137. case agent.FieldCollectionID:
  1138. m.ResetCollectionID()
  1139. return nil
  1140. }
  1141. return fmt.Errorf("unknown Agent field %s", name)
  1142. }
  1143. // AddedEdges returns all edge names that were set/added in this mutation.
  1144. func (m *AgentMutation) AddedEdges() []string {
  1145. edges := make([]string, 0, 3)
  1146. if m.wx_agent != nil {
  1147. edges = append(edges, agent.EdgeWxAgent)
  1148. }
  1149. if m.token_agent != nil {
  1150. edges = append(edges, agent.EdgeTokenAgent)
  1151. }
  1152. if m.wa_agent != nil {
  1153. edges = append(edges, agent.EdgeWaAgent)
  1154. }
  1155. return edges
  1156. }
  1157. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1158. // name in this mutation.
  1159. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1160. switch name {
  1161. case agent.EdgeWxAgent:
  1162. ids := make([]ent.Value, 0, len(m.wx_agent))
  1163. for id := range m.wx_agent {
  1164. ids = append(ids, id)
  1165. }
  1166. return ids
  1167. case agent.EdgeTokenAgent:
  1168. ids := make([]ent.Value, 0, len(m.token_agent))
  1169. for id := range m.token_agent {
  1170. ids = append(ids, id)
  1171. }
  1172. return ids
  1173. case agent.EdgeWaAgent:
  1174. ids := make([]ent.Value, 0, len(m.wa_agent))
  1175. for id := range m.wa_agent {
  1176. ids = append(ids, id)
  1177. }
  1178. return ids
  1179. }
  1180. return nil
  1181. }
  1182. // RemovedEdges returns all edge names that were removed in this mutation.
  1183. func (m *AgentMutation) RemovedEdges() []string {
  1184. edges := make([]string, 0, 3)
  1185. if m.removedwx_agent != nil {
  1186. edges = append(edges, agent.EdgeWxAgent)
  1187. }
  1188. if m.removedtoken_agent != nil {
  1189. edges = append(edges, agent.EdgeTokenAgent)
  1190. }
  1191. if m.removedwa_agent != nil {
  1192. edges = append(edges, agent.EdgeWaAgent)
  1193. }
  1194. return edges
  1195. }
  1196. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1197. // the given name in this mutation.
  1198. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1199. switch name {
  1200. case agent.EdgeWxAgent:
  1201. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1202. for id := range m.removedwx_agent {
  1203. ids = append(ids, id)
  1204. }
  1205. return ids
  1206. case agent.EdgeTokenAgent:
  1207. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1208. for id := range m.removedtoken_agent {
  1209. ids = append(ids, id)
  1210. }
  1211. return ids
  1212. case agent.EdgeWaAgent:
  1213. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1214. for id := range m.removedwa_agent {
  1215. ids = append(ids, id)
  1216. }
  1217. return ids
  1218. }
  1219. return nil
  1220. }
  1221. // ClearedEdges returns all edge names that were cleared in this mutation.
  1222. func (m *AgentMutation) ClearedEdges() []string {
  1223. edges := make([]string, 0, 3)
  1224. if m.clearedwx_agent {
  1225. edges = append(edges, agent.EdgeWxAgent)
  1226. }
  1227. if m.clearedtoken_agent {
  1228. edges = append(edges, agent.EdgeTokenAgent)
  1229. }
  1230. if m.clearedwa_agent {
  1231. edges = append(edges, agent.EdgeWaAgent)
  1232. }
  1233. return edges
  1234. }
  1235. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1236. // was cleared in this mutation.
  1237. func (m *AgentMutation) EdgeCleared(name string) bool {
  1238. switch name {
  1239. case agent.EdgeWxAgent:
  1240. return m.clearedwx_agent
  1241. case agent.EdgeTokenAgent:
  1242. return m.clearedtoken_agent
  1243. case agent.EdgeWaAgent:
  1244. return m.clearedwa_agent
  1245. }
  1246. return false
  1247. }
  1248. // ClearEdge clears the value of the edge with the given name. It returns an error
  1249. // if that edge is not defined in the schema.
  1250. func (m *AgentMutation) ClearEdge(name string) error {
  1251. switch name {
  1252. }
  1253. return fmt.Errorf("unknown Agent unique edge %s", name)
  1254. }
  1255. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1256. // It returns an error if the edge is not defined in the schema.
  1257. func (m *AgentMutation) ResetEdge(name string) error {
  1258. switch name {
  1259. case agent.EdgeWxAgent:
  1260. m.ResetWxAgent()
  1261. return nil
  1262. case agent.EdgeTokenAgent:
  1263. m.ResetTokenAgent()
  1264. return nil
  1265. case agent.EdgeWaAgent:
  1266. m.ResetWaAgent()
  1267. return nil
  1268. }
  1269. return fmt.Errorf("unknown Agent edge %s", name)
  1270. }
  1271. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1272. type AgentBaseMutation struct {
  1273. config
  1274. op Op
  1275. typ string
  1276. id *string
  1277. q *string
  1278. a *string
  1279. chunk_index *uint64
  1280. addchunk_index *int64
  1281. indexes *[]string
  1282. appendindexes []string
  1283. dataset_id *string
  1284. collection_id *string
  1285. source_name *string
  1286. can_write *[]bool
  1287. appendcan_write []bool
  1288. is_owner *[]bool
  1289. appendis_owner []bool
  1290. clearedFields map[string]struct{}
  1291. wx_agent map[uint64]struct{}
  1292. removedwx_agent map[uint64]struct{}
  1293. clearedwx_agent bool
  1294. done bool
  1295. oldValue func(context.Context) (*AgentBase, error)
  1296. predicates []predicate.AgentBase
  1297. }
  1298. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1299. // agentbaseOption allows management of the mutation configuration using functional options.
  1300. type agentbaseOption func(*AgentBaseMutation)
  1301. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1302. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1303. m := &AgentBaseMutation{
  1304. config: c,
  1305. op: op,
  1306. typ: TypeAgentBase,
  1307. clearedFields: make(map[string]struct{}),
  1308. }
  1309. for _, opt := range opts {
  1310. opt(m)
  1311. }
  1312. return m
  1313. }
  1314. // withAgentBaseID sets the ID field of the mutation.
  1315. func withAgentBaseID(id string) agentbaseOption {
  1316. return func(m *AgentBaseMutation) {
  1317. var (
  1318. err error
  1319. once sync.Once
  1320. value *AgentBase
  1321. )
  1322. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1323. once.Do(func() {
  1324. if m.done {
  1325. err = errors.New("querying old values post mutation is not allowed")
  1326. } else {
  1327. value, err = m.Client().AgentBase.Get(ctx, id)
  1328. }
  1329. })
  1330. return value, err
  1331. }
  1332. m.id = &id
  1333. }
  1334. }
  1335. // withAgentBase sets the old AgentBase of the mutation.
  1336. func withAgentBase(node *AgentBase) agentbaseOption {
  1337. return func(m *AgentBaseMutation) {
  1338. m.oldValue = func(context.Context) (*AgentBase, error) {
  1339. return node, nil
  1340. }
  1341. m.id = &node.ID
  1342. }
  1343. }
  1344. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1345. // executed in a transaction (ent.Tx), a transactional client is returned.
  1346. func (m AgentBaseMutation) Client() *Client {
  1347. client := &Client{config: m.config}
  1348. client.init()
  1349. return client
  1350. }
  1351. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1352. // it returns an error otherwise.
  1353. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1354. if _, ok := m.driver.(*txDriver); !ok {
  1355. return nil, errors.New("ent: mutation is not running in a transaction")
  1356. }
  1357. tx := &Tx{config: m.config}
  1358. tx.init()
  1359. return tx, nil
  1360. }
  1361. // SetID sets the value of the id field. Note that this
  1362. // operation is only accepted on creation of AgentBase entities.
  1363. func (m *AgentBaseMutation) SetID(id string) {
  1364. m.id = &id
  1365. }
  1366. // ID returns the ID value in the mutation. Note that the ID is only available
  1367. // if it was provided to the builder or after it was returned from the database.
  1368. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1369. if m.id == nil {
  1370. return
  1371. }
  1372. return *m.id, true
  1373. }
  1374. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1375. // That means, if the mutation is applied within a transaction with an isolation level such
  1376. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1377. // or updated by the mutation.
  1378. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1379. switch {
  1380. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1381. id, exists := m.ID()
  1382. if exists {
  1383. return []string{id}, nil
  1384. }
  1385. fallthrough
  1386. case m.op.Is(OpUpdate | OpDelete):
  1387. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1388. default:
  1389. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1390. }
  1391. }
  1392. // SetQ sets the "q" field.
  1393. func (m *AgentBaseMutation) SetQ(s string) {
  1394. m.q = &s
  1395. }
  1396. // Q returns the value of the "q" field in the mutation.
  1397. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1398. v := m.q
  1399. if v == nil {
  1400. return
  1401. }
  1402. return *v, true
  1403. }
  1404. // OldQ returns the old "q" field's value of the AgentBase entity.
  1405. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1407. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1408. if !m.op.Is(OpUpdateOne) {
  1409. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1410. }
  1411. if m.id == nil || m.oldValue == nil {
  1412. return v, errors.New("OldQ requires an ID field in the mutation")
  1413. }
  1414. oldValue, err := m.oldValue(ctx)
  1415. if err != nil {
  1416. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1417. }
  1418. return oldValue.Q, nil
  1419. }
  1420. // ClearQ clears the value of the "q" field.
  1421. func (m *AgentBaseMutation) ClearQ() {
  1422. m.q = nil
  1423. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1424. }
  1425. // QCleared returns if the "q" field was cleared in this mutation.
  1426. func (m *AgentBaseMutation) QCleared() bool {
  1427. _, ok := m.clearedFields[agentbase.FieldQ]
  1428. return ok
  1429. }
  1430. // ResetQ resets all changes to the "q" field.
  1431. func (m *AgentBaseMutation) ResetQ() {
  1432. m.q = nil
  1433. delete(m.clearedFields, agentbase.FieldQ)
  1434. }
  1435. // SetA sets the "a" field.
  1436. func (m *AgentBaseMutation) SetA(s string) {
  1437. m.a = &s
  1438. }
  1439. // A returns the value of the "a" field in the mutation.
  1440. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1441. v := m.a
  1442. if v == nil {
  1443. return
  1444. }
  1445. return *v, true
  1446. }
  1447. // OldA returns the old "a" field's value of the AgentBase entity.
  1448. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1450. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1451. if !m.op.Is(OpUpdateOne) {
  1452. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1453. }
  1454. if m.id == nil || m.oldValue == nil {
  1455. return v, errors.New("OldA requires an ID field in the mutation")
  1456. }
  1457. oldValue, err := m.oldValue(ctx)
  1458. if err != nil {
  1459. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1460. }
  1461. return oldValue.A, nil
  1462. }
  1463. // ClearA clears the value of the "a" field.
  1464. func (m *AgentBaseMutation) ClearA() {
  1465. m.a = nil
  1466. m.clearedFields[agentbase.FieldA] = struct{}{}
  1467. }
  1468. // ACleared returns if the "a" field was cleared in this mutation.
  1469. func (m *AgentBaseMutation) ACleared() bool {
  1470. _, ok := m.clearedFields[agentbase.FieldA]
  1471. return ok
  1472. }
  1473. // ResetA resets all changes to the "a" field.
  1474. func (m *AgentBaseMutation) ResetA() {
  1475. m.a = nil
  1476. delete(m.clearedFields, agentbase.FieldA)
  1477. }
  1478. // SetChunkIndex sets the "chunk_index" field.
  1479. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1480. m.chunk_index = &u
  1481. m.addchunk_index = nil
  1482. }
  1483. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1484. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1485. v := m.chunk_index
  1486. if v == nil {
  1487. return
  1488. }
  1489. return *v, true
  1490. }
  1491. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1492. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1494. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1495. if !m.op.Is(OpUpdateOne) {
  1496. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1497. }
  1498. if m.id == nil || m.oldValue == nil {
  1499. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1500. }
  1501. oldValue, err := m.oldValue(ctx)
  1502. if err != nil {
  1503. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1504. }
  1505. return oldValue.ChunkIndex, nil
  1506. }
  1507. // AddChunkIndex adds u to the "chunk_index" field.
  1508. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1509. if m.addchunk_index != nil {
  1510. *m.addchunk_index += u
  1511. } else {
  1512. m.addchunk_index = &u
  1513. }
  1514. }
  1515. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1516. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1517. v := m.addchunk_index
  1518. if v == nil {
  1519. return
  1520. }
  1521. return *v, true
  1522. }
  1523. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1524. func (m *AgentBaseMutation) ResetChunkIndex() {
  1525. m.chunk_index = nil
  1526. m.addchunk_index = nil
  1527. }
  1528. // SetIndexes sets the "indexes" field.
  1529. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1530. m.indexes = &s
  1531. m.appendindexes = nil
  1532. }
  1533. // Indexes returns the value of the "indexes" field in the mutation.
  1534. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1535. v := m.indexes
  1536. if v == nil {
  1537. return
  1538. }
  1539. return *v, true
  1540. }
  1541. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1542. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1544. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1545. if !m.op.Is(OpUpdateOne) {
  1546. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1547. }
  1548. if m.id == nil || m.oldValue == nil {
  1549. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1550. }
  1551. oldValue, err := m.oldValue(ctx)
  1552. if err != nil {
  1553. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1554. }
  1555. return oldValue.Indexes, nil
  1556. }
  1557. // AppendIndexes adds s to the "indexes" field.
  1558. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1559. m.appendindexes = append(m.appendindexes, s...)
  1560. }
  1561. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1562. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1563. if len(m.appendindexes) == 0 {
  1564. return nil, false
  1565. }
  1566. return m.appendindexes, true
  1567. }
  1568. // ClearIndexes clears the value of the "indexes" field.
  1569. func (m *AgentBaseMutation) ClearIndexes() {
  1570. m.indexes = nil
  1571. m.appendindexes = nil
  1572. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1573. }
  1574. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1575. func (m *AgentBaseMutation) IndexesCleared() bool {
  1576. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1577. return ok
  1578. }
  1579. // ResetIndexes resets all changes to the "indexes" field.
  1580. func (m *AgentBaseMutation) ResetIndexes() {
  1581. m.indexes = nil
  1582. m.appendindexes = nil
  1583. delete(m.clearedFields, agentbase.FieldIndexes)
  1584. }
  1585. // SetDatasetID sets the "dataset_id" field.
  1586. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1587. m.dataset_id = &s
  1588. }
  1589. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1590. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1591. v := m.dataset_id
  1592. if v == nil {
  1593. return
  1594. }
  1595. return *v, true
  1596. }
  1597. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1598. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1600. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1601. if !m.op.Is(OpUpdateOne) {
  1602. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1603. }
  1604. if m.id == nil || m.oldValue == nil {
  1605. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1606. }
  1607. oldValue, err := m.oldValue(ctx)
  1608. if err != nil {
  1609. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1610. }
  1611. return oldValue.DatasetID, nil
  1612. }
  1613. // ClearDatasetID clears the value of the "dataset_id" field.
  1614. func (m *AgentBaseMutation) ClearDatasetID() {
  1615. m.dataset_id = nil
  1616. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1617. }
  1618. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1619. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1620. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1621. return ok
  1622. }
  1623. // ResetDatasetID resets all changes to the "dataset_id" field.
  1624. func (m *AgentBaseMutation) ResetDatasetID() {
  1625. m.dataset_id = nil
  1626. delete(m.clearedFields, agentbase.FieldDatasetID)
  1627. }
  1628. // SetCollectionID sets the "collection_id" field.
  1629. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1630. m.collection_id = &s
  1631. }
  1632. // CollectionID returns the value of the "collection_id" field in the mutation.
  1633. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1634. v := m.collection_id
  1635. if v == nil {
  1636. return
  1637. }
  1638. return *v, true
  1639. }
  1640. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1641. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1643. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1644. if !m.op.Is(OpUpdateOne) {
  1645. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1646. }
  1647. if m.id == nil || m.oldValue == nil {
  1648. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1649. }
  1650. oldValue, err := m.oldValue(ctx)
  1651. if err != nil {
  1652. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1653. }
  1654. return oldValue.CollectionID, nil
  1655. }
  1656. // ClearCollectionID clears the value of the "collection_id" field.
  1657. func (m *AgentBaseMutation) ClearCollectionID() {
  1658. m.collection_id = nil
  1659. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1660. }
  1661. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1662. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1663. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1664. return ok
  1665. }
  1666. // ResetCollectionID resets all changes to the "collection_id" field.
  1667. func (m *AgentBaseMutation) ResetCollectionID() {
  1668. m.collection_id = nil
  1669. delete(m.clearedFields, agentbase.FieldCollectionID)
  1670. }
  1671. // SetSourceName sets the "source_name" field.
  1672. func (m *AgentBaseMutation) SetSourceName(s string) {
  1673. m.source_name = &s
  1674. }
  1675. // SourceName returns the value of the "source_name" field in the mutation.
  1676. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1677. v := m.source_name
  1678. if v == nil {
  1679. return
  1680. }
  1681. return *v, true
  1682. }
  1683. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1684. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1686. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1687. if !m.op.Is(OpUpdateOne) {
  1688. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1689. }
  1690. if m.id == nil || m.oldValue == nil {
  1691. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1692. }
  1693. oldValue, err := m.oldValue(ctx)
  1694. if err != nil {
  1695. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1696. }
  1697. return oldValue.SourceName, nil
  1698. }
  1699. // ClearSourceName clears the value of the "source_name" field.
  1700. func (m *AgentBaseMutation) ClearSourceName() {
  1701. m.source_name = nil
  1702. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1703. }
  1704. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1705. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1706. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1707. return ok
  1708. }
  1709. // ResetSourceName resets all changes to the "source_name" field.
  1710. func (m *AgentBaseMutation) ResetSourceName() {
  1711. m.source_name = nil
  1712. delete(m.clearedFields, agentbase.FieldSourceName)
  1713. }
  1714. // SetCanWrite sets the "can_write" field.
  1715. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1716. m.can_write = &b
  1717. m.appendcan_write = nil
  1718. }
  1719. // CanWrite returns the value of the "can_write" field in the mutation.
  1720. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1721. v := m.can_write
  1722. if v == nil {
  1723. return
  1724. }
  1725. return *v, true
  1726. }
  1727. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1728. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1730. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1731. if !m.op.Is(OpUpdateOne) {
  1732. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1733. }
  1734. if m.id == nil || m.oldValue == nil {
  1735. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1736. }
  1737. oldValue, err := m.oldValue(ctx)
  1738. if err != nil {
  1739. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1740. }
  1741. return oldValue.CanWrite, nil
  1742. }
  1743. // AppendCanWrite adds b to the "can_write" field.
  1744. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1745. m.appendcan_write = append(m.appendcan_write, b...)
  1746. }
  1747. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1748. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1749. if len(m.appendcan_write) == 0 {
  1750. return nil, false
  1751. }
  1752. return m.appendcan_write, true
  1753. }
  1754. // ClearCanWrite clears the value of the "can_write" field.
  1755. func (m *AgentBaseMutation) ClearCanWrite() {
  1756. m.can_write = nil
  1757. m.appendcan_write = nil
  1758. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1759. }
  1760. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1761. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1762. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1763. return ok
  1764. }
  1765. // ResetCanWrite resets all changes to the "can_write" field.
  1766. func (m *AgentBaseMutation) ResetCanWrite() {
  1767. m.can_write = nil
  1768. m.appendcan_write = nil
  1769. delete(m.clearedFields, agentbase.FieldCanWrite)
  1770. }
  1771. // SetIsOwner sets the "is_owner" field.
  1772. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1773. m.is_owner = &b
  1774. m.appendis_owner = nil
  1775. }
  1776. // IsOwner returns the value of the "is_owner" field in the mutation.
  1777. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1778. v := m.is_owner
  1779. if v == nil {
  1780. return
  1781. }
  1782. return *v, true
  1783. }
  1784. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1785. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1787. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1788. if !m.op.Is(OpUpdateOne) {
  1789. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1790. }
  1791. if m.id == nil || m.oldValue == nil {
  1792. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1793. }
  1794. oldValue, err := m.oldValue(ctx)
  1795. if err != nil {
  1796. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1797. }
  1798. return oldValue.IsOwner, nil
  1799. }
  1800. // AppendIsOwner adds b to the "is_owner" field.
  1801. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1802. m.appendis_owner = append(m.appendis_owner, b...)
  1803. }
  1804. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1805. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1806. if len(m.appendis_owner) == 0 {
  1807. return nil, false
  1808. }
  1809. return m.appendis_owner, true
  1810. }
  1811. // ClearIsOwner clears the value of the "is_owner" field.
  1812. func (m *AgentBaseMutation) ClearIsOwner() {
  1813. m.is_owner = nil
  1814. m.appendis_owner = nil
  1815. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1816. }
  1817. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1818. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1819. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1820. return ok
  1821. }
  1822. // ResetIsOwner resets all changes to the "is_owner" field.
  1823. func (m *AgentBaseMutation) ResetIsOwner() {
  1824. m.is_owner = nil
  1825. m.appendis_owner = nil
  1826. delete(m.clearedFields, agentbase.FieldIsOwner)
  1827. }
  1828. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1829. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1830. if m.wx_agent == nil {
  1831. m.wx_agent = make(map[uint64]struct{})
  1832. }
  1833. for i := range ids {
  1834. m.wx_agent[ids[i]] = struct{}{}
  1835. }
  1836. }
  1837. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1838. func (m *AgentBaseMutation) ClearWxAgent() {
  1839. m.clearedwx_agent = true
  1840. }
  1841. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1842. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1843. return m.clearedwx_agent
  1844. }
  1845. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1846. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1847. if m.removedwx_agent == nil {
  1848. m.removedwx_agent = make(map[uint64]struct{})
  1849. }
  1850. for i := range ids {
  1851. delete(m.wx_agent, ids[i])
  1852. m.removedwx_agent[ids[i]] = struct{}{}
  1853. }
  1854. }
  1855. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1856. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1857. for id := range m.removedwx_agent {
  1858. ids = append(ids, id)
  1859. }
  1860. return
  1861. }
  1862. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1863. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1864. for id := range m.wx_agent {
  1865. ids = append(ids, id)
  1866. }
  1867. return
  1868. }
  1869. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1870. func (m *AgentBaseMutation) ResetWxAgent() {
  1871. m.wx_agent = nil
  1872. m.clearedwx_agent = false
  1873. m.removedwx_agent = nil
  1874. }
  1875. // Where appends a list predicates to the AgentBaseMutation builder.
  1876. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1877. m.predicates = append(m.predicates, ps...)
  1878. }
  1879. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1880. // users can use type-assertion to append predicates that do not depend on any generated package.
  1881. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1882. p := make([]predicate.AgentBase, len(ps))
  1883. for i := range ps {
  1884. p[i] = ps[i]
  1885. }
  1886. m.Where(p...)
  1887. }
  1888. // Op returns the operation name.
  1889. func (m *AgentBaseMutation) Op() Op {
  1890. return m.op
  1891. }
  1892. // SetOp allows setting the mutation operation.
  1893. func (m *AgentBaseMutation) SetOp(op Op) {
  1894. m.op = op
  1895. }
  1896. // Type returns the node type of this mutation (AgentBase).
  1897. func (m *AgentBaseMutation) Type() string {
  1898. return m.typ
  1899. }
  1900. // Fields returns all fields that were changed during this mutation. Note that in
  1901. // order to get all numeric fields that were incremented/decremented, call
  1902. // AddedFields().
  1903. func (m *AgentBaseMutation) Fields() []string {
  1904. fields := make([]string, 0, 9)
  1905. if m.q != nil {
  1906. fields = append(fields, agentbase.FieldQ)
  1907. }
  1908. if m.a != nil {
  1909. fields = append(fields, agentbase.FieldA)
  1910. }
  1911. if m.chunk_index != nil {
  1912. fields = append(fields, agentbase.FieldChunkIndex)
  1913. }
  1914. if m.indexes != nil {
  1915. fields = append(fields, agentbase.FieldIndexes)
  1916. }
  1917. if m.dataset_id != nil {
  1918. fields = append(fields, agentbase.FieldDatasetID)
  1919. }
  1920. if m.collection_id != nil {
  1921. fields = append(fields, agentbase.FieldCollectionID)
  1922. }
  1923. if m.source_name != nil {
  1924. fields = append(fields, agentbase.FieldSourceName)
  1925. }
  1926. if m.can_write != nil {
  1927. fields = append(fields, agentbase.FieldCanWrite)
  1928. }
  1929. if m.is_owner != nil {
  1930. fields = append(fields, agentbase.FieldIsOwner)
  1931. }
  1932. return fields
  1933. }
  1934. // Field returns the value of a field with the given name. The second boolean
  1935. // return value indicates that this field was not set, or was not defined in the
  1936. // schema.
  1937. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1938. switch name {
  1939. case agentbase.FieldQ:
  1940. return m.Q()
  1941. case agentbase.FieldA:
  1942. return m.A()
  1943. case agentbase.FieldChunkIndex:
  1944. return m.ChunkIndex()
  1945. case agentbase.FieldIndexes:
  1946. return m.Indexes()
  1947. case agentbase.FieldDatasetID:
  1948. return m.DatasetID()
  1949. case agentbase.FieldCollectionID:
  1950. return m.CollectionID()
  1951. case agentbase.FieldSourceName:
  1952. return m.SourceName()
  1953. case agentbase.FieldCanWrite:
  1954. return m.CanWrite()
  1955. case agentbase.FieldIsOwner:
  1956. return m.IsOwner()
  1957. }
  1958. return nil, false
  1959. }
  1960. // OldField returns the old value of the field from the database. An error is
  1961. // returned if the mutation operation is not UpdateOne, or the query to the
  1962. // database failed.
  1963. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1964. switch name {
  1965. case agentbase.FieldQ:
  1966. return m.OldQ(ctx)
  1967. case agentbase.FieldA:
  1968. return m.OldA(ctx)
  1969. case agentbase.FieldChunkIndex:
  1970. return m.OldChunkIndex(ctx)
  1971. case agentbase.FieldIndexes:
  1972. return m.OldIndexes(ctx)
  1973. case agentbase.FieldDatasetID:
  1974. return m.OldDatasetID(ctx)
  1975. case agentbase.FieldCollectionID:
  1976. return m.OldCollectionID(ctx)
  1977. case agentbase.FieldSourceName:
  1978. return m.OldSourceName(ctx)
  1979. case agentbase.FieldCanWrite:
  1980. return m.OldCanWrite(ctx)
  1981. case agentbase.FieldIsOwner:
  1982. return m.OldIsOwner(ctx)
  1983. }
  1984. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1985. }
  1986. // SetField sets the value of a field with the given name. It returns an error if
  1987. // the field is not defined in the schema, or if the type mismatched the field
  1988. // type.
  1989. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1990. switch name {
  1991. case agentbase.FieldQ:
  1992. v, ok := value.(string)
  1993. if !ok {
  1994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1995. }
  1996. m.SetQ(v)
  1997. return nil
  1998. case agentbase.FieldA:
  1999. v, ok := value.(string)
  2000. if !ok {
  2001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2002. }
  2003. m.SetA(v)
  2004. return nil
  2005. case agentbase.FieldChunkIndex:
  2006. v, ok := value.(uint64)
  2007. if !ok {
  2008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2009. }
  2010. m.SetChunkIndex(v)
  2011. return nil
  2012. case agentbase.FieldIndexes:
  2013. v, ok := value.([]string)
  2014. if !ok {
  2015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2016. }
  2017. m.SetIndexes(v)
  2018. return nil
  2019. case agentbase.FieldDatasetID:
  2020. v, ok := value.(string)
  2021. if !ok {
  2022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2023. }
  2024. m.SetDatasetID(v)
  2025. return nil
  2026. case agentbase.FieldCollectionID:
  2027. v, ok := value.(string)
  2028. if !ok {
  2029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2030. }
  2031. m.SetCollectionID(v)
  2032. return nil
  2033. case agentbase.FieldSourceName:
  2034. v, ok := value.(string)
  2035. if !ok {
  2036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2037. }
  2038. m.SetSourceName(v)
  2039. return nil
  2040. case agentbase.FieldCanWrite:
  2041. v, ok := value.([]bool)
  2042. if !ok {
  2043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2044. }
  2045. m.SetCanWrite(v)
  2046. return nil
  2047. case agentbase.FieldIsOwner:
  2048. v, ok := value.([]bool)
  2049. if !ok {
  2050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2051. }
  2052. m.SetIsOwner(v)
  2053. return nil
  2054. }
  2055. return fmt.Errorf("unknown AgentBase field %s", name)
  2056. }
  2057. // AddedFields returns all numeric fields that were incremented/decremented during
  2058. // this mutation.
  2059. func (m *AgentBaseMutation) AddedFields() []string {
  2060. var fields []string
  2061. if m.addchunk_index != nil {
  2062. fields = append(fields, agentbase.FieldChunkIndex)
  2063. }
  2064. return fields
  2065. }
  2066. // AddedField returns the numeric value that was incremented/decremented on a field
  2067. // with the given name. The second boolean return value indicates that this field
  2068. // was not set, or was not defined in the schema.
  2069. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2070. switch name {
  2071. case agentbase.FieldChunkIndex:
  2072. return m.AddedChunkIndex()
  2073. }
  2074. return nil, false
  2075. }
  2076. // AddField adds the value to the field with the given name. It returns an error if
  2077. // the field is not defined in the schema, or if the type mismatched the field
  2078. // type.
  2079. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2080. switch name {
  2081. case agentbase.FieldChunkIndex:
  2082. v, ok := value.(int64)
  2083. if !ok {
  2084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2085. }
  2086. m.AddChunkIndex(v)
  2087. return nil
  2088. }
  2089. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2090. }
  2091. // ClearedFields returns all nullable fields that were cleared during this
  2092. // mutation.
  2093. func (m *AgentBaseMutation) ClearedFields() []string {
  2094. var fields []string
  2095. if m.FieldCleared(agentbase.FieldQ) {
  2096. fields = append(fields, agentbase.FieldQ)
  2097. }
  2098. if m.FieldCleared(agentbase.FieldA) {
  2099. fields = append(fields, agentbase.FieldA)
  2100. }
  2101. if m.FieldCleared(agentbase.FieldIndexes) {
  2102. fields = append(fields, agentbase.FieldIndexes)
  2103. }
  2104. if m.FieldCleared(agentbase.FieldDatasetID) {
  2105. fields = append(fields, agentbase.FieldDatasetID)
  2106. }
  2107. if m.FieldCleared(agentbase.FieldCollectionID) {
  2108. fields = append(fields, agentbase.FieldCollectionID)
  2109. }
  2110. if m.FieldCleared(agentbase.FieldSourceName) {
  2111. fields = append(fields, agentbase.FieldSourceName)
  2112. }
  2113. if m.FieldCleared(agentbase.FieldCanWrite) {
  2114. fields = append(fields, agentbase.FieldCanWrite)
  2115. }
  2116. if m.FieldCleared(agentbase.FieldIsOwner) {
  2117. fields = append(fields, agentbase.FieldIsOwner)
  2118. }
  2119. return fields
  2120. }
  2121. // FieldCleared returns a boolean indicating if a field with the given name was
  2122. // cleared in this mutation.
  2123. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2124. _, ok := m.clearedFields[name]
  2125. return ok
  2126. }
  2127. // ClearField clears the value of the field with the given name. It returns an
  2128. // error if the field is not defined in the schema.
  2129. func (m *AgentBaseMutation) ClearField(name string) error {
  2130. switch name {
  2131. case agentbase.FieldQ:
  2132. m.ClearQ()
  2133. return nil
  2134. case agentbase.FieldA:
  2135. m.ClearA()
  2136. return nil
  2137. case agentbase.FieldIndexes:
  2138. m.ClearIndexes()
  2139. return nil
  2140. case agentbase.FieldDatasetID:
  2141. m.ClearDatasetID()
  2142. return nil
  2143. case agentbase.FieldCollectionID:
  2144. m.ClearCollectionID()
  2145. return nil
  2146. case agentbase.FieldSourceName:
  2147. m.ClearSourceName()
  2148. return nil
  2149. case agentbase.FieldCanWrite:
  2150. m.ClearCanWrite()
  2151. return nil
  2152. case agentbase.FieldIsOwner:
  2153. m.ClearIsOwner()
  2154. return nil
  2155. }
  2156. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2157. }
  2158. // ResetField resets all changes in the mutation for the field with the given name.
  2159. // It returns an error if the field is not defined in the schema.
  2160. func (m *AgentBaseMutation) ResetField(name string) error {
  2161. switch name {
  2162. case agentbase.FieldQ:
  2163. m.ResetQ()
  2164. return nil
  2165. case agentbase.FieldA:
  2166. m.ResetA()
  2167. return nil
  2168. case agentbase.FieldChunkIndex:
  2169. m.ResetChunkIndex()
  2170. return nil
  2171. case agentbase.FieldIndexes:
  2172. m.ResetIndexes()
  2173. return nil
  2174. case agentbase.FieldDatasetID:
  2175. m.ResetDatasetID()
  2176. return nil
  2177. case agentbase.FieldCollectionID:
  2178. m.ResetCollectionID()
  2179. return nil
  2180. case agentbase.FieldSourceName:
  2181. m.ResetSourceName()
  2182. return nil
  2183. case agentbase.FieldCanWrite:
  2184. m.ResetCanWrite()
  2185. return nil
  2186. case agentbase.FieldIsOwner:
  2187. m.ResetIsOwner()
  2188. return nil
  2189. }
  2190. return fmt.Errorf("unknown AgentBase field %s", name)
  2191. }
  2192. // AddedEdges returns all edge names that were set/added in this mutation.
  2193. func (m *AgentBaseMutation) AddedEdges() []string {
  2194. edges := make([]string, 0, 1)
  2195. if m.wx_agent != nil {
  2196. edges = append(edges, agentbase.EdgeWxAgent)
  2197. }
  2198. return edges
  2199. }
  2200. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2201. // name in this mutation.
  2202. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2203. switch name {
  2204. case agentbase.EdgeWxAgent:
  2205. ids := make([]ent.Value, 0, len(m.wx_agent))
  2206. for id := range m.wx_agent {
  2207. ids = append(ids, id)
  2208. }
  2209. return ids
  2210. }
  2211. return nil
  2212. }
  2213. // RemovedEdges returns all edge names that were removed in this mutation.
  2214. func (m *AgentBaseMutation) RemovedEdges() []string {
  2215. edges := make([]string, 0, 1)
  2216. if m.removedwx_agent != nil {
  2217. edges = append(edges, agentbase.EdgeWxAgent)
  2218. }
  2219. return edges
  2220. }
  2221. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2222. // the given name in this mutation.
  2223. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2224. switch name {
  2225. case agentbase.EdgeWxAgent:
  2226. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2227. for id := range m.removedwx_agent {
  2228. ids = append(ids, id)
  2229. }
  2230. return ids
  2231. }
  2232. return nil
  2233. }
  2234. // ClearedEdges returns all edge names that were cleared in this mutation.
  2235. func (m *AgentBaseMutation) ClearedEdges() []string {
  2236. edges := make([]string, 0, 1)
  2237. if m.clearedwx_agent {
  2238. edges = append(edges, agentbase.EdgeWxAgent)
  2239. }
  2240. return edges
  2241. }
  2242. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2243. // was cleared in this mutation.
  2244. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2245. switch name {
  2246. case agentbase.EdgeWxAgent:
  2247. return m.clearedwx_agent
  2248. }
  2249. return false
  2250. }
  2251. // ClearEdge clears the value of the edge with the given name. It returns an error
  2252. // if that edge is not defined in the schema.
  2253. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2254. switch name {
  2255. }
  2256. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2257. }
  2258. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2259. // It returns an error if the edge is not defined in the schema.
  2260. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2261. switch name {
  2262. case agentbase.EdgeWxAgent:
  2263. m.ResetWxAgent()
  2264. return nil
  2265. }
  2266. return fmt.Errorf("unknown AgentBase edge %s", name)
  2267. }
  2268. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2269. type AliyunAvatarMutation struct {
  2270. config
  2271. op Op
  2272. typ string
  2273. id *uint64
  2274. created_at *time.Time
  2275. updated_at *time.Time
  2276. deleted_at *time.Time
  2277. user_id *uint64
  2278. adduser_id *int64
  2279. biz_id *string
  2280. access_key_id *string
  2281. access_key_secret *string
  2282. app_id *string
  2283. tenant_id *uint64
  2284. addtenant_id *int64
  2285. response *string
  2286. token *string
  2287. session_id *string
  2288. clearedFields map[string]struct{}
  2289. done bool
  2290. oldValue func(context.Context) (*AliyunAvatar, error)
  2291. predicates []predicate.AliyunAvatar
  2292. }
  2293. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2294. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2295. type aliyunavatarOption func(*AliyunAvatarMutation)
  2296. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2297. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2298. m := &AliyunAvatarMutation{
  2299. config: c,
  2300. op: op,
  2301. typ: TypeAliyunAvatar,
  2302. clearedFields: make(map[string]struct{}),
  2303. }
  2304. for _, opt := range opts {
  2305. opt(m)
  2306. }
  2307. return m
  2308. }
  2309. // withAliyunAvatarID sets the ID field of the mutation.
  2310. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2311. return func(m *AliyunAvatarMutation) {
  2312. var (
  2313. err error
  2314. once sync.Once
  2315. value *AliyunAvatar
  2316. )
  2317. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2318. once.Do(func() {
  2319. if m.done {
  2320. err = errors.New("querying old values post mutation is not allowed")
  2321. } else {
  2322. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2323. }
  2324. })
  2325. return value, err
  2326. }
  2327. m.id = &id
  2328. }
  2329. }
  2330. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2331. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2332. return func(m *AliyunAvatarMutation) {
  2333. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2334. return node, nil
  2335. }
  2336. m.id = &node.ID
  2337. }
  2338. }
  2339. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2340. // executed in a transaction (ent.Tx), a transactional client is returned.
  2341. func (m AliyunAvatarMutation) Client() *Client {
  2342. client := &Client{config: m.config}
  2343. client.init()
  2344. return client
  2345. }
  2346. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2347. // it returns an error otherwise.
  2348. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2349. if _, ok := m.driver.(*txDriver); !ok {
  2350. return nil, errors.New("ent: mutation is not running in a transaction")
  2351. }
  2352. tx := &Tx{config: m.config}
  2353. tx.init()
  2354. return tx, nil
  2355. }
  2356. // SetID sets the value of the id field. Note that this
  2357. // operation is only accepted on creation of AliyunAvatar entities.
  2358. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2359. m.id = &id
  2360. }
  2361. // ID returns the ID value in the mutation. Note that the ID is only available
  2362. // if it was provided to the builder or after it was returned from the database.
  2363. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2364. if m.id == nil {
  2365. return
  2366. }
  2367. return *m.id, true
  2368. }
  2369. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2370. // That means, if the mutation is applied within a transaction with an isolation level such
  2371. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2372. // or updated by the mutation.
  2373. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2374. switch {
  2375. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2376. id, exists := m.ID()
  2377. if exists {
  2378. return []uint64{id}, nil
  2379. }
  2380. fallthrough
  2381. case m.op.Is(OpUpdate | OpDelete):
  2382. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2383. default:
  2384. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2385. }
  2386. }
  2387. // SetCreatedAt sets the "created_at" field.
  2388. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2389. m.created_at = &t
  2390. }
  2391. // CreatedAt returns the value of the "created_at" field in the mutation.
  2392. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2393. v := m.created_at
  2394. if v == nil {
  2395. return
  2396. }
  2397. return *v, true
  2398. }
  2399. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2400. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2402. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2403. if !m.op.Is(OpUpdateOne) {
  2404. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2405. }
  2406. if m.id == nil || m.oldValue == nil {
  2407. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2408. }
  2409. oldValue, err := m.oldValue(ctx)
  2410. if err != nil {
  2411. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2412. }
  2413. return oldValue.CreatedAt, nil
  2414. }
  2415. // ResetCreatedAt resets all changes to the "created_at" field.
  2416. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2417. m.created_at = nil
  2418. }
  2419. // SetUpdatedAt sets the "updated_at" field.
  2420. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2421. m.updated_at = &t
  2422. }
  2423. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2424. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2425. v := m.updated_at
  2426. if v == nil {
  2427. return
  2428. }
  2429. return *v, true
  2430. }
  2431. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2432. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2434. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2435. if !m.op.Is(OpUpdateOne) {
  2436. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2437. }
  2438. if m.id == nil || m.oldValue == nil {
  2439. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2440. }
  2441. oldValue, err := m.oldValue(ctx)
  2442. if err != nil {
  2443. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2444. }
  2445. return oldValue.UpdatedAt, nil
  2446. }
  2447. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2448. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2449. m.updated_at = nil
  2450. }
  2451. // SetDeletedAt sets the "deleted_at" field.
  2452. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2453. m.deleted_at = &t
  2454. }
  2455. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2456. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2457. v := m.deleted_at
  2458. if v == nil {
  2459. return
  2460. }
  2461. return *v, true
  2462. }
  2463. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2464. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2466. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2467. if !m.op.Is(OpUpdateOne) {
  2468. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2469. }
  2470. if m.id == nil || m.oldValue == nil {
  2471. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2472. }
  2473. oldValue, err := m.oldValue(ctx)
  2474. if err != nil {
  2475. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2476. }
  2477. return oldValue.DeletedAt, nil
  2478. }
  2479. // ClearDeletedAt clears the value of the "deleted_at" field.
  2480. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2481. m.deleted_at = nil
  2482. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2483. }
  2484. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2485. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2486. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2487. return ok
  2488. }
  2489. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2490. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2491. m.deleted_at = nil
  2492. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2493. }
  2494. // SetUserID sets the "user_id" field.
  2495. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2496. m.user_id = &u
  2497. m.adduser_id = nil
  2498. }
  2499. // UserID returns the value of the "user_id" field in the mutation.
  2500. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2501. v := m.user_id
  2502. if v == nil {
  2503. return
  2504. }
  2505. return *v, true
  2506. }
  2507. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2508. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2510. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2511. if !m.op.Is(OpUpdateOne) {
  2512. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2513. }
  2514. if m.id == nil || m.oldValue == nil {
  2515. return v, errors.New("OldUserID requires an ID field in the mutation")
  2516. }
  2517. oldValue, err := m.oldValue(ctx)
  2518. if err != nil {
  2519. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2520. }
  2521. return oldValue.UserID, nil
  2522. }
  2523. // AddUserID adds u to the "user_id" field.
  2524. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2525. if m.adduser_id != nil {
  2526. *m.adduser_id += u
  2527. } else {
  2528. m.adduser_id = &u
  2529. }
  2530. }
  2531. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2532. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2533. v := m.adduser_id
  2534. if v == nil {
  2535. return
  2536. }
  2537. return *v, true
  2538. }
  2539. // ResetUserID resets all changes to the "user_id" field.
  2540. func (m *AliyunAvatarMutation) ResetUserID() {
  2541. m.user_id = nil
  2542. m.adduser_id = nil
  2543. }
  2544. // SetBizID sets the "biz_id" field.
  2545. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2546. m.biz_id = &s
  2547. }
  2548. // BizID returns the value of the "biz_id" field in the mutation.
  2549. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2550. v := m.biz_id
  2551. if v == nil {
  2552. return
  2553. }
  2554. return *v, true
  2555. }
  2556. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2557. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2559. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2560. if !m.op.Is(OpUpdateOne) {
  2561. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2562. }
  2563. if m.id == nil || m.oldValue == nil {
  2564. return v, errors.New("OldBizID requires an ID field in the mutation")
  2565. }
  2566. oldValue, err := m.oldValue(ctx)
  2567. if err != nil {
  2568. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2569. }
  2570. return oldValue.BizID, nil
  2571. }
  2572. // ResetBizID resets all changes to the "biz_id" field.
  2573. func (m *AliyunAvatarMutation) ResetBizID() {
  2574. m.biz_id = nil
  2575. }
  2576. // SetAccessKeyID sets the "access_key_id" field.
  2577. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2578. m.access_key_id = &s
  2579. }
  2580. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2581. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2582. v := m.access_key_id
  2583. if v == nil {
  2584. return
  2585. }
  2586. return *v, true
  2587. }
  2588. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2589. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2591. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2592. if !m.op.Is(OpUpdateOne) {
  2593. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2594. }
  2595. if m.id == nil || m.oldValue == nil {
  2596. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2597. }
  2598. oldValue, err := m.oldValue(ctx)
  2599. if err != nil {
  2600. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2601. }
  2602. return oldValue.AccessKeyID, nil
  2603. }
  2604. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2605. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2606. m.access_key_id = nil
  2607. }
  2608. // SetAccessKeySecret sets the "access_key_secret" field.
  2609. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2610. m.access_key_secret = &s
  2611. }
  2612. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2613. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2614. v := m.access_key_secret
  2615. if v == nil {
  2616. return
  2617. }
  2618. return *v, true
  2619. }
  2620. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2621. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2623. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2624. if !m.op.Is(OpUpdateOne) {
  2625. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2626. }
  2627. if m.id == nil || m.oldValue == nil {
  2628. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2629. }
  2630. oldValue, err := m.oldValue(ctx)
  2631. if err != nil {
  2632. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2633. }
  2634. return oldValue.AccessKeySecret, nil
  2635. }
  2636. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2637. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2638. m.access_key_secret = nil
  2639. }
  2640. // SetAppID sets the "app_id" field.
  2641. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2642. m.app_id = &s
  2643. }
  2644. // AppID returns the value of the "app_id" field in the mutation.
  2645. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2646. v := m.app_id
  2647. if v == nil {
  2648. return
  2649. }
  2650. return *v, true
  2651. }
  2652. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2653. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2655. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2656. if !m.op.Is(OpUpdateOne) {
  2657. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2658. }
  2659. if m.id == nil || m.oldValue == nil {
  2660. return v, errors.New("OldAppID requires an ID field in the mutation")
  2661. }
  2662. oldValue, err := m.oldValue(ctx)
  2663. if err != nil {
  2664. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2665. }
  2666. return oldValue.AppID, nil
  2667. }
  2668. // ClearAppID clears the value of the "app_id" field.
  2669. func (m *AliyunAvatarMutation) ClearAppID() {
  2670. m.app_id = nil
  2671. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2672. }
  2673. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2674. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2675. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2676. return ok
  2677. }
  2678. // ResetAppID resets all changes to the "app_id" field.
  2679. func (m *AliyunAvatarMutation) ResetAppID() {
  2680. m.app_id = nil
  2681. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2682. }
  2683. // SetTenantID sets the "tenant_id" field.
  2684. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2685. m.tenant_id = &u
  2686. m.addtenant_id = nil
  2687. }
  2688. // TenantID returns the value of the "tenant_id" field in the mutation.
  2689. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2690. v := m.tenant_id
  2691. if v == nil {
  2692. return
  2693. }
  2694. return *v, true
  2695. }
  2696. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2697. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2699. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2700. if !m.op.Is(OpUpdateOne) {
  2701. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2702. }
  2703. if m.id == nil || m.oldValue == nil {
  2704. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2705. }
  2706. oldValue, err := m.oldValue(ctx)
  2707. if err != nil {
  2708. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2709. }
  2710. return oldValue.TenantID, nil
  2711. }
  2712. // AddTenantID adds u to the "tenant_id" field.
  2713. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2714. if m.addtenant_id != nil {
  2715. *m.addtenant_id += u
  2716. } else {
  2717. m.addtenant_id = &u
  2718. }
  2719. }
  2720. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2721. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2722. v := m.addtenant_id
  2723. if v == nil {
  2724. return
  2725. }
  2726. return *v, true
  2727. }
  2728. // ResetTenantID resets all changes to the "tenant_id" field.
  2729. func (m *AliyunAvatarMutation) ResetTenantID() {
  2730. m.tenant_id = nil
  2731. m.addtenant_id = nil
  2732. }
  2733. // SetResponse sets the "response" field.
  2734. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2735. m.response = &s
  2736. }
  2737. // Response returns the value of the "response" field in the mutation.
  2738. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2739. v := m.response
  2740. if v == nil {
  2741. return
  2742. }
  2743. return *v, true
  2744. }
  2745. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2746. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2748. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2749. if !m.op.Is(OpUpdateOne) {
  2750. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2751. }
  2752. if m.id == nil || m.oldValue == nil {
  2753. return v, errors.New("OldResponse requires an ID field in the mutation")
  2754. }
  2755. oldValue, err := m.oldValue(ctx)
  2756. if err != nil {
  2757. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2758. }
  2759. return oldValue.Response, nil
  2760. }
  2761. // ResetResponse resets all changes to the "response" field.
  2762. func (m *AliyunAvatarMutation) ResetResponse() {
  2763. m.response = nil
  2764. }
  2765. // SetToken sets the "token" field.
  2766. func (m *AliyunAvatarMutation) SetToken(s string) {
  2767. m.token = &s
  2768. }
  2769. // Token returns the value of the "token" field in the mutation.
  2770. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2771. v := m.token
  2772. if v == nil {
  2773. return
  2774. }
  2775. return *v, true
  2776. }
  2777. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2778. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2780. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2781. if !m.op.Is(OpUpdateOne) {
  2782. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2783. }
  2784. if m.id == nil || m.oldValue == nil {
  2785. return v, errors.New("OldToken requires an ID field in the mutation")
  2786. }
  2787. oldValue, err := m.oldValue(ctx)
  2788. if err != nil {
  2789. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2790. }
  2791. return oldValue.Token, nil
  2792. }
  2793. // ResetToken resets all changes to the "token" field.
  2794. func (m *AliyunAvatarMutation) ResetToken() {
  2795. m.token = nil
  2796. }
  2797. // SetSessionID sets the "session_id" field.
  2798. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2799. m.session_id = &s
  2800. }
  2801. // SessionID returns the value of the "session_id" field in the mutation.
  2802. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2803. v := m.session_id
  2804. if v == nil {
  2805. return
  2806. }
  2807. return *v, true
  2808. }
  2809. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2810. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2812. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2813. if !m.op.Is(OpUpdateOne) {
  2814. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2815. }
  2816. if m.id == nil || m.oldValue == nil {
  2817. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2818. }
  2819. oldValue, err := m.oldValue(ctx)
  2820. if err != nil {
  2821. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2822. }
  2823. return oldValue.SessionID, nil
  2824. }
  2825. // ResetSessionID resets all changes to the "session_id" field.
  2826. func (m *AliyunAvatarMutation) ResetSessionID() {
  2827. m.session_id = nil
  2828. }
  2829. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2830. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2831. m.predicates = append(m.predicates, ps...)
  2832. }
  2833. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2834. // users can use type-assertion to append predicates that do not depend on any generated package.
  2835. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2836. p := make([]predicate.AliyunAvatar, len(ps))
  2837. for i := range ps {
  2838. p[i] = ps[i]
  2839. }
  2840. m.Where(p...)
  2841. }
  2842. // Op returns the operation name.
  2843. func (m *AliyunAvatarMutation) Op() Op {
  2844. return m.op
  2845. }
  2846. // SetOp allows setting the mutation operation.
  2847. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2848. m.op = op
  2849. }
  2850. // Type returns the node type of this mutation (AliyunAvatar).
  2851. func (m *AliyunAvatarMutation) Type() string {
  2852. return m.typ
  2853. }
  2854. // Fields returns all fields that were changed during this mutation. Note that in
  2855. // order to get all numeric fields that were incremented/decremented, call
  2856. // AddedFields().
  2857. func (m *AliyunAvatarMutation) Fields() []string {
  2858. fields := make([]string, 0, 12)
  2859. if m.created_at != nil {
  2860. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2861. }
  2862. if m.updated_at != nil {
  2863. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2864. }
  2865. if m.deleted_at != nil {
  2866. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2867. }
  2868. if m.user_id != nil {
  2869. fields = append(fields, aliyunavatar.FieldUserID)
  2870. }
  2871. if m.biz_id != nil {
  2872. fields = append(fields, aliyunavatar.FieldBizID)
  2873. }
  2874. if m.access_key_id != nil {
  2875. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2876. }
  2877. if m.access_key_secret != nil {
  2878. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2879. }
  2880. if m.app_id != nil {
  2881. fields = append(fields, aliyunavatar.FieldAppID)
  2882. }
  2883. if m.tenant_id != nil {
  2884. fields = append(fields, aliyunavatar.FieldTenantID)
  2885. }
  2886. if m.response != nil {
  2887. fields = append(fields, aliyunavatar.FieldResponse)
  2888. }
  2889. if m.token != nil {
  2890. fields = append(fields, aliyunavatar.FieldToken)
  2891. }
  2892. if m.session_id != nil {
  2893. fields = append(fields, aliyunavatar.FieldSessionID)
  2894. }
  2895. return fields
  2896. }
  2897. // Field returns the value of a field with the given name. The second boolean
  2898. // return value indicates that this field was not set, or was not defined in the
  2899. // schema.
  2900. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2901. switch name {
  2902. case aliyunavatar.FieldCreatedAt:
  2903. return m.CreatedAt()
  2904. case aliyunavatar.FieldUpdatedAt:
  2905. return m.UpdatedAt()
  2906. case aliyunavatar.FieldDeletedAt:
  2907. return m.DeletedAt()
  2908. case aliyunavatar.FieldUserID:
  2909. return m.UserID()
  2910. case aliyunavatar.FieldBizID:
  2911. return m.BizID()
  2912. case aliyunavatar.FieldAccessKeyID:
  2913. return m.AccessKeyID()
  2914. case aliyunavatar.FieldAccessKeySecret:
  2915. return m.AccessKeySecret()
  2916. case aliyunavatar.FieldAppID:
  2917. return m.AppID()
  2918. case aliyunavatar.FieldTenantID:
  2919. return m.TenantID()
  2920. case aliyunavatar.FieldResponse:
  2921. return m.Response()
  2922. case aliyunavatar.FieldToken:
  2923. return m.Token()
  2924. case aliyunavatar.FieldSessionID:
  2925. return m.SessionID()
  2926. }
  2927. return nil, false
  2928. }
  2929. // OldField returns the old value of the field from the database. An error is
  2930. // returned if the mutation operation is not UpdateOne, or the query to the
  2931. // database failed.
  2932. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2933. switch name {
  2934. case aliyunavatar.FieldCreatedAt:
  2935. return m.OldCreatedAt(ctx)
  2936. case aliyunavatar.FieldUpdatedAt:
  2937. return m.OldUpdatedAt(ctx)
  2938. case aliyunavatar.FieldDeletedAt:
  2939. return m.OldDeletedAt(ctx)
  2940. case aliyunavatar.FieldUserID:
  2941. return m.OldUserID(ctx)
  2942. case aliyunavatar.FieldBizID:
  2943. return m.OldBizID(ctx)
  2944. case aliyunavatar.FieldAccessKeyID:
  2945. return m.OldAccessKeyID(ctx)
  2946. case aliyunavatar.FieldAccessKeySecret:
  2947. return m.OldAccessKeySecret(ctx)
  2948. case aliyunavatar.FieldAppID:
  2949. return m.OldAppID(ctx)
  2950. case aliyunavatar.FieldTenantID:
  2951. return m.OldTenantID(ctx)
  2952. case aliyunavatar.FieldResponse:
  2953. return m.OldResponse(ctx)
  2954. case aliyunavatar.FieldToken:
  2955. return m.OldToken(ctx)
  2956. case aliyunavatar.FieldSessionID:
  2957. return m.OldSessionID(ctx)
  2958. }
  2959. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2960. }
  2961. // SetField sets the value of a field with the given name. It returns an error if
  2962. // the field is not defined in the schema, or if the type mismatched the field
  2963. // type.
  2964. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2965. switch name {
  2966. case aliyunavatar.FieldCreatedAt:
  2967. v, ok := value.(time.Time)
  2968. if !ok {
  2969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2970. }
  2971. m.SetCreatedAt(v)
  2972. return nil
  2973. case aliyunavatar.FieldUpdatedAt:
  2974. v, ok := value.(time.Time)
  2975. if !ok {
  2976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2977. }
  2978. m.SetUpdatedAt(v)
  2979. return nil
  2980. case aliyunavatar.FieldDeletedAt:
  2981. v, ok := value.(time.Time)
  2982. if !ok {
  2983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2984. }
  2985. m.SetDeletedAt(v)
  2986. return nil
  2987. case aliyunavatar.FieldUserID:
  2988. v, ok := value.(uint64)
  2989. if !ok {
  2990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2991. }
  2992. m.SetUserID(v)
  2993. return nil
  2994. case aliyunavatar.FieldBizID:
  2995. v, ok := value.(string)
  2996. if !ok {
  2997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2998. }
  2999. m.SetBizID(v)
  3000. return nil
  3001. case aliyunavatar.FieldAccessKeyID:
  3002. v, ok := value.(string)
  3003. if !ok {
  3004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3005. }
  3006. m.SetAccessKeyID(v)
  3007. return nil
  3008. case aliyunavatar.FieldAccessKeySecret:
  3009. v, ok := value.(string)
  3010. if !ok {
  3011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3012. }
  3013. m.SetAccessKeySecret(v)
  3014. return nil
  3015. case aliyunavatar.FieldAppID:
  3016. v, ok := value.(string)
  3017. if !ok {
  3018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3019. }
  3020. m.SetAppID(v)
  3021. return nil
  3022. case aliyunavatar.FieldTenantID:
  3023. v, ok := value.(uint64)
  3024. if !ok {
  3025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3026. }
  3027. m.SetTenantID(v)
  3028. return nil
  3029. case aliyunavatar.FieldResponse:
  3030. v, ok := value.(string)
  3031. if !ok {
  3032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3033. }
  3034. m.SetResponse(v)
  3035. return nil
  3036. case aliyunavatar.FieldToken:
  3037. v, ok := value.(string)
  3038. if !ok {
  3039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3040. }
  3041. m.SetToken(v)
  3042. return nil
  3043. case aliyunavatar.FieldSessionID:
  3044. v, ok := value.(string)
  3045. if !ok {
  3046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3047. }
  3048. m.SetSessionID(v)
  3049. return nil
  3050. }
  3051. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3052. }
  3053. // AddedFields returns all numeric fields that were incremented/decremented during
  3054. // this mutation.
  3055. func (m *AliyunAvatarMutation) AddedFields() []string {
  3056. var fields []string
  3057. if m.adduser_id != nil {
  3058. fields = append(fields, aliyunavatar.FieldUserID)
  3059. }
  3060. if m.addtenant_id != nil {
  3061. fields = append(fields, aliyunavatar.FieldTenantID)
  3062. }
  3063. return fields
  3064. }
  3065. // AddedField returns the numeric value that was incremented/decremented on a field
  3066. // with the given name. The second boolean return value indicates that this field
  3067. // was not set, or was not defined in the schema.
  3068. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3069. switch name {
  3070. case aliyunavatar.FieldUserID:
  3071. return m.AddedUserID()
  3072. case aliyunavatar.FieldTenantID:
  3073. return m.AddedTenantID()
  3074. }
  3075. return nil, false
  3076. }
  3077. // AddField adds the value to the field with the given name. It returns an error if
  3078. // the field is not defined in the schema, or if the type mismatched the field
  3079. // type.
  3080. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3081. switch name {
  3082. case aliyunavatar.FieldUserID:
  3083. v, ok := value.(int64)
  3084. if !ok {
  3085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3086. }
  3087. m.AddUserID(v)
  3088. return nil
  3089. case aliyunavatar.FieldTenantID:
  3090. v, ok := value.(int64)
  3091. if !ok {
  3092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3093. }
  3094. m.AddTenantID(v)
  3095. return nil
  3096. }
  3097. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3098. }
  3099. // ClearedFields returns all nullable fields that were cleared during this
  3100. // mutation.
  3101. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3102. var fields []string
  3103. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3104. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3105. }
  3106. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3107. fields = append(fields, aliyunavatar.FieldAppID)
  3108. }
  3109. return fields
  3110. }
  3111. // FieldCleared returns a boolean indicating if a field with the given name was
  3112. // cleared in this mutation.
  3113. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3114. _, ok := m.clearedFields[name]
  3115. return ok
  3116. }
  3117. // ClearField clears the value of the field with the given name. It returns an
  3118. // error if the field is not defined in the schema.
  3119. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3120. switch name {
  3121. case aliyunavatar.FieldDeletedAt:
  3122. m.ClearDeletedAt()
  3123. return nil
  3124. case aliyunavatar.FieldAppID:
  3125. m.ClearAppID()
  3126. return nil
  3127. }
  3128. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3129. }
  3130. // ResetField resets all changes in the mutation for the field with the given name.
  3131. // It returns an error if the field is not defined in the schema.
  3132. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3133. switch name {
  3134. case aliyunavatar.FieldCreatedAt:
  3135. m.ResetCreatedAt()
  3136. return nil
  3137. case aliyunavatar.FieldUpdatedAt:
  3138. m.ResetUpdatedAt()
  3139. return nil
  3140. case aliyunavatar.FieldDeletedAt:
  3141. m.ResetDeletedAt()
  3142. return nil
  3143. case aliyunavatar.FieldUserID:
  3144. m.ResetUserID()
  3145. return nil
  3146. case aliyunavatar.FieldBizID:
  3147. m.ResetBizID()
  3148. return nil
  3149. case aliyunavatar.FieldAccessKeyID:
  3150. m.ResetAccessKeyID()
  3151. return nil
  3152. case aliyunavatar.FieldAccessKeySecret:
  3153. m.ResetAccessKeySecret()
  3154. return nil
  3155. case aliyunavatar.FieldAppID:
  3156. m.ResetAppID()
  3157. return nil
  3158. case aliyunavatar.FieldTenantID:
  3159. m.ResetTenantID()
  3160. return nil
  3161. case aliyunavatar.FieldResponse:
  3162. m.ResetResponse()
  3163. return nil
  3164. case aliyunavatar.FieldToken:
  3165. m.ResetToken()
  3166. return nil
  3167. case aliyunavatar.FieldSessionID:
  3168. m.ResetSessionID()
  3169. return nil
  3170. }
  3171. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3172. }
  3173. // AddedEdges returns all edge names that were set/added in this mutation.
  3174. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3175. edges := make([]string, 0, 0)
  3176. return edges
  3177. }
  3178. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3179. // name in this mutation.
  3180. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3181. return nil
  3182. }
  3183. // RemovedEdges returns all edge names that were removed in this mutation.
  3184. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3185. edges := make([]string, 0, 0)
  3186. return edges
  3187. }
  3188. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3189. // the given name in this mutation.
  3190. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3191. return nil
  3192. }
  3193. // ClearedEdges returns all edge names that were cleared in this mutation.
  3194. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3195. edges := make([]string, 0, 0)
  3196. return edges
  3197. }
  3198. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3199. // was cleared in this mutation.
  3200. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3201. return false
  3202. }
  3203. // ClearEdge clears the value of the edge with the given name. It returns an error
  3204. // if that edge is not defined in the schema.
  3205. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3206. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3207. }
  3208. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3209. // It returns an error if the edge is not defined in the schema.
  3210. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3211. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3212. }
  3213. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3214. type AllocAgentMutation struct {
  3215. config
  3216. op Op
  3217. typ string
  3218. id *uint64
  3219. created_at *time.Time
  3220. updated_at *time.Time
  3221. deleted_at *time.Time
  3222. user_id *string
  3223. organization_id *uint64
  3224. addorganization_id *int64
  3225. agents *[]uint64
  3226. appendagents []uint64
  3227. status *int
  3228. addstatus *int
  3229. clearedFields map[string]struct{}
  3230. done bool
  3231. oldValue func(context.Context) (*AllocAgent, error)
  3232. predicates []predicate.AllocAgent
  3233. }
  3234. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3235. // allocagentOption allows management of the mutation configuration using functional options.
  3236. type allocagentOption func(*AllocAgentMutation)
  3237. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3238. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3239. m := &AllocAgentMutation{
  3240. config: c,
  3241. op: op,
  3242. typ: TypeAllocAgent,
  3243. clearedFields: make(map[string]struct{}),
  3244. }
  3245. for _, opt := range opts {
  3246. opt(m)
  3247. }
  3248. return m
  3249. }
  3250. // withAllocAgentID sets the ID field of the mutation.
  3251. func withAllocAgentID(id uint64) allocagentOption {
  3252. return func(m *AllocAgentMutation) {
  3253. var (
  3254. err error
  3255. once sync.Once
  3256. value *AllocAgent
  3257. )
  3258. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3259. once.Do(func() {
  3260. if m.done {
  3261. err = errors.New("querying old values post mutation is not allowed")
  3262. } else {
  3263. value, err = m.Client().AllocAgent.Get(ctx, id)
  3264. }
  3265. })
  3266. return value, err
  3267. }
  3268. m.id = &id
  3269. }
  3270. }
  3271. // withAllocAgent sets the old AllocAgent of the mutation.
  3272. func withAllocAgent(node *AllocAgent) allocagentOption {
  3273. return func(m *AllocAgentMutation) {
  3274. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3275. return node, nil
  3276. }
  3277. m.id = &node.ID
  3278. }
  3279. }
  3280. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3281. // executed in a transaction (ent.Tx), a transactional client is returned.
  3282. func (m AllocAgentMutation) Client() *Client {
  3283. client := &Client{config: m.config}
  3284. client.init()
  3285. return client
  3286. }
  3287. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3288. // it returns an error otherwise.
  3289. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3290. if _, ok := m.driver.(*txDriver); !ok {
  3291. return nil, errors.New("ent: mutation is not running in a transaction")
  3292. }
  3293. tx := &Tx{config: m.config}
  3294. tx.init()
  3295. return tx, nil
  3296. }
  3297. // SetID sets the value of the id field. Note that this
  3298. // operation is only accepted on creation of AllocAgent entities.
  3299. func (m *AllocAgentMutation) SetID(id uint64) {
  3300. m.id = &id
  3301. }
  3302. // ID returns the ID value in the mutation. Note that the ID is only available
  3303. // if it was provided to the builder or after it was returned from the database.
  3304. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3305. if m.id == nil {
  3306. return
  3307. }
  3308. return *m.id, true
  3309. }
  3310. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3311. // That means, if the mutation is applied within a transaction with an isolation level such
  3312. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3313. // or updated by the mutation.
  3314. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3315. switch {
  3316. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3317. id, exists := m.ID()
  3318. if exists {
  3319. return []uint64{id}, nil
  3320. }
  3321. fallthrough
  3322. case m.op.Is(OpUpdate | OpDelete):
  3323. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3324. default:
  3325. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3326. }
  3327. }
  3328. // SetCreatedAt sets the "created_at" field.
  3329. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3330. m.created_at = &t
  3331. }
  3332. // CreatedAt returns the value of the "created_at" field in the mutation.
  3333. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3334. v := m.created_at
  3335. if v == nil {
  3336. return
  3337. }
  3338. return *v, true
  3339. }
  3340. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3341. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3343. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3344. if !m.op.Is(OpUpdateOne) {
  3345. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3346. }
  3347. if m.id == nil || m.oldValue == nil {
  3348. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3349. }
  3350. oldValue, err := m.oldValue(ctx)
  3351. if err != nil {
  3352. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3353. }
  3354. return oldValue.CreatedAt, nil
  3355. }
  3356. // ResetCreatedAt resets all changes to the "created_at" field.
  3357. func (m *AllocAgentMutation) ResetCreatedAt() {
  3358. m.created_at = nil
  3359. }
  3360. // SetUpdatedAt sets the "updated_at" field.
  3361. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3362. m.updated_at = &t
  3363. }
  3364. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3365. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3366. v := m.updated_at
  3367. if v == nil {
  3368. return
  3369. }
  3370. return *v, true
  3371. }
  3372. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3373. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3375. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3376. if !m.op.Is(OpUpdateOne) {
  3377. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3378. }
  3379. if m.id == nil || m.oldValue == nil {
  3380. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3381. }
  3382. oldValue, err := m.oldValue(ctx)
  3383. if err != nil {
  3384. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3385. }
  3386. return oldValue.UpdatedAt, nil
  3387. }
  3388. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3389. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3390. m.updated_at = nil
  3391. }
  3392. // SetDeletedAt sets the "deleted_at" field.
  3393. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3394. m.deleted_at = &t
  3395. }
  3396. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3397. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3398. v := m.deleted_at
  3399. if v == nil {
  3400. return
  3401. }
  3402. return *v, true
  3403. }
  3404. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3405. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3407. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3408. if !m.op.Is(OpUpdateOne) {
  3409. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3410. }
  3411. if m.id == nil || m.oldValue == nil {
  3412. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3413. }
  3414. oldValue, err := m.oldValue(ctx)
  3415. if err != nil {
  3416. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3417. }
  3418. return oldValue.DeletedAt, nil
  3419. }
  3420. // ClearDeletedAt clears the value of the "deleted_at" field.
  3421. func (m *AllocAgentMutation) ClearDeletedAt() {
  3422. m.deleted_at = nil
  3423. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3424. }
  3425. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3426. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3427. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3428. return ok
  3429. }
  3430. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3431. func (m *AllocAgentMutation) ResetDeletedAt() {
  3432. m.deleted_at = nil
  3433. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3434. }
  3435. // SetUserID sets the "user_id" field.
  3436. func (m *AllocAgentMutation) SetUserID(s string) {
  3437. m.user_id = &s
  3438. }
  3439. // UserID returns the value of the "user_id" field in the mutation.
  3440. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3441. v := m.user_id
  3442. if v == nil {
  3443. return
  3444. }
  3445. return *v, true
  3446. }
  3447. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3448. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3450. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3451. if !m.op.Is(OpUpdateOne) {
  3452. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3453. }
  3454. if m.id == nil || m.oldValue == nil {
  3455. return v, errors.New("OldUserID requires an ID field in the mutation")
  3456. }
  3457. oldValue, err := m.oldValue(ctx)
  3458. if err != nil {
  3459. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3460. }
  3461. return oldValue.UserID, nil
  3462. }
  3463. // ClearUserID clears the value of the "user_id" field.
  3464. func (m *AllocAgentMutation) ClearUserID() {
  3465. m.user_id = nil
  3466. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3467. }
  3468. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3469. func (m *AllocAgentMutation) UserIDCleared() bool {
  3470. _, ok := m.clearedFields[allocagent.FieldUserID]
  3471. return ok
  3472. }
  3473. // ResetUserID resets all changes to the "user_id" field.
  3474. func (m *AllocAgentMutation) ResetUserID() {
  3475. m.user_id = nil
  3476. delete(m.clearedFields, allocagent.FieldUserID)
  3477. }
  3478. // SetOrganizationID sets the "organization_id" field.
  3479. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3480. m.organization_id = &u
  3481. m.addorganization_id = nil
  3482. }
  3483. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3484. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3485. v := m.organization_id
  3486. if v == nil {
  3487. return
  3488. }
  3489. return *v, true
  3490. }
  3491. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3492. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3494. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3495. if !m.op.Is(OpUpdateOne) {
  3496. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3497. }
  3498. if m.id == nil || m.oldValue == nil {
  3499. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3500. }
  3501. oldValue, err := m.oldValue(ctx)
  3502. if err != nil {
  3503. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3504. }
  3505. return oldValue.OrganizationID, nil
  3506. }
  3507. // AddOrganizationID adds u to the "organization_id" field.
  3508. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3509. if m.addorganization_id != nil {
  3510. *m.addorganization_id += u
  3511. } else {
  3512. m.addorganization_id = &u
  3513. }
  3514. }
  3515. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3516. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3517. v := m.addorganization_id
  3518. if v == nil {
  3519. return
  3520. }
  3521. return *v, true
  3522. }
  3523. // ClearOrganizationID clears the value of the "organization_id" field.
  3524. func (m *AllocAgentMutation) ClearOrganizationID() {
  3525. m.organization_id = nil
  3526. m.addorganization_id = nil
  3527. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3528. }
  3529. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3530. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3531. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3532. return ok
  3533. }
  3534. // ResetOrganizationID resets all changes to the "organization_id" field.
  3535. func (m *AllocAgentMutation) ResetOrganizationID() {
  3536. m.organization_id = nil
  3537. m.addorganization_id = nil
  3538. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3539. }
  3540. // SetAgents sets the "agents" field.
  3541. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3542. m.agents = &u
  3543. m.appendagents = nil
  3544. }
  3545. // Agents returns the value of the "agents" field in the mutation.
  3546. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3547. v := m.agents
  3548. if v == nil {
  3549. return
  3550. }
  3551. return *v, true
  3552. }
  3553. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3554. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3556. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3557. if !m.op.Is(OpUpdateOne) {
  3558. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3559. }
  3560. if m.id == nil || m.oldValue == nil {
  3561. return v, errors.New("OldAgents requires an ID field in the mutation")
  3562. }
  3563. oldValue, err := m.oldValue(ctx)
  3564. if err != nil {
  3565. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3566. }
  3567. return oldValue.Agents, nil
  3568. }
  3569. // AppendAgents adds u to the "agents" field.
  3570. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3571. m.appendagents = append(m.appendagents, u...)
  3572. }
  3573. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3574. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3575. if len(m.appendagents) == 0 {
  3576. return nil, false
  3577. }
  3578. return m.appendagents, true
  3579. }
  3580. // ResetAgents resets all changes to the "agents" field.
  3581. func (m *AllocAgentMutation) ResetAgents() {
  3582. m.agents = nil
  3583. m.appendagents = nil
  3584. }
  3585. // SetStatus sets the "status" field.
  3586. func (m *AllocAgentMutation) SetStatus(i int) {
  3587. m.status = &i
  3588. m.addstatus = nil
  3589. }
  3590. // Status returns the value of the "status" field in the mutation.
  3591. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3592. v := m.status
  3593. if v == nil {
  3594. return
  3595. }
  3596. return *v, true
  3597. }
  3598. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3599. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3601. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3602. if !m.op.Is(OpUpdateOne) {
  3603. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3604. }
  3605. if m.id == nil || m.oldValue == nil {
  3606. return v, errors.New("OldStatus requires an ID field in the mutation")
  3607. }
  3608. oldValue, err := m.oldValue(ctx)
  3609. if err != nil {
  3610. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3611. }
  3612. return oldValue.Status, nil
  3613. }
  3614. // AddStatus adds i to the "status" field.
  3615. func (m *AllocAgentMutation) AddStatus(i int) {
  3616. if m.addstatus != nil {
  3617. *m.addstatus += i
  3618. } else {
  3619. m.addstatus = &i
  3620. }
  3621. }
  3622. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3623. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3624. v := m.addstatus
  3625. if v == nil {
  3626. return
  3627. }
  3628. return *v, true
  3629. }
  3630. // ClearStatus clears the value of the "status" field.
  3631. func (m *AllocAgentMutation) ClearStatus() {
  3632. m.status = nil
  3633. m.addstatus = nil
  3634. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3635. }
  3636. // StatusCleared returns if the "status" field was cleared in this mutation.
  3637. func (m *AllocAgentMutation) StatusCleared() bool {
  3638. _, ok := m.clearedFields[allocagent.FieldStatus]
  3639. return ok
  3640. }
  3641. // ResetStatus resets all changes to the "status" field.
  3642. func (m *AllocAgentMutation) ResetStatus() {
  3643. m.status = nil
  3644. m.addstatus = nil
  3645. delete(m.clearedFields, allocagent.FieldStatus)
  3646. }
  3647. // Where appends a list predicates to the AllocAgentMutation builder.
  3648. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3649. m.predicates = append(m.predicates, ps...)
  3650. }
  3651. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3652. // users can use type-assertion to append predicates that do not depend on any generated package.
  3653. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3654. p := make([]predicate.AllocAgent, len(ps))
  3655. for i := range ps {
  3656. p[i] = ps[i]
  3657. }
  3658. m.Where(p...)
  3659. }
  3660. // Op returns the operation name.
  3661. func (m *AllocAgentMutation) Op() Op {
  3662. return m.op
  3663. }
  3664. // SetOp allows setting the mutation operation.
  3665. func (m *AllocAgentMutation) SetOp(op Op) {
  3666. m.op = op
  3667. }
  3668. // Type returns the node type of this mutation (AllocAgent).
  3669. func (m *AllocAgentMutation) Type() string {
  3670. return m.typ
  3671. }
  3672. // Fields returns all fields that were changed during this mutation. Note that in
  3673. // order to get all numeric fields that were incremented/decremented, call
  3674. // AddedFields().
  3675. func (m *AllocAgentMutation) Fields() []string {
  3676. fields := make([]string, 0, 7)
  3677. if m.created_at != nil {
  3678. fields = append(fields, allocagent.FieldCreatedAt)
  3679. }
  3680. if m.updated_at != nil {
  3681. fields = append(fields, allocagent.FieldUpdatedAt)
  3682. }
  3683. if m.deleted_at != nil {
  3684. fields = append(fields, allocagent.FieldDeletedAt)
  3685. }
  3686. if m.user_id != nil {
  3687. fields = append(fields, allocagent.FieldUserID)
  3688. }
  3689. if m.organization_id != nil {
  3690. fields = append(fields, allocagent.FieldOrganizationID)
  3691. }
  3692. if m.agents != nil {
  3693. fields = append(fields, allocagent.FieldAgents)
  3694. }
  3695. if m.status != nil {
  3696. fields = append(fields, allocagent.FieldStatus)
  3697. }
  3698. return fields
  3699. }
  3700. // Field returns the value of a field with the given name. The second boolean
  3701. // return value indicates that this field was not set, or was not defined in the
  3702. // schema.
  3703. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3704. switch name {
  3705. case allocagent.FieldCreatedAt:
  3706. return m.CreatedAt()
  3707. case allocagent.FieldUpdatedAt:
  3708. return m.UpdatedAt()
  3709. case allocagent.FieldDeletedAt:
  3710. return m.DeletedAt()
  3711. case allocagent.FieldUserID:
  3712. return m.UserID()
  3713. case allocagent.FieldOrganizationID:
  3714. return m.OrganizationID()
  3715. case allocagent.FieldAgents:
  3716. return m.Agents()
  3717. case allocagent.FieldStatus:
  3718. return m.Status()
  3719. }
  3720. return nil, false
  3721. }
  3722. // OldField returns the old value of the field from the database. An error is
  3723. // returned if the mutation operation is not UpdateOne, or the query to the
  3724. // database failed.
  3725. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3726. switch name {
  3727. case allocagent.FieldCreatedAt:
  3728. return m.OldCreatedAt(ctx)
  3729. case allocagent.FieldUpdatedAt:
  3730. return m.OldUpdatedAt(ctx)
  3731. case allocagent.FieldDeletedAt:
  3732. return m.OldDeletedAt(ctx)
  3733. case allocagent.FieldUserID:
  3734. return m.OldUserID(ctx)
  3735. case allocagent.FieldOrganizationID:
  3736. return m.OldOrganizationID(ctx)
  3737. case allocagent.FieldAgents:
  3738. return m.OldAgents(ctx)
  3739. case allocagent.FieldStatus:
  3740. return m.OldStatus(ctx)
  3741. }
  3742. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3743. }
  3744. // SetField sets the value of a field with the given name. It returns an error if
  3745. // the field is not defined in the schema, or if the type mismatched the field
  3746. // type.
  3747. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3748. switch name {
  3749. case allocagent.FieldCreatedAt:
  3750. v, ok := value.(time.Time)
  3751. if !ok {
  3752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3753. }
  3754. m.SetCreatedAt(v)
  3755. return nil
  3756. case allocagent.FieldUpdatedAt:
  3757. v, ok := value.(time.Time)
  3758. if !ok {
  3759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3760. }
  3761. m.SetUpdatedAt(v)
  3762. return nil
  3763. case allocagent.FieldDeletedAt:
  3764. v, ok := value.(time.Time)
  3765. if !ok {
  3766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3767. }
  3768. m.SetDeletedAt(v)
  3769. return nil
  3770. case allocagent.FieldUserID:
  3771. v, ok := value.(string)
  3772. if !ok {
  3773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3774. }
  3775. m.SetUserID(v)
  3776. return nil
  3777. case allocagent.FieldOrganizationID:
  3778. v, ok := value.(uint64)
  3779. if !ok {
  3780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3781. }
  3782. m.SetOrganizationID(v)
  3783. return nil
  3784. case allocagent.FieldAgents:
  3785. v, ok := value.([]uint64)
  3786. if !ok {
  3787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3788. }
  3789. m.SetAgents(v)
  3790. return nil
  3791. case allocagent.FieldStatus:
  3792. v, ok := value.(int)
  3793. if !ok {
  3794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3795. }
  3796. m.SetStatus(v)
  3797. return nil
  3798. }
  3799. return fmt.Errorf("unknown AllocAgent field %s", name)
  3800. }
  3801. // AddedFields returns all numeric fields that were incremented/decremented during
  3802. // this mutation.
  3803. func (m *AllocAgentMutation) AddedFields() []string {
  3804. var fields []string
  3805. if m.addorganization_id != nil {
  3806. fields = append(fields, allocagent.FieldOrganizationID)
  3807. }
  3808. if m.addstatus != nil {
  3809. fields = append(fields, allocagent.FieldStatus)
  3810. }
  3811. return fields
  3812. }
  3813. // AddedField returns the numeric value that was incremented/decremented on a field
  3814. // with the given name. The second boolean return value indicates that this field
  3815. // was not set, or was not defined in the schema.
  3816. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3817. switch name {
  3818. case allocagent.FieldOrganizationID:
  3819. return m.AddedOrganizationID()
  3820. case allocagent.FieldStatus:
  3821. return m.AddedStatus()
  3822. }
  3823. return nil, false
  3824. }
  3825. // AddField adds the value to the field with the given name. It returns an error if
  3826. // the field is not defined in the schema, or if the type mismatched the field
  3827. // type.
  3828. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3829. switch name {
  3830. case allocagent.FieldOrganizationID:
  3831. v, ok := value.(int64)
  3832. if !ok {
  3833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3834. }
  3835. m.AddOrganizationID(v)
  3836. return nil
  3837. case allocagent.FieldStatus:
  3838. v, ok := value.(int)
  3839. if !ok {
  3840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3841. }
  3842. m.AddStatus(v)
  3843. return nil
  3844. }
  3845. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3846. }
  3847. // ClearedFields returns all nullable fields that were cleared during this
  3848. // mutation.
  3849. func (m *AllocAgentMutation) ClearedFields() []string {
  3850. var fields []string
  3851. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3852. fields = append(fields, allocagent.FieldDeletedAt)
  3853. }
  3854. if m.FieldCleared(allocagent.FieldUserID) {
  3855. fields = append(fields, allocagent.FieldUserID)
  3856. }
  3857. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3858. fields = append(fields, allocagent.FieldOrganizationID)
  3859. }
  3860. if m.FieldCleared(allocagent.FieldStatus) {
  3861. fields = append(fields, allocagent.FieldStatus)
  3862. }
  3863. return fields
  3864. }
  3865. // FieldCleared returns a boolean indicating if a field with the given name was
  3866. // cleared in this mutation.
  3867. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3868. _, ok := m.clearedFields[name]
  3869. return ok
  3870. }
  3871. // ClearField clears the value of the field with the given name. It returns an
  3872. // error if the field is not defined in the schema.
  3873. func (m *AllocAgentMutation) ClearField(name string) error {
  3874. switch name {
  3875. case allocagent.FieldDeletedAt:
  3876. m.ClearDeletedAt()
  3877. return nil
  3878. case allocagent.FieldUserID:
  3879. m.ClearUserID()
  3880. return nil
  3881. case allocagent.FieldOrganizationID:
  3882. m.ClearOrganizationID()
  3883. return nil
  3884. case allocagent.FieldStatus:
  3885. m.ClearStatus()
  3886. return nil
  3887. }
  3888. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3889. }
  3890. // ResetField resets all changes in the mutation for the field with the given name.
  3891. // It returns an error if the field is not defined in the schema.
  3892. func (m *AllocAgentMutation) ResetField(name string) error {
  3893. switch name {
  3894. case allocagent.FieldCreatedAt:
  3895. m.ResetCreatedAt()
  3896. return nil
  3897. case allocagent.FieldUpdatedAt:
  3898. m.ResetUpdatedAt()
  3899. return nil
  3900. case allocagent.FieldDeletedAt:
  3901. m.ResetDeletedAt()
  3902. return nil
  3903. case allocagent.FieldUserID:
  3904. m.ResetUserID()
  3905. return nil
  3906. case allocagent.FieldOrganizationID:
  3907. m.ResetOrganizationID()
  3908. return nil
  3909. case allocagent.FieldAgents:
  3910. m.ResetAgents()
  3911. return nil
  3912. case allocagent.FieldStatus:
  3913. m.ResetStatus()
  3914. return nil
  3915. }
  3916. return fmt.Errorf("unknown AllocAgent field %s", name)
  3917. }
  3918. // AddedEdges returns all edge names that were set/added in this mutation.
  3919. func (m *AllocAgentMutation) AddedEdges() []string {
  3920. edges := make([]string, 0, 0)
  3921. return edges
  3922. }
  3923. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3924. // name in this mutation.
  3925. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3926. return nil
  3927. }
  3928. // RemovedEdges returns all edge names that were removed in this mutation.
  3929. func (m *AllocAgentMutation) RemovedEdges() []string {
  3930. edges := make([]string, 0, 0)
  3931. return edges
  3932. }
  3933. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3934. // the given name in this mutation.
  3935. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3936. return nil
  3937. }
  3938. // ClearedEdges returns all edge names that were cleared in this mutation.
  3939. func (m *AllocAgentMutation) ClearedEdges() []string {
  3940. edges := make([]string, 0, 0)
  3941. return edges
  3942. }
  3943. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3944. // was cleared in this mutation.
  3945. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3946. return false
  3947. }
  3948. // ClearEdge clears the value of the edge with the given name. It returns an error
  3949. // if that edge is not defined in the schema.
  3950. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3951. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3952. }
  3953. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3954. // It returns an error if the edge is not defined in the schema.
  3955. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3956. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3957. }
  3958. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3959. type BatchMsgMutation struct {
  3960. config
  3961. op Op
  3962. typ string
  3963. id *uint64
  3964. created_at *time.Time
  3965. updated_at *time.Time
  3966. deleted_at *time.Time
  3967. status *uint8
  3968. addstatus *int8
  3969. batch_no *string
  3970. task_name *string
  3971. fromwxid *string
  3972. msg *string
  3973. tag *string
  3974. tagids *string
  3975. total *int32
  3976. addtotal *int32
  3977. success *int32
  3978. addsuccess *int32
  3979. fail *int32
  3980. addfail *int32
  3981. start_time *time.Time
  3982. stop_time *time.Time
  3983. send_time *time.Time
  3984. _type *int32
  3985. add_type *int32
  3986. organization_id *uint64
  3987. addorganization_id *int64
  3988. ctype *uint64
  3989. addctype *int64
  3990. cc *string
  3991. phone *string
  3992. template_name *string
  3993. template_code *string
  3994. lang *string
  3995. clearedFields map[string]struct{}
  3996. done bool
  3997. oldValue func(context.Context) (*BatchMsg, error)
  3998. predicates []predicate.BatchMsg
  3999. }
  4000. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  4001. // batchmsgOption allows management of the mutation configuration using functional options.
  4002. type batchmsgOption func(*BatchMsgMutation)
  4003. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  4004. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  4005. m := &BatchMsgMutation{
  4006. config: c,
  4007. op: op,
  4008. typ: TypeBatchMsg,
  4009. clearedFields: make(map[string]struct{}),
  4010. }
  4011. for _, opt := range opts {
  4012. opt(m)
  4013. }
  4014. return m
  4015. }
  4016. // withBatchMsgID sets the ID field of the mutation.
  4017. func withBatchMsgID(id uint64) batchmsgOption {
  4018. return func(m *BatchMsgMutation) {
  4019. var (
  4020. err error
  4021. once sync.Once
  4022. value *BatchMsg
  4023. )
  4024. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  4025. once.Do(func() {
  4026. if m.done {
  4027. err = errors.New("querying old values post mutation is not allowed")
  4028. } else {
  4029. value, err = m.Client().BatchMsg.Get(ctx, id)
  4030. }
  4031. })
  4032. return value, err
  4033. }
  4034. m.id = &id
  4035. }
  4036. }
  4037. // withBatchMsg sets the old BatchMsg of the mutation.
  4038. func withBatchMsg(node *BatchMsg) batchmsgOption {
  4039. return func(m *BatchMsgMutation) {
  4040. m.oldValue = func(context.Context) (*BatchMsg, error) {
  4041. return node, nil
  4042. }
  4043. m.id = &node.ID
  4044. }
  4045. }
  4046. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4047. // executed in a transaction (ent.Tx), a transactional client is returned.
  4048. func (m BatchMsgMutation) Client() *Client {
  4049. client := &Client{config: m.config}
  4050. client.init()
  4051. return client
  4052. }
  4053. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4054. // it returns an error otherwise.
  4055. func (m BatchMsgMutation) Tx() (*Tx, error) {
  4056. if _, ok := m.driver.(*txDriver); !ok {
  4057. return nil, errors.New("ent: mutation is not running in a transaction")
  4058. }
  4059. tx := &Tx{config: m.config}
  4060. tx.init()
  4061. return tx, nil
  4062. }
  4063. // SetID sets the value of the id field. Note that this
  4064. // operation is only accepted on creation of BatchMsg entities.
  4065. func (m *BatchMsgMutation) SetID(id uint64) {
  4066. m.id = &id
  4067. }
  4068. // ID returns the ID value in the mutation. Note that the ID is only available
  4069. // if it was provided to the builder or after it was returned from the database.
  4070. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  4071. if m.id == nil {
  4072. return
  4073. }
  4074. return *m.id, true
  4075. }
  4076. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4077. // That means, if the mutation is applied within a transaction with an isolation level such
  4078. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4079. // or updated by the mutation.
  4080. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  4081. switch {
  4082. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4083. id, exists := m.ID()
  4084. if exists {
  4085. return []uint64{id}, nil
  4086. }
  4087. fallthrough
  4088. case m.op.Is(OpUpdate | OpDelete):
  4089. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4090. default:
  4091. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4092. }
  4093. }
  4094. // SetCreatedAt sets the "created_at" field.
  4095. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4096. m.created_at = &t
  4097. }
  4098. // CreatedAt returns the value of the "created_at" field in the mutation.
  4099. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4100. v := m.created_at
  4101. if v == nil {
  4102. return
  4103. }
  4104. return *v, true
  4105. }
  4106. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4107. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4109. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4110. if !m.op.Is(OpUpdateOne) {
  4111. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4112. }
  4113. if m.id == nil || m.oldValue == nil {
  4114. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4115. }
  4116. oldValue, err := m.oldValue(ctx)
  4117. if err != nil {
  4118. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4119. }
  4120. return oldValue.CreatedAt, nil
  4121. }
  4122. // ResetCreatedAt resets all changes to the "created_at" field.
  4123. func (m *BatchMsgMutation) ResetCreatedAt() {
  4124. m.created_at = nil
  4125. }
  4126. // SetUpdatedAt sets the "updated_at" field.
  4127. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4128. m.updated_at = &t
  4129. }
  4130. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4131. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4132. v := m.updated_at
  4133. if v == nil {
  4134. return
  4135. }
  4136. return *v, true
  4137. }
  4138. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4139. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4141. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4142. if !m.op.Is(OpUpdateOne) {
  4143. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4144. }
  4145. if m.id == nil || m.oldValue == nil {
  4146. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4147. }
  4148. oldValue, err := m.oldValue(ctx)
  4149. if err != nil {
  4150. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4151. }
  4152. return oldValue.UpdatedAt, nil
  4153. }
  4154. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4155. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4156. m.updated_at = nil
  4157. }
  4158. // SetDeletedAt sets the "deleted_at" field.
  4159. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4160. m.deleted_at = &t
  4161. }
  4162. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4163. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4164. v := m.deleted_at
  4165. if v == nil {
  4166. return
  4167. }
  4168. return *v, true
  4169. }
  4170. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4171. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4173. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4174. if !m.op.Is(OpUpdateOne) {
  4175. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4176. }
  4177. if m.id == nil || m.oldValue == nil {
  4178. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4179. }
  4180. oldValue, err := m.oldValue(ctx)
  4181. if err != nil {
  4182. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4183. }
  4184. return oldValue.DeletedAt, nil
  4185. }
  4186. // ClearDeletedAt clears the value of the "deleted_at" field.
  4187. func (m *BatchMsgMutation) ClearDeletedAt() {
  4188. m.deleted_at = nil
  4189. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4190. }
  4191. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4192. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4193. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4194. return ok
  4195. }
  4196. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4197. func (m *BatchMsgMutation) ResetDeletedAt() {
  4198. m.deleted_at = nil
  4199. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4200. }
  4201. // SetStatus sets the "status" field.
  4202. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4203. m.status = &u
  4204. m.addstatus = nil
  4205. }
  4206. // Status returns the value of the "status" field in the mutation.
  4207. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4208. v := m.status
  4209. if v == nil {
  4210. return
  4211. }
  4212. return *v, true
  4213. }
  4214. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4215. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4217. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4218. if !m.op.Is(OpUpdateOne) {
  4219. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4220. }
  4221. if m.id == nil || m.oldValue == nil {
  4222. return v, errors.New("OldStatus requires an ID field in the mutation")
  4223. }
  4224. oldValue, err := m.oldValue(ctx)
  4225. if err != nil {
  4226. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4227. }
  4228. return oldValue.Status, nil
  4229. }
  4230. // AddStatus adds u to the "status" field.
  4231. func (m *BatchMsgMutation) AddStatus(u int8) {
  4232. if m.addstatus != nil {
  4233. *m.addstatus += u
  4234. } else {
  4235. m.addstatus = &u
  4236. }
  4237. }
  4238. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4239. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4240. v := m.addstatus
  4241. if v == nil {
  4242. return
  4243. }
  4244. return *v, true
  4245. }
  4246. // ClearStatus clears the value of the "status" field.
  4247. func (m *BatchMsgMutation) ClearStatus() {
  4248. m.status = nil
  4249. m.addstatus = nil
  4250. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4251. }
  4252. // StatusCleared returns if the "status" field was cleared in this mutation.
  4253. func (m *BatchMsgMutation) StatusCleared() bool {
  4254. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4255. return ok
  4256. }
  4257. // ResetStatus resets all changes to the "status" field.
  4258. func (m *BatchMsgMutation) ResetStatus() {
  4259. m.status = nil
  4260. m.addstatus = nil
  4261. delete(m.clearedFields, batchmsg.FieldStatus)
  4262. }
  4263. // SetBatchNo sets the "batch_no" field.
  4264. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4265. m.batch_no = &s
  4266. }
  4267. // BatchNo returns the value of the "batch_no" field in the mutation.
  4268. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4269. v := m.batch_no
  4270. if v == nil {
  4271. return
  4272. }
  4273. return *v, true
  4274. }
  4275. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4276. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4278. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4279. if !m.op.Is(OpUpdateOne) {
  4280. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4281. }
  4282. if m.id == nil || m.oldValue == nil {
  4283. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4284. }
  4285. oldValue, err := m.oldValue(ctx)
  4286. if err != nil {
  4287. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4288. }
  4289. return oldValue.BatchNo, nil
  4290. }
  4291. // ClearBatchNo clears the value of the "batch_no" field.
  4292. func (m *BatchMsgMutation) ClearBatchNo() {
  4293. m.batch_no = nil
  4294. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4295. }
  4296. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4297. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4298. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4299. return ok
  4300. }
  4301. // ResetBatchNo resets all changes to the "batch_no" field.
  4302. func (m *BatchMsgMutation) ResetBatchNo() {
  4303. m.batch_no = nil
  4304. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4305. }
  4306. // SetTaskName sets the "task_name" field.
  4307. func (m *BatchMsgMutation) SetTaskName(s string) {
  4308. m.task_name = &s
  4309. }
  4310. // TaskName returns the value of the "task_name" field in the mutation.
  4311. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4312. v := m.task_name
  4313. if v == nil {
  4314. return
  4315. }
  4316. return *v, true
  4317. }
  4318. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4319. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4321. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4322. if !m.op.Is(OpUpdateOne) {
  4323. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4324. }
  4325. if m.id == nil || m.oldValue == nil {
  4326. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4327. }
  4328. oldValue, err := m.oldValue(ctx)
  4329. if err != nil {
  4330. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4331. }
  4332. return oldValue.TaskName, nil
  4333. }
  4334. // ClearTaskName clears the value of the "task_name" field.
  4335. func (m *BatchMsgMutation) ClearTaskName() {
  4336. m.task_name = nil
  4337. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4338. }
  4339. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4340. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4341. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4342. return ok
  4343. }
  4344. // ResetTaskName resets all changes to the "task_name" field.
  4345. func (m *BatchMsgMutation) ResetTaskName() {
  4346. m.task_name = nil
  4347. delete(m.clearedFields, batchmsg.FieldTaskName)
  4348. }
  4349. // SetFromwxid sets the "fromwxid" field.
  4350. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4351. m.fromwxid = &s
  4352. }
  4353. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4354. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4355. v := m.fromwxid
  4356. if v == nil {
  4357. return
  4358. }
  4359. return *v, true
  4360. }
  4361. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4362. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4364. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4365. if !m.op.Is(OpUpdateOne) {
  4366. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4367. }
  4368. if m.id == nil || m.oldValue == nil {
  4369. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4370. }
  4371. oldValue, err := m.oldValue(ctx)
  4372. if err != nil {
  4373. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4374. }
  4375. return oldValue.Fromwxid, nil
  4376. }
  4377. // ClearFromwxid clears the value of the "fromwxid" field.
  4378. func (m *BatchMsgMutation) ClearFromwxid() {
  4379. m.fromwxid = nil
  4380. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4381. }
  4382. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4383. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4384. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4385. return ok
  4386. }
  4387. // ResetFromwxid resets all changes to the "fromwxid" field.
  4388. func (m *BatchMsgMutation) ResetFromwxid() {
  4389. m.fromwxid = nil
  4390. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4391. }
  4392. // SetMsg sets the "msg" field.
  4393. func (m *BatchMsgMutation) SetMsg(s string) {
  4394. m.msg = &s
  4395. }
  4396. // Msg returns the value of the "msg" field in the mutation.
  4397. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4398. v := m.msg
  4399. if v == nil {
  4400. return
  4401. }
  4402. return *v, true
  4403. }
  4404. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4405. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4407. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4408. if !m.op.Is(OpUpdateOne) {
  4409. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4410. }
  4411. if m.id == nil || m.oldValue == nil {
  4412. return v, errors.New("OldMsg requires an ID field in the mutation")
  4413. }
  4414. oldValue, err := m.oldValue(ctx)
  4415. if err != nil {
  4416. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4417. }
  4418. return oldValue.Msg, nil
  4419. }
  4420. // ClearMsg clears the value of the "msg" field.
  4421. func (m *BatchMsgMutation) ClearMsg() {
  4422. m.msg = nil
  4423. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4424. }
  4425. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4426. func (m *BatchMsgMutation) MsgCleared() bool {
  4427. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4428. return ok
  4429. }
  4430. // ResetMsg resets all changes to the "msg" field.
  4431. func (m *BatchMsgMutation) ResetMsg() {
  4432. m.msg = nil
  4433. delete(m.clearedFields, batchmsg.FieldMsg)
  4434. }
  4435. // SetTag sets the "tag" field.
  4436. func (m *BatchMsgMutation) SetTag(s string) {
  4437. m.tag = &s
  4438. }
  4439. // Tag returns the value of the "tag" field in the mutation.
  4440. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4441. v := m.tag
  4442. if v == nil {
  4443. return
  4444. }
  4445. return *v, true
  4446. }
  4447. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4448. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4450. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4451. if !m.op.Is(OpUpdateOne) {
  4452. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4453. }
  4454. if m.id == nil || m.oldValue == nil {
  4455. return v, errors.New("OldTag requires an ID field in the mutation")
  4456. }
  4457. oldValue, err := m.oldValue(ctx)
  4458. if err != nil {
  4459. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4460. }
  4461. return oldValue.Tag, nil
  4462. }
  4463. // ClearTag clears the value of the "tag" field.
  4464. func (m *BatchMsgMutation) ClearTag() {
  4465. m.tag = nil
  4466. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4467. }
  4468. // TagCleared returns if the "tag" field was cleared in this mutation.
  4469. func (m *BatchMsgMutation) TagCleared() bool {
  4470. _, ok := m.clearedFields[batchmsg.FieldTag]
  4471. return ok
  4472. }
  4473. // ResetTag resets all changes to the "tag" field.
  4474. func (m *BatchMsgMutation) ResetTag() {
  4475. m.tag = nil
  4476. delete(m.clearedFields, batchmsg.FieldTag)
  4477. }
  4478. // SetTagids sets the "tagids" field.
  4479. func (m *BatchMsgMutation) SetTagids(s string) {
  4480. m.tagids = &s
  4481. }
  4482. // Tagids returns the value of the "tagids" field in the mutation.
  4483. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4484. v := m.tagids
  4485. if v == nil {
  4486. return
  4487. }
  4488. return *v, true
  4489. }
  4490. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4491. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4493. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4494. if !m.op.Is(OpUpdateOne) {
  4495. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4496. }
  4497. if m.id == nil || m.oldValue == nil {
  4498. return v, errors.New("OldTagids requires an ID field in the mutation")
  4499. }
  4500. oldValue, err := m.oldValue(ctx)
  4501. if err != nil {
  4502. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4503. }
  4504. return oldValue.Tagids, nil
  4505. }
  4506. // ClearTagids clears the value of the "tagids" field.
  4507. func (m *BatchMsgMutation) ClearTagids() {
  4508. m.tagids = nil
  4509. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4510. }
  4511. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4512. func (m *BatchMsgMutation) TagidsCleared() bool {
  4513. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4514. return ok
  4515. }
  4516. // ResetTagids resets all changes to the "tagids" field.
  4517. func (m *BatchMsgMutation) ResetTagids() {
  4518. m.tagids = nil
  4519. delete(m.clearedFields, batchmsg.FieldTagids)
  4520. }
  4521. // SetTotal sets the "total" field.
  4522. func (m *BatchMsgMutation) SetTotal(i int32) {
  4523. m.total = &i
  4524. m.addtotal = nil
  4525. }
  4526. // Total returns the value of the "total" field in the mutation.
  4527. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4528. v := m.total
  4529. if v == nil {
  4530. return
  4531. }
  4532. return *v, true
  4533. }
  4534. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4535. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4537. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4538. if !m.op.Is(OpUpdateOne) {
  4539. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4540. }
  4541. if m.id == nil || m.oldValue == nil {
  4542. return v, errors.New("OldTotal requires an ID field in the mutation")
  4543. }
  4544. oldValue, err := m.oldValue(ctx)
  4545. if err != nil {
  4546. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4547. }
  4548. return oldValue.Total, nil
  4549. }
  4550. // AddTotal adds i to the "total" field.
  4551. func (m *BatchMsgMutation) AddTotal(i int32) {
  4552. if m.addtotal != nil {
  4553. *m.addtotal += i
  4554. } else {
  4555. m.addtotal = &i
  4556. }
  4557. }
  4558. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4559. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4560. v := m.addtotal
  4561. if v == nil {
  4562. return
  4563. }
  4564. return *v, true
  4565. }
  4566. // ClearTotal clears the value of the "total" field.
  4567. func (m *BatchMsgMutation) ClearTotal() {
  4568. m.total = nil
  4569. m.addtotal = nil
  4570. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4571. }
  4572. // TotalCleared returns if the "total" field was cleared in this mutation.
  4573. func (m *BatchMsgMutation) TotalCleared() bool {
  4574. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4575. return ok
  4576. }
  4577. // ResetTotal resets all changes to the "total" field.
  4578. func (m *BatchMsgMutation) ResetTotal() {
  4579. m.total = nil
  4580. m.addtotal = nil
  4581. delete(m.clearedFields, batchmsg.FieldTotal)
  4582. }
  4583. // SetSuccess sets the "success" field.
  4584. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4585. m.success = &i
  4586. m.addsuccess = nil
  4587. }
  4588. // Success returns the value of the "success" field in the mutation.
  4589. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4590. v := m.success
  4591. if v == nil {
  4592. return
  4593. }
  4594. return *v, true
  4595. }
  4596. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4597. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4599. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4600. if !m.op.Is(OpUpdateOne) {
  4601. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4602. }
  4603. if m.id == nil || m.oldValue == nil {
  4604. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4605. }
  4606. oldValue, err := m.oldValue(ctx)
  4607. if err != nil {
  4608. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4609. }
  4610. return oldValue.Success, nil
  4611. }
  4612. // AddSuccess adds i to the "success" field.
  4613. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4614. if m.addsuccess != nil {
  4615. *m.addsuccess += i
  4616. } else {
  4617. m.addsuccess = &i
  4618. }
  4619. }
  4620. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4621. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4622. v := m.addsuccess
  4623. if v == nil {
  4624. return
  4625. }
  4626. return *v, true
  4627. }
  4628. // ClearSuccess clears the value of the "success" field.
  4629. func (m *BatchMsgMutation) ClearSuccess() {
  4630. m.success = nil
  4631. m.addsuccess = nil
  4632. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4633. }
  4634. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4635. func (m *BatchMsgMutation) SuccessCleared() bool {
  4636. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4637. return ok
  4638. }
  4639. // ResetSuccess resets all changes to the "success" field.
  4640. func (m *BatchMsgMutation) ResetSuccess() {
  4641. m.success = nil
  4642. m.addsuccess = nil
  4643. delete(m.clearedFields, batchmsg.FieldSuccess)
  4644. }
  4645. // SetFail sets the "fail" field.
  4646. func (m *BatchMsgMutation) SetFail(i int32) {
  4647. m.fail = &i
  4648. m.addfail = nil
  4649. }
  4650. // Fail returns the value of the "fail" field in the mutation.
  4651. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4652. v := m.fail
  4653. if v == nil {
  4654. return
  4655. }
  4656. return *v, true
  4657. }
  4658. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4659. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4661. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4662. if !m.op.Is(OpUpdateOne) {
  4663. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4664. }
  4665. if m.id == nil || m.oldValue == nil {
  4666. return v, errors.New("OldFail requires an ID field in the mutation")
  4667. }
  4668. oldValue, err := m.oldValue(ctx)
  4669. if err != nil {
  4670. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4671. }
  4672. return oldValue.Fail, nil
  4673. }
  4674. // AddFail adds i to the "fail" field.
  4675. func (m *BatchMsgMutation) AddFail(i int32) {
  4676. if m.addfail != nil {
  4677. *m.addfail += i
  4678. } else {
  4679. m.addfail = &i
  4680. }
  4681. }
  4682. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4683. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4684. v := m.addfail
  4685. if v == nil {
  4686. return
  4687. }
  4688. return *v, true
  4689. }
  4690. // ClearFail clears the value of the "fail" field.
  4691. func (m *BatchMsgMutation) ClearFail() {
  4692. m.fail = nil
  4693. m.addfail = nil
  4694. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4695. }
  4696. // FailCleared returns if the "fail" field was cleared in this mutation.
  4697. func (m *BatchMsgMutation) FailCleared() bool {
  4698. _, ok := m.clearedFields[batchmsg.FieldFail]
  4699. return ok
  4700. }
  4701. // ResetFail resets all changes to the "fail" field.
  4702. func (m *BatchMsgMutation) ResetFail() {
  4703. m.fail = nil
  4704. m.addfail = nil
  4705. delete(m.clearedFields, batchmsg.FieldFail)
  4706. }
  4707. // SetStartTime sets the "start_time" field.
  4708. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4709. m.start_time = &t
  4710. }
  4711. // StartTime returns the value of the "start_time" field in the mutation.
  4712. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4713. v := m.start_time
  4714. if v == nil {
  4715. return
  4716. }
  4717. return *v, true
  4718. }
  4719. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4720. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4722. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4723. if !m.op.Is(OpUpdateOne) {
  4724. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4725. }
  4726. if m.id == nil || m.oldValue == nil {
  4727. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4728. }
  4729. oldValue, err := m.oldValue(ctx)
  4730. if err != nil {
  4731. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4732. }
  4733. return oldValue.StartTime, nil
  4734. }
  4735. // ClearStartTime clears the value of the "start_time" field.
  4736. func (m *BatchMsgMutation) ClearStartTime() {
  4737. m.start_time = nil
  4738. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4739. }
  4740. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4741. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4742. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4743. return ok
  4744. }
  4745. // ResetStartTime resets all changes to the "start_time" field.
  4746. func (m *BatchMsgMutation) ResetStartTime() {
  4747. m.start_time = nil
  4748. delete(m.clearedFields, batchmsg.FieldStartTime)
  4749. }
  4750. // SetStopTime sets the "stop_time" field.
  4751. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4752. m.stop_time = &t
  4753. }
  4754. // StopTime returns the value of the "stop_time" field in the mutation.
  4755. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4756. v := m.stop_time
  4757. if v == nil {
  4758. return
  4759. }
  4760. return *v, true
  4761. }
  4762. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4763. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4765. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4766. if !m.op.Is(OpUpdateOne) {
  4767. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4768. }
  4769. if m.id == nil || m.oldValue == nil {
  4770. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4771. }
  4772. oldValue, err := m.oldValue(ctx)
  4773. if err != nil {
  4774. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4775. }
  4776. return oldValue.StopTime, nil
  4777. }
  4778. // ClearStopTime clears the value of the "stop_time" field.
  4779. func (m *BatchMsgMutation) ClearStopTime() {
  4780. m.stop_time = nil
  4781. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4782. }
  4783. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4784. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4785. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4786. return ok
  4787. }
  4788. // ResetStopTime resets all changes to the "stop_time" field.
  4789. func (m *BatchMsgMutation) ResetStopTime() {
  4790. m.stop_time = nil
  4791. delete(m.clearedFields, batchmsg.FieldStopTime)
  4792. }
  4793. // SetSendTime sets the "send_time" field.
  4794. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4795. m.send_time = &t
  4796. }
  4797. // SendTime returns the value of the "send_time" field in the mutation.
  4798. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4799. v := m.send_time
  4800. if v == nil {
  4801. return
  4802. }
  4803. return *v, true
  4804. }
  4805. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4806. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4808. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4809. if !m.op.Is(OpUpdateOne) {
  4810. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4811. }
  4812. if m.id == nil || m.oldValue == nil {
  4813. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4814. }
  4815. oldValue, err := m.oldValue(ctx)
  4816. if err != nil {
  4817. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4818. }
  4819. return oldValue.SendTime, nil
  4820. }
  4821. // ClearSendTime clears the value of the "send_time" field.
  4822. func (m *BatchMsgMutation) ClearSendTime() {
  4823. m.send_time = nil
  4824. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4825. }
  4826. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4827. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4828. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4829. return ok
  4830. }
  4831. // ResetSendTime resets all changes to the "send_time" field.
  4832. func (m *BatchMsgMutation) ResetSendTime() {
  4833. m.send_time = nil
  4834. delete(m.clearedFields, batchmsg.FieldSendTime)
  4835. }
  4836. // SetType sets the "type" field.
  4837. func (m *BatchMsgMutation) SetType(i int32) {
  4838. m._type = &i
  4839. m.add_type = nil
  4840. }
  4841. // GetType returns the value of the "type" field in the mutation.
  4842. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4843. v := m._type
  4844. if v == nil {
  4845. return
  4846. }
  4847. return *v, true
  4848. }
  4849. // OldType returns the old "type" field's value of the BatchMsg entity.
  4850. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4852. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4853. if !m.op.Is(OpUpdateOne) {
  4854. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4855. }
  4856. if m.id == nil || m.oldValue == nil {
  4857. return v, errors.New("OldType requires an ID field in the mutation")
  4858. }
  4859. oldValue, err := m.oldValue(ctx)
  4860. if err != nil {
  4861. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4862. }
  4863. return oldValue.Type, nil
  4864. }
  4865. // AddType adds i to the "type" field.
  4866. func (m *BatchMsgMutation) AddType(i int32) {
  4867. if m.add_type != nil {
  4868. *m.add_type += i
  4869. } else {
  4870. m.add_type = &i
  4871. }
  4872. }
  4873. // AddedType returns the value that was added to the "type" field in this mutation.
  4874. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4875. v := m.add_type
  4876. if v == nil {
  4877. return
  4878. }
  4879. return *v, true
  4880. }
  4881. // ClearType clears the value of the "type" field.
  4882. func (m *BatchMsgMutation) ClearType() {
  4883. m._type = nil
  4884. m.add_type = nil
  4885. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4886. }
  4887. // TypeCleared returns if the "type" field was cleared in this mutation.
  4888. func (m *BatchMsgMutation) TypeCleared() bool {
  4889. _, ok := m.clearedFields[batchmsg.FieldType]
  4890. return ok
  4891. }
  4892. // ResetType resets all changes to the "type" field.
  4893. func (m *BatchMsgMutation) ResetType() {
  4894. m._type = nil
  4895. m.add_type = nil
  4896. delete(m.clearedFields, batchmsg.FieldType)
  4897. }
  4898. // SetOrganizationID sets the "organization_id" field.
  4899. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4900. m.organization_id = &u
  4901. m.addorganization_id = nil
  4902. }
  4903. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4904. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4905. v := m.organization_id
  4906. if v == nil {
  4907. return
  4908. }
  4909. return *v, true
  4910. }
  4911. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4912. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4914. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4915. if !m.op.Is(OpUpdateOne) {
  4916. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4917. }
  4918. if m.id == nil || m.oldValue == nil {
  4919. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4920. }
  4921. oldValue, err := m.oldValue(ctx)
  4922. if err != nil {
  4923. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4924. }
  4925. return oldValue.OrganizationID, nil
  4926. }
  4927. // AddOrganizationID adds u to the "organization_id" field.
  4928. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4929. if m.addorganization_id != nil {
  4930. *m.addorganization_id += u
  4931. } else {
  4932. m.addorganization_id = &u
  4933. }
  4934. }
  4935. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4936. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4937. v := m.addorganization_id
  4938. if v == nil {
  4939. return
  4940. }
  4941. return *v, true
  4942. }
  4943. // ResetOrganizationID resets all changes to the "organization_id" field.
  4944. func (m *BatchMsgMutation) ResetOrganizationID() {
  4945. m.organization_id = nil
  4946. m.addorganization_id = nil
  4947. }
  4948. // SetCtype sets the "ctype" field.
  4949. func (m *BatchMsgMutation) SetCtype(u uint64) {
  4950. m.ctype = &u
  4951. m.addctype = nil
  4952. }
  4953. // Ctype returns the value of the "ctype" field in the mutation.
  4954. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  4955. v := m.ctype
  4956. if v == nil {
  4957. return
  4958. }
  4959. return *v, true
  4960. }
  4961. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  4962. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4964. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  4965. if !m.op.Is(OpUpdateOne) {
  4966. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  4967. }
  4968. if m.id == nil || m.oldValue == nil {
  4969. return v, errors.New("OldCtype requires an ID field in the mutation")
  4970. }
  4971. oldValue, err := m.oldValue(ctx)
  4972. if err != nil {
  4973. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  4974. }
  4975. return oldValue.Ctype, nil
  4976. }
  4977. // AddCtype adds u to the "ctype" field.
  4978. func (m *BatchMsgMutation) AddCtype(u int64) {
  4979. if m.addctype != nil {
  4980. *m.addctype += u
  4981. } else {
  4982. m.addctype = &u
  4983. }
  4984. }
  4985. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  4986. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  4987. v := m.addctype
  4988. if v == nil {
  4989. return
  4990. }
  4991. return *v, true
  4992. }
  4993. // ResetCtype resets all changes to the "ctype" field.
  4994. func (m *BatchMsgMutation) ResetCtype() {
  4995. m.ctype = nil
  4996. m.addctype = nil
  4997. }
  4998. // SetCc sets the "cc" field.
  4999. func (m *BatchMsgMutation) SetCc(s string) {
  5000. m.cc = &s
  5001. }
  5002. // Cc returns the value of the "cc" field in the mutation.
  5003. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  5004. v := m.cc
  5005. if v == nil {
  5006. return
  5007. }
  5008. return *v, true
  5009. }
  5010. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  5011. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5013. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  5014. if !m.op.Is(OpUpdateOne) {
  5015. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  5016. }
  5017. if m.id == nil || m.oldValue == nil {
  5018. return v, errors.New("OldCc requires an ID field in the mutation")
  5019. }
  5020. oldValue, err := m.oldValue(ctx)
  5021. if err != nil {
  5022. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  5023. }
  5024. return oldValue.Cc, nil
  5025. }
  5026. // ClearCc clears the value of the "cc" field.
  5027. func (m *BatchMsgMutation) ClearCc() {
  5028. m.cc = nil
  5029. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  5030. }
  5031. // CcCleared returns if the "cc" field was cleared in this mutation.
  5032. func (m *BatchMsgMutation) CcCleared() bool {
  5033. _, ok := m.clearedFields[batchmsg.FieldCc]
  5034. return ok
  5035. }
  5036. // ResetCc resets all changes to the "cc" field.
  5037. func (m *BatchMsgMutation) ResetCc() {
  5038. m.cc = nil
  5039. delete(m.clearedFields, batchmsg.FieldCc)
  5040. }
  5041. // SetPhone sets the "phone" field.
  5042. func (m *BatchMsgMutation) SetPhone(s string) {
  5043. m.phone = &s
  5044. }
  5045. // Phone returns the value of the "phone" field in the mutation.
  5046. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  5047. v := m.phone
  5048. if v == nil {
  5049. return
  5050. }
  5051. return *v, true
  5052. }
  5053. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  5054. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5056. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  5057. if !m.op.Is(OpUpdateOne) {
  5058. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  5059. }
  5060. if m.id == nil || m.oldValue == nil {
  5061. return v, errors.New("OldPhone requires an ID field in the mutation")
  5062. }
  5063. oldValue, err := m.oldValue(ctx)
  5064. if err != nil {
  5065. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  5066. }
  5067. return oldValue.Phone, nil
  5068. }
  5069. // ClearPhone clears the value of the "phone" field.
  5070. func (m *BatchMsgMutation) ClearPhone() {
  5071. m.phone = nil
  5072. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  5073. }
  5074. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  5075. func (m *BatchMsgMutation) PhoneCleared() bool {
  5076. _, ok := m.clearedFields[batchmsg.FieldPhone]
  5077. return ok
  5078. }
  5079. // ResetPhone resets all changes to the "phone" field.
  5080. func (m *BatchMsgMutation) ResetPhone() {
  5081. m.phone = nil
  5082. delete(m.clearedFields, batchmsg.FieldPhone)
  5083. }
  5084. // SetTemplateName sets the "template_name" field.
  5085. func (m *BatchMsgMutation) SetTemplateName(s string) {
  5086. m.template_name = &s
  5087. }
  5088. // TemplateName returns the value of the "template_name" field in the mutation.
  5089. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  5090. v := m.template_name
  5091. if v == nil {
  5092. return
  5093. }
  5094. return *v, true
  5095. }
  5096. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  5097. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5099. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  5100. if !m.op.Is(OpUpdateOne) {
  5101. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  5102. }
  5103. if m.id == nil || m.oldValue == nil {
  5104. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  5105. }
  5106. oldValue, err := m.oldValue(ctx)
  5107. if err != nil {
  5108. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  5109. }
  5110. return oldValue.TemplateName, nil
  5111. }
  5112. // ClearTemplateName clears the value of the "template_name" field.
  5113. func (m *BatchMsgMutation) ClearTemplateName() {
  5114. m.template_name = nil
  5115. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  5116. }
  5117. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  5118. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  5119. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  5120. return ok
  5121. }
  5122. // ResetTemplateName resets all changes to the "template_name" field.
  5123. func (m *BatchMsgMutation) ResetTemplateName() {
  5124. m.template_name = nil
  5125. delete(m.clearedFields, batchmsg.FieldTemplateName)
  5126. }
  5127. // SetTemplateCode sets the "template_code" field.
  5128. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  5129. m.template_code = &s
  5130. }
  5131. // TemplateCode returns the value of the "template_code" field in the mutation.
  5132. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  5133. v := m.template_code
  5134. if v == nil {
  5135. return
  5136. }
  5137. return *v, true
  5138. }
  5139. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  5140. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5142. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  5143. if !m.op.Is(OpUpdateOne) {
  5144. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  5145. }
  5146. if m.id == nil || m.oldValue == nil {
  5147. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  5148. }
  5149. oldValue, err := m.oldValue(ctx)
  5150. if err != nil {
  5151. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  5152. }
  5153. return oldValue.TemplateCode, nil
  5154. }
  5155. // ClearTemplateCode clears the value of the "template_code" field.
  5156. func (m *BatchMsgMutation) ClearTemplateCode() {
  5157. m.template_code = nil
  5158. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  5159. }
  5160. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  5161. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  5162. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  5163. return ok
  5164. }
  5165. // ResetTemplateCode resets all changes to the "template_code" field.
  5166. func (m *BatchMsgMutation) ResetTemplateCode() {
  5167. m.template_code = nil
  5168. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  5169. }
  5170. // SetLang sets the "lang" field.
  5171. func (m *BatchMsgMutation) SetLang(s string) {
  5172. m.lang = &s
  5173. }
  5174. // Lang returns the value of the "lang" field in the mutation.
  5175. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  5176. v := m.lang
  5177. if v == nil {
  5178. return
  5179. }
  5180. return *v, true
  5181. }
  5182. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  5183. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5185. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  5186. if !m.op.Is(OpUpdateOne) {
  5187. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  5188. }
  5189. if m.id == nil || m.oldValue == nil {
  5190. return v, errors.New("OldLang requires an ID field in the mutation")
  5191. }
  5192. oldValue, err := m.oldValue(ctx)
  5193. if err != nil {
  5194. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  5195. }
  5196. return oldValue.Lang, nil
  5197. }
  5198. // ClearLang clears the value of the "lang" field.
  5199. func (m *BatchMsgMutation) ClearLang() {
  5200. m.lang = nil
  5201. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  5202. }
  5203. // LangCleared returns if the "lang" field was cleared in this mutation.
  5204. func (m *BatchMsgMutation) LangCleared() bool {
  5205. _, ok := m.clearedFields[batchmsg.FieldLang]
  5206. return ok
  5207. }
  5208. // ResetLang resets all changes to the "lang" field.
  5209. func (m *BatchMsgMutation) ResetLang() {
  5210. m.lang = nil
  5211. delete(m.clearedFields, batchmsg.FieldLang)
  5212. }
  5213. // Where appends a list predicates to the BatchMsgMutation builder.
  5214. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  5215. m.predicates = append(m.predicates, ps...)
  5216. }
  5217. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  5218. // users can use type-assertion to append predicates that do not depend on any generated package.
  5219. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  5220. p := make([]predicate.BatchMsg, len(ps))
  5221. for i := range ps {
  5222. p[i] = ps[i]
  5223. }
  5224. m.Where(p...)
  5225. }
  5226. // Op returns the operation name.
  5227. func (m *BatchMsgMutation) Op() Op {
  5228. return m.op
  5229. }
  5230. // SetOp allows setting the mutation operation.
  5231. func (m *BatchMsgMutation) SetOp(op Op) {
  5232. m.op = op
  5233. }
  5234. // Type returns the node type of this mutation (BatchMsg).
  5235. func (m *BatchMsgMutation) Type() string {
  5236. return m.typ
  5237. }
  5238. // Fields returns all fields that were changed during this mutation. Note that in
  5239. // order to get all numeric fields that were incremented/decremented, call
  5240. // AddedFields().
  5241. func (m *BatchMsgMutation) Fields() []string {
  5242. fields := make([]string, 0, 24)
  5243. if m.created_at != nil {
  5244. fields = append(fields, batchmsg.FieldCreatedAt)
  5245. }
  5246. if m.updated_at != nil {
  5247. fields = append(fields, batchmsg.FieldUpdatedAt)
  5248. }
  5249. if m.deleted_at != nil {
  5250. fields = append(fields, batchmsg.FieldDeletedAt)
  5251. }
  5252. if m.status != nil {
  5253. fields = append(fields, batchmsg.FieldStatus)
  5254. }
  5255. if m.batch_no != nil {
  5256. fields = append(fields, batchmsg.FieldBatchNo)
  5257. }
  5258. if m.task_name != nil {
  5259. fields = append(fields, batchmsg.FieldTaskName)
  5260. }
  5261. if m.fromwxid != nil {
  5262. fields = append(fields, batchmsg.FieldFromwxid)
  5263. }
  5264. if m.msg != nil {
  5265. fields = append(fields, batchmsg.FieldMsg)
  5266. }
  5267. if m.tag != nil {
  5268. fields = append(fields, batchmsg.FieldTag)
  5269. }
  5270. if m.tagids != nil {
  5271. fields = append(fields, batchmsg.FieldTagids)
  5272. }
  5273. if m.total != nil {
  5274. fields = append(fields, batchmsg.FieldTotal)
  5275. }
  5276. if m.success != nil {
  5277. fields = append(fields, batchmsg.FieldSuccess)
  5278. }
  5279. if m.fail != nil {
  5280. fields = append(fields, batchmsg.FieldFail)
  5281. }
  5282. if m.start_time != nil {
  5283. fields = append(fields, batchmsg.FieldStartTime)
  5284. }
  5285. if m.stop_time != nil {
  5286. fields = append(fields, batchmsg.FieldStopTime)
  5287. }
  5288. if m.send_time != nil {
  5289. fields = append(fields, batchmsg.FieldSendTime)
  5290. }
  5291. if m._type != nil {
  5292. fields = append(fields, batchmsg.FieldType)
  5293. }
  5294. if m.organization_id != nil {
  5295. fields = append(fields, batchmsg.FieldOrganizationID)
  5296. }
  5297. if m.ctype != nil {
  5298. fields = append(fields, batchmsg.FieldCtype)
  5299. }
  5300. if m.cc != nil {
  5301. fields = append(fields, batchmsg.FieldCc)
  5302. }
  5303. if m.phone != nil {
  5304. fields = append(fields, batchmsg.FieldPhone)
  5305. }
  5306. if m.template_name != nil {
  5307. fields = append(fields, batchmsg.FieldTemplateName)
  5308. }
  5309. if m.template_code != nil {
  5310. fields = append(fields, batchmsg.FieldTemplateCode)
  5311. }
  5312. if m.lang != nil {
  5313. fields = append(fields, batchmsg.FieldLang)
  5314. }
  5315. return fields
  5316. }
  5317. // Field returns the value of a field with the given name. The second boolean
  5318. // return value indicates that this field was not set, or was not defined in the
  5319. // schema.
  5320. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  5321. switch name {
  5322. case batchmsg.FieldCreatedAt:
  5323. return m.CreatedAt()
  5324. case batchmsg.FieldUpdatedAt:
  5325. return m.UpdatedAt()
  5326. case batchmsg.FieldDeletedAt:
  5327. return m.DeletedAt()
  5328. case batchmsg.FieldStatus:
  5329. return m.Status()
  5330. case batchmsg.FieldBatchNo:
  5331. return m.BatchNo()
  5332. case batchmsg.FieldTaskName:
  5333. return m.TaskName()
  5334. case batchmsg.FieldFromwxid:
  5335. return m.Fromwxid()
  5336. case batchmsg.FieldMsg:
  5337. return m.Msg()
  5338. case batchmsg.FieldTag:
  5339. return m.Tag()
  5340. case batchmsg.FieldTagids:
  5341. return m.Tagids()
  5342. case batchmsg.FieldTotal:
  5343. return m.Total()
  5344. case batchmsg.FieldSuccess:
  5345. return m.Success()
  5346. case batchmsg.FieldFail:
  5347. return m.Fail()
  5348. case batchmsg.FieldStartTime:
  5349. return m.StartTime()
  5350. case batchmsg.FieldStopTime:
  5351. return m.StopTime()
  5352. case batchmsg.FieldSendTime:
  5353. return m.SendTime()
  5354. case batchmsg.FieldType:
  5355. return m.GetType()
  5356. case batchmsg.FieldOrganizationID:
  5357. return m.OrganizationID()
  5358. case batchmsg.FieldCtype:
  5359. return m.Ctype()
  5360. case batchmsg.FieldCc:
  5361. return m.Cc()
  5362. case batchmsg.FieldPhone:
  5363. return m.Phone()
  5364. case batchmsg.FieldTemplateName:
  5365. return m.TemplateName()
  5366. case batchmsg.FieldTemplateCode:
  5367. return m.TemplateCode()
  5368. case batchmsg.FieldLang:
  5369. return m.Lang()
  5370. }
  5371. return nil, false
  5372. }
  5373. // OldField returns the old value of the field from the database. An error is
  5374. // returned if the mutation operation is not UpdateOne, or the query to the
  5375. // database failed.
  5376. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5377. switch name {
  5378. case batchmsg.FieldCreatedAt:
  5379. return m.OldCreatedAt(ctx)
  5380. case batchmsg.FieldUpdatedAt:
  5381. return m.OldUpdatedAt(ctx)
  5382. case batchmsg.FieldDeletedAt:
  5383. return m.OldDeletedAt(ctx)
  5384. case batchmsg.FieldStatus:
  5385. return m.OldStatus(ctx)
  5386. case batchmsg.FieldBatchNo:
  5387. return m.OldBatchNo(ctx)
  5388. case batchmsg.FieldTaskName:
  5389. return m.OldTaskName(ctx)
  5390. case batchmsg.FieldFromwxid:
  5391. return m.OldFromwxid(ctx)
  5392. case batchmsg.FieldMsg:
  5393. return m.OldMsg(ctx)
  5394. case batchmsg.FieldTag:
  5395. return m.OldTag(ctx)
  5396. case batchmsg.FieldTagids:
  5397. return m.OldTagids(ctx)
  5398. case batchmsg.FieldTotal:
  5399. return m.OldTotal(ctx)
  5400. case batchmsg.FieldSuccess:
  5401. return m.OldSuccess(ctx)
  5402. case batchmsg.FieldFail:
  5403. return m.OldFail(ctx)
  5404. case batchmsg.FieldStartTime:
  5405. return m.OldStartTime(ctx)
  5406. case batchmsg.FieldStopTime:
  5407. return m.OldStopTime(ctx)
  5408. case batchmsg.FieldSendTime:
  5409. return m.OldSendTime(ctx)
  5410. case batchmsg.FieldType:
  5411. return m.OldType(ctx)
  5412. case batchmsg.FieldOrganizationID:
  5413. return m.OldOrganizationID(ctx)
  5414. case batchmsg.FieldCtype:
  5415. return m.OldCtype(ctx)
  5416. case batchmsg.FieldCc:
  5417. return m.OldCc(ctx)
  5418. case batchmsg.FieldPhone:
  5419. return m.OldPhone(ctx)
  5420. case batchmsg.FieldTemplateName:
  5421. return m.OldTemplateName(ctx)
  5422. case batchmsg.FieldTemplateCode:
  5423. return m.OldTemplateCode(ctx)
  5424. case batchmsg.FieldLang:
  5425. return m.OldLang(ctx)
  5426. }
  5427. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5428. }
  5429. // SetField sets the value of a field with the given name. It returns an error if
  5430. // the field is not defined in the schema, or if the type mismatched the field
  5431. // type.
  5432. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5433. switch name {
  5434. case batchmsg.FieldCreatedAt:
  5435. v, ok := value.(time.Time)
  5436. if !ok {
  5437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5438. }
  5439. m.SetCreatedAt(v)
  5440. return nil
  5441. case batchmsg.FieldUpdatedAt:
  5442. v, ok := value.(time.Time)
  5443. if !ok {
  5444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5445. }
  5446. m.SetUpdatedAt(v)
  5447. return nil
  5448. case batchmsg.FieldDeletedAt:
  5449. v, ok := value.(time.Time)
  5450. if !ok {
  5451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5452. }
  5453. m.SetDeletedAt(v)
  5454. return nil
  5455. case batchmsg.FieldStatus:
  5456. v, ok := value.(uint8)
  5457. if !ok {
  5458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5459. }
  5460. m.SetStatus(v)
  5461. return nil
  5462. case batchmsg.FieldBatchNo:
  5463. v, ok := value.(string)
  5464. if !ok {
  5465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5466. }
  5467. m.SetBatchNo(v)
  5468. return nil
  5469. case batchmsg.FieldTaskName:
  5470. v, ok := value.(string)
  5471. if !ok {
  5472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5473. }
  5474. m.SetTaskName(v)
  5475. return nil
  5476. case batchmsg.FieldFromwxid:
  5477. v, ok := value.(string)
  5478. if !ok {
  5479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5480. }
  5481. m.SetFromwxid(v)
  5482. return nil
  5483. case batchmsg.FieldMsg:
  5484. v, ok := value.(string)
  5485. if !ok {
  5486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5487. }
  5488. m.SetMsg(v)
  5489. return nil
  5490. case batchmsg.FieldTag:
  5491. v, ok := value.(string)
  5492. if !ok {
  5493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5494. }
  5495. m.SetTag(v)
  5496. return nil
  5497. case batchmsg.FieldTagids:
  5498. v, ok := value.(string)
  5499. if !ok {
  5500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5501. }
  5502. m.SetTagids(v)
  5503. return nil
  5504. case batchmsg.FieldTotal:
  5505. v, ok := value.(int32)
  5506. if !ok {
  5507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5508. }
  5509. m.SetTotal(v)
  5510. return nil
  5511. case batchmsg.FieldSuccess:
  5512. v, ok := value.(int32)
  5513. if !ok {
  5514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5515. }
  5516. m.SetSuccess(v)
  5517. return nil
  5518. case batchmsg.FieldFail:
  5519. v, ok := value.(int32)
  5520. if !ok {
  5521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5522. }
  5523. m.SetFail(v)
  5524. return nil
  5525. case batchmsg.FieldStartTime:
  5526. v, ok := value.(time.Time)
  5527. if !ok {
  5528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5529. }
  5530. m.SetStartTime(v)
  5531. return nil
  5532. case batchmsg.FieldStopTime:
  5533. v, ok := value.(time.Time)
  5534. if !ok {
  5535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5536. }
  5537. m.SetStopTime(v)
  5538. return nil
  5539. case batchmsg.FieldSendTime:
  5540. v, ok := value.(time.Time)
  5541. if !ok {
  5542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5543. }
  5544. m.SetSendTime(v)
  5545. return nil
  5546. case batchmsg.FieldType:
  5547. v, ok := value.(int32)
  5548. if !ok {
  5549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5550. }
  5551. m.SetType(v)
  5552. return nil
  5553. case batchmsg.FieldOrganizationID:
  5554. v, ok := value.(uint64)
  5555. if !ok {
  5556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5557. }
  5558. m.SetOrganizationID(v)
  5559. return nil
  5560. case batchmsg.FieldCtype:
  5561. v, ok := value.(uint64)
  5562. if !ok {
  5563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5564. }
  5565. m.SetCtype(v)
  5566. return nil
  5567. case batchmsg.FieldCc:
  5568. v, ok := value.(string)
  5569. if !ok {
  5570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5571. }
  5572. m.SetCc(v)
  5573. return nil
  5574. case batchmsg.FieldPhone:
  5575. v, ok := value.(string)
  5576. if !ok {
  5577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5578. }
  5579. m.SetPhone(v)
  5580. return nil
  5581. case batchmsg.FieldTemplateName:
  5582. v, ok := value.(string)
  5583. if !ok {
  5584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5585. }
  5586. m.SetTemplateName(v)
  5587. return nil
  5588. case batchmsg.FieldTemplateCode:
  5589. v, ok := value.(string)
  5590. if !ok {
  5591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5592. }
  5593. m.SetTemplateCode(v)
  5594. return nil
  5595. case batchmsg.FieldLang:
  5596. v, ok := value.(string)
  5597. if !ok {
  5598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5599. }
  5600. m.SetLang(v)
  5601. return nil
  5602. }
  5603. return fmt.Errorf("unknown BatchMsg field %s", name)
  5604. }
  5605. // AddedFields returns all numeric fields that were incremented/decremented during
  5606. // this mutation.
  5607. func (m *BatchMsgMutation) AddedFields() []string {
  5608. var fields []string
  5609. if m.addstatus != nil {
  5610. fields = append(fields, batchmsg.FieldStatus)
  5611. }
  5612. if m.addtotal != nil {
  5613. fields = append(fields, batchmsg.FieldTotal)
  5614. }
  5615. if m.addsuccess != nil {
  5616. fields = append(fields, batchmsg.FieldSuccess)
  5617. }
  5618. if m.addfail != nil {
  5619. fields = append(fields, batchmsg.FieldFail)
  5620. }
  5621. if m.add_type != nil {
  5622. fields = append(fields, batchmsg.FieldType)
  5623. }
  5624. if m.addorganization_id != nil {
  5625. fields = append(fields, batchmsg.FieldOrganizationID)
  5626. }
  5627. if m.addctype != nil {
  5628. fields = append(fields, batchmsg.FieldCtype)
  5629. }
  5630. return fields
  5631. }
  5632. // AddedField returns the numeric value that was incremented/decremented on a field
  5633. // with the given name. The second boolean return value indicates that this field
  5634. // was not set, or was not defined in the schema.
  5635. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5636. switch name {
  5637. case batchmsg.FieldStatus:
  5638. return m.AddedStatus()
  5639. case batchmsg.FieldTotal:
  5640. return m.AddedTotal()
  5641. case batchmsg.FieldSuccess:
  5642. return m.AddedSuccess()
  5643. case batchmsg.FieldFail:
  5644. return m.AddedFail()
  5645. case batchmsg.FieldType:
  5646. return m.AddedType()
  5647. case batchmsg.FieldOrganizationID:
  5648. return m.AddedOrganizationID()
  5649. case batchmsg.FieldCtype:
  5650. return m.AddedCtype()
  5651. }
  5652. return nil, false
  5653. }
  5654. // AddField adds the value to the field with the given name. It returns an error if
  5655. // the field is not defined in the schema, or if the type mismatched the field
  5656. // type.
  5657. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5658. switch name {
  5659. case batchmsg.FieldStatus:
  5660. v, ok := value.(int8)
  5661. if !ok {
  5662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5663. }
  5664. m.AddStatus(v)
  5665. return nil
  5666. case batchmsg.FieldTotal:
  5667. v, ok := value.(int32)
  5668. if !ok {
  5669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5670. }
  5671. m.AddTotal(v)
  5672. return nil
  5673. case batchmsg.FieldSuccess:
  5674. v, ok := value.(int32)
  5675. if !ok {
  5676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5677. }
  5678. m.AddSuccess(v)
  5679. return nil
  5680. case batchmsg.FieldFail:
  5681. v, ok := value.(int32)
  5682. if !ok {
  5683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5684. }
  5685. m.AddFail(v)
  5686. return nil
  5687. case batchmsg.FieldType:
  5688. v, ok := value.(int32)
  5689. if !ok {
  5690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5691. }
  5692. m.AddType(v)
  5693. return nil
  5694. case batchmsg.FieldOrganizationID:
  5695. v, ok := value.(int64)
  5696. if !ok {
  5697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5698. }
  5699. m.AddOrganizationID(v)
  5700. return nil
  5701. case batchmsg.FieldCtype:
  5702. v, ok := value.(int64)
  5703. if !ok {
  5704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5705. }
  5706. m.AddCtype(v)
  5707. return nil
  5708. }
  5709. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5710. }
  5711. // ClearedFields returns all nullable fields that were cleared during this
  5712. // mutation.
  5713. func (m *BatchMsgMutation) ClearedFields() []string {
  5714. var fields []string
  5715. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5716. fields = append(fields, batchmsg.FieldDeletedAt)
  5717. }
  5718. if m.FieldCleared(batchmsg.FieldStatus) {
  5719. fields = append(fields, batchmsg.FieldStatus)
  5720. }
  5721. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5722. fields = append(fields, batchmsg.FieldBatchNo)
  5723. }
  5724. if m.FieldCleared(batchmsg.FieldTaskName) {
  5725. fields = append(fields, batchmsg.FieldTaskName)
  5726. }
  5727. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5728. fields = append(fields, batchmsg.FieldFromwxid)
  5729. }
  5730. if m.FieldCleared(batchmsg.FieldMsg) {
  5731. fields = append(fields, batchmsg.FieldMsg)
  5732. }
  5733. if m.FieldCleared(batchmsg.FieldTag) {
  5734. fields = append(fields, batchmsg.FieldTag)
  5735. }
  5736. if m.FieldCleared(batchmsg.FieldTagids) {
  5737. fields = append(fields, batchmsg.FieldTagids)
  5738. }
  5739. if m.FieldCleared(batchmsg.FieldTotal) {
  5740. fields = append(fields, batchmsg.FieldTotal)
  5741. }
  5742. if m.FieldCleared(batchmsg.FieldSuccess) {
  5743. fields = append(fields, batchmsg.FieldSuccess)
  5744. }
  5745. if m.FieldCleared(batchmsg.FieldFail) {
  5746. fields = append(fields, batchmsg.FieldFail)
  5747. }
  5748. if m.FieldCleared(batchmsg.FieldStartTime) {
  5749. fields = append(fields, batchmsg.FieldStartTime)
  5750. }
  5751. if m.FieldCleared(batchmsg.FieldStopTime) {
  5752. fields = append(fields, batchmsg.FieldStopTime)
  5753. }
  5754. if m.FieldCleared(batchmsg.FieldSendTime) {
  5755. fields = append(fields, batchmsg.FieldSendTime)
  5756. }
  5757. if m.FieldCleared(batchmsg.FieldType) {
  5758. fields = append(fields, batchmsg.FieldType)
  5759. }
  5760. if m.FieldCleared(batchmsg.FieldCc) {
  5761. fields = append(fields, batchmsg.FieldCc)
  5762. }
  5763. if m.FieldCleared(batchmsg.FieldPhone) {
  5764. fields = append(fields, batchmsg.FieldPhone)
  5765. }
  5766. if m.FieldCleared(batchmsg.FieldTemplateName) {
  5767. fields = append(fields, batchmsg.FieldTemplateName)
  5768. }
  5769. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  5770. fields = append(fields, batchmsg.FieldTemplateCode)
  5771. }
  5772. if m.FieldCleared(batchmsg.FieldLang) {
  5773. fields = append(fields, batchmsg.FieldLang)
  5774. }
  5775. return fields
  5776. }
  5777. // FieldCleared returns a boolean indicating if a field with the given name was
  5778. // cleared in this mutation.
  5779. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5780. _, ok := m.clearedFields[name]
  5781. return ok
  5782. }
  5783. // ClearField clears the value of the field with the given name. It returns an
  5784. // error if the field is not defined in the schema.
  5785. func (m *BatchMsgMutation) ClearField(name string) error {
  5786. switch name {
  5787. case batchmsg.FieldDeletedAt:
  5788. m.ClearDeletedAt()
  5789. return nil
  5790. case batchmsg.FieldStatus:
  5791. m.ClearStatus()
  5792. return nil
  5793. case batchmsg.FieldBatchNo:
  5794. m.ClearBatchNo()
  5795. return nil
  5796. case batchmsg.FieldTaskName:
  5797. m.ClearTaskName()
  5798. return nil
  5799. case batchmsg.FieldFromwxid:
  5800. m.ClearFromwxid()
  5801. return nil
  5802. case batchmsg.FieldMsg:
  5803. m.ClearMsg()
  5804. return nil
  5805. case batchmsg.FieldTag:
  5806. m.ClearTag()
  5807. return nil
  5808. case batchmsg.FieldTagids:
  5809. m.ClearTagids()
  5810. return nil
  5811. case batchmsg.FieldTotal:
  5812. m.ClearTotal()
  5813. return nil
  5814. case batchmsg.FieldSuccess:
  5815. m.ClearSuccess()
  5816. return nil
  5817. case batchmsg.FieldFail:
  5818. m.ClearFail()
  5819. return nil
  5820. case batchmsg.FieldStartTime:
  5821. m.ClearStartTime()
  5822. return nil
  5823. case batchmsg.FieldStopTime:
  5824. m.ClearStopTime()
  5825. return nil
  5826. case batchmsg.FieldSendTime:
  5827. m.ClearSendTime()
  5828. return nil
  5829. case batchmsg.FieldType:
  5830. m.ClearType()
  5831. return nil
  5832. case batchmsg.FieldCc:
  5833. m.ClearCc()
  5834. return nil
  5835. case batchmsg.FieldPhone:
  5836. m.ClearPhone()
  5837. return nil
  5838. case batchmsg.FieldTemplateName:
  5839. m.ClearTemplateName()
  5840. return nil
  5841. case batchmsg.FieldTemplateCode:
  5842. m.ClearTemplateCode()
  5843. return nil
  5844. case batchmsg.FieldLang:
  5845. m.ClearLang()
  5846. return nil
  5847. }
  5848. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5849. }
  5850. // ResetField resets all changes in the mutation for the field with the given name.
  5851. // It returns an error if the field is not defined in the schema.
  5852. func (m *BatchMsgMutation) ResetField(name string) error {
  5853. switch name {
  5854. case batchmsg.FieldCreatedAt:
  5855. m.ResetCreatedAt()
  5856. return nil
  5857. case batchmsg.FieldUpdatedAt:
  5858. m.ResetUpdatedAt()
  5859. return nil
  5860. case batchmsg.FieldDeletedAt:
  5861. m.ResetDeletedAt()
  5862. return nil
  5863. case batchmsg.FieldStatus:
  5864. m.ResetStatus()
  5865. return nil
  5866. case batchmsg.FieldBatchNo:
  5867. m.ResetBatchNo()
  5868. return nil
  5869. case batchmsg.FieldTaskName:
  5870. m.ResetTaskName()
  5871. return nil
  5872. case batchmsg.FieldFromwxid:
  5873. m.ResetFromwxid()
  5874. return nil
  5875. case batchmsg.FieldMsg:
  5876. m.ResetMsg()
  5877. return nil
  5878. case batchmsg.FieldTag:
  5879. m.ResetTag()
  5880. return nil
  5881. case batchmsg.FieldTagids:
  5882. m.ResetTagids()
  5883. return nil
  5884. case batchmsg.FieldTotal:
  5885. m.ResetTotal()
  5886. return nil
  5887. case batchmsg.FieldSuccess:
  5888. m.ResetSuccess()
  5889. return nil
  5890. case batchmsg.FieldFail:
  5891. m.ResetFail()
  5892. return nil
  5893. case batchmsg.FieldStartTime:
  5894. m.ResetStartTime()
  5895. return nil
  5896. case batchmsg.FieldStopTime:
  5897. m.ResetStopTime()
  5898. return nil
  5899. case batchmsg.FieldSendTime:
  5900. m.ResetSendTime()
  5901. return nil
  5902. case batchmsg.FieldType:
  5903. m.ResetType()
  5904. return nil
  5905. case batchmsg.FieldOrganizationID:
  5906. m.ResetOrganizationID()
  5907. return nil
  5908. case batchmsg.FieldCtype:
  5909. m.ResetCtype()
  5910. return nil
  5911. case batchmsg.FieldCc:
  5912. m.ResetCc()
  5913. return nil
  5914. case batchmsg.FieldPhone:
  5915. m.ResetPhone()
  5916. return nil
  5917. case batchmsg.FieldTemplateName:
  5918. m.ResetTemplateName()
  5919. return nil
  5920. case batchmsg.FieldTemplateCode:
  5921. m.ResetTemplateCode()
  5922. return nil
  5923. case batchmsg.FieldLang:
  5924. m.ResetLang()
  5925. return nil
  5926. }
  5927. return fmt.Errorf("unknown BatchMsg field %s", name)
  5928. }
  5929. // AddedEdges returns all edge names that were set/added in this mutation.
  5930. func (m *BatchMsgMutation) AddedEdges() []string {
  5931. edges := make([]string, 0, 0)
  5932. return edges
  5933. }
  5934. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5935. // name in this mutation.
  5936. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5937. return nil
  5938. }
  5939. // RemovedEdges returns all edge names that were removed in this mutation.
  5940. func (m *BatchMsgMutation) RemovedEdges() []string {
  5941. edges := make([]string, 0, 0)
  5942. return edges
  5943. }
  5944. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5945. // the given name in this mutation.
  5946. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5947. return nil
  5948. }
  5949. // ClearedEdges returns all edge names that were cleared in this mutation.
  5950. func (m *BatchMsgMutation) ClearedEdges() []string {
  5951. edges := make([]string, 0, 0)
  5952. return edges
  5953. }
  5954. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5955. // was cleared in this mutation.
  5956. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5957. return false
  5958. }
  5959. // ClearEdge clears the value of the edge with the given name. It returns an error
  5960. // if that edge is not defined in the schema.
  5961. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5962. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5963. }
  5964. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5965. // It returns an error if the edge is not defined in the schema.
  5966. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5967. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5968. }
  5969. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5970. type CategoryMutation struct {
  5971. config
  5972. op Op
  5973. typ string
  5974. id *uint64
  5975. created_at *time.Time
  5976. updated_at *time.Time
  5977. deleted_at *time.Time
  5978. name *string
  5979. organization_id *uint64
  5980. addorganization_id *int64
  5981. clearedFields map[string]struct{}
  5982. done bool
  5983. oldValue func(context.Context) (*Category, error)
  5984. predicates []predicate.Category
  5985. }
  5986. var _ ent.Mutation = (*CategoryMutation)(nil)
  5987. // categoryOption allows management of the mutation configuration using functional options.
  5988. type categoryOption func(*CategoryMutation)
  5989. // newCategoryMutation creates new mutation for the Category entity.
  5990. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5991. m := &CategoryMutation{
  5992. config: c,
  5993. op: op,
  5994. typ: TypeCategory,
  5995. clearedFields: make(map[string]struct{}),
  5996. }
  5997. for _, opt := range opts {
  5998. opt(m)
  5999. }
  6000. return m
  6001. }
  6002. // withCategoryID sets the ID field of the mutation.
  6003. func withCategoryID(id uint64) categoryOption {
  6004. return func(m *CategoryMutation) {
  6005. var (
  6006. err error
  6007. once sync.Once
  6008. value *Category
  6009. )
  6010. m.oldValue = func(ctx context.Context) (*Category, error) {
  6011. once.Do(func() {
  6012. if m.done {
  6013. err = errors.New("querying old values post mutation is not allowed")
  6014. } else {
  6015. value, err = m.Client().Category.Get(ctx, id)
  6016. }
  6017. })
  6018. return value, err
  6019. }
  6020. m.id = &id
  6021. }
  6022. }
  6023. // withCategory sets the old Category of the mutation.
  6024. func withCategory(node *Category) categoryOption {
  6025. return func(m *CategoryMutation) {
  6026. m.oldValue = func(context.Context) (*Category, error) {
  6027. return node, nil
  6028. }
  6029. m.id = &node.ID
  6030. }
  6031. }
  6032. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6033. // executed in a transaction (ent.Tx), a transactional client is returned.
  6034. func (m CategoryMutation) Client() *Client {
  6035. client := &Client{config: m.config}
  6036. client.init()
  6037. return client
  6038. }
  6039. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6040. // it returns an error otherwise.
  6041. func (m CategoryMutation) Tx() (*Tx, error) {
  6042. if _, ok := m.driver.(*txDriver); !ok {
  6043. return nil, errors.New("ent: mutation is not running in a transaction")
  6044. }
  6045. tx := &Tx{config: m.config}
  6046. tx.init()
  6047. return tx, nil
  6048. }
  6049. // SetID sets the value of the id field. Note that this
  6050. // operation is only accepted on creation of Category entities.
  6051. func (m *CategoryMutation) SetID(id uint64) {
  6052. m.id = &id
  6053. }
  6054. // ID returns the ID value in the mutation. Note that the ID is only available
  6055. // if it was provided to the builder or after it was returned from the database.
  6056. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  6057. if m.id == nil {
  6058. return
  6059. }
  6060. return *m.id, true
  6061. }
  6062. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6063. // That means, if the mutation is applied within a transaction with an isolation level such
  6064. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6065. // or updated by the mutation.
  6066. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  6067. switch {
  6068. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6069. id, exists := m.ID()
  6070. if exists {
  6071. return []uint64{id}, nil
  6072. }
  6073. fallthrough
  6074. case m.op.Is(OpUpdate | OpDelete):
  6075. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  6076. default:
  6077. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6078. }
  6079. }
  6080. // SetCreatedAt sets the "created_at" field.
  6081. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  6082. m.created_at = &t
  6083. }
  6084. // CreatedAt returns the value of the "created_at" field in the mutation.
  6085. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  6086. v := m.created_at
  6087. if v == nil {
  6088. return
  6089. }
  6090. return *v, true
  6091. }
  6092. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  6093. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6095. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6096. if !m.op.Is(OpUpdateOne) {
  6097. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6098. }
  6099. if m.id == nil || m.oldValue == nil {
  6100. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6101. }
  6102. oldValue, err := m.oldValue(ctx)
  6103. if err != nil {
  6104. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6105. }
  6106. return oldValue.CreatedAt, nil
  6107. }
  6108. // ResetCreatedAt resets all changes to the "created_at" field.
  6109. func (m *CategoryMutation) ResetCreatedAt() {
  6110. m.created_at = nil
  6111. }
  6112. // SetUpdatedAt sets the "updated_at" field.
  6113. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  6114. m.updated_at = &t
  6115. }
  6116. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6117. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  6118. v := m.updated_at
  6119. if v == nil {
  6120. return
  6121. }
  6122. return *v, true
  6123. }
  6124. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  6125. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6127. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6128. if !m.op.Is(OpUpdateOne) {
  6129. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6130. }
  6131. if m.id == nil || m.oldValue == nil {
  6132. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6133. }
  6134. oldValue, err := m.oldValue(ctx)
  6135. if err != nil {
  6136. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6137. }
  6138. return oldValue.UpdatedAt, nil
  6139. }
  6140. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6141. func (m *CategoryMutation) ResetUpdatedAt() {
  6142. m.updated_at = nil
  6143. }
  6144. // SetDeletedAt sets the "deleted_at" field.
  6145. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  6146. m.deleted_at = &t
  6147. }
  6148. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6149. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  6150. v := m.deleted_at
  6151. if v == nil {
  6152. return
  6153. }
  6154. return *v, true
  6155. }
  6156. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  6157. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6159. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6160. if !m.op.Is(OpUpdateOne) {
  6161. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6162. }
  6163. if m.id == nil || m.oldValue == nil {
  6164. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6165. }
  6166. oldValue, err := m.oldValue(ctx)
  6167. if err != nil {
  6168. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6169. }
  6170. return oldValue.DeletedAt, nil
  6171. }
  6172. // ClearDeletedAt clears the value of the "deleted_at" field.
  6173. func (m *CategoryMutation) ClearDeletedAt() {
  6174. m.deleted_at = nil
  6175. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  6176. }
  6177. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6178. func (m *CategoryMutation) DeletedAtCleared() bool {
  6179. _, ok := m.clearedFields[category.FieldDeletedAt]
  6180. return ok
  6181. }
  6182. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6183. func (m *CategoryMutation) ResetDeletedAt() {
  6184. m.deleted_at = nil
  6185. delete(m.clearedFields, category.FieldDeletedAt)
  6186. }
  6187. // SetName sets the "name" field.
  6188. func (m *CategoryMutation) SetName(s string) {
  6189. m.name = &s
  6190. }
  6191. // Name returns the value of the "name" field in the mutation.
  6192. func (m *CategoryMutation) Name() (r string, exists bool) {
  6193. v := m.name
  6194. if v == nil {
  6195. return
  6196. }
  6197. return *v, true
  6198. }
  6199. // OldName returns the old "name" field's value of the Category entity.
  6200. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6202. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  6203. if !m.op.Is(OpUpdateOne) {
  6204. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6205. }
  6206. if m.id == nil || m.oldValue == nil {
  6207. return v, errors.New("OldName requires an ID field in the mutation")
  6208. }
  6209. oldValue, err := m.oldValue(ctx)
  6210. if err != nil {
  6211. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6212. }
  6213. return oldValue.Name, nil
  6214. }
  6215. // ResetName resets all changes to the "name" field.
  6216. func (m *CategoryMutation) ResetName() {
  6217. m.name = nil
  6218. }
  6219. // SetOrganizationID sets the "organization_id" field.
  6220. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  6221. m.organization_id = &u
  6222. m.addorganization_id = nil
  6223. }
  6224. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6225. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  6226. v := m.organization_id
  6227. if v == nil {
  6228. return
  6229. }
  6230. return *v, true
  6231. }
  6232. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  6233. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  6234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6235. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6236. if !m.op.Is(OpUpdateOne) {
  6237. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6238. }
  6239. if m.id == nil || m.oldValue == nil {
  6240. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6241. }
  6242. oldValue, err := m.oldValue(ctx)
  6243. if err != nil {
  6244. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6245. }
  6246. return oldValue.OrganizationID, nil
  6247. }
  6248. // AddOrganizationID adds u to the "organization_id" field.
  6249. func (m *CategoryMutation) AddOrganizationID(u int64) {
  6250. if m.addorganization_id != nil {
  6251. *m.addorganization_id += u
  6252. } else {
  6253. m.addorganization_id = &u
  6254. }
  6255. }
  6256. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6257. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  6258. v := m.addorganization_id
  6259. if v == nil {
  6260. return
  6261. }
  6262. return *v, true
  6263. }
  6264. // ResetOrganizationID resets all changes to the "organization_id" field.
  6265. func (m *CategoryMutation) ResetOrganizationID() {
  6266. m.organization_id = nil
  6267. m.addorganization_id = nil
  6268. }
  6269. // Where appends a list predicates to the CategoryMutation builder.
  6270. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  6271. m.predicates = append(m.predicates, ps...)
  6272. }
  6273. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  6274. // users can use type-assertion to append predicates that do not depend on any generated package.
  6275. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  6276. p := make([]predicate.Category, len(ps))
  6277. for i := range ps {
  6278. p[i] = ps[i]
  6279. }
  6280. m.Where(p...)
  6281. }
  6282. // Op returns the operation name.
  6283. func (m *CategoryMutation) Op() Op {
  6284. return m.op
  6285. }
  6286. // SetOp allows setting the mutation operation.
  6287. func (m *CategoryMutation) SetOp(op Op) {
  6288. m.op = op
  6289. }
  6290. // Type returns the node type of this mutation (Category).
  6291. func (m *CategoryMutation) Type() string {
  6292. return m.typ
  6293. }
  6294. // Fields returns all fields that were changed during this mutation. Note that in
  6295. // order to get all numeric fields that were incremented/decremented, call
  6296. // AddedFields().
  6297. func (m *CategoryMutation) Fields() []string {
  6298. fields := make([]string, 0, 5)
  6299. if m.created_at != nil {
  6300. fields = append(fields, category.FieldCreatedAt)
  6301. }
  6302. if m.updated_at != nil {
  6303. fields = append(fields, category.FieldUpdatedAt)
  6304. }
  6305. if m.deleted_at != nil {
  6306. fields = append(fields, category.FieldDeletedAt)
  6307. }
  6308. if m.name != nil {
  6309. fields = append(fields, category.FieldName)
  6310. }
  6311. if m.organization_id != nil {
  6312. fields = append(fields, category.FieldOrganizationID)
  6313. }
  6314. return fields
  6315. }
  6316. // Field returns the value of a field with the given name. The second boolean
  6317. // return value indicates that this field was not set, or was not defined in the
  6318. // schema.
  6319. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  6320. switch name {
  6321. case category.FieldCreatedAt:
  6322. return m.CreatedAt()
  6323. case category.FieldUpdatedAt:
  6324. return m.UpdatedAt()
  6325. case category.FieldDeletedAt:
  6326. return m.DeletedAt()
  6327. case category.FieldName:
  6328. return m.Name()
  6329. case category.FieldOrganizationID:
  6330. return m.OrganizationID()
  6331. }
  6332. return nil, false
  6333. }
  6334. // OldField returns the old value of the field from the database. An error is
  6335. // returned if the mutation operation is not UpdateOne, or the query to the
  6336. // database failed.
  6337. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6338. switch name {
  6339. case category.FieldCreatedAt:
  6340. return m.OldCreatedAt(ctx)
  6341. case category.FieldUpdatedAt:
  6342. return m.OldUpdatedAt(ctx)
  6343. case category.FieldDeletedAt:
  6344. return m.OldDeletedAt(ctx)
  6345. case category.FieldName:
  6346. return m.OldName(ctx)
  6347. case category.FieldOrganizationID:
  6348. return m.OldOrganizationID(ctx)
  6349. }
  6350. return nil, fmt.Errorf("unknown Category field %s", name)
  6351. }
  6352. // SetField sets the value of a field with the given name. It returns an error if
  6353. // the field is not defined in the schema, or if the type mismatched the field
  6354. // type.
  6355. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  6356. switch name {
  6357. case category.FieldCreatedAt:
  6358. v, ok := value.(time.Time)
  6359. if !ok {
  6360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6361. }
  6362. m.SetCreatedAt(v)
  6363. return nil
  6364. case category.FieldUpdatedAt:
  6365. v, ok := value.(time.Time)
  6366. if !ok {
  6367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6368. }
  6369. m.SetUpdatedAt(v)
  6370. return nil
  6371. case category.FieldDeletedAt:
  6372. v, ok := value.(time.Time)
  6373. if !ok {
  6374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6375. }
  6376. m.SetDeletedAt(v)
  6377. return nil
  6378. case category.FieldName:
  6379. v, ok := value.(string)
  6380. if !ok {
  6381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6382. }
  6383. m.SetName(v)
  6384. return nil
  6385. case category.FieldOrganizationID:
  6386. v, ok := value.(uint64)
  6387. if !ok {
  6388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6389. }
  6390. m.SetOrganizationID(v)
  6391. return nil
  6392. }
  6393. return fmt.Errorf("unknown Category field %s", name)
  6394. }
  6395. // AddedFields returns all numeric fields that were incremented/decremented during
  6396. // this mutation.
  6397. func (m *CategoryMutation) AddedFields() []string {
  6398. var fields []string
  6399. if m.addorganization_id != nil {
  6400. fields = append(fields, category.FieldOrganizationID)
  6401. }
  6402. return fields
  6403. }
  6404. // AddedField returns the numeric value that was incremented/decremented on a field
  6405. // with the given name. The second boolean return value indicates that this field
  6406. // was not set, or was not defined in the schema.
  6407. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  6408. switch name {
  6409. case category.FieldOrganizationID:
  6410. return m.AddedOrganizationID()
  6411. }
  6412. return nil, false
  6413. }
  6414. // AddField adds the value to the field with the given name. It returns an error if
  6415. // the field is not defined in the schema, or if the type mismatched the field
  6416. // type.
  6417. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  6418. switch name {
  6419. case category.FieldOrganizationID:
  6420. v, ok := value.(int64)
  6421. if !ok {
  6422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6423. }
  6424. m.AddOrganizationID(v)
  6425. return nil
  6426. }
  6427. return fmt.Errorf("unknown Category numeric field %s", name)
  6428. }
  6429. // ClearedFields returns all nullable fields that were cleared during this
  6430. // mutation.
  6431. func (m *CategoryMutation) ClearedFields() []string {
  6432. var fields []string
  6433. if m.FieldCleared(category.FieldDeletedAt) {
  6434. fields = append(fields, category.FieldDeletedAt)
  6435. }
  6436. return fields
  6437. }
  6438. // FieldCleared returns a boolean indicating if a field with the given name was
  6439. // cleared in this mutation.
  6440. func (m *CategoryMutation) FieldCleared(name string) bool {
  6441. _, ok := m.clearedFields[name]
  6442. return ok
  6443. }
  6444. // ClearField clears the value of the field with the given name. It returns an
  6445. // error if the field is not defined in the schema.
  6446. func (m *CategoryMutation) ClearField(name string) error {
  6447. switch name {
  6448. case category.FieldDeletedAt:
  6449. m.ClearDeletedAt()
  6450. return nil
  6451. }
  6452. return fmt.Errorf("unknown Category nullable field %s", name)
  6453. }
  6454. // ResetField resets all changes in the mutation for the field with the given name.
  6455. // It returns an error if the field is not defined in the schema.
  6456. func (m *CategoryMutation) ResetField(name string) error {
  6457. switch name {
  6458. case category.FieldCreatedAt:
  6459. m.ResetCreatedAt()
  6460. return nil
  6461. case category.FieldUpdatedAt:
  6462. m.ResetUpdatedAt()
  6463. return nil
  6464. case category.FieldDeletedAt:
  6465. m.ResetDeletedAt()
  6466. return nil
  6467. case category.FieldName:
  6468. m.ResetName()
  6469. return nil
  6470. case category.FieldOrganizationID:
  6471. m.ResetOrganizationID()
  6472. return nil
  6473. }
  6474. return fmt.Errorf("unknown Category field %s", name)
  6475. }
  6476. // AddedEdges returns all edge names that were set/added in this mutation.
  6477. func (m *CategoryMutation) AddedEdges() []string {
  6478. edges := make([]string, 0, 0)
  6479. return edges
  6480. }
  6481. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6482. // name in this mutation.
  6483. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  6484. return nil
  6485. }
  6486. // RemovedEdges returns all edge names that were removed in this mutation.
  6487. func (m *CategoryMutation) RemovedEdges() []string {
  6488. edges := make([]string, 0, 0)
  6489. return edges
  6490. }
  6491. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6492. // the given name in this mutation.
  6493. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  6494. return nil
  6495. }
  6496. // ClearedEdges returns all edge names that were cleared in this mutation.
  6497. func (m *CategoryMutation) ClearedEdges() []string {
  6498. edges := make([]string, 0, 0)
  6499. return edges
  6500. }
  6501. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6502. // was cleared in this mutation.
  6503. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6504. return false
  6505. }
  6506. // ClearEdge clears the value of the edge with the given name. It returns an error
  6507. // if that edge is not defined in the schema.
  6508. func (m *CategoryMutation) ClearEdge(name string) error {
  6509. return fmt.Errorf("unknown Category unique edge %s", name)
  6510. }
  6511. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6512. // It returns an error if the edge is not defined in the schema.
  6513. func (m *CategoryMutation) ResetEdge(name string) error {
  6514. return fmt.Errorf("unknown Category edge %s", name)
  6515. }
  6516. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6517. type ChatRecordsMutation struct {
  6518. config
  6519. op Op
  6520. typ string
  6521. id *uint64
  6522. created_at *time.Time
  6523. updated_at *time.Time
  6524. deleted_at *time.Time
  6525. content *string
  6526. content_type *uint8
  6527. addcontent_type *int8
  6528. session_id *uint64
  6529. addsession_id *int64
  6530. user_id *uint64
  6531. adduser_id *int64
  6532. bot_id *uint64
  6533. addbot_id *int64
  6534. bot_type *uint8
  6535. addbot_type *int8
  6536. clearedFields map[string]struct{}
  6537. done bool
  6538. oldValue func(context.Context) (*ChatRecords, error)
  6539. predicates []predicate.ChatRecords
  6540. }
  6541. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6542. // chatrecordsOption allows management of the mutation configuration using functional options.
  6543. type chatrecordsOption func(*ChatRecordsMutation)
  6544. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6545. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6546. m := &ChatRecordsMutation{
  6547. config: c,
  6548. op: op,
  6549. typ: TypeChatRecords,
  6550. clearedFields: make(map[string]struct{}),
  6551. }
  6552. for _, opt := range opts {
  6553. opt(m)
  6554. }
  6555. return m
  6556. }
  6557. // withChatRecordsID sets the ID field of the mutation.
  6558. func withChatRecordsID(id uint64) chatrecordsOption {
  6559. return func(m *ChatRecordsMutation) {
  6560. var (
  6561. err error
  6562. once sync.Once
  6563. value *ChatRecords
  6564. )
  6565. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6566. once.Do(func() {
  6567. if m.done {
  6568. err = errors.New("querying old values post mutation is not allowed")
  6569. } else {
  6570. value, err = m.Client().ChatRecords.Get(ctx, id)
  6571. }
  6572. })
  6573. return value, err
  6574. }
  6575. m.id = &id
  6576. }
  6577. }
  6578. // withChatRecords sets the old ChatRecords of the mutation.
  6579. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6580. return func(m *ChatRecordsMutation) {
  6581. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6582. return node, nil
  6583. }
  6584. m.id = &node.ID
  6585. }
  6586. }
  6587. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6588. // executed in a transaction (ent.Tx), a transactional client is returned.
  6589. func (m ChatRecordsMutation) Client() *Client {
  6590. client := &Client{config: m.config}
  6591. client.init()
  6592. return client
  6593. }
  6594. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6595. // it returns an error otherwise.
  6596. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6597. if _, ok := m.driver.(*txDriver); !ok {
  6598. return nil, errors.New("ent: mutation is not running in a transaction")
  6599. }
  6600. tx := &Tx{config: m.config}
  6601. tx.init()
  6602. return tx, nil
  6603. }
  6604. // SetID sets the value of the id field. Note that this
  6605. // operation is only accepted on creation of ChatRecords entities.
  6606. func (m *ChatRecordsMutation) SetID(id uint64) {
  6607. m.id = &id
  6608. }
  6609. // ID returns the ID value in the mutation. Note that the ID is only available
  6610. // if it was provided to the builder or after it was returned from the database.
  6611. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6612. if m.id == nil {
  6613. return
  6614. }
  6615. return *m.id, true
  6616. }
  6617. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6618. // That means, if the mutation is applied within a transaction with an isolation level such
  6619. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6620. // or updated by the mutation.
  6621. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6622. switch {
  6623. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6624. id, exists := m.ID()
  6625. if exists {
  6626. return []uint64{id}, nil
  6627. }
  6628. fallthrough
  6629. case m.op.Is(OpUpdate | OpDelete):
  6630. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6631. default:
  6632. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6633. }
  6634. }
  6635. // SetCreatedAt sets the "created_at" field.
  6636. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6637. m.created_at = &t
  6638. }
  6639. // CreatedAt returns the value of the "created_at" field in the mutation.
  6640. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6641. v := m.created_at
  6642. if v == nil {
  6643. return
  6644. }
  6645. return *v, true
  6646. }
  6647. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6648. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6650. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6651. if !m.op.Is(OpUpdateOne) {
  6652. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6653. }
  6654. if m.id == nil || m.oldValue == nil {
  6655. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6656. }
  6657. oldValue, err := m.oldValue(ctx)
  6658. if err != nil {
  6659. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6660. }
  6661. return oldValue.CreatedAt, nil
  6662. }
  6663. // ResetCreatedAt resets all changes to the "created_at" field.
  6664. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6665. m.created_at = nil
  6666. }
  6667. // SetUpdatedAt sets the "updated_at" field.
  6668. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6669. m.updated_at = &t
  6670. }
  6671. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6672. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6673. v := m.updated_at
  6674. if v == nil {
  6675. return
  6676. }
  6677. return *v, true
  6678. }
  6679. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6680. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6682. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6683. if !m.op.Is(OpUpdateOne) {
  6684. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6685. }
  6686. if m.id == nil || m.oldValue == nil {
  6687. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6688. }
  6689. oldValue, err := m.oldValue(ctx)
  6690. if err != nil {
  6691. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6692. }
  6693. return oldValue.UpdatedAt, nil
  6694. }
  6695. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6696. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6697. m.updated_at = nil
  6698. }
  6699. // SetDeletedAt sets the "deleted_at" field.
  6700. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6701. m.deleted_at = &t
  6702. }
  6703. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6704. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6705. v := m.deleted_at
  6706. if v == nil {
  6707. return
  6708. }
  6709. return *v, true
  6710. }
  6711. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6712. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6714. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6715. if !m.op.Is(OpUpdateOne) {
  6716. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6717. }
  6718. if m.id == nil || m.oldValue == nil {
  6719. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6720. }
  6721. oldValue, err := m.oldValue(ctx)
  6722. if err != nil {
  6723. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6724. }
  6725. return oldValue.DeletedAt, nil
  6726. }
  6727. // ClearDeletedAt clears the value of the "deleted_at" field.
  6728. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6729. m.deleted_at = nil
  6730. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6731. }
  6732. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6733. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6734. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6735. return ok
  6736. }
  6737. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6738. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6739. m.deleted_at = nil
  6740. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6741. }
  6742. // SetContent sets the "content" field.
  6743. func (m *ChatRecordsMutation) SetContent(s string) {
  6744. m.content = &s
  6745. }
  6746. // Content returns the value of the "content" field in the mutation.
  6747. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6748. v := m.content
  6749. if v == nil {
  6750. return
  6751. }
  6752. return *v, true
  6753. }
  6754. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6755. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6757. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6758. if !m.op.Is(OpUpdateOne) {
  6759. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6760. }
  6761. if m.id == nil || m.oldValue == nil {
  6762. return v, errors.New("OldContent requires an ID field in the mutation")
  6763. }
  6764. oldValue, err := m.oldValue(ctx)
  6765. if err != nil {
  6766. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6767. }
  6768. return oldValue.Content, nil
  6769. }
  6770. // ResetContent resets all changes to the "content" field.
  6771. func (m *ChatRecordsMutation) ResetContent() {
  6772. m.content = nil
  6773. }
  6774. // SetContentType sets the "content_type" field.
  6775. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6776. m.content_type = &u
  6777. m.addcontent_type = nil
  6778. }
  6779. // ContentType returns the value of the "content_type" field in the mutation.
  6780. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6781. v := m.content_type
  6782. if v == nil {
  6783. return
  6784. }
  6785. return *v, true
  6786. }
  6787. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6788. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6790. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6791. if !m.op.Is(OpUpdateOne) {
  6792. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6793. }
  6794. if m.id == nil || m.oldValue == nil {
  6795. return v, errors.New("OldContentType requires an ID field in the mutation")
  6796. }
  6797. oldValue, err := m.oldValue(ctx)
  6798. if err != nil {
  6799. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6800. }
  6801. return oldValue.ContentType, nil
  6802. }
  6803. // AddContentType adds u to the "content_type" field.
  6804. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6805. if m.addcontent_type != nil {
  6806. *m.addcontent_type += u
  6807. } else {
  6808. m.addcontent_type = &u
  6809. }
  6810. }
  6811. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6812. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6813. v := m.addcontent_type
  6814. if v == nil {
  6815. return
  6816. }
  6817. return *v, true
  6818. }
  6819. // ResetContentType resets all changes to the "content_type" field.
  6820. func (m *ChatRecordsMutation) ResetContentType() {
  6821. m.content_type = nil
  6822. m.addcontent_type = nil
  6823. }
  6824. // SetSessionID sets the "session_id" field.
  6825. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6826. m.session_id = &u
  6827. m.addsession_id = nil
  6828. }
  6829. // SessionID returns the value of the "session_id" field in the mutation.
  6830. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6831. v := m.session_id
  6832. if v == nil {
  6833. return
  6834. }
  6835. return *v, true
  6836. }
  6837. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6838. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6840. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6841. if !m.op.Is(OpUpdateOne) {
  6842. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6843. }
  6844. if m.id == nil || m.oldValue == nil {
  6845. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6846. }
  6847. oldValue, err := m.oldValue(ctx)
  6848. if err != nil {
  6849. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6850. }
  6851. return oldValue.SessionID, nil
  6852. }
  6853. // AddSessionID adds u to the "session_id" field.
  6854. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6855. if m.addsession_id != nil {
  6856. *m.addsession_id += u
  6857. } else {
  6858. m.addsession_id = &u
  6859. }
  6860. }
  6861. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6862. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6863. v := m.addsession_id
  6864. if v == nil {
  6865. return
  6866. }
  6867. return *v, true
  6868. }
  6869. // ResetSessionID resets all changes to the "session_id" field.
  6870. func (m *ChatRecordsMutation) ResetSessionID() {
  6871. m.session_id = nil
  6872. m.addsession_id = nil
  6873. }
  6874. // SetUserID sets the "user_id" field.
  6875. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6876. m.user_id = &u
  6877. m.adduser_id = nil
  6878. }
  6879. // UserID returns the value of the "user_id" field in the mutation.
  6880. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6881. v := m.user_id
  6882. if v == nil {
  6883. return
  6884. }
  6885. return *v, true
  6886. }
  6887. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6888. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6890. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6891. if !m.op.Is(OpUpdateOne) {
  6892. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6893. }
  6894. if m.id == nil || m.oldValue == nil {
  6895. return v, errors.New("OldUserID requires an ID field in the mutation")
  6896. }
  6897. oldValue, err := m.oldValue(ctx)
  6898. if err != nil {
  6899. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6900. }
  6901. return oldValue.UserID, nil
  6902. }
  6903. // AddUserID adds u to the "user_id" field.
  6904. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6905. if m.adduser_id != nil {
  6906. *m.adduser_id += u
  6907. } else {
  6908. m.adduser_id = &u
  6909. }
  6910. }
  6911. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6912. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6913. v := m.adduser_id
  6914. if v == nil {
  6915. return
  6916. }
  6917. return *v, true
  6918. }
  6919. // ResetUserID resets all changes to the "user_id" field.
  6920. func (m *ChatRecordsMutation) ResetUserID() {
  6921. m.user_id = nil
  6922. m.adduser_id = nil
  6923. }
  6924. // SetBotID sets the "bot_id" field.
  6925. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6926. m.bot_id = &u
  6927. m.addbot_id = nil
  6928. }
  6929. // BotID returns the value of the "bot_id" field in the mutation.
  6930. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6931. v := m.bot_id
  6932. if v == nil {
  6933. return
  6934. }
  6935. return *v, true
  6936. }
  6937. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6938. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6940. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6941. if !m.op.Is(OpUpdateOne) {
  6942. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6943. }
  6944. if m.id == nil || m.oldValue == nil {
  6945. return v, errors.New("OldBotID requires an ID field in the mutation")
  6946. }
  6947. oldValue, err := m.oldValue(ctx)
  6948. if err != nil {
  6949. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6950. }
  6951. return oldValue.BotID, nil
  6952. }
  6953. // AddBotID adds u to the "bot_id" field.
  6954. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6955. if m.addbot_id != nil {
  6956. *m.addbot_id += u
  6957. } else {
  6958. m.addbot_id = &u
  6959. }
  6960. }
  6961. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6962. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6963. v := m.addbot_id
  6964. if v == nil {
  6965. return
  6966. }
  6967. return *v, true
  6968. }
  6969. // ResetBotID resets all changes to the "bot_id" field.
  6970. func (m *ChatRecordsMutation) ResetBotID() {
  6971. m.bot_id = nil
  6972. m.addbot_id = nil
  6973. }
  6974. // SetBotType sets the "bot_type" field.
  6975. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6976. m.bot_type = &u
  6977. m.addbot_type = nil
  6978. }
  6979. // BotType returns the value of the "bot_type" field in the mutation.
  6980. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6981. v := m.bot_type
  6982. if v == nil {
  6983. return
  6984. }
  6985. return *v, true
  6986. }
  6987. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6988. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6990. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6991. if !m.op.Is(OpUpdateOne) {
  6992. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6993. }
  6994. if m.id == nil || m.oldValue == nil {
  6995. return v, errors.New("OldBotType requires an ID field in the mutation")
  6996. }
  6997. oldValue, err := m.oldValue(ctx)
  6998. if err != nil {
  6999. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7000. }
  7001. return oldValue.BotType, nil
  7002. }
  7003. // AddBotType adds u to the "bot_type" field.
  7004. func (m *ChatRecordsMutation) AddBotType(u int8) {
  7005. if m.addbot_type != nil {
  7006. *m.addbot_type += u
  7007. } else {
  7008. m.addbot_type = &u
  7009. }
  7010. }
  7011. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7012. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  7013. v := m.addbot_type
  7014. if v == nil {
  7015. return
  7016. }
  7017. return *v, true
  7018. }
  7019. // ResetBotType resets all changes to the "bot_type" field.
  7020. func (m *ChatRecordsMutation) ResetBotType() {
  7021. m.bot_type = nil
  7022. m.addbot_type = nil
  7023. }
  7024. // Where appends a list predicates to the ChatRecordsMutation builder.
  7025. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  7026. m.predicates = append(m.predicates, ps...)
  7027. }
  7028. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  7029. // users can use type-assertion to append predicates that do not depend on any generated package.
  7030. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  7031. p := make([]predicate.ChatRecords, len(ps))
  7032. for i := range ps {
  7033. p[i] = ps[i]
  7034. }
  7035. m.Where(p...)
  7036. }
  7037. // Op returns the operation name.
  7038. func (m *ChatRecordsMutation) Op() Op {
  7039. return m.op
  7040. }
  7041. // SetOp allows setting the mutation operation.
  7042. func (m *ChatRecordsMutation) SetOp(op Op) {
  7043. m.op = op
  7044. }
  7045. // Type returns the node type of this mutation (ChatRecords).
  7046. func (m *ChatRecordsMutation) Type() string {
  7047. return m.typ
  7048. }
  7049. // Fields returns all fields that were changed during this mutation. Note that in
  7050. // order to get all numeric fields that were incremented/decremented, call
  7051. // AddedFields().
  7052. func (m *ChatRecordsMutation) Fields() []string {
  7053. fields := make([]string, 0, 9)
  7054. if m.created_at != nil {
  7055. fields = append(fields, chatrecords.FieldCreatedAt)
  7056. }
  7057. if m.updated_at != nil {
  7058. fields = append(fields, chatrecords.FieldUpdatedAt)
  7059. }
  7060. if m.deleted_at != nil {
  7061. fields = append(fields, chatrecords.FieldDeletedAt)
  7062. }
  7063. if m.content != nil {
  7064. fields = append(fields, chatrecords.FieldContent)
  7065. }
  7066. if m.content_type != nil {
  7067. fields = append(fields, chatrecords.FieldContentType)
  7068. }
  7069. if m.session_id != nil {
  7070. fields = append(fields, chatrecords.FieldSessionID)
  7071. }
  7072. if m.user_id != nil {
  7073. fields = append(fields, chatrecords.FieldUserID)
  7074. }
  7075. if m.bot_id != nil {
  7076. fields = append(fields, chatrecords.FieldBotID)
  7077. }
  7078. if m.bot_type != nil {
  7079. fields = append(fields, chatrecords.FieldBotType)
  7080. }
  7081. return fields
  7082. }
  7083. // Field returns the value of a field with the given name. The second boolean
  7084. // return value indicates that this field was not set, or was not defined in the
  7085. // schema.
  7086. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  7087. switch name {
  7088. case chatrecords.FieldCreatedAt:
  7089. return m.CreatedAt()
  7090. case chatrecords.FieldUpdatedAt:
  7091. return m.UpdatedAt()
  7092. case chatrecords.FieldDeletedAt:
  7093. return m.DeletedAt()
  7094. case chatrecords.FieldContent:
  7095. return m.Content()
  7096. case chatrecords.FieldContentType:
  7097. return m.ContentType()
  7098. case chatrecords.FieldSessionID:
  7099. return m.SessionID()
  7100. case chatrecords.FieldUserID:
  7101. return m.UserID()
  7102. case chatrecords.FieldBotID:
  7103. return m.BotID()
  7104. case chatrecords.FieldBotType:
  7105. return m.BotType()
  7106. }
  7107. return nil, false
  7108. }
  7109. // OldField returns the old value of the field from the database. An error is
  7110. // returned if the mutation operation is not UpdateOne, or the query to the
  7111. // database failed.
  7112. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7113. switch name {
  7114. case chatrecords.FieldCreatedAt:
  7115. return m.OldCreatedAt(ctx)
  7116. case chatrecords.FieldUpdatedAt:
  7117. return m.OldUpdatedAt(ctx)
  7118. case chatrecords.FieldDeletedAt:
  7119. return m.OldDeletedAt(ctx)
  7120. case chatrecords.FieldContent:
  7121. return m.OldContent(ctx)
  7122. case chatrecords.FieldContentType:
  7123. return m.OldContentType(ctx)
  7124. case chatrecords.FieldSessionID:
  7125. return m.OldSessionID(ctx)
  7126. case chatrecords.FieldUserID:
  7127. return m.OldUserID(ctx)
  7128. case chatrecords.FieldBotID:
  7129. return m.OldBotID(ctx)
  7130. case chatrecords.FieldBotType:
  7131. return m.OldBotType(ctx)
  7132. }
  7133. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  7134. }
  7135. // SetField sets the value of a field with the given name. It returns an error if
  7136. // the field is not defined in the schema, or if the type mismatched the field
  7137. // type.
  7138. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  7139. switch name {
  7140. case chatrecords.FieldCreatedAt:
  7141. v, ok := value.(time.Time)
  7142. if !ok {
  7143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7144. }
  7145. m.SetCreatedAt(v)
  7146. return nil
  7147. case chatrecords.FieldUpdatedAt:
  7148. v, ok := value.(time.Time)
  7149. if !ok {
  7150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7151. }
  7152. m.SetUpdatedAt(v)
  7153. return nil
  7154. case chatrecords.FieldDeletedAt:
  7155. v, ok := value.(time.Time)
  7156. if !ok {
  7157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7158. }
  7159. m.SetDeletedAt(v)
  7160. return nil
  7161. case chatrecords.FieldContent:
  7162. v, ok := value.(string)
  7163. if !ok {
  7164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7165. }
  7166. m.SetContent(v)
  7167. return nil
  7168. case chatrecords.FieldContentType:
  7169. v, ok := value.(uint8)
  7170. if !ok {
  7171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7172. }
  7173. m.SetContentType(v)
  7174. return nil
  7175. case chatrecords.FieldSessionID:
  7176. v, ok := value.(uint64)
  7177. if !ok {
  7178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7179. }
  7180. m.SetSessionID(v)
  7181. return nil
  7182. case chatrecords.FieldUserID:
  7183. v, ok := value.(uint64)
  7184. if !ok {
  7185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7186. }
  7187. m.SetUserID(v)
  7188. return nil
  7189. case chatrecords.FieldBotID:
  7190. v, ok := value.(uint64)
  7191. if !ok {
  7192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7193. }
  7194. m.SetBotID(v)
  7195. return nil
  7196. case chatrecords.FieldBotType:
  7197. v, ok := value.(uint8)
  7198. if !ok {
  7199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7200. }
  7201. m.SetBotType(v)
  7202. return nil
  7203. }
  7204. return fmt.Errorf("unknown ChatRecords field %s", name)
  7205. }
  7206. // AddedFields returns all numeric fields that were incremented/decremented during
  7207. // this mutation.
  7208. func (m *ChatRecordsMutation) AddedFields() []string {
  7209. var fields []string
  7210. if m.addcontent_type != nil {
  7211. fields = append(fields, chatrecords.FieldContentType)
  7212. }
  7213. if m.addsession_id != nil {
  7214. fields = append(fields, chatrecords.FieldSessionID)
  7215. }
  7216. if m.adduser_id != nil {
  7217. fields = append(fields, chatrecords.FieldUserID)
  7218. }
  7219. if m.addbot_id != nil {
  7220. fields = append(fields, chatrecords.FieldBotID)
  7221. }
  7222. if m.addbot_type != nil {
  7223. fields = append(fields, chatrecords.FieldBotType)
  7224. }
  7225. return fields
  7226. }
  7227. // AddedField returns the numeric value that was incremented/decremented on a field
  7228. // with the given name. The second boolean return value indicates that this field
  7229. // was not set, or was not defined in the schema.
  7230. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  7231. switch name {
  7232. case chatrecords.FieldContentType:
  7233. return m.AddedContentType()
  7234. case chatrecords.FieldSessionID:
  7235. return m.AddedSessionID()
  7236. case chatrecords.FieldUserID:
  7237. return m.AddedUserID()
  7238. case chatrecords.FieldBotID:
  7239. return m.AddedBotID()
  7240. case chatrecords.FieldBotType:
  7241. return m.AddedBotType()
  7242. }
  7243. return nil, false
  7244. }
  7245. // AddField adds the value to the field with the given name. It returns an error if
  7246. // the field is not defined in the schema, or if the type mismatched the field
  7247. // type.
  7248. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  7249. switch name {
  7250. case chatrecords.FieldContentType:
  7251. v, ok := value.(int8)
  7252. if !ok {
  7253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7254. }
  7255. m.AddContentType(v)
  7256. return nil
  7257. case chatrecords.FieldSessionID:
  7258. v, ok := value.(int64)
  7259. if !ok {
  7260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7261. }
  7262. m.AddSessionID(v)
  7263. return nil
  7264. case chatrecords.FieldUserID:
  7265. v, ok := value.(int64)
  7266. if !ok {
  7267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7268. }
  7269. m.AddUserID(v)
  7270. return nil
  7271. case chatrecords.FieldBotID:
  7272. v, ok := value.(int64)
  7273. if !ok {
  7274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7275. }
  7276. m.AddBotID(v)
  7277. return nil
  7278. case chatrecords.FieldBotType:
  7279. v, ok := value.(int8)
  7280. if !ok {
  7281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7282. }
  7283. m.AddBotType(v)
  7284. return nil
  7285. }
  7286. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  7287. }
  7288. // ClearedFields returns all nullable fields that were cleared during this
  7289. // mutation.
  7290. func (m *ChatRecordsMutation) ClearedFields() []string {
  7291. var fields []string
  7292. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  7293. fields = append(fields, chatrecords.FieldDeletedAt)
  7294. }
  7295. return fields
  7296. }
  7297. // FieldCleared returns a boolean indicating if a field with the given name was
  7298. // cleared in this mutation.
  7299. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  7300. _, ok := m.clearedFields[name]
  7301. return ok
  7302. }
  7303. // ClearField clears the value of the field with the given name. It returns an
  7304. // error if the field is not defined in the schema.
  7305. func (m *ChatRecordsMutation) ClearField(name string) error {
  7306. switch name {
  7307. case chatrecords.FieldDeletedAt:
  7308. m.ClearDeletedAt()
  7309. return nil
  7310. }
  7311. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  7312. }
  7313. // ResetField resets all changes in the mutation for the field with the given name.
  7314. // It returns an error if the field is not defined in the schema.
  7315. func (m *ChatRecordsMutation) ResetField(name string) error {
  7316. switch name {
  7317. case chatrecords.FieldCreatedAt:
  7318. m.ResetCreatedAt()
  7319. return nil
  7320. case chatrecords.FieldUpdatedAt:
  7321. m.ResetUpdatedAt()
  7322. return nil
  7323. case chatrecords.FieldDeletedAt:
  7324. m.ResetDeletedAt()
  7325. return nil
  7326. case chatrecords.FieldContent:
  7327. m.ResetContent()
  7328. return nil
  7329. case chatrecords.FieldContentType:
  7330. m.ResetContentType()
  7331. return nil
  7332. case chatrecords.FieldSessionID:
  7333. m.ResetSessionID()
  7334. return nil
  7335. case chatrecords.FieldUserID:
  7336. m.ResetUserID()
  7337. return nil
  7338. case chatrecords.FieldBotID:
  7339. m.ResetBotID()
  7340. return nil
  7341. case chatrecords.FieldBotType:
  7342. m.ResetBotType()
  7343. return nil
  7344. }
  7345. return fmt.Errorf("unknown ChatRecords field %s", name)
  7346. }
  7347. // AddedEdges returns all edge names that were set/added in this mutation.
  7348. func (m *ChatRecordsMutation) AddedEdges() []string {
  7349. edges := make([]string, 0, 0)
  7350. return edges
  7351. }
  7352. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7353. // name in this mutation.
  7354. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  7355. return nil
  7356. }
  7357. // RemovedEdges returns all edge names that were removed in this mutation.
  7358. func (m *ChatRecordsMutation) RemovedEdges() []string {
  7359. edges := make([]string, 0, 0)
  7360. return edges
  7361. }
  7362. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7363. // the given name in this mutation.
  7364. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  7365. return nil
  7366. }
  7367. // ClearedEdges returns all edge names that were cleared in this mutation.
  7368. func (m *ChatRecordsMutation) ClearedEdges() []string {
  7369. edges := make([]string, 0, 0)
  7370. return edges
  7371. }
  7372. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7373. // was cleared in this mutation.
  7374. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  7375. return false
  7376. }
  7377. // ClearEdge clears the value of the edge with the given name. It returns an error
  7378. // if that edge is not defined in the schema.
  7379. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  7380. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  7381. }
  7382. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7383. // It returns an error if the edge is not defined in the schema.
  7384. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  7385. return fmt.Errorf("unknown ChatRecords edge %s", name)
  7386. }
  7387. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  7388. type ChatSessionMutation struct {
  7389. config
  7390. op Op
  7391. typ string
  7392. id *uint64
  7393. created_at *time.Time
  7394. updated_at *time.Time
  7395. deleted_at *time.Time
  7396. name *string
  7397. user_id *uint64
  7398. adduser_id *int64
  7399. bot_id *uint64
  7400. addbot_id *int64
  7401. bot_type *uint8
  7402. addbot_type *int8
  7403. clearedFields map[string]struct{}
  7404. done bool
  7405. oldValue func(context.Context) (*ChatSession, error)
  7406. predicates []predicate.ChatSession
  7407. }
  7408. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  7409. // chatsessionOption allows management of the mutation configuration using functional options.
  7410. type chatsessionOption func(*ChatSessionMutation)
  7411. // newChatSessionMutation creates new mutation for the ChatSession entity.
  7412. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  7413. m := &ChatSessionMutation{
  7414. config: c,
  7415. op: op,
  7416. typ: TypeChatSession,
  7417. clearedFields: make(map[string]struct{}),
  7418. }
  7419. for _, opt := range opts {
  7420. opt(m)
  7421. }
  7422. return m
  7423. }
  7424. // withChatSessionID sets the ID field of the mutation.
  7425. func withChatSessionID(id uint64) chatsessionOption {
  7426. return func(m *ChatSessionMutation) {
  7427. var (
  7428. err error
  7429. once sync.Once
  7430. value *ChatSession
  7431. )
  7432. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  7433. once.Do(func() {
  7434. if m.done {
  7435. err = errors.New("querying old values post mutation is not allowed")
  7436. } else {
  7437. value, err = m.Client().ChatSession.Get(ctx, id)
  7438. }
  7439. })
  7440. return value, err
  7441. }
  7442. m.id = &id
  7443. }
  7444. }
  7445. // withChatSession sets the old ChatSession of the mutation.
  7446. func withChatSession(node *ChatSession) chatsessionOption {
  7447. return func(m *ChatSessionMutation) {
  7448. m.oldValue = func(context.Context) (*ChatSession, error) {
  7449. return node, nil
  7450. }
  7451. m.id = &node.ID
  7452. }
  7453. }
  7454. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7455. // executed in a transaction (ent.Tx), a transactional client is returned.
  7456. func (m ChatSessionMutation) Client() *Client {
  7457. client := &Client{config: m.config}
  7458. client.init()
  7459. return client
  7460. }
  7461. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7462. // it returns an error otherwise.
  7463. func (m ChatSessionMutation) Tx() (*Tx, error) {
  7464. if _, ok := m.driver.(*txDriver); !ok {
  7465. return nil, errors.New("ent: mutation is not running in a transaction")
  7466. }
  7467. tx := &Tx{config: m.config}
  7468. tx.init()
  7469. return tx, nil
  7470. }
  7471. // SetID sets the value of the id field. Note that this
  7472. // operation is only accepted on creation of ChatSession entities.
  7473. func (m *ChatSessionMutation) SetID(id uint64) {
  7474. m.id = &id
  7475. }
  7476. // ID returns the ID value in the mutation. Note that the ID is only available
  7477. // if it was provided to the builder or after it was returned from the database.
  7478. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  7479. if m.id == nil {
  7480. return
  7481. }
  7482. return *m.id, true
  7483. }
  7484. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7485. // That means, if the mutation is applied within a transaction with an isolation level such
  7486. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7487. // or updated by the mutation.
  7488. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  7489. switch {
  7490. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7491. id, exists := m.ID()
  7492. if exists {
  7493. return []uint64{id}, nil
  7494. }
  7495. fallthrough
  7496. case m.op.Is(OpUpdate | OpDelete):
  7497. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7498. default:
  7499. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7500. }
  7501. }
  7502. // SetCreatedAt sets the "created_at" field.
  7503. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7504. m.created_at = &t
  7505. }
  7506. // CreatedAt returns the value of the "created_at" field in the mutation.
  7507. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7508. v := m.created_at
  7509. if v == nil {
  7510. return
  7511. }
  7512. return *v, true
  7513. }
  7514. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7515. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7517. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7518. if !m.op.Is(OpUpdateOne) {
  7519. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7520. }
  7521. if m.id == nil || m.oldValue == nil {
  7522. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7523. }
  7524. oldValue, err := m.oldValue(ctx)
  7525. if err != nil {
  7526. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7527. }
  7528. return oldValue.CreatedAt, nil
  7529. }
  7530. // ResetCreatedAt resets all changes to the "created_at" field.
  7531. func (m *ChatSessionMutation) ResetCreatedAt() {
  7532. m.created_at = nil
  7533. }
  7534. // SetUpdatedAt sets the "updated_at" field.
  7535. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7536. m.updated_at = &t
  7537. }
  7538. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7539. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7540. v := m.updated_at
  7541. if v == nil {
  7542. return
  7543. }
  7544. return *v, true
  7545. }
  7546. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7547. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7549. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7550. if !m.op.Is(OpUpdateOne) {
  7551. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7552. }
  7553. if m.id == nil || m.oldValue == nil {
  7554. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7555. }
  7556. oldValue, err := m.oldValue(ctx)
  7557. if err != nil {
  7558. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7559. }
  7560. return oldValue.UpdatedAt, nil
  7561. }
  7562. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7563. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7564. m.updated_at = nil
  7565. }
  7566. // SetDeletedAt sets the "deleted_at" field.
  7567. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7568. m.deleted_at = &t
  7569. }
  7570. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7571. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7572. v := m.deleted_at
  7573. if v == nil {
  7574. return
  7575. }
  7576. return *v, true
  7577. }
  7578. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7579. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7581. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7582. if !m.op.Is(OpUpdateOne) {
  7583. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7584. }
  7585. if m.id == nil || m.oldValue == nil {
  7586. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7587. }
  7588. oldValue, err := m.oldValue(ctx)
  7589. if err != nil {
  7590. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7591. }
  7592. return oldValue.DeletedAt, nil
  7593. }
  7594. // ClearDeletedAt clears the value of the "deleted_at" field.
  7595. func (m *ChatSessionMutation) ClearDeletedAt() {
  7596. m.deleted_at = nil
  7597. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7598. }
  7599. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7600. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7601. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7602. return ok
  7603. }
  7604. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7605. func (m *ChatSessionMutation) ResetDeletedAt() {
  7606. m.deleted_at = nil
  7607. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7608. }
  7609. // SetName sets the "name" field.
  7610. func (m *ChatSessionMutation) SetName(s string) {
  7611. m.name = &s
  7612. }
  7613. // Name returns the value of the "name" field in the mutation.
  7614. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7615. v := m.name
  7616. if v == nil {
  7617. return
  7618. }
  7619. return *v, true
  7620. }
  7621. // OldName returns the old "name" field's value of the ChatSession entity.
  7622. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7624. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7625. if !m.op.Is(OpUpdateOne) {
  7626. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7627. }
  7628. if m.id == nil || m.oldValue == nil {
  7629. return v, errors.New("OldName requires an ID field in the mutation")
  7630. }
  7631. oldValue, err := m.oldValue(ctx)
  7632. if err != nil {
  7633. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7634. }
  7635. return oldValue.Name, nil
  7636. }
  7637. // ResetName resets all changes to the "name" field.
  7638. func (m *ChatSessionMutation) ResetName() {
  7639. m.name = nil
  7640. }
  7641. // SetUserID sets the "user_id" field.
  7642. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7643. m.user_id = &u
  7644. m.adduser_id = nil
  7645. }
  7646. // UserID returns the value of the "user_id" field in the mutation.
  7647. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7648. v := m.user_id
  7649. if v == nil {
  7650. return
  7651. }
  7652. return *v, true
  7653. }
  7654. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7655. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7657. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7658. if !m.op.Is(OpUpdateOne) {
  7659. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7660. }
  7661. if m.id == nil || m.oldValue == nil {
  7662. return v, errors.New("OldUserID requires an ID field in the mutation")
  7663. }
  7664. oldValue, err := m.oldValue(ctx)
  7665. if err != nil {
  7666. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7667. }
  7668. return oldValue.UserID, nil
  7669. }
  7670. // AddUserID adds u to the "user_id" field.
  7671. func (m *ChatSessionMutation) AddUserID(u int64) {
  7672. if m.adduser_id != nil {
  7673. *m.adduser_id += u
  7674. } else {
  7675. m.adduser_id = &u
  7676. }
  7677. }
  7678. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7679. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7680. v := m.adduser_id
  7681. if v == nil {
  7682. return
  7683. }
  7684. return *v, true
  7685. }
  7686. // ResetUserID resets all changes to the "user_id" field.
  7687. func (m *ChatSessionMutation) ResetUserID() {
  7688. m.user_id = nil
  7689. m.adduser_id = nil
  7690. }
  7691. // SetBotID sets the "bot_id" field.
  7692. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7693. m.bot_id = &u
  7694. m.addbot_id = nil
  7695. }
  7696. // BotID returns the value of the "bot_id" field in the mutation.
  7697. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7698. v := m.bot_id
  7699. if v == nil {
  7700. return
  7701. }
  7702. return *v, true
  7703. }
  7704. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7705. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7707. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7708. if !m.op.Is(OpUpdateOne) {
  7709. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7710. }
  7711. if m.id == nil || m.oldValue == nil {
  7712. return v, errors.New("OldBotID requires an ID field in the mutation")
  7713. }
  7714. oldValue, err := m.oldValue(ctx)
  7715. if err != nil {
  7716. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7717. }
  7718. return oldValue.BotID, nil
  7719. }
  7720. // AddBotID adds u to the "bot_id" field.
  7721. func (m *ChatSessionMutation) AddBotID(u int64) {
  7722. if m.addbot_id != nil {
  7723. *m.addbot_id += u
  7724. } else {
  7725. m.addbot_id = &u
  7726. }
  7727. }
  7728. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7729. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7730. v := m.addbot_id
  7731. if v == nil {
  7732. return
  7733. }
  7734. return *v, true
  7735. }
  7736. // ResetBotID resets all changes to the "bot_id" field.
  7737. func (m *ChatSessionMutation) ResetBotID() {
  7738. m.bot_id = nil
  7739. m.addbot_id = nil
  7740. }
  7741. // SetBotType sets the "bot_type" field.
  7742. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7743. m.bot_type = &u
  7744. m.addbot_type = nil
  7745. }
  7746. // BotType returns the value of the "bot_type" field in the mutation.
  7747. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7748. v := m.bot_type
  7749. if v == nil {
  7750. return
  7751. }
  7752. return *v, true
  7753. }
  7754. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7755. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7757. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7758. if !m.op.Is(OpUpdateOne) {
  7759. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7760. }
  7761. if m.id == nil || m.oldValue == nil {
  7762. return v, errors.New("OldBotType requires an ID field in the mutation")
  7763. }
  7764. oldValue, err := m.oldValue(ctx)
  7765. if err != nil {
  7766. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7767. }
  7768. return oldValue.BotType, nil
  7769. }
  7770. // AddBotType adds u to the "bot_type" field.
  7771. func (m *ChatSessionMutation) AddBotType(u int8) {
  7772. if m.addbot_type != nil {
  7773. *m.addbot_type += u
  7774. } else {
  7775. m.addbot_type = &u
  7776. }
  7777. }
  7778. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7779. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7780. v := m.addbot_type
  7781. if v == nil {
  7782. return
  7783. }
  7784. return *v, true
  7785. }
  7786. // ResetBotType resets all changes to the "bot_type" field.
  7787. func (m *ChatSessionMutation) ResetBotType() {
  7788. m.bot_type = nil
  7789. m.addbot_type = nil
  7790. }
  7791. // Where appends a list predicates to the ChatSessionMutation builder.
  7792. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7793. m.predicates = append(m.predicates, ps...)
  7794. }
  7795. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7796. // users can use type-assertion to append predicates that do not depend on any generated package.
  7797. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7798. p := make([]predicate.ChatSession, len(ps))
  7799. for i := range ps {
  7800. p[i] = ps[i]
  7801. }
  7802. m.Where(p...)
  7803. }
  7804. // Op returns the operation name.
  7805. func (m *ChatSessionMutation) Op() Op {
  7806. return m.op
  7807. }
  7808. // SetOp allows setting the mutation operation.
  7809. func (m *ChatSessionMutation) SetOp(op Op) {
  7810. m.op = op
  7811. }
  7812. // Type returns the node type of this mutation (ChatSession).
  7813. func (m *ChatSessionMutation) Type() string {
  7814. return m.typ
  7815. }
  7816. // Fields returns all fields that were changed during this mutation. Note that in
  7817. // order to get all numeric fields that were incremented/decremented, call
  7818. // AddedFields().
  7819. func (m *ChatSessionMutation) Fields() []string {
  7820. fields := make([]string, 0, 7)
  7821. if m.created_at != nil {
  7822. fields = append(fields, chatsession.FieldCreatedAt)
  7823. }
  7824. if m.updated_at != nil {
  7825. fields = append(fields, chatsession.FieldUpdatedAt)
  7826. }
  7827. if m.deleted_at != nil {
  7828. fields = append(fields, chatsession.FieldDeletedAt)
  7829. }
  7830. if m.name != nil {
  7831. fields = append(fields, chatsession.FieldName)
  7832. }
  7833. if m.user_id != nil {
  7834. fields = append(fields, chatsession.FieldUserID)
  7835. }
  7836. if m.bot_id != nil {
  7837. fields = append(fields, chatsession.FieldBotID)
  7838. }
  7839. if m.bot_type != nil {
  7840. fields = append(fields, chatsession.FieldBotType)
  7841. }
  7842. return fields
  7843. }
  7844. // Field returns the value of a field with the given name. The second boolean
  7845. // return value indicates that this field was not set, or was not defined in the
  7846. // schema.
  7847. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7848. switch name {
  7849. case chatsession.FieldCreatedAt:
  7850. return m.CreatedAt()
  7851. case chatsession.FieldUpdatedAt:
  7852. return m.UpdatedAt()
  7853. case chatsession.FieldDeletedAt:
  7854. return m.DeletedAt()
  7855. case chatsession.FieldName:
  7856. return m.Name()
  7857. case chatsession.FieldUserID:
  7858. return m.UserID()
  7859. case chatsession.FieldBotID:
  7860. return m.BotID()
  7861. case chatsession.FieldBotType:
  7862. return m.BotType()
  7863. }
  7864. return nil, false
  7865. }
  7866. // OldField returns the old value of the field from the database. An error is
  7867. // returned if the mutation operation is not UpdateOne, or the query to the
  7868. // database failed.
  7869. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7870. switch name {
  7871. case chatsession.FieldCreatedAt:
  7872. return m.OldCreatedAt(ctx)
  7873. case chatsession.FieldUpdatedAt:
  7874. return m.OldUpdatedAt(ctx)
  7875. case chatsession.FieldDeletedAt:
  7876. return m.OldDeletedAt(ctx)
  7877. case chatsession.FieldName:
  7878. return m.OldName(ctx)
  7879. case chatsession.FieldUserID:
  7880. return m.OldUserID(ctx)
  7881. case chatsession.FieldBotID:
  7882. return m.OldBotID(ctx)
  7883. case chatsession.FieldBotType:
  7884. return m.OldBotType(ctx)
  7885. }
  7886. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7887. }
  7888. // SetField sets the value of a field with the given name. It returns an error if
  7889. // the field is not defined in the schema, or if the type mismatched the field
  7890. // type.
  7891. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7892. switch name {
  7893. case chatsession.FieldCreatedAt:
  7894. v, ok := value.(time.Time)
  7895. if !ok {
  7896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7897. }
  7898. m.SetCreatedAt(v)
  7899. return nil
  7900. case chatsession.FieldUpdatedAt:
  7901. v, ok := value.(time.Time)
  7902. if !ok {
  7903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7904. }
  7905. m.SetUpdatedAt(v)
  7906. return nil
  7907. case chatsession.FieldDeletedAt:
  7908. v, ok := value.(time.Time)
  7909. if !ok {
  7910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7911. }
  7912. m.SetDeletedAt(v)
  7913. return nil
  7914. case chatsession.FieldName:
  7915. v, ok := value.(string)
  7916. if !ok {
  7917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7918. }
  7919. m.SetName(v)
  7920. return nil
  7921. case chatsession.FieldUserID:
  7922. v, ok := value.(uint64)
  7923. if !ok {
  7924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7925. }
  7926. m.SetUserID(v)
  7927. return nil
  7928. case chatsession.FieldBotID:
  7929. v, ok := value.(uint64)
  7930. if !ok {
  7931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7932. }
  7933. m.SetBotID(v)
  7934. return nil
  7935. case chatsession.FieldBotType:
  7936. v, ok := value.(uint8)
  7937. if !ok {
  7938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7939. }
  7940. m.SetBotType(v)
  7941. return nil
  7942. }
  7943. return fmt.Errorf("unknown ChatSession field %s", name)
  7944. }
  7945. // AddedFields returns all numeric fields that were incremented/decremented during
  7946. // this mutation.
  7947. func (m *ChatSessionMutation) AddedFields() []string {
  7948. var fields []string
  7949. if m.adduser_id != nil {
  7950. fields = append(fields, chatsession.FieldUserID)
  7951. }
  7952. if m.addbot_id != nil {
  7953. fields = append(fields, chatsession.FieldBotID)
  7954. }
  7955. if m.addbot_type != nil {
  7956. fields = append(fields, chatsession.FieldBotType)
  7957. }
  7958. return fields
  7959. }
  7960. // AddedField returns the numeric value that was incremented/decremented on a field
  7961. // with the given name. The second boolean return value indicates that this field
  7962. // was not set, or was not defined in the schema.
  7963. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7964. switch name {
  7965. case chatsession.FieldUserID:
  7966. return m.AddedUserID()
  7967. case chatsession.FieldBotID:
  7968. return m.AddedBotID()
  7969. case chatsession.FieldBotType:
  7970. return m.AddedBotType()
  7971. }
  7972. return nil, false
  7973. }
  7974. // AddField adds the value to the field with the given name. It returns an error if
  7975. // the field is not defined in the schema, or if the type mismatched the field
  7976. // type.
  7977. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7978. switch name {
  7979. case chatsession.FieldUserID:
  7980. v, ok := value.(int64)
  7981. if !ok {
  7982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7983. }
  7984. m.AddUserID(v)
  7985. return nil
  7986. case chatsession.FieldBotID:
  7987. v, ok := value.(int64)
  7988. if !ok {
  7989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7990. }
  7991. m.AddBotID(v)
  7992. return nil
  7993. case chatsession.FieldBotType:
  7994. v, ok := value.(int8)
  7995. if !ok {
  7996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7997. }
  7998. m.AddBotType(v)
  7999. return nil
  8000. }
  8001. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  8002. }
  8003. // ClearedFields returns all nullable fields that were cleared during this
  8004. // mutation.
  8005. func (m *ChatSessionMutation) ClearedFields() []string {
  8006. var fields []string
  8007. if m.FieldCleared(chatsession.FieldDeletedAt) {
  8008. fields = append(fields, chatsession.FieldDeletedAt)
  8009. }
  8010. return fields
  8011. }
  8012. // FieldCleared returns a boolean indicating if a field with the given name was
  8013. // cleared in this mutation.
  8014. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  8015. _, ok := m.clearedFields[name]
  8016. return ok
  8017. }
  8018. // ClearField clears the value of the field with the given name. It returns an
  8019. // error if the field is not defined in the schema.
  8020. func (m *ChatSessionMutation) ClearField(name string) error {
  8021. switch name {
  8022. case chatsession.FieldDeletedAt:
  8023. m.ClearDeletedAt()
  8024. return nil
  8025. }
  8026. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  8027. }
  8028. // ResetField resets all changes in the mutation for the field with the given name.
  8029. // It returns an error if the field is not defined in the schema.
  8030. func (m *ChatSessionMutation) ResetField(name string) error {
  8031. switch name {
  8032. case chatsession.FieldCreatedAt:
  8033. m.ResetCreatedAt()
  8034. return nil
  8035. case chatsession.FieldUpdatedAt:
  8036. m.ResetUpdatedAt()
  8037. return nil
  8038. case chatsession.FieldDeletedAt:
  8039. m.ResetDeletedAt()
  8040. return nil
  8041. case chatsession.FieldName:
  8042. m.ResetName()
  8043. return nil
  8044. case chatsession.FieldUserID:
  8045. m.ResetUserID()
  8046. return nil
  8047. case chatsession.FieldBotID:
  8048. m.ResetBotID()
  8049. return nil
  8050. case chatsession.FieldBotType:
  8051. m.ResetBotType()
  8052. return nil
  8053. }
  8054. return fmt.Errorf("unknown ChatSession field %s", name)
  8055. }
  8056. // AddedEdges returns all edge names that were set/added in this mutation.
  8057. func (m *ChatSessionMutation) AddedEdges() []string {
  8058. edges := make([]string, 0, 0)
  8059. return edges
  8060. }
  8061. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8062. // name in this mutation.
  8063. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  8064. return nil
  8065. }
  8066. // RemovedEdges returns all edge names that were removed in this mutation.
  8067. func (m *ChatSessionMutation) RemovedEdges() []string {
  8068. edges := make([]string, 0, 0)
  8069. return edges
  8070. }
  8071. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8072. // the given name in this mutation.
  8073. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  8074. return nil
  8075. }
  8076. // ClearedEdges returns all edge names that were cleared in this mutation.
  8077. func (m *ChatSessionMutation) ClearedEdges() []string {
  8078. edges := make([]string, 0, 0)
  8079. return edges
  8080. }
  8081. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8082. // was cleared in this mutation.
  8083. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  8084. return false
  8085. }
  8086. // ClearEdge clears the value of the edge with the given name. It returns an error
  8087. // if that edge is not defined in the schema.
  8088. func (m *ChatSessionMutation) ClearEdge(name string) error {
  8089. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  8090. }
  8091. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8092. // It returns an error if the edge is not defined in the schema.
  8093. func (m *ChatSessionMutation) ResetEdge(name string) error {
  8094. return fmt.Errorf("unknown ChatSession edge %s", name)
  8095. }
  8096. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  8097. type ContactMutation struct {
  8098. config
  8099. op Op
  8100. typ string
  8101. id *uint64
  8102. created_at *time.Time
  8103. updated_at *time.Time
  8104. status *uint8
  8105. addstatus *int8
  8106. deleted_at *time.Time
  8107. wx_wxid *string
  8108. _type *int
  8109. add_type *int
  8110. wxid *string
  8111. account *string
  8112. nickname *string
  8113. markname *string
  8114. headimg *string
  8115. sex *int
  8116. addsex *int
  8117. starrole *string
  8118. dontseeit *int
  8119. adddontseeit *int
  8120. dontseeme *int
  8121. adddontseeme *int
  8122. lag *string
  8123. gid *string
  8124. gname *string
  8125. v3 *string
  8126. organization_id *uint64
  8127. addorganization_id *int64
  8128. ctype *uint64
  8129. addctype *int64
  8130. cage *int
  8131. addcage *int
  8132. cname *string
  8133. carea *string
  8134. cbirthday *string
  8135. cbirtharea *string
  8136. cidcard_no *string
  8137. ctitle *string
  8138. cc *string
  8139. phone *string
  8140. clearedFields map[string]struct{}
  8141. contact_relationships map[uint64]struct{}
  8142. removedcontact_relationships map[uint64]struct{}
  8143. clearedcontact_relationships bool
  8144. contact_messages map[uint64]struct{}
  8145. removedcontact_messages map[uint64]struct{}
  8146. clearedcontact_messages bool
  8147. done bool
  8148. oldValue func(context.Context) (*Contact, error)
  8149. predicates []predicate.Contact
  8150. }
  8151. var _ ent.Mutation = (*ContactMutation)(nil)
  8152. // contactOption allows management of the mutation configuration using functional options.
  8153. type contactOption func(*ContactMutation)
  8154. // newContactMutation creates new mutation for the Contact entity.
  8155. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  8156. m := &ContactMutation{
  8157. config: c,
  8158. op: op,
  8159. typ: TypeContact,
  8160. clearedFields: make(map[string]struct{}),
  8161. }
  8162. for _, opt := range opts {
  8163. opt(m)
  8164. }
  8165. return m
  8166. }
  8167. // withContactID sets the ID field of the mutation.
  8168. func withContactID(id uint64) contactOption {
  8169. return func(m *ContactMutation) {
  8170. var (
  8171. err error
  8172. once sync.Once
  8173. value *Contact
  8174. )
  8175. m.oldValue = func(ctx context.Context) (*Contact, error) {
  8176. once.Do(func() {
  8177. if m.done {
  8178. err = errors.New("querying old values post mutation is not allowed")
  8179. } else {
  8180. value, err = m.Client().Contact.Get(ctx, id)
  8181. }
  8182. })
  8183. return value, err
  8184. }
  8185. m.id = &id
  8186. }
  8187. }
  8188. // withContact sets the old Contact of the mutation.
  8189. func withContact(node *Contact) contactOption {
  8190. return func(m *ContactMutation) {
  8191. m.oldValue = func(context.Context) (*Contact, error) {
  8192. return node, nil
  8193. }
  8194. m.id = &node.ID
  8195. }
  8196. }
  8197. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8198. // executed in a transaction (ent.Tx), a transactional client is returned.
  8199. func (m ContactMutation) Client() *Client {
  8200. client := &Client{config: m.config}
  8201. client.init()
  8202. return client
  8203. }
  8204. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8205. // it returns an error otherwise.
  8206. func (m ContactMutation) Tx() (*Tx, error) {
  8207. if _, ok := m.driver.(*txDriver); !ok {
  8208. return nil, errors.New("ent: mutation is not running in a transaction")
  8209. }
  8210. tx := &Tx{config: m.config}
  8211. tx.init()
  8212. return tx, nil
  8213. }
  8214. // SetID sets the value of the id field. Note that this
  8215. // operation is only accepted on creation of Contact entities.
  8216. func (m *ContactMutation) SetID(id uint64) {
  8217. m.id = &id
  8218. }
  8219. // ID returns the ID value in the mutation. Note that the ID is only available
  8220. // if it was provided to the builder or after it was returned from the database.
  8221. func (m *ContactMutation) ID() (id uint64, exists bool) {
  8222. if m.id == nil {
  8223. return
  8224. }
  8225. return *m.id, true
  8226. }
  8227. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8228. // That means, if the mutation is applied within a transaction with an isolation level such
  8229. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8230. // or updated by the mutation.
  8231. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  8232. switch {
  8233. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8234. id, exists := m.ID()
  8235. if exists {
  8236. return []uint64{id}, nil
  8237. }
  8238. fallthrough
  8239. case m.op.Is(OpUpdate | OpDelete):
  8240. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  8241. default:
  8242. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8243. }
  8244. }
  8245. // SetCreatedAt sets the "created_at" field.
  8246. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  8247. m.created_at = &t
  8248. }
  8249. // CreatedAt returns the value of the "created_at" field in the mutation.
  8250. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  8251. v := m.created_at
  8252. if v == nil {
  8253. return
  8254. }
  8255. return *v, true
  8256. }
  8257. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  8258. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8260. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8261. if !m.op.Is(OpUpdateOne) {
  8262. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8263. }
  8264. if m.id == nil || m.oldValue == nil {
  8265. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8266. }
  8267. oldValue, err := m.oldValue(ctx)
  8268. if err != nil {
  8269. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8270. }
  8271. return oldValue.CreatedAt, nil
  8272. }
  8273. // ResetCreatedAt resets all changes to the "created_at" field.
  8274. func (m *ContactMutation) ResetCreatedAt() {
  8275. m.created_at = nil
  8276. }
  8277. // SetUpdatedAt sets the "updated_at" field.
  8278. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  8279. m.updated_at = &t
  8280. }
  8281. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8282. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  8283. v := m.updated_at
  8284. if v == nil {
  8285. return
  8286. }
  8287. return *v, true
  8288. }
  8289. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  8290. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8292. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8293. if !m.op.Is(OpUpdateOne) {
  8294. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8295. }
  8296. if m.id == nil || m.oldValue == nil {
  8297. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8298. }
  8299. oldValue, err := m.oldValue(ctx)
  8300. if err != nil {
  8301. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8302. }
  8303. return oldValue.UpdatedAt, nil
  8304. }
  8305. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8306. func (m *ContactMutation) ResetUpdatedAt() {
  8307. m.updated_at = nil
  8308. }
  8309. // SetStatus sets the "status" field.
  8310. func (m *ContactMutation) SetStatus(u uint8) {
  8311. m.status = &u
  8312. m.addstatus = nil
  8313. }
  8314. // Status returns the value of the "status" field in the mutation.
  8315. func (m *ContactMutation) Status() (r uint8, exists bool) {
  8316. v := m.status
  8317. if v == nil {
  8318. return
  8319. }
  8320. return *v, true
  8321. }
  8322. // OldStatus returns the old "status" field's value of the Contact entity.
  8323. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8325. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  8326. if !m.op.Is(OpUpdateOne) {
  8327. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  8328. }
  8329. if m.id == nil || m.oldValue == nil {
  8330. return v, errors.New("OldStatus requires an ID field in the mutation")
  8331. }
  8332. oldValue, err := m.oldValue(ctx)
  8333. if err != nil {
  8334. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  8335. }
  8336. return oldValue.Status, nil
  8337. }
  8338. // AddStatus adds u to the "status" field.
  8339. func (m *ContactMutation) AddStatus(u int8) {
  8340. if m.addstatus != nil {
  8341. *m.addstatus += u
  8342. } else {
  8343. m.addstatus = &u
  8344. }
  8345. }
  8346. // AddedStatus returns the value that was added to the "status" field in this mutation.
  8347. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  8348. v := m.addstatus
  8349. if v == nil {
  8350. return
  8351. }
  8352. return *v, true
  8353. }
  8354. // ClearStatus clears the value of the "status" field.
  8355. func (m *ContactMutation) ClearStatus() {
  8356. m.status = nil
  8357. m.addstatus = nil
  8358. m.clearedFields[contact.FieldStatus] = struct{}{}
  8359. }
  8360. // StatusCleared returns if the "status" field was cleared in this mutation.
  8361. func (m *ContactMutation) StatusCleared() bool {
  8362. _, ok := m.clearedFields[contact.FieldStatus]
  8363. return ok
  8364. }
  8365. // ResetStatus resets all changes to the "status" field.
  8366. func (m *ContactMutation) ResetStatus() {
  8367. m.status = nil
  8368. m.addstatus = nil
  8369. delete(m.clearedFields, contact.FieldStatus)
  8370. }
  8371. // SetDeletedAt sets the "deleted_at" field.
  8372. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  8373. m.deleted_at = &t
  8374. }
  8375. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8376. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  8377. v := m.deleted_at
  8378. if v == nil {
  8379. return
  8380. }
  8381. return *v, true
  8382. }
  8383. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  8384. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8386. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8387. if !m.op.Is(OpUpdateOne) {
  8388. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8389. }
  8390. if m.id == nil || m.oldValue == nil {
  8391. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8392. }
  8393. oldValue, err := m.oldValue(ctx)
  8394. if err != nil {
  8395. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8396. }
  8397. return oldValue.DeletedAt, nil
  8398. }
  8399. // ClearDeletedAt clears the value of the "deleted_at" field.
  8400. func (m *ContactMutation) ClearDeletedAt() {
  8401. m.deleted_at = nil
  8402. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  8403. }
  8404. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8405. func (m *ContactMutation) DeletedAtCleared() bool {
  8406. _, ok := m.clearedFields[contact.FieldDeletedAt]
  8407. return ok
  8408. }
  8409. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8410. func (m *ContactMutation) ResetDeletedAt() {
  8411. m.deleted_at = nil
  8412. delete(m.clearedFields, contact.FieldDeletedAt)
  8413. }
  8414. // SetWxWxid sets the "wx_wxid" field.
  8415. func (m *ContactMutation) SetWxWxid(s string) {
  8416. m.wx_wxid = &s
  8417. }
  8418. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  8419. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  8420. v := m.wx_wxid
  8421. if v == nil {
  8422. return
  8423. }
  8424. return *v, true
  8425. }
  8426. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  8427. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8429. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8430. if !m.op.Is(OpUpdateOne) {
  8431. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8432. }
  8433. if m.id == nil || m.oldValue == nil {
  8434. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8435. }
  8436. oldValue, err := m.oldValue(ctx)
  8437. if err != nil {
  8438. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8439. }
  8440. return oldValue.WxWxid, nil
  8441. }
  8442. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8443. func (m *ContactMutation) ResetWxWxid() {
  8444. m.wx_wxid = nil
  8445. }
  8446. // SetType sets the "type" field.
  8447. func (m *ContactMutation) SetType(i int) {
  8448. m._type = &i
  8449. m.add_type = nil
  8450. }
  8451. // GetType returns the value of the "type" field in the mutation.
  8452. func (m *ContactMutation) GetType() (r int, exists bool) {
  8453. v := m._type
  8454. if v == nil {
  8455. return
  8456. }
  8457. return *v, true
  8458. }
  8459. // OldType returns the old "type" field's value of the Contact entity.
  8460. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8462. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  8463. if !m.op.Is(OpUpdateOne) {
  8464. return v, errors.New("OldType is only allowed on UpdateOne operations")
  8465. }
  8466. if m.id == nil || m.oldValue == nil {
  8467. return v, errors.New("OldType requires an ID field in the mutation")
  8468. }
  8469. oldValue, err := m.oldValue(ctx)
  8470. if err != nil {
  8471. return v, fmt.Errorf("querying old value for OldType: %w", err)
  8472. }
  8473. return oldValue.Type, nil
  8474. }
  8475. // AddType adds i to the "type" field.
  8476. func (m *ContactMutation) AddType(i int) {
  8477. if m.add_type != nil {
  8478. *m.add_type += i
  8479. } else {
  8480. m.add_type = &i
  8481. }
  8482. }
  8483. // AddedType returns the value that was added to the "type" field in this mutation.
  8484. func (m *ContactMutation) AddedType() (r int, exists bool) {
  8485. v := m.add_type
  8486. if v == nil {
  8487. return
  8488. }
  8489. return *v, true
  8490. }
  8491. // ClearType clears the value of the "type" field.
  8492. func (m *ContactMutation) ClearType() {
  8493. m._type = nil
  8494. m.add_type = nil
  8495. m.clearedFields[contact.FieldType] = struct{}{}
  8496. }
  8497. // TypeCleared returns if the "type" field was cleared in this mutation.
  8498. func (m *ContactMutation) TypeCleared() bool {
  8499. _, ok := m.clearedFields[contact.FieldType]
  8500. return ok
  8501. }
  8502. // ResetType resets all changes to the "type" field.
  8503. func (m *ContactMutation) ResetType() {
  8504. m._type = nil
  8505. m.add_type = nil
  8506. delete(m.clearedFields, contact.FieldType)
  8507. }
  8508. // SetWxid sets the "wxid" field.
  8509. func (m *ContactMutation) SetWxid(s string) {
  8510. m.wxid = &s
  8511. }
  8512. // Wxid returns the value of the "wxid" field in the mutation.
  8513. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8514. v := m.wxid
  8515. if v == nil {
  8516. return
  8517. }
  8518. return *v, true
  8519. }
  8520. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8521. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8523. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8524. if !m.op.Is(OpUpdateOne) {
  8525. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8526. }
  8527. if m.id == nil || m.oldValue == nil {
  8528. return v, errors.New("OldWxid requires an ID field in the mutation")
  8529. }
  8530. oldValue, err := m.oldValue(ctx)
  8531. if err != nil {
  8532. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8533. }
  8534. return oldValue.Wxid, nil
  8535. }
  8536. // ResetWxid resets all changes to the "wxid" field.
  8537. func (m *ContactMutation) ResetWxid() {
  8538. m.wxid = nil
  8539. }
  8540. // SetAccount sets the "account" field.
  8541. func (m *ContactMutation) SetAccount(s string) {
  8542. m.account = &s
  8543. }
  8544. // Account returns the value of the "account" field in the mutation.
  8545. func (m *ContactMutation) Account() (r string, exists bool) {
  8546. v := m.account
  8547. if v == nil {
  8548. return
  8549. }
  8550. return *v, true
  8551. }
  8552. // OldAccount returns the old "account" field's value of the Contact entity.
  8553. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8555. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8556. if !m.op.Is(OpUpdateOne) {
  8557. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8558. }
  8559. if m.id == nil || m.oldValue == nil {
  8560. return v, errors.New("OldAccount requires an ID field in the mutation")
  8561. }
  8562. oldValue, err := m.oldValue(ctx)
  8563. if err != nil {
  8564. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8565. }
  8566. return oldValue.Account, nil
  8567. }
  8568. // ResetAccount resets all changes to the "account" field.
  8569. func (m *ContactMutation) ResetAccount() {
  8570. m.account = nil
  8571. }
  8572. // SetNickname sets the "nickname" field.
  8573. func (m *ContactMutation) SetNickname(s string) {
  8574. m.nickname = &s
  8575. }
  8576. // Nickname returns the value of the "nickname" field in the mutation.
  8577. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8578. v := m.nickname
  8579. if v == nil {
  8580. return
  8581. }
  8582. return *v, true
  8583. }
  8584. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8585. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8587. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8588. if !m.op.Is(OpUpdateOne) {
  8589. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8590. }
  8591. if m.id == nil || m.oldValue == nil {
  8592. return v, errors.New("OldNickname requires an ID field in the mutation")
  8593. }
  8594. oldValue, err := m.oldValue(ctx)
  8595. if err != nil {
  8596. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8597. }
  8598. return oldValue.Nickname, nil
  8599. }
  8600. // ResetNickname resets all changes to the "nickname" field.
  8601. func (m *ContactMutation) ResetNickname() {
  8602. m.nickname = nil
  8603. }
  8604. // SetMarkname sets the "markname" field.
  8605. func (m *ContactMutation) SetMarkname(s string) {
  8606. m.markname = &s
  8607. }
  8608. // Markname returns the value of the "markname" field in the mutation.
  8609. func (m *ContactMutation) Markname() (r string, exists bool) {
  8610. v := m.markname
  8611. if v == nil {
  8612. return
  8613. }
  8614. return *v, true
  8615. }
  8616. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8617. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8619. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8620. if !m.op.Is(OpUpdateOne) {
  8621. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8622. }
  8623. if m.id == nil || m.oldValue == nil {
  8624. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8625. }
  8626. oldValue, err := m.oldValue(ctx)
  8627. if err != nil {
  8628. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8629. }
  8630. return oldValue.Markname, nil
  8631. }
  8632. // ResetMarkname resets all changes to the "markname" field.
  8633. func (m *ContactMutation) ResetMarkname() {
  8634. m.markname = nil
  8635. }
  8636. // SetHeadimg sets the "headimg" field.
  8637. func (m *ContactMutation) SetHeadimg(s string) {
  8638. m.headimg = &s
  8639. }
  8640. // Headimg returns the value of the "headimg" field in the mutation.
  8641. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8642. v := m.headimg
  8643. if v == nil {
  8644. return
  8645. }
  8646. return *v, true
  8647. }
  8648. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8649. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8651. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8652. if !m.op.Is(OpUpdateOne) {
  8653. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8654. }
  8655. if m.id == nil || m.oldValue == nil {
  8656. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8657. }
  8658. oldValue, err := m.oldValue(ctx)
  8659. if err != nil {
  8660. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8661. }
  8662. return oldValue.Headimg, nil
  8663. }
  8664. // ResetHeadimg resets all changes to the "headimg" field.
  8665. func (m *ContactMutation) ResetHeadimg() {
  8666. m.headimg = nil
  8667. }
  8668. // SetSex sets the "sex" field.
  8669. func (m *ContactMutation) SetSex(i int) {
  8670. m.sex = &i
  8671. m.addsex = nil
  8672. }
  8673. // Sex returns the value of the "sex" field in the mutation.
  8674. func (m *ContactMutation) Sex() (r int, exists bool) {
  8675. v := m.sex
  8676. if v == nil {
  8677. return
  8678. }
  8679. return *v, true
  8680. }
  8681. // OldSex returns the old "sex" field's value of the Contact entity.
  8682. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8684. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8685. if !m.op.Is(OpUpdateOne) {
  8686. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8687. }
  8688. if m.id == nil || m.oldValue == nil {
  8689. return v, errors.New("OldSex requires an ID field in the mutation")
  8690. }
  8691. oldValue, err := m.oldValue(ctx)
  8692. if err != nil {
  8693. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8694. }
  8695. return oldValue.Sex, nil
  8696. }
  8697. // AddSex adds i to the "sex" field.
  8698. func (m *ContactMutation) AddSex(i int) {
  8699. if m.addsex != nil {
  8700. *m.addsex += i
  8701. } else {
  8702. m.addsex = &i
  8703. }
  8704. }
  8705. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8706. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8707. v := m.addsex
  8708. if v == nil {
  8709. return
  8710. }
  8711. return *v, true
  8712. }
  8713. // ResetSex resets all changes to the "sex" field.
  8714. func (m *ContactMutation) ResetSex() {
  8715. m.sex = nil
  8716. m.addsex = nil
  8717. }
  8718. // SetStarrole sets the "starrole" field.
  8719. func (m *ContactMutation) SetStarrole(s string) {
  8720. m.starrole = &s
  8721. }
  8722. // Starrole returns the value of the "starrole" field in the mutation.
  8723. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8724. v := m.starrole
  8725. if v == nil {
  8726. return
  8727. }
  8728. return *v, true
  8729. }
  8730. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8731. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8733. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8734. if !m.op.Is(OpUpdateOne) {
  8735. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8736. }
  8737. if m.id == nil || m.oldValue == nil {
  8738. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8739. }
  8740. oldValue, err := m.oldValue(ctx)
  8741. if err != nil {
  8742. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8743. }
  8744. return oldValue.Starrole, nil
  8745. }
  8746. // ResetStarrole resets all changes to the "starrole" field.
  8747. func (m *ContactMutation) ResetStarrole() {
  8748. m.starrole = nil
  8749. }
  8750. // SetDontseeit sets the "dontseeit" field.
  8751. func (m *ContactMutation) SetDontseeit(i int) {
  8752. m.dontseeit = &i
  8753. m.adddontseeit = nil
  8754. }
  8755. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8756. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8757. v := m.dontseeit
  8758. if v == nil {
  8759. return
  8760. }
  8761. return *v, true
  8762. }
  8763. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8764. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8766. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8767. if !m.op.Is(OpUpdateOne) {
  8768. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8769. }
  8770. if m.id == nil || m.oldValue == nil {
  8771. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8772. }
  8773. oldValue, err := m.oldValue(ctx)
  8774. if err != nil {
  8775. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8776. }
  8777. return oldValue.Dontseeit, nil
  8778. }
  8779. // AddDontseeit adds i to the "dontseeit" field.
  8780. func (m *ContactMutation) AddDontseeit(i int) {
  8781. if m.adddontseeit != nil {
  8782. *m.adddontseeit += i
  8783. } else {
  8784. m.adddontseeit = &i
  8785. }
  8786. }
  8787. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8788. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8789. v := m.adddontseeit
  8790. if v == nil {
  8791. return
  8792. }
  8793. return *v, true
  8794. }
  8795. // ResetDontseeit resets all changes to the "dontseeit" field.
  8796. func (m *ContactMutation) ResetDontseeit() {
  8797. m.dontseeit = nil
  8798. m.adddontseeit = nil
  8799. }
  8800. // SetDontseeme sets the "dontseeme" field.
  8801. func (m *ContactMutation) SetDontseeme(i int) {
  8802. m.dontseeme = &i
  8803. m.adddontseeme = nil
  8804. }
  8805. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8806. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8807. v := m.dontseeme
  8808. if v == nil {
  8809. return
  8810. }
  8811. return *v, true
  8812. }
  8813. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8814. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8816. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8817. if !m.op.Is(OpUpdateOne) {
  8818. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8819. }
  8820. if m.id == nil || m.oldValue == nil {
  8821. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8822. }
  8823. oldValue, err := m.oldValue(ctx)
  8824. if err != nil {
  8825. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8826. }
  8827. return oldValue.Dontseeme, nil
  8828. }
  8829. // AddDontseeme adds i to the "dontseeme" field.
  8830. func (m *ContactMutation) AddDontseeme(i int) {
  8831. if m.adddontseeme != nil {
  8832. *m.adddontseeme += i
  8833. } else {
  8834. m.adddontseeme = &i
  8835. }
  8836. }
  8837. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8838. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8839. v := m.adddontseeme
  8840. if v == nil {
  8841. return
  8842. }
  8843. return *v, true
  8844. }
  8845. // ResetDontseeme resets all changes to the "dontseeme" field.
  8846. func (m *ContactMutation) ResetDontseeme() {
  8847. m.dontseeme = nil
  8848. m.adddontseeme = nil
  8849. }
  8850. // SetLag sets the "lag" field.
  8851. func (m *ContactMutation) SetLag(s string) {
  8852. m.lag = &s
  8853. }
  8854. // Lag returns the value of the "lag" field in the mutation.
  8855. func (m *ContactMutation) Lag() (r string, exists bool) {
  8856. v := m.lag
  8857. if v == nil {
  8858. return
  8859. }
  8860. return *v, true
  8861. }
  8862. // OldLag returns the old "lag" field's value of the Contact entity.
  8863. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8865. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8866. if !m.op.Is(OpUpdateOne) {
  8867. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8868. }
  8869. if m.id == nil || m.oldValue == nil {
  8870. return v, errors.New("OldLag requires an ID field in the mutation")
  8871. }
  8872. oldValue, err := m.oldValue(ctx)
  8873. if err != nil {
  8874. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8875. }
  8876. return oldValue.Lag, nil
  8877. }
  8878. // ResetLag resets all changes to the "lag" field.
  8879. func (m *ContactMutation) ResetLag() {
  8880. m.lag = nil
  8881. }
  8882. // SetGid sets the "gid" field.
  8883. func (m *ContactMutation) SetGid(s string) {
  8884. m.gid = &s
  8885. }
  8886. // Gid returns the value of the "gid" field in the mutation.
  8887. func (m *ContactMutation) Gid() (r string, exists bool) {
  8888. v := m.gid
  8889. if v == nil {
  8890. return
  8891. }
  8892. return *v, true
  8893. }
  8894. // OldGid returns the old "gid" field's value of the Contact entity.
  8895. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8897. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8898. if !m.op.Is(OpUpdateOne) {
  8899. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8900. }
  8901. if m.id == nil || m.oldValue == nil {
  8902. return v, errors.New("OldGid requires an ID field in the mutation")
  8903. }
  8904. oldValue, err := m.oldValue(ctx)
  8905. if err != nil {
  8906. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8907. }
  8908. return oldValue.Gid, nil
  8909. }
  8910. // ResetGid resets all changes to the "gid" field.
  8911. func (m *ContactMutation) ResetGid() {
  8912. m.gid = nil
  8913. }
  8914. // SetGname sets the "gname" field.
  8915. func (m *ContactMutation) SetGname(s string) {
  8916. m.gname = &s
  8917. }
  8918. // Gname returns the value of the "gname" field in the mutation.
  8919. func (m *ContactMutation) Gname() (r string, exists bool) {
  8920. v := m.gname
  8921. if v == nil {
  8922. return
  8923. }
  8924. return *v, true
  8925. }
  8926. // OldGname returns the old "gname" field's value of the Contact entity.
  8927. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8929. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8930. if !m.op.Is(OpUpdateOne) {
  8931. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8932. }
  8933. if m.id == nil || m.oldValue == nil {
  8934. return v, errors.New("OldGname requires an ID field in the mutation")
  8935. }
  8936. oldValue, err := m.oldValue(ctx)
  8937. if err != nil {
  8938. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8939. }
  8940. return oldValue.Gname, nil
  8941. }
  8942. // ResetGname resets all changes to the "gname" field.
  8943. func (m *ContactMutation) ResetGname() {
  8944. m.gname = nil
  8945. }
  8946. // SetV3 sets the "v3" field.
  8947. func (m *ContactMutation) SetV3(s string) {
  8948. m.v3 = &s
  8949. }
  8950. // V3 returns the value of the "v3" field in the mutation.
  8951. func (m *ContactMutation) V3() (r string, exists bool) {
  8952. v := m.v3
  8953. if v == nil {
  8954. return
  8955. }
  8956. return *v, true
  8957. }
  8958. // OldV3 returns the old "v3" field's value of the Contact entity.
  8959. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8960. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8961. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8962. if !m.op.Is(OpUpdateOne) {
  8963. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8964. }
  8965. if m.id == nil || m.oldValue == nil {
  8966. return v, errors.New("OldV3 requires an ID field in the mutation")
  8967. }
  8968. oldValue, err := m.oldValue(ctx)
  8969. if err != nil {
  8970. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8971. }
  8972. return oldValue.V3, nil
  8973. }
  8974. // ResetV3 resets all changes to the "v3" field.
  8975. func (m *ContactMutation) ResetV3() {
  8976. m.v3 = nil
  8977. }
  8978. // SetOrganizationID sets the "organization_id" field.
  8979. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8980. m.organization_id = &u
  8981. m.addorganization_id = nil
  8982. }
  8983. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8984. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8985. v := m.organization_id
  8986. if v == nil {
  8987. return
  8988. }
  8989. return *v, true
  8990. }
  8991. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8992. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8994. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8995. if !m.op.Is(OpUpdateOne) {
  8996. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8997. }
  8998. if m.id == nil || m.oldValue == nil {
  8999. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9000. }
  9001. oldValue, err := m.oldValue(ctx)
  9002. if err != nil {
  9003. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9004. }
  9005. return oldValue.OrganizationID, nil
  9006. }
  9007. // AddOrganizationID adds u to the "organization_id" field.
  9008. func (m *ContactMutation) AddOrganizationID(u int64) {
  9009. if m.addorganization_id != nil {
  9010. *m.addorganization_id += u
  9011. } else {
  9012. m.addorganization_id = &u
  9013. }
  9014. }
  9015. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9016. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  9017. v := m.addorganization_id
  9018. if v == nil {
  9019. return
  9020. }
  9021. return *v, true
  9022. }
  9023. // ClearOrganizationID clears the value of the "organization_id" field.
  9024. func (m *ContactMutation) ClearOrganizationID() {
  9025. m.organization_id = nil
  9026. m.addorganization_id = nil
  9027. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  9028. }
  9029. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9030. func (m *ContactMutation) OrganizationIDCleared() bool {
  9031. _, ok := m.clearedFields[contact.FieldOrganizationID]
  9032. return ok
  9033. }
  9034. // ResetOrganizationID resets all changes to the "organization_id" field.
  9035. func (m *ContactMutation) ResetOrganizationID() {
  9036. m.organization_id = nil
  9037. m.addorganization_id = nil
  9038. delete(m.clearedFields, contact.FieldOrganizationID)
  9039. }
  9040. // SetCtype sets the "ctype" field.
  9041. func (m *ContactMutation) SetCtype(u uint64) {
  9042. m.ctype = &u
  9043. m.addctype = nil
  9044. }
  9045. // Ctype returns the value of the "ctype" field in the mutation.
  9046. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  9047. v := m.ctype
  9048. if v == nil {
  9049. return
  9050. }
  9051. return *v, true
  9052. }
  9053. // OldCtype returns the old "ctype" field's value of the Contact entity.
  9054. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9056. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  9057. if !m.op.Is(OpUpdateOne) {
  9058. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  9059. }
  9060. if m.id == nil || m.oldValue == nil {
  9061. return v, errors.New("OldCtype requires an ID field in the mutation")
  9062. }
  9063. oldValue, err := m.oldValue(ctx)
  9064. if err != nil {
  9065. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  9066. }
  9067. return oldValue.Ctype, nil
  9068. }
  9069. // AddCtype adds u to the "ctype" field.
  9070. func (m *ContactMutation) AddCtype(u int64) {
  9071. if m.addctype != nil {
  9072. *m.addctype += u
  9073. } else {
  9074. m.addctype = &u
  9075. }
  9076. }
  9077. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  9078. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  9079. v := m.addctype
  9080. if v == nil {
  9081. return
  9082. }
  9083. return *v, true
  9084. }
  9085. // ResetCtype resets all changes to the "ctype" field.
  9086. func (m *ContactMutation) ResetCtype() {
  9087. m.ctype = nil
  9088. m.addctype = nil
  9089. }
  9090. // SetCage sets the "cage" field.
  9091. func (m *ContactMutation) SetCage(i int) {
  9092. m.cage = &i
  9093. m.addcage = nil
  9094. }
  9095. // Cage returns the value of the "cage" field in the mutation.
  9096. func (m *ContactMutation) Cage() (r int, exists bool) {
  9097. v := m.cage
  9098. if v == nil {
  9099. return
  9100. }
  9101. return *v, true
  9102. }
  9103. // OldCage returns the old "cage" field's value of the Contact entity.
  9104. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9106. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  9107. if !m.op.Is(OpUpdateOne) {
  9108. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  9109. }
  9110. if m.id == nil || m.oldValue == nil {
  9111. return v, errors.New("OldCage requires an ID field in the mutation")
  9112. }
  9113. oldValue, err := m.oldValue(ctx)
  9114. if err != nil {
  9115. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  9116. }
  9117. return oldValue.Cage, nil
  9118. }
  9119. // AddCage adds i to the "cage" field.
  9120. func (m *ContactMutation) AddCage(i int) {
  9121. if m.addcage != nil {
  9122. *m.addcage += i
  9123. } else {
  9124. m.addcage = &i
  9125. }
  9126. }
  9127. // AddedCage returns the value that was added to the "cage" field in this mutation.
  9128. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  9129. v := m.addcage
  9130. if v == nil {
  9131. return
  9132. }
  9133. return *v, true
  9134. }
  9135. // ResetCage resets all changes to the "cage" field.
  9136. func (m *ContactMutation) ResetCage() {
  9137. m.cage = nil
  9138. m.addcage = nil
  9139. }
  9140. // SetCname sets the "cname" field.
  9141. func (m *ContactMutation) SetCname(s string) {
  9142. m.cname = &s
  9143. }
  9144. // Cname returns the value of the "cname" field in the mutation.
  9145. func (m *ContactMutation) Cname() (r string, exists bool) {
  9146. v := m.cname
  9147. if v == nil {
  9148. return
  9149. }
  9150. return *v, true
  9151. }
  9152. // OldCname returns the old "cname" field's value of the Contact entity.
  9153. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9155. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  9156. if !m.op.Is(OpUpdateOne) {
  9157. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  9158. }
  9159. if m.id == nil || m.oldValue == nil {
  9160. return v, errors.New("OldCname requires an ID field in the mutation")
  9161. }
  9162. oldValue, err := m.oldValue(ctx)
  9163. if err != nil {
  9164. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  9165. }
  9166. return oldValue.Cname, nil
  9167. }
  9168. // ResetCname resets all changes to the "cname" field.
  9169. func (m *ContactMutation) ResetCname() {
  9170. m.cname = nil
  9171. }
  9172. // SetCarea sets the "carea" field.
  9173. func (m *ContactMutation) SetCarea(s string) {
  9174. m.carea = &s
  9175. }
  9176. // Carea returns the value of the "carea" field in the mutation.
  9177. func (m *ContactMutation) Carea() (r string, exists bool) {
  9178. v := m.carea
  9179. if v == nil {
  9180. return
  9181. }
  9182. return *v, true
  9183. }
  9184. // OldCarea returns the old "carea" field's value of the Contact entity.
  9185. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9187. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  9188. if !m.op.Is(OpUpdateOne) {
  9189. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  9190. }
  9191. if m.id == nil || m.oldValue == nil {
  9192. return v, errors.New("OldCarea requires an ID field in the mutation")
  9193. }
  9194. oldValue, err := m.oldValue(ctx)
  9195. if err != nil {
  9196. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  9197. }
  9198. return oldValue.Carea, nil
  9199. }
  9200. // ResetCarea resets all changes to the "carea" field.
  9201. func (m *ContactMutation) ResetCarea() {
  9202. m.carea = nil
  9203. }
  9204. // SetCbirthday sets the "cbirthday" field.
  9205. func (m *ContactMutation) SetCbirthday(s string) {
  9206. m.cbirthday = &s
  9207. }
  9208. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  9209. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  9210. v := m.cbirthday
  9211. if v == nil {
  9212. return
  9213. }
  9214. return *v, true
  9215. }
  9216. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  9217. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9219. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  9220. if !m.op.Is(OpUpdateOne) {
  9221. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  9222. }
  9223. if m.id == nil || m.oldValue == nil {
  9224. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  9225. }
  9226. oldValue, err := m.oldValue(ctx)
  9227. if err != nil {
  9228. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  9229. }
  9230. return oldValue.Cbirthday, nil
  9231. }
  9232. // ResetCbirthday resets all changes to the "cbirthday" field.
  9233. func (m *ContactMutation) ResetCbirthday() {
  9234. m.cbirthday = nil
  9235. }
  9236. // SetCbirtharea sets the "cbirtharea" field.
  9237. func (m *ContactMutation) SetCbirtharea(s string) {
  9238. m.cbirtharea = &s
  9239. }
  9240. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  9241. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  9242. v := m.cbirtharea
  9243. if v == nil {
  9244. return
  9245. }
  9246. return *v, true
  9247. }
  9248. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  9249. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9251. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  9252. if !m.op.Is(OpUpdateOne) {
  9253. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  9254. }
  9255. if m.id == nil || m.oldValue == nil {
  9256. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  9257. }
  9258. oldValue, err := m.oldValue(ctx)
  9259. if err != nil {
  9260. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  9261. }
  9262. return oldValue.Cbirtharea, nil
  9263. }
  9264. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  9265. func (m *ContactMutation) ResetCbirtharea() {
  9266. m.cbirtharea = nil
  9267. }
  9268. // SetCidcardNo sets the "cidcard_no" field.
  9269. func (m *ContactMutation) SetCidcardNo(s string) {
  9270. m.cidcard_no = &s
  9271. }
  9272. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  9273. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  9274. v := m.cidcard_no
  9275. if v == nil {
  9276. return
  9277. }
  9278. return *v, true
  9279. }
  9280. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  9281. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9283. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  9284. if !m.op.Is(OpUpdateOne) {
  9285. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  9286. }
  9287. if m.id == nil || m.oldValue == nil {
  9288. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  9289. }
  9290. oldValue, err := m.oldValue(ctx)
  9291. if err != nil {
  9292. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  9293. }
  9294. return oldValue.CidcardNo, nil
  9295. }
  9296. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  9297. func (m *ContactMutation) ResetCidcardNo() {
  9298. m.cidcard_no = nil
  9299. }
  9300. // SetCtitle sets the "ctitle" field.
  9301. func (m *ContactMutation) SetCtitle(s string) {
  9302. m.ctitle = &s
  9303. }
  9304. // Ctitle returns the value of the "ctitle" field in the mutation.
  9305. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  9306. v := m.ctitle
  9307. if v == nil {
  9308. return
  9309. }
  9310. return *v, true
  9311. }
  9312. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  9313. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9315. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  9316. if !m.op.Is(OpUpdateOne) {
  9317. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  9318. }
  9319. if m.id == nil || m.oldValue == nil {
  9320. return v, errors.New("OldCtitle requires an ID field in the mutation")
  9321. }
  9322. oldValue, err := m.oldValue(ctx)
  9323. if err != nil {
  9324. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  9325. }
  9326. return oldValue.Ctitle, nil
  9327. }
  9328. // ResetCtitle resets all changes to the "ctitle" field.
  9329. func (m *ContactMutation) ResetCtitle() {
  9330. m.ctitle = nil
  9331. }
  9332. // SetCc sets the "cc" field.
  9333. func (m *ContactMutation) SetCc(s string) {
  9334. m.cc = &s
  9335. }
  9336. // Cc returns the value of the "cc" field in the mutation.
  9337. func (m *ContactMutation) Cc() (r string, exists bool) {
  9338. v := m.cc
  9339. if v == nil {
  9340. return
  9341. }
  9342. return *v, true
  9343. }
  9344. // OldCc returns the old "cc" field's value of the Contact entity.
  9345. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9347. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  9348. if !m.op.Is(OpUpdateOne) {
  9349. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  9350. }
  9351. if m.id == nil || m.oldValue == nil {
  9352. return v, errors.New("OldCc requires an ID field in the mutation")
  9353. }
  9354. oldValue, err := m.oldValue(ctx)
  9355. if err != nil {
  9356. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  9357. }
  9358. return oldValue.Cc, nil
  9359. }
  9360. // ResetCc resets all changes to the "cc" field.
  9361. func (m *ContactMutation) ResetCc() {
  9362. m.cc = nil
  9363. }
  9364. // SetPhone sets the "phone" field.
  9365. func (m *ContactMutation) SetPhone(s string) {
  9366. m.phone = &s
  9367. }
  9368. // Phone returns the value of the "phone" field in the mutation.
  9369. func (m *ContactMutation) Phone() (r string, exists bool) {
  9370. v := m.phone
  9371. if v == nil {
  9372. return
  9373. }
  9374. return *v, true
  9375. }
  9376. // OldPhone returns the old "phone" field's value of the Contact entity.
  9377. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9379. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  9380. if !m.op.Is(OpUpdateOne) {
  9381. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  9382. }
  9383. if m.id == nil || m.oldValue == nil {
  9384. return v, errors.New("OldPhone requires an ID field in the mutation")
  9385. }
  9386. oldValue, err := m.oldValue(ctx)
  9387. if err != nil {
  9388. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  9389. }
  9390. return oldValue.Phone, nil
  9391. }
  9392. // ResetPhone resets all changes to the "phone" field.
  9393. func (m *ContactMutation) ResetPhone() {
  9394. m.phone = nil
  9395. }
  9396. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  9397. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  9398. if m.contact_relationships == nil {
  9399. m.contact_relationships = make(map[uint64]struct{})
  9400. }
  9401. for i := range ids {
  9402. m.contact_relationships[ids[i]] = struct{}{}
  9403. }
  9404. }
  9405. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  9406. func (m *ContactMutation) ClearContactRelationships() {
  9407. m.clearedcontact_relationships = true
  9408. }
  9409. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  9410. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  9411. return m.clearedcontact_relationships
  9412. }
  9413. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  9414. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  9415. if m.removedcontact_relationships == nil {
  9416. m.removedcontact_relationships = make(map[uint64]struct{})
  9417. }
  9418. for i := range ids {
  9419. delete(m.contact_relationships, ids[i])
  9420. m.removedcontact_relationships[ids[i]] = struct{}{}
  9421. }
  9422. }
  9423. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  9424. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  9425. for id := range m.removedcontact_relationships {
  9426. ids = append(ids, id)
  9427. }
  9428. return
  9429. }
  9430. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  9431. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  9432. for id := range m.contact_relationships {
  9433. ids = append(ids, id)
  9434. }
  9435. return
  9436. }
  9437. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  9438. func (m *ContactMutation) ResetContactRelationships() {
  9439. m.contact_relationships = nil
  9440. m.clearedcontact_relationships = false
  9441. m.removedcontact_relationships = nil
  9442. }
  9443. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  9444. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  9445. if m.contact_messages == nil {
  9446. m.contact_messages = make(map[uint64]struct{})
  9447. }
  9448. for i := range ids {
  9449. m.contact_messages[ids[i]] = struct{}{}
  9450. }
  9451. }
  9452. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  9453. func (m *ContactMutation) ClearContactMessages() {
  9454. m.clearedcontact_messages = true
  9455. }
  9456. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  9457. func (m *ContactMutation) ContactMessagesCleared() bool {
  9458. return m.clearedcontact_messages
  9459. }
  9460. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  9461. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  9462. if m.removedcontact_messages == nil {
  9463. m.removedcontact_messages = make(map[uint64]struct{})
  9464. }
  9465. for i := range ids {
  9466. delete(m.contact_messages, ids[i])
  9467. m.removedcontact_messages[ids[i]] = struct{}{}
  9468. }
  9469. }
  9470. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  9471. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  9472. for id := range m.removedcontact_messages {
  9473. ids = append(ids, id)
  9474. }
  9475. return
  9476. }
  9477. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  9478. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  9479. for id := range m.contact_messages {
  9480. ids = append(ids, id)
  9481. }
  9482. return
  9483. }
  9484. // ResetContactMessages resets all changes to the "contact_messages" edge.
  9485. func (m *ContactMutation) ResetContactMessages() {
  9486. m.contact_messages = nil
  9487. m.clearedcontact_messages = false
  9488. m.removedcontact_messages = nil
  9489. }
  9490. // Where appends a list predicates to the ContactMutation builder.
  9491. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  9492. m.predicates = append(m.predicates, ps...)
  9493. }
  9494. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  9495. // users can use type-assertion to append predicates that do not depend on any generated package.
  9496. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  9497. p := make([]predicate.Contact, len(ps))
  9498. for i := range ps {
  9499. p[i] = ps[i]
  9500. }
  9501. m.Where(p...)
  9502. }
  9503. // Op returns the operation name.
  9504. func (m *ContactMutation) Op() Op {
  9505. return m.op
  9506. }
  9507. // SetOp allows setting the mutation operation.
  9508. func (m *ContactMutation) SetOp(op Op) {
  9509. m.op = op
  9510. }
  9511. // Type returns the node type of this mutation (Contact).
  9512. func (m *ContactMutation) Type() string {
  9513. return m.typ
  9514. }
  9515. // Fields returns all fields that were changed during this mutation. Note that in
  9516. // order to get all numeric fields that were incremented/decremented, call
  9517. // AddedFields().
  9518. func (m *ContactMutation) Fields() []string {
  9519. fields := make([]string, 0, 30)
  9520. if m.created_at != nil {
  9521. fields = append(fields, contact.FieldCreatedAt)
  9522. }
  9523. if m.updated_at != nil {
  9524. fields = append(fields, contact.FieldUpdatedAt)
  9525. }
  9526. if m.status != nil {
  9527. fields = append(fields, contact.FieldStatus)
  9528. }
  9529. if m.deleted_at != nil {
  9530. fields = append(fields, contact.FieldDeletedAt)
  9531. }
  9532. if m.wx_wxid != nil {
  9533. fields = append(fields, contact.FieldWxWxid)
  9534. }
  9535. if m._type != nil {
  9536. fields = append(fields, contact.FieldType)
  9537. }
  9538. if m.wxid != nil {
  9539. fields = append(fields, contact.FieldWxid)
  9540. }
  9541. if m.account != nil {
  9542. fields = append(fields, contact.FieldAccount)
  9543. }
  9544. if m.nickname != nil {
  9545. fields = append(fields, contact.FieldNickname)
  9546. }
  9547. if m.markname != nil {
  9548. fields = append(fields, contact.FieldMarkname)
  9549. }
  9550. if m.headimg != nil {
  9551. fields = append(fields, contact.FieldHeadimg)
  9552. }
  9553. if m.sex != nil {
  9554. fields = append(fields, contact.FieldSex)
  9555. }
  9556. if m.starrole != nil {
  9557. fields = append(fields, contact.FieldStarrole)
  9558. }
  9559. if m.dontseeit != nil {
  9560. fields = append(fields, contact.FieldDontseeit)
  9561. }
  9562. if m.dontseeme != nil {
  9563. fields = append(fields, contact.FieldDontseeme)
  9564. }
  9565. if m.lag != nil {
  9566. fields = append(fields, contact.FieldLag)
  9567. }
  9568. if m.gid != nil {
  9569. fields = append(fields, contact.FieldGid)
  9570. }
  9571. if m.gname != nil {
  9572. fields = append(fields, contact.FieldGname)
  9573. }
  9574. if m.v3 != nil {
  9575. fields = append(fields, contact.FieldV3)
  9576. }
  9577. if m.organization_id != nil {
  9578. fields = append(fields, contact.FieldOrganizationID)
  9579. }
  9580. if m.ctype != nil {
  9581. fields = append(fields, contact.FieldCtype)
  9582. }
  9583. if m.cage != nil {
  9584. fields = append(fields, contact.FieldCage)
  9585. }
  9586. if m.cname != nil {
  9587. fields = append(fields, contact.FieldCname)
  9588. }
  9589. if m.carea != nil {
  9590. fields = append(fields, contact.FieldCarea)
  9591. }
  9592. if m.cbirthday != nil {
  9593. fields = append(fields, contact.FieldCbirthday)
  9594. }
  9595. if m.cbirtharea != nil {
  9596. fields = append(fields, contact.FieldCbirtharea)
  9597. }
  9598. if m.cidcard_no != nil {
  9599. fields = append(fields, contact.FieldCidcardNo)
  9600. }
  9601. if m.ctitle != nil {
  9602. fields = append(fields, contact.FieldCtitle)
  9603. }
  9604. if m.cc != nil {
  9605. fields = append(fields, contact.FieldCc)
  9606. }
  9607. if m.phone != nil {
  9608. fields = append(fields, contact.FieldPhone)
  9609. }
  9610. return fields
  9611. }
  9612. // Field returns the value of a field with the given name. The second boolean
  9613. // return value indicates that this field was not set, or was not defined in the
  9614. // schema.
  9615. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  9616. switch name {
  9617. case contact.FieldCreatedAt:
  9618. return m.CreatedAt()
  9619. case contact.FieldUpdatedAt:
  9620. return m.UpdatedAt()
  9621. case contact.FieldStatus:
  9622. return m.Status()
  9623. case contact.FieldDeletedAt:
  9624. return m.DeletedAt()
  9625. case contact.FieldWxWxid:
  9626. return m.WxWxid()
  9627. case contact.FieldType:
  9628. return m.GetType()
  9629. case contact.FieldWxid:
  9630. return m.Wxid()
  9631. case contact.FieldAccount:
  9632. return m.Account()
  9633. case contact.FieldNickname:
  9634. return m.Nickname()
  9635. case contact.FieldMarkname:
  9636. return m.Markname()
  9637. case contact.FieldHeadimg:
  9638. return m.Headimg()
  9639. case contact.FieldSex:
  9640. return m.Sex()
  9641. case contact.FieldStarrole:
  9642. return m.Starrole()
  9643. case contact.FieldDontseeit:
  9644. return m.Dontseeit()
  9645. case contact.FieldDontseeme:
  9646. return m.Dontseeme()
  9647. case contact.FieldLag:
  9648. return m.Lag()
  9649. case contact.FieldGid:
  9650. return m.Gid()
  9651. case contact.FieldGname:
  9652. return m.Gname()
  9653. case contact.FieldV3:
  9654. return m.V3()
  9655. case contact.FieldOrganizationID:
  9656. return m.OrganizationID()
  9657. case contact.FieldCtype:
  9658. return m.Ctype()
  9659. case contact.FieldCage:
  9660. return m.Cage()
  9661. case contact.FieldCname:
  9662. return m.Cname()
  9663. case contact.FieldCarea:
  9664. return m.Carea()
  9665. case contact.FieldCbirthday:
  9666. return m.Cbirthday()
  9667. case contact.FieldCbirtharea:
  9668. return m.Cbirtharea()
  9669. case contact.FieldCidcardNo:
  9670. return m.CidcardNo()
  9671. case contact.FieldCtitle:
  9672. return m.Ctitle()
  9673. case contact.FieldCc:
  9674. return m.Cc()
  9675. case contact.FieldPhone:
  9676. return m.Phone()
  9677. }
  9678. return nil, false
  9679. }
  9680. // OldField returns the old value of the field from the database. An error is
  9681. // returned if the mutation operation is not UpdateOne, or the query to the
  9682. // database failed.
  9683. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9684. switch name {
  9685. case contact.FieldCreatedAt:
  9686. return m.OldCreatedAt(ctx)
  9687. case contact.FieldUpdatedAt:
  9688. return m.OldUpdatedAt(ctx)
  9689. case contact.FieldStatus:
  9690. return m.OldStatus(ctx)
  9691. case contact.FieldDeletedAt:
  9692. return m.OldDeletedAt(ctx)
  9693. case contact.FieldWxWxid:
  9694. return m.OldWxWxid(ctx)
  9695. case contact.FieldType:
  9696. return m.OldType(ctx)
  9697. case contact.FieldWxid:
  9698. return m.OldWxid(ctx)
  9699. case contact.FieldAccount:
  9700. return m.OldAccount(ctx)
  9701. case contact.FieldNickname:
  9702. return m.OldNickname(ctx)
  9703. case contact.FieldMarkname:
  9704. return m.OldMarkname(ctx)
  9705. case contact.FieldHeadimg:
  9706. return m.OldHeadimg(ctx)
  9707. case contact.FieldSex:
  9708. return m.OldSex(ctx)
  9709. case contact.FieldStarrole:
  9710. return m.OldStarrole(ctx)
  9711. case contact.FieldDontseeit:
  9712. return m.OldDontseeit(ctx)
  9713. case contact.FieldDontseeme:
  9714. return m.OldDontseeme(ctx)
  9715. case contact.FieldLag:
  9716. return m.OldLag(ctx)
  9717. case contact.FieldGid:
  9718. return m.OldGid(ctx)
  9719. case contact.FieldGname:
  9720. return m.OldGname(ctx)
  9721. case contact.FieldV3:
  9722. return m.OldV3(ctx)
  9723. case contact.FieldOrganizationID:
  9724. return m.OldOrganizationID(ctx)
  9725. case contact.FieldCtype:
  9726. return m.OldCtype(ctx)
  9727. case contact.FieldCage:
  9728. return m.OldCage(ctx)
  9729. case contact.FieldCname:
  9730. return m.OldCname(ctx)
  9731. case contact.FieldCarea:
  9732. return m.OldCarea(ctx)
  9733. case contact.FieldCbirthday:
  9734. return m.OldCbirthday(ctx)
  9735. case contact.FieldCbirtharea:
  9736. return m.OldCbirtharea(ctx)
  9737. case contact.FieldCidcardNo:
  9738. return m.OldCidcardNo(ctx)
  9739. case contact.FieldCtitle:
  9740. return m.OldCtitle(ctx)
  9741. case contact.FieldCc:
  9742. return m.OldCc(ctx)
  9743. case contact.FieldPhone:
  9744. return m.OldPhone(ctx)
  9745. }
  9746. return nil, fmt.Errorf("unknown Contact field %s", name)
  9747. }
  9748. // SetField sets the value of a field with the given name. It returns an error if
  9749. // the field is not defined in the schema, or if the type mismatched the field
  9750. // type.
  9751. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  9752. switch name {
  9753. case contact.FieldCreatedAt:
  9754. v, ok := value.(time.Time)
  9755. if !ok {
  9756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9757. }
  9758. m.SetCreatedAt(v)
  9759. return nil
  9760. case contact.FieldUpdatedAt:
  9761. v, ok := value.(time.Time)
  9762. if !ok {
  9763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9764. }
  9765. m.SetUpdatedAt(v)
  9766. return nil
  9767. case contact.FieldStatus:
  9768. v, ok := value.(uint8)
  9769. if !ok {
  9770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9771. }
  9772. m.SetStatus(v)
  9773. return nil
  9774. case contact.FieldDeletedAt:
  9775. v, ok := value.(time.Time)
  9776. if !ok {
  9777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9778. }
  9779. m.SetDeletedAt(v)
  9780. return nil
  9781. case contact.FieldWxWxid:
  9782. v, ok := value.(string)
  9783. if !ok {
  9784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9785. }
  9786. m.SetWxWxid(v)
  9787. return nil
  9788. case contact.FieldType:
  9789. v, ok := value.(int)
  9790. if !ok {
  9791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9792. }
  9793. m.SetType(v)
  9794. return nil
  9795. case contact.FieldWxid:
  9796. v, ok := value.(string)
  9797. if !ok {
  9798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9799. }
  9800. m.SetWxid(v)
  9801. return nil
  9802. case contact.FieldAccount:
  9803. v, ok := value.(string)
  9804. if !ok {
  9805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9806. }
  9807. m.SetAccount(v)
  9808. return nil
  9809. case contact.FieldNickname:
  9810. v, ok := value.(string)
  9811. if !ok {
  9812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9813. }
  9814. m.SetNickname(v)
  9815. return nil
  9816. case contact.FieldMarkname:
  9817. v, ok := value.(string)
  9818. if !ok {
  9819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9820. }
  9821. m.SetMarkname(v)
  9822. return nil
  9823. case contact.FieldHeadimg:
  9824. v, ok := value.(string)
  9825. if !ok {
  9826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9827. }
  9828. m.SetHeadimg(v)
  9829. return nil
  9830. case contact.FieldSex:
  9831. v, ok := value.(int)
  9832. if !ok {
  9833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9834. }
  9835. m.SetSex(v)
  9836. return nil
  9837. case contact.FieldStarrole:
  9838. v, ok := value.(string)
  9839. if !ok {
  9840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9841. }
  9842. m.SetStarrole(v)
  9843. return nil
  9844. case contact.FieldDontseeit:
  9845. v, ok := value.(int)
  9846. if !ok {
  9847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9848. }
  9849. m.SetDontseeit(v)
  9850. return nil
  9851. case contact.FieldDontseeme:
  9852. v, ok := value.(int)
  9853. if !ok {
  9854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9855. }
  9856. m.SetDontseeme(v)
  9857. return nil
  9858. case contact.FieldLag:
  9859. v, ok := value.(string)
  9860. if !ok {
  9861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9862. }
  9863. m.SetLag(v)
  9864. return nil
  9865. case contact.FieldGid:
  9866. v, ok := value.(string)
  9867. if !ok {
  9868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9869. }
  9870. m.SetGid(v)
  9871. return nil
  9872. case contact.FieldGname:
  9873. v, ok := value.(string)
  9874. if !ok {
  9875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9876. }
  9877. m.SetGname(v)
  9878. return nil
  9879. case contact.FieldV3:
  9880. v, ok := value.(string)
  9881. if !ok {
  9882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9883. }
  9884. m.SetV3(v)
  9885. return nil
  9886. case contact.FieldOrganizationID:
  9887. v, ok := value.(uint64)
  9888. if !ok {
  9889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9890. }
  9891. m.SetOrganizationID(v)
  9892. return nil
  9893. case contact.FieldCtype:
  9894. v, ok := value.(uint64)
  9895. if !ok {
  9896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9897. }
  9898. m.SetCtype(v)
  9899. return nil
  9900. case contact.FieldCage:
  9901. v, ok := value.(int)
  9902. if !ok {
  9903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9904. }
  9905. m.SetCage(v)
  9906. return nil
  9907. case contact.FieldCname:
  9908. v, ok := value.(string)
  9909. if !ok {
  9910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9911. }
  9912. m.SetCname(v)
  9913. return nil
  9914. case contact.FieldCarea:
  9915. v, ok := value.(string)
  9916. if !ok {
  9917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9918. }
  9919. m.SetCarea(v)
  9920. return nil
  9921. case contact.FieldCbirthday:
  9922. v, ok := value.(string)
  9923. if !ok {
  9924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9925. }
  9926. m.SetCbirthday(v)
  9927. return nil
  9928. case contact.FieldCbirtharea:
  9929. v, ok := value.(string)
  9930. if !ok {
  9931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9932. }
  9933. m.SetCbirtharea(v)
  9934. return nil
  9935. case contact.FieldCidcardNo:
  9936. v, ok := value.(string)
  9937. if !ok {
  9938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9939. }
  9940. m.SetCidcardNo(v)
  9941. return nil
  9942. case contact.FieldCtitle:
  9943. v, ok := value.(string)
  9944. if !ok {
  9945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9946. }
  9947. m.SetCtitle(v)
  9948. return nil
  9949. case contact.FieldCc:
  9950. v, ok := value.(string)
  9951. if !ok {
  9952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9953. }
  9954. m.SetCc(v)
  9955. return nil
  9956. case contact.FieldPhone:
  9957. v, ok := value.(string)
  9958. if !ok {
  9959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9960. }
  9961. m.SetPhone(v)
  9962. return nil
  9963. }
  9964. return fmt.Errorf("unknown Contact field %s", name)
  9965. }
  9966. // AddedFields returns all numeric fields that were incremented/decremented during
  9967. // this mutation.
  9968. func (m *ContactMutation) AddedFields() []string {
  9969. var fields []string
  9970. if m.addstatus != nil {
  9971. fields = append(fields, contact.FieldStatus)
  9972. }
  9973. if m.add_type != nil {
  9974. fields = append(fields, contact.FieldType)
  9975. }
  9976. if m.addsex != nil {
  9977. fields = append(fields, contact.FieldSex)
  9978. }
  9979. if m.adddontseeit != nil {
  9980. fields = append(fields, contact.FieldDontseeit)
  9981. }
  9982. if m.adddontseeme != nil {
  9983. fields = append(fields, contact.FieldDontseeme)
  9984. }
  9985. if m.addorganization_id != nil {
  9986. fields = append(fields, contact.FieldOrganizationID)
  9987. }
  9988. if m.addctype != nil {
  9989. fields = append(fields, contact.FieldCtype)
  9990. }
  9991. if m.addcage != nil {
  9992. fields = append(fields, contact.FieldCage)
  9993. }
  9994. return fields
  9995. }
  9996. // AddedField returns the numeric value that was incremented/decremented on a field
  9997. // with the given name. The second boolean return value indicates that this field
  9998. // was not set, or was not defined in the schema.
  9999. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  10000. switch name {
  10001. case contact.FieldStatus:
  10002. return m.AddedStatus()
  10003. case contact.FieldType:
  10004. return m.AddedType()
  10005. case contact.FieldSex:
  10006. return m.AddedSex()
  10007. case contact.FieldDontseeit:
  10008. return m.AddedDontseeit()
  10009. case contact.FieldDontseeme:
  10010. return m.AddedDontseeme()
  10011. case contact.FieldOrganizationID:
  10012. return m.AddedOrganizationID()
  10013. case contact.FieldCtype:
  10014. return m.AddedCtype()
  10015. case contact.FieldCage:
  10016. return m.AddedCage()
  10017. }
  10018. return nil, false
  10019. }
  10020. // AddField adds the value to the field with the given name. It returns an error if
  10021. // the field is not defined in the schema, or if the type mismatched the field
  10022. // type.
  10023. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  10024. switch name {
  10025. case contact.FieldStatus:
  10026. v, ok := value.(int8)
  10027. if !ok {
  10028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10029. }
  10030. m.AddStatus(v)
  10031. return nil
  10032. case contact.FieldType:
  10033. v, ok := value.(int)
  10034. if !ok {
  10035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10036. }
  10037. m.AddType(v)
  10038. return nil
  10039. case contact.FieldSex:
  10040. v, ok := value.(int)
  10041. if !ok {
  10042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10043. }
  10044. m.AddSex(v)
  10045. return nil
  10046. case contact.FieldDontseeit:
  10047. v, ok := value.(int)
  10048. if !ok {
  10049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10050. }
  10051. m.AddDontseeit(v)
  10052. return nil
  10053. case contact.FieldDontseeme:
  10054. v, ok := value.(int)
  10055. if !ok {
  10056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10057. }
  10058. m.AddDontseeme(v)
  10059. return nil
  10060. case contact.FieldOrganizationID:
  10061. v, ok := value.(int64)
  10062. if !ok {
  10063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10064. }
  10065. m.AddOrganizationID(v)
  10066. return nil
  10067. case contact.FieldCtype:
  10068. v, ok := value.(int64)
  10069. if !ok {
  10070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10071. }
  10072. m.AddCtype(v)
  10073. return nil
  10074. case contact.FieldCage:
  10075. v, ok := value.(int)
  10076. if !ok {
  10077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10078. }
  10079. m.AddCage(v)
  10080. return nil
  10081. }
  10082. return fmt.Errorf("unknown Contact numeric field %s", name)
  10083. }
  10084. // ClearedFields returns all nullable fields that were cleared during this
  10085. // mutation.
  10086. func (m *ContactMutation) ClearedFields() []string {
  10087. var fields []string
  10088. if m.FieldCleared(contact.FieldStatus) {
  10089. fields = append(fields, contact.FieldStatus)
  10090. }
  10091. if m.FieldCleared(contact.FieldDeletedAt) {
  10092. fields = append(fields, contact.FieldDeletedAt)
  10093. }
  10094. if m.FieldCleared(contact.FieldType) {
  10095. fields = append(fields, contact.FieldType)
  10096. }
  10097. if m.FieldCleared(contact.FieldOrganizationID) {
  10098. fields = append(fields, contact.FieldOrganizationID)
  10099. }
  10100. return fields
  10101. }
  10102. // FieldCleared returns a boolean indicating if a field with the given name was
  10103. // cleared in this mutation.
  10104. func (m *ContactMutation) FieldCleared(name string) bool {
  10105. _, ok := m.clearedFields[name]
  10106. return ok
  10107. }
  10108. // ClearField clears the value of the field with the given name. It returns an
  10109. // error if the field is not defined in the schema.
  10110. func (m *ContactMutation) ClearField(name string) error {
  10111. switch name {
  10112. case contact.FieldStatus:
  10113. m.ClearStatus()
  10114. return nil
  10115. case contact.FieldDeletedAt:
  10116. m.ClearDeletedAt()
  10117. return nil
  10118. case contact.FieldType:
  10119. m.ClearType()
  10120. return nil
  10121. case contact.FieldOrganizationID:
  10122. m.ClearOrganizationID()
  10123. return nil
  10124. }
  10125. return fmt.Errorf("unknown Contact nullable field %s", name)
  10126. }
  10127. // ResetField resets all changes in the mutation for the field with the given name.
  10128. // It returns an error if the field is not defined in the schema.
  10129. func (m *ContactMutation) ResetField(name string) error {
  10130. switch name {
  10131. case contact.FieldCreatedAt:
  10132. m.ResetCreatedAt()
  10133. return nil
  10134. case contact.FieldUpdatedAt:
  10135. m.ResetUpdatedAt()
  10136. return nil
  10137. case contact.FieldStatus:
  10138. m.ResetStatus()
  10139. return nil
  10140. case contact.FieldDeletedAt:
  10141. m.ResetDeletedAt()
  10142. return nil
  10143. case contact.FieldWxWxid:
  10144. m.ResetWxWxid()
  10145. return nil
  10146. case contact.FieldType:
  10147. m.ResetType()
  10148. return nil
  10149. case contact.FieldWxid:
  10150. m.ResetWxid()
  10151. return nil
  10152. case contact.FieldAccount:
  10153. m.ResetAccount()
  10154. return nil
  10155. case contact.FieldNickname:
  10156. m.ResetNickname()
  10157. return nil
  10158. case contact.FieldMarkname:
  10159. m.ResetMarkname()
  10160. return nil
  10161. case contact.FieldHeadimg:
  10162. m.ResetHeadimg()
  10163. return nil
  10164. case contact.FieldSex:
  10165. m.ResetSex()
  10166. return nil
  10167. case contact.FieldStarrole:
  10168. m.ResetStarrole()
  10169. return nil
  10170. case contact.FieldDontseeit:
  10171. m.ResetDontseeit()
  10172. return nil
  10173. case contact.FieldDontseeme:
  10174. m.ResetDontseeme()
  10175. return nil
  10176. case contact.FieldLag:
  10177. m.ResetLag()
  10178. return nil
  10179. case contact.FieldGid:
  10180. m.ResetGid()
  10181. return nil
  10182. case contact.FieldGname:
  10183. m.ResetGname()
  10184. return nil
  10185. case contact.FieldV3:
  10186. m.ResetV3()
  10187. return nil
  10188. case contact.FieldOrganizationID:
  10189. m.ResetOrganizationID()
  10190. return nil
  10191. case contact.FieldCtype:
  10192. m.ResetCtype()
  10193. return nil
  10194. case contact.FieldCage:
  10195. m.ResetCage()
  10196. return nil
  10197. case contact.FieldCname:
  10198. m.ResetCname()
  10199. return nil
  10200. case contact.FieldCarea:
  10201. m.ResetCarea()
  10202. return nil
  10203. case contact.FieldCbirthday:
  10204. m.ResetCbirthday()
  10205. return nil
  10206. case contact.FieldCbirtharea:
  10207. m.ResetCbirtharea()
  10208. return nil
  10209. case contact.FieldCidcardNo:
  10210. m.ResetCidcardNo()
  10211. return nil
  10212. case contact.FieldCtitle:
  10213. m.ResetCtitle()
  10214. return nil
  10215. case contact.FieldCc:
  10216. m.ResetCc()
  10217. return nil
  10218. case contact.FieldPhone:
  10219. m.ResetPhone()
  10220. return nil
  10221. }
  10222. return fmt.Errorf("unknown Contact field %s", name)
  10223. }
  10224. // AddedEdges returns all edge names that were set/added in this mutation.
  10225. func (m *ContactMutation) AddedEdges() []string {
  10226. edges := make([]string, 0, 2)
  10227. if m.contact_relationships != nil {
  10228. edges = append(edges, contact.EdgeContactRelationships)
  10229. }
  10230. if m.contact_messages != nil {
  10231. edges = append(edges, contact.EdgeContactMessages)
  10232. }
  10233. return edges
  10234. }
  10235. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10236. // name in this mutation.
  10237. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  10238. switch name {
  10239. case contact.EdgeContactRelationships:
  10240. ids := make([]ent.Value, 0, len(m.contact_relationships))
  10241. for id := range m.contact_relationships {
  10242. ids = append(ids, id)
  10243. }
  10244. return ids
  10245. case contact.EdgeContactMessages:
  10246. ids := make([]ent.Value, 0, len(m.contact_messages))
  10247. for id := range m.contact_messages {
  10248. ids = append(ids, id)
  10249. }
  10250. return ids
  10251. }
  10252. return nil
  10253. }
  10254. // RemovedEdges returns all edge names that were removed in this mutation.
  10255. func (m *ContactMutation) RemovedEdges() []string {
  10256. edges := make([]string, 0, 2)
  10257. if m.removedcontact_relationships != nil {
  10258. edges = append(edges, contact.EdgeContactRelationships)
  10259. }
  10260. if m.removedcontact_messages != nil {
  10261. edges = append(edges, contact.EdgeContactMessages)
  10262. }
  10263. return edges
  10264. }
  10265. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10266. // the given name in this mutation.
  10267. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  10268. switch name {
  10269. case contact.EdgeContactRelationships:
  10270. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  10271. for id := range m.removedcontact_relationships {
  10272. ids = append(ids, id)
  10273. }
  10274. return ids
  10275. case contact.EdgeContactMessages:
  10276. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  10277. for id := range m.removedcontact_messages {
  10278. ids = append(ids, id)
  10279. }
  10280. return ids
  10281. }
  10282. return nil
  10283. }
  10284. // ClearedEdges returns all edge names that were cleared in this mutation.
  10285. func (m *ContactMutation) ClearedEdges() []string {
  10286. edges := make([]string, 0, 2)
  10287. if m.clearedcontact_relationships {
  10288. edges = append(edges, contact.EdgeContactRelationships)
  10289. }
  10290. if m.clearedcontact_messages {
  10291. edges = append(edges, contact.EdgeContactMessages)
  10292. }
  10293. return edges
  10294. }
  10295. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10296. // was cleared in this mutation.
  10297. func (m *ContactMutation) EdgeCleared(name string) bool {
  10298. switch name {
  10299. case contact.EdgeContactRelationships:
  10300. return m.clearedcontact_relationships
  10301. case contact.EdgeContactMessages:
  10302. return m.clearedcontact_messages
  10303. }
  10304. return false
  10305. }
  10306. // ClearEdge clears the value of the edge with the given name. It returns an error
  10307. // if that edge is not defined in the schema.
  10308. func (m *ContactMutation) ClearEdge(name string) error {
  10309. switch name {
  10310. }
  10311. return fmt.Errorf("unknown Contact unique edge %s", name)
  10312. }
  10313. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10314. // It returns an error if the edge is not defined in the schema.
  10315. func (m *ContactMutation) ResetEdge(name string) error {
  10316. switch name {
  10317. case contact.EdgeContactRelationships:
  10318. m.ResetContactRelationships()
  10319. return nil
  10320. case contact.EdgeContactMessages:
  10321. m.ResetContactMessages()
  10322. return nil
  10323. }
  10324. return fmt.Errorf("unknown Contact edge %s", name)
  10325. }
  10326. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  10327. type CreditBalanceMutation struct {
  10328. config
  10329. op Op
  10330. typ string
  10331. id *uint64
  10332. created_at *time.Time
  10333. updated_at *time.Time
  10334. deleted_at *time.Time
  10335. user_id *string
  10336. balance *float32
  10337. addbalance *float32
  10338. status *int
  10339. addstatus *int
  10340. organization_id *uint64
  10341. addorganization_id *int64
  10342. clearedFields map[string]struct{}
  10343. done bool
  10344. oldValue func(context.Context) (*CreditBalance, error)
  10345. predicates []predicate.CreditBalance
  10346. }
  10347. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  10348. // creditbalanceOption allows management of the mutation configuration using functional options.
  10349. type creditbalanceOption func(*CreditBalanceMutation)
  10350. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  10351. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  10352. m := &CreditBalanceMutation{
  10353. config: c,
  10354. op: op,
  10355. typ: TypeCreditBalance,
  10356. clearedFields: make(map[string]struct{}),
  10357. }
  10358. for _, opt := range opts {
  10359. opt(m)
  10360. }
  10361. return m
  10362. }
  10363. // withCreditBalanceID sets the ID field of the mutation.
  10364. func withCreditBalanceID(id uint64) creditbalanceOption {
  10365. return func(m *CreditBalanceMutation) {
  10366. var (
  10367. err error
  10368. once sync.Once
  10369. value *CreditBalance
  10370. )
  10371. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  10372. once.Do(func() {
  10373. if m.done {
  10374. err = errors.New("querying old values post mutation is not allowed")
  10375. } else {
  10376. value, err = m.Client().CreditBalance.Get(ctx, id)
  10377. }
  10378. })
  10379. return value, err
  10380. }
  10381. m.id = &id
  10382. }
  10383. }
  10384. // withCreditBalance sets the old CreditBalance of the mutation.
  10385. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  10386. return func(m *CreditBalanceMutation) {
  10387. m.oldValue = func(context.Context) (*CreditBalance, error) {
  10388. return node, nil
  10389. }
  10390. m.id = &node.ID
  10391. }
  10392. }
  10393. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10394. // executed in a transaction (ent.Tx), a transactional client is returned.
  10395. func (m CreditBalanceMutation) Client() *Client {
  10396. client := &Client{config: m.config}
  10397. client.init()
  10398. return client
  10399. }
  10400. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10401. // it returns an error otherwise.
  10402. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  10403. if _, ok := m.driver.(*txDriver); !ok {
  10404. return nil, errors.New("ent: mutation is not running in a transaction")
  10405. }
  10406. tx := &Tx{config: m.config}
  10407. tx.init()
  10408. return tx, nil
  10409. }
  10410. // SetID sets the value of the id field. Note that this
  10411. // operation is only accepted on creation of CreditBalance entities.
  10412. func (m *CreditBalanceMutation) SetID(id uint64) {
  10413. m.id = &id
  10414. }
  10415. // ID returns the ID value in the mutation. Note that the ID is only available
  10416. // if it was provided to the builder or after it was returned from the database.
  10417. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  10418. if m.id == nil {
  10419. return
  10420. }
  10421. return *m.id, true
  10422. }
  10423. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10424. // That means, if the mutation is applied within a transaction with an isolation level such
  10425. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10426. // or updated by the mutation.
  10427. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  10428. switch {
  10429. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10430. id, exists := m.ID()
  10431. if exists {
  10432. return []uint64{id}, nil
  10433. }
  10434. fallthrough
  10435. case m.op.Is(OpUpdate | OpDelete):
  10436. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  10437. default:
  10438. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10439. }
  10440. }
  10441. // SetCreatedAt sets the "created_at" field.
  10442. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  10443. m.created_at = &t
  10444. }
  10445. // CreatedAt returns the value of the "created_at" field in the mutation.
  10446. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  10447. v := m.created_at
  10448. if v == nil {
  10449. return
  10450. }
  10451. return *v, true
  10452. }
  10453. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  10454. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10456. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10457. if !m.op.Is(OpUpdateOne) {
  10458. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10459. }
  10460. if m.id == nil || m.oldValue == nil {
  10461. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10462. }
  10463. oldValue, err := m.oldValue(ctx)
  10464. if err != nil {
  10465. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10466. }
  10467. return oldValue.CreatedAt, nil
  10468. }
  10469. // ResetCreatedAt resets all changes to the "created_at" field.
  10470. func (m *CreditBalanceMutation) ResetCreatedAt() {
  10471. m.created_at = nil
  10472. }
  10473. // SetUpdatedAt sets the "updated_at" field.
  10474. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  10475. m.updated_at = &t
  10476. }
  10477. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10478. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  10479. v := m.updated_at
  10480. if v == nil {
  10481. return
  10482. }
  10483. return *v, true
  10484. }
  10485. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  10486. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10488. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10489. if !m.op.Is(OpUpdateOne) {
  10490. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10491. }
  10492. if m.id == nil || m.oldValue == nil {
  10493. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10494. }
  10495. oldValue, err := m.oldValue(ctx)
  10496. if err != nil {
  10497. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10498. }
  10499. return oldValue.UpdatedAt, nil
  10500. }
  10501. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10502. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  10503. m.updated_at = nil
  10504. }
  10505. // SetDeletedAt sets the "deleted_at" field.
  10506. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  10507. m.deleted_at = &t
  10508. }
  10509. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10510. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  10511. v := m.deleted_at
  10512. if v == nil {
  10513. return
  10514. }
  10515. return *v, true
  10516. }
  10517. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  10518. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10520. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10521. if !m.op.Is(OpUpdateOne) {
  10522. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10523. }
  10524. if m.id == nil || m.oldValue == nil {
  10525. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10526. }
  10527. oldValue, err := m.oldValue(ctx)
  10528. if err != nil {
  10529. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10530. }
  10531. return oldValue.DeletedAt, nil
  10532. }
  10533. // ClearDeletedAt clears the value of the "deleted_at" field.
  10534. func (m *CreditBalanceMutation) ClearDeletedAt() {
  10535. m.deleted_at = nil
  10536. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  10537. }
  10538. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10539. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  10540. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  10541. return ok
  10542. }
  10543. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10544. func (m *CreditBalanceMutation) ResetDeletedAt() {
  10545. m.deleted_at = nil
  10546. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  10547. }
  10548. // SetUserID sets the "user_id" field.
  10549. func (m *CreditBalanceMutation) SetUserID(s string) {
  10550. m.user_id = &s
  10551. }
  10552. // UserID returns the value of the "user_id" field in the mutation.
  10553. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  10554. v := m.user_id
  10555. if v == nil {
  10556. return
  10557. }
  10558. return *v, true
  10559. }
  10560. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  10561. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10563. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  10564. if !m.op.Is(OpUpdateOne) {
  10565. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10566. }
  10567. if m.id == nil || m.oldValue == nil {
  10568. return v, errors.New("OldUserID requires an ID field in the mutation")
  10569. }
  10570. oldValue, err := m.oldValue(ctx)
  10571. if err != nil {
  10572. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10573. }
  10574. return oldValue.UserID, nil
  10575. }
  10576. // ClearUserID clears the value of the "user_id" field.
  10577. func (m *CreditBalanceMutation) ClearUserID() {
  10578. m.user_id = nil
  10579. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  10580. }
  10581. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  10582. func (m *CreditBalanceMutation) UserIDCleared() bool {
  10583. _, ok := m.clearedFields[creditbalance.FieldUserID]
  10584. return ok
  10585. }
  10586. // ResetUserID resets all changes to the "user_id" field.
  10587. func (m *CreditBalanceMutation) ResetUserID() {
  10588. m.user_id = nil
  10589. delete(m.clearedFields, creditbalance.FieldUserID)
  10590. }
  10591. // SetBalance sets the "balance" field.
  10592. func (m *CreditBalanceMutation) SetBalance(f float32) {
  10593. m.balance = &f
  10594. m.addbalance = nil
  10595. }
  10596. // Balance returns the value of the "balance" field in the mutation.
  10597. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  10598. v := m.balance
  10599. if v == nil {
  10600. return
  10601. }
  10602. return *v, true
  10603. }
  10604. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  10605. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10607. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  10608. if !m.op.Is(OpUpdateOne) {
  10609. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  10610. }
  10611. if m.id == nil || m.oldValue == nil {
  10612. return v, errors.New("OldBalance requires an ID field in the mutation")
  10613. }
  10614. oldValue, err := m.oldValue(ctx)
  10615. if err != nil {
  10616. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  10617. }
  10618. return oldValue.Balance, nil
  10619. }
  10620. // AddBalance adds f to the "balance" field.
  10621. func (m *CreditBalanceMutation) AddBalance(f float32) {
  10622. if m.addbalance != nil {
  10623. *m.addbalance += f
  10624. } else {
  10625. m.addbalance = &f
  10626. }
  10627. }
  10628. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  10629. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  10630. v := m.addbalance
  10631. if v == nil {
  10632. return
  10633. }
  10634. return *v, true
  10635. }
  10636. // ResetBalance resets all changes to the "balance" field.
  10637. func (m *CreditBalanceMutation) ResetBalance() {
  10638. m.balance = nil
  10639. m.addbalance = nil
  10640. }
  10641. // SetStatus sets the "status" field.
  10642. func (m *CreditBalanceMutation) SetStatus(i int) {
  10643. m.status = &i
  10644. m.addstatus = nil
  10645. }
  10646. // Status returns the value of the "status" field in the mutation.
  10647. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  10648. v := m.status
  10649. if v == nil {
  10650. return
  10651. }
  10652. return *v, true
  10653. }
  10654. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  10655. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10657. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  10658. if !m.op.Is(OpUpdateOne) {
  10659. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10660. }
  10661. if m.id == nil || m.oldValue == nil {
  10662. return v, errors.New("OldStatus requires an ID field in the mutation")
  10663. }
  10664. oldValue, err := m.oldValue(ctx)
  10665. if err != nil {
  10666. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10667. }
  10668. return oldValue.Status, nil
  10669. }
  10670. // AddStatus adds i to the "status" field.
  10671. func (m *CreditBalanceMutation) AddStatus(i int) {
  10672. if m.addstatus != nil {
  10673. *m.addstatus += i
  10674. } else {
  10675. m.addstatus = &i
  10676. }
  10677. }
  10678. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10679. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  10680. v := m.addstatus
  10681. if v == nil {
  10682. return
  10683. }
  10684. return *v, true
  10685. }
  10686. // ClearStatus clears the value of the "status" field.
  10687. func (m *CreditBalanceMutation) ClearStatus() {
  10688. m.status = nil
  10689. m.addstatus = nil
  10690. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  10691. }
  10692. // StatusCleared returns if the "status" field was cleared in this mutation.
  10693. func (m *CreditBalanceMutation) StatusCleared() bool {
  10694. _, ok := m.clearedFields[creditbalance.FieldStatus]
  10695. return ok
  10696. }
  10697. // ResetStatus resets all changes to the "status" field.
  10698. func (m *CreditBalanceMutation) ResetStatus() {
  10699. m.status = nil
  10700. m.addstatus = nil
  10701. delete(m.clearedFields, creditbalance.FieldStatus)
  10702. }
  10703. // SetOrganizationID sets the "organization_id" field.
  10704. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  10705. m.organization_id = &u
  10706. m.addorganization_id = nil
  10707. }
  10708. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10709. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  10710. v := m.organization_id
  10711. if v == nil {
  10712. return
  10713. }
  10714. return *v, true
  10715. }
  10716. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  10717. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  10718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10719. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10720. if !m.op.Is(OpUpdateOne) {
  10721. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10722. }
  10723. if m.id == nil || m.oldValue == nil {
  10724. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10725. }
  10726. oldValue, err := m.oldValue(ctx)
  10727. if err != nil {
  10728. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10729. }
  10730. return oldValue.OrganizationID, nil
  10731. }
  10732. // AddOrganizationID adds u to the "organization_id" field.
  10733. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  10734. if m.addorganization_id != nil {
  10735. *m.addorganization_id += u
  10736. } else {
  10737. m.addorganization_id = &u
  10738. }
  10739. }
  10740. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10741. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  10742. v := m.addorganization_id
  10743. if v == nil {
  10744. return
  10745. }
  10746. return *v, true
  10747. }
  10748. // ClearOrganizationID clears the value of the "organization_id" field.
  10749. func (m *CreditBalanceMutation) ClearOrganizationID() {
  10750. m.organization_id = nil
  10751. m.addorganization_id = nil
  10752. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  10753. }
  10754. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10755. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  10756. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  10757. return ok
  10758. }
  10759. // ResetOrganizationID resets all changes to the "organization_id" field.
  10760. func (m *CreditBalanceMutation) ResetOrganizationID() {
  10761. m.organization_id = nil
  10762. m.addorganization_id = nil
  10763. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  10764. }
  10765. // Where appends a list predicates to the CreditBalanceMutation builder.
  10766. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  10767. m.predicates = append(m.predicates, ps...)
  10768. }
  10769. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  10770. // users can use type-assertion to append predicates that do not depend on any generated package.
  10771. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  10772. p := make([]predicate.CreditBalance, len(ps))
  10773. for i := range ps {
  10774. p[i] = ps[i]
  10775. }
  10776. m.Where(p...)
  10777. }
  10778. // Op returns the operation name.
  10779. func (m *CreditBalanceMutation) Op() Op {
  10780. return m.op
  10781. }
  10782. // SetOp allows setting the mutation operation.
  10783. func (m *CreditBalanceMutation) SetOp(op Op) {
  10784. m.op = op
  10785. }
  10786. // Type returns the node type of this mutation (CreditBalance).
  10787. func (m *CreditBalanceMutation) Type() string {
  10788. return m.typ
  10789. }
  10790. // Fields returns all fields that were changed during this mutation. Note that in
  10791. // order to get all numeric fields that were incremented/decremented, call
  10792. // AddedFields().
  10793. func (m *CreditBalanceMutation) Fields() []string {
  10794. fields := make([]string, 0, 7)
  10795. if m.created_at != nil {
  10796. fields = append(fields, creditbalance.FieldCreatedAt)
  10797. }
  10798. if m.updated_at != nil {
  10799. fields = append(fields, creditbalance.FieldUpdatedAt)
  10800. }
  10801. if m.deleted_at != nil {
  10802. fields = append(fields, creditbalance.FieldDeletedAt)
  10803. }
  10804. if m.user_id != nil {
  10805. fields = append(fields, creditbalance.FieldUserID)
  10806. }
  10807. if m.balance != nil {
  10808. fields = append(fields, creditbalance.FieldBalance)
  10809. }
  10810. if m.status != nil {
  10811. fields = append(fields, creditbalance.FieldStatus)
  10812. }
  10813. if m.organization_id != nil {
  10814. fields = append(fields, creditbalance.FieldOrganizationID)
  10815. }
  10816. return fields
  10817. }
  10818. // Field returns the value of a field with the given name. The second boolean
  10819. // return value indicates that this field was not set, or was not defined in the
  10820. // schema.
  10821. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  10822. switch name {
  10823. case creditbalance.FieldCreatedAt:
  10824. return m.CreatedAt()
  10825. case creditbalance.FieldUpdatedAt:
  10826. return m.UpdatedAt()
  10827. case creditbalance.FieldDeletedAt:
  10828. return m.DeletedAt()
  10829. case creditbalance.FieldUserID:
  10830. return m.UserID()
  10831. case creditbalance.FieldBalance:
  10832. return m.Balance()
  10833. case creditbalance.FieldStatus:
  10834. return m.Status()
  10835. case creditbalance.FieldOrganizationID:
  10836. return m.OrganizationID()
  10837. }
  10838. return nil, false
  10839. }
  10840. // OldField returns the old value of the field from the database. An error is
  10841. // returned if the mutation operation is not UpdateOne, or the query to the
  10842. // database failed.
  10843. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10844. switch name {
  10845. case creditbalance.FieldCreatedAt:
  10846. return m.OldCreatedAt(ctx)
  10847. case creditbalance.FieldUpdatedAt:
  10848. return m.OldUpdatedAt(ctx)
  10849. case creditbalance.FieldDeletedAt:
  10850. return m.OldDeletedAt(ctx)
  10851. case creditbalance.FieldUserID:
  10852. return m.OldUserID(ctx)
  10853. case creditbalance.FieldBalance:
  10854. return m.OldBalance(ctx)
  10855. case creditbalance.FieldStatus:
  10856. return m.OldStatus(ctx)
  10857. case creditbalance.FieldOrganizationID:
  10858. return m.OldOrganizationID(ctx)
  10859. }
  10860. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  10861. }
  10862. // SetField sets the value of a field with the given name. It returns an error if
  10863. // the field is not defined in the schema, or if the type mismatched the field
  10864. // type.
  10865. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  10866. switch name {
  10867. case creditbalance.FieldCreatedAt:
  10868. v, ok := value.(time.Time)
  10869. if !ok {
  10870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10871. }
  10872. m.SetCreatedAt(v)
  10873. return nil
  10874. case creditbalance.FieldUpdatedAt:
  10875. v, ok := value.(time.Time)
  10876. if !ok {
  10877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10878. }
  10879. m.SetUpdatedAt(v)
  10880. return nil
  10881. case creditbalance.FieldDeletedAt:
  10882. v, ok := value.(time.Time)
  10883. if !ok {
  10884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10885. }
  10886. m.SetDeletedAt(v)
  10887. return nil
  10888. case creditbalance.FieldUserID:
  10889. v, ok := value.(string)
  10890. if !ok {
  10891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10892. }
  10893. m.SetUserID(v)
  10894. return nil
  10895. case creditbalance.FieldBalance:
  10896. v, ok := value.(float32)
  10897. if !ok {
  10898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10899. }
  10900. m.SetBalance(v)
  10901. return nil
  10902. case creditbalance.FieldStatus:
  10903. v, ok := value.(int)
  10904. if !ok {
  10905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10906. }
  10907. m.SetStatus(v)
  10908. return nil
  10909. case creditbalance.FieldOrganizationID:
  10910. v, ok := value.(uint64)
  10911. if !ok {
  10912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10913. }
  10914. m.SetOrganizationID(v)
  10915. return nil
  10916. }
  10917. return fmt.Errorf("unknown CreditBalance field %s", name)
  10918. }
  10919. // AddedFields returns all numeric fields that were incremented/decremented during
  10920. // this mutation.
  10921. func (m *CreditBalanceMutation) AddedFields() []string {
  10922. var fields []string
  10923. if m.addbalance != nil {
  10924. fields = append(fields, creditbalance.FieldBalance)
  10925. }
  10926. if m.addstatus != nil {
  10927. fields = append(fields, creditbalance.FieldStatus)
  10928. }
  10929. if m.addorganization_id != nil {
  10930. fields = append(fields, creditbalance.FieldOrganizationID)
  10931. }
  10932. return fields
  10933. }
  10934. // AddedField returns the numeric value that was incremented/decremented on a field
  10935. // with the given name. The second boolean return value indicates that this field
  10936. // was not set, or was not defined in the schema.
  10937. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  10938. switch name {
  10939. case creditbalance.FieldBalance:
  10940. return m.AddedBalance()
  10941. case creditbalance.FieldStatus:
  10942. return m.AddedStatus()
  10943. case creditbalance.FieldOrganizationID:
  10944. return m.AddedOrganizationID()
  10945. }
  10946. return nil, false
  10947. }
  10948. // AddField adds the value to the field with the given name. It returns an error if
  10949. // the field is not defined in the schema, or if the type mismatched the field
  10950. // type.
  10951. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  10952. switch name {
  10953. case creditbalance.FieldBalance:
  10954. v, ok := value.(float32)
  10955. if !ok {
  10956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10957. }
  10958. m.AddBalance(v)
  10959. return nil
  10960. case creditbalance.FieldStatus:
  10961. v, ok := value.(int)
  10962. if !ok {
  10963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10964. }
  10965. m.AddStatus(v)
  10966. return nil
  10967. case creditbalance.FieldOrganizationID:
  10968. v, ok := value.(int64)
  10969. if !ok {
  10970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10971. }
  10972. m.AddOrganizationID(v)
  10973. return nil
  10974. }
  10975. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  10976. }
  10977. // ClearedFields returns all nullable fields that were cleared during this
  10978. // mutation.
  10979. func (m *CreditBalanceMutation) ClearedFields() []string {
  10980. var fields []string
  10981. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  10982. fields = append(fields, creditbalance.FieldDeletedAt)
  10983. }
  10984. if m.FieldCleared(creditbalance.FieldUserID) {
  10985. fields = append(fields, creditbalance.FieldUserID)
  10986. }
  10987. if m.FieldCleared(creditbalance.FieldStatus) {
  10988. fields = append(fields, creditbalance.FieldStatus)
  10989. }
  10990. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  10991. fields = append(fields, creditbalance.FieldOrganizationID)
  10992. }
  10993. return fields
  10994. }
  10995. // FieldCleared returns a boolean indicating if a field with the given name was
  10996. // cleared in this mutation.
  10997. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  10998. _, ok := m.clearedFields[name]
  10999. return ok
  11000. }
  11001. // ClearField clears the value of the field with the given name. It returns an
  11002. // error if the field is not defined in the schema.
  11003. func (m *CreditBalanceMutation) ClearField(name string) error {
  11004. switch name {
  11005. case creditbalance.FieldDeletedAt:
  11006. m.ClearDeletedAt()
  11007. return nil
  11008. case creditbalance.FieldUserID:
  11009. m.ClearUserID()
  11010. return nil
  11011. case creditbalance.FieldStatus:
  11012. m.ClearStatus()
  11013. return nil
  11014. case creditbalance.FieldOrganizationID:
  11015. m.ClearOrganizationID()
  11016. return nil
  11017. }
  11018. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  11019. }
  11020. // ResetField resets all changes in the mutation for the field with the given name.
  11021. // It returns an error if the field is not defined in the schema.
  11022. func (m *CreditBalanceMutation) ResetField(name string) error {
  11023. switch name {
  11024. case creditbalance.FieldCreatedAt:
  11025. m.ResetCreatedAt()
  11026. return nil
  11027. case creditbalance.FieldUpdatedAt:
  11028. m.ResetUpdatedAt()
  11029. return nil
  11030. case creditbalance.FieldDeletedAt:
  11031. m.ResetDeletedAt()
  11032. return nil
  11033. case creditbalance.FieldUserID:
  11034. m.ResetUserID()
  11035. return nil
  11036. case creditbalance.FieldBalance:
  11037. m.ResetBalance()
  11038. return nil
  11039. case creditbalance.FieldStatus:
  11040. m.ResetStatus()
  11041. return nil
  11042. case creditbalance.FieldOrganizationID:
  11043. m.ResetOrganizationID()
  11044. return nil
  11045. }
  11046. return fmt.Errorf("unknown CreditBalance field %s", name)
  11047. }
  11048. // AddedEdges returns all edge names that were set/added in this mutation.
  11049. func (m *CreditBalanceMutation) AddedEdges() []string {
  11050. edges := make([]string, 0, 0)
  11051. return edges
  11052. }
  11053. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11054. // name in this mutation.
  11055. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  11056. return nil
  11057. }
  11058. // RemovedEdges returns all edge names that were removed in this mutation.
  11059. func (m *CreditBalanceMutation) RemovedEdges() []string {
  11060. edges := make([]string, 0, 0)
  11061. return edges
  11062. }
  11063. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11064. // the given name in this mutation.
  11065. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  11066. return nil
  11067. }
  11068. // ClearedEdges returns all edge names that were cleared in this mutation.
  11069. func (m *CreditBalanceMutation) ClearedEdges() []string {
  11070. edges := make([]string, 0, 0)
  11071. return edges
  11072. }
  11073. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11074. // was cleared in this mutation.
  11075. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  11076. return false
  11077. }
  11078. // ClearEdge clears the value of the edge with the given name. It returns an error
  11079. // if that edge is not defined in the schema.
  11080. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  11081. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  11082. }
  11083. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11084. // It returns an error if the edge is not defined in the schema.
  11085. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  11086. return fmt.Errorf("unknown CreditBalance edge %s", name)
  11087. }
  11088. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  11089. type CreditUsageMutation struct {
  11090. config
  11091. op Op
  11092. typ string
  11093. id *uint64
  11094. created_at *time.Time
  11095. updated_at *time.Time
  11096. deleted_at *time.Time
  11097. user_id *string
  11098. number *float32
  11099. addnumber *float32
  11100. status *int
  11101. addstatus *int
  11102. ntype *int
  11103. addntype *int
  11104. table *string
  11105. organization_id *uint64
  11106. addorganization_id *int64
  11107. nid *uint64
  11108. addnid *int64
  11109. reason *string
  11110. operator *string
  11111. clearedFields map[string]struct{}
  11112. done bool
  11113. oldValue func(context.Context) (*CreditUsage, error)
  11114. predicates []predicate.CreditUsage
  11115. }
  11116. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  11117. // creditusageOption allows management of the mutation configuration using functional options.
  11118. type creditusageOption func(*CreditUsageMutation)
  11119. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  11120. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  11121. m := &CreditUsageMutation{
  11122. config: c,
  11123. op: op,
  11124. typ: TypeCreditUsage,
  11125. clearedFields: make(map[string]struct{}),
  11126. }
  11127. for _, opt := range opts {
  11128. opt(m)
  11129. }
  11130. return m
  11131. }
  11132. // withCreditUsageID sets the ID field of the mutation.
  11133. func withCreditUsageID(id uint64) creditusageOption {
  11134. return func(m *CreditUsageMutation) {
  11135. var (
  11136. err error
  11137. once sync.Once
  11138. value *CreditUsage
  11139. )
  11140. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  11141. once.Do(func() {
  11142. if m.done {
  11143. err = errors.New("querying old values post mutation is not allowed")
  11144. } else {
  11145. value, err = m.Client().CreditUsage.Get(ctx, id)
  11146. }
  11147. })
  11148. return value, err
  11149. }
  11150. m.id = &id
  11151. }
  11152. }
  11153. // withCreditUsage sets the old CreditUsage of the mutation.
  11154. func withCreditUsage(node *CreditUsage) creditusageOption {
  11155. return func(m *CreditUsageMutation) {
  11156. m.oldValue = func(context.Context) (*CreditUsage, error) {
  11157. return node, nil
  11158. }
  11159. m.id = &node.ID
  11160. }
  11161. }
  11162. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11163. // executed in a transaction (ent.Tx), a transactional client is returned.
  11164. func (m CreditUsageMutation) Client() *Client {
  11165. client := &Client{config: m.config}
  11166. client.init()
  11167. return client
  11168. }
  11169. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11170. // it returns an error otherwise.
  11171. func (m CreditUsageMutation) Tx() (*Tx, error) {
  11172. if _, ok := m.driver.(*txDriver); !ok {
  11173. return nil, errors.New("ent: mutation is not running in a transaction")
  11174. }
  11175. tx := &Tx{config: m.config}
  11176. tx.init()
  11177. return tx, nil
  11178. }
  11179. // SetID sets the value of the id field. Note that this
  11180. // operation is only accepted on creation of CreditUsage entities.
  11181. func (m *CreditUsageMutation) SetID(id uint64) {
  11182. m.id = &id
  11183. }
  11184. // ID returns the ID value in the mutation. Note that the ID is only available
  11185. // if it was provided to the builder or after it was returned from the database.
  11186. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  11187. if m.id == nil {
  11188. return
  11189. }
  11190. return *m.id, true
  11191. }
  11192. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11193. // That means, if the mutation is applied within a transaction with an isolation level such
  11194. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11195. // or updated by the mutation.
  11196. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  11197. switch {
  11198. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11199. id, exists := m.ID()
  11200. if exists {
  11201. return []uint64{id}, nil
  11202. }
  11203. fallthrough
  11204. case m.op.Is(OpUpdate | OpDelete):
  11205. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  11206. default:
  11207. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11208. }
  11209. }
  11210. // SetCreatedAt sets the "created_at" field.
  11211. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  11212. m.created_at = &t
  11213. }
  11214. // CreatedAt returns the value of the "created_at" field in the mutation.
  11215. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  11216. v := m.created_at
  11217. if v == nil {
  11218. return
  11219. }
  11220. return *v, true
  11221. }
  11222. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  11223. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11225. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11226. if !m.op.Is(OpUpdateOne) {
  11227. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11228. }
  11229. if m.id == nil || m.oldValue == nil {
  11230. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11231. }
  11232. oldValue, err := m.oldValue(ctx)
  11233. if err != nil {
  11234. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11235. }
  11236. return oldValue.CreatedAt, nil
  11237. }
  11238. // ResetCreatedAt resets all changes to the "created_at" field.
  11239. func (m *CreditUsageMutation) ResetCreatedAt() {
  11240. m.created_at = nil
  11241. }
  11242. // SetUpdatedAt sets the "updated_at" field.
  11243. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  11244. m.updated_at = &t
  11245. }
  11246. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11247. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  11248. v := m.updated_at
  11249. if v == nil {
  11250. return
  11251. }
  11252. return *v, true
  11253. }
  11254. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  11255. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11257. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11258. if !m.op.Is(OpUpdateOne) {
  11259. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11260. }
  11261. if m.id == nil || m.oldValue == nil {
  11262. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11263. }
  11264. oldValue, err := m.oldValue(ctx)
  11265. if err != nil {
  11266. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11267. }
  11268. return oldValue.UpdatedAt, nil
  11269. }
  11270. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11271. func (m *CreditUsageMutation) ResetUpdatedAt() {
  11272. m.updated_at = nil
  11273. }
  11274. // SetDeletedAt sets the "deleted_at" field.
  11275. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  11276. m.deleted_at = &t
  11277. }
  11278. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11279. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  11280. v := m.deleted_at
  11281. if v == nil {
  11282. return
  11283. }
  11284. return *v, true
  11285. }
  11286. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  11287. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11289. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11290. if !m.op.Is(OpUpdateOne) {
  11291. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11292. }
  11293. if m.id == nil || m.oldValue == nil {
  11294. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11295. }
  11296. oldValue, err := m.oldValue(ctx)
  11297. if err != nil {
  11298. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11299. }
  11300. return oldValue.DeletedAt, nil
  11301. }
  11302. // ClearDeletedAt clears the value of the "deleted_at" field.
  11303. func (m *CreditUsageMutation) ClearDeletedAt() {
  11304. m.deleted_at = nil
  11305. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  11306. }
  11307. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11308. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  11309. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  11310. return ok
  11311. }
  11312. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11313. func (m *CreditUsageMutation) ResetDeletedAt() {
  11314. m.deleted_at = nil
  11315. delete(m.clearedFields, creditusage.FieldDeletedAt)
  11316. }
  11317. // SetUserID sets the "user_id" field.
  11318. func (m *CreditUsageMutation) SetUserID(s string) {
  11319. m.user_id = &s
  11320. }
  11321. // UserID returns the value of the "user_id" field in the mutation.
  11322. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  11323. v := m.user_id
  11324. if v == nil {
  11325. return
  11326. }
  11327. return *v, true
  11328. }
  11329. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  11330. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11332. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  11333. if !m.op.Is(OpUpdateOne) {
  11334. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  11335. }
  11336. if m.id == nil || m.oldValue == nil {
  11337. return v, errors.New("OldUserID requires an ID field in the mutation")
  11338. }
  11339. oldValue, err := m.oldValue(ctx)
  11340. if err != nil {
  11341. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  11342. }
  11343. return oldValue.UserID, nil
  11344. }
  11345. // ClearUserID clears the value of the "user_id" field.
  11346. func (m *CreditUsageMutation) ClearUserID() {
  11347. m.user_id = nil
  11348. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  11349. }
  11350. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  11351. func (m *CreditUsageMutation) UserIDCleared() bool {
  11352. _, ok := m.clearedFields[creditusage.FieldUserID]
  11353. return ok
  11354. }
  11355. // ResetUserID resets all changes to the "user_id" field.
  11356. func (m *CreditUsageMutation) ResetUserID() {
  11357. m.user_id = nil
  11358. delete(m.clearedFields, creditusage.FieldUserID)
  11359. }
  11360. // SetNumber sets the "number" field.
  11361. func (m *CreditUsageMutation) SetNumber(f float32) {
  11362. m.number = &f
  11363. m.addnumber = nil
  11364. }
  11365. // Number returns the value of the "number" field in the mutation.
  11366. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  11367. v := m.number
  11368. if v == nil {
  11369. return
  11370. }
  11371. return *v, true
  11372. }
  11373. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  11374. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11376. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  11377. if !m.op.Is(OpUpdateOne) {
  11378. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  11379. }
  11380. if m.id == nil || m.oldValue == nil {
  11381. return v, errors.New("OldNumber requires an ID field in the mutation")
  11382. }
  11383. oldValue, err := m.oldValue(ctx)
  11384. if err != nil {
  11385. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  11386. }
  11387. return oldValue.Number, nil
  11388. }
  11389. // AddNumber adds f to the "number" field.
  11390. func (m *CreditUsageMutation) AddNumber(f float32) {
  11391. if m.addnumber != nil {
  11392. *m.addnumber += f
  11393. } else {
  11394. m.addnumber = &f
  11395. }
  11396. }
  11397. // AddedNumber returns the value that was added to the "number" field in this mutation.
  11398. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  11399. v := m.addnumber
  11400. if v == nil {
  11401. return
  11402. }
  11403. return *v, true
  11404. }
  11405. // ResetNumber resets all changes to the "number" field.
  11406. func (m *CreditUsageMutation) ResetNumber() {
  11407. m.number = nil
  11408. m.addnumber = nil
  11409. }
  11410. // SetStatus sets the "status" field.
  11411. func (m *CreditUsageMutation) SetStatus(i int) {
  11412. m.status = &i
  11413. m.addstatus = nil
  11414. }
  11415. // Status returns the value of the "status" field in the mutation.
  11416. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  11417. v := m.status
  11418. if v == nil {
  11419. return
  11420. }
  11421. return *v, true
  11422. }
  11423. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  11424. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11426. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  11427. if !m.op.Is(OpUpdateOne) {
  11428. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11429. }
  11430. if m.id == nil || m.oldValue == nil {
  11431. return v, errors.New("OldStatus requires an ID field in the mutation")
  11432. }
  11433. oldValue, err := m.oldValue(ctx)
  11434. if err != nil {
  11435. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11436. }
  11437. return oldValue.Status, nil
  11438. }
  11439. // AddStatus adds i to the "status" field.
  11440. func (m *CreditUsageMutation) AddStatus(i int) {
  11441. if m.addstatus != nil {
  11442. *m.addstatus += i
  11443. } else {
  11444. m.addstatus = &i
  11445. }
  11446. }
  11447. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11448. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  11449. v := m.addstatus
  11450. if v == nil {
  11451. return
  11452. }
  11453. return *v, true
  11454. }
  11455. // ClearStatus clears the value of the "status" field.
  11456. func (m *CreditUsageMutation) ClearStatus() {
  11457. m.status = nil
  11458. m.addstatus = nil
  11459. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  11460. }
  11461. // StatusCleared returns if the "status" field was cleared in this mutation.
  11462. func (m *CreditUsageMutation) StatusCleared() bool {
  11463. _, ok := m.clearedFields[creditusage.FieldStatus]
  11464. return ok
  11465. }
  11466. // ResetStatus resets all changes to the "status" field.
  11467. func (m *CreditUsageMutation) ResetStatus() {
  11468. m.status = nil
  11469. m.addstatus = nil
  11470. delete(m.clearedFields, creditusage.FieldStatus)
  11471. }
  11472. // SetNtype sets the "ntype" field.
  11473. func (m *CreditUsageMutation) SetNtype(i int) {
  11474. m.ntype = &i
  11475. m.addntype = nil
  11476. }
  11477. // Ntype returns the value of the "ntype" field in the mutation.
  11478. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  11479. v := m.ntype
  11480. if v == nil {
  11481. return
  11482. }
  11483. return *v, true
  11484. }
  11485. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  11486. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11488. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  11489. if !m.op.Is(OpUpdateOne) {
  11490. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  11491. }
  11492. if m.id == nil || m.oldValue == nil {
  11493. return v, errors.New("OldNtype requires an ID field in the mutation")
  11494. }
  11495. oldValue, err := m.oldValue(ctx)
  11496. if err != nil {
  11497. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  11498. }
  11499. return oldValue.Ntype, nil
  11500. }
  11501. // AddNtype adds i to the "ntype" field.
  11502. func (m *CreditUsageMutation) AddNtype(i int) {
  11503. if m.addntype != nil {
  11504. *m.addntype += i
  11505. } else {
  11506. m.addntype = &i
  11507. }
  11508. }
  11509. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  11510. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  11511. v := m.addntype
  11512. if v == nil {
  11513. return
  11514. }
  11515. return *v, true
  11516. }
  11517. // ResetNtype resets all changes to the "ntype" field.
  11518. func (m *CreditUsageMutation) ResetNtype() {
  11519. m.ntype = nil
  11520. m.addntype = nil
  11521. }
  11522. // SetTable sets the "table" field.
  11523. func (m *CreditUsageMutation) SetTable(s string) {
  11524. m.table = &s
  11525. }
  11526. // Table returns the value of the "table" field in the mutation.
  11527. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  11528. v := m.table
  11529. if v == nil {
  11530. return
  11531. }
  11532. return *v, true
  11533. }
  11534. // OldTable returns the old "table" field's value of the CreditUsage entity.
  11535. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11537. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  11538. if !m.op.Is(OpUpdateOne) {
  11539. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  11540. }
  11541. if m.id == nil || m.oldValue == nil {
  11542. return v, errors.New("OldTable requires an ID field in the mutation")
  11543. }
  11544. oldValue, err := m.oldValue(ctx)
  11545. if err != nil {
  11546. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  11547. }
  11548. return oldValue.Table, nil
  11549. }
  11550. // ResetTable resets all changes to the "table" field.
  11551. func (m *CreditUsageMutation) ResetTable() {
  11552. m.table = nil
  11553. }
  11554. // SetOrganizationID sets the "organization_id" field.
  11555. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  11556. m.organization_id = &u
  11557. m.addorganization_id = nil
  11558. }
  11559. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11560. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  11561. v := m.organization_id
  11562. if v == nil {
  11563. return
  11564. }
  11565. return *v, true
  11566. }
  11567. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  11568. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11570. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11571. if !m.op.Is(OpUpdateOne) {
  11572. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11573. }
  11574. if m.id == nil || m.oldValue == nil {
  11575. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11576. }
  11577. oldValue, err := m.oldValue(ctx)
  11578. if err != nil {
  11579. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11580. }
  11581. return oldValue.OrganizationID, nil
  11582. }
  11583. // AddOrganizationID adds u to the "organization_id" field.
  11584. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  11585. if m.addorganization_id != nil {
  11586. *m.addorganization_id += u
  11587. } else {
  11588. m.addorganization_id = &u
  11589. }
  11590. }
  11591. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11592. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  11593. v := m.addorganization_id
  11594. if v == nil {
  11595. return
  11596. }
  11597. return *v, true
  11598. }
  11599. // ClearOrganizationID clears the value of the "organization_id" field.
  11600. func (m *CreditUsageMutation) ClearOrganizationID() {
  11601. m.organization_id = nil
  11602. m.addorganization_id = nil
  11603. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  11604. }
  11605. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11606. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  11607. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  11608. return ok
  11609. }
  11610. // ResetOrganizationID resets all changes to the "organization_id" field.
  11611. func (m *CreditUsageMutation) ResetOrganizationID() {
  11612. m.organization_id = nil
  11613. m.addorganization_id = nil
  11614. delete(m.clearedFields, creditusage.FieldOrganizationID)
  11615. }
  11616. // SetNid sets the "nid" field.
  11617. func (m *CreditUsageMutation) SetNid(u uint64) {
  11618. m.nid = &u
  11619. m.addnid = nil
  11620. }
  11621. // Nid returns the value of the "nid" field in the mutation.
  11622. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  11623. v := m.nid
  11624. if v == nil {
  11625. return
  11626. }
  11627. return *v, true
  11628. }
  11629. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  11630. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11632. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  11633. if !m.op.Is(OpUpdateOne) {
  11634. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  11635. }
  11636. if m.id == nil || m.oldValue == nil {
  11637. return v, errors.New("OldNid requires an ID field in the mutation")
  11638. }
  11639. oldValue, err := m.oldValue(ctx)
  11640. if err != nil {
  11641. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  11642. }
  11643. return oldValue.Nid, nil
  11644. }
  11645. // AddNid adds u to the "nid" field.
  11646. func (m *CreditUsageMutation) AddNid(u int64) {
  11647. if m.addnid != nil {
  11648. *m.addnid += u
  11649. } else {
  11650. m.addnid = &u
  11651. }
  11652. }
  11653. // AddedNid returns the value that was added to the "nid" field in this mutation.
  11654. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  11655. v := m.addnid
  11656. if v == nil {
  11657. return
  11658. }
  11659. return *v, true
  11660. }
  11661. // ResetNid resets all changes to the "nid" field.
  11662. func (m *CreditUsageMutation) ResetNid() {
  11663. m.nid = nil
  11664. m.addnid = nil
  11665. }
  11666. // SetReason sets the "reason" field.
  11667. func (m *CreditUsageMutation) SetReason(s string) {
  11668. m.reason = &s
  11669. }
  11670. // Reason returns the value of the "reason" field in the mutation.
  11671. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  11672. v := m.reason
  11673. if v == nil {
  11674. return
  11675. }
  11676. return *v, true
  11677. }
  11678. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  11679. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11681. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  11682. if !m.op.Is(OpUpdateOne) {
  11683. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  11684. }
  11685. if m.id == nil || m.oldValue == nil {
  11686. return v, errors.New("OldReason requires an ID field in the mutation")
  11687. }
  11688. oldValue, err := m.oldValue(ctx)
  11689. if err != nil {
  11690. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  11691. }
  11692. return oldValue.Reason, nil
  11693. }
  11694. // ResetReason resets all changes to the "reason" field.
  11695. func (m *CreditUsageMutation) ResetReason() {
  11696. m.reason = nil
  11697. }
  11698. // SetOperator sets the "operator" field.
  11699. func (m *CreditUsageMutation) SetOperator(s string) {
  11700. m.operator = &s
  11701. }
  11702. // Operator returns the value of the "operator" field in the mutation.
  11703. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  11704. v := m.operator
  11705. if v == nil {
  11706. return
  11707. }
  11708. return *v, true
  11709. }
  11710. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  11711. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  11712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11713. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  11714. if !m.op.Is(OpUpdateOne) {
  11715. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  11716. }
  11717. if m.id == nil || m.oldValue == nil {
  11718. return v, errors.New("OldOperator requires an ID field in the mutation")
  11719. }
  11720. oldValue, err := m.oldValue(ctx)
  11721. if err != nil {
  11722. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  11723. }
  11724. return oldValue.Operator, nil
  11725. }
  11726. // ResetOperator resets all changes to the "operator" field.
  11727. func (m *CreditUsageMutation) ResetOperator() {
  11728. m.operator = nil
  11729. }
  11730. // Where appends a list predicates to the CreditUsageMutation builder.
  11731. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  11732. m.predicates = append(m.predicates, ps...)
  11733. }
  11734. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  11735. // users can use type-assertion to append predicates that do not depend on any generated package.
  11736. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  11737. p := make([]predicate.CreditUsage, len(ps))
  11738. for i := range ps {
  11739. p[i] = ps[i]
  11740. }
  11741. m.Where(p...)
  11742. }
  11743. // Op returns the operation name.
  11744. func (m *CreditUsageMutation) Op() Op {
  11745. return m.op
  11746. }
  11747. // SetOp allows setting the mutation operation.
  11748. func (m *CreditUsageMutation) SetOp(op Op) {
  11749. m.op = op
  11750. }
  11751. // Type returns the node type of this mutation (CreditUsage).
  11752. func (m *CreditUsageMutation) Type() string {
  11753. return m.typ
  11754. }
  11755. // Fields returns all fields that were changed during this mutation. Note that in
  11756. // order to get all numeric fields that were incremented/decremented, call
  11757. // AddedFields().
  11758. func (m *CreditUsageMutation) Fields() []string {
  11759. fields := make([]string, 0, 12)
  11760. if m.created_at != nil {
  11761. fields = append(fields, creditusage.FieldCreatedAt)
  11762. }
  11763. if m.updated_at != nil {
  11764. fields = append(fields, creditusage.FieldUpdatedAt)
  11765. }
  11766. if m.deleted_at != nil {
  11767. fields = append(fields, creditusage.FieldDeletedAt)
  11768. }
  11769. if m.user_id != nil {
  11770. fields = append(fields, creditusage.FieldUserID)
  11771. }
  11772. if m.number != nil {
  11773. fields = append(fields, creditusage.FieldNumber)
  11774. }
  11775. if m.status != nil {
  11776. fields = append(fields, creditusage.FieldStatus)
  11777. }
  11778. if m.ntype != nil {
  11779. fields = append(fields, creditusage.FieldNtype)
  11780. }
  11781. if m.table != nil {
  11782. fields = append(fields, creditusage.FieldTable)
  11783. }
  11784. if m.organization_id != nil {
  11785. fields = append(fields, creditusage.FieldOrganizationID)
  11786. }
  11787. if m.nid != nil {
  11788. fields = append(fields, creditusage.FieldNid)
  11789. }
  11790. if m.reason != nil {
  11791. fields = append(fields, creditusage.FieldReason)
  11792. }
  11793. if m.operator != nil {
  11794. fields = append(fields, creditusage.FieldOperator)
  11795. }
  11796. return fields
  11797. }
  11798. // Field returns the value of a field with the given name. The second boolean
  11799. // return value indicates that this field was not set, or was not defined in the
  11800. // schema.
  11801. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  11802. switch name {
  11803. case creditusage.FieldCreatedAt:
  11804. return m.CreatedAt()
  11805. case creditusage.FieldUpdatedAt:
  11806. return m.UpdatedAt()
  11807. case creditusage.FieldDeletedAt:
  11808. return m.DeletedAt()
  11809. case creditusage.FieldUserID:
  11810. return m.UserID()
  11811. case creditusage.FieldNumber:
  11812. return m.Number()
  11813. case creditusage.FieldStatus:
  11814. return m.Status()
  11815. case creditusage.FieldNtype:
  11816. return m.Ntype()
  11817. case creditusage.FieldTable:
  11818. return m.Table()
  11819. case creditusage.FieldOrganizationID:
  11820. return m.OrganizationID()
  11821. case creditusage.FieldNid:
  11822. return m.Nid()
  11823. case creditusage.FieldReason:
  11824. return m.Reason()
  11825. case creditusage.FieldOperator:
  11826. return m.Operator()
  11827. }
  11828. return nil, false
  11829. }
  11830. // OldField returns the old value of the field from the database. An error is
  11831. // returned if the mutation operation is not UpdateOne, or the query to the
  11832. // database failed.
  11833. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11834. switch name {
  11835. case creditusage.FieldCreatedAt:
  11836. return m.OldCreatedAt(ctx)
  11837. case creditusage.FieldUpdatedAt:
  11838. return m.OldUpdatedAt(ctx)
  11839. case creditusage.FieldDeletedAt:
  11840. return m.OldDeletedAt(ctx)
  11841. case creditusage.FieldUserID:
  11842. return m.OldUserID(ctx)
  11843. case creditusage.FieldNumber:
  11844. return m.OldNumber(ctx)
  11845. case creditusage.FieldStatus:
  11846. return m.OldStatus(ctx)
  11847. case creditusage.FieldNtype:
  11848. return m.OldNtype(ctx)
  11849. case creditusage.FieldTable:
  11850. return m.OldTable(ctx)
  11851. case creditusage.FieldOrganizationID:
  11852. return m.OldOrganizationID(ctx)
  11853. case creditusage.FieldNid:
  11854. return m.OldNid(ctx)
  11855. case creditusage.FieldReason:
  11856. return m.OldReason(ctx)
  11857. case creditusage.FieldOperator:
  11858. return m.OldOperator(ctx)
  11859. }
  11860. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  11861. }
  11862. // SetField sets the value of a field with the given name. It returns an error if
  11863. // the field is not defined in the schema, or if the type mismatched the field
  11864. // type.
  11865. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  11866. switch name {
  11867. case creditusage.FieldCreatedAt:
  11868. v, ok := value.(time.Time)
  11869. if !ok {
  11870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11871. }
  11872. m.SetCreatedAt(v)
  11873. return nil
  11874. case creditusage.FieldUpdatedAt:
  11875. v, ok := value.(time.Time)
  11876. if !ok {
  11877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11878. }
  11879. m.SetUpdatedAt(v)
  11880. return nil
  11881. case creditusage.FieldDeletedAt:
  11882. v, ok := value.(time.Time)
  11883. if !ok {
  11884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11885. }
  11886. m.SetDeletedAt(v)
  11887. return nil
  11888. case creditusage.FieldUserID:
  11889. v, ok := value.(string)
  11890. if !ok {
  11891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11892. }
  11893. m.SetUserID(v)
  11894. return nil
  11895. case creditusage.FieldNumber:
  11896. v, ok := value.(float32)
  11897. if !ok {
  11898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11899. }
  11900. m.SetNumber(v)
  11901. return nil
  11902. case creditusage.FieldStatus:
  11903. v, ok := value.(int)
  11904. if !ok {
  11905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11906. }
  11907. m.SetStatus(v)
  11908. return nil
  11909. case creditusage.FieldNtype:
  11910. v, ok := value.(int)
  11911. if !ok {
  11912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11913. }
  11914. m.SetNtype(v)
  11915. return nil
  11916. case creditusage.FieldTable:
  11917. v, ok := value.(string)
  11918. if !ok {
  11919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11920. }
  11921. m.SetTable(v)
  11922. return nil
  11923. case creditusage.FieldOrganizationID:
  11924. v, ok := value.(uint64)
  11925. if !ok {
  11926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11927. }
  11928. m.SetOrganizationID(v)
  11929. return nil
  11930. case creditusage.FieldNid:
  11931. v, ok := value.(uint64)
  11932. if !ok {
  11933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11934. }
  11935. m.SetNid(v)
  11936. return nil
  11937. case creditusage.FieldReason:
  11938. v, ok := value.(string)
  11939. if !ok {
  11940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11941. }
  11942. m.SetReason(v)
  11943. return nil
  11944. case creditusage.FieldOperator:
  11945. v, ok := value.(string)
  11946. if !ok {
  11947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11948. }
  11949. m.SetOperator(v)
  11950. return nil
  11951. }
  11952. return fmt.Errorf("unknown CreditUsage field %s", name)
  11953. }
  11954. // AddedFields returns all numeric fields that were incremented/decremented during
  11955. // this mutation.
  11956. func (m *CreditUsageMutation) AddedFields() []string {
  11957. var fields []string
  11958. if m.addnumber != nil {
  11959. fields = append(fields, creditusage.FieldNumber)
  11960. }
  11961. if m.addstatus != nil {
  11962. fields = append(fields, creditusage.FieldStatus)
  11963. }
  11964. if m.addntype != nil {
  11965. fields = append(fields, creditusage.FieldNtype)
  11966. }
  11967. if m.addorganization_id != nil {
  11968. fields = append(fields, creditusage.FieldOrganizationID)
  11969. }
  11970. if m.addnid != nil {
  11971. fields = append(fields, creditusage.FieldNid)
  11972. }
  11973. return fields
  11974. }
  11975. // AddedField returns the numeric value that was incremented/decremented on a field
  11976. // with the given name. The second boolean return value indicates that this field
  11977. // was not set, or was not defined in the schema.
  11978. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  11979. switch name {
  11980. case creditusage.FieldNumber:
  11981. return m.AddedNumber()
  11982. case creditusage.FieldStatus:
  11983. return m.AddedStatus()
  11984. case creditusage.FieldNtype:
  11985. return m.AddedNtype()
  11986. case creditusage.FieldOrganizationID:
  11987. return m.AddedOrganizationID()
  11988. case creditusage.FieldNid:
  11989. return m.AddedNid()
  11990. }
  11991. return nil, false
  11992. }
  11993. // AddField adds the value to the field with the given name. It returns an error if
  11994. // the field is not defined in the schema, or if the type mismatched the field
  11995. // type.
  11996. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  11997. switch name {
  11998. case creditusage.FieldNumber:
  11999. v, ok := value.(float32)
  12000. if !ok {
  12001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12002. }
  12003. m.AddNumber(v)
  12004. return nil
  12005. case creditusage.FieldStatus:
  12006. v, ok := value.(int)
  12007. if !ok {
  12008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12009. }
  12010. m.AddStatus(v)
  12011. return nil
  12012. case creditusage.FieldNtype:
  12013. v, ok := value.(int)
  12014. if !ok {
  12015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12016. }
  12017. m.AddNtype(v)
  12018. return nil
  12019. case creditusage.FieldOrganizationID:
  12020. v, ok := value.(int64)
  12021. if !ok {
  12022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12023. }
  12024. m.AddOrganizationID(v)
  12025. return nil
  12026. case creditusage.FieldNid:
  12027. v, ok := value.(int64)
  12028. if !ok {
  12029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12030. }
  12031. m.AddNid(v)
  12032. return nil
  12033. }
  12034. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  12035. }
  12036. // ClearedFields returns all nullable fields that were cleared during this
  12037. // mutation.
  12038. func (m *CreditUsageMutation) ClearedFields() []string {
  12039. var fields []string
  12040. if m.FieldCleared(creditusage.FieldDeletedAt) {
  12041. fields = append(fields, creditusage.FieldDeletedAt)
  12042. }
  12043. if m.FieldCleared(creditusage.FieldUserID) {
  12044. fields = append(fields, creditusage.FieldUserID)
  12045. }
  12046. if m.FieldCleared(creditusage.FieldStatus) {
  12047. fields = append(fields, creditusage.FieldStatus)
  12048. }
  12049. if m.FieldCleared(creditusage.FieldOrganizationID) {
  12050. fields = append(fields, creditusage.FieldOrganizationID)
  12051. }
  12052. return fields
  12053. }
  12054. // FieldCleared returns a boolean indicating if a field with the given name was
  12055. // cleared in this mutation.
  12056. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  12057. _, ok := m.clearedFields[name]
  12058. return ok
  12059. }
  12060. // ClearField clears the value of the field with the given name. It returns an
  12061. // error if the field is not defined in the schema.
  12062. func (m *CreditUsageMutation) ClearField(name string) error {
  12063. switch name {
  12064. case creditusage.FieldDeletedAt:
  12065. m.ClearDeletedAt()
  12066. return nil
  12067. case creditusage.FieldUserID:
  12068. m.ClearUserID()
  12069. return nil
  12070. case creditusage.FieldStatus:
  12071. m.ClearStatus()
  12072. return nil
  12073. case creditusage.FieldOrganizationID:
  12074. m.ClearOrganizationID()
  12075. return nil
  12076. }
  12077. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  12078. }
  12079. // ResetField resets all changes in the mutation for the field with the given name.
  12080. // It returns an error if the field is not defined in the schema.
  12081. func (m *CreditUsageMutation) ResetField(name string) error {
  12082. switch name {
  12083. case creditusage.FieldCreatedAt:
  12084. m.ResetCreatedAt()
  12085. return nil
  12086. case creditusage.FieldUpdatedAt:
  12087. m.ResetUpdatedAt()
  12088. return nil
  12089. case creditusage.FieldDeletedAt:
  12090. m.ResetDeletedAt()
  12091. return nil
  12092. case creditusage.FieldUserID:
  12093. m.ResetUserID()
  12094. return nil
  12095. case creditusage.FieldNumber:
  12096. m.ResetNumber()
  12097. return nil
  12098. case creditusage.FieldStatus:
  12099. m.ResetStatus()
  12100. return nil
  12101. case creditusage.FieldNtype:
  12102. m.ResetNtype()
  12103. return nil
  12104. case creditusage.FieldTable:
  12105. m.ResetTable()
  12106. return nil
  12107. case creditusage.FieldOrganizationID:
  12108. m.ResetOrganizationID()
  12109. return nil
  12110. case creditusage.FieldNid:
  12111. m.ResetNid()
  12112. return nil
  12113. case creditusage.FieldReason:
  12114. m.ResetReason()
  12115. return nil
  12116. case creditusage.FieldOperator:
  12117. m.ResetOperator()
  12118. return nil
  12119. }
  12120. return fmt.Errorf("unknown CreditUsage field %s", name)
  12121. }
  12122. // AddedEdges returns all edge names that were set/added in this mutation.
  12123. func (m *CreditUsageMutation) AddedEdges() []string {
  12124. edges := make([]string, 0, 0)
  12125. return edges
  12126. }
  12127. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12128. // name in this mutation.
  12129. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  12130. return nil
  12131. }
  12132. // RemovedEdges returns all edge names that were removed in this mutation.
  12133. func (m *CreditUsageMutation) RemovedEdges() []string {
  12134. edges := make([]string, 0, 0)
  12135. return edges
  12136. }
  12137. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12138. // the given name in this mutation.
  12139. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  12140. return nil
  12141. }
  12142. // ClearedEdges returns all edge names that were cleared in this mutation.
  12143. func (m *CreditUsageMutation) ClearedEdges() []string {
  12144. edges := make([]string, 0, 0)
  12145. return edges
  12146. }
  12147. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12148. // was cleared in this mutation.
  12149. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  12150. return false
  12151. }
  12152. // ClearEdge clears the value of the edge with the given name. It returns an error
  12153. // if that edge is not defined in the schema.
  12154. func (m *CreditUsageMutation) ClearEdge(name string) error {
  12155. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  12156. }
  12157. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12158. // It returns an error if the edge is not defined in the schema.
  12159. func (m *CreditUsageMutation) ResetEdge(name string) error {
  12160. return fmt.Errorf("unknown CreditUsage edge %s", name)
  12161. }
  12162. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  12163. type EmployeeMutation struct {
  12164. config
  12165. op Op
  12166. typ string
  12167. id *uint64
  12168. created_at *time.Time
  12169. updated_at *time.Time
  12170. deleted_at *time.Time
  12171. title *string
  12172. avatar *string
  12173. tags *string
  12174. hire_count *int
  12175. addhire_count *int
  12176. service_count *int
  12177. addservice_count *int
  12178. achievement_count *int
  12179. addachievement_count *int
  12180. intro *string
  12181. estimate *string
  12182. skill *string
  12183. ability_type *string
  12184. scene *string
  12185. switch_in *string
  12186. video_url *string
  12187. organization_id *uint64
  12188. addorganization_id *int64
  12189. category_id *uint64
  12190. addcategory_id *int64
  12191. api_base *string
  12192. api_key *string
  12193. ai_info *string
  12194. is_vip *int
  12195. addis_vip *int
  12196. chat_url *string
  12197. clearedFields map[string]struct{}
  12198. em_work_experiences map[uint64]struct{}
  12199. removedem_work_experiences map[uint64]struct{}
  12200. clearedem_work_experiences bool
  12201. em_tutorial map[uint64]struct{}
  12202. removedem_tutorial map[uint64]struct{}
  12203. clearedem_tutorial bool
  12204. done bool
  12205. oldValue func(context.Context) (*Employee, error)
  12206. predicates []predicate.Employee
  12207. }
  12208. var _ ent.Mutation = (*EmployeeMutation)(nil)
  12209. // employeeOption allows management of the mutation configuration using functional options.
  12210. type employeeOption func(*EmployeeMutation)
  12211. // newEmployeeMutation creates new mutation for the Employee entity.
  12212. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  12213. m := &EmployeeMutation{
  12214. config: c,
  12215. op: op,
  12216. typ: TypeEmployee,
  12217. clearedFields: make(map[string]struct{}),
  12218. }
  12219. for _, opt := range opts {
  12220. opt(m)
  12221. }
  12222. return m
  12223. }
  12224. // withEmployeeID sets the ID field of the mutation.
  12225. func withEmployeeID(id uint64) employeeOption {
  12226. return func(m *EmployeeMutation) {
  12227. var (
  12228. err error
  12229. once sync.Once
  12230. value *Employee
  12231. )
  12232. m.oldValue = func(ctx context.Context) (*Employee, error) {
  12233. once.Do(func() {
  12234. if m.done {
  12235. err = errors.New("querying old values post mutation is not allowed")
  12236. } else {
  12237. value, err = m.Client().Employee.Get(ctx, id)
  12238. }
  12239. })
  12240. return value, err
  12241. }
  12242. m.id = &id
  12243. }
  12244. }
  12245. // withEmployee sets the old Employee of the mutation.
  12246. func withEmployee(node *Employee) employeeOption {
  12247. return func(m *EmployeeMutation) {
  12248. m.oldValue = func(context.Context) (*Employee, error) {
  12249. return node, nil
  12250. }
  12251. m.id = &node.ID
  12252. }
  12253. }
  12254. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12255. // executed in a transaction (ent.Tx), a transactional client is returned.
  12256. func (m EmployeeMutation) Client() *Client {
  12257. client := &Client{config: m.config}
  12258. client.init()
  12259. return client
  12260. }
  12261. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12262. // it returns an error otherwise.
  12263. func (m EmployeeMutation) Tx() (*Tx, error) {
  12264. if _, ok := m.driver.(*txDriver); !ok {
  12265. return nil, errors.New("ent: mutation is not running in a transaction")
  12266. }
  12267. tx := &Tx{config: m.config}
  12268. tx.init()
  12269. return tx, nil
  12270. }
  12271. // SetID sets the value of the id field. Note that this
  12272. // operation is only accepted on creation of Employee entities.
  12273. func (m *EmployeeMutation) SetID(id uint64) {
  12274. m.id = &id
  12275. }
  12276. // ID returns the ID value in the mutation. Note that the ID is only available
  12277. // if it was provided to the builder or after it was returned from the database.
  12278. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  12279. if m.id == nil {
  12280. return
  12281. }
  12282. return *m.id, true
  12283. }
  12284. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12285. // That means, if the mutation is applied within a transaction with an isolation level such
  12286. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12287. // or updated by the mutation.
  12288. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  12289. switch {
  12290. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12291. id, exists := m.ID()
  12292. if exists {
  12293. return []uint64{id}, nil
  12294. }
  12295. fallthrough
  12296. case m.op.Is(OpUpdate | OpDelete):
  12297. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  12298. default:
  12299. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12300. }
  12301. }
  12302. // SetCreatedAt sets the "created_at" field.
  12303. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  12304. m.created_at = &t
  12305. }
  12306. // CreatedAt returns the value of the "created_at" field in the mutation.
  12307. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  12308. v := m.created_at
  12309. if v == nil {
  12310. return
  12311. }
  12312. return *v, true
  12313. }
  12314. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  12315. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12317. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12318. if !m.op.Is(OpUpdateOne) {
  12319. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12320. }
  12321. if m.id == nil || m.oldValue == nil {
  12322. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12323. }
  12324. oldValue, err := m.oldValue(ctx)
  12325. if err != nil {
  12326. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12327. }
  12328. return oldValue.CreatedAt, nil
  12329. }
  12330. // ResetCreatedAt resets all changes to the "created_at" field.
  12331. func (m *EmployeeMutation) ResetCreatedAt() {
  12332. m.created_at = nil
  12333. }
  12334. // SetUpdatedAt sets the "updated_at" field.
  12335. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  12336. m.updated_at = &t
  12337. }
  12338. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12339. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  12340. v := m.updated_at
  12341. if v == nil {
  12342. return
  12343. }
  12344. return *v, true
  12345. }
  12346. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  12347. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12349. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12350. if !m.op.Is(OpUpdateOne) {
  12351. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12352. }
  12353. if m.id == nil || m.oldValue == nil {
  12354. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12355. }
  12356. oldValue, err := m.oldValue(ctx)
  12357. if err != nil {
  12358. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12359. }
  12360. return oldValue.UpdatedAt, nil
  12361. }
  12362. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12363. func (m *EmployeeMutation) ResetUpdatedAt() {
  12364. m.updated_at = nil
  12365. }
  12366. // SetDeletedAt sets the "deleted_at" field.
  12367. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  12368. m.deleted_at = &t
  12369. }
  12370. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12371. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  12372. v := m.deleted_at
  12373. if v == nil {
  12374. return
  12375. }
  12376. return *v, true
  12377. }
  12378. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  12379. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12381. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12382. if !m.op.Is(OpUpdateOne) {
  12383. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12384. }
  12385. if m.id == nil || m.oldValue == nil {
  12386. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12387. }
  12388. oldValue, err := m.oldValue(ctx)
  12389. if err != nil {
  12390. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12391. }
  12392. return oldValue.DeletedAt, nil
  12393. }
  12394. // ClearDeletedAt clears the value of the "deleted_at" field.
  12395. func (m *EmployeeMutation) ClearDeletedAt() {
  12396. m.deleted_at = nil
  12397. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  12398. }
  12399. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12400. func (m *EmployeeMutation) DeletedAtCleared() bool {
  12401. _, ok := m.clearedFields[employee.FieldDeletedAt]
  12402. return ok
  12403. }
  12404. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12405. func (m *EmployeeMutation) ResetDeletedAt() {
  12406. m.deleted_at = nil
  12407. delete(m.clearedFields, employee.FieldDeletedAt)
  12408. }
  12409. // SetTitle sets the "title" field.
  12410. func (m *EmployeeMutation) SetTitle(s string) {
  12411. m.title = &s
  12412. }
  12413. // Title returns the value of the "title" field in the mutation.
  12414. func (m *EmployeeMutation) Title() (r string, exists bool) {
  12415. v := m.title
  12416. if v == nil {
  12417. return
  12418. }
  12419. return *v, true
  12420. }
  12421. // OldTitle returns the old "title" field's value of the Employee entity.
  12422. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12424. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  12425. if !m.op.Is(OpUpdateOne) {
  12426. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  12427. }
  12428. if m.id == nil || m.oldValue == nil {
  12429. return v, errors.New("OldTitle requires an ID field in the mutation")
  12430. }
  12431. oldValue, err := m.oldValue(ctx)
  12432. if err != nil {
  12433. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  12434. }
  12435. return oldValue.Title, nil
  12436. }
  12437. // ResetTitle resets all changes to the "title" field.
  12438. func (m *EmployeeMutation) ResetTitle() {
  12439. m.title = nil
  12440. }
  12441. // SetAvatar sets the "avatar" field.
  12442. func (m *EmployeeMutation) SetAvatar(s string) {
  12443. m.avatar = &s
  12444. }
  12445. // Avatar returns the value of the "avatar" field in the mutation.
  12446. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  12447. v := m.avatar
  12448. if v == nil {
  12449. return
  12450. }
  12451. return *v, true
  12452. }
  12453. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  12454. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12456. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  12457. if !m.op.Is(OpUpdateOne) {
  12458. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  12459. }
  12460. if m.id == nil || m.oldValue == nil {
  12461. return v, errors.New("OldAvatar requires an ID field in the mutation")
  12462. }
  12463. oldValue, err := m.oldValue(ctx)
  12464. if err != nil {
  12465. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  12466. }
  12467. return oldValue.Avatar, nil
  12468. }
  12469. // ResetAvatar resets all changes to the "avatar" field.
  12470. func (m *EmployeeMutation) ResetAvatar() {
  12471. m.avatar = nil
  12472. }
  12473. // SetTags sets the "tags" field.
  12474. func (m *EmployeeMutation) SetTags(s string) {
  12475. m.tags = &s
  12476. }
  12477. // Tags returns the value of the "tags" field in the mutation.
  12478. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  12479. v := m.tags
  12480. if v == nil {
  12481. return
  12482. }
  12483. return *v, true
  12484. }
  12485. // OldTags returns the old "tags" field's value of the Employee entity.
  12486. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12488. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  12489. if !m.op.Is(OpUpdateOne) {
  12490. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  12491. }
  12492. if m.id == nil || m.oldValue == nil {
  12493. return v, errors.New("OldTags requires an ID field in the mutation")
  12494. }
  12495. oldValue, err := m.oldValue(ctx)
  12496. if err != nil {
  12497. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  12498. }
  12499. return oldValue.Tags, nil
  12500. }
  12501. // ResetTags resets all changes to the "tags" field.
  12502. func (m *EmployeeMutation) ResetTags() {
  12503. m.tags = nil
  12504. }
  12505. // SetHireCount sets the "hire_count" field.
  12506. func (m *EmployeeMutation) SetHireCount(i int) {
  12507. m.hire_count = &i
  12508. m.addhire_count = nil
  12509. }
  12510. // HireCount returns the value of the "hire_count" field in the mutation.
  12511. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  12512. v := m.hire_count
  12513. if v == nil {
  12514. return
  12515. }
  12516. return *v, true
  12517. }
  12518. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  12519. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12521. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  12522. if !m.op.Is(OpUpdateOne) {
  12523. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  12524. }
  12525. if m.id == nil || m.oldValue == nil {
  12526. return v, errors.New("OldHireCount requires an ID field in the mutation")
  12527. }
  12528. oldValue, err := m.oldValue(ctx)
  12529. if err != nil {
  12530. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  12531. }
  12532. return oldValue.HireCount, nil
  12533. }
  12534. // AddHireCount adds i to the "hire_count" field.
  12535. func (m *EmployeeMutation) AddHireCount(i int) {
  12536. if m.addhire_count != nil {
  12537. *m.addhire_count += i
  12538. } else {
  12539. m.addhire_count = &i
  12540. }
  12541. }
  12542. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  12543. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  12544. v := m.addhire_count
  12545. if v == nil {
  12546. return
  12547. }
  12548. return *v, true
  12549. }
  12550. // ResetHireCount resets all changes to the "hire_count" field.
  12551. func (m *EmployeeMutation) ResetHireCount() {
  12552. m.hire_count = nil
  12553. m.addhire_count = nil
  12554. }
  12555. // SetServiceCount sets the "service_count" field.
  12556. func (m *EmployeeMutation) SetServiceCount(i int) {
  12557. m.service_count = &i
  12558. m.addservice_count = nil
  12559. }
  12560. // ServiceCount returns the value of the "service_count" field in the mutation.
  12561. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  12562. v := m.service_count
  12563. if v == nil {
  12564. return
  12565. }
  12566. return *v, true
  12567. }
  12568. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  12569. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12571. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  12572. if !m.op.Is(OpUpdateOne) {
  12573. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  12574. }
  12575. if m.id == nil || m.oldValue == nil {
  12576. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  12577. }
  12578. oldValue, err := m.oldValue(ctx)
  12579. if err != nil {
  12580. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  12581. }
  12582. return oldValue.ServiceCount, nil
  12583. }
  12584. // AddServiceCount adds i to the "service_count" field.
  12585. func (m *EmployeeMutation) AddServiceCount(i int) {
  12586. if m.addservice_count != nil {
  12587. *m.addservice_count += i
  12588. } else {
  12589. m.addservice_count = &i
  12590. }
  12591. }
  12592. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  12593. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  12594. v := m.addservice_count
  12595. if v == nil {
  12596. return
  12597. }
  12598. return *v, true
  12599. }
  12600. // ResetServiceCount resets all changes to the "service_count" field.
  12601. func (m *EmployeeMutation) ResetServiceCount() {
  12602. m.service_count = nil
  12603. m.addservice_count = nil
  12604. }
  12605. // SetAchievementCount sets the "achievement_count" field.
  12606. func (m *EmployeeMutation) SetAchievementCount(i int) {
  12607. m.achievement_count = &i
  12608. m.addachievement_count = nil
  12609. }
  12610. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  12611. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  12612. v := m.achievement_count
  12613. if v == nil {
  12614. return
  12615. }
  12616. return *v, true
  12617. }
  12618. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  12619. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12621. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  12622. if !m.op.Is(OpUpdateOne) {
  12623. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  12624. }
  12625. if m.id == nil || m.oldValue == nil {
  12626. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  12627. }
  12628. oldValue, err := m.oldValue(ctx)
  12629. if err != nil {
  12630. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  12631. }
  12632. return oldValue.AchievementCount, nil
  12633. }
  12634. // AddAchievementCount adds i to the "achievement_count" field.
  12635. func (m *EmployeeMutation) AddAchievementCount(i int) {
  12636. if m.addachievement_count != nil {
  12637. *m.addachievement_count += i
  12638. } else {
  12639. m.addachievement_count = &i
  12640. }
  12641. }
  12642. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  12643. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  12644. v := m.addachievement_count
  12645. if v == nil {
  12646. return
  12647. }
  12648. return *v, true
  12649. }
  12650. // ResetAchievementCount resets all changes to the "achievement_count" field.
  12651. func (m *EmployeeMutation) ResetAchievementCount() {
  12652. m.achievement_count = nil
  12653. m.addachievement_count = nil
  12654. }
  12655. // SetIntro sets the "intro" field.
  12656. func (m *EmployeeMutation) SetIntro(s string) {
  12657. m.intro = &s
  12658. }
  12659. // Intro returns the value of the "intro" field in the mutation.
  12660. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  12661. v := m.intro
  12662. if v == nil {
  12663. return
  12664. }
  12665. return *v, true
  12666. }
  12667. // OldIntro returns the old "intro" field's value of the Employee entity.
  12668. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12670. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  12671. if !m.op.Is(OpUpdateOne) {
  12672. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  12673. }
  12674. if m.id == nil || m.oldValue == nil {
  12675. return v, errors.New("OldIntro requires an ID field in the mutation")
  12676. }
  12677. oldValue, err := m.oldValue(ctx)
  12678. if err != nil {
  12679. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  12680. }
  12681. return oldValue.Intro, nil
  12682. }
  12683. // ResetIntro resets all changes to the "intro" field.
  12684. func (m *EmployeeMutation) ResetIntro() {
  12685. m.intro = nil
  12686. }
  12687. // SetEstimate sets the "estimate" field.
  12688. func (m *EmployeeMutation) SetEstimate(s string) {
  12689. m.estimate = &s
  12690. }
  12691. // Estimate returns the value of the "estimate" field in the mutation.
  12692. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  12693. v := m.estimate
  12694. if v == nil {
  12695. return
  12696. }
  12697. return *v, true
  12698. }
  12699. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  12700. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12702. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  12703. if !m.op.Is(OpUpdateOne) {
  12704. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  12705. }
  12706. if m.id == nil || m.oldValue == nil {
  12707. return v, errors.New("OldEstimate requires an ID field in the mutation")
  12708. }
  12709. oldValue, err := m.oldValue(ctx)
  12710. if err != nil {
  12711. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  12712. }
  12713. return oldValue.Estimate, nil
  12714. }
  12715. // ResetEstimate resets all changes to the "estimate" field.
  12716. func (m *EmployeeMutation) ResetEstimate() {
  12717. m.estimate = nil
  12718. }
  12719. // SetSkill sets the "skill" field.
  12720. func (m *EmployeeMutation) SetSkill(s string) {
  12721. m.skill = &s
  12722. }
  12723. // Skill returns the value of the "skill" field in the mutation.
  12724. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  12725. v := m.skill
  12726. if v == nil {
  12727. return
  12728. }
  12729. return *v, true
  12730. }
  12731. // OldSkill returns the old "skill" field's value of the Employee entity.
  12732. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12734. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  12735. if !m.op.Is(OpUpdateOne) {
  12736. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  12737. }
  12738. if m.id == nil || m.oldValue == nil {
  12739. return v, errors.New("OldSkill requires an ID field in the mutation")
  12740. }
  12741. oldValue, err := m.oldValue(ctx)
  12742. if err != nil {
  12743. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  12744. }
  12745. return oldValue.Skill, nil
  12746. }
  12747. // ResetSkill resets all changes to the "skill" field.
  12748. func (m *EmployeeMutation) ResetSkill() {
  12749. m.skill = nil
  12750. }
  12751. // SetAbilityType sets the "ability_type" field.
  12752. func (m *EmployeeMutation) SetAbilityType(s string) {
  12753. m.ability_type = &s
  12754. }
  12755. // AbilityType returns the value of the "ability_type" field in the mutation.
  12756. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  12757. v := m.ability_type
  12758. if v == nil {
  12759. return
  12760. }
  12761. return *v, true
  12762. }
  12763. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  12764. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12766. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  12767. if !m.op.Is(OpUpdateOne) {
  12768. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  12769. }
  12770. if m.id == nil || m.oldValue == nil {
  12771. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  12772. }
  12773. oldValue, err := m.oldValue(ctx)
  12774. if err != nil {
  12775. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  12776. }
  12777. return oldValue.AbilityType, nil
  12778. }
  12779. // ResetAbilityType resets all changes to the "ability_type" field.
  12780. func (m *EmployeeMutation) ResetAbilityType() {
  12781. m.ability_type = nil
  12782. }
  12783. // SetScene sets the "scene" field.
  12784. func (m *EmployeeMutation) SetScene(s string) {
  12785. m.scene = &s
  12786. }
  12787. // Scene returns the value of the "scene" field in the mutation.
  12788. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  12789. v := m.scene
  12790. if v == nil {
  12791. return
  12792. }
  12793. return *v, true
  12794. }
  12795. // OldScene returns the old "scene" field's value of the Employee entity.
  12796. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12798. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  12799. if !m.op.Is(OpUpdateOne) {
  12800. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  12801. }
  12802. if m.id == nil || m.oldValue == nil {
  12803. return v, errors.New("OldScene requires an ID field in the mutation")
  12804. }
  12805. oldValue, err := m.oldValue(ctx)
  12806. if err != nil {
  12807. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  12808. }
  12809. return oldValue.Scene, nil
  12810. }
  12811. // ResetScene resets all changes to the "scene" field.
  12812. func (m *EmployeeMutation) ResetScene() {
  12813. m.scene = nil
  12814. }
  12815. // SetSwitchIn sets the "switch_in" field.
  12816. func (m *EmployeeMutation) SetSwitchIn(s string) {
  12817. m.switch_in = &s
  12818. }
  12819. // SwitchIn returns the value of the "switch_in" field in the mutation.
  12820. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  12821. v := m.switch_in
  12822. if v == nil {
  12823. return
  12824. }
  12825. return *v, true
  12826. }
  12827. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  12828. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12830. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  12831. if !m.op.Is(OpUpdateOne) {
  12832. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  12833. }
  12834. if m.id == nil || m.oldValue == nil {
  12835. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  12836. }
  12837. oldValue, err := m.oldValue(ctx)
  12838. if err != nil {
  12839. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  12840. }
  12841. return oldValue.SwitchIn, nil
  12842. }
  12843. // ResetSwitchIn resets all changes to the "switch_in" field.
  12844. func (m *EmployeeMutation) ResetSwitchIn() {
  12845. m.switch_in = nil
  12846. }
  12847. // SetVideoURL sets the "video_url" field.
  12848. func (m *EmployeeMutation) SetVideoURL(s string) {
  12849. m.video_url = &s
  12850. }
  12851. // VideoURL returns the value of the "video_url" field in the mutation.
  12852. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  12853. v := m.video_url
  12854. if v == nil {
  12855. return
  12856. }
  12857. return *v, true
  12858. }
  12859. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  12860. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12862. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  12863. if !m.op.Is(OpUpdateOne) {
  12864. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  12865. }
  12866. if m.id == nil || m.oldValue == nil {
  12867. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  12868. }
  12869. oldValue, err := m.oldValue(ctx)
  12870. if err != nil {
  12871. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  12872. }
  12873. return oldValue.VideoURL, nil
  12874. }
  12875. // ResetVideoURL resets all changes to the "video_url" field.
  12876. func (m *EmployeeMutation) ResetVideoURL() {
  12877. m.video_url = nil
  12878. }
  12879. // SetOrganizationID sets the "organization_id" field.
  12880. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  12881. m.organization_id = &u
  12882. m.addorganization_id = nil
  12883. }
  12884. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12885. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  12886. v := m.organization_id
  12887. if v == nil {
  12888. return
  12889. }
  12890. return *v, true
  12891. }
  12892. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  12893. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12895. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12896. if !m.op.Is(OpUpdateOne) {
  12897. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12898. }
  12899. if m.id == nil || m.oldValue == nil {
  12900. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12901. }
  12902. oldValue, err := m.oldValue(ctx)
  12903. if err != nil {
  12904. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12905. }
  12906. return oldValue.OrganizationID, nil
  12907. }
  12908. // AddOrganizationID adds u to the "organization_id" field.
  12909. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  12910. if m.addorganization_id != nil {
  12911. *m.addorganization_id += u
  12912. } else {
  12913. m.addorganization_id = &u
  12914. }
  12915. }
  12916. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12917. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  12918. v := m.addorganization_id
  12919. if v == nil {
  12920. return
  12921. }
  12922. return *v, true
  12923. }
  12924. // ResetOrganizationID resets all changes to the "organization_id" field.
  12925. func (m *EmployeeMutation) ResetOrganizationID() {
  12926. m.organization_id = nil
  12927. m.addorganization_id = nil
  12928. }
  12929. // SetCategoryID sets the "category_id" field.
  12930. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  12931. m.category_id = &u
  12932. m.addcategory_id = nil
  12933. }
  12934. // CategoryID returns the value of the "category_id" field in the mutation.
  12935. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  12936. v := m.category_id
  12937. if v == nil {
  12938. return
  12939. }
  12940. return *v, true
  12941. }
  12942. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  12943. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12945. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  12946. if !m.op.Is(OpUpdateOne) {
  12947. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  12948. }
  12949. if m.id == nil || m.oldValue == nil {
  12950. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  12951. }
  12952. oldValue, err := m.oldValue(ctx)
  12953. if err != nil {
  12954. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  12955. }
  12956. return oldValue.CategoryID, nil
  12957. }
  12958. // AddCategoryID adds u to the "category_id" field.
  12959. func (m *EmployeeMutation) AddCategoryID(u int64) {
  12960. if m.addcategory_id != nil {
  12961. *m.addcategory_id += u
  12962. } else {
  12963. m.addcategory_id = &u
  12964. }
  12965. }
  12966. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  12967. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  12968. v := m.addcategory_id
  12969. if v == nil {
  12970. return
  12971. }
  12972. return *v, true
  12973. }
  12974. // ResetCategoryID resets all changes to the "category_id" field.
  12975. func (m *EmployeeMutation) ResetCategoryID() {
  12976. m.category_id = nil
  12977. m.addcategory_id = nil
  12978. }
  12979. // SetAPIBase sets the "api_base" field.
  12980. func (m *EmployeeMutation) SetAPIBase(s string) {
  12981. m.api_base = &s
  12982. }
  12983. // APIBase returns the value of the "api_base" field in the mutation.
  12984. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  12985. v := m.api_base
  12986. if v == nil {
  12987. return
  12988. }
  12989. return *v, true
  12990. }
  12991. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  12992. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12994. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  12995. if !m.op.Is(OpUpdateOne) {
  12996. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  12997. }
  12998. if m.id == nil || m.oldValue == nil {
  12999. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  13000. }
  13001. oldValue, err := m.oldValue(ctx)
  13002. if err != nil {
  13003. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  13004. }
  13005. return oldValue.APIBase, nil
  13006. }
  13007. // ResetAPIBase resets all changes to the "api_base" field.
  13008. func (m *EmployeeMutation) ResetAPIBase() {
  13009. m.api_base = nil
  13010. }
  13011. // SetAPIKey sets the "api_key" field.
  13012. func (m *EmployeeMutation) SetAPIKey(s string) {
  13013. m.api_key = &s
  13014. }
  13015. // APIKey returns the value of the "api_key" field in the mutation.
  13016. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  13017. v := m.api_key
  13018. if v == nil {
  13019. return
  13020. }
  13021. return *v, true
  13022. }
  13023. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  13024. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13026. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  13027. if !m.op.Is(OpUpdateOne) {
  13028. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  13029. }
  13030. if m.id == nil || m.oldValue == nil {
  13031. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  13032. }
  13033. oldValue, err := m.oldValue(ctx)
  13034. if err != nil {
  13035. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  13036. }
  13037. return oldValue.APIKey, nil
  13038. }
  13039. // ResetAPIKey resets all changes to the "api_key" field.
  13040. func (m *EmployeeMutation) ResetAPIKey() {
  13041. m.api_key = nil
  13042. }
  13043. // SetAiInfo sets the "ai_info" field.
  13044. func (m *EmployeeMutation) SetAiInfo(s string) {
  13045. m.ai_info = &s
  13046. }
  13047. // AiInfo returns the value of the "ai_info" field in the mutation.
  13048. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  13049. v := m.ai_info
  13050. if v == nil {
  13051. return
  13052. }
  13053. return *v, true
  13054. }
  13055. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  13056. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13058. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  13059. if !m.op.Is(OpUpdateOne) {
  13060. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  13061. }
  13062. if m.id == nil || m.oldValue == nil {
  13063. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  13064. }
  13065. oldValue, err := m.oldValue(ctx)
  13066. if err != nil {
  13067. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  13068. }
  13069. return oldValue.AiInfo, nil
  13070. }
  13071. // ClearAiInfo clears the value of the "ai_info" field.
  13072. func (m *EmployeeMutation) ClearAiInfo() {
  13073. m.ai_info = nil
  13074. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  13075. }
  13076. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  13077. func (m *EmployeeMutation) AiInfoCleared() bool {
  13078. _, ok := m.clearedFields[employee.FieldAiInfo]
  13079. return ok
  13080. }
  13081. // ResetAiInfo resets all changes to the "ai_info" field.
  13082. func (m *EmployeeMutation) ResetAiInfo() {
  13083. m.ai_info = nil
  13084. delete(m.clearedFields, employee.FieldAiInfo)
  13085. }
  13086. // SetIsVip sets the "is_vip" field.
  13087. func (m *EmployeeMutation) SetIsVip(i int) {
  13088. m.is_vip = &i
  13089. m.addis_vip = nil
  13090. }
  13091. // IsVip returns the value of the "is_vip" field in the mutation.
  13092. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  13093. v := m.is_vip
  13094. if v == nil {
  13095. return
  13096. }
  13097. return *v, true
  13098. }
  13099. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  13100. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13102. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  13103. if !m.op.Is(OpUpdateOne) {
  13104. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  13105. }
  13106. if m.id == nil || m.oldValue == nil {
  13107. return v, errors.New("OldIsVip requires an ID field in the mutation")
  13108. }
  13109. oldValue, err := m.oldValue(ctx)
  13110. if err != nil {
  13111. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  13112. }
  13113. return oldValue.IsVip, nil
  13114. }
  13115. // AddIsVip adds i to the "is_vip" field.
  13116. func (m *EmployeeMutation) AddIsVip(i int) {
  13117. if m.addis_vip != nil {
  13118. *m.addis_vip += i
  13119. } else {
  13120. m.addis_vip = &i
  13121. }
  13122. }
  13123. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  13124. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  13125. v := m.addis_vip
  13126. if v == nil {
  13127. return
  13128. }
  13129. return *v, true
  13130. }
  13131. // ResetIsVip resets all changes to the "is_vip" field.
  13132. func (m *EmployeeMutation) ResetIsVip() {
  13133. m.is_vip = nil
  13134. m.addis_vip = nil
  13135. }
  13136. // SetChatURL sets the "chat_url" field.
  13137. func (m *EmployeeMutation) SetChatURL(s string) {
  13138. m.chat_url = &s
  13139. }
  13140. // ChatURL returns the value of the "chat_url" field in the mutation.
  13141. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  13142. v := m.chat_url
  13143. if v == nil {
  13144. return
  13145. }
  13146. return *v, true
  13147. }
  13148. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  13149. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13151. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  13152. if !m.op.Is(OpUpdateOne) {
  13153. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  13154. }
  13155. if m.id == nil || m.oldValue == nil {
  13156. return v, errors.New("OldChatURL requires an ID field in the mutation")
  13157. }
  13158. oldValue, err := m.oldValue(ctx)
  13159. if err != nil {
  13160. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  13161. }
  13162. return oldValue.ChatURL, nil
  13163. }
  13164. // ResetChatURL resets all changes to the "chat_url" field.
  13165. func (m *EmployeeMutation) ResetChatURL() {
  13166. m.chat_url = nil
  13167. }
  13168. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  13169. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  13170. if m.em_work_experiences == nil {
  13171. m.em_work_experiences = make(map[uint64]struct{})
  13172. }
  13173. for i := range ids {
  13174. m.em_work_experiences[ids[i]] = struct{}{}
  13175. }
  13176. }
  13177. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  13178. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  13179. m.clearedem_work_experiences = true
  13180. }
  13181. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  13182. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  13183. return m.clearedem_work_experiences
  13184. }
  13185. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  13186. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  13187. if m.removedem_work_experiences == nil {
  13188. m.removedem_work_experiences = make(map[uint64]struct{})
  13189. }
  13190. for i := range ids {
  13191. delete(m.em_work_experiences, ids[i])
  13192. m.removedem_work_experiences[ids[i]] = struct{}{}
  13193. }
  13194. }
  13195. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  13196. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  13197. for id := range m.removedem_work_experiences {
  13198. ids = append(ids, id)
  13199. }
  13200. return
  13201. }
  13202. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  13203. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  13204. for id := range m.em_work_experiences {
  13205. ids = append(ids, id)
  13206. }
  13207. return
  13208. }
  13209. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  13210. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  13211. m.em_work_experiences = nil
  13212. m.clearedem_work_experiences = false
  13213. m.removedem_work_experiences = nil
  13214. }
  13215. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  13216. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  13217. if m.em_tutorial == nil {
  13218. m.em_tutorial = make(map[uint64]struct{})
  13219. }
  13220. for i := range ids {
  13221. m.em_tutorial[ids[i]] = struct{}{}
  13222. }
  13223. }
  13224. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  13225. func (m *EmployeeMutation) ClearEmTutorial() {
  13226. m.clearedem_tutorial = true
  13227. }
  13228. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  13229. func (m *EmployeeMutation) EmTutorialCleared() bool {
  13230. return m.clearedem_tutorial
  13231. }
  13232. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  13233. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  13234. if m.removedem_tutorial == nil {
  13235. m.removedem_tutorial = make(map[uint64]struct{})
  13236. }
  13237. for i := range ids {
  13238. delete(m.em_tutorial, ids[i])
  13239. m.removedem_tutorial[ids[i]] = struct{}{}
  13240. }
  13241. }
  13242. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  13243. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  13244. for id := range m.removedem_tutorial {
  13245. ids = append(ids, id)
  13246. }
  13247. return
  13248. }
  13249. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  13250. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  13251. for id := range m.em_tutorial {
  13252. ids = append(ids, id)
  13253. }
  13254. return
  13255. }
  13256. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  13257. func (m *EmployeeMutation) ResetEmTutorial() {
  13258. m.em_tutorial = nil
  13259. m.clearedem_tutorial = false
  13260. m.removedem_tutorial = nil
  13261. }
  13262. // Where appends a list predicates to the EmployeeMutation builder.
  13263. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  13264. m.predicates = append(m.predicates, ps...)
  13265. }
  13266. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  13267. // users can use type-assertion to append predicates that do not depend on any generated package.
  13268. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  13269. p := make([]predicate.Employee, len(ps))
  13270. for i := range ps {
  13271. p[i] = ps[i]
  13272. }
  13273. m.Where(p...)
  13274. }
  13275. // Op returns the operation name.
  13276. func (m *EmployeeMutation) Op() Op {
  13277. return m.op
  13278. }
  13279. // SetOp allows setting the mutation operation.
  13280. func (m *EmployeeMutation) SetOp(op Op) {
  13281. m.op = op
  13282. }
  13283. // Type returns the node type of this mutation (Employee).
  13284. func (m *EmployeeMutation) Type() string {
  13285. return m.typ
  13286. }
  13287. // Fields returns all fields that were changed during this mutation. Note that in
  13288. // order to get all numeric fields that were incremented/decremented, call
  13289. // AddedFields().
  13290. func (m *EmployeeMutation) Fields() []string {
  13291. fields := make([]string, 0, 23)
  13292. if m.created_at != nil {
  13293. fields = append(fields, employee.FieldCreatedAt)
  13294. }
  13295. if m.updated_at != nil {
  13296. fields = append(fields, employee.FieldUpdatedAt)
  13297. }
  13298. if m.deleted_at != nil {
  13299. fields = append(fields, employee.FieldDeletedAt)
  13300. }
  13301. if m.title != nil {
  13302. fields = append(fields, employee.FieldTitle)
  13303. }
  13304. if m.avatar != nil {
  13305. fields = append(fields, employee.FieldAvatar)
  13306. }
  13307. if m.tags != nil {
  13308. fields = append(fields, employee.FieldTags)
  13309. }
  13310. if m.hire_count != nil {
  13311. fields = append(fields, employee.FieldHireCount)
  13312. }
  13313. if m.service_count != nil {
  13314. fields = append(fields, employee.FieldServiceCount)
  13315. }
  13316. if m.achievement_count != nil {
  13317. fields = append(fields, employee.FieldAchievementCount)
  13318. }
  13319. if m.intro != nil {
  13320. fields = append(fields, employee.FieldIntro)
  13321. }
  13322. if m.estimate != nil {
  13323. fields = append(fields, employee.FieldEstimate)
  13324. }
  13325. if m.skill != nil {
  13326. fields = append(fields, employee.FieldSkill)
  13327. }
  13328. if m.ability_type != nil {
  13329. fields = append(fields, employee.FieldAbilityType)
  13330. }
  13331. if m.scene != nil {
  13332. fields = append(fields, employee.FieldScene)
  13333. }
  13334. if m.switch_in != nil {
  13335. fields = append(fields, employee.FieldSwitchIn)
  13336. }
  13337. if m.video_url != nil {
  13338. fields = append(fields, employee.FieldVideoURL)
  13339. }
  13340. if m.organization_id != nil {
  13341. fields = append(fields, employee.FieldOrganizationID)
  13342. }
  13343. if m.category_id != nil {
  13344. fields = append(fields, employee.FieldCategoryID)
  13345. }
  13346. if m.api_base != nil {
  13347. fields = append(fields, employee.FieldAPIBase)
  13348. }
  13349. if m.api_key != nil {
  13350. fields = append(fields, employee.FieldAPIKey)
  13351. }
  13352. if m.ai_info != nil {
  13353. fields = append(fields, employee.FieldAiInfo)
  13354. }
  13355. if m.is_vip != nil {
  13356. fields = append(fields, employee.FieldIsVip)
  13357. }
  13358. if m.chat_url != nil {
  13359. fields = append(fields, employee.FieldChatURL)
  13360. }
  13361. return fields
  13362. }
  13363. // Field returns the value of a field with the given name. The second boolean
  13364. // return value indicates that this field was not set, or was not defined in the
  13365. // schema.
  13366. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  13367. switch name {
  13368. case employee.FieldCreatedAt:
  13369. return m.CreatedAt()
  13370. case employee.FieldUpdatedAt:
  13371. return m.UpdatedAt()
  13372. case employee.FieldDeletedAt:
  13373. return m.DeletedAt()
  13374. case employee.FieldTitle:
  13375. return m.Title()
  13376. case employee.FieldAvatar:
  13377. return m.Avatar()
  13378. case employee.FieldTags:
  13379. return m.Tags()
  13380. case employee.FieldHireCount:
  13381. return m.HireCount()
  13382. case employee.FieldServiceCount:
  13383. return m.ServiceCount()
  13384. case employee.FieldAchievementCount:
  13385. return m.AchievementCount()
  13386. case employee.FieldIntro:
  13387. return m.Intro()
  13388. case employee.FieldEstimate:
  13389. return m.Estimate()
  13390. case employee.FieldSkill:
  13391. return m.Skill()
  13392. case employee.FieldAbilityType:
  13393. return m.AbilityType()
  13394. case employee.FieldScene:
  13395. return m.Scene()
  13396. case employee.FieldSwitchIn:
  13397. return m.SwitchIn()
  13398. case employee.FieldVideoURL:
  13399. return m.VideoURL()
  13400. case employee.FieldOrganizationID:
  13401. return m.OrganizationID()
  13402. case employee.FieldCategoryID:
  13403. return m.CategoryID()
  13404. case employee.FieldAPIBase:
  13405. return m.APIBase()
  13406. case employee.FieldAPIKey:
  13407. return m.APIKey()
  13408. case employee.FieldAiInfo:
  13409. return m.AiInfo()
  13410. case employee.FieldIsVip:
  13411. return m.IsVip()
  13412. case employee.FieldChatURL:
  13413. return m.ChatURL()
  13414. }
  13415. return nil, false
  13416. }
  13417. // OldField returns the old value of the field from the database. An error is
  13418. // returned if the mutation operation is not UpdateOne, or the query to the
  13419. // database failed.
  13420. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13421. switch name {
  13422. case employee.FieldCreatedAt:
  13423. return m.OldCreatedAt(ctx)
  13424. case employee.FieldUpdatedAt:
  13425. return m.OldUpdatedAt(ctx)
  13426. case employee.FieldDeletedAt:
  13427. return m.OldDeletedAt(ctx)
  13428. case employee.FieldTitle:
  13429. return m.OldTitle(ctx)
  13430. case employee.FieldAvatar:
  13431. return m.OldAvatar(ctx)
  13432. case employee.FieldTags:
  13433. return m.OldTags(ctx)
  13434. case employee.FieldHireCount:
  13435. return m.OldHireCount(ctx)
  13436. case employee.FieldServiceCount:
  13437. return m.OldServiceCount(ctx)
  13438. case employee.FieldAchievementCount:
  13439. return m.OldAchievementCount(ctx)
  13440. case employee.FieldIntro:
  13441. return m.OldIntro(ctx)
  13442. case employee.FieldEstimate:
  13443. return m.OldEstimate(ctx)
  13444. case employee.FieldSkill:
  13445. return m.OldSkill(ctx)
  13446. case employee.FieldAbilityType:
  13447. return m.OldAbilityType(ctx)
  13448. case employee.FieldScene:
  13449. return m.OldScene(ctx)
  13450. case employee.FieldSwitchIn:
  13451. return m.OldSwitchIn(ctx)
  13452. case employee.FieldVideoURL:
  13453. return m.OldVideoURL(ctx)
  13454. case employee.FieldOrganizationID:
  13455. return m.OldOrganizationID(ctx)
  13456. case employee.FieldCategoryID:
  13457. return m.OldCategoryID(ctx)
  13458. case employee.FieldAPIBase:
  13459. return m.OldAPIBase(ctx)
  13460. case employee.FieldAPIKey:
  13461. return m.OldAPIKey(ctx)
  13462. case employee.FieldAiInfo:
  13463. return m.OldAiInfo(ctx)
  13464. case employee.FieldIsVip:
  13465. return m.OldIsVip(ctx)
  13466. case employee.FieldChatURL:
  13467. return m.OldChatURL(ctx)
  13468. }
  13469. return nil, fmt.Errorf("unknown Employee field %s", name)
  13470. }
  13471. // SetField sets the value of a field with the given name. It returns an error if
  13472. // the field is not defined in the schema, or if the type mismatched the field
  13473. // type.
  13474. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  13475. switch name {
  13476. case employee.FieldCreatedAt:
  13477. v, ok := value.(time.Time)
  13478. if !ok {
  13479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13480. }
  13481. m.SetCreatedAt(v)
  13482. return nil
  13483. case employee.FieldUpdatedAt:
  13484. v, ok := value.(time.Time)
  13485. if !ok {
  13486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13487. }
  13488. m.SetUpdatedAt(v)
  13489. return nil
  13490. case employee.FieldDeletedAt:
  13491. v, ok := value.(time.Time)
  13492. if !ok {
  13493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13494. }
  13495. m.SetDeletedAt(v)
  13496. return nil
  13497. case employee.FieldTitle:
  13498. v, ok := value.(string)
  13499. if !ok {
  13500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13501. }
  13502. m.SetTitle(v)
  13503. return nil
  13504. case employee.FieldAvatar:
  13505. v, ok := value.(string)
  13506. if !ok {
  13507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13508. }
  13509. m.SetAvatar(v)
  13510. return nil
  13511. case employee.FieldTags:
  13512. v, ok := value.(string)
  13513. if !ok {
  13514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13515. }
  13516. m.SetTags(v)
  13517. return nil
  13518. case employee.FieldHireCount:
  13519. v, ok := value.(int)
  13520. if !ok {
  13521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13522. }
  13523. m.SetHireCount(v)
  13524. return nil
  13525. case employee.FieldServiceCount:
  13526. v, ok := value.(int)
  13527. if !ok {
  13528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13529. }
  13530. m.SetServiceCount(v)
  13531. return nil
  13532. case employee.FieldAchievementCount:
  13533. v, ok := value.(int)
  13534. if !ok {
  13535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13536. }
  13537. m.SetAchievementCount(v)
  13538. return nil
  13539. case employee.FieldIntro:
  13540. v, ok := value.(string)
  13541. if !ok {
  13542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13543. }
  13544. m.SetIntro(v)
  13545. return nil
  13546. case employee.FieldEstimate:
  13547. v, ok := value.(string)
  13548. if !ok {
  13549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13550. }
  13551. m.SetEstimate(v)
  13552. return nil
  13553. case employee.FieldSkill:
  13554. v, ok := value.(string)
  13555. if !ok {
  13556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13557. }
  13558. m.SetSkill(v)
  13559. return nil
  13560. case employee.FieldAbilityType:
  13561. v, ok := value.(string)
  13562. if !ok {
  13563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13564. }
  13565. m.SetAbilityType(v)
  13566. return nil
  13567. case employee.FieldScene:
  13568. v, ok := value.(string)
  13569. if !ok {
  13570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13571. }
  13572. m.SetScene(v)
  13573. return nil
  13574. case employee.FieldSwitchIn:
  13575. v, ok := value.(string)
  13576. if !ok {
  13577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13578. }
  13579. m.SetSwitchIn(v)
  13580. return nil
  13581. case employee.FieldVideoURL:
  13582. v, ok := value.(string)
  13583. if !ok {
  13584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13585. }
  13586. m.SetVideoURL(v)
  13587. return nil
  13588. case employee.FieldOrganizationID:
  13589. v, ok := value.(uint64)
  13590. if !ok {
  13591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13592. }
  13593. m.SetOrganizationID(v)
  13594. return nil
  13595. case employee.FieldCategoryID:
  13596. v, ok := value.(uint64)
  13597. if !ok {
  13598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13599. }
  13600. m.SetCategoryID(v)
  13601. return nil
  13602. case employee.FieldAPIBase:
  13603. v, ok := value.(string)
  13604. if !ok {
  13605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13606. }
  13607. m.SetAPIBase(v)
  13608. return nil
  13609. case employee.FieldAPIKey:
  13610. v, ok := value.(string)
  13611. if !ok {
  13612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13613. }
  13614. m.SetAPIKey(v)
  13615. return nil
  13616. case employee.FieldAiInfo:
  13617. v, ok := value.(string)
  13618. if !ok {
  13619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13620. }
  13621. m.SetAiInfo(v)
  13622. return nil
  13623. case employee.FieldIsVip:
  13624. v, ok := value.(int)
  13625. if !ok {
  13626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13627. }
  13628. m.SetIsVip(v)
  13629. return nil
  13630. case employee.FieldChatURL:
  13631. v, ok := value.(string)
  13632. if !ok {
  13633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13634. }
  13635. m.SetChatURL(v)
  13636. return nil
  13637. }
  13638. return fmt.Errorf("unknown Employee field %s", name)
  13639. }
  13640. // AddedFields returns all numeric fields that were incremented/decremented during
  13641. // this mutation.
  13642. func (m *EmployeeMutation) AddedFields() []string {
  13643. var fields []string
  13644. if m.addhire_count != nil {
  13645. fields = append(fields, employee.FieldHireCount)
  13646. }
  13647. if m.addservice_count != nil {
  13648. fields = append(fields, employee.FieldServiceCount)
  13649. }
  13650. if m.addachievement_count != nil {
  13651. fields = append(fields, employee.FieldAchievementCount)
  13652. }
  13653. if m.addorganization_id != nil {
  13654. fields = append(fields, employee.FieldOrganizationID)
  13655. }
  13656. if m.addcategory_id != nil {
  13657. fields = append(fields, employee.FieldCategoryID)
  13658. }
  13659. if m.addis_vip != nil {
  13660. fields = append(fields, employee.FieldIsVip)
  13661. }
  13662. return fields
  13663. }
  13664. // AddedField returns the numeric value that was incremented/decremented on a field
  13665. // with the given name. The second boolean return value indicates that this field
  13666. // was not set, or was not defined in the schema.
  13667. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  13668. switch name {
  13669. case employee.FieldHireCount:
  13670. return m.AddedHireCount()
  13671. case employee.FieldServiceCount:
  13672. return m.AddedServiceCount()
  13673. case employee.FieldAchievementCount:
  13674. return m.AddedAchievementCount()
  13675. case employee.FieldOrganizationID:
  13676. return m.AddedOrganizationID()
  13677. case employee.FieldCategoryID:
  13678. return m.AddedCategoryID()
  13679. case employee.FieldIsVip:
  13680. return m.AddedIsVip()
  13681. }
  13682. return nil, false
  13683. }
  13684. // AddField adds the value to the field with the given name. It returns an error if
  13685. // the field is not defined in the schema, or if the type mismatched the field
  13686. // type.
  13687. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  13688. switch name {
  13689. case employee.FieldHireCount:
  13690. v, ok := value.(int)
  13691. if !ok {
  13692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13693. }
  13694. m.AddHireCount(v)
  13695. return nil
  13696. case employee.FieldServiceCount:
  13697. v, ok := value.(int)
  13698. if !ok {
  13699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13700. }
  13701. m.AddServiceCount(v)
  13702. return nil
  13703. case employee.FieldAchievementCount:
  13704. v, ok := value.(int)
  13705. if !ok {
  13706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13707. }
  13708. m.AddAchievementCount(v)
  13709. return nil
  13710. case employee.FieldOrganizationID:
  13711. v, ok := value.(int64)
  13712. if !ok {
  13713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13714. }
  13715. m.AddOrganizationID(v)
  13716. return nil
  13717. case employee.FieldCategoryID:
  13718. v, ok := value.(int64)
  13719. if !ok {
  13720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13721. }
  13722. m.AddCategoryID(v)
  13723. return nil
  13724. case employee.FieldIsVip:
  13725. v, ok := value.(int)
  13726. if !ok {
  13727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13728. }
  13729. m.AddIsVip(v)
  13730. return nil
  13731. }
  13732. return fmt.Errorf("unknown Employee numeric field %s", name)
  13733. }
  13734. // ClearedFields returns all nullable fields that were cleared during this
  13735. // mutation.
  13736. func (m *EmployeeMutation) ClearedFields() []string {
  13737. var fields []string
  13738. if m.FieldCleared(employee.FieldDeletedAt) {
  13739. fields = append(fields, employee.FieldDeletedAt)
  13740. }
  13741. if m.FieldCleared(employee.FieldAiInfo) {
  13742. fields = append(fields, employee.FieldAiInfo)
  13743. }
  13744. return fields
  13745. }
  13746. // FieldCleared returns a boolean indicating if a field with the given name was
  13747. // cleared in this mutation.
  13748. func (m *EmployeeMutation) FieldCleared(name string) bool {
  13749. _, ok := m.clearedFields[name]
  13750. return ok
  13751. }
  13752. // ClearField clears the value of the field with the given name. It returns an
  13753. // error if the field is not defined in the schema.
  13754. func (m *EmployeeMutation) ClearField(name string) error {
  13755. switch name {
  13756. case employee.FieldDeletedAt:
  13757. m.ClearDeletedAt()
  13758. return nil
  13759. case employee.FieldAiInfo:
  13760. m.ClearAiInfo()
  13761. return nil
  13762. }
  13763. return fmt.Errorf("unknown Employee nullable field %s", name)
  13764. }
  13765. // ResetField resets all changes in the mutation for the field with the given name.
  13766. // It returns an error if the field is not defined in the schema.
  13767. func (m *EmployeeMutation) ResetField(name string) error {
  13768. switch name {
  13769. case employee.FieldCreatedAt:
  13770. m.ResetCreatedAt()
  13771. return nil
  13772. case employee.FieldUpdatedAt:
  13773. m.ResetUpdatedAt()
  13774. return nil
  13775. case employee.FieldDeletedAt:
  13776. m.ResetDeletedAt()
  13777. return nil
  13778. case employee.FieldTitle:
  13779. m.ResetTitle()
  13780. return nil
  13781. case employee.FieldAvatar:
  13782. m.ResetAvatar()
  13783. return nil
  13784. case employee.FieldTags:
  13785. m.ResetTags()
  13786. return nil
  13787. case employee.FieldHireCount:
  13788. m.ResetHireCount()
  13789. return nil
  13790. case employee.FieldServiceCount:
  13791. m.ResetServiceCount()
  13792. return nil
  13793. case employee.FieldAchievementCount:
  13794. m.ResetAchievementCount()
  13795. return nil
  13796. case employee.FieldIntro:
  13797. m.ResetIntro()
  13798. return nil
  13799. case employee.FieldEstimate:
  13800. m.ResetEstimate()
  13801. return nil
  13802. case employee.FieldSkill:
  13803. m.ResetSkill()
  13804. return nil
  13805. case employee.FieldAbilityType:
  13806. m.ResetAbilityType()
  13807. return nil
  13808. case employee.FieldScene:
  13809. m.ResetScene()
  13810. return nil
  13811. case employee.FieldSwitchIn:
  13812. m.ResetSwitchIn()
  13813. return nil
  13814. case employee.FieldVideoURL:
  13815. m.ResetVideoURL()
  13816. return nil
  13817. case employee.FieldOrganizationID:
  13818. m.ResetOrganizationID()
  13819. return nil
  13820. case employee.FieldCategoryID:
  13821. m.ResetCategoryID()
  13822. return nil
  13823. case employee.FieldAPIBase:
  13824. m.ResetAPIBase()
  13825. return nil
  13826. case employee.FieldAPIKey:
  13827. m.ResetAPIKey()
  13828. return nil
  13829. case employee.FieldAiInfo:
  13830. m.ResetAiInfo()
  13831. return nil
  13832. case employee.FieldIsVip:
  13833. m.ResetIsVip()
  13834. return nil
  13835. case employee.FieldChatURL:
  13836. m.ResetChatURL()
  13837. return nil
  13838. }
  13839. return fmt.Errorf("unknown Employee field %s", name)
  13840. }
  13841. // AddedEdges returns all edge names that were set/added in this mutation.
  13842. func (m *EmployeeMutation) AddedEdges() []string {
  13843. edges := make([]string, 0, 2)
  13844. if m.em_work_experiences != nil {
  13845. edges = append(edges, employee.EdgeEmWorkExperiences)
  13846. }
  13847. if m.em_tutorial != nil {
  13848. edges = append(edges, employee.EdgeEmTutorial)
  13849. }
  13850. return edges
  13851. }
  13852. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13853. // name in this mutation.
  13854. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  13855. switch name {
  13856. case employee.EdgeEmWorkExperiences:
  13857. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  13858. for id := range m.em_work_experiences {
  13859. ids = append(ids, id)
  13860. }
  13861. return ids
  13862. case employee.EdgeEmTutorial:
  13863. ids := make([]ent.Value, 0, len(m.em_tutorial))
  13864. for id := range m.em_tutorial {
  13865. ids = append(ids, id)
  13866. }
  13867. return ids
  13868. }
  13869. return nil
  13870. }
  13871. // RemovedEdges returns all edge names that were removed in this mutation.
  13872. func (m *EmployeeMutation) RemovedEdges() []string {
  13873. edges := make([]string, 0, 2)
  13874. if m.removedem_work_experiences != nil {
  13875. edges = append(edges, employee.EdgeEmWorkExperiences)
  13876. }
  13877. if m.removedem_tutorial != nil {
  13878. edges = append(edges, employee.EdgeEmTutorial)
  13879. }
  13880. return edges
  13881. }
  13882. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13883. // the given name in this mutation.
  13884. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  13885. switch name {
  13886. case employee.EdgeEmWorkExperiences:
  13887. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  13888. for id := range m.removedem_work_experiences {
  13889. ids = append(ids, id)
  13890. }
  13891. return ids
  13892. case employee.EdgeEmTutorial:
  13893. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  13894. for id := range m.removedem_tutorial {
  13895. ids = append(ids, id)
  13896. }
  13897. return ids
  13898. }
  13899. return nil
  13900. }
  13901. // ClearedEdges returns all edge names that were cleared in this mutation.
  13902. func (m *EmployeeMutation) ClearedEdges() []string {
  13903. edges := make([]string, 0, 2)
  13904. if m.clearedem_work_experiences {
  13905. edges = append(edges, employee.EdgeEmWorkExperiences)
  13906. }
  13907. if m.clearedem_tutorial {
  13908. edges = append(edges, employee.EdgeEmTutorial)
  13909. }
  13910. return edges
  13911. }
  13912. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13913. // was cleared in this mutation.
  13914. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  13915. switch name {
  13916. case employee.EdgeEmWorkExperiences:
  13917. return m.clearedem_work_experiences
  13918. case employee.EdgeEmTutorial:
  13919. return m.clearedem_tutorial
  13920. }
  13921. return false
  13922. }
  13923. // ClearEdge clears the value of the edge with the given name. It returns an error
  13924. // if that edge is not defined in the schema.
  13925. func (m *EmployeeMutation) ClearEdge(name string) error {
  13926. switch name {
  13927. }
  13928. return fmt.Errorf("unknown Employee unique edge %s", name)
  13929. }
  13930. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13931. // It returns an error if the edge is not defined in the schema.
  13932. func (m *EmployeeMutation) ResetEdge(name string) error {
  13933. switch name {
  13934. case employee.EdgeEmWorkExperiences:
  13935. m.ResetEmWorkExperiences()
  13936. return nil
  13937. case employee.EdgeEmTutorial:
  13938. m.ResetEmTutorial()
  13939. return nil
  13940. }
  13941. return fmt.Errorf("unknown Employee edge %s", name)
  13942. }
  13943. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  13944. type EmployeeConfigMutation struct {
  13945. config
  13946. op Op
  13947. typ string
  13948. id *uint64
  13949. created_at *time.Time
  13950. updated_at *time.Time
  13951. deleted_at *time.Time
  13952. stype *string
  13953. title *string
  13954. photo *string
  13955. organization_id *uint64
  13956. addorganization_id *int64
  13957. clearedFields map[string]struct{}
  13958. done bool
  13959. oldValue func(context.Context) (*EmployeeConfig, error)
  13960. predicates []predicate.EmployeeConfig
  13961. }
  13962. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  13963. // employeeconfigOption allows management of the mutation configuration using functional options.
  13964. type employeeconfigOption func(*EmployeeConfigMutation)
  13965. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  13966. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  13967. m := &EmployeeConfigMutation{
  13968. config: c,
  13969. op: op,
  13970. typ: TypeEmployeeConfig,
  13971. clearedFields: make(map[string]struct{}),
  13972. }
  13973. for _, opt := range opts {
  13974. opt(m)
  13975. }
  13976. return m
  13977. }
  13978. // withEmployeeConfigID sets the ID field of the mutation.
  13979. func withEmployeeConfigID(id uint64) employeeconfigOption {
  13980. return func(m *EmployeeConfigMutation) {
  13981. var (
  13982. err error
  13983. once sync.Once
  13984. value *EmployeeConfig
  13985. )
  13986. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  13987. once.Do(func() {
  13988. if m.done {
  13989. err = errors.New("querying old values post mutation is not allowed")
  13990. } else {
  13991. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  13992. }
  13993. })
  13994. return value, err
  13995. }
  13996. m.id = &id
  13997. }
  13998. }
  13999. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  14000. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  14001. return func(m *EmployeeConfigMutation) {
  14002. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  14003. return node, nil
  14004. }
  14005. m.id = &node.ID
  14006. }
  14007. }
  14008. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14009. // executed in a transaction (ent.Tx), a transactional client is returned.
  14010. func (m EmployeeConfigMutation) Client() *Client {
  14011. client := &Client{config: m.config}
  14012. client.init()
  14013. return client
  14014. }
  14015. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14016. // it returns an error otherwise.
  14017. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  14018. if _, ok := m.driver.(*txDriver); !ok {
  14019. return nil, errors.New("ent: mutation is not running in a transaction")
  14020. }
  14021. tx := &Tx{config: m.config}
  14022. tx.init()
  14023. return tx, nil
  14024. }
  14025. // SetID sets the value of the id field. Note that this
  14026. // operation is only accepted on creation of EmployeeConfig entities.
  14027. func (m *EmployeeConfigMutation) SetID(id uint64) {
  14028. m.id = &id
  14029. }
  14030. // ID returns the ID value in the mutation. Note that the ID is only available
  14031. // if it was provided to the builder or after it was returned from the database.
  14032. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  14033. if m.id == nil {
  14034. return
  14035. }
  14036. return *m.id, true
  14037. }
  14038. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14039. // That means, if the mutation is applied within a transaction with an isolation level such
  14040. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14041. // or updated by the mutation.
  14042. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  14043. switch {
  14044. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14045. id, exists := m.ID()
  14046. if exists {
  14047. return []uint64{id}, nil
  14048. }
  14049. fallthrough
  14050. case m.op.Is(OpUpdate | OpDelete):
  14051. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  14052. default:
  14053. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14054. }
  14055. }
  14056. // SetCreatedAt sets the "created_at" field.
  14057. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  14058. m.created_at = &t
  14059. }
  14060. // CreatedAt returns the value of the "created_at" field in the mutation.
  14061. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  14062. v := m.created_at
  14063. if v == nil {
  14064. return
  14065. }
  14066. return *v, true
  14067. }
  14068. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  14069. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14071. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14072. if !m.op.Is(OpUpdateOne) {
  14073. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14074. }
  14075. if m.id == nil || m.oldValue == nil {
  14076. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14077. }
  14078. oldValue, err := m.oldValue(ctx)
  14079. if err != nil {
  14080. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14081. }
  14082. return oldValue.CreatedAt, nil
  14083. }
  14084. // ResetCreatedAt resets all changes to the "created_at" field.
  14085. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  14086. m.created_at = nil
  14087. }
  14088. // SetUpdatedAt sets the "updated_at" field.
  14089. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  14090. m.updated_at = &t
  14091. }
  14092. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14093. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  14094. v := m.updated_at
  14095. if v == nil {
  14096. return
  14097. }
  14098. return *v, true
  14099. }
  14100. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  14101. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14103. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14104. if !m.op.Is(OpUpdateOne) {
  14105. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14106. }
  14107. if m.id == nil || m.oldValue == nil {
  14108. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14109. }
  14110. oldValue, err := m.oldValue(ctx)
  14111. if err != nil {
  14112. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14113. }
  14114. return oldValue.UpdatedAt, nil
  14115. }
  14116. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14117. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  14118. m.updated_at = nil
  14119. }
  14120. // SetDeletedAt sets the "deleted_at" field.
  14121. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  14122. m.deleted_at = &t
  14123. }
  14124. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14125. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  14126. v := m.deleted_at
  14127. if v == nil {
  14128. return
  14129. }
  14130. return *v, true
  14131. }
  14132. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  14133. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14135. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14136. if !m.op.Is(OpUpdateOne) {
  14137. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14138. }
  14139. if m.id == nil || m.oldValue == nil {
  14140. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14141. }
  14142. oldValue, err := m.oldValue(ctx)
  14143. if err != nil {
  14144. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14145. }
  14146. return oldValue.DeletedAt, nil
  14147. }
  14148. // ClearDeletedAt clears the value of the "deleted_at" field.
  14149. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  14150. m.deleted_at = nil
  14151. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  14152. }
  14153. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14154. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  14155. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  14156. return ok
  14157. }
  14158. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14159. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  14160. m.deleted_at = nil
  14161. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  14162. }
  14163. // SetStype sets the "stype" field.
  14164. func (m *EmployeeConfigMutation) SetStype(s string) {
  14165. m.stype = &s
  14166. }
  14167. // Stype returns the value of the "stype" field in the mutation.
  14168. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  14169. v := m.stype
  14170. if v == nil {
  14171. return
  14172. }
  14173. return *v, true
  14174. }
  14175. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  14176. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14178. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  14179. if !m.op.Is(OpUpdateOne) {
  14180. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  14181. }
  14182. if m.id == nil || m.oldValue == nil {
  14183. return v, errors.New("OldStype requires an ID field in the mutation")
  14184. }
  14185. oldValue, err := m.oldValue(ctx)
  14186. if err != nil {
  14187. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  14188. }
  14189. return oldValue.Stype, nil
  14190. }
  14191. // ResetStype resets all changes to the "stype" field.
  14192. func (m *EmployeeConfigMutation) ResetStype() {
  14193. m.stype = nil
  14194. }
  14195. // SetTitle sets the "title" field.
  14196. func (m *EmployeeConfigMutation) SetTitle(s string) {
  14197. m.title = &s
  14198. }
  14199. // Title returns the value of the "title" field in the mutation.
  14200. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  14201. v := m.title
  14202. if v == nil {
  14203. return
  14204. }
  14205. return *v, true
  14206. }
  14207. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  14208. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14210. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  14211. if !m.op.Is(OpUpdateOne) {
  14212. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  14213. }
  14214. if m.id == nil || m.oldValue == nil {
  14215. return v, errors.New("OldTitle requires an ID field in the mutation")
  14216. }
  14217. oldValue, err := m.oldValue(ctx)
  14218. if err != nil {
  14219. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  14220. }
  14221. return oldValue.Title, nil
  14222. }
  14223. // ResetTitle resets all changes to the "title" field.
  14224. func (m *EmployeeConfigMutation) ResetTitle() {
  14225. m.title = nil
  14226. }
  14227. // SetPhoto sets the "photo" field.
  14228. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  14229. m.photo = &s
  14230. }
  14231. // Photo returns the value of the "photo" field in the mutation.
  14232. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  14233. v := m.photo
  14234. if v == nil {
  14235. return
  14236. }
  14237. return *v, true
  14238. }
  14239. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  14240. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14242. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  14243. if !m.op.Is(OpUpdateOne) {
  14244. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  14245. }
  14246. if m.id == nil || m.oldValue == nil {
  14247. return v, errors.New("OldPhoto requires an ID field in the mutation")
  14248. }
  14249. oldValue, err := m.oldValue(ctx)
  14250. if err != nil {
  14251. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  14252. }
  14253. return oldValue.Photo, nil
  14254. }
  14255. // ResetPhoto resets all changes to the "photo" field.
  14256. func (m *EmployeeConfigMutation) ResetPhoto() {
  14257. m.photo = nil
  14258. }
  14259. // SetOrganizationID sets the "organization_id" field.
  14260. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  14261. m.organization_id = &u
  14262. m.addorganization_id = nil
  14263. }
  14264. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14265. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  14266. v := m.organization_id
  14267. if v == nil {
  14268. return
  14269. }
  14270. return *v, true
  14271. }
  14272. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  14273. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  14274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14275. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14276. if !m.op.Is(OpUpdateOne) {
  14277. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14278. }
  14279. if m.id == nil || m.oldValue == nil {
  14280. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14281. }
  14282. oldValue, err := m.oldValue(ctx)
  14283. if err != nil {
  14284. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14285. }
  14286. return oldValue.OrganizationID, nil
  14287. }
  14288. // AddOrganizationID adds u to the "organization_id" field.
  14289. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  14290. if m.addorganization_id != nil {
  14291. *m.addorganization_id += u
  14292. } else {
  14293. m.addorganization_id = &u
  14294. }
  14295. }
  14296. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14297. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  14298. v := m.addorganization_id
  14299. if v == nil {
  14300. return
  14301. }
  14302. return *v, true
  14303. }
  14304. // ClearOrganizationID clears the value of the "organization_id" field.
  14305. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  14306. m.organization_id = nil
  14307. m.addorganization_id = nil
  14308. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  14309. }
  14310. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14311. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  14312. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  14313. return ok
  14314. }
  14315. // ResetOrganizationID resets all changes to the "organization_id" field.
  14316. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  14317. m.organization_id = nil
  14318. m.addorganization_id = nil
  14319. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  14320. }
  14321. // Where appends a list predicates to the EmployeeConfigMutation builder.
  14322. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  14323. m.predicates = append(m.predicates, ps...)
  14324. }
  14325. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  14326. // users can use type-assertion to append predicates that do not depend on any generated package.
  14327. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  14328. p := make([]predicate.EmployeeConfig, len(ps))
  14329. for i := range ps {
  14330. p[i] = ps[i]
  14331. }
  14332. m.Where(p...)
  14333. }
  14334. // Op returns the operation name.
  14335. func (m *EmployeeConfigMutation) Op() Op {
  14336. return m.op
  14337. }
  14338. // SetOp allows setting the mutation operation.
  14339. func (m *EmployeeConfigMutation) SetOp(op Op) {
  14340. m.op = op
  14341. }
  14342. // Type returns the node type of this mutation (EmployeeConfig).
  14343. func (m *EmployeeConfigMutation) Type() string {
  14344. return m.typ
  14345. }
  14346. // Fields returns all fields that were changed during this mutation. Note that in
  14347. // order to get all numeric fields that were incremented/decremented, call
  14348. // AddedFields().
  14349. func (m *EmployeeConfigMutation) Fields() []string {
  14350. fields := make([]string, 0, 7)
  14351. if m.created_at != nil {
  14352. fields = append(fields, employeeconfig.FieldCreatedAt)
  14353. }
  14354. if m.updated_at != nil {
  14355. fields = append(fields, employeeconfig.FieldUpdatedAt)
  14356. }
  14357. if m.deleted_at != nil {
  14358. fields = append(fields, employeeconfig.FieldDeletedAt)
  14359. }
  14360. if m.stype != nil {
  14361. fields = append(fields, employeeconfig.FieldStype)
  14362. }
  14363. if m.title != nil {
  14364. fields = append(fields, employeeconfig.FieldTitle)
  14365. }
  14366. if m.photo != nil {
  14367. fields = append(fields, employeeconfig.FieldPhoto)
  14368. }
  14369. if m.organization_id != nil {
  14370. fields = append(fields, employeeconfig.FieldOrganizationID)
  14371. }
  14372. return fields
  14373. }
  14374. // Field returns the value of a field with the given name. The second boolean
  14375. // return value indicates that this field was not set, or was not defined in the
  14376. // schema.
  14377. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  14378. switch name {
  14379. case employeeconfig.FieldCreatedAt:
  14380. return m.CreatedAt()
  14381. case employeeconfig.FieldUpdatedAt:
  14382. return m.UpdatedAt()
  14383. case employeeconfig.FieldDeletedAt:
  14384. return m.DeletedAt()
  14385. case employeeconfig.FieldStype:
  14386. return m.Stype()
  14387. case employeeconfig.FieldTitle:
  14388. return m.Title()
  14389. case employeeconfig.FieldPhoto:
  14390. return m.Photo()
  14391. case employeeconfig.FieldOrganizationID:
  14392. return m.OrganizationID()
  14393. }
  14394. return nil, false
  14395. }
  14396. // OldField returns the old value of the field from the database. An error is
  14397. // returned if the mutation operation is not UpdateOne, or the query to the
  14398. // database failed.
  14399. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14400. switch name {
  14401. case employeeconfig.FieldCreatedAt:
  14402. return m.OldCreatedAt(ctx)
  14403. case employeeconfig.FieldUpdatedAt:
  14404. return m.OldUpdatedAt(ctx)
  14405. case employeeconfig.FieldDeletedAt:
  14406. return m.OldDeletedAt(ctx)
  14407. case employeeconfig.FieldStype:
  14408. return m.OldStype(ctx)
  14409. case employeeconfig.FieldTitle:
  14410. return m.OldTitle(ctx)
  14411. case employeeconfig.FieldPhoto:
  14412. return m.OldPhoto(ctx)
  14413. case employeeconfig.FieldOrganizationID:
  14414. return m.OldOrganizationID(ctx)
  14415. }
  14416. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  14417. }
  14418. // SetField sets the value of a field with the given name. It returns an error if
  14419. // the field is not defined in the schema, or if the type mismatched the field
  14420. // type.
  14421. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  14422. switch name {
  14423. case employeeconfig.FieldCreatedAt:
  14424. v, ok := value.(time.Time)
  14425. if !ok {
  14426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14427. }
  14428. m.SetCreatedAt(v)
  14429. return nil
  14430. case employeeconfig.FieldUpdatedAt:
  14431. v, ok := value.(time.Time)
  14432. if !ok {
  14433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14434. }
  14435. m.SetUpdatedAt(v)
  14436. return nil
  14437. case employeeconfig.FieldDeletedAt:
  14438. v, ok := value.(time.Time)
  14439. if !ok {
  14440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14441. }
  14442. m.SetDeletedAt(v)
  14443. return nil
  14444. case employeeconfig.FieldStype:
  14445. v, ok := value.(string)
  14446. if !ok {
  14447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14448. }
  14449. m.SetStype(v)
  14450. return nil
  14451. case employeeconfig.FieldTitle:
  14452. v, ok := value.(string)
  14453. if !ok {
  14454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14455. }
  14456. m.SetTitle(v)
  14457. return nil
  14458. case employeeconfig.FieldPhoto:
  14459. v, ok := value.(string)
  14460. if !ok {
  14461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14462. }
  14463. m.SetPhoto(v)
  14464. return nil
  14465. case employeeconfig.FieldOrganizationID:
  14466. v, ok := value.(uint64)
  14467. if !ok {
  14468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14469. }
  14470. m.SetOrganizationID(v)
  14471. return nil
  14472. }
  14473. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  14474. }
  14475. // AddedFields returns all numeric fields that were incremented/decremented during
  14476. // this mutation.
  14477. func (m *EmployeeConfigMutation) AddedFields() []string {
  14478. var fields []string
  14479. if m.addorganization_id != nil {
  14480. fields = append(fields, employeeconfig.FieldOrganizationID)
  14481. }
  14482. return fields
  14483. }
  14484. // AddedField returns the numeric value that was incremented/decremented on a field
  14485. // with the given name. The second boolean return value indicates that this field
  14486. // was not set, or was not defined in the schema.
  14487. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  14488. switch name {
  14489. case employeeconfig.FieldOrganizationID:
  14490. return m.AddedOrganizationID()
  14491. }
  14492. return nil, false
  14493. }
  14494. // AddField adds the value to the field with the given name. It returns an error if
  14495. // the field is not defined in the schema, or if the type mismatched the field
  14496. // type.
  14497. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  14498. switch name {
  14499. case employeeconfig.FieldOrganizationID:
  14500. v, ok := value.(int64)
  14501. if !ok {
  14502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14503. }
  14504. m.AddOrganizationID(v)
  14505. return nil
  14506. }
  14507. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  14508. }
  14509. // ClearedFields returns all nullable fields that were cleared during this
  14510. // mutation.
  14511. func (m *EmployeeConfigMutation) ClearedFields() []string {
  14512. var fields []string
  14513. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  14514. fields = append(fields, employeeconfig.FieldDeletedAt)
  14515. }
  14516. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  14517. fields = append(fields, employeeconfig.FieldOrganizationID)
  14518. }
  14519. return fields
  14520. }
  14521. // FieldCleared returns a boolean indicating if a field with the given name was
  14522. // cleared in this mutation.
  14523. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  14524. _, ok := m.clearedFields[name]
  14525. return ok
  14526. }
  14527. // ClearField clears the value of the field with the given name. It returns an
  14528. // error if the field is not defined in the schema.
  14529. func (m *EmployeeConfigMutation) ClearField(name string) error {
  14530. switch name {
  14531. case employeeconfig.FieldDeletedAt:
  14532. m.ClearDeletedAt()
  14533. return nil
  14534. case employeeconfig.FieldOrganizationID:
  14535. m.ClearOrganizationID()
  14536. return nil
  14537. }
  14538. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  14539. }
  14540. // ResetField resets all changes in the mutation for the field with the given name.
  14541. // It returns an error if the field is not defined in the schema.
  14542. func (m *EmployeeConfigMutation) ResetField(name string) error {
  14543. switch name {
  14544. case employeeconfig.FieldCreatedAt:
  14545. m.ResetCreatedAt()
  14546. return nil
  14547. case employeeconfig.FieldUpdatedAt:
  14548. m.ResetUpdatedAt()
  14549. return nil
  14550. case employeeconfig.FieldDeletedAt:
  14551. m.ResetDeletedAt()
  14552. return nil
  14553. case employeeconfig.FieldStype:
  14554. m.ResetStype()
  14555. return nil
  14556. case employeeconfig.FieldTitle:
  14557. m.ResetTitle()
  14558. return nil
  14559. case employeeconfig.FieldPhoto:
  14560. m.ResetPhoto()
  14561. return nil
  14562. case employeeconfig.FieldOrganizationID:
  14563. m.ResetOrganizationID()
  14564. return nil
  14565. }
  14566. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  14567. }
  14568. // AddedEdges returns all edge names that were set/added in this mutation.
  14569. func (m *EmployeeConfigMutation) AddedEdges() []string {
  14570. edges := make([]string, 0, 0)
  14571. return edges
  14572. }
  14573. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14574. // name in this mutation.
  14575. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  14576. return nil
  14577. }
  14578. // RemovedEdges returns all edge names that were removed in this mutation.
  14579. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  14580. edges := make([]string, 0, 0)
  14581. return edges
  14582. }
  14583. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14584. // the given name in this mutation.
  14585. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  14586. return nil
  14587. }
  14588. // ClearedEdges returns all edge names that were cleared in this mutation.
  14589. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  14590. edges := make([]string, 0, 0)
  14591. return edges
  14592. }
  14593. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14594. // was cleared in this mutation.
  14595. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  14596. return false
  14597. }
  14598. // ClearEdge clears the value of the edge with the given name. It returns an error
  14599. // if that edge is not defined in the schema.
  14600. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  14601. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  14602. }
  14603. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14604. // It returns an error if the edge is not defined in the schema.
  14605. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  14606. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  14607. }
  14608. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  14609. type LabelMutation struct {
  14610. config
  14611. op Op
  14612. typ string
  14613. id *uint64
  14614. created_at *time.Time
  14615. updated_at *time.Time
  14616. status *uint8
  14617. addstatus *int8
  14618. _type *int
  14619. add_type *int
  14620. name *string
  14621. from *int
  14622. addfrom *int
  14623. mode *int
  14624. addmode *int
  14625. conditions *string
  14626. organization_id *uint64
  14627. addorganization_id *int64
  14628. clearedFields map[string]struct{}
  14629. label_relationships map[uint64]struct{}
  14630. removedlabel_relationships map[uint64]struct{}
  14631. clearedlabel_relationships bool
  14632. done bool
  14633. oldValue func(context.Context) (*Label, error)
  14634. predicates []predicate.Label
  14635. }
  14636. var _ ent.Mutation = (*LabelMutation)(nil)
  14637. // labelOption allows management of the mutation configuration using functional options.
  14638. type labelOption func(*LabelMutation)
  14639. // newLabelMutation creates new mutation for the Label entity.
  14640. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  14641. m := &LabelMutation{
  14642. config: c,
  14643. op: op,
  14644. typ: TypeLabel,
  14645. clearedFields: make(map[string]struct{}),
  14646. }
  14647. for _, opt := range opts {
  14648. opt(m)
  14649. }
  14650. return m
  14651. }
  14652. // withLabelID sets the ID field of the mutation.
  14653. func withLabelID(id uint64) labelOption {
  14654. return func(m *LabelMutation) {
  14655. var (
  14656. err error
  14657. once sync.Once
  14658. value *Label
  14659. )
  14660. m.oldValue = func(ctx context.Context) (*Label, error) {
  14661. once.Do(func() {
  14662. if m.done {
  14663. err = errors.New("querying old values post mutation is not allowed")
  14664. } else {
  14665. value, err = m.Client().Label.Get(ctx, id)
  14666. }
  14667. })
  14668. return value, err
  14669. }
  14670. m.id = &id
  14671. }
  14672. }
  14673. // withLabel sets the old Label of the mutation.
  14674. func withLabel(node *Label) labelOption {
  14675. return func(m *LabelMutation) {
  14676. m.oldValue = func(context.Context) (*Label, error) {
  14677. return node, nil
  14678. }
  14679. m.id = &node.ID
  14680. }
  14681. }
  14682. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14683. // executed in a transaction (ent.Tx), a transactional client is returned.
  14684. func (m LabelMutation) Client() *Client {
  14685. client := &Client{config: m.config}
  14686. client.init()
  14687. return client
  14688. }
  14689. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14690. // it returns an error otherwise.
  14691. func (m LabelMutation) Tx() (*Tx, error) {
  14692. if _, ok := m.driver.(*txDriver); !ok {
  14693. return nil, errors.New("ent: mutation is not running in a transaction")
  14694. }
  14695. tx := &Tx{config: m.config}
  14696. tx.init()
  14697. return tx, nil
  14698. }
  14699. // SetID sets the value of the id field. Note that this
  14700. // operation is only accepted on creation of Label entities.
  14701. func (m *LabelMutation) SetID(id uint64) {
  14702. m.id = &id
  14703. }
  14704. // ID returns the ID value in the mutation. Note that the ID is only available
  14705. // if it was provided to the builder or after it was returned from the database.
  14706. func (m *LabelMutation) ID() (id uint64, exists bool) {
  14707. if m.id == nil {
  14708. return
  14709. }
  14710. return *m.id, true
  14711. }
  14712. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14713. // That means, if the mutation is applied within a transaction with an isolation level such
  14714. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14715. // or updated by the mutation.
  14716. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  14717. switch {
  14718. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14719. id, exists := m.ID()
  14720. if exists {
  14721. return []uint64{id}, nil
  14722. }
  14723. fallthrough
  14724. case m.op.Is(OpUpdate | OpDelete):
  14725. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  14726. default:
  14727. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14728. }
  14729. }
  14730. // SetCreatedAt sets the "created_at" field.
  14731. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  14732. m.created_at = &t
  14733. }
  14734. // CreatedAt returns the value of the "created_at" field in the mutation.
  14735. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  14736. v := m.created_at
  14737. if v == nil {
  14738. return
  14739. }
  14740. return *v, true
  14741. }
  14742. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  14743. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14745. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14746. if !m.op.Is(OpUpdateOne) {
  14747. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14748. }
  14749. if m.id == nil || m.oldValue == nil {
  14750. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14751. }
  14752. oldValue, err := m.oldValue(ctx)
  14753. if err != nil {
  14754. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14755. }
  14756. return oldValue.CreatedAt, nil
  14757. }
  14758. // ResetCreatedAt resets all changes to the "created_at" field.
  14759. func (m *LabelMutation) ResetCreatedAt() {
  14760. m.created_at = nil
  14761. }
  14762. // SetUpdatedAt sets the "updated_at" field.
  14763. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  14764. m.updated_at = &t
  14765. }
  14766. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14767. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  14768. v := m.updated_at
  14769. if v == nil {
  14770. return
  14771. }
  14772. return *v, true
  14773. }
  14774. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  14775. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14777. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14778. if !m.op.Is(OpUpdateOne) {
  14779. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14780. }
  14781. if m.id == nil || m.oldValue == nil {
  14782. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14783. }
  14784. oldValue, err := m.oldValue(ctx)
  14785. if err != nil {
  14786. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14787. }
  14788. return oldValue.UpdatedAt, nil
  14789. }
  14790. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14791. func (m *LabelMutation) ResetUpdatedAt() {
  14792. m.updated_at = nil
  14793. }
  14794. // SetStatus sets the "status" field.
  14795. func (m *LabelMutation) SetStatus(u uint8) {
  14796. m.status = &u
  14797. m.addstatus = nil
  14798. }
  14799. // Status returns the value of the "status" field in the mutation.
  14800. func (m *LabelMutation) Status() (r uint8, exists bool) {
  14801. v := m.status
  14802. if v == nil {
  14803. return
  14804. }
  14805. return *v, true
  14806. }
  14807. // OldStatus returns the old "status" field's value of the Label entity.
  14808. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14810. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14811. if !m.op.Is(OpUpdateOne) {
  14812. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14813. }
  14814. if m.id == nil || m.oldValue == nil {
  14815. return v, errors.New("OldStatus requires an ID field in the mutation")
  14816. }
  14817. oldValue, err := m.oldValue(ctx)
  14818. if err != nil {
  14819. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14820. }
  14821. return oldValue.Status, nil
  14822. }
  14823. // AddStatus adds u to the "status" field.
  14824. func (m *LabelMutation) AddStatus(u int8) {
  14825. if m.addstatus != nil {
  14826. *m.addstatus += u
  14827. } else {
  14828. m.addstatus = &u
  14829. }
  14830. }
  14831. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14832. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  14833. v := m.addstatus
  14834. if v == nil {
  14835. return
  14836. }
  14837. return *v, true
  14838. }
  14839. // ClearStatus clears the value of the "status" field.
  14840. func (m *LabelMutation) ClearStatus() {
  14841. m.status = nil
  14842. m.addstatus = nil
  14843. m.clearedFields[label.FieldStatus] = struct{}{}
  14844. }
  14845. // StatusCleared returns if the "status" field was cleared in this mutation.
  14846. func (m *LabelMutation) StatusCleared() bool {
  14847. _, ok := m.clearedFields[label.FieldStatus]
  14848. return ok
  14849. }
  14850. // ResetStatus resets all changes to the "status" field.
  14851. func (m *LabelMutation) ResetStatus() {
  14852. m.status = nil
  14853. m.addstatus = nil
  14854. delete(m.clearedFields, label.FieldStatus)
  14855. }
  14856. // SetType sets the "type" field.
  14857. func (m *LabelMutation) SetType(i int) {
  14858. m._type = &i
  14859. m.add_type = nil
  14860. }
  14861. // GetType returns the value of the "type" field in the mutation.
  14862. func (m *LabelMutation) GetType() (r int, exists bool) {
  14863. v := m._type
  14864. if v == nil {
  14865. return
  14866. }
  14867. return *v, true
  14868. }
  14869. // OldType returns the old "type" field's value of the Label entity.
  14870. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14872. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  14873. if !m.op.Is(OpUpdateOne) {
  14874. return v, errors.New("OldType is only allowed on UpdateOne operations")
  14875. }
  14876. if m.id == nil || m.oldValue == nil {
  14877. return v, errors.New("OldType requires an ID field in the mutation")
  14878. }
  14879. oldValue, err := m.oldValue(ctx)
  14880. if err != nil {
  14881. return v, fmt.Errorf("querying old value for OldType: %w", err)
  14882. }
  14883. return oldValue.Type, nil
  14884. }
  14885. // AddType adds i to the "type" field.
  14886. func (m *LabelMutation) AddType(i int) {
  14887. if m.add_type != nil {
  14888. *m.add_type += i
  14889. } else {
  14890. m.add_type = &i
  14891. }
  14892. }
  14893. // AddedType returns the value that was added to the "type" field in this mutation.
  14894. func (m *LabelMutation) AddedType() (r int, exists bool) {
  14895. v := m.add_type
  14896. if v == nil {
  14897. return
  14898. }
  14899. return *v, true
  14900. }
  14901. // ResetType resets all changes to the "type" field.
  14902. func (m *LabelMutation) ResetType() {
  14903. m._type = nil
  14904. m.add_type = nil
  14905. }
  14906. // SetName sets the "name" field.
  14907. func (m *LabelMutation) SetName(s string) {
  14908. m.name = &s
  14909. }
  14910. // Name returns the value of the "name" field in the mutation.
  14911. func (m *LabelMutation) Name() (r string, exists bool) {
  14912. v := m.name
  14913. if v == nil {
  14914. return
  14915. }
  14916. return *v, true
  14917. }
  14918. // OldName returns the old "name" field's value of the Label entity.
  14919. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14921. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  14922. if !m.op.Is(OpUpdateOne) {
  14923. return v, errors.New("OldName is only allowed on UpdateOne operations")
  14924. }
  14925. if m.id == nil || m.oldValue == nil {
  14926. return v, errors.New("OldName requires an ID field in the mutation")
  14927. }
  14928. oldValue, err := m.oldValue(ctx)
  14929. if err != nil {
  14930. return v, fmt.Errorf("querying old value for OldName: %w", err)
  14931. }
  14932. return oldValue.Name, nil
  14933. }
  14934. // ResetName resets all changes to the "name" field.
  14935. func (m *LabelMutation) ResetName() {
  14936. m.name = nil
  14937. }
  14938. // SetFrom sets the "from" field.
  14939. func (m *LabelMutation) SetFrom(i int) {
  14940. m.from = &i
  14941. m.addfrom = nil
  14942. }
  14943. // From returns the value of the "from" field in the mutation.
  14944. func (m *LabelMutation) From() (r int, exists bool) {
  14945. v := m.from
  14946. if v == nil {
  14947. return
  14948. }
  14949. return *v, true
  14950. }
  14951. // OldFrom returns the old "from" field's value of the Label entity.
  14952. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14954. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  14955. if !m.op.Is(OpUpdateOne) {
  14956. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  14957. }
  14958. if m.id == nil || m.oldValue == nil {
  14959. return v, errors.New("OldFrom requires an ID field in the mutation")
  14960. }
  14961. oldValue, err := m.oldValue(ctx)
  14962. if err != nil {
  14963. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  14964. }
  14965. return oldValue.From, nil
  14966. }
  14967. // AddFrom adds i to the "from" field.
  14968. func (m *LabelMutation) AddFrom(i int) {
  14969. if m.addfrom != nil {
  14970. *m.addfrom += i
  14971. } else {
  14972. m.addfrom = &i
  14973. }
  14974. }
  14975. // AddedFrom returns the value that was added to the "from" field in this mutation.
  14976. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  14977. v := m.addfrom
  14978. if v == nil {
  14979. return
  14980. }
  14981. return *v, true
  14982. }
  14983. // ResetFrom resets all changes to the "from" field.
  14984. func (m *LabelMutation) ResetFrom() {
  14985. m.from = nil
  14986. m.addfrom = nil
  14987. }
  14988. // SetMode sets the "mode" field.
  14989. func (m *LabelMutation) SetMode(i int) {
  14990. m.mode = &i
  14991. m.addmode = nil
  14992. }
  14993. // Mode returns the value of the "mode" field in the mutation.
  14994. func (m *LabelMutation) Mode() (r int, exists bool) {
  14995. v := m.mode
  14996. if v == nil {
  14997. return
  14998. }
  14999. return *v, true
  15000. }
  15001. // OldMode returns the old "mode" field's value of the Label entity.
  15002. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15004. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  15005. if !m.op.Is(OpUpdateOne) {
  15006. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  15007. }
  15008. if m.id == nil || m.oldValue == nil {
  15009. return v, errors.New("OldMode requires an ID field in the mutation")
  15010. }
  15011. oldValue, err := m.oldValue(ctx)
  15012. if err != nil {
  15013. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  15014. }
  15015. return oldValue.Mode, nil
  15016. }
  15017. // AddMode adds i to the "mode" field.
  15018. func (m *LabelMutation) AddMode(i int) {
  15019. if m.addmode != nil {
  15020. *m.addmode += i
  15021. } else {
  15022. m.addmode = &i
  15023. }
  15024. }
  15025. // AddedMode returns the value that was added to the "mode" field in this mutation.
  15026. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  15027. v := m.addmode
  15028. if v == nil {
  15029. return
  15030. }
  15031. return *v, true
  15032. }
  15033. // ResetMode resets all changes to the "mode" field.
  15034. func (m *LabelMutation) ResetMode() {
  15035. m.mode = nil
  15036. m.addmode = nil
  15037. }
  15038. // SetConditions sets the "conditions" field.
  15039. func (m *LabelMutation) SetConditions(s string) {
  15040. m.conditions = &s
  15041. }
  15042. // Conditions returns the value of the "conditions" field in the mutation.
  15043. func (m *LabelMutation) Conditions() (r string, exists bool) {
  15044. v := m.conditions
  15045. if v == nil {
  15046. return
  15047. }
  15048. return *v, true
  15049. }
  15050. // OldConditions returns the old "conditions" field's value of the Label entity.
  15051. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15053. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  15054. if !m.op.Is(OpUpdateOne) {
  15055. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15056. }
  15057. if m.id == nil || m.oldValue == nil {
  15058. return v, errors.New("OldConditions requires an ID field in the mutation")
  15059. }
  15060. oldValue, err := m.oldValue(ctx)
  15061. if err != nil {
  15062. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15063. }
  15064. return oldValue.Conditions, nil
  15065. }
  15066. // ClearConditions clears the value of the "conditions" field.
  15067. func (m *LabelMutation) ClearConditions() {
  15068. m.conditions = nil
  15069. m.clearedFields[label.FieldConditions] = struct{}{}
  15070. }
  15071. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  15072. func (m *LabelMutation) ConditionsCleared() bool {
  15073. _, ok := m.clearedFields[label.FieldConditions]
  15074. return ok
  15075. }
  15076. // ResetConditions resets all changes to the "conditions" field.
  15077. func (m *LabelMutation) ResetConditions() {
  15078. m.conditions = nil
  15079. delete(m.clearedFields, label.FieldConditions)
  15080. }
  15081. // SetOrganizationID sets the "organization_id" field.
  15082. func (m *LabelMutation) SetOrganizationID(u uint64) {
  15083. m.organization_id = &u
  15084. m.addorganization_id = nil
  15085. }
  15086. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15087. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  15088. v := m.organization_id
  15089. if v == nil {
  15090. return
  15091. }
  15092. return *v, true
  15093. }
  15094. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  15095. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  15096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15097. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15098. if !m.op.Is(OpUpdateOne) {
  15099. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15100. }
  15101. if m.id == nil || m.oldValue == nil {
  15102. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15103. }
  15104. oldValue, err := m.oldValue(ctx)
  15105. if err != nil {
  15106. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15107. }
  15108. return oldValue.OrganizationID, nil
  15109. }
  15110. // AddOrganizationID adds u to the "organization_id" field.
  15111. func (m *LabelMutation) AddOrganizationID(u int64) {
  15112. if m.addorganization_id != nil {
  15113. *m.addorganization_id += u
  15114. } else {
  15115. m.addorganization_id = &u
  15116. }
  15117. }
  15118. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15119. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  15120. v := m.addorganization_id
  15121. if v == nil {
  15122. return
  15123. }
  15124. return *v, true
  15125. }
  15126. // ClearOrganizationID clears the value of the "organization_id" field.
  15127. func (m *LabelMutation) ClearOrganizationID() {
  15128. m.organization_id = nil
  15129. m.addorganization_id = nil
  15130. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  15131. }
  15132. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15133. func (m *LabelMutation) OrganizationIDCleared() bool {
  15134. _, ok := m.clearedFields[label.FieldOrganizationID]
  15135. return ok
  15136. }
  15137. // ResetOrganizationID resets all changes to the "organization_id" field.
  15138. func (m *LabelMutation) ResetOrganizationID() {
  15139. m.organization_id = nil
  15140. m.addorganization_id = nil
  15141. delete(m.clearedFields, label.FieldOrganizationID)
  15142. }
  15143. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  15144. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  15145. if m.label_relationships == nil {
  15146. m.label_relationships = make(map[uint64]struct{})
  15147. }
  15148. for i := range ids {
  15149. m.label_relationships[ids[i]] = struct{}{}
  15150. }
  15151. }
  15152. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  15153. func (m *LabelMutation) ClearLabelRelationships() {
  15154. m.clearedlabel_relationships = true
  15155. }
  15156. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  15157. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  15158. return m.clearedlabel_relationships
  15159. }
  15160. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  15161. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  15162. if m.removedlabel_relationships == nil {
  15163. m.removedlabel_relationships = make(map[uint64]struct{})
  15164. }
  15165. for i := range ids {
  15166. delete(m.label_relationships, ids[i])
  15167. m.removedlabel_relationships[ids[i]] = struct{}{}
  15168. }
  15169. }
  15170. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  15171. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  15172. for id := range m.removedlabel_relationships {
  15173. ids = append(ids, id)
  15174. }
  15175. return
  15176. }
  15177. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  15178. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  15179. for id := range m.label_relationships {
  15180. ids = append(ids, id)
  15181. }
  15182. return
  15183. }
  15184. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  15185. func (m *LabelMutation) ResetLabelRelationships() {
  15186. m.label_relationships = nil
  15187. m.clearedlabel_relationships = false
  15188. m.removedlabel_relationships = nil
  15189. }
  15190. // Where appends a list predicates to the LabelMutation builder.
  15191. func (m *LabelMutation) Where(ps ...predicate.Label) {
  15192. m.predicates = append(m.predicates, ps...)
  15193. }
  15194. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  15195. // users can use type-assertion to append predicates that do not depend on any generated package.
  15196. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  15197. p := make([]predicate.Label, len(ps))
  15198. for i := range ps {
  15199. p[i] = ps[i]
  15200. }
  15201. m.Where(p...)
  15202. }
  15203. // Op returns the operation name.
  15204. func (m *LabelMutation) Op() Op {
  15205. return m.op
  15206. }
  15207. // SetOp allows setting the mutation operation.
  15208. func (m *LabelMutation) SetOp(op Op) {
  15209. m.op = op
  15210. }
  15211. // Type returns the node type of this mutation (Label).
  15212. func (m *LabelMutation) Type() string {
  15213. return m.typ
  15214. }
  15215. // Fields returns all fields that were changed during this mutation. Note that in
  15216. // order to get all numeric fields that were incremented/decremented, call
  15217. // AddedFields().
  15218. func (m *LabelMutation) Fields() []string {
  15219. fields := make([]string, 0, 9)
  15220. if m.created_at != nil {
  15221. fields = append(fields, label.FieldCreatedAt)
  15222. }
  15223. if m.updated_at != nil {
  15224. fields = append(fields, label.FieldUpdatedAt)
  15225. }
  15226. if m.status != nil {
  15227. fields = append(fields, label.FieldStatus)
  15228. }
  15229. if m._type != nil {
  15230. fields = append(fields, label.FieldType)
  15231. }
  15232. if m.name != nil {
  15233. fields = append(fields, label.FieldName)
  15234. }
  15235. if m.from != nil {
  15236. fields = append(fields, label.FieldFrom)
  15237. }
  15238. if m.mode != nil {
  15239. fields = append(fields, label.FieldMode)
  15240. }
  15241. if m.conditions != nil {
  15242. fields = append(fields, label.FieldConditions)
  15243. }
  15244. if m.organization_id != nil {
  15245. fields = append(fields, label.FieldOrganizationID)
  15246. }
  15247. return fields
  15248. }
  15249. // Field returns the value of a field with the given name. The second boolean
  15250. // return value indicates that this field was not set, or was not defined in the
  15251. // schema.
  15252. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  15253. switch name {
  15254. case label.FieldCreatedAt:
  15255. return m.CreatedAt()
  15256. case label.FieldUpdatedAt:
  15257. return m.UpdatedAt()
  15258. case label.FieldStatus:
  15259. return m.Status()
  15260. case label.FieldType:
  15261. return m.GetType()
  15262. case label.FieldName:
  15263. return m.Name()
  15264. case label.FieldFrom:
  15265. return m.From()
  15266. case label.FieldMode:
  15267. return m.Mode()
  15268. case label.FieldConditions:
  15269. return m.Conditions()
  15270. case label.FieldOrganizationID:
  15271. return m.OrganizationID()
  15272. }
  15273. return nil, false
  15274. }
  15275. // OldField returns the old value of the field from the database. An error is
  15276. // returned if the mutation operation is not UpdateOne, or the query to the
  15277. // database failed.
  15278. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15279. switch name {
  15280. case label.FieldCreatedAt:
  15281. return m.OldCreatedAt(ctx)
  15282. case label.FieldUpdatedAt:
  15283. return m.OldUpdatedAt(ctx)
  15284. case label.FieldStatus:
  15285. return m.OldStatus(ctx)
  15286. case label.FieldType:
  15287. return m.OldType(ctx)
  15288. case label.FieldName:
  15289. return m.OldName(ctx)
  15290. case label.FieldFrom:
  15291. return m.OldFrom(ctx)
  15292. case label.FieldMode:
  15293. return m.OldMode(ctx)
  15294. case label.FieldConditions:
  15295. return m.OldConditions(ctx)
  15296. case label.FieldOrganizationID:
  15297. return m.OldOrganizationID(ctx)
  15298. }
  15299. return nil, fmt.Errorf("unknown Label field %s", name)
  15300. }
  15301. // SetField sets the value of a field with the given name. It returns an error if
  15302. // the field is not defined in the schema, or if the type mismatched the field
  15303. // type.
  15304. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  15305. switch name {
  15306. case label.FieldCreatedAt:
  15307. v, ok := value.(time.Time)
  15308. if !ok {
  15309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15310. }
  15311. m.SetCreatedAt(v)
  15312. return nil
  15313. case label.FieldUpdatedAt:
  15314. v, ok := value.(time.Time)
  15315. if !ok {
  15316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15317. }
  15318. m.SetUpdatedAt(v)
  15319. return nil
  15320. case label.FieldStatus:
  15321. v, ok := value.(uint8)
  15322. if !ok {
  15323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15324. }
  15325. m.SetStatus(v)
  15326. return nil
  15327. case label.FieldType:
  15328. v, ok := value.(int)
  15329. if !ok {
  15330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15331. }
  15332. m.SetType(v)
  15333. return nil
  15334. case label.FieldName:
  15335. v, ok := value.(string)
  15336. if !ok {
  15337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15338. }
  15339. m.SetName(v)
  15340. return nil
  15341. case label.FieldFrom:
  15342. v, ok := value.(int)
  15343. if !ok {
  15344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15345. }
  15346. m.SetFrom(v)
  15347. return nil
  15348. case label.FieldMode:
  15349. v, ok := value.(int)
  15350. if !ok {
  15351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15352. }
  15353. m.SetMode(v)
  15354. return nil
  15355. case label.FieldConditions:
  15356. v, ok := value.(string)
  15357. if !ok {
  15358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15359. }
  15360. m.SetConditions(v)
  15361. return nil
  15362. case label.FieldOrganizationID:
  15363. v, ok := value.(uint64)
  15364. if !ok {
  15365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15366. }
  15367. m.SetOrganizationID(v)
  15368. return nil
  15369. }
  15370. return fmt.Errorf("unknown Label field %s", name)
  15371. }
  15372. // AddedFields returns all numeric fields that were incremented/decremented during
  15373. // this mutation.
  15374. func (m *LabelMutation) AddedFields() []string {
  15375. var fields []string
  15376. if m.addstatus != nil {
  15377. fields = append(fields, label.FieldStatus)
  15378. }
  15379. if m.add_type != nil {
  15380. fields = append(fields, label.FieldType)
  15381. }
  15382. if m.addfrom != nil {
  15383. fields = append(fields, label.FieldFrom)
  15384. }
  15385. if m.addmode != nil {
  15386. fields = append(fields, label.FieldMode)
  15387. }
  15388. if m.addorganization_id != nil {
  15389. fields = append(fields, label.FieldOrganizationID)
  15390. }
  15391. return fields
  15392. }
  15393. // AddedField returns the numeric value that was incremented/decremented on a field
  15394. // with the given name. The second boolean return value indicates that this field
  15395. // was not set, or was not defined in the schema.
  15396. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  15397. switch name {
  15398. case label.FieldStatus:
  15399. return m.AddedStatus()
  15400. case label.FieldType:
  15401. return m.AddedType()
  15402. case label.FieldFrom:
  15403. return m.AddedFrom()
  15404. case label.FieldMode:
  15405. return m.AddedMode()
  15406. case label.FieldOrganizationID:
  15407. return m.AddedOrganizationID()
  15408. }
  15409. return nil, false
  15410. }
  15411. // AddField adds the value to the field with the given name. It returns an error if
  15412. // the field is not defined in the schema, or if the type mismatched the field
  15413. // type.
  15414. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  15415. switch name {
  15416. case label.FieldStatus:
  15417. v, ok := value.(int8)
  15418. if !ok {
  15419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15420. }
  15421. m.AddStatus(v)
  15422. return nil
  15423. case label.FieldType:
  15424. v, ok := value.(int)
  15425. if !ok {
  15426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15427. }
  15428. m.AddType(v)
  15429. return nil
  15430. case label.FieldFrom:
  15431. v, ok := value.(int)
  15432. if !ok {
  15433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15434. }
  15435. m.AddFrom(v)
  15436. return nil
  15437. case label.FieldMode:
  15438. v, ok := value.(int)
  15439. if !ok {
  15440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15441. }
  15442. m.AddMode(v)
  15443. return nil
  15444. case label.FieldOrganizationID:
  15445. v, ok := value.(int64)
  15446. if !ok {
  15447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15448. }
  15449. m.AddOrganizationID(v)
  15450. return nil
  15451. }
  15452. return fmt.Errorf("unknown Label numeric field %s", name)
  15453. }
  15454. // ClearedFields returns all nullable fields that were cleared during this
  15455. // mutation.
  15456. func (m *LabelMutation) ClearedFields() []string {
  15457. var fields []string
  15458. if m.FieldCleared(label.FieldStatus) {
  15459. fields = append(fields, label.FieldStatus)
  15460. }
  15461. if m.FieldCleared(label.FieldConditions) {
  15462. fields = append(fields, label.FieldConditions)
  15463. }
  15464. if m.FieldCleared(label.FieldOrganizationID) {
  15465. fields = append(fields, label.FieldOrganizationID)
  15466. }
  15467. return fields
  15468. }
  15469. // FieldCleared returns a boolean indicating if a field with the given name was
  15470. // cleared in this mutation.
  15471. func (m *LabelMutation) FieldCleared(name string) bool {
  15472. _, ok := m.clearedFields[name]
  15473. return ok
  15474. }
  15475. // ClearField clears the value of the field with the given name. It returns an
  15476. // error if the field is not defined in the schema.
  15477. func (m *LabelMutation) ClearField(name string) error {
  15478. switch name {
  15479. case label.FieldStatus:
  15480. m.ClearStatus()
  15481. return nil
  15482. case label.FieldConditions:
  15483. m.ClearConditions()
  15484. return nil
  15485. case label.FieldOrganizationID:
  15486. m.ClearOrganizationID()
  15487. return nil
  15488. }
  15489. return fmt.Errorf("unknown Label nullable field %s", name)
  15490. }
  15491. // ResetField resets all changes in the mutation for the field with the given name.
  15492. // It returns an error if the field is not defined in the schema.
  15493. func (m *LabelMutation) ResetField(name string) error {
  15494. switch name {
  15495. case label.FieldCreatedAt:
  15496. m.ResetCreatedAt()
  15497. return nil
  15498. case label.FieldUpdatedAt:
  15499. m.ResetUpdatedAt()
  15500. return nil
  15501. case label.FieldStatus:
  15502. m.ResetStatus()
  15503. return nil
  15504. case label.FieldType:
  15505. m.ResetType()
  15506. return nil
  15507. case label.FieldName:
  15508. m.ResetName()
  15509. return nil
  15510. case label.FieldFrom:
  15511. m.ResetFrom()
  15512. return nil
  15513. case label.FieldMode:
  15514. m.ResetMode()
  15515. return nil
  15516. case label.FieldConditions:
  15517. m.ResetConditions()
  15518. return nil
  15519. case label.FieldOrganizationID:
  15520. m.ResetOrganizationID()
  15521. return nil
  15522. }
  15523. return fmt.Errorf("unknown Label field %s", name)
  15524. }
  15525. // AddedEdges returns all edge names that were set/added in this mutation.
  15526. func (m *LabelMutation) AddedEdges() []string {
  15527. edges := make([]string, 0, 1)
  15528. if m.label_relationships != nil {
  15529. edges = append(edges, label.EdgeLabelRelationships)
  15530. }
  15531. return edges
  15532. }
  15533. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15534. // name in this mutation.
  15535. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  15536. switch name {
  15537. case label.EdgeLabelRelationships:
  15538. ids := make([]ent.Value, 0, len(m.label_relationships))
  15539. for id := range m.label_relationships {
  15540. ids = append(ids, id)
  15541. }
  15542. return ids
  15543. }
  15544. return nil
  15545. }
  15546. // RemovedEdges returns all edge names that were removed in this mutation.
  15547. func (m *LabelMutation) RemovedEdges() []string {
  15548. edges := make([]string, 0, 1)
  15549. if m.removedlabel_relationships != nil {
  15550. edges = append(edges, label.EdgeLabelRelationships)
  15551. }
  15552. return edges
  15553. }
  15554. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15555. // the given name in this mutation.
  15556. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  15557. switch name {
  15558. case label.EdgeLabelRelationships:
  15559. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  15560. for id := range m.removedlabel_relationships {
  15561. ids = append(ids, id)
  15562. }
  15563. return ids
  15564. }
  15565. return nil
  15566. }
  15567. // ClearedEdges returns all edge names that were cleared in this mutation.
  15568. func (m *LabelMutation) ClearedEdges() []string {
  15569. edges := make([]string, 0, 1)
  15570. if m.clearedlabel_relationships {
  15571. edges = append(edges, label.EdgeLabelRelationships)
  15572. }
  15573. return edges
  15574. }
  15575. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15576. // was cleared in this mutation.
  15577. func (m *LabelMutation) EdgeCleared(name string) bool {
  15578. switch name {
  15579. case label.EdgeLabelRelationships:
  15580. return m.clearedlabel_relationships
  15581. }
  15582. return false
  15583. }
  15584. // ClearEdge clears the value of the edge with the given name. It returns an error
  15585. // if that edge is not defined in the schema.
  15586. func (m *LabelMutation) ClearEdge(name string) error {
  15587. switch name {
  15588. }
  15589. return fmt.Errorf("unknown Label unique edge %s", name)
  15590. }
  15591. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15592. // It returns an error if the edge is not defined in the schema.
  15593. func (m *LabelMutation) ResetEdge(name string) error {
  15594. switch name {
  15595. case label.EdgeLabelRelationships:
  15596. m.ResetLabelRelationships()
  15597. return nil
  15598. }
  15599. return fmt.Errorf("unknown Label edge %s", name)
  15600. }
  15601. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  15602. type LabelRelationshipMutation struct {
  15603. config
  15604. op Op
  15605. typ string
  15606. id *uint64
  15607. created_at *time.Time
  15608. updated_at *time.Time
  15609. status *uint8
  15610. addstatus *int8
  15611. organization_id *uint64
  15612. addorganization_id *int64
  15613. clearedFields map[string]struct{}
  15614. contacts *uint64
  15615. clearedcontacts bool
  15616. labels *uint64
  15617. clearedlabels bool
  15618. done bool
  15619. oldValue func(context.Context) (*LabelRelationship, error)
  15620. predicates []predicate.LabelRelationship
  15621. }
  15622. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  15623. // labelrelationshipOption allows management of the mutation configuration using functional options.
  15624. type labelrelationshipOption func(*LabelRelationshipMutation)
  15625. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  15626. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  15627. m := &LabelRelationshipMutation{
  15628. config: c,
  15629. op: op,
  15630. typ: TypeLabelRelationship,
  15631. clearedFields: make(map[string]struct{}),
  15632. }
  15633. for _, opt := range opts {
  15634. opt(m)
  15635. }
  15636. return m
  15637. }
  15638. // withLabelRelationshipID sets the ID field of the mutation.
  15639. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  15640. return func(m *LabelRelationshipMutation) {
  15641. var (
  15642. err error
  15643. once sync.Once
  15644. value *LabelRelationship
  15645. )
  15646. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  15647. once.Do(func() {
  15648. if m.done {
  15649. err = errors.New("querying old values post mutation is not allowed")
  15650. } else {
  15651. value, err = m.Client().LabelRelationship.Get(ctx, id)
  15652. }
  15653. })
  15654. return value, err
  15655. }
  15656. m.id = &id
  15657. }
  15658. }
  15659. // withLabelRelationship sets the old LabelRelationship of the mutation.
  15660. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  15661. return func(m *LabelRelationshipMutation) {
  15662. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  15663. return node, nil
  15664. }
  15665. m.id = &node.ID
  15666. }
  15667. }
  15668. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15669. // executed in a transaction (ent.Tx), a transactional client is returned.
  15670. func (m LabelRelationshipMutation) Client() *Client {
  15671. client := &Client{config: m.config}
  15672. client.init()
  15673. return client
  15674. }
  15675. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15676. // it returns an error otherwise.
  15677. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  15678. if _, ok := m.driver.(*txDriver); !ok {
  15679. return nil, errors.New("ent: mutation is not running in a transaction")
  15680. }
  15681. tx := &Tx{config: m.config}
  15682. tx.init()
  15683. return tx, nil
  15684. }
  15685. // SetID sets the value of the id field. Note that this
  15686. // operation is only accepted on creation of LabelRelationship entities.
  15687. func (m *LabelRelationshipMutation) SetID(id uint64) {
  15688. m.id = &id
  15689. }
  15690. // ID returns the ID value in the mutation. Note that the ID is only available
  15691. // if it was provided to the builder or after it was returned from the database.
  15692. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  15693. if m.id == nil {
  15694. return
  15695. }
  15696. return *m.id, true
  15697. }
  15698. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15699. // That means, if the mutation is applied within a transaction with an isolation level such
  15700. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15701. // or updated by the mutation.
  15702. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  15703. switch {
  15704. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15705. id, exists := m.ID()
  15706. if exists {
  15707. return []uint64{id}, nil
  15708. }
  15709. fallthrough
  15710. case m.op.Is(OpUpdate | OpDelete):
  15711. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  15712. default:
  15713. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15714. }
  15715. }
  15716. // SetCreatedAt sets the "created_at" field.
  15717. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  15718. m.created_at = &t
  15719. }
  15720. // CreatedAt returns the value of the "created_at" field in the mutation.
  15721. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  15722. v := m.created_at
  15723. if v == nil {
  15724. return
  15725. }
  15726. return *v, true
  15727. }
  15728. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  15729. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15731. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15732. if !m.op.Is(OpUpdateOne) {
  15733. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15734. }
  15735. if m.id == nil || m.oldValue == nil {
  15736. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15737. }
  15738. oldValue, err := m.oldValue(ctx)
  15739. if err != nil {
  15740. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15741. }
  15742. return oldValue.CreatedAt, nil
  15743. }
  15744. // ResetCreatedAt resets all changes to the "created_at" field.
  15745. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  15746. m.created_at = nil
  15747. }
  15748. // SetUpdatedAt sets the "updated_at" field.
  15749. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  15750. m.updated_at = &t
  15751. }
  15752. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15753. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  15754. v := m.updated_at
  15755. if v == nil {
  15756. return
  15757. }
  15758. return *v, true
  15759. }
  15760. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  15761. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15763. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15764. if !m.op.Is(OpUpdateOne) {
  15765. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15766. }
  15767. if m.id == nil || m.oldValue == nil {
  15768. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15769. }
  15770. oldValue, err := m.oldValue(ctx)
  15771. if err != nil {
  15772. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15773. }
  15774. return oldValue.UpdatedAt, nil
  15775. }
  15776. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15777. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  15778. m.updated_at = nil
  15779. }
  15780. // SetStatus sets the "status" field.
  15781. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  15782. m.status = &u
  15783. m.addstatus = nil
  15784. }
  15785. // Status returns the value of the "status" field in the mutation.
  15786. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  15787. v := m.status
  15788. if v == nil {
  15789. return
  15790. }
  15791. return *v, true
  15792. }
  15793. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  15794. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15796. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15797. if !m.op.Is(OpUpdateOne) {
  15798. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15799. }
  15800. if m.id == nil || m.oldValue == nil {
  15801. return v, errors.New("OldStatus requires an ID field in the mutation")
  15802. }
  15803. oldValue, err := m.oldValue(ctx)
  15804. if err != nil {
  15805. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15806. }
  15807. return oldValue.Status, nil
  15808. }
  15809. // AddStatus adds u to the "status" field.
  15810. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  15811. if m.addstatus != nil {
  15812. *m.addstatus += u
  15813. } else {
  15814. m.addstatus = &u
  15815. }
  15816. }
  15817. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15818. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  15819. v := m.addstatus
  15820. if v == nil {
  15821. return
  15822. }
  15823. return *v, true
  15824. }
  15825. // ClearStatus clears the value of the "status" field.
  15826. func (m *LabelRelationshipMutation) ClearStatus() {
  15827. m.status = nil
  15828. m.addstatus = nil
  15829. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  15830. }
  15831. // StatusCleared returns if the "status" field was cleared in this mutation.
  15832. func (m *LabelRelationshipMutation) StatusCleared() bool {
  15833. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  15834. return ok
  15835. }
  15836. // ResetStatus resets all changes to the "status" field.
  15837. func (m *LabelRelationshipMutation) ResetStatus() {
  15838. m.status = nil
  15839. m.addstatus = nil
  15840. delete(m.clearedFields, labelrelationship.FieldStatus)
  15841. }
  15842. // SetLabelID sets the "label_id" field.
  15843. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  15844. m.labels = &u
  15845. }
  15846. // LabelID returns the value of the "label_id" field in the mutation.
  15847. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  15848. v := m.labels
  15849. if v == nil {
  15850. return
  15851. }
  15852. return *v, true
  15853. }
  15854. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  15855. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15857. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  15858. if !m.op.Is(OpUpdateOne) {
  15859. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  15860. }
  15861. if m.id == nil || m.oldValue == nil {
  15862. return v, errors.New("OldLabelID requires an ID field in the mutation")
  15863. }
  15864. oldValue, err := m.oldValue(ctx)
  15865. if err != nil {
  15866. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  15867. }
  15868. return oldValue.LabelID, nil
  15869. }
  15870. // ResetLabelID resets all changes to the "label_id" field.
  15871. func (m *LabelRelationshipMutation) ResetLabelID() {
  15872. m.labels = nil
  15873. }
  15874. // SetContactID sets the "contact_id" field.
  15875. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  15876. m.contacts = &u
  15877. }
  15878. // ContactID returns the value of the "contact_id" field in the mutation.
  15879. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  15880. v := m.contacts
  15881. if v == nil {
  15882. return
  15883. }
  15884. return *v, true
  15885. }
  15886. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  15887. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15889. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  15890. if !m.op.Is(OpUpdateOne) {
  15891. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  15892. }
  15893. if m.id == nil || m.oldValue == nil {
  15894. return v, errors.New("OldContactID requires an ID field in the mutation")
  15895. }
  15896. oldValue, err := m.oldValue(ctx)
  15897. if err != nil {
  15898. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  15899. }
  15900. return oldValue.ContactID, nil
  15901. }
  15902. // ResetContactID resets all changes to the "contact_id" field.
  15903. func (m *LabelRelationshipMutation) ResetContactID() {
  15904. m.contacts = nil
  15905. }
  15906. // SetOrganizationID sets the "organization_id" field.
  15907. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  15908. m.organization_id = &u
  15909. m.addorganization_id = nil
  15910. }
  15911. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15912. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  15913. v := m.organization_id
  15914. if v == nil {
  15915. return
  15916. }
  15917. return *v, true
  15918. }
  15919. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  15920. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  15921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15922. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15923. if !m.op.Is(OpUpdateOne) {
  15924. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15925. }
  15926. if m.id == nil || m.oldValue == nil {
  15927. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15928. }
  15929. oldValue, err := m.oldValue(ctx)
  15930. if err != nil {
  15931. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15932. }
  15933. return oldValue.OrganizationID, nil
  15934. }
  15935. // AddOrganizationID adds u to the "organization_id" field.
  15936. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  15937. if m.addorganization_id != nil {
  15938. *m.addorganization_id += u
  15939. } else {
  15940. m.addorganization_id = &u
  15941. }
  15942. }
  15943. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15944. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  15945. v := m.addorganization_id
  15946. if v == nil {
  15947. return
  15948. }
  15949. return *v, true
  15950. }
  15951. // ClearOrganizationID clears the value of the "organization_id" field.
  15952. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  15953. m.organization_id = nil
  15954. m.addorganization_id = nil
  15955. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  15956. }
  15957. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15958. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  15959. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  15960. return ok
  15961. }
  15962. // ResetOrganizationID resets all changes to the "organization_id" field.
  15963. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  15964. m.organization_id = nil
  15965. m.addorganization_id = nil
  15966. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  15967. }
  15968. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  15969. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  15970. m.contacts = &id
  15971. }
  15972. // ClearContacts clears the "contacts" edge to the Contact entity.
  15973. func (m *LabelRelationshipMutation) ClearContacts() {
  15974. m.clearedcontacts = true
  15975. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  15976. }
  15977. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  15978. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  15979. return m.clearedcontacts
  15980. }
  15981. // ContactsID returns the "contacts" edge ID in the mutation.
  15982. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  15983. if m.contacts != nil {
  15984. return *m.contacts, true
  15985. }
  15986. return
  15987. }
  15988. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  15989. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15990. // ContactsID instead. It exists only for internal usage by the builders.
  15991. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  15992. if id := m.contacts; id != nil {
  15993. ids = append(ids, *id)
  15994. }
  15995. return
  15996. }
  15997. // ResetContacts resets all changes to the "contacts" edge.
  15998. func (m *LabelRelationshipMutation) ResetContacts() {
  15999. m.contacts = nil
  16000. m.clearedcontacts = false
  16001. }
  16002. // SetLabelsID sets the "labels" edge to the Label entity by id.
  16003. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  16004. m.labels = &id
  16005. }
  16006. // ClearLabels clears the "labels" edge to the Label entity.
  16007. func (m *LabelRelationshipMutation) ClearLabels() {
  16008. m.clearedlabels = true
  16009. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  16010. }
  16011. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  16012. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  16013. return m.clearedlabels
  16014. }
  16015. // LabelsID returns the "labels" edge ID in the mutation.
  16016. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  16017. if m.labels != nil {
  16018. return *m.labels, true
  16019. }
  16020. return
  16021. }
  16022. // LabelsIDs returns the "labels" edge IDs in the mutation.
  16023. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16024. // LabelsID instead. It exists only for internal usage by the builders.
  16025. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  16026. if id := m.labels; id != nil {
  16027. ids = append(ids, *id)
  16028. }
  16029. return
  16030. }
  16031. // ResetLabels resets all changes to the "labels" edge.
  16032. func (m *LabelRelationshipMutation) ResetLabels() {
  16033. m.labels = nil
  16034. m.clearedlabels = false
  16035. }
  16036. // Where appends a list predicates to the LabelRelationshipMutation builder.
  16037. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  16038. m.predicates = append(m.predicates, ps...)
  16039. }
  16040. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  16041. // users can use type-assertion to append predicates that do not depend on any generated package.
  16042. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  16043. p := make([]predicate.LabelRelationship, len(ps))
  16044. for i := range ps {
  16045. p[i] = ps[i]
  16046. }
  16047. m.Where(p...)
  16048. }
  16049. // Op returns the operation name.
  16050. func (m *LabelRelationshipMutation) Op() Op {
  16051. return m.op
  16052. }
  16053. // SetOp allows setting the mutation operation.
  16054. func (m *LabelRelationshipMutation) SetOp(op Op) {
  16055. m.op = op
  16056. }
  16057. // Type returns the node type of this mutation (LabelRelationship).
  16058. func (m *LabelRelationshipMutation) Type() string {
  16059. return m.typ
  16060. }
  16061. // Fields returns all fields that were changed during this mutation. Note that in
  16062. // order to get all numeric fields that were incremented/decremented, call
  16063. // AddedFields().
  16064. func (m *LabelRelationshipMutation) Fields() []string {
  16065. fields := make([]string, 0, 6)
  16066. if m.created_at != nil {
  16067. fields = append(fields, labelrelationship.FieldCreatedAt)
  16068. }
  16069. if m.updated_at != nil {
  16070. fields = append(fields, labelrelationship.FieldUpdatedAt)
  16071. }
  16072. if m.status != nil {
  16073. fields = append(fields, labelrelationship.FieldStatus)
  16074. }
  16075. if m.labels != nil {
  16076. fields = append(fields, labelrelationship.FieldLabelID)
  16077. }
  16078. if m.contacts != nil {
  16079. fields = append(fields, labelrelationship.FieldContactID)
  16080. }
  16081. if m.organization_id != nil {
  16082. fields = append(fields, labelrelationship.FieldOrganizationID)
  16083. }
  16084. return fields
  16085. }
  16086. // Field returns the value of a field with the given name. The second boolean
  16087. // return value indicates that this field was not set, or was not defined in the
  16088. // schema.
  16089. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  16090. switch name {
  16091. case labelrelationship.FieldCreatedAt:
  16092. return m.CreatedAt()
  16093. case labelrelationship.FieldUpdatedAt:
  16094. return m.UpdatedAt()
  16095. case labelrelationship.FieldStatus:
  16096. return m.Status()
  16097. case labelrelationship.FieldLabelID:
  16098. return m.LabelID()
  16099. case labelrelationship.FieldContactID:
  16100. return m.ContactID()
  16101. case labelrelationship.FieldOrganizationID:
  16102. return m.OrganizationID()
  16103. }
  16104. return nil, false
  16105. }
  16106. // OldField returns the old value of the field from the database. An error is
  16107. // returned if the mutation operation is not UpdateOne, or the query to the
  16108. // database failed.
  16109. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16110. switch name {
  16111. case labelrelationship.FieldCreatedAt:
  16112. return m.OldCreatedAt(ctx)
  16113. case labelrelationship.FieldUpdatedAt:
  16114. return m.OldUpdatedAt(ctx)
  16115. case labelrelationship.FieldStatus:
  16116. return m.OldStatus(ctx)
  16117. case labelrelationship.FieldLabelID:
  16118. return m.OldLabelID(ctx)
  16119. case labelrelationship.FieldContactID:
  16120. return m.OldContactID(ctx)
  16121. case labelrelationship.FieldOrganizationID:
  16122. return m.OldOrganizationID(ctx)
  16123. }
  16124. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  16125. }
  16126. // SetField sets the value of a field with the given name. It returns an error if
  16127. // the field is not defined in the schema, or if the type mismatched the field
  16128. // type.
  16129. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  16130. switch name {
  16131. case labelrelationship.FieldCreatedAt:
  16132. v, ok := value.(time.Time)
  16133. if !ok {
  16134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16135. }
  16136. m.SetCreatedAt(v)
  16137. return nil
  16138. case labelrelationship.FieldUpdatedAt:
  16139. v, ok := value.(time.Time)
  16140. if !ok {
  16141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16142. }
  16143. m.SetUpdatedAt(v)
  16144. return nil
  16145. case labelrelationship.FieldStatus:
  16146. v, ok := value.(uint8)
  16147. if !ok {
  16148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16149. }
  16150. m.SetStatus(v)
  16151. return nil
  16152. case labelrelationship.FieldLabelID:
  16153. v, ok := value.(uint64)
  16154. if !ok {
  16155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16156. }
  16157. m.SetLabelID(v)
  16158. return nil
  16159. case labelrelationship.FieldContactID:
  16160. v, ok := value.(uint64)
  16161. if !ok {
  16162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16163. }
  16164. m.SetContactID(v)
  16165. return nil
  16166. case labelrelationship.FieldOrganizationID:
  16167. v, ok := value.(uint64)
  16168. if !ok {
  16169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16170. }
  16171. m.SetOrganizationID(v)
  16172. return nil
  16173. }
  16174. return fmt.Errorf("unknown LabelRelationship field %s", name)
  16175. }
  16176. // AddedFields returns all numeric fields that were incremented/decremented during
  16177. // this mutation.
  16178. func (m *LabelRelationshipMutation) AddedFields() []string {
  16179. var fields []string
  16180. if m.addstatus != nil {
  16181. fields = append(fields, labelrelationship.FieldStatus)
  16182. }
  16183. if m.addorganization_id != nil {
  16184. fields = append(fields, labelrelationship.FieldOrganizationID)
  16185. }
  16186. return fields
  16187. }
  16188. // AddedField returns the numeric value that was incremented/decremented on a field
  16189. // with the given name. The second boolean return value indicates that this field
  16190. // was not set, or was not defined in the schema.
  16191. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  16192. switch name {
  16193. case labelrelationship.FieldStatus:
  16194. return m.AddedStatus()
  16195. case labelrelationship.FieldOrganizationID:
  16196. return m.AddedOrganizationID()
  16197. }
  16198. return nil, false
  16199. }
  16200. // AddField adds the value to the field with the given name. It returns an error if
  16201. // the field is not defined in the schema, or if the type mismatched the field
  16202. // type.
  16203. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  16204. switch name {
  16205. case labelrelationship.FieldStatus:
  16206. v, ok := value.(int8)
  16207. if !ok {
  16208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16209. }
  16210. m.AddStatus(v)
  16211. return nil
  16212. case labelrelationship.FieldOrganizationID:
  16213. v, ok := value.(int64)
  16214. if !ok {
  16215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16216. }
  16217. m.AddOrganizationID(v)
  16218. return nil
  16219. }
  16220. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  16221. }
  16222. // ClearedFields returns all nullable fields that were cleared during this
  16223. // mutation.
  16224. func (m *LabelRelationshipMutation) ClearedFields() []string {
  16225. var fields []string
  16226. if m.FieldCleared(labelrelationship.FieldStatus) {
  16227. fields = append(fields, labelrelationship.FieldStatus)
  16228. }
  16229. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  16230. fields = append(fields, labelrelationship.FieldOrganizationID)
  16231. }
  16232. return fields
  16233. }
  16234. // FieldCleared returns a boolean indicating if a field with the given name was
  16235. // cleared in this mutation.
  16236. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  16237. _, ok := m.clearedFields[name]
  16238. return ok
  16239. }
  16240. // ClearField clears the value of the field with the given name. It returns an
  16241. // error if the field is not defined in the schema.
  16242. func (m *LabelRelationshipMutation) ClearField(name string) error {
  16243. switch name {
  16244. case labelrelationship.FieldStatus:
  16245. m.ClearStatus()
  16246. return nil
  16247. case labelrelationship.FieldOrganizationID:
  16248. m.ClearOrganizationID()
  16249. return nil
  16250. }
  16251. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  16252. }
  16253. // ResetField resets all changes in the mutation for the field with the given name.
  16254. // It returns an error if the field is not defined in the schema.
  16255. func (m *LabelRelationshipMutation) ResetField(name string) error {
  16256. switch name {
  16257. case labelrelationship.FieldCreatedAt:
  16258. m.ResetCreatedAt()
  16259. return nil
  16260. case labelrelationship.FieldUpdatedAt:
  16261. m.ResetUpdatedAt()
  16262. return nil
  16263. case labelrelationship.FieldStatus:
  16264. m.ResetStatus()
  16265. return nil
  16266. case labelrelationship.FieldLabelID:
  16267. m.ResetLabelID()
  16268. return nil
  16269. case labelrelationship.FieldContactID:
  16270. m.ResetContactID()
  16271. return nil
  16272. case labelrelationship.FieldOrganizationID:
  16273. m.ResetOrganizationID()
  16274. return nil
  16275. }
  16276. return fmt.Errorf("unknown LabelRelationship field %s", name)
  16277. }
  16278. // AddedEdges returns all edge names that were set/added in this mutation.
  16279. func (m *LabelRelationshipMutation) AddedEdges() []string {
  16280. edges := make([]string, 0, 2)
  16281. if m.contacts != nil {
  16282. edges = append(edges, labelrelationship.EdgeContacts)
  16283. }
  16284. if m.labels != nil {
  16285. edges = append(edges, labelrelationship.EdgeLabels)
  16286. }
  16287. return edges
  16288. }
  16289. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16290. // name in this mutation.
  16291. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  16292. switch name {
  16293. case labelrelationship.EdgeContacts:
  16294. if id := m.contacts; id != nil {
  16295. return []ent.Value{*id}
  16296. }
  16297. case labelrelationship.EdgeLabels:
  16298. if id := m.labels; id != nil {
  16299. return []ent.Value{*id}
  16300. }
  16301. }
  16302. return nil
  16303. }
  16304. // RemovedEdges returns all edge names that were removed in this mutation.
  16305. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  16306. edges := make([]string, 0, 2)
  16307. return edges
  16308. }
  16309. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16310. // the given name in this mutation.
  16311. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  16312. return nil
  16313. }
  16314. // ClearedEdges returns all edge names that were cleared in this mutation.
  16315. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  16316. edges := make([]string, 0, 2)
  16317. if m.clearedcontacts {
  16318. edges = append(edges, labelrelationship.EdgeContacts)
  16319. }
  16320. if m.clearedlabels {
  16321. edges = append(edges, labelrelationship.EdgeLabels)
  16322. }
  16323. return edges
  16324. }
  16325. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16326. // was cleared in this mutation.
  16327. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  16328. switch name {
  16329. case labelrelationship.EdgeContacts:
  16330. return m.clearedcontacts
  16331. case labelrelationship.EdgeLabels:
  16332. return m.clearedlabels
  16333. }
  16334. return false
  16335. }
  16336. // ClearEdge clears the value of the edge with the given name. It returns an error
  16337. // if that edge is not defined in the schema.
  16338. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  16339. switch name {
  16340. case labelrelationship.EdgeContacts:
  16341. m.ClearContacts()
  16342. return nil
  16343. case labelrelationship.EdgeLabels:
  16344. m.ClearLabels()
  16345. return nil
  16346. }
  16347. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  16348. }
  16349. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16350. // It returns an error if the edge is not defined in the schema.
  16351. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  16352. switch name {
  16353. case labelrelationship.EdgeContacts:
  16354. m.ResetContacts()
  16355. return nil
  16356. case labelrelationship.EdgeLabels:
  16357. m.ResetLabels()
  16358. return nil
  16359. }
  16360. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  16361. }
  16362. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  16363. type LabelTaggingMutation struct {
  16364. config
  16365. op Op
  16366. typ string
  16367. id *uint64
  16368. created_at *time.Time
  16369. updated_at *time.Time
  16370. status *uint8
  16371. addstatus *int8
  16372. deleted_at *time.Time
  16373. organization_id *uint64
  16374. addorganization_id *int64
  16375. _type *int
  16376. add_type *int
  16377. conditions *string
  16378. action_label_add *[]uint64
  16379. appendaction_label_add []uint64
  16380. action_label_del *[]uint64
  16381. appendaction_label_del []uint64
  16382. clearedFields map[string]struct{}
  16383. done bool
  16384. oldValue func(context.Context) (*LabelTagging, error)
  16385. predicates []predicate.LabelTagging
  16386. }
  16387. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  16388. // labeltaggingOption allows management of the mutation configuration using functional options.
  16389. type labeltaggingOption func(*LabelTaggingMutation)
  16390. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  16391. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  16392. m := &LabelTaggingMutation{
  16393. config: c,
  16394. op: op,
  16395. typ: TypeLabelTagging,
  16396. clearedFields: make(map[string]struct{}),
  16397. }
  16398. for _, opt := range opts {
  16399. opt(m)
  16400. }
  16401. return m
  16402. }
  16403. // withLabelTaggingID sets the ID field of the mutation.
  16404. func withLabelTaggingID(id uint64) labeltaggingOption {
  16405. return func(m *LabelTaggingMutation) {
  16406. var (
  16407. err error
  16408. once sync.Once
  16409. value *LabelTagging
  16410. )
  16411. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  16412. once.Do(func() {
  16413. if m.done {
  16414. err = errors.New("querying old values post mutation is not allowed")
  16415. } else {
  16416. value, err = m.Client().LabelTagging.Get(ctx, id)
  16417. }
  16418. })
  16419. return value, err
  16420. }
  16421. m.id = &id
  16422. }
  16423. }
  16424. // withLabelTagging sets the old LabelTagging of the mutation.
  16425. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  16426. return func(m *LabelTaggingMutation) {
  16427. m.oldValue = func(context.Context) (*LabelTagging, error) {
  16428. return node, nil
  16429. }
  16430. m.id = &node.ID
  16431. }
  16432. }
  16433. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16434. // executed in a transaction (ent.Tx), a transactional client is returned.
  16435. func (m LabelTaggingMutation) Client() *Client {
  16436. client := &Client{config: m.config}
  16437. client.init()
  16438. return client
  16439. }
  16440. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16441. // it returns an error otherwise.
  16442. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  16443. if _, ok := m.driver.(*txDriver); !ok {
  16444. return nil, errors.New("ent: mutation is not running in a transaction")
  16445. }
  16446. tx := &Tx{config: m.config}
  16447. tx.init()
  16448. return tx, nil
  16449. }
  16450. // SetID sets the value of the id field. Note that this
  16451. // operation is only accepted on creation of LabelTagging entities.
  16452. func (m *LabelTaggingMutation) SetID(id uint64) {
  16453. m.id = &id
  16454. }
  16455. // ID returns the ID value in the mutation. Note that the ID is only available
  16456. // if it was provided to the builder or after it was returned from the database.
  16457. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  16458. if m.id == nil {
  16459. return
  16460. }
  16461. return *m.id, true
  16462. }
  16463. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16464. // That means, if the mutation is applied within a transaction with an isolation level such
  16465. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16466. // or updated by the mutation.
  16467. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  16468. switch {
  16469. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16470. id, exists := m.ID()
  16471. if exists {
  16472. return []uint64{id}, nil
  16473. }
  16474. fallthrough
  16475. case m.op.Is(OpUpdate | OpDelete):
  16476. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  16477. default:
  16478. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16479. }
  16480. }
  16481. // SetCreatedAt sets the "created_at" field.
  16482. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  16483. m.created_at = &t
  16484. }
  16485. // CreatedAt returns the value of the "created_at" field in the mutation.
  16486. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  16487. v := m.created_at
  16488. if v == nil {
  16489. return
  16490. }
  16491. return *v, true
  16492. }
  16493. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  16494. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16496. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16497. if !m.op.Is(OpUpdateOne) {
  16498. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16499. }
  16500. if m.id == nil || m.oldValue == nil {
  16501. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16502. }
  16503. oldValue, err := m.oldValue(ctx)
  16504. if err != nil {
  16505. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16506. }
  16507. return oldValue.CreatedAt, nil
  16508. }
  16509. // ResetCreatedAt resets all changes to the "created_at" field.
  16510. func (m *LabelTaggingMutation) ResetCreatedAt() {
  16511. m.created_at = nil
  16512. }
  16513. // SetUpdatedAt sets the "updated_at" field.
  16514. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  16515. m.updated_at = &t
  16516. }
  16517. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16518. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  16519. v := m.updated_at
  16520. if v == nil {
  16521. return
  16522. }
  16523. return *v, true
  16524. }
  16525. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  16526. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16528. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16529. if !m.op.Is(OpUpdateOne) {
  16530. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16531. }
  16532. if m.id == nil || m.oldValue == nil {
  16533. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16534. }
  16535. oldValue, err := m.oldValue(ctx)
  16536. if err != nil {
  16537. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16538. }
  16539. return oldValue.UpdatedAt, nil
  16540. }
  16541. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16542. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  16543. m.updated_at = nil
  16544. }
  16545. // SetStatus sets the "status" field.
  16546. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  16547. m.status = &u
  16548. m.addstatus = nil
  16549. }
  16550. // Status returns the value of the "status" field in the mutation.
  16551. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  16552. v := m.status
  16553. if v == nil {
  16554. return
  16555. }
  16556. return *v, true
  16557. }
  16558. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  16559. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16561. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16562. if !m.op.Is(OpUpdateOne) {
  16563. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16564. }
  16565. if m.id == nil || m.oldValue == nil {
  16566. return v, errors.New("OldStatus requires an ID field in the mutation")
  16567. }
  16568. oldValue, err := m.oldValue(ctx)
  16569. if err != nil {
  16570. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16571. }
  16572. return oldValue.Status, nil
  16573. }
  16574. // AddStatus adds u to the "status" field.
  16575. func (m *LabelTaggingMutation) AddStatus(u int8) {
  16576. if m.addstatus != nil {
  16577. *m.addstatus += u
  16578. } else {
  16579. m.addstatus = &u
  16580. }
  16581. }
  16582. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16583. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  16584. v := m.addstatus
  16585. if v == nil {
  16586. return
  16587. }
  16588. return *v, true
  16589. }
  16590. // ClearStatus clears the value of the "status" field.
  16591. func (m *LabelTaggingMutation) ClearStatus() {
  16592. m.status = nil
  16593. m.addstatus = nil
  16594. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  16595. }
  16596. // StatusCleared returns if the "status" field was cleared in this mutation.
  16597. func (m *LabelTaggingMutation) StatusCleared() bool {
  16598. _, ok := m.clearedFields[labeltagging.FieldStatus]
  16599. return ok
  16600. }
  16601. // ResetStatus resets all changes to the "status" field.
  16602. func (m *LabelTaggingMutation) ResetStatus() {
  16603. m.status = nil
  16604. m.addstatus = nil
  16605. delete(m.clearedFields, labeltagging.FieldStatus)
  16606. }
  16607. // SetDeletedAt sets the "deleted_at" field.
  16608. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  16609. m.deleted_at = &t
  16610. }
  16611. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16612. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  16613. v := m.deleted_at
  16614. if v == nil {
  16615. return
  16616. }
  16617. return *v, true
  16618. }
  16619. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  16620. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16622. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16623. if !m.op.Is(OpUpdateOne) {
  16624. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16625. }
  16626. if m.id == nil || m.oldValue == nil {
  16627. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16628. }
  16629. oldValue, err := m.oldValue(ctx)
  16630. if err != nil {
  16631. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16632. }
  16633. return oldValue.DeletedAt, nil
  16634. }
  16635. // ClearDeletedAt clears the value of the "deleted_at" field.
  16636. func (m *LabelTaggingMutation) ClearDeletedAt() {
  16637. m.deleted_at = nil
  16638. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  16639. }
  16640. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16641. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  16642. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  16643. return ok
  16644. }
  16645. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16646. func (m *LabelTaggingMutation) ResetDeletedAt() {
  16647. m.deleted_at = nil
  16648. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  16649. }
  16650. // SetOrganizationID sets the "organization_id" field.
  16651. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  16652. m.organization_id = &u
  16653. m.addorganization_id = nil
  16654. }
  16655. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16656. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  16657. v := m.organization_id
  16658. if v == nil {
  16659. return
  16660. }
  16661. return *v, true
  16662. }
  16663. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  16664. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16666. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16667. if !m.op.Is(OpUpdateOne) {
  16668. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16669. }
  16670. if m.id == nil || m.oldValue == nil {
  16671. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16672. }
  16673. oldValue, err := m.oldValue(ctx)
  16674. if err != nil {
  16675. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16676. }
  16677. return oldValue.OrganizationID, nil
  16678. }
  16679. // AddOrganizationID adds u to the "organization_id" field.
  16680. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  16681. if m.addorganization_id != nil {
  16682. *m.addorganization_id += u
  16683. } else {
  16684. m.addorganization_id = &u
  16685. }
  16686. }
  16687. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16688. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  16689. v := m.addorganization_id
  16690. if v == nil {
  16691. return
  16692. }
  16693. return *v, true
  16694. }
  16695. // ResetOrganizationID resets all changes to the "organization_id" field.
  16696. func (m *LabelTaggingMutation) ResetOrganizationID() {
  16697. m.organization_id = nil
  16698. m.addorganization_id = nil
  16699. }
  16700. // SetType sets the "type" field.
  16701. func (m *LabelTaggingMutation) SetType(i int) {
  16702. m._type = &i
  16703. m.add_type = nil
  16704. }
  16705. // GetType returns the value of the "type" field in the mutation.
  16706. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  16707. v := m._type
  16708. if v == nil {
  16709. return
  16710. }
  16711. return *v, true
  16712. }
  16713. // OldType returns the old "type" field's value of the LabelTagging entity.
  16714. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16716. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  16717. if !m.op.Is(OpUpdateOne) {
  16718. return v, errors.New("OldType is only allowed on UpdateOne operations")
  16719. }
  16720. if m.id == nil || m.oldValue == nil {
  16721. return v, errors.New("OldType requires an ID field in the mutation")
  16722. }
  16723. oldValue, err := m.oldValue(ctx)
  16724. if err != nil {
  16725. return v, fmt.Errorf("querying old value for OldType: %w", err)
  16726. }
  16727. return oldValue.Type, nil
  16728. }
  16729. // AddType adds i to the "type" field.
  16730. func (m *LabelTaggingMutation) AddType(i int) {
  16731. if m.add_type != nil {
  16732. *m.add_type += i
  16733. } else {
  16734. m.add_type = &i
  16735. }
  16736. }
  16737. // AddedType returns the value that was added to the "type" field in this mutation.
  16738. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  16739. v := m.add_type
  16740. if v == nil {
  16741. return
  16742. }
  16743. return *v, true
  16744. }
  16745. // ResetType resets all changes to the "type" field.
  16746. func (m *LabelTaggingMutation) ResetType() {
  16747. m._type = nil
  16748. m.add_type = nil
  16749. }
  16750. // SetConditions sets the "conditions" field.
  16751. func (m *LabelTaggingMutation) SetConditions(s string) {
  16752. m.conditions = &s
  16753. }
  16754. // Conditions returns the value of the "conditions" field in the mutation.
  16755. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  16756. v := m.conditions
  16757. if v == nil {
  16758. return
  16759. }
  16760. return *v, true
  16761. }
  16762. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  16763. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16765. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  16766. if !m.op.Is(OpUpdateOne) {
  16767. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16768. }
  16769. if m.id == nil || m.oldValue == nil {
  16770. return v, errors.New("OldConditions requires an ID field in the mutation")
  16771. }
  16772. oldValue, err := m.oldValue(ctx)
  16773. if err != nil {
  16774. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  16775. }
  16776. return oldValue.Conditions, nil
  16777. }
  16778. // ResetConditions resets all changes to the "conditions" field.
  16779. func (m *LabelTaggingMutation) ResetConditions() {
  16780. m.conditions = nil
  16781. }
  16782. // SetActionLabelAdd sets the "action_label_add" field.
  16783. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  16784. m.action_label_add = &u
  16785. m.appendaction_label_add = nil
  16786. }
  16787. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  16788. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  16789. v := m.action_label_add
  16790. if v == nil {
  16791. return
  16792. }
  16793. return *v, true
  16794. }
  16795. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  16796. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16798. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  16799. if !m.op.Is(OpUpdateOne) {
  16800. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  16801. }
  16802. if m.id == nil || m.oldValue == nil {
  16803. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  16804. }
  16805. oldValue, err := m.oldValue(ctx)
  16806. if err != nil {
  16807. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  16808. }
  16809. return oldValue.ActionLabelAdd, nil
  16810. }
  16811. // AppendActionLabelAdd adds u to the "action_label_add" field.
  16812. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  16813. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  16814. }
  16815. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  16816. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  16817. if len(m.appendaction_label_add) == 0 {
  16818. return nil, false
  16819. }
  16820. return m.appendaction_label_add, true
  16821. }
  16822. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  16823. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  16824. m.action_label_add = nil
  16825. m.appendaction_label_add = nil
  16826. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  16827. }
  16828. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  16829. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  16830. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  16831. return ok
  16832. }
  16833. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  16834. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  16835. m.action_label_add = nil
  16836. m.appendaction_label_add = nil
  16837. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  16838. }
  16839. // SetActionLabelDel sets the "action_label_del" field.
  16840. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  16841. m.action_label_del = &u
  16842. m.appendaction_label_del = nil
  16843. }
  16844. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  16845. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  16846. v := m.action_label_del
  16847. if v == nil {
  16848. return
  16849. }
  16850. return *v, true
  16851. }
  16852. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  16853. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  16854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16855. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  16856. if !m.op.Is(OpUpdateOne) {
  16857. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  16858. }
  16859. if m.id == nil || m.oldValue == nil {
  16860. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  16861. }
  16862. oldValue, err := m.oldValue(ctx)
  16863. if err != nil {
  16864. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  16865. }
  16866. return oldValue.ActionLabelDel, nil
  16867. }
  16868. // AppendActionLabelDel adds u to the "action_label_del" field.
  16869. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  16870. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  16871. }
  16872. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  16873. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  16874. if len(m.appendaction_label_del) == 0 {
  16875. return nil, false
  16876. }
  16877. return m.appendaction_label_del, true
  16878. }
  16879. // ClearActionLabelDel clears the value of the "action_label_del" field.
  16880. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  16881. m.action_label_del = nil
  16882. m.appendaction_label_del = nil
  16883. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  16884. }
  16885. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  16886. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  16887. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  16888. return ok
  16889. }
  16890. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  16891. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  16892. m.action_label_del = nil
  16893. m.appendaction_label_del = nil
  16894. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  16895. }
  16896. // Where appends a list predicates to the LabelTaggingMutation builder.
  16897. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  16898. m.predicates = append(m.predicates, ps...)
  16899. }
  16900. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  16901. // users can use type-assertion to append predicates that do not depend on any generated package.
  16902. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  16903. p := make([]predicate.LabelTagging, len(ps))
  16904. for i := range ps {
  16905. p[i] = ps[i]
  16906. }
  16907. m.Where(p...)
  16908. }
  16909. // Op returns the operation name.
  16910. func (m *LabelTaggingMutation) Op() Op {
  16911. return m.op
  16912. }
  16913. // SetOp allows setting the mutation operation.
  16914. func (m *LabelTaggingMutation) SetOp(op Op) {
  16915. m.op = op
  16916. }
  16917. // Type returns the node type of this mutation (LabelTagging).
  16918. func (m *LabelTaggingMutation) Type() string {
  16919. return m.typ
  16920. }
  16921. // Fields returns all fields that were changed during this mutation. Note that in
  16922. // order to get all numeric fields that were incremented/decremented, call
  16923. // AddedFields().
  16924. func (m *LabelTaggingMutation) Fields() []string {
  16925. fields := make([]string, 0, 9)
  16926. if m.created_at != nil {
  16927. fields = append(fields, labeltagging.FieldCreatedAt)
  16928. }
  16929. if m.updated_at != nil {
  16930. fields = append(fields, labeltagging.FieldUpdatedAt)
  16931. }
  16932. if m.status != nil {
  16933. fields = append(fields, labeltagging.FieldStatus)
  16934. }
  16935. if m.deleted_at != nil {
  16936. fields = append(fields, labeltagging.FieldDeletedAt)
  16937. }
  16938. if m.organization_id != nil {
  16939. fields = append(fields, labeltagging.FieldOrganizationID)
  16940. }
  16941. if m._type != nil {
  16942. fields = append(fields, labeltagging.FieldType)
  16943. }
  16944. if m.conditions != nil {
  16945. fields = append(fields, labeltagging.FieldConditions)
  16946. }
  16947. if m.action_label_add != nil {
  16948. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16949. }
  16950. if m.action_label_del != nil {
  16951. fields = append(fields, labeltagging.FieldActionLabelDel)
  16952. }
  16953. return fields
  16954. }
  16955. // Field returns the value of a field with the given name. The second boolean
  16956. // return value indicates that this field was not set, or was not defined in the
  16957. // schema.
  16958. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  16959. switch name {
  16960. case labeltagging.FieldCreatedAt:
  16961. return m.CreatedAt()
  16962. case labeltagging.FieldUpdatedAt:
  16963. return m.UpdatedAt()
  16964. case labeltagging.FieldStatus:
  16965. return m.Status()
  16966. case labeltagging.FieldDeletedAt:
  16967. return m.DeletedAt()
  16968. case labeltagging.FieldOrganizationID:
  16969. return m.OrganizationID()
  16970. case labeltagging.FieldType:
  16971. return m.GetType()
  16972. case labeltagging.FieldConditions:
  16973. return m.Conditions()
  16974. case labeltagging.FieldActionLabelAdd:
  16975. return m.ActionLabelAdd()
  16976. case labeltagging.FieldActionLabelDel:
  16977. return m.ActionLabelDel()
  16978. }
  16979. return nil, false
  16980. }
  16981. // OldField returns the old value of the field from the database. An error is
  16982. // returned if the mutation operation is not UpdateOne, or the query to the
  16983. // database failed.
  16984. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16985. switch name {
  16986. case labeltagging.FieldCreatedAt:
  16987. return m.OldCreatedAt(ctx)
  16988. case labeltagging.FieldUpdatedAt:
  16989. return m.OldUpdatedAt(ctx)
  16990. case labeltagging.FieldStatus:
  16991. return m.OldStatus(ctx)
  16992. case labeltagging.FieldDeletedAt:
  16993. return m.OldDeletedAt(ctx)
  16994. case labeltagging.FieldOrganizationID:
  16995. return m.OldOrganizationID(ctx)
  16996. case labeltagging.FieldType:
  16997. return m.OldType(ctx)
  16998. case labeltagging.FieldConditions:
  16999. return m.OldConditions(ctx)
  17000. case labeltagging.FieldActionLabelAdd:
  17001. return m.OldActionLabelAdd(ctx)
  17002. case labeltagging.FieldActionLabelDel:
  17003. return m.OldActionLabelDel(ctx)
  17004. }
  17005. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  17006. }
  17007. // SetField sets the value of a field with the given name. It returns an error if
  17008. // the field is not defined in the schema, or if the type mismatched the field
  17009. // type.
  17010. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  17011. switch name {
  17012. case labeltagging.FieldCreatedAt:
  17013. v, ok := value.(time.Time)
  17014. if !ok {
  17015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17016. }
  17017. m.SetCreatedAt(v)
  17018. return nil
  17019. case labeltagging.FieldUpdatedAt:
  17020. v, ok := value.(time.Time)
  17021. if !ok {
  17022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17023. }
  17024. m.SetUpdatedAt(v)
  17025. return nil
  17026. case labeltagging.FieldStatus:
  17027. v, ok := value.(uint8)
  17028. if !ok {
  17029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17030. }
  17031. m.SetStatus(v)
  17032. return nil
  17033. case labeltagging.FieldDeletedAt:
  17034. v, ok := value.(time.Time)
  17035. if !ok {
  17036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17037. }
  17038. m.SetDeletedAt(v)
  17039. return nil
  17040. case labeltagging.FieldOrganizationID:
  17041. v, ok := value.(uint64)
  17042. if !ok {
  17043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17044. }
  17045. m.SetOrganizationID(v)
  17046. return nil
  17047. case labeltagging.FieldType:
  17048. v, ok := value.(int)
  17049. if !ok {
  17050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17051. }
  17052. m.SetType(v)
  17053. return nil
  17054. case labeltagging.FieldConditions:
  17055. v, ok := value.(string)
  17056. if !ok {
  17057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17058. }
  17059. m.SetConditions(v)
  17060. return nil
  17061. case labeltagging.FieldActionLabelAdd:
  17062. v, ok := value.([]uint64)
  17063. if !ok {
  17064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17065. }
  17066. m.SetActionLabelAdd(v)
  17067. return nil
  17068. case labeltagging.FieldActionLabelDel:
  17069. v, ok := value.([]uint64)
  17070. if !ok {
  17071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17072. }
  17073. m.SetActionLabelDel(v)
  17074. return nil
  17075. }
  17076. return fmt.Errorf("unknown LabelTagging field %s", name)
  17077. }
  17078. // AddedFields returns all numeric fields that were incremented/decremented during
  17079. // this mutation.
  17080. func (m *LabelTaggingMutation) AddedFields() []string {
  17081. var fields []string
  17082. if m.addstatus != nil {
  17083. fields = append(fields, labeltagging.FieldStatus)
  17084. }
  17085. if m.addorganization_id != nil {
  17086. fields = append(fields, labeltagging.FieldOrganizationID)
  17087. }
  17088. if m.add_type != nil {
  17089. fields = append(fields, labeltagging.FieldType)
  17090. }
  17091. return fields
  17092. }
  17093. // AddedField returns the numeric value that was incremented/decremented on a field
  17094. // with the given name. The second boolean return value indicates that this field
  17095. // was not set, or was not defined in the schema.
  17096. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  17097. switch name {
  17098. case labeltagging.FieldStatus:
  17099. return m.AddedStatus()
  17100. case labeltagging.FieldOrganizationID:
  17101. return m.AddedOrganizationID()
  17102. case labeltagging.FieldType:
  17103. return m.AddedType()
  17104. }
  17105. return nil, false
  17106. }
  17107. // AddField adds the value to the field with the given name. It returns an error if
  17108. // the field is not defined in the schema, or if the type mismatched the field
  17109. // type.
  17110. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  17111. switch name {
  17112. case labeltagging.FieldStatus:
  17113. v, ok := value.(int8)
  17114. if !ok {
  17115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17116. }
  17117. m.AddStatus(v)
  17118. return nil
  17119. case labeltagging.FieldOrganizationID:
  17120. v, ok := value.(int64)
  17121. if !ok {
  17122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17123. }
  17124. m.AddOrganizationID(v)
  17125. return nil
  17126. case labeltagging.FieldType:
  17127. v, ok := value.(int)
  17128. if !ok {
  17129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17130. }
  17131. m.AddType(v)
  17132. return nil
  17133. }
  17134. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  17135. }
  17136. // ClearedFields returns all nullable fields that were cleared during this
  17137. // mutation.
  17138. func (m *LabelTaggingMutation) ClearedFields() []string {
  17139. var fields []string
  17140. if m.FieldCleared(labeltagging.FieldStatus) {
  17141. fields = append(fields, labeltagging.FieldStatus)
  17142. }
  17143. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  17144. fields = append(fields, labeltagging.FieldDeletedAt)
  17145. }
  17146. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  17147. fields = append(fields, labeltagging.FieldActionLabelAdd)
  17148. }
  17149. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  17150. fields = append(fields, labeltagging.FieldActionLabelDel)
  17151. }
  17152. return fields
  17153. }
  17154. // FieldCleared returns a boolean indicating if a field with the given name was
  17155. // cleared in this mutation.
  17156. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  17157. _, ok := m.clearedFields[name]
  17158. return ok
  17159. }
  17160. // ClearField clears the value of the field with the given name. It returns an
  17161. // error if the field is not defined in the schema.
  17162. func (m *LabelTaggingMutation) ClearField(name string) error {
  17163. switch name {
  17164. case labeltagging.FieldStatus:
  17165. m.ClearStatus()
  17166. return nil
  17167. case labeltagging.FieldDeletedAt:
  17168. m.ClearDeletedAt()
  17169. return nil
  17170. case labeltagging.FieldActionLabelAdd:
  17171. m.ClearActionLabelAdd()
  17172. return nil
  17173. case labeltagging.FieldActionLabelDel:
  17174. m.ClearActionLabelDel()
  17175. return nil
  17176. }
  17177. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  17178. }
  17179. // ResetField resets all changes in the mutation for the field with the given name.
  17180. // It returns an error if the field is not defined in the schema.
  17181. func (m *LabelTaggingMutation) ResetField(name string) error {
  17182. switch name {
  17183. case labeltagging.FieldCreatedAt:
  17184. m.ResetCreatedAt()
  17185. return nil
  17186. case labeltagging.FieldUpdatedAt:
  17187. m.ResetUpdatedAt()
  17188. return nil
  17189. case labeltagging.FieldStatus:
  17190. m.ResetStatus()
  17191. return nil
  17192. case labeltagging.FieldDeletedAt:
  17193. m.ResetDeletedAt()
  17194. return nil
  17195. case labeltagging.FieldOrganizationID:
  17196. m.ResetOrganizationID()
  17197. return nil
  17198. case labeltagging.FieldType:
  17199. m.ResetType()
  17200. return nil
  17201. case labeltagging.FieldConditions:
  17202. m.ResetConditions()
  17203. return nil
  17204. case labeltagging.FieldActionLabelAdd:
  17205. m.ResetActionLabelAdd()
  17206. return nil
  17207. case labeltagging.FieldActionLabelDel:
  17208. m.ResetActionLabelDel()
  17209. return nil
  17210. }
  17211. return fmt.Errorf("unknown LabelTagging field %s", name)
  17212. }
  17213. // AddedEdges returns all edge names that were set/added in this mutation.
  17214. func (m *LabelTaggingMutation) AddedEdges() []string {
  17215. edges := make([]string, 0, 0)
  17216. return edges
  17217. }
  17218. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17219. // name in this mutation.
  17220. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  17221. return nil
  17222. }
  17223. // RemovedEdges returns all edge names that were removed in this mutation.
  17224. func (m *LabelTaggingMutation) RemovedEdges() []string {
  17225. edges := make([]string, 0, 0)
  17226. return edges
  17227. }
  17228. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17229. // the given name in this mutation.
  17230. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  17231. return nil
  17232. }
  17233. // ClearedEdges returns all edge names that were cleared in this mutation.
  17234. func (m *LabelTaggingMutation) ClearedEdges() []string {
  17235. edges := make([]string, 0, 0)
  17236. return edges
  17237. }
  17238. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17239. // was cleared in this mutation.
  17240. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  17241. return false
  17242. }
  17243. // ClearEdge clears the value of the edge with the given name. It returns an error
  17244. // if that edge is not defined in the schema.
  17245. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  17246. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  17247. }
  17248. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17249. // It returns an error if the edge is not defined in the schema.
  17250. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  17251. return fmt.Errorf("unknown LabelTagging edge %s", name)
  17252. }
  17253. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  17254. type MessageMutation struct {
  17255. config
  17256. op Op
  17257. typ string
  17258. id *int
  17259. wx_wxid *string
  17260. wxid *string
  17261. content *string
  17262. clearedFields map[string]struct{}
  17263. done bool
  17264. oldValue func(context.Context) (*Message, error)
  17265. predicates []predicate.Message
  17266. }
  17267. var _ ent.Mutation = (*MessageMutation)(nil)
  17268. // messageOption allows management of the mutation configuration using functional options.
  17269. type messageOption func(*MessageMutation)
  17270. // newMessageMutation creates new mutation for the Message entity.
  17271. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  17272. m := &MessageMutation{
  17273. config: c,
  17274. op: op,
  17275. typ: TypeMessage,
  17276. clearedFields: make(map[string]struct{}),
  17277. }
  17278. for _, opt := range opts {
  17279. opt(m)
  17280. }
  17281. return m
  17282. }
  17283. // withMessageID sets the ID field of the mutation.
  17284. func withMessageID(id int) messageOption {
  17285. return func(m *MessageMutation) {
  17286. var (
  17287. err error
  17288. once sync.Once
  17289. value *Message
  17290. )
  17291. m.oldValue = func(ctx context.Context) (*Message, error) {
  17292. once.Do(func() {
  17293. if m.done {
  17294. err = errors.New("querying old values post mutation is not allowed")
  17295. } else {
  17296. value, err = m.Client().Message.Get(ctx, id)
  17297. }
  17298. })
  17299. return value, err
  17300. }
  17301. m.id = &id
  17302. }
  17303. }
  17304. // withMessage sets the old Message of the mutation.
  17305. func withMessage(node *Message) messageOption {
  17306. return func(m *MessageMutation) {
  17307. m.oldValue = func(context.Context) (*Message, error) {
  17308. return node, nil
  17309. }
  17310. m.id = &node.ID
  17311. }
  17312. }
  17313. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17314. // executed in a transaction (ent.Tx), a transactional client is returned.
  17315. func (m MessageMutation) Client() *Client {
  17316. client := &Client{config: m.config}
  17317. client.init()
  17318. return client
  17319. }
  17320. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17321. // it returns an error otherwise.
  17322. func (m MessageMutation) Tx() (*Tx, error) {
  17323. if _, ok := m.driver.(*txDriver); !ok {
  17324. return nil, errors.New("ent: mutation is not running in a transaction")
  17325. }
  17326. tx := &Tx{config: m.config}
  17327. tx.init()
  17328. return tx, nil
  17329. }
  17330. // ID returns the ID value in the mutation. Note that the ID is only available
  17331. // if it was provided to the builder or after it was returned from the database.
  17332. func (m *MessageMutation) ID() (id int, exists bool) {
  17333. if m.id == nil {
  17334. return
  17335. }
  17336. return *m.id, true
  17337. }
  17338. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17339. // That means, if the mutation is applied within a transaction with an isolation level such
  17340. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17341. // or updated by the mutation.
  17342. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  17343. switch {
  17344. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17345. id, exists := m.ID()
  17346. if exists {
  17347. return []int{id}, nil
  17348. }
  17349. fallthrough
  17350. case m.op.Is(OpUpdate | OpDelete):
  17351. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  17352. default:
  17353. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17354. }
  17355. }
  17356. // SetWxWxid sets the "wx_wxid" field.
  17357. func (m *MessageMutation) SetWxWxid(s string) {
  17358. m.wx_wxid = &s
  17359. }
  17360. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  17361. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  17362. v := m.wx_wxid
  17363. if v == nil {
  17364. return
  17365. }
  17366. return *v, true
  17367. }
  17368. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  17369. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17371. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  17372. if !m.op.Is(OpUpdateOne) {
  17373. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  17374. }
  17375. if m.id == nil || m.oldValue == nil {
  17376. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  17377. }
  17378. oldValue, err := m.oldValue(ctx)
  17379. if err != nil {
  17380. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  17381. }
  17382. return oldValue.WxWxid, nil
  17383. }
  17384. // ClearWxWxid clears the value of the "wx_wxid" field.
  17385. func (m *MessageMutation) ClearWxWxid() {
  17386. m.wx_wxid = nil
  17387. m.clearedFields[message.FieldWxWxid] = struct{}{}
  17388. }
  17389. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  17390. func (m *MessageMutation) WxWxidCleared() bool {
  17391. _, ok := m.clearedFields[message.FieldWxWxid]
  17392. return ok
  17393. }
  17394. // ResetWxWxid resets all changes to the "wx_wxid" field.
  17395. func (m *MessageMutation) ResetWxWxid() {
  17396. m.wx_wxid = nil
  17397. delete(m.clearedFields, message.FieldWxWxid)
  17398. }
  17399. // SetWxid sets the "wxid" field.
  17400. func (m *MessageMutation) SetWxid(s string) {
  17401. m.wxid = &s
  17402. }
  17403. // Wxid returns the value of the "wxid" field in the mutation.
  17404. func (m *MessageMutation) Wxid() (r string, exists bool) {
  17405. v := m.wxid
  17406. if v == nil {
  17407. return
  17408. }
  17409. return *v, true
  17410. }
  17411. // OldWxid returns the old "wxid" field's value of the Message entity.
  17412. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17414. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  17415. if !m.op.Is(OpUpdateOne) {
  17416. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  17417. }
  17418. if m.id == nil || m.oldValue == nil {
  17419. return v, errors.New("OldWxid requires an ID field in the mutation")
  17420. }
  17421. oldValue, err := m.oldValue(ctx)
  17422. if err != nil {
  17423. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  17424. }
  17425. return oldValue.Wxid, nil
  17426. }
  17427. // ResetWxid resets all changes to the "wxid" field.
  17428. func (m *MessageMutation) ResetWxid() {
  17429. m.wxid = nil
  17430. }
  17431. // SetContent sets the "content" field.
  17432. func (m *MessageMutation) SetContent(s string) {
  17433. m.content = &s
  17434. }
  17435. // Content returns the value of the "content" field in the mutation.
  17436. func (m *MessageMutation) Content() (r string, exists bool) {
  17437. v := m.content
  17438. if v == nil {
  17439. return
  17440. }
  17441. return *v, true
  17442. }
  17443. // OldContent returns the old "content" field's value of the Message entity.
  17444. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  17445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17446. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  17447. if !m.op.Is(OpUpdateOne) {
  17448. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17449. }
  17450. if m.id == nil || m.oldValue == nil {
  17451. return v, errors.New("OldContent requires an ID field in the mutation")
  17452. }
  17453. oldValue, err := m.oldValue(ctx)
  17454. if err != nil {
  17455. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17456. }
  17457. return oldValue.Content, nil
  17458. }
  17459. // ResetContent resets all changes to the "content" field.
  17460. func (m *MessageMutation) ResetContent() {
  17461. m.content = nil
  17462. }
  17463. // Where appends a list predicates to the MessageMutation builder.
  17464. func (m *MessageMutation) Where(ps ...predicate.Message) {
  17465. m.predicates = append(m.predicates, ps...)
  17466. }
  17467. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  17468. // users can use type-assertion to append predicates that do not depend on any generated package.
  17469. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  17470. p := make([]predicate.Message, len(ps))
  17471. for i := range ps {
  17472. p[i] = ps[i]
  17473. }
  17474. m.Where(p...)
  17475. }
  17476. // Op returns the operation name.
  17477. func (m *MessageMutation) Op() Op {
  17478. return m.op
  17479. }
  17480. // SetOp allows setting the mutation operation.
  17481. func (m *MessageMutation) SetOp(op Op) {
  17482. m.op = op
  17483. }
  17484. // Type returns the node type of this mutation (Message).
  17485. func (m *MessageMutation) Type() string {
  17486. return m.typ
  17487. }
  17488. // Fields returns all fields that were changed during this mutation. Note that in
  17489. // order to get all numeric fields that were incremented/decremented, call
  17490. // AddedFields().
  17491. func (m *MessageMutation) Fields() []string {
  17492. fields := make([]string, 0, 3)
  17493. if m.wx_wxid != nil {
  17494. fields = append(fields, message.FieldWxWxid)
  17495. }
  17496. if m.wxid != nil {
  17497. fields = append(fields, message.FieldWxid)
  17498. }
  17499. if m.content != nil {
  17500. fields = append(fields, message.FieldContent)
  17501. }
  17502. return fields
  17503. }
  17504. // Field returns the value of a field with the given name. The second boolean
  17505. // return value indicates that this field was not set, or was not defined in the
  17506. // schema.
  17507. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  17508. switch name {
  17509. case message.FieldWxWxid:
  17510. return m.WxWxid()
  17511. case message.FieldWxid:
  17512. return m.Wxid()
  17513. case message.FieldContent:
  17514. return m.Content()
  17515. }
  17516. return nil, false
  17517. }
  17518. // OldField returns the old value of the field from the database. An error is
  17519. // returned if the mutation operation is not UpdateOne, or the query to the
  17520. // database failed.
  17521. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17522. switch name {
  17523. case message.FieldWxWxid:
  17524. return m.OldWxWxid(ctx)
  17525. case message.FieldWxid:
  17526. return m.OldWxid(ctx)
  17527. case message.FieldContent:
  17528. return m.OldContent(ctx)
  17529. }
  17530. return nil, fmt.Errorf("unknown Message field %s", name)
  17531. }
  17532. // SetField sets the value of a field with the given name. It returns an error if
  17533. // the field is not defined in the schema, or if the type mismatched the field
  17534. // type.
  17535. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  17536. switch name {
  17537. case message.FieldWxWxid:
  17538. v, ok := value.(string)
  17539. if !ok {
  17540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17541. }
  17542. m.SetWxWxid(v)
  17543. return nil
  17544. case message.FieldWxid:
  17545. v, ok := value.(string)
  17546. if !ok {
  17547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17548. }
  17549. m.SetWxid(v)
  17550. return nil
  17551. case message.FieldContent:
  17552. v, ok := value.(string)
  17553. if !ok {
  17554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17555. }
  17556. m.SetContent(v)
  17557. return nil
  17558. }
  17559. return fmt.Errorf("unknown Message field %s", name)
  17560. }
  17561. // AddedFields returns all numeric fields that were incremented/decremented during
  17562. // this mutation.
  17563. func (m *MessageMutation) AddedFields() []string {
  17564. return nil
  17565. }
  17566. // AddedField returns the numeric value that was incremented/decremented on a field
  17567. // with the given name. The second boolean return value indicates that this field
  17568. // was not set, or was not defined in the schema.
  17569. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  17570. return nil, false
  17571. }
  17572. // AddField adds the value to the field with the given name. It returns an error if
  17573. // the field is not defined in the schema, or if the type mismatched the field
  17574. // type.
  17575. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  17576. switch name {
  17577. }
  17578. return fmt.Errorf("unknown Message numeric field %s", name)
  17579. }
  17580. // ClearedFields returns all nullable fields that were cleared during this
  17581. // mutation.
  17582. func (m *MessageMutation) ClearedFields() []string {
  17583. var fields []string
  17584. if m.FieldCleared(message.FieldWxWxid) {
  17585. fields = append(fields, message.FieldWxWxid)
  17586. }
  17587. return fields
  17588. }
  17589. // FieldCleared returns a boolean indicating if a field with the given name was
  17590. // cleared in this mutation.
  17591. func (m *MessageMutation) FieldCleared(name string) bool {
  17592. _, ok := m.clearedFields[name]
  17593. return ok
  17594. }
  17595. // ClearField clears the value of the field with the given name. It returns an
  17596. // error if the field is not defined in the schema.
  17597. func (m *MessageMutation) ClearField(name string) error {
  17598. switch name {
  17599. case message.FieldWxWxid:
  17600. m.ClearWxWxid()
  17601. return nil
  17602. }
  17603. return fmt.Errorf("unknown Message nullable field %s", name)
  17604. }
  17605. // ResetField resets all changes in the mutation for the field with the given name.
  17606. // It returns an error if the field is not defined in the schema.
  17607. func (m *MessageMutation) ResetField(name string) error {
  17608. switch name {
  17609. case message.FieldWxWxid:
  17610. m.ResetWxWxid()
  17611. return nil
  17612. case message.FieldWxid:
  17613. m.ResetWxid()
  17614. return nil
  17615. case message.FieldContent:
  17616. m.ResetContent()
  17617. return nil
  17618. }
  17619. return fmt.Errorf("unknown Message field %s", name)
  17620. }
  17621. // AddedEdges returns all edge names that were set/added in this mutation.
  17622. func (m *MessageMutation) AddedEdges() []string {
  17623. edges := make([]string, 0, 0)
  17624. return edges
  17625. }
  17626. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17627. // name in this mutation.
  17628. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  17629. return nil
  17630. }
  17631. // RemovedEdges returns all edge names that were removed in this mutation.
  17632. func (m *MessageMutation) RemovedEdges() []string {
  17633. edges := make([]string, 0, 0)
  17634. return edges
  17635. }
  17636. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17637. // the given name in this mutation.
  17638. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  17639. return nil
  17640. }
  17641. // ClearedEdges returns all edge names that were cleared in this mutation.
  17642. func (m *MessageMutation) ClearedEdges() []string {
  17643. edges := make([]string, 0, 0)
  17644. return edges
  17645. }
  17646. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17647. // was cleared in this mutation.
  17648. func (m *MessageMutation) EdgeCleared(name string) bool {
  17649. return false
  17650. }
  17651. // ClearEdge clears the value of the edge with the given name. It returns an error
  17652. // if that edge is not defined in the schema.
  17653. func (m *MessageMutation) ClearEdge(name string) error {
  17654. return fmt.Errorf("unknown Message unique edge %s", name)
  17655. }
  17656. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17657. // It returns an error if the edge is not defined in the schema.
  17658. func (m *MessageMutation) ResetEdge(name string) error {
  17659. return fmt.Errorf("unknown Message edge %s", name)
  17660. }
  17661. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  17662. type MessageRecordsMutation struct {
  17663. config
  17664. op Op
  17665. typ string
  17666. id *uint64
  17667. created_at *time.Time
  17668. updated_at *time.Time
  17669. status *uint8
  17670. addstatus *int8
  17671. bot_wxid *string
  17672. contact_type *int
  17673. addcontact_type *int
  17674. contact_wxid *string
  17675. content_type *int
  17676. addcontent_type *int
  17677. content *string
  17678. meta *custom_types.Meta
  17679. error_detail *string
  17680. send_time *time.Time
  17681. source_type *int
  17682. addsource_type *int
  17683. organization_id *uint64
  17684. addorganization_id *int64
  17685. clearedFields map[string]struct{}
  17686. sop_stage *uint64
  17687. clearedsop_stage bool
  17688. sop_node *uint64
  17689. clearedsop_node bool
  17690. message_contact *uint64
  17691. clearedmessage_contact bool
  17692. done bool
  17693. oldValue func(context.Context) (*MessageRecords, error)
  17694. predicates []predicate.MessageRecords
  17695. }
  17696. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  17697. // messagerecordsOption allows management of the mutation configuration using functional options.
  17698. type messagerecordsOption func(*MessageRecordsMutation)
  17699. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  17700. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  17701. m := &MessageRecordsMutation{
  17702. config: c,
  17703. op: op,
  17704. typ: TypeMessageRecords,
  17705. clearedFields: make(map[string]struct{}),
  17706. }
  17707. for _, opt := range opts {
  17708. opt(m)
  17709. }
  17710. return m
  17711. }
  17712. // withMessageRecordsID sets the ID field of the mutation.
  17713. func withMessageRecordsID(id uint64) messagerecordsOption {
  17714. return func(m *MessageRecordsMutation) {
  17715. var (
  17716. err error
  17717. once sync.Once
  17718. value *MessageRecords
  17719. )
  17720. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  17721. once.Do(func() {
  17722. if m.done {
  17723. err = errors.New("querying old values post mutation is not allowed")
  17724. } else {
  17725. value, err = m.Client().MessageRecords.Get(ctx, id)
  17726. }
  17727. })
  17728. return value, err
  17729. }
  17730. m.id = &id
  17731. }
  17732. }
  17733. // withMessageRecords sets the old MessageRecords of the mutation.
  17734. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  17735. return func(m *MessageRecordsMutation) {
  17736. m.oldValue = func(context.Context) (*MessageRecords, error) {
  17737. return node, nil
  17738. }
  17739. m.id = &node.ID
  17740. }
  17741. }
  17742. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17743. // executed in a transaction (ent.Tx), a transactional client is returned.
  17744. func (m MessageRecordsMutation) Client() *Client {
  17745. client := &Client{config: m.config}
  17746. client.init()
  17747. return client
  17748. }
  17749. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17750. // it returns an error otherwise.
  17751. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  17752. if _, ok := m.driver.(*txDriver); !ok {
  17753. return nil, errors.New("ent: mutation is not running in a transaction")
  17754. }
  17755. tx := &Tx{config: m.config}
  17756. tx.init()
  17757. return tx, nil
  17758. }
  17759. // SetID sets the value of the id field. Note that this
  17760. // operation is only accepted on creation of MessageRecords entities.
  17761. func (m *MessageRecordsMutation) SetID(id uint64) {
  17762. m.id = &id
  17763. }
  17764. // ID returns the ID value in the mutation. Note that the ID is only available
  17765. // if it was provided to the builder or after it was returned from the database.
  17766. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  17767. if m.id == nil {
  17768. return
  17769. }
  17770. return *m.id, true
  17771. }
  17772. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17773. // That means, if the mutation is applied within a transaction with an isolation level such
  17774. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17775. // or updated by the mutation.
  17776. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  17777. switch {
  17778. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17779. id, exists := m.ID()
  17780. if exists {
  17781. return []uint64{id}, nil
  17782. }
  17783. fallthrough
  17784. case m.op.Is(OpUpdate | OpDelete):
  17785. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  17786. default:
  17787. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17788. }
  17789. }
  17790. // SetCreatedAt sets the "created_at" field.
  17791. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  17792. m.created_at = &t
  17793. }
  17794. // CreatedAt returns the value of the "created_at" field in the mutation.
  17795. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  17796. v := m.created_at
  17797. if v == nil {
  17798. return
  17799. }
  17800. return *v, true
  17801. }
  17802. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  17803. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17805. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17806. if !m.op.Is(OpUpdateOne) {
  17807. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17808. }
  17809. if m.id == nil || m.oldValue == nil {
  17810. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17811. }
  17812. oldValue, err := m.oldValue(ctx)
  17813. if err != nil {
  17814. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17815. }
  17816. return oldValue.CreatedAt, nil
  17817. }
  17818. // ResetCreatedAt resets all changes to the "created_at" field.
  17819. func (m *MessageRecordsMutation) ResetCreatedAt() {
  17820. m.created_at = nil
  17821. }
  17822. // SetUpdatedAt sets the "updated_at" field.
  17823. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  17824. m.updated_at = &t
  17825. }
  17826. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17827. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  17828. v := m.updated_at
  17829. if v == nil {
  17830. return
  17831. }
  17832. return *v, true
  17833. }
  17834. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  17835. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17837. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17838. if !m.op.Is(OpUpdateOne) {
  17839. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17840. }
  17841. if m.id == nil || m.oldValue == nil {
  17842. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17843. }
  17844. oldValue, err := m.oldValue(ctx)
  17845. if err != nil {
  17846. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17847. }
  17848. return oldValue.UpdatedAt, nil
  17849. }
  17850. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17851. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  17852. m.updated_at = nil
  17853. }
  17854. // SetStatus sets the "status" field.
  17855. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  17856. m.status = &u
  17857. m.addstatus = nil
  17858. }
  17859. // Status returns the value of the "status" field in the mutation.
  17860. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  17861. v := m.status
  17862. if v == nil {
  17863. return
  17864. }
  17865. return *v, true
  17866. }
  17867. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  17868. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17870. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17871. if !m.op.Is(OpUpdateOne) {
  17872. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17873. }
  17874. if m.id == nil || m.oldValue == nil {
  17875. return v, errors.New("OldStatus requires an ID field in the mutation")
  17876. }
  17877. oldValue, err := m.oldValue(ctx)
  17878. if err != nil {
  17879. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17880. }
  17881. return oldValue.Status, nil
  17882. }
  17883. // AddStatus adds u to the "status" field.
  17884. func (m *MessageRecordsMutation) AddStatus(u int8) {
  17885. if m.addstatus != nil {
  17886. *m.addstatus += u
  17887. } else {
  17888. m.addstatus = &u
  17889. }
  17890. }
  17891. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17892. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  17893. v := m.addstatus
  17894. if v == nil {
  17895. return
  17896. }
  17897. return *v, true
  17898. }
  17899. // ClearStatus clears the value of the "status" field.
  17900. func (m *MessageRecordsMutation) ClearStatus() {
  17901. m.status = nil
  17902. m.addstatus = nil
  17903. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  17904. }
  17905. // StatusCleared returns if the "status" field was cleared in this mutation.
  17906. func (m *MessageRecordsMutation) StatusCleared() bool {
  17907. _, ok := m.clearedFields[messagerecords.FieldStatus]
  17908. return ok
  17909. }
  17910. // ResetStatus resets all changes to the "status" field.
  17911. func (m *MessageRecordsMutation) ResetStatus() {
  17912. m.status = nil
  17913. m.addstatus = nil
  17914. delete(m.clearedFields, messagerecords.FieldStatus)
  17915. }
  17916. // SetBotWxid sets the "bot_wxid" field.
  17917. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  17918. m.bot_wxid = &s
  17919. }
  17920. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  17921. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  17922. v := m.bot_wxid
  17923. if v == nil {
  17924. return
  17925. }
  17926. return *v, true
  17927. }
  17928. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  17929. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17931. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  17932. if !m.op.Is(OpUpdateOne) {
  17933. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  17934. }
  17935. if m.id == nil || m.oldValue == nil {
  17936. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  17937. }
  17938. oldValue, err := m.oldValue(ctx)
  17939. if err != nil {
  17940. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  17941. }
  17942. return oldValue.BotWxid, nil
  17943. }
  17944. // ResetBotWxid resets all changes to the "bot_wxid" field.
  17945. func (m *MessageRecordsMutation) ResetBotWxid() {
  17946. m.bot_wxid = nil
  17947. }
  17948. // SetContactID sets the "contact_id" field.
  17949. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  17950. m.message_contact = &u
  17951. }
  17952. // ContactID returns the value of the "contact_id" field in the mutation.
  17953. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  17954. v := m.message_contact
  17955. if v == nil {
  17956. return
  17957. }
  17958. return *v, true
  17959. }
  17960. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  17961. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17963. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  17964. if !m.op.Is(OpUpdateOne) {
  17965. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  17966. }
  17967. if m.id == nil || m.oldValue == nil {
  17968. return v, errors.New("OldContactID requires an ID field in the mutation")
  17969. }
  17970. oldValue, err := m.oldValue(ctx)
  17971. if err != nil {
  17972. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  17973. }
  17974. return oldValue.ContactID, nil
  17975. }
  17976. // ClearContactID clears the value of the "contact_id" field.
  17977. func (m *MessageRecordsMutation) ClearContactID() {
  17978. m.message_contact = nil
  17979. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17980. }
  17981. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  17982. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  17983. _, ok := m.clearedFields[messagerecords.FieldContactID]
  17984. return ok
  17985. }
  17986. // ResetContactID resets all changes to the "contact_id" field.
  17987. func (m *MessageRecordsMutation) ResetContactID() {
  17988. m.message_contact = nil
  17989. delete(m.clearedFields, messagerecords.FieldContactID)
  17990. }
  17991. // SetContactType sets the "contact_type" field.
  17992. func (m *MessageRecordsMutation) SetContactType(i int) {
  17993. m.contact_type = &i
  17994. m.addcontact_type = nil
  17995. }
  17996. // ContactType returns the value of the "contact_type" field in the mutation.
  17997. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  17998. v := m.contact_type
  17999. if v == nil {
  18000. return
  18001. }
  18002. return *v, true
  18003. }
  18004. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  18005. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18007. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  18008. if !m.op.Is(OpUpdateOne) {
  18009. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  18010. }
  18011. if m.id == nil || m.oldValue == nil {
  18012. return v, errors.New("OldContactType requires an ID field in the mutation")
  18013. }
  18014. oldValue, err := m.oldValue(ctx)
  18015. if err != nil {
  18016. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  18017. }
  18018. return oldValue.ContactType, nil
  18019. }
  18020. // AddContactType adds i to the "contact_type" field.
  18021. func (m *MessageRecordsMutation) AddContactType(i int) {
  18022. if m.addcontact_type != nil {
  18023. *m.addcontact_type += i
  18024. } else {
  18025. m.addcontact_type = &i
  18026. }
  18027. }
  18028. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  18029. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  18030. v := m.addcontact_type
  18031. if v == nil {
  18032. return
  18033. }
  18034. return *v, true
  18035. }
  18036. // ResetContactType resets all changes to the "contact_type" field.
  18037. func (m *MessageRecordsMutation) ResetContactType() {
  18038. m.contact_type = nil
  18039. m.addcontact_type = nil
  18040. }
  18041. // SetContactWxid sets the "contact_wxid" field.
  18042. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  18043. m.contact_wxid = &s
  18044. }
  18045. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  18046. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  18047. v := m.contact_wxid
  18048. if v == nil {
  18049. return
  18050. }
  18051. return *v, true
  18052. }
  18053. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  18054. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18056. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  18057. if !m.op.Is(OpUpdateOne) {
  18058. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  18059. }
  18060. if m.id == nil || m.oldValue == nil {
  18061. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  18062. }
  18063. oldValue, err := m.oldValue(ctx)
  18064. if err != nil {
  18065. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  18066. }
  18067. return oldValue.ContactWxid, nil
  18068. }
  18069. // ResetContactWxid resets all changes to the "contact_wxid" field.
  18070. func (m *MessageRecordsMutation) ResetContactWxid() {
  18071. m.contact_wxid = nil
  18072. }
  18073. // SetContentType sets the "content_type" field.
  18074. func (m *MessageRecordsMutation) SetContentType(i int) {
  18075. m.content_type = &i
  18076. m.addcontent_type = nil
  18077. }
  18078. // ContentType returns the value of the "content_type" field in the mutation.
  18079. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  18080. v := m.content_type
  18081. if v == nil {
  18082. return
  18083. }
  18084. return *v, true
  18085. }
  18086. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  18087. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18089. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  18090. if !m.op.Is(OpUpdateOne) {
  18091. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  18092. }
  18093. if m.id == nil || m.oldValue == nil {
  18094. return v, errors.New("OldContentType requires an ID field in the mutation")
  18095. }
  18096. oldValue, err := m.oldValue(ctx)
  18097. if err != nil {
  18098. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  18099. }
  18100. return oldValue.ContentType, nil
  18101. }
  18102. // AddContentType adds i to the "content_type" field.
  18103. func (m *MessageRecordsMutation) AddContentType(i int) {
  18104. if m.addcontent_type != nil {
  18105. *m.addcontent_type += i
  18106. } else {
  18107. m.addcontent_type = &i
  18108. }
  18109. }
  18110. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  18111. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  18112. v := m.addcontent_type
  18113. if v == nil {
  18114. return
  18115. }
  18116. return *v, true
  18117. }
  18118. // ResetContentType resets all changes to the "content_type" field.
  18119. func (m *MessageRecordsMutation) ResetContentType() {
  18120. m.content_type = nil
  18121. m.addcontent_type = nil
  18122. }
  18123. // SetContent sets the "content" field.
  18124. func (m *MessageRecordsMutation) SetContent(s string) {
  18125. m.content = &s
  18126. }
  18127. // Content returns the value of the "content" field in the mutation.
  18128. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  18129. v := m.content
  18130. if v == nil {
  18131. return
  18132. }
  18133. return *v, true
  18134. }
  18135. // OldContent returns the old "content" field's value of the MessageRecords entity.
  18136. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18138. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  18139. if !m.op.Is(OpUpdateOne) {
  18140. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18141. }
  18142. if m.id == nil || m.oldValue == nil {
  18143. return v, errors.New("OldContent requires an ID field in the mutation")
  18144. }
  18145. oldValue, err := m.oldValue(ctx)
  18146. if err != nil {
  18147. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18148. }
  18149. return oldValue.Content, nil
  18150. }
  18151. // ResetContent resets all changes to the "content" field.
  18152. func (m *MessageRecordsMutation) ResetContent() {
  18153. m.content = nil
  18154. }
  18155. // SetMeta sets the "meta" field.
  18156. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  18157. m.meta = &ct
  18158. }
  18159. // Meta returns the value of the "meta" field in the mutation.
  18160. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  18161. v := m.meta
  18162. if v == nil {
  18163. return
  18164. }
  18165. return *v, true
  18166. }
  18167. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  18168. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18170. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  18171. if !m.op.Is(OpUpdateOne) {
  18172. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  18173. }
  18174. if m.id == nil || m.oldValue == nil {
  18175. return v, errors.New("OldMeta requires an ID field in the mutation")
  18176. }
  18177. oldValue, err := m.oldValue(ctx)
  18178. if err != nil {
  18179. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  18180. }
  18181. return oldValue.Meta, nil
  18182. }
  18183. // ClearMeta clears the value of the "meta" field.
  18184. func (m *MessageRecordsMutation) ClearMeta() {
  18185. m.meta = nil
  18186. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  18187. }
  18188. // MetaCleared returns if the "meta" field was cleared in this mutation.
  18189. func (m *MessageRecordsMutation) MetaCleared() bool {
  18190. _, ok := m.clearedFields[messagerecords.FieldMeta]
  18191. return ok
  18192. }
  18193. // ResetMeta resets all changes to the "meta" field.
  18194. func (m *MessageRecordsMutation) ResetMeta() {
  18195. m.meta = nil
  18196. delete(m.clearedFields, messagerecords.FieldMeta)
  18197. }
  18198. // SetErrorDetail sets the "error_detail" field.
  18199. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  18200. m.error_detail = &s
  18201. }
  18202. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  18203. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  18204. v := m.error_detail
  18205. if v == nil {
  18206. return
  18207. }
  18208. return *v, true
  18209. }
  18210. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  18211. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18213. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  18214. if !m.op.Is(OpUpdateOne) {
  18215. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  18216. }
  18217. if m.id == nil || m.oldValue == nil {
  18218. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  18219. }
  18220. oldValue, err := m.oldValue(ctx)
  18221. if err != nil {
  18222. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  18223. }
  18224. return oldValue.ErrorDetail, nil
  18225. }
  18226. // ResetErrorDetail resets all changes to the "error_detail" field.
  18227. func (m *MessageRecordsMutation) ResetErrorDetail() {
  18228. m.error_detail = nil
  18229. }
  18230. // SetSendTime sets the "send_time" field.
  18231. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  18232. m.send_time = &t
  18233. }
  18234. // SendTime returns the value of the "send_time" field in the mutation.
  18235. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  18236. v := m.send_time
  18237. if v == nil {
  18238. return
  18239. }
  18240. return *v, true
  18241. }
  18242. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  18243. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18245. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  18246. if !m.op.Is(OpUpdateOne) {
  18247. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  18248. }
  18249. if m.id == nil || m.oldValue == nil {
  18250. return v, errors.New("OldSendTime requires an ID field in the mutation")
  18251. }
  18252. oldValue, err := m.oldValue(ctx)
  18253. if err != nil {
  18254. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  18255. }
  18256. return oldValue.SendTime, nil
  18257. }
  18258. // ClearSendTime clears the value of the "send_time" field.
  18259. func (m *MessageRecordsMutation) ClearSendTime() {
  18260. m.send_time = nil
  18261. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  18262. }
  18263. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  18264. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  18265. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  18266. return ok
  18267. }
  18268. // ResetSendTime resets all changes to the "send_time" field.
  18269. func (m *MessageRecordsMutation) ResetSendTime() {
  18270. m.send_time = nil
  18271. delete(m.clearedFields, messagerecords.FieldSendTime)
  18272. }
  18273. // SetSourceType sets the "source_type" field.
  18274. func (m *MessageRecordsMutation) SetSourceType(i int) {
  18275. m.source_type = &i
  18276. m.addsource_type = nil
  18277. }
  18278. // SourceType returns the value of the "source_type" field in the mutation.
  18279. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  18280. v := m.source_type
  18281. if v == nil {
  18282. return
  18283. }
  18284. return *v, true
  18285. }
  18286. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  18287. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18289. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  18290. if !m.op.Is(OpUpdateOne) {
  18291. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  18292. }
  18293. if m.id == nil || m.oldValue == nil {
  18294. return v, errors.New("OldSourceType requires an ID field in the mutation")
  18295. }
  18296. oldValue, err := m.oldValue(ctx)
  18297. if err != nil {
  18298. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  18299. }
  18300. return oldValue.SourceType, nil
  18301. }
  18302. // AddSourceType adds i to the "source_type" field.
  18303. func (m *MessageRecordsMutation) AddSourceType(i int) {
  18304. if m.addsource_type != nil {
  18305. *m.addsource_type += i
  18306. } else {
  18307. m.addsource_type = &i
  18308. }
  18309. }
  18310. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  18311. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  18312. v := m.addsource_type
  18313. if v == nil {
  18314. return
  18315. }
  18316. return *v, true
  18317. }
  18318. // ResetSourceType resets all changes to the "source_type" field.
  18319. func (m *MessageRecordsMutation) ResetSourceType() {
  18320. m.source_type = nil
  18321. m.addsource_type = nil
  18322. }
  18323. // SetSourceID sets the "source_id" field.
  18324. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  18325. m.sop_stage = &u
  18326. }
  18327. // SourceID returns the value of the "source_id" field in the mutation.
  18328. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  18329. v := m.sop_stage
  18330. if v == nil {
  18331. return
  18332. }
  18333. return *v, true
  18334. }
  18335. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  18336. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18338. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  18339. if !m.op.Is(OpUpdateOne) {
  18340. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  18341. }
  18342. if m.id == nil || m.oldValue == nil {
  18343. return v, errors.New("OldSourceID requires an ID field in the mutation")
  18344. }
  18345. oldValue, err := m.oldValue(ctx)
  18346. if err != nil {
  18347. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  18348. }
  18349. return oldValue.SourceID, nil
  18350. }
  18351. // ClearSourceID clears the value of the "source_id" field.
  18352. func (m *MessageRecordsMutation) ClearSourceID() {
  18353. m.sop_stage = nil
  18354. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  18355. }
  18356. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  18357. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  18358. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  18359. return ok
  18360. }
  18361. // ResetSourceID resets all changes to the "source_id" field.
  18362. func (m *MessageRecordsMutation) ResetSourceID() {
  18363. m.sop_stage = nil
  18364. delete(m.clearedFields, messagerecords.FieldSourceID)
  18365. }
  18366. // SetSubSourceID sets the "sub_source_id" field.
  18367. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  18368. m.sop_node = &u
  18369. }
  18370. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  18371. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  18372. v := m.sop_node
  18373. if v == nil {
  18374. return
  18375. }
  18376. return *v, true
  18377. }
  18378. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  18379. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18381. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  18382. if !m.op.Is(OpUpdateOne) {
  18383. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  18384. }
  18385. if m.id == nil || m.oldValue == nil {
  18386. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  18387. }
  18388. oldValue, err := m.oldValue(ctx)
  18389. if err != nil {
  18390. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  18391. }
  18392. return oldValue.SubSourceID, nil
  18393. }
  18394. // ClearSubSourceID clears the value of the "sub_source_id" field.
  18395. func (m *MessageRecordsMutation) ClearSubSourceID() {
  18396. m.sop_node = nil
  18397. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  18398. }
  18399. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  18400. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  18401. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  18402. return ok
  18403. }
  18404. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  18405. func (m *MessageRecordsMutation) ResetSubSourceID() {
  18406. m.sop_node = nil
  18407. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  18408. }
  18409. // SetOrganizationID sets the "organization_id" field.
  18410. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  18411. m.organization_id = &u
  18412. m.addorganization_id = nil
  18413. }
  18414. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18415. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  18416. v := m.organization_id
  18417. if v == nil {
  18418. return
  18419. }
  18420. return *v, true
  18421. }
  18422. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  18423. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  18424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18425. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18426. if !m.op.Is(OpUpdateOne) {
  18427. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18428. }
  18429. if m.id == nil || m.oldValue == nil {
  18430. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18431. }
  18432. oldValue, err := m.oldValue(ctx)
  18433. if err != nil {
  18434. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18435. }
  18436. return oldValue.OrganizationID, nil
  18437. }
  18438. // AddOrganizationID adds u to the "organization_id" field.
  18439. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  18440. if m.addorganization_id != nil {
  18441. *m.addorganization_id += u
  18442. } else {
  18443. m.addorganization_id = &u
  18444. }
  18445. }
  18446. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18447. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  18448. v := m.addorganization_id
  18449. if v == nil {
  18450. return
  18451. }
  18452. return *v, true
  18453. }
  18454. // ClearOrganizationID clears the value of the "organization_id" field.
  18455. func (m *MessageRecordsMutation) ClearOrganizationID() {
  18456. m.organization_id = nil
  18457. m.addorganization_id = nil
  18458. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  18459. }
  18460. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18461. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  18462. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  18463. return ok
  18464. }
  18465. // ResetOrganizationID resets all changes to the "organization_id" field.
  18466. func (m *MessageRecordsMutation) ResetOrganizationID() {
  18467. m.organization_id = nil
  18468. m.addorganization_id = nil
  18469. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  18470. }
  18471. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  18472. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  18473. m.sop_stage = &id
  18474. }
  18475. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  18476. func (m *MessageRecordsMutation) ClearSopStage() {
  18477. m.clearedsop_stage = true
  18478. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  18479. }
  18480. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  18481. func (m *MessageRecordsMutation) SopStageCleared() bool {
  18482. return m.SourceIDCleared() || m.clearedsop_stage
  18483. }
  18484. // SopStageID returns the "sop_stage" edge ID in the mutation.
  18485. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  18486. if m.sop_stage != nil {
  18487. return *m.sop_stage, true
  18488. }
  18489. return
  18490. }
  18491. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  18492. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18493. // SopStageID instead. It exists only for internal usage by the builders.
  18494. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  18495. if id := m.sop_stage; id != nil {
  18496. ids = append(ids, *id)
  18497. }
  18498. return
  18499. }
  18500. // ResetSopStage resets all changes to the "sop_stage" edge.
  18501. func (m *MessageRecordsMutation) ResetSopStage() {
  18502. m.sop_stage = nil
  18503. m.clearedsop_stage = false
  18504. }
  18505. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  18506. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  18507. m.sop_node = &id
  18508. }
  18509. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  18510. func (m *MessageRecordsMutation) ClearSopNode() {
  18511. m.clearedsop_node = true
  18512. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  18513. }
  18514. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  18515. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  18516. return m.SubSourceIDCleared() || m.clearedsop_node
  18517. }
  18518. // SopNodeID returns the "sop_node" edge ID in the mutation.
  18519. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  18520. if m.sop_node != nil {
  18521. return *m.sop_node, true
  18522. }
  18523. return
  18524. }
  18525. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  18526. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18527. // SopNodeID instead. It exists only for internal usage by the builders.
  18528. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  18529. if id := m.sop_node; id != nil {
  18530. ids = append(ids, *id)
  18531. }
  18532. return
  18533. }
  18534. // ResetSopNode resets all changes to the "sop_node" edge.
  18535. func (m *MessageRecordsMutation) ResetSopNode() {
  18536. m.sop_node = nil
  18537. m.clearedsop_node = false
  18538. }
  18539. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  18540. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  18541. m.message_contact = &id
  18542. }
  18543. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  18544. func (m *MessageRecordsMutation) ClearMessageContact() {
  18545. m.clearedmessage_contact = true
  18546. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  18547. }
  18548. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  18549. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  18550. return m.ContactIDCleared() || m.clearedmessage_contact
  18551. }
  18552. // MessageContactID returns the "message_contact" edge ID in the mutation.
  18553. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  18554. if m.message_contact != nil {
  18555. return *m.message_contact, true
  18556. }
  18557. return
  18558. }
  18559. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  18560. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18561. // MessageContactID instead. It exists only for internal usage by the builders.
  18562. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  18563. if id := m.message_contact; id != nil {
  18564. ids = append(ids, *id)
  18565. }
  18566. return
  18567. }
  18568. // ResetMessageContact resets all changes to the "message_contact" edge.
  18569. func (m *MessageRecordsMutation) ResetMessageContact() {
  18570. m.message_contact = nil
  18571. m.clearedmessage_contact = false
  18572. }
  18573. // Where appends a list predicates to the MessageRecordsMutation builder.
  18574. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  18575. m.predicates = append(m.predicates, ps...)
  18576. }
  18577. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  18578. // users can use type-assertion to append predicates that do not depend on any generated package.
  18579. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  18580. p := make([]predicate.MessageRecords, len(ps))
  18581. for i := range ps {
  18582. p[i] = ps[i]
  18583. }
  18584. m.Where(p...)
  18585. }
  18586. // Op returns the operation name.
  18587. func (m *MessageRecordsMutation) Op() Op {
  18588. return m.op
  18589. }
  18590. // SetOp allows setting the mutation operation.
  18591. func (m *MessageRecordsMutation) SetOp(op Op) {
  18592. m.op = op
  18593. }
  18594. // Type returns the node type of this mutation (MessageRecords).
  18595. func (m *MessageRecordsMutation) Type() string {
  18596. return m.typ
  18597. }
  18598. // Fields returns all fields that were changed during this mutation. Note that in
  18599. // order to get all numeric fields that were incremented/decremented, call
  18600. // AddedFields().
  18601. func (m *MessageRecordsMutation) Fields() []string {
  18602. fields := make([]string, 0, 16)
  18603. if m.created_at != nil {
  18604. fields = append(fields, messagerecords.FieldCreatedAt)
  18605. }
  18606. if m.updated_at != nil {
  18607. fields = append(fields, messagerecords.FieldUpdatedAt)
  18608. }
  18609. if m.status != nil {
  18610. fields = append(fields, messagerecords.FieldStatus)
  18611. }
  18612. if m.bot_wxid != nil {
  18613. fields = append(fields, messagerecords.FieldBotWxid)
  18614. }
  18615. if m.message_contact != nil {
  18616. fields = append(fields, messagerecords.FieldContactID)
  18617. }
  18618. if m.contact_type != nil {
  18619. fields = append(fields, messagerecords.FieldContactType)
  18620. }
  18621. if m.contact_wxid != nil {
  18622. fields = append(fields, messagerecords.FieldContactWxid)
  18623. }
  18624. if m.content_type != nil {
  18625. fields = append(fields, messagerecords.FieldContentType)
  18626. }
  18627. if m.content != nil {
  18628. fields = append(fields, messagerecords.FieldContent)
  18629. }
  18630. if m.meta != nil {
  18631. fields = append(fields, messagerecords.FieldMeta)
  18632. }
  18633. if m.error_detail != nil {
  18634. fields = append(fields, messagerecords.FieldErrorDetail)
  18635. }
  18636. if m.send_time != nil {
  18637. fields = append(fields, messagerecords.FieldSendTime)
  18638. }
  18639. if m.source_type != nil {
  18640. fields = append(fields, messagerecords.FieldSourceType)
  18641. }
  18642. if m.sop_stage != nil {
  18643. fields = append(fields, messagerecords.FieldSourceID)
  18644. }
  18645. if m.sop_node != nil {
  18646. fields = append(fields, messagerecords.FieldSubSourceID)
  18647. }
  18648. if m.organization_id != nil {
  18649. fields = append(fields, messagerecords.FieldOrganizationID)
  18650. }
  18651. return fields
  18652. }
  18653. // Field returns the value of a field with the given name. The second boolean
  18654. // return value indicates that this field was not set, or was not defined in the
  18655. // schema.
  18656. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  18657. switch name {
  18658. case messagerecords.FieldCreatedAt:
  18659. return m.CreatedAt()
  18660. case messagerecords.FieldUpdatedAt:
  18661. return m.UpdatedAt()
  18662. case messagerecords.FieldStatus:
  18663. return m.Status()
  18664. case messagerecords.FieldBotWxid:
  18665. return m.BotWxid()
  18666. case messagerecords.FieldContactID:
  18667. return m.ContactID()
  18668. case messagerecords.FieldContactType:
  18669. return m.ContactType()
  18670. case messagerecords.FieldContactWxid:
  18671. return m.ContactWxid()
  18672. case messagerecords.FieldContentType:
  18673. return m.ContentType()
  18674. case messagerecords.FieldContent:
  18675. return m.Content()
  18676. case messagerecords.FieldMeta:
  18677. return m.Meta()
  18678. case messagerecords.FieldErrorDetail:
  18679. return m.ErrorDetail()
  18680. case messagerecords.FieldSendTime:
  18681. return m.SendTime()
  18682. case messagerecords.FieldSourceType:
  18683. return m.SourceType()
  18684. case messagerecords.FieldSourceID:
  18685. return m.SourceID()
  18686. case messagerecords.FieldSubSourceID:
  18687. return m.SubSourceID()
  18688. case messagerecords.FieldOrganizationID:
  18689. return m.OrganizationID()
  18690. }
  18691. return nil, false
  18692. }
  18693. // OldField returns the old value of the field from the database. An error is
  18694. // returned if the mutation operation is not UpdateOne, or the query to the
  18695. // database failed.
  18696. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18697. switch name {
  18698. case messagerecords.FieldCreatedAt:
  18699. return m.OldCreatedAt(ctx)
  18700. case messagerecords.FieldUpdatedAt:
  18701. return m.OldUpdatedAt(ctx)
  18702. case messagerecords.FieldStatus:
  18703. return m.OldStatus(ctx)
  18704. case messagerecords.FieldBotWxid:
  18705. return m.OldBotWxid(ctx)
  18706. case messagerecords.FieldContactID:
  18707. return m.OldContactID(ctx)
  18708. case messagerecords.FieldContactType:
  18709. return m.OldContactType(ctx)
  18710. case messagerecords.FieldContactWxid:
  18711. return m.OldContactWxid(ctx)
  18712. case messagerecords.FieldContentType:
  18713. return m.OldContentType(ctx)
  18714. case messagerecords.FieldContent:
  18715. return m.OldContent(ctx)
  18716. case messagerecords.FieldMeta:
  18717. return m.OldMeta(ctx)
  18718. case messagerecords.FieldErrorDetail:
  18719. return m.OldErrorDetail(ctx)
  18720. case messagerecords.FieldSendTime:
  18721. return m.OldSendTime(ctx)
  18722. case messagerecords.FieldSourceType:
  18723. return m.OldSourceType(ctx)
  18724. case messagerecords.FieldSourceID:
  18725. return m.OldSourceID(ctx)
  18726. case messagerecords.FieldSubSourceID:
  18727. return m.OldSubSourceID(ctx)
  18728. case messagerecords.FieldOrganizationID:
  18729. return m.OldOrganizationID(ctx)
  18730. }
  18731. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  18732. }
  18733. // SetField sets the value of a field with the given name. It returns an error if
  18734. // the field is not defined in the schema, or if the type mismatched the field
  18735. // type.
  18736. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  18737. switch name {
  18738. case messagerecords.FieldCreatedAt:
  18739. v, ok := value.(time.Time)
  18740. if !ok {
  18741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18742. }
  18743. m.SetCreatedAt(v)
  18744. return nil
  18745. case messagerecords.FieldUpdatedAt:
  18746. v, ok := value.(time.Time)
  18747. if !ok {
  18748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18749. }
  18750. m.SetUpdatedAt(v)
  18751. return nil
  18752. case messagerecords.FieldStatus:
  18753. v, ok := value.(uint8)
  18754. if !ok {
  18755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18756. }
  18757. m.SetStatus(v)
  18758. return nil
  18759. case messagerecords.FieldBotWxid:
  18760. v, ok := value.(string)
  18761. if !ok {
  18762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18763. }
  18764. m.SetBotWxid(v)
  18765. return nil
  18766. case messagerecords.FieldContactID:
  18767. v, ok := value.(uint64)
  18768. if !ok {
  18769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18770. }
  18771. m.SetContactID(v)
  18772. return nil
  18773. case messagerecords.FieldContactType:
  18774. v, ok := value.(int)
  18775. if !ok {
  18776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18777. }
  18778. m.SetContactType(v)
  18779. return nil
  18780. case messagerecords.FieldContactWxid:
  18781. v, ok := value.(string)
  18782. if !ok {
  18783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18784. }
  18785. m.SetContactWxid(v)
  18786. return nil
  18787. case messagerecords.FieldContentType:
  18788. v, ok := value.(int)
  18789. if !ok {
  18790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18791. }
  18792. m.SetContentType(v)
  18793. return nil
  18794. case messagerecords.FieldContent:
  18795. v, ok := value.(string)
  18796. if !ok {
  18797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18798. }
  18799. m.SetContent(v)
  18800. return nil
  18801. case messagerecords.FieldMeta:
  18802. v, ok := value.(custom_types.Meta)
  18803. if !ok {
  18804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18805. }
  18806. m.SetMeta(v)
  18807. return nil
  18808. case messagerecords.FieldErrorDetail:
  18809. v, ok := value.(string)
  18810. if !ok {
  18811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18812. }
  18813. m.SetErrorDetail(v)
  18814. return nil
  18815. case messagerecords.FieldSendTime:
  18816. v, ok := value.(time.Time)
  18817. if !ok {
  18818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18819. }
  18820. m.SetSendTime(v)
  18821. return nil
  18822. case messagerecords.FieldSourceType:
  18823. v, ok := value.(int)
  18824. if !ok {
  18825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18826. }
  18827. m.SetSourceType(v)
  18828. return nil
  18829. case messagerecords.FieldSourceID:
  18830. v, ok := value.(uint64)
  18831. if !ok {
  18832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18833. }
  18834. m.SetSourceID(v)
  18835. return nil
  18836. case messagerecords.FieldSubSourceID:
  18837. v, ok := value.(uint64)
  18838. if !ok {
  18839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18840. }
  18841. m.SetSubSourceID(v)
  18842. return nil
  18843. case messagerecords.FieldOrganizationID:
  18844. v, ok := value.(uint64)
  18845. if !ok {
  18846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18847. }
  18848. m.SetOrganizationID(v)
  18849. return nil
  18850. }
  18851. return fmt.Errorf("unknown MessageRecords field %s", name)
  18852. }
  18853. // AddedFields returns all numeric fields that were incremented/decremented during
  18854. // this mutation.
  18855. func (m *MessageRecordsMutation) AddedFields() []string {
  18856. var fields []string
  18857. if m.addstatus != nil {
  18858. fields = append(fields, messagerecords.FieldStatus)
  18859. }
  18860. if m.addcontact_type != nil {
  18861. fields = append(fields, messagerecords.FieldContactType)
  18862. }
  18863. if m.addcontent_type != nil {
  18864. fields = append(fields, messagerecords.FieldContentType)
  18865. }
  18866. if m.addsource_type != nil {
  18867. fields = append(fields, messagerecords.FieldSourceType)
  18868. }
  18869. if m.addorganization_id != nil {
  18870. fields = append(fields, messagerecords.FieldOrganizationID)
  18871. }
  18872. return fields
  18873. }
  18874. // AddedField returns the numeric value that was incremented/decremented on a field
  18875. // with the given name. The second boolean return value indicates that this field
  18876. // was not set, or was not defined in the schema.
  18877. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  18878. switch name {
  18879. case messagerecords.FieldStatus:
  18880. return m.AddedStatus()
  18881. case messagerecords.FieldContactType:
  18882. return m.AddedContactType()
  18883. case messagerecords.FieldContentType:
  18884. return m.AddedContentType()
  18885. case messagerecords.FieldSourceType:
  18886. return m.AddedSourceType()
  18887. case messagerecords.FieldOrganizationID:
  18888. return m.AddedOrganizationID()
  18889. }
  18890. return nil, false
  18891. }
  18892. // AddField adds the value to the field with the given name. It returns an error if
  18893. // the field is not defined in the schema, or if the type mismatched the field
  18894. // type.
  18895. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  18896. switch name {
  18897. case messagerecords.FieldStatus:
  18898. v, ok := value.(int8)
  18899. if !ok {
  18900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18901. }
  18902. m.AddStatus(v)
  18903. return nil
  18904. case messagerecords.FieldContactType:
  18905. v, ok := value.(int)
  18906. if !ok {
  18907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18908. }
  18909. m.AddContactType(v)
  18910. return nil
  18911. case messagerecords.FieldContentType:
  18912. v, ok := value.(int)
  18913. if !ok {
  18914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18915. }
  18916. m.AddContentType(v)
  18917. return nil
  18918. case messagerecords.FieldSourceType:
  18919. v, ok := value.(int)
  18920. if !ok {
  18921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18922. }
  18923. m.AddSourceType(v)
  18924. return nil
  18925. case messagerecords.FieldOrganizationID:
  18926. v, ok := value.(int64)
  18927. if !ok {
  18928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18929. }
  18930. m.AddOrganizationID(v)
  18931. return nil
  18932. }
  18933. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  18934. }
  18935. // ClearedFields returns all nullable fields that were cleared during this
  18936. // mutation.
  18937. func (m *MessageRecordsMutation) ClearedFields() []string {
  18938. var fields []string
  18939. if m.FieldCleared(messagerecords.FieldStatus) {
  18940. fields = append(fields, messagerecords.FieldStatus)
  18941. }
  18942. if m.FieldCleared(messagerecords.FieldContactID) {
  18943. fields = append(fields, messagerecords.FieldContactID)
  18944. }
  18945. if m.FieldCleared(messagerecords.FieldMeta) {
  18946. fields = append(fields, messagerecords.FieldMeta)
  18947. }
  18948. if m.FieldCleared(messagerecords.FieldSendTime) {
  18949. fields = append(fields, messagerecords.FieldSendTime)
  18950. }
  18951. if m.FieldCleared(messagerecords.FieldSourceID) {
  18952. fields = append(fields, messagerecords.FieldSourceID)
  18953. }
  18954. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  18955. fields = append(fields, messagerecords.FieldSubSourceID)
  18956. }
  18957. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  18958. fields = append(fields, messagerecords.FieldOrganizationID)
  18959. }
  18960. return fields
  18961. }
  18962. // FieldCleared returns a boolean indicating if a field with the given name was
  18963. // cleared in this mutation.
  18964. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  18965. _, ok := m.clearedFields[name]
  18966. return ok
  18967. }
  18968. // ClearField clears the value of the field with the given name. It returns an
  18969. // error if the field is not defined in the schema.
  18970. func (m *MessageRecordsMutation) ClearField(name string) error {
  18971. switch name {
  18972. case messagerecords.FieldStatus:
  18973. m.ClearStatus()
  18974. return nil
  18975. case messagerecords.FieldContactID:
  18976. m.ClearContactID()
  18977. return nil
  18978. case messagerecords.FieldMeta:
  18979. m.ClearMeta()
  18980. return nil
  18981. case messagerecords.FieldSendTime:
  18982. m.ClearSendTime()
  18983. return nil
  18984. case messagerecords.FieldSourceID:
  18985. m.ClearSourceID()
  18986. return nil
  18987. case messagerecords.FieldSubSourceID:
  18988. m.ClearSubSourceID()
  18989. return nil
  18990. case messagerecords.FieldOrganizationID:
  18991. m.ClearOrganizationID()
  18992. return nil
  18993. }
  18994. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  18995. }
  18996. // ResetField resets all changes in the mutation for the field with the given name.
  18997. // It returns an error if the field is not defined in the schema.
  18998. func (m *MessageRecordsMutation) ResetField(name string) error {
  18999. switch name {
  19000. case messagerecords.FieldCreatedAt:
  19001. m.ResetCreatedAt()
  19002. return nil
  19003. case messagerecords.FieldUpdatedAt:
  19004. m.ResetUpdatedAt()
  19005. return nil
  19006. case messagerecords.FieldStatus:
  19007. m.ResetStatus()
  19008. return nil
  19009. case messagerecords.FieldBotWxid:
  19010. m.ResetBotWxid()
  19011. return nil
  19012. case messagerecords.FieldContactID:
  19013. m.ResetContactID()
  19014. return nil
  19015. case messagerecords.FieldContactType:
  19016. m.ResetContactType()
  19017. return nil
  19018. case messagerecords.FieldContactWxid:
  19019. m.ResetContactWxid()
  19020. return nil
  19021. case messagerecords.FieldContentType:
  19022. m.ResetContentType()
  19023. return nil
  19024. case messagerecords.FieldContent:
  19025. m.ResetContent()
  19026. return nil
  19027. case messagerecords.FieldMeta:
  19028. m.ResetMeta()
  19029. return nil
  19030. case messagerecords.FieldErrorDetail:
  19031. m.ResetErrorDetail()
  19032. return nil
  19033. case messagerecords.FieldSendTime:
  19034. m.ResetSendTime()
  19035. return nil
  19036. case messagerecords.FieldSourceType:
  19037. m.ResetSourceType()
  19038. return nil
  19039. case messagerecords.FieldSourceID:
  19040. m.ResetSourceID()
  19041. return nil
  19042. case messagerecords.FieldSubSourceID:
  19043. m.ResetSubSourceID()
  19044. return nil
  19045. case messagerecords.FieldOrganizationID:
  19046. m.ResetOrganizationID()
  19047. return nil
  19048. }
  19049. return fmt.Errorf("unknown MessageRecords field %s", name)
  19050. }
  19051. // AddedEdges returns all edge names that were set/added in this mutation.
  19052. func (m *MessageRecordsMutation) AddedEdges() []string {
  19053. edges := make([]string, 0, 3)
  19054. if m.sop_stage != nil {
  19055. edges = append(edges, messagerecords.EdgeSopStage)
  19056. }
  19057. if m.sop_node != nil {
  19058. edges = append(edges, messagerecords.EdgeSopNode)
  19059. }
  19060. if m.message_contact != nil {
  19061. edges = append(edges, messagerecords.EdgeMessageContact)
  19062. }
  19063. return edges
  19064. }
  19065. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19066. // name in this mutation.
  19067. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  19068. switch name {
  19069. case messagerecords.EdgeSopStage:
  19070. if id := m.sop_stage; id != nil {
  19071. return []ent.Value{*id}
  19072. }
  19073. case messagerecords.EdgeSopNode:
  19074. if id := m.sop_node; id != nil {
  19075. return []ent.Value{*id}
  19076. }
  19077. case messagerecords.EdgeMessageContact:
  19078. if id := m.message_contact; id != nil {
  19079. return []ent.Value{*id}
  19080. }
  19081. }
  19082. return nil
  19083. }
  19084. // RemovedEdges returns all edge names that were removed in this mutation.
  19085. func (m *MessageRecordsMutation) RemovedEdges() []string {
  19086. edges := make([]string, 0, 3)
  19087. return edges
  19088. }
  19089. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19090. // the given name in this mutation.
  19091. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  19092. return nil
  19093. }
  19094. // ClearedEdges returns all edge names that were cleared in this mutation.
  19095. func (m *MessageRecordsMutation) ClearedEdges() []string {
  19096. edges := make([]string, 0, 3)
  19097. if m.clearedsop_stage {
  19098. edges = append(edges, messagerecords.EdgeSopStage)
  19099. }
  19100. if m.clearedsop_node {
  19101. edges = append(edges, messagerecords.EdgeSopNode)
  19102. }
  19103. if m.clearedmessage_contact {
  19104. edges = append(edges, messagerecords.EdgeMessageContact)
  19105. }
  19106. return edges
  19107. }
  19108. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19109. // was cleared in this mutation.
  19110. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  19111. switch name {
  19112. case messagerecords.EdgeSopStage:
  19113. return m.clearedsop_stage
  19114. case messagerecords.EdgeSopNode:
  19115. return m.clearedsop_node
  19116. case messagerecords.EdgeMessageContact:
  19117. return m.clearedmessage_contact
  19118. }
  19119. return false
  19120. }
  19121. // ClearEdge clears the value of the edge with the given name. It returns an error
  19122. // if that edge is not defined in the schema.
  19123. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  19124. switch name {
  19125. case messagerecords.EdgeSopStage:
  19126. m.ClearSopStage()
  19127. return nil
  19128. case messagerecords.EdgeSopNode:
  19129. m.ClearSopNode()
  19130. return nil
  19131. case messagerecords.EdgeMessageContact:
  19132. m.ClearMessageContact()
  19133. return nil
  19134. }
  19135. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  19136. }
  19137. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19138. // It returns an error if the edge is not defined in the schema.
  19139. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  19140. switch name {
  19141. case messagerecords.EdgeSopStage:
  19142. m.ResetSopStage()
  19143. return nil
  19144. case messagerecords.EdgeSopNode:
  19145. m.ResetSopNode()
  19146. return nil
  19147. case messagerecords.EdgeMessageContact:
  19148. m.ResetMessageContact()
  19149. return nil
  19150. }
  19151. return fmt.Errorf("unknown MessageRecords edge %s", name)
  19152. }
  19153. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  19154. type MsgMutation struct {
  19155. config
  19156. op Op
  19157. typ string
  19158. id *uint64
  19159. created_at *time.Time
  19160. updated_at *time.Time
  19161. deleted_at *time.Time
  19162. status *uint8
  19163. addstatus *int8
  19164. fromwxid *string
  19165. toid *string
  19166. msgtype *int32
  19167. addmsgtype *int32
  19168. msg *string
  19169. batch_no *string
  19170. cc *string
  19171. phone *string
  19172. clearedFields map[string]struct{}
  19173. done bool
  19174. oldValue func(context.Context) (*Msg, error)
  19175. predicates []predicate.Msg
  19176. }
  19177. var _ ent.Mutation = (*MsgMutation)(nil)
  19178. // msgOption allows management of the mutation configuration using functional options.
  19179. type msgOption func(*MsgMutation)
  19180. // newMsgMutation creates new mutation for the Msg entity.
  19181. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  19182. m := &MsgMutation{
  19183. config: c,
  19184. op: op,
  19185. typ: TypeMsg,
  19186. clearedFields: make(map[string]struct{}),
  19187. }
  19188. for _, opt := range opts {
  19189. opt(m)
  19190. }
  19191. return m
  19192. }
  19193. // withMsgID sets the ID field of the mutation.
  19194. func withMsgID(id uint64) msgOption {
  19195. return func(m *MsgMutation) {
  19196. var (
  19197. err error
  19198. once sync.Once
  19199. value *Msg
  19200. )
  19201. m.oldValue = func(ctx context.Context) (*Msg, error) {
  19202. once.Do(func() {
  19203. if m.done {
  19204. err = errors.New("querying old values post mutation is not allowed")
  19205. } else {
  19206. value, err = m.Client().Msg.Get(ctx, id)
  19207. }
  19208. })
  19209. return value, err
  19210. }
  19211. m.id = &id
  19212. }
  19213. }
  19214. // withMsg sets the old Msg of the mutation.
  19215. func withMsg(node *Msg) msgOption {
  19216. return func(m *MsgMutation) {
  19217. m.oldValue = func(context.Context) (*Msg, error) {
  19218. return node, nil
  19219. }
  19220. m.id = &node.ID
  19221. }
  19222. }
  19223. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19224. // executed in a transaction (ent.Tx), a transactional client is returned.
  19225. func (m MsgMutation) Client() *Client {
  19226. client := &Client{config: m.config}
  19227. client.init()
  19228. return client
  19229. }
  19230. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19231. // it returns an error otherwise.
  19232. func (m MsgMutation) Tx() (*Tx, error) {
  19233. if _, ok := m.driver.(*txDriver); !ok {
  19234. return nil, errors.New("ent: mutation is not running in a transaction")
  19235. }
  19236. tx := &Tx{config: m.config}
  19237. tx.init()
  19238. return tx, nil
  19239. }
  19240. // SetID sets the value of the id field. Note that this
  19241. // operation is only accepted on creation of Msg entities.
  19242. func (m *MsgMutation) SetID(id uint64) {
  19243. m.id = &id
  19244. }
  19245. // ID returns the ID value in the mutation. Note that the ID is only available
  19246. // if it was provided to the builder or after it was returned from the database.
  19247. func (m *MsgMutation) ID() (id uint64, exists bool) {
  19248. if m.id == nil {
  19249. return
  19250. }
  19251. return *m.id, true
  19252. }
  19253. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19254. // That means, if the mutation is applied within a transaction with an isolation level such
  19255. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19256. // or updated by the mutation.
  19257. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  19258. switch {
  19259. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19260. id, exists := m.ID()
  19261. if exists {
  19262. return []uint64{id}, nil
  19263. }
  19264. fallthrough
  19265. case m.op.Is(OpUpdate | OpDelete):
  19266. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  19267. default:
  19268. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19269. }
  19270. }
  19271. // SetCreatedAt sets the "created_at" field.
  19272. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  19273. m.created_at = &t
  19274. }
  19275. // CreatedAt returns the value of the "created_at" field in the mutation.
  19276. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  19277. v := m.created_at
  19278. if v == nil {
  19279. return
  19280. }
  19281. return *v, true
  19282. }
  19283. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  19284. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19286. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19287. if !m.op.Is(OpUpdateOne) {
  19288. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19289. }
  19290. if m.id == nil || m.oldValue == nil {
  19291. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19292. }
  19293. oldValue, err := m.oldValue(ctx)
  19294. if err != nil {
  19295. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19296. }
  19297. return oldValue.CreatedAt, nil
  19298. }
  19299. // ResetCreatedAt resets all changes to the "created_at" field.
  19300. func (m *MsgMutation) ResetCreatedAt() {
  19301. m.created_at = nil
  19302. }
  19303. // SetUpdatedAt sets the "updated_at" field.
  19304. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  19305. m.updated_at = &t
  19306. }
  19307. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19308. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  19309. v := m.updated_at
  19310. if v == nil {
  19311. return
  19312. }
  19313. return *v, true
  19314. }
  19315. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  19316. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19318. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19319. if !m.op.Is(OpUpdateOne) {
  19320. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19321. }
  19322. if m.id == nil || m.oldValue == nil {
  19323. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19324. }
  19325. oldValue, err := m.oldValue(ctx)
  19326. if err != nil {
  19327. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19328. }
  19329. return oldValue.UpdatedAt, nil
  19330. }
  19331. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19332. func (m *MsgMutation) ResetUpdatedAt() {
  19333. m.updated_at = nil
  19334. }
  19335. // SetDeletedAt sets the "deleted_at" field.
  19336. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  19337. m.deleted_at = &t
  19338. }
  19339. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19340. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  19341. v := m.deleted_at
  19342. if v == nil {
  19343. return
  19344. }
  19345. return *v, true
  19346. }
  19347. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  19348. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19350. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19351. if !m.op.Is(OpUpdateOne) {
  19352. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19353. }
  19354. if m.id == nil || m.oldValue == nil {
  19355. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19356. }
  19357. oldValue, err := m.oldValue(ctx)
  19358. if err != nil {
  19359. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19360. }
  19361. return oldValue.DeletedAt, nil
  19362. }
  19363. // ClearDeletedAt clears the value of the "deleted_at" field.
  19364. func (m *MsgMutation) ClearDeletedAt() {
  19365. m.deleted_at = nil
  19366. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  19367. }
  19368. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19369. func (m *MsgMutation) DeletedAtCleared() bool {
  19370. _, ok := m.clearedFields[msg.FieldDeletedAt]
  19371. return ok
  19372. }
  19373. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19374. func (m *MsgMutation) ResetDeletedAt() {
  19375. m.deleted_at = nil
  19376. delete(m.clearedFields, msg.FieldDeletedAt)
  19377. }
  19378. // SetStatus sets the "status" field.
  19379. func (m *MsgMutation) SetStatus(u uint8) {
  19380. m.status = &u
  19381. m.addstatus = nil
  19382. }
  19383. // Status returns the value of the "status" field in the mutation.
  19384. func (m *MsgMutation) Status() (r uint8, exists bool) {
  19385. v := m.status
  19386. if v == nil {
  19387. return
  19388. }
  19389. return *v, true
  19390. }
  19391. // OldStatus returns the old "status" field's value of the Msg entity.
  19392. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19394. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19395. if !m.op.Is(OpUpdateOne) {
  19396. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19397. }
  19398. if m.id == nil || m.oldValue == nil {
  19399. return v, errors.New("OldStatus requires an ID field in the mutation")
  19400. }
  19401. oldValue, err := m.oldValue(ctx)
  19402. if err != nil {
  19403. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19404. }
  19405. return oldValue.Status, nil
  19406. }
  19407. // AddStatus adds u to the "status" field.
  19408. func (m *MsgMutation) AddStatus(u int8) {
  19409. if m.addstatus != nil {
  19410. *m.addstatus += u
  19411. } else {
  19412. m.addstatus = &u
  19413. }
  19414. }
  19415. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19416. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  19417. v := m.addstatus
  19418. if v == nil {
  19419. return
  19420. }
  19421. return *v, true
  19422. }
  19423. // ClearStatus clears the value of the "status" field.
  19424. func (m *MsgMutation) ClearStatus() {
  19425. m.status = nil
  19426. m.addstatus = nil
  19427. m.clearedFields[msg.FieldStatus] = struct{}{}
  19428. }
  19429. // StatusCleared returns if the "status" field was cleared in this mutation.
  19430. func (m *MsgMutation) StatusCleared() bool {
  19431. _, ok := m.clearedFields[msg.FieldStatus]
  19432. return ok
  19433. }
  19434. // ResetStatus resets all changes to the "status" field.
  19435. func (m *MsgMutation) ResetStatus() {
  19436. m.status = nil
  19437. m.addstatus = nil
  19438. delete(m.clearedFields, msg.FieldStatus)
  19439. }
  19440. // SetFromwxid sets the "fromwxid" field.
  19441. func (m *MsgMutation) SetFromwxid(s string) {
  19442. m.fromwxid = &s
  19443. }
  19444. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  19445. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  19446. v := m.fromwxid
  19447. if v == nil {
  19448. return
  19449. }
  19450. return *v, true
  19451. }
  19452. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  19453. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19455. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  19456. if !m.op.Is(OpUpdateOne) {
  19457. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  19458. }
  19459. if m.id == nil || m.oldValue == nil {
  19460. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  19461. }
  19462. oldValue, err := m.oldValue(ctx)
  19463. if err != nil {
  19464. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  19465. }
  19466. return oldValue.Fromwxid, nil
  19467. }
  19468. // ClearFromwxid clears the value of the "fromwxid" field.
  19469. func (m *MsgMutation) ClearFromwxid() {
  19470. m.fromwxid = nil
  19471. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  19472. }
  19473. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  19474. func (m *MsgMutation) FromwxidCleared() bool {
  19475. _, ok := m.clearedFields[msg.FieldFromwxid]
  19476. return ok
  19477. }
  19478. // ResetFromwxid resets all changes to the "fromwxid" field.
  19479. func (m *MsgMutation) ResetFromwxid() {
  19480. m.fromwxid = nil
  19481. delete(m.clearedFields, msg.FieldFromwxid)
  19482. }
  19483. // SetToid sets the "toid" field.
  19484. func (m *MsgMutation) SetToid(s string) {
  19485. m.toid = &s
  19486. }
  19487. // Toid returns the value of the "toid" field in the mutation.
  19488. func (m *MsgMutation) Toid() (r string, exists bool) {
  19489. v := m.toid
  19490. if v == nil {
  19491. return
  19492. }
  19493. return *v, true
  19494. }
  19495. // OldToid returns the old "toid" field's value of the Msg entity.
  19496. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19498. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  19499. if !m.op.Is(OpUpdateOne) {
  19500. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  19501. }
  19502. if m.id == nil || m.oldValue == nil {
  19503. return v, errors.New("OldToid requires an ID field in the mutation")
  19504. }
  19505. oldValue, err := m.oldValue(ctx)
  19506. if err != nil {
  19507. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  19508. }
  19509. return oldValue.Toid, nil
  19510. }
  19511. // ClearToid clears the value of the "toid" field.
  19512. func (m *MsgMutation) ClearToid() {
  19513. m.toid = nil
  19514. m.clearedFields[msg.FieldToid] = struct{}{}
  19515. }
  19516. // ToidCleared returns if the "toid" field was cleared in this mutation.
  19517. func (m *MsgMutation) ToidCleared() bool {
  19518. _, ok := m.clearedFields[msg.FieldToid]
  19519. return ok
  19520. }
  19521. // ResetToid resets all changes to the "toid" field.
  19522. func (m *MsgMutation) ResetToid() {
  19523. m.toid = nil
  19524. delete(m.clearedFields, msg.FieldToid)
  19525. }
  19526. // SetMsgtype sets the "msgtype" field.
  19527. func (m *MsgMutation) SetMsgtype(i int32) {
  19528. m.msgtype = &i
  19529. m.addmsgtype = nil
  19530. }
  19531. // Msgtype returns the value of the "msgtype" field in the mutation.
  19532. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  19533. v := m.msgtype
  19534. if v == nil {
  19535. return
  19536. }
  19537. return *v, true
  19538. }
  19539. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  19540. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19542. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  19543. if !m.op.Is(OpUpdateOne) {
  19544. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  19545. }
  19546. if m.id == nil || m.oldValue == nil {
  19547. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  19548. }
  19549. oldValue, err := m.oldValue(ctx)
  19550. if err != nil {
  19551. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  19552. }
  19553. return oldValue.Msgtype, nil
  19554. }
  19555. // AddMsgtype adds i to the "msgtype" field.
  19556. func (m *MsgMutation) AddMsgtype(i int32) {
  19557. if m.addmsgtype != nil {
  19558. *m.addmsgtype += i
  19559. } else {
  19560. m.addmsgtype = &i
  19561. }
  19562. }
  19563. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  19564. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  19565. v := m.addmsgtype
  19566. if v == nil {
  19567. return
  19568. }
  19569. return *v, true
  19570. }
  19571. // ClearMsgtype clears the value of the "msgtype" field.
  19572. func (m *MsgMutation) ClearMsgtype() {
  19573. m.msgtype = nil
  19574. m.addmsgtype = nil
  19575. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  19576. }
  19577. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  19578. func (m *MsgMutation) MsgtypeCleared() bool {
  19579. _, ok := m.clearedFields[msg.FieldMsgtype]
  19580. return ok
  19581. }
  19582. // ResetMsgtype resets all changes to the "msgtype" field.
  19583. func (m *MsgMutation) ResetMsgtype() {
  19584. m.msgtype = nil
  19585. m.addmsgtype = nil
  19586. delete(m.clearedFields, msg.FieldMsgtype)
  19587. }
  19588. // SetMsg sets the "msg" field.
  19589. func (m *MsgMutation) SetMsg(s string) {
  19590. m.msg = &s
  19591. }
  19592. // Msg returns the value of the "msg" field in the mutation.
  19593. func (m *MsgMutation) Msg() (r string, exists bool) {
  19594. v := m.msg
  19595. if v == nil {
  19596. return
  19597. }
  19598. return *v, true
  19599. }
  19600. // OldMsg returns the old "msg" field's value of the Msg entity.
  19601. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19603. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  19604. if !m.op.Is(OpUpdateOne) {
  19605. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  19606. }
  19607. if m.id == nil || m.oldValue == nil {
  19608. return v, errors.New("OldMsg requires an ID field in the mutation")
  19609. }
  19610. oldValue, err := m.oldValue(ctx)
  19611. if err != nil {
  19612. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  19613. }
  19614. return oldValue.Msg, nil
  19615. }
  19616. // ClearMsg clears the value of the "msg" field.
  19617. func (m *MsgMutation) ClearMsg() {
  19618. m.msg = nil
  19619. m.clearedFields[msg.FieldMsg] = struct{}{}
  19620. }
  19621. // MsgCleared returns if the "msg" field was cleared in this mutation.
  19622. func (m *MsgMutation) MsgCleared() bool {
  19623. _, ok := m.clearedFields[msg.FieldMsg]
  19624. return ok
  19625. }
  19626. // ResetMsg resets all changes to the "msg" field.
  19627. func (m *MsgMutation) ResetMsg() {
  19628. m.msg = nil
  19629. delete(m.clearedFields, msg.FieldMsg)
  19630. }
  19631. // SetBatchNo sets the "batch_no" field.
  19632. func (m *MsgMutation) SetBatchNo(s string) {
  19633. m.batch_no = &s
  19634. }
  19635. // BatchNo returns the value of the "batch_no" field in the mutation.
  19636. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  19637. v := m.batch_no
  19638. if v == nil {
  19639. return
  19640. }
  19641. return *v, true
  19642. }
  19643. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  19644. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19646. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  19647. if !m.op.Is(OpUpdateOne) {
  19648. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  19649. }
  19650. if m.id == nil || m.oldValue == nil {
  19651. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  19652. }
  19653. oldValue, err := m.oldValue(ctx)
  19654. if err != nil {
  19655. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  19656. }
  19657. return oldValue.BatchNo, nil
  19658. }
  19659. // ClearBatchNo clears the value of the "batch_no" field.
  19660. func (m *MsgMutation) ClearBatchNo() {
  19661. m.batch_no = nil
  19662. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  19663. }
  19664. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  19665. func (m *MsgMutation) BatchNoCleared() bool {
  19666. _, ok := m.clearedFields[msg.FieldBatchNo]
  19667. return ok
  19668. }
  19669. // ResetBatchNo resets all changes to the "batch_no" field.
  19670. func (m *MsgMutation) ResetBatchNo() {
  19671. m.batch_no = nil
  19672. delete(m.clearedFields, msg.FieldBatchNo)
  19673. }
  19674. // SetCc sets the "cc" field.
  19675. func (m *MsgMutation) SetCc(s string) {
  19676. m.cc = &s
  19677. }
  19678. // Cc returns the value of the "cc" field in the mutation.
  19679. func (m *MsgMutation) Cc() (r string, exists bool) {
  19680. v := m.cc
  19681. if v == nil {
  19682. return
  19683. }
  19684. return *v, true
  19685. }
  19686. // OldCc returns the old "cc" field's value of the Msg entity.
  19687. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19689. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  19690. if !m.op.Is(OpUpdateOne) {
  19691. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  19692. }
  19693. if m.id == nil || m.oldValue == nil {
  19694. return v, errors.New("OldCc requires an ID field in the mutation")
  19695. }
  19696. oldValue, err := m.oldValue(ctx)
  19697. if err != nil {
  19698. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  19699. }
  19700. return oldValue.Cc, nil
  19701. }
  19702. // ResetCc resets all changes to the "cc" field.
  19703. func (m *MsgMutation) ResetCc() {
  19704. m.cc = nil
  19705. }
  19706. // SetPhone sets the "phone" field.
  19707. func (m *MsgMutation) SetPhone(s string) {
  19708. m.phone = &s
  19709. }
  19710. // Phone returns the value of the "phone" field in the mutation.
  19711. func (m *MsgMutation) Phone() (r string, exists bool) {
  19712. v := m.phone
  19713. if v == nil {
  19714. return
  19715. }
  19716. return *v, true
  19717. }
  19718. // OldPhone returns the old "phone" field's value of the Msg entity.
  19719. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  19720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19721. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  19722. if !m.op.Is(OpUpdateOne) {
  19723. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  19724. }
  19725. if m.id == nil || m.oldValue == nil {
  19726. return v, errors.New("OldPhone requires an ID field in the mutation")
  19727. }
  19728. oldValue, err := m.oldValue(ctx)
  19729. if err != nil {
  19730. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  19731. }
  19732. return oldValue.Phone, nil
  19733. }
  19734. // ResetPhone resets all changes to the "phone" field.
  19735. func (m *MsgMutation) ResetPhone() {
  19736. m.phone = nil
  19737. }
  19738. // Where appends a list predicates to the MsgMutation builder.
  19739. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  19740. m.predicates = append(m.predicates, ps...)
  19741. }
  19742. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  19743. // users can use type-assertion to append predicates that do not depend on any generated package.
  19744. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  19745. p := make([]predicate.Msg, len(ps))
  19746. for i := range ps {
  19747. p[i] = ps[i]
  19748. }
  19749. m.Where(p...)
  19750. }
  19751. // Op returns the operation name.
  19752. func (m *MsgMutation) Op() Op {
  19753. return m.op
  19754. }
  19755. // SetOp allows setting the mutation operation.
  19756. func (m *MsgMutation) SetOp(op Op) {
  19757. m.op = op
  19758. }
  19759. // Type returns the node type of this mutation (Msg).
  19760. func (m *MsgMutation) Type() string {
  19761. return m.typ
  19762. }
  19763. // Fields returns all fields that were changed during this mutation. Note that in
  19764. // order to get all numeric fields that were incremented/decremented, call
  19765. // AddedFields().
  19766. func (m *MsgMutation) Fields() []string {
  19767. fields := make([]string, 0, 11)
  19768. if m.created_at != nil {
  19769. fields = append(fields, msg.FieldCreatedAt)
  19770. }
  19771. if m.updated_at != nil {
  19772. fields = append(fields, msg.FieldUpdatedAt)
  19773. }
  19774. if m.deleted_at != nil {
  19775. fields = append(fields, msg.FieldDeletedAt)
  19776. }
  19777. if m.status != nil {
  19778. fields = append(fields, msg.FieldStatus)
  19779. }
  19780. if m.fromwxid != nil {
  19781. fields = append(fields, msg.FieldFromwxid)
  19782. }
  19783. if m.toid != nil {
  19784. fields = append(fields, msg.FieldToid)
  19785. }
  19786. if m.msgtype != nil {
  19787. fields = append(fields, msg.FieldMsgtype)
  19788. }
  19789. if m.msg != nil {
  19790. fields = append(fields, msg.FieldMsg)
  19791. }
  19792. if m.batch_no != nil {
  19793. fields = append(fields, msg.FieldBatchNo)
  19794. }
  19795. if m.cc != nil {
  19796. fields = append(fields, msg.FieldCc)
  19797. }
  19798. if m.phone != nil {
  19799. fields = append(fields, msg.FieldPhone)
  19800. }
  19801. return fields
  19802. }
  19803. // Field returns the value of a field with the given name. The second boolean
  19804. // return value indicates that this field was not set, or was not defined in the
  19805. // schema.
  19806. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  19807. switch name {
  19808. case msg.FieldCreatedAt:
  19809. return m.CreatedAt()
  19810. case msg.FieldUpdatedAt:
  19811. return m.UpdatedAt()
  19812. case msg.FieldDeletedAt:
  19813. return m.DeletedAt()
  19814. case msg.FieldStatus:
  19815. return m.Status()
  19816. case msg.FieldFromwxid:
  19817. return m.Fromwxid()
  19818. case msg.FieldToid:
  19819. return m.Toid()
  19820. case msg.FieldMsgtype:
  19821. return m.Msgtype()
  19822. case msg.FieldMsg:
  19823. return m.Msg()
  19824. case msg.FieldBatchNo:
  19825. return m.BatchNo()
  19826. case msg.FieldCc:
  19827. return m.Cc()
  19828. case msg.FieldPhone:
  19829. return m.Phone()
  19830. }
  19831. return nil, false
  19832. }
  19833. // OldField returns the old value of the field from the database. An error is
  19834. // returned if the mutation operation is not UpdateOne, or the query to the
  19835. // database failed.
  19836. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19837. switch name {
  19838. case msg.FieldCreatedAt:
  19839. return m.OldCreatedAt(ctx)
  19840. case msg.FieldUpdatedAt:
  19841. return m.OldUpdatedAt(ctx)
  19842. case msg.FieldDeletedAt:
  19843. return m.OldDeletedAt(ctx)
  19844. case msg.FieldStatus:
  19845. return m.OldStatus(ctx)
  19846. case msg.FieldFromwxid:
  19847. return m.OldFromwxid(ctx)
  19848. case msg.FieldToid:
  19849. return m.OldToid(ctx)
  19850. case msg.FieldMsgtype:
  19851. return m.OldMsgtype(ctx)
  19852. case msg.FieldMsg:
  19853. return m.OldMsg(ctx)
  19854. case msg.FieldBatchNo:
  19855. return m.OldBatchNo(ctx)
  19856. case msg.FieldCc:
  19857. return m.OldCc(ctx)
  19858. case msg.FieldPhone:
  19859. return m.OldPhone(ctx)
  19860. }
  19861. return nil, fmt.Errorf("unknown Msg field %s", name)
  19862. }
  19863. // SetField sets the value of a field with the given name. It returns an error if
  19864. // the field is not defined in the schema, or if the type mismatched the field
  19865. // type.
  19866. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  19867. switch name {
  19868. case msg.FieldCreatedAt:
  19869. v, ok := value.(time.Time)
  19870. if !ok {
  19871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19872. }
  19873. m.SetCreatedAt(v)
  19874. return nil
  19875. case msg.FieldUpdatedAt:
  19876. v, ok := value.(time.Time)
  19877. if !ok {
  19878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19879. }
  19880. m.SetUpdatedAt(v)
  19881. return nil
  19882. case msg.FieldDeletedAt:
  19883. v, ok := value.(time.Time)
  19884. if !ok {
  19885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19886. }
  19887. m.SetDeletedAt(v)
  19888. return nil
  19889. case msg.FieldStatus:
  19890. v, ok := value.(uint8)
  19891. if !ok {
  19892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19893. }
  19894. m.SetStatus(v)
  19895. return nil
  19896. case msg.FieldFromwxid:
  19897. v, ok := value.(string)
  19898. if !ok {
  19899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19900. }
  19901. m.SetFromwxid(v)
  19902. return nil
  19903. case msg.FieldToid:
  19904. v, ok := value.(string)
  19905. if !ok {
  19906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19907. }
  19908. m.SetToid(v)
  19909. return nil
  19910. case msg.FieldMsgtype:
  19911. v, ok := value.(int32)
  19912. if !ok {
  19913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19914. }
  19915. m.SetMsgtype(v)
  19916. return nil
  19917. case msg.FieldMsg:
  19918. v, ok := value.(string)
  19919. if !ok {
  19920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19921. }
  19922. m.SetMsg(v)
  19923. return nil
  19924. case msg.FieldBatchNo:
  19925. v, ok := value.(string)
  19926. if !ok {
  19927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19928. }
  19929. m.SetBatchNo(v)
  19930. return nil
  19931. case msg.FieldCc:
  19932. v, ok := value.(string)
  19933. if !ok {
  19934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19935. }
  19936. m.SetCc(v)
  19937. return nil
  19938. case msg.FieldPhone:
  19939. v, ok := value.(string)
  19940. if !ok {
  19941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19942. }
  19943. m.SetPhone(v)
  19944. return nil
  19945. }
  19946. return fmt.Errorf("unknown Msg field %s", name)
  19947. }
  19948. // AddedFields returns all numeric fields that were incremented/decremented during
  19949. // this mutation.
  19950. func (m *MsgMutation) AddedFields() []string {
  19951. var fields []string
  19952. if m.addstatus != nil {
  19953. fields = append(fields, msg.FieldStatus)
  19954. }
  19955. if m.addmsgtype != nil {
  19956. fields = append(fields, msg.FieldMsgtype)
  19957. }
  19958. return fields
  19959. }
  19960. // AddedField returns the numeric value that was incremented/decremented on a field
  19961. // with the given name. The second boolean return value indicates that this field
  19962. // was not set, or was not defined in the schema.
  19963. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  19964. switch name {
  19965. case msg.FieldStatus:
  19966. return m.AddedStatus()
  19967. case msg.FieldMsgtype:
  19968. return m.AddedMsgtype()
  19969. }
  19970. return nil, false
  19971. }
  19972. // AddField adds the value to the field with the given name. It returns an error if
  19973. // the field is not defined in the schema, or if the type mismatched the field
  19974. // type.
  19975. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  19976. switch name {
  19977. case msg.FieldStatus:
  19978. v, ok := value.(int8)
  19979. if !ok {
  19980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19981. }
  19982. m.AddStatus(v)
  19983. return nil
  19984. case msg.FieldMsgtype:
  19985. v, ok := value.(int32)
  19986. if !ok {
  19987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19988. }
  19989. m.AddMsgtype(v)
  19990. return nil
  19991. }
  19992. return fmt.Errorf("unknown Msg numeric field %s", name)
  19993. }
  19994. // ClearedFields returns all nullable fields that were cleared during this
  19995. // mutation.
  19996. func (m *MsgMutation) ClearedFields() []string {
  19997. var fields []string
  19998. if m.FieldCleared(msg.FieldDeletedAt) {
  19999. fields = append(fields, msg.FieldDeletedAt)
  20000. }
  20001. if m.FieldCleared(msg.FieldStatus) {
  20002. fields = append(fields, msg.FieldStatus)
  20003. }
  20004. if m.FieldCleared(msg.FieldFromwxid) {
  20005. fields = append(fields, msg.FieldFromwxid)
  20006. }
  20007. if m.FieldCleared(msg.FieldToid) {
  20008. fields = append(fields, msg.FieldToid)
  20009. }
  20010. if m.FieldCleared(msg.FieldMsgtype) {
  20011. fields = append(fields, msg.FieldMsgtype)
  20012. }
  20013. if m.FieldCleared(msg.FieldMsg) {
  20014. fields = append(fields, msg.FieldMsg)
  20015. }
  20016. if m.FieldCleared(msg.FieldBatchNo) {
  20017. fields = append(fields, msg.FieldBatchNo)
  20018. }
  20019. return fields
  20020. }
  20021. // FieldCleared returns a boolean indicating if a field with the given name was
  20022. // cleared in this mutation.
  20023. func (m *MsgMutation) FieldCleared(name string) bool {
  20024. _, ok := m.clearedFields[name]
  20025. return ok
  20026. }
  20027. // ClearField clears the value of the field with the given name. It returns an
  20028. // error if the field is not defined in the schema.
  20029. func (m *MsgMutation) ClearField(name string) error {
  20030. switch name {
  20031. case msg.FieldDeletedAt:
  20032. m.ClearDeletedAt()
  20033. return nil
  20034. case msg.FieldStatus:
  20035. m.ClearStatus()
  20036. return nil
  20037. case msg.FieldFromwxid:
  20038. m.ClearFromwxid()
  20039. return nil
  20040. case msg.FieldToid:
  20041. m.ClearToid()
  20042. return nil
  20043. case msg.FieldMsgtype:
  20044. m.ClearMsgtype()
  20045. return nil
  20046. case msg.FieldMsg:
  20047. m.ClearMsg()
  20048. return nil
  20049. case msg.FieldBatchNo:
  20050. m.ClearBatchNo()
  20051. return nil
  20052. }
  20053. return fmt.Errorf("unknown Msg nullable field %s", name)
  20054. }
  20055. // ResetField resets all changes in the mutation for the field with the given name.
  20056. // It returns an error if the field is not defined in the schema.
  20057. func (m *MsgMutation) ResetField(name string) error {
  20058. switch name {
  20059. case msg.FieldCreatedAt:
  20060. m.ResetCreatedAt()
  20061. return nil
  20062. case msg.FieldUpdatedAt:
  20063. m.ResetUpdatedAt()
  20064. return nil
  20065. case msg.FieldDeletedAt:
  20066. m.ResetDeletedAt()
  20067. return nil
  20068. case msg.FieldStatus:
  20069. m.ResetStatus()
  20070. return nil
  20071. case msg.FieldFromwxid:
  20072. m.ResetFromwxid()
  20073. return nil
  20074. case msg.FieldToid:
  20075. m.ResetToid()
  20076. return nil
  20077. case msg.FieldMsgtype:
  20078. m.ResetMsgtype()
  20079. return nil
  20080. case msg.FieldMsg:
  20081. m.ResetMsg()
  20082. return nil
  20083. case msg.FieldBatchNo:
  20084. m.ResetBatchNo()
  20085. return nil
  20086. case msg.FieldCc:
  20087. m.ResetCc()
  20088. return nil
  20089. case msg.FieldPhone:
  20090. m.ResetPhone()
  20091. return nil
  20092. }
  20093. return fmt.Errorf("unknown Msg field %s", name)
  20094. }
  20095. // AddedEdges returns all edge names that were set/added in this mutation.
  20096. func (m *MsgMutation) AddedEdges() []string {
  20097. edges := make([]string, 0, 0)
  20098. return edges
  20099. }
  20100. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20101. // name in this mutation.
  20102. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  20103. return nil
  20104. }
  20105. // RemovedEdges returns all edge names that were removed in this mutation.
  20106. func (m *MsgMutation) RemovedEdges() []string {
  20107. edges := make([]string, 0, 0)
  20108. return edges
  20109. }
  20110. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20111. // the given name in this mutation.
  20112. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  20113. return nil
  20114. }
  20115. // ClearedEdges returns all edge names that were cleared in this mutation.
  20116. func (m *MsgMutation) ClearedEdges() []string {
  20117. edges := make([]string, 0, 0)
  20118. return edges
  20119. }
  20120. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20121. // was cleared in this mutation.
  20122. func (m *MsgMutation) EdgeCleared(name string) bool {
  20123. return false
  20124. }
  20125. // ClearEdge clears the value of the edge with the given name. It returns an error
  20126. // if that edge is not defined in the schema.
  20127. func (m *MsgMutation) ClearEdge(name string) error {
  20128. return fmt.Errorf("unknown Msg unique edge %s", name)
  20129. }
  20130. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20131. // It returns an error if the edge is not defined in the schema.
  20132. func (m *MsgMutation) ResetEdge(name string) error {
  20133. return fmt.Errorf("unknown Msg edge %s", name)
  20134. }
  20135. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  20136. type PayRechargeMutation struct {
  20137. config
  20138. op Op
  20139. typ string
  20140. id *uint64
  20141. created_at *time.Time
  20142. updated_at *time.Time
  20143. deleted_at *time.Time
  20144. user_id *string
  20145. number *float32
  20146. addnumber *float32
  20147. status *int
  20148. addstatus *int
  20149. money *float32
  20150. addmoney *float32
  20151. out_trade_no *string
  20152. organization_id *uint64
  20153. addorganization_id *int64
  20154. clearedFields map[string]struct{}
  20155. done bool
  20156. oldValue func(context.Context) (*PayRecharge, error)
  20157. predicates []predicate.PayRecharge
  20158. }
  20159. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  20160. // payrechargeOption allows management of the mutation configuration using functional options.
  20161. type payrechargeOption func(*PayRechargeMutation)
  20162. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  20163. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  20164. m := &PayRechargeMutation{
  20165. config: c,
  20166. op: op,
  20167. typ: TypePayRecharge,
  20168. clearedFields: make(map[string]struct{}),
  20169. }
  20170. for _, opt := range opts {
  20171. opt(m)
  20172. }
  20173. return m
  20174. }
  20175. // withPayRechargeID sets the ID field of the mutation.
  20176. func withPayRechargeID(id uint64) payrechargeOption {
  20177. return func(m *PayRechargeMutation) {
  20178. var (
  20179. err error
  20180. once sync.Once
  20181. value *PayRecharge
  20182. )
  20183. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  20184. once.Do(func() {
  20185. if m.done {
  20186. err = errors.New("querying old values post mutation is not allowed")
  20187. } else {
  20188. value, err = m.Client().PayRecharge.Get(ctx, id)
  20189. }
  20190. })
  20191. return value, err
  20192. }
  20193. m.id = &id
  20194. }
  20195. }
  20196. // withPayRecharge sets the old PayRecharge of the mutation.
  20197. func withPayRecharge(node *PayRecharge) payrechargeOption {
  20198. return func(m *PayRechargeMutation) {
  20199. m.oldValue = func(context.Context) (*PayRecharge, error) {
  20200. return node, nil
  20201. }
  20202. m.id = &node.ID
  20203. }
  20204. }
  20205. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20206. // executed in a transaction (ent.Tx), a transactional client is returned.
  20207. func (m PayRechargeMutation) Client() *Client {
  20208. client := &Client{config: m.config}
  20209. client.init()
  20210. return client
  20211. }
  20212. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20213. // it returns an error otherwise.
  20214. func (m PayRechargeMutation) Tx() (*Tx, error) {
  20215. if _, ok := m.driver.(*txDriver); !ok {
  20216. return nil, errors.New("ent: mutation is not running in a transaction")
  20217. }
  20218. tx := &Tx{config: m.config}
  20219. tx.init()
  20220. return tx, nil
  20221. }
  20222. // SetID sets the value of the id field. Note that this
  20223. // operation is only accepted on creation of PayRecharge entities.
  20224. func (m *PayRechargeMutation) SetID(id uint64) {
  20225. m.id = &id
  20226. }
  20227. // ID returns the ID value in the mutation. Note that the ID is only available
  20228. // if it was provided to the builder or after it was returned from the database.
  20229. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  20230. if m.id == nil {
  20231. return
  20232. }
  20233. return *m.id, true
  20234. }
  20235. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20236. // That means, if the mutation is applied within a transaction with an isolation level such
  20237. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20238. // or updated by the mutation.
  20239. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20240. switch {
  20241. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20242. id, exists := m.ID()
  20243. if exists {
  20244. return []uint64{id}, nil
  20245. }
  20246. fallthrough
  20247. case m.op.Is(OpUpdate | OpDelete):
  20248. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  20249. default:
  20250. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20251. }
  20252. }
  20253. // SetCreatedAt sets the "created_at" field.
  20254. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  20255. m.created_at = &t
  20256. }
  20257. // CreatedAt returns the value of the "created_at" field in the mutation.
  20258. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  20259. v := m.created_at
  20260. if v == nil {
  20261. return
  20262. }
  20263. return *v, true
  20264. }
  20265. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  20266. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20268. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20269. if !m.op.Is(OpUpdateOne) {
  20270. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20271. }
  20272. if m.id == nil || m.oldValue == nil {
  20273. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20274. }
  20275. oldValue, err := m.oldValue(ctx)
  20276. if err != nil {
  20277. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20278. }
  20279. return oldValue.CreatedAt, nil
  20280. }
  20281. // ResetCreatedAt resets all changes to the "created_at" field.
  20282. func (m *PayRechargeMutation) ResetCreatedAt() {
  20283. m.created_at = nil
  20284. }
  20285. // SetUpdatedAt sets the "updated_at" field.
  20286. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  20287. m.updated_at = &t
  20288. }
  20289. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20290. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  20291. v := m.updated_at
  20292. if v == nil {
  20293. return
  20294. }
  20295. return *v, true
  20296. }
  20297. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  20298. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20300. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20301. if !m.op.Is(OpUpdateOne) {
  20302. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20303. }
  20304. if m.id == nil || m.oldValue == nil {
  20305. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20306. }
  20307. oldValue, err := m.oldValue(ctx)
  20308. if err != nil {
  20309. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20310. }
  20311. return oldValue.UpdatedAt, nil
  20312. }
  20313. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20314. func (m *PayRechargeMutation) ResetUpdatedAt() {
  20315. m.updated_at = nil
  20316. }
  20317. // SetDeletedAt sets the "deleted_at" field.
  20318. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  20319. m.deleted_at = &t
  20320. }
  20321. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20322. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  20323. v := m.deleted_at
  20324. if v == nil {
  20325. return
  20326. }
  20327. return *v, true
  20328. }
  20329. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  20330. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20332. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20333. if !m.op.Is(OpUpdateOne) {
  20334. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20335. }
  20336. if m.id == nil || m.oldValue == nil {
  20337. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20338. }
  20339. oldValue, err := m.oldValue(ctx)
  20340. if err != nil {
  20341. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20342. }
  20343. return oldValue.DeletedAt, nil
  20344. }
  20345. // ClearDeletedAt clears the value of the "deleted_at" field.
  20346. func (m *PayRechargeMutation) ClearDeletedAt() {
  20347. m.deleted_at = nil
  20348. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  20349. }
  20350. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20351. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  20352. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  20353. return ok
  20354. }
  20355. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20356. func (m *PayRechargeMutation) ResetDeletedAt() {
  20357. m.deleted_at = nil
  20358. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  20359. }
  20360. // SetUserID sets the "user_id" field.
  20361. func (m *PayRechargeMutation) SetUserID(s string) {
  20362. m.user_id = &s
  20363. }
  20364. // UserID returns the value of the "user_id" field in the mutation.
  20365. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  20366. v := m.user_id
  20367. if v == nil {
  20368. return
  20369. }
  20370. return *v, true
  20371. }
  20372. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  20373. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20375. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  20376. if !m.op.Is(OpUpdateOne) {
  20377. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  20378. }
  20379. if m.id == nil || m.oldValue == nil {
  20380. return v, errors.New("OldUserID requires an ID field in the mutation")
  20381. }
  20382. oldValue, err := m.oldValue(ctx)
  20383. if err != nil {
  20384. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  20385. }
  20386. return oldValue.UserID, nil
  20387. }
  20388. // ResetUserID resets all changes to the "user_id" field.
  20389. func (m *PayRechargeMutation) ResetUserID() {
  20390. m.user_id = nil
  20391. }
  20392. // SetNumber sets the "number" field.
  20393. func (m *PayRechargeMutation) SetNumber(f float32) {
  20394. m.number = &f
  20395. m.addnumber = nil
  20396. }
  20397. // Number returns the value of the "number" field in the mutation.
  20398. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  20399. v := m.number
  20400. if v == nil {
  20401. return
  20402. }
  20403. return *v, true
  20404. }
  20405. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  20406. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20408. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  20409. if !m.op.Is(OpUpdateOne) {
  20410. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  20411. }
  20412. if m.id == nil || m.oldValue == nil {
  20413. return v, errors.New("OldNumber requires an ID field in the mutation")
  20414. }
  20415. oldValue, err := m.oldValue(ctx)
  20416. if err != nil {
  20417. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  20418. }
  20419. return oldValue.Number, nil
  20420. }
  20421. // AddNumber adds f to the "number" field.
  20422. func (m *PayRechargeMutation) AddNumber(f float32) {
  20423. if m.addnumber != nil {
  20424. *m.addnumber += f
  20425. } else {
  20426. m.addnumber = &f
  20427. }
  20428. }
  20429. // AddedNumber returns the value that was added to the "number" field in this mutation.
  20430. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  20431. v := m.addnumber
  20432. if v == nil {
  20433. return
  20434. }
  20435. return *v, true
  20436. }
  20437. // ResetNumber resets all changes to the "number" field.
  20438. func (m *PayRechargeMutation) ResetNumber() {
  20439. m.number = nil
  20440. m.addnumber = nil
  20441. }
  20442. // SetStatus sets the "status" field.
  20443. func (m *PayRechargeMutation) SetStatus(i int) {
  20444. m.status = &i
  20445. m.addstatus = nil
  20446. }
  20447. // Status returns the value of the "status" field in the mutation.
  20448. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  20449. v := m.status
  20450. if v == nil {
  20451. return
  20452. }
  20453. return *v, true
  20454. }
  20455. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  20456. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20458. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  20459. if !m.op.Is(OpUpdateOne) {
  20460. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20461. }
  20462. if m.id == nil || m.oldValue == nil {
  20463. return v, errors.New("OldStatus requires an ID field in the mutation")
  20464. }
  20465. oldValue, err := m.oldValue(ctx)
  20466. if err != nil {
  20467. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20468. }
  20469. return oldValue.Status, nil
  20470. }
  20471. // AddStatus adds i to the "status" field.
  20472. func (m *PayRechargeMutation) AddStatus(i int) {
  20473. if m.addstatus != nil {
  20474. *m.addstatus += i
  20475. } else {
  20476. m.addstatus = &i
  20477. }
  20478. }
  20479. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20480. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  20481. v := m.addstatus
  20482. if v == nil {
  20483. return
  20484. }
  20485. return *v, true
  20486. }
  20487. // ClearStatus clears the value of the "status" field.
  20488. func (m *PayRechargeMutation) ClearStatus() {
  20489. m.status = nil
  20490. m.addstatus = nil
  20491. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  20492. }
  20493. // StatusCleared returns if the "status" field was cleared in this mutation.
  20494. func (m *PayRechargeMutation) StatusCleared() bool {
  20495. _, ok := m.clearedFields[payrecharge.FieldStatus]
  20496. return ok
  20497. }
  20498. // ResetStatus resets all changes to the "status" field.
  20499. func (m *PayRechargeMutation) ResetStatus() {
  20500. m.status = nil
  20501. m.addstatus = nil
  20502. delete(m.clearedFields, payrecharge.FieldStatus)
  20503. }
  20504. // SetMoney sets the "money" field.
  20505. func (m *PayRechargeMutation) SetMoney(f float32) {
  20506. m.money = &f
  20507. m.addmoney = nil
  20508. }
  20509. // Money returns the value of the "money" field in the mutation.
  20510. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  20511. v := m.money
  20512. if v == nil {
  20513. return
  20514. }
  20515. return *v, true
  20516. }
  20517. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  20518. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20520. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  20521. if !m.op.Is(OpUpdateOne) {
  20522. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  20523. }
  20524. if m.id == nil || m.oldValue == nil {
  20525. return v, errors.New("OldMoney requires an ID field in the mutation")
  20526. }
  20527. oldValue, err := m.oldValue(ctx)
  20528. if err != nil {
  20529. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  20530. }
  20531. return oldValue.Money, nil
  20532. }
  20533. // AddMoney adds f to the "money" field.
  20534. func (m *PayRechargeMutation) AddMoney(f float32) {
  20535. if m.addmoney != nil {
  20536. *m.addmoney += f
  20537. } else {
  20538. m.addmoney = &f
  20539. }
  20540. }
  20541. // AddedMoney returns the value that was added to the "money" field in this mutation.
  20542. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  20543. v := m.addmoney
  20544. if v == nil {
  20545. return
  20546. }
  20547. return *v, true
  20548. }
  20549. // ClearMoney clears the value of the "money" field.
  20550. func (m *PayRechargeMutation) ClearMoney() {
  20551. m.money = nil
  20552. m.addmoney = nil
  20553. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  20554. }
  20555. // MoneyCleared returns if the "money" field was cleared in this mutation.
  20556. func (m *PayRechargeMutation) MoneyCleared() bool {
  20557. _, ok := m.clearedFields[payrecharge.FieldMoney]
  20558. return ok
  20559. }
  20560. // ResetMoney resets all changes to the "money" field.
  20561. func (m *PayRechargeMutation) ResetMoney() {
  20562. m.money = nil
  20563. m.addmoney = nil
  20564. delete(m.clearedFields, payrecharge.FieldMoney)
  20565. }
  20566. // SetOutTradeNo sets the "out_trade_no" field.
  20567. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  20568. m.out_trade_no = &s
  20569. }
  20570. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  20571. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  20572. v := m.out_trade_no
  20573. if v == nil {
  20574. return
  20575. }
  20576. return *v, true
  20577. }
  20578. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  20579. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20581. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  20582. if !m.op.Is(OpUpdateOne) {
  20583. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  20584. }
  20585. if m.id == nil || m.oldValue == nil {
  20586. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  20587. }
  20588. oldValue, err := m.oldValue(ctx)
  20589. if err != nil {
  20590. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  20591. }
  20592. return oldValue.OutTradeNo, nil
  20593. }
  20594. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  20595. func (m *PayRechargeMutation) ClearOutTradeNo() {
  20596. m.out_trade_no = nil
  20597. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  20598. }
  20599. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  20600. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  20601. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  20602. return ok
  20603. }
  20604. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  20605. func (m *PayRechargeMutation) ResetOutTradeNo() {
  20606. m.out_trade_no = nil
  20607. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  20608. }
  20609. // SetOrganizationID sets the "organization_id" field.
  20610. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  20611. m.organization_id = &u
  20612. m.addorganization_id = nil
  20613. }
  20614. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20615. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  20616. v := m.organization_id
  20617. if v == nil {
  20618. return
  20619. }
  20620. return *v, true
  20621. }
  20622. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  20623. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  20624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20625. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20626. if !m.op.Is(OpUpdateOne) {
  20627. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20628. }
  20629. if m.id == nil || m.oldValue == nil {
  20630. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20631. }
  20632. oldValue, err := m.oldValue(ctx)
  20633. if err != nil {
  20634. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20635. }
  20636. return oldValue.OrganizationID, nil
  20637. }
  20638. // AddOrganizationID adds u to the "organization_id" field.
  20639. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  20640. if m.addorganization_id != nil {
  20641. *m.addorganization_id += u
  20642. } else {
  20643. m.addorganization_id = &u
  20644. }
  20645. }
  20646. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20647. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  20648. v := m.addorganization_id
  20649. if v == nil {
  20650. return
  20651. }
  20652. return *v, true
  20653. }
  20654. // ResetOrganizationID resets all changes to the "organization_id" field.
  20655. func (m *PayRechargeMutation) ResetOrganizationID() {
  20656. m.organization_id = nil
  20657. m.addorganization_id = nil
  20658. }
  20659. // Where appends a list predicates to the PayRechargeMutation builder.
  20660. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  20661. m.predicates = append(m.predicates, ps...)
  20662. }
  20663. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  20664. // users can use type-assertion to append predicates that do not depend on any generated package.
  20665. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  20666. p := make([]predicate.PayRecharge, len(ps))
  20667. for i := range ps {
  20668. p[i] = ps[i]
  20669. }
  20670. m.Where(p...)
  20671. }
  20672. // Op returns the operation name.
  20673. func (m *PayRechargeMutation) Op() Op {
  20674. return m.op
  20675. }
  20676. // SetOp allows setting the mutation operation.
  20677. func (m *PayRechargeMutation) SetOp(op Op) {
  20678. m.op = op
  20679. }
  20680. // Type returns the node type of this mutation (PayRecharge).
  20681. func (m *PayRechargeMutation) Type() string {
  20682. return m.typ
  20683. }
  20684. // Fields returns all fields that were changed during this mutation. Note that in
  20685. // order to get all numeric fields that were incremented/decremented, call
  20686. // AddedFields().
  20687. func (m *PayRechargeMutation) Fields() []string {
  20688. fields := make([]string, 0, 9)
  20689. if m.created_at != nil {
  20690. fields = append(fields, payrecharge.FieldCreatedAt)
  20691. }
  20692. if m.updated_at != nil {
  20693. fields = append(fields, payrecharge.FieldUpdatedAt)
  20694. }
  20695. if m.deleted_at != nil {
  20696. fields = append(fields, payrecharge.FieldDeletedAt)
  20697. }
  20698. if m.user_id != nil {
  20699. fields = append(fields, payrecharge.FieldUserID)
  20700. }
  20701. if m.number != nil {
  20702. fields = append(fields, payrecharge.FieldNumber)
  20703. }
  20704. if m.status != nil {
  20705. fields = append(fields, payrecharge.FieldStatus)
  20706. }
  20707. if m.money != nil {
  20708. fields = append(fields, payrecharge.FieldMoney)
  20709. }
  20710. if m.out_trade_no != nil {
  20711. fields = append(fields, payrecharge.FieldOutTradeNo)
  20712. }
  20713. if m.organization_id != nil {
  20714. fields = append(fields, payrecharge.FieldOrganizationID)
  20715. }
  20716. return fields
  20717. }
  20718. // Field returns the value of a field with the given name. The second boolean
  20719. // return value indicates that this field was not set, or was not defined in the
  20720. // schema.
  20721. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  20722. switch name {
  20723. case payrecharge.FieldCreatedAt:
  20724. return m.CreatedAt()
  20725. case payrecharge.FieldUpdatedAt:
  20726. return m.UpdatedAt()
  20727. case payrecharge.FieldDeletedAt:
  20728. return m.DeletedAt()
  20729. case payrecharge.FieldUserID:
  20730. return m.UserID()
  20731. case payrecharge.FieldNumber:
  20732. return m.Number()
  20733. case payrecharge.FieldStatus:
  20734. return m.Status()
  20735. case payrecharge.FieldMoney:
  20736. return m.Money()
  20737. case payrecharge.FieldOutTradeNo:
  20738. return m.OutTradeNo()
  20739. case payrecharge.FieldOrganizationID:
  20740. return m.OrganizationID()
  20741. }
  20742. return nil, false
  20743. }
  20744. // OldField returns the old value of the field from the database. An error is
  20745. // returned if the mutation operation is not UpdateOne, or the query to the
  20746. // database failed.
  20747. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20748. switch name {
  20749. case payrecharge.FieldCreatedAt:
  20750. return m.OldCreatedAt(ctx)
  20751. case payrecharge.FieldUpdatedAt:
  20752. return m.OldUpdatedAt(ctx)
  20753. case payrecharge.FieldDeletedAt:
  20754. return m.OldDeletedAt(ctx)
  20755. case payrecharge.FieldUserID:
  20756. return m.OldUserID(ctx)
  20757. case payrecharge.FieldNumber:
  20758. return m.OldNumber(ctx)
  20759. case payrecharge.FieldStatus:
  20760. return m.OldStatus(ctx)
  20761. case payrecharge.FieldMoney:
  20762. return m.OldMoney(ctx)
  20763. case payrecharge.FieldOutTradeNo:
  20764. return m.OldOutTradeNo(ctx)
  20765. case payrecharge.FieldOrganizationID:
  20766. return m.OldOrganizationID(ctx)
  20767. }
  20768. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  20769. }
  20770. // SetField sets the value of a field with the given name. It returns an error if
  20771. // the field is not defined in the schema, or if the type mismatched the field
  20772. // type.
  20773. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  20774. switch name {
  20775. case payrecharge.FieldCreatedAt:
  20776. v, ok := value.(time.Time)
  20777. if !ok {
  20778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20779. }
  20780. m.SetCreatedAt(v)
  20781. return nil
  20782. case payrecharge.FieldUpdatedAt:
  20783. v, ok := value.(time.Time)
  20784. if !ok {
  20785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20786. }
  20787. m.SetUpdatedAt(v)
  20788. return nil
  20789. case payrecharge.FieldDeletedAt:
  20790. v, ok := value.(time.Time)
  20791. if !ok {
  20792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20793. }
  20794. m.SetDeletedAt(v)
  20795. return nil
  20796. case payrecharge.FieldUserID:
  20797. v, ok := value.(string)
  20798. if !ok {
  20799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20800. }
  20801. m.SetUserID(v)
  20802. return nil
  20803. case payrecharge.FieldNumber:
  20804. v, ok := value.(float32)
  20805. if !ok {
  20806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20807. }
  20808. m.SetNumber(v)
  20809. return nil
  20810. case payrecharge.FieldStatus:
  20811. v, ok := value.(int)
  20812. if !ok {
  20813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20814. }
  20815. m.SetStatus(v)
  20816. return nil
  20817. case payrecharge.FieldMoney:
  20818. v, ok := value.(float32)
  20819. if !ok {
  20820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20821. }
  20822. m.SetMoney(v)
  20823. return nil
  20824. case payrecharge.FieldOutTradeNo:
  20825. v, ok := value.(string)
  20826. if !ok {
  20827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20828. }
  20829. m.SetOutTradeNo(v)
  20830. return nil
  20831. case payrecharge.FieldOrganizationID:
  20832. v, ok := value.(uint64)
  20833. if !ok {
  20834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20835. }
  20836. m.SetOrganizationID(v)
  20837. return nil
  20838. }
  20839. return fmt.Errorf("unknown PayRecharge field %s", name)
  20840. }
  20841. // AddedFields returns all numeric fields that were incremented/decremented during
  20842. // this mutation.
  20843. func (m *PayRechargeMutation) AddedFields() []string {
  20844. var fields []string
  20845. if m.addnumber != nil {
  20846. fields = append(fields, payrecharge.FieldNumber)
  20847. }
  20848. if m.addstatus != nil {
  20849. fields = append(fields, payrecharge.FieldStatus)
  20850. }
  20851. if m.addmoney != nil {
  20852. fields = append(fields, payrecharge.FieldMoney)
  20853. }
  20854. if m.addorganization_id != nil {
  20855. fields = append(fields, payrecharge.FieldOrganizationID)
  20856. }
  20857. return fields
  20858. }
  20859. // AddedField returns the numeric value that was incremented/decremented on a field
  20860. // with the given name. The second boolean return value indicates that this field
  20861. // was not set, or was not defined in the schema.
  20862. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  20863. switch name {
  20864. case payrecharge.FieldNumber:
  20865. return m.AddedNumber()
  20866. case payrecharge.FieldStatus:
  20867. return m.AddedStatus()
  20868. case payrecharge.FieldMoney:
  20869. return m.AddedMoney()
  20870. case payrecharge.FieldOrganizationID:
  20871. return m.AddedOrganizationID()
  20872. }
  20873. return nil, false
  20874. }
  20875. // AddField adds the value to the field with the given name. It returns an error if
  20876. // the field is not defined in the schema, or if the type mismatched the field
  20877. // type.
  20878. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  20879. switch name {
  20880. case payrecharge.FieldNumber:
  20881. v, ok := value.(float32)
  20882. if !ok {
  20883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20884. }
  20885. m.AddNumber(v)
  20886. return nil
  20887. case payrecharge.FieldStatus:
  20888. v, ok := value.(int)
  20889. if !ok {
  20890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20891. }
  20892. m.AddStatus(v)
  20893. return nil
  20894. case payrecharge.FieldMoney:
  20895. v, ok := value.(float32)
  20896. if !ok {
  20897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20898. }
  20899. m.AddMoney(v)
  20900. return nil
  20901. case payrecharge.FieldOrganizationID:
  20902. v, ok := value.(int64)
  20903. if !ok {
  20904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20905. }
  20906. m.AddOrganizationID(v)
  20907. return nil
  20908. }
  20909. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  20910. }
  20911. // ClearedFields returns all nullable fields that were cleared during this
  20912. // mutation.
  20913. func (m *PayRechargeMutation) ClearedFields() []string {
  20914. var fields []string
  20915. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  20916. fields = append(fields, payrecharge.FieldDeletedAt)
  20917. }
  20918. if m.FieldCleared(payrecharge.FieldStatus) {
  20919. fields = append(fields, payrecharge.FieldStatus)
  20920. }
  20921. if m.FieldCleared(payrecharge.FieldMoney) {
  20922. fields = append(fields, payrecharge.FieldMoney)
  20923. }
  20924. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  20925. fields = append(fields, payrecharge.FieldOutTradeNo)
  20926. }
  20927. return fields
  20928. }
  20929. // FieldCleared returns a boolean indicating if a field with the given name was
  20930. // cleared in this mutation.
  20931. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  20932. _, ok := m.clearedFields[name]
  20933. return ok
  20934. }
  20935. // ClearField clears the value of the field with the given name. It returns an
  20936. // error if the field is not defined in the schema.
  20937. func (m *PayRechargeMutation) ClearField(name string) error {
  20938. switch name {
  20939. case payrecharge.FieldDeletedAt:
  20940. m.ClearDeletedAt()
  20941. return nil
  20942. case payrecharge.FieldStatus:
  20943. m.ClearStatus()
  20944. return nil
  20945. case payrecharge.FieldMoney:
  20946. m.ClearMoney()
  20947. return nil
  20948. case payrecharge.FieldOutTradeNo:
  20949. m.ClearOutTradeNo()
  20950. return nil
  20951. }
  20952. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  20953. }
  20954. // ResetField resets all changes in the mutation for the field with the given name.
  20955. // It returns an error if the field is not defined in the schema.
  20956. func (m *PayRechargeMutation) ResetField(name string) error {
  20957. switch name {
  20958. case payrecharge.FieldCreatedAt:
  20959. m.ResetCreatedAt()
  20960. return nil
  20961. case payrecharge.FieldUpdatedAt:
  20962. m.ResetUpdatedAt()
  20963. return nil
  20964. case payrecharge.FieldDeletedAt:
  20965. m.ResetDeletedAt()
  20966. return nil
  20967. case payrecharge.FieldUserID:
  20968. m.ResetUserID()
  20969. return nil
  20970. case payrecharge.FieldNumber:
  20971. m.ResetNumber()
  20972. return nil
  20973. case payrecharge.FieldStatus:
  20974. m.ResetStatus()
  20975. return nil
  20976. case payrecharge.FieldMoney:
  20977. m.ResetMoney()
  20978. return nil
  20979. case payrecharge.FieldOutTradeNo:
  20980. m.ResetOutTradeNo()
  20981. return nil
  20982. case payrecharge.FieldOrganizationID:
  20983. m.ResetOrganizationID()
  20984. return nil
  20985. }
  20986. return fmt.Errorf("unknown PayRecharge field %s", name)
  20987. }
  20988. // AddedEdges returns all edge names that were set/added in this mutation.
  20989. func (m *PayRechargeMutation) AddedEdges() []string {
  20990. edges := make([]string, 0, 0)
  20991. return edges
  20992. }
  20993. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20994. // name in this mutation.
  20995. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  20996. return nil
  20997. }
  20998. // RemovedEdges returns all edge names that were removed in this mutation.
  20999. func (m *PayRechargeMutation) RemovedEdges() []string {
  21000. edges := make([]string, 0, 0)
  21001. return edges
  21002. }
  21003. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21004. // the given name in this mutation.
  21005. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  21006. return nil
  21007. }
  21008. // ClearedEdges returns all edge names that were cleared in this mutation.
  21009. func (m *PayRechargeMutation) ClearedEdges() []string {
  21010. edges := make([]string, 0, 0)
  21011. return edges
  21012. }
  21013. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21014. // was cleared in this mutation.
  21015. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  21016. return false
  21017. }
  21018. // ClearEdge clears the value of the edge with the given name. It returns an error
  21019. // if that edge is not defined in the schema.
  21020. func (m *PayRechargeMutation) ClearEdge(name string) error {
  21021. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  21022. }
  21023. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21024. // It returns an error if the edge is not defined in the schema.
  21025. func (m *PayRechargeMutation) ResetEdge(name string) error {
  21026. return fmt.Errorf("unknown PayRecharge edge %s", name)
  21027. }
  21028. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  21029. type ServerMutation struct {
  21030. config
  21031. op Op
  21032. typ string
  21033. id *uint64
  21034. created_at *time.Time
  21035. updated_at *time.Time
  21036. status *uint8
  21037. addstatus *int8
  21038. deleted_at *time.Time
  21039. name *string
  21040. public_ip *string
  21041. private_ip *string
  21042. admin_port *string
  21043. clearedFields map[string]struct{}
  21044. wxs map[uint64]struct{}
  21045. removedwxs map[uint64]struct{}
  21046. clearedwxs bool
  21047. done bool
  21048. oldValue func(context.Context) (*Server, error)
  21049. predicates []predicate.Server
  21050. }
  21051. var _ ent.Mutation = (*ServerMutation)(nil)
  21052. // serverOption allows management of the mutation configuration using functional options.
  21053. type serverOption func(*ServerMutation)
  21054. // newServerMutation creates new mutation for the Server entity.
  21055. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  21056. m := &ServerMutation{
  21057. config: c,
  21058. op: op,
  21059. typ: TypeServer,
  21060. clearedFields: make(map[string]struct{}),
  21061. }
  21062. for _, opt := range opts {
  21063. opt(m)
  21064. }
  21065. return m
  21066. }
  21067. // withServerID sets the ID field of the mutation.
  21068. func withServerID(id uint64) serverOption {
  21069. return func(m *ServerMutation) {
  21070. var (
  21071. err error
  21072. once sync.Once
  21073. value *Server
  21074. )
  21075. m.oldValue = func(ctx context.Context) (*Server, error) {
  21076. once.Do(func() {
  21077. if m.done {
  21078. err = errors.New("querying old values post mutation is not allowed")
  21079. } else {
  21080. value, err = m.Client().Server.Get(ctx, id)
  21081. }
  21082. })
  21083. return value, err
  21084. }
  21085. m.id = &id
  21086. }
  21087. }
  21088. // withServer sets the old Server of the mutation.
  21089. func withServer(node *Server) serverOption {
  21090. return func(m *ServerMutation) {
  21091. m.oldValue = func(context.Context) (*Server, error) {
  21092. return node, nil
  21093. }
  21094. m.id = &node.ID
  21095. }
  21096. }
  21097. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21098. // executed in a transaction (ent.Tx), a transactional client is returned.
  21099. func (m ServerMutation) Client() *Client {
  21100. client := &Client{config: m.config}
  21101. client.init()
  21102. return client
  21103. }
  21104. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21105. // it returns an error otherwise.
  21106. func (m ServerMutation) Tx() (*Tx, error) {
  21107. if _, ok := m.driver.(*txDriver); !ok {
  21108. return nil, errors.New("ent: mutation is not running in a transaction")
  21109. }
  21110. tx := &Tx{config: m.config}
  21111. tx.init()
  21112. return tx, nil
  21113. }
  21114. // SetID sets the value of the id field. Note that this
  21115. // operation is only accepted on creation of Server entities.
  21116. func (m *ServerMutation) SetID(id uint64) {
  21117. m.id = &id
  21118. }
  21119. // ID returns the ID value in the mutation. Note that the ID is only available
  21120. // if it was provided to the builder or after it was returned from the database.
  21121. func (m *ServerMutation) ID() (id uint64, exists bool) {
  21122. if m.id == nil {
  21123. return
  21124. }
  21125. return *m.id, true
  21126. }
  21127. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21128. // That means, if the mutation is applied within a transaction with an isolation level such
  21129. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21130. // or updated by the mutation.
  21131. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  21132. switch {
  21133. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21134. id, exists := m.ID()
  21135. if exists {
  21136. return []uint64{id}, nil
  21137. }
  21138. fallthrough
  21139. case m.op.Is(OpUpdate | OpDelete):
  21140. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  21141. default:
  21142. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21143. }
  21144. }
  21145. // SetCreatedAt sets the "created_at" field.
  21146. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  21147. m.created_at = &t
  21148. }
  21149. // CreatedAt returns the value of the "created_at" field in the mutation.
  21150. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  21151. v := m.created_at
  21152. if v == nil {
  21153. return
  21154. }
  21155. return *v, true
  21156. }
  21157. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  21158. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21160. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21161. if !m.op.Is(OpUpdateOne) {
  21162. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21163. }
  21164. if m.id == nil || m.oldValue == nil {
  21165. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21166. }
  21167. oldValue, err := m.oldValue(ctx)
  21168. if err != nil {
  21169. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21170. }
  21171. return oldValue.CreatedAt, nil
  21172. }
  21173. // ResetCreatedAt resets all changes to the "created_at" field.
  21174. func (m *ServerMutation) ResetCreatedAt() {
  21175. m.created_at = nil
  21176. }
  21177. // SetUpdatedAt sets the "updated_at" field.
  21178. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  21179. m.updated_at = &t
  21180. }
  21181. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21182. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  21183. v := m.updated_at
  21184. if v == nil {
  21185. return
  21186. }
  21187. return *v, true
  21188. }
  21189. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  21190. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21192. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21193. if !m.op.Is(OpUpdateOne) {
  21194. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21195. }
  21196. if m.id == nil || m.oldValue == nil {
  21197. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21198. }
  21199. oldValue, err := m.oldValue(ctx)
  21200. if err != nil {
  21201. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21202. }
  21203. return oldValue.UpdatedAt, nil
  21204. }
  21205. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21206. func (m *ServerMutation) ResetUpdatedAt() {
  21207. m.updated_at = nil
  21208. }
  21209. // SetStatus sets the "status" field.
  21210. func (m *ServerMutation) SetStatus(u uint8) {
  21211. m.status = &u
  21212. m.addstatus = nil
  21213. }
  21214. // Status returns the value of the "status" field in the mutation.
  21215. func (m *ServerMutation) Status() (r uint8, exists bool) {
  21216. v := m.status
  21217. if v == nil {
  21218. return
  21219. }
  21220. return *v, true
  21221. }
  21222. // OldStatus returns the old "status" field's value of the Server entity.
  21223. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21225. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21226. if !m.op.Is(OpUpdateOne) {
  21227. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21228. }
  21229. if m.id == nil || m.oldValue == nil {
  21230. return v, errors.New("OldStatus requires an ID field in the mutation")
  21231. }
  21232. oldValue, err := m.oldValue(ctx)
  21233. if err != nil {
  21234. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21235. }
  21236. return oldValue.Status, nil
  21237. }
  21238. // AddStatus adds u to the "status" field.
  21239. func (m *ServerMutation) AddStatus(u int8) {
  21240. if m.addstatus != nil {
  21241. *m.addstatus += u
  21242. } else {
  21243. m.addstatus = &u
  21244. }
  21245. }
  21246. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21247. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  21248. v := m.addstatus
  21249. if v == nil {
  21250. return
  21251. }
  21252. return *v, true
  21253. }
  21254. // ClearStatus clears the value of the "status" field.
  21255. func (m *ServerMutation) ClearStatus() {
  21256. m.status = nil
  21257. m.addstatus = nil
  21258. m.clearedFields[server.FieldStatus] = struct{}{}
  21259. }
  21260. // StatusCleared returns if the "status" field was cleared in this mutation.
  21261. func (m *ServerMutation) StatusCleared() bool {
  21262. _, ok := m.clearedFields[server.FieldStatus]
  21263. return ok
  21264. }
  21265. // ResetStatus resets all changes to the "status" field.
  21266. func (m *ServerMutation) ResetStatus() {
  21267. m.status = nil
  21268. m.addstatus = nil
  21269. delete(m.clearedFields, server.FieldStatus)
  21270. }
  21271. // SetDeletedAt sets the "deleted_at" field.
  21272. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  21273. m.deleted_at = &t
  21274. }
  21275. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21276. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  21277. v := m.deleted_at
  21278. if v == nil {
  21279. return
  21280. }
  21281. return *v, true
  21282. }
  21283. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  21284. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21286. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21287. if !m.op.Is(OpUpdateOne) {
  21288. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21289. }
  21290. if m.id == nil || m.oldValue == nil {
  21291. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21292. }
  21293. oldValue, err := m.oldValue(ctx)
  21294. if err != nil {
  21295. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21296. }
  21297. return oldValue.DeletedAt, nil
  21298. }
  21299. // ClearDeletedAt clears the value of the "deleted_at" field.
  21300. func (m *ServerMutation) ClearDeletedAt() {
  21301. m.deleted_at = nil
  21302. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  21303. }
  21304. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21305. func (m *ServerMutation) DeletedAtCleared() bool {
  21306. _, ok := m.clearedFields[server.FieldDeletedAt]
  21307. return ok
  21308. }
  21309. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21310. func (m *ServerMutation) ResetDeletedAt() {
  21311. m.deleted_at = nil
  21312. delete(m.clearedFields, server.FieldDeletedAt)
  21313. }
  21314. // SetName sets the "name" field.
  21315. func (m *ServerMutation) SetName(s string) {
  21316. m.name = &s
  21317. }
  21318. // Name returns the value of the "name" field in the mutation.
  21319. func (m *ServerMutation) Name() (r string, exists bool) {
  21320. v := m.name
  21321. if v == nil {
  21322. return
  21323. }
  21324. return *v, true
  21325. }
  21326. // OldName returns the old "name" field's value of the Server entity.
  21327. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21329. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  21330. if !m.op.Is(OpUpdateOne) {
  21331. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21332. }
  21333. if m.id == nil || m.oldValue == nil {
  21334. return v, errors.New("OldName requires an ID field in the mutation")
  21335. }
  21336. oldValue, err := m.oldValue(ctx)
  21337. if err != nil {
  21338. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21339. }
  21340. return oldValue.Name, nil
  21341. }
  21342. // ResetName resets all changes to the "name" field.
  21343. func (m *ServerMutation) ResetName() {
  21344. m.name = nil
  21345. }
  21346. // SetPublicIP sets the "public_ip" field.
  21347. func (m *ServerMutation) SetPublicIP(s string) {
  21348. m.public_ip = &s
  21349. }
  21350. // PublicIP returns the value of the "public_ip" field in the mutation.
  21351. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  21352. v := m.public_ip
  21353. if v == nil {
  21354. return
  21355. }
  21356. return *v, true
  21357. }
  21358. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  21359. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21361. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  21362. if !m.op.Is(OpUpdateOne) {
  21363. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  21364. }
  21365. if m.id == nil || m.oldValue == nil {
  21366. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  21367. }
  21368. oldValue, err := m.oldValue(ctx)
  21369. if err != nil {
  21370. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  21371. }
  21372. return oldValue.PublicIP, nil
  21373. }
  21374. // ResetPublicIP resets all changes to the "public_ip" field.
  21375. func (m *ServerMutation) ResetPublicIP() {
  21376. m.public_ip = nil
  21377. }
  21378. // SetPrivateIP sets the "private_ip" field.
  21379. func (m *ServerMutation) SetPrivateIP(s string) {
  21380. m.private_ip = &s
  21381. }
  21382. // PrivateIP returns the value of the "private_ip" field in the mutation.
  21383. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  21384. v := m.private_ip
  21385. if v == nil {
  21386. return
  21387. }
  21388. return *v, true
  21389. }
  21390. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  21391. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21393. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  21394. if !m.op.Is(OpUpdateOne) {
  21395. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  21396. }
  21397. if m.id == nil || m.oldValue == nil {
  21398. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  21399. }
  21400. oldValue, err := m.oldValue(ctx)
  21401. if err != nil {
  21402. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  21403. }
  21404. return oldValue.PrivateIP, nil
  21405. }
  21406. // ResetPrivateIP resets all changes to the "private_ip" field.
  21407. func (m *ServerMutation) ResetPrivateIP() {
  21408. m.private_ip = nil
  21409. }
  21410. // SetAdminPort sets the "admin_port" field.
  21411. func (m *ServerMutation) SetAdminPort(s string) {
  21412. m.admin_port = &s
  21413. }
  21414. // AdminPort returns the value of the "admin_port" field in the mutation.
  21415. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  21416. v := m.admin_port
  21417. if v == nil {
  21418. return
  21419. }
  21420. return *v, true
  21421. }
  21422. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  21423. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  21424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21425. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  21426. if !m.op.Is(OpUpdateOne) {
  21427. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  21428. }
  21429. if m.id == nil || m.oldValue == nil {
  21430. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  21431. }
  21432. oldValue, err := m.oldValue(ctx)
  21433. if err != nil {
  21434. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  21435. }
  21436. return oldValue.AdminPort, nil
  21437. }
  21438. // ResetAdminPort resets all changes to the "admin_port" field.
  21439. func (m *ServerMutation) ResetAdminPort() {
  21440. m.admin_port = nil
  21441. }
  21442. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  21443. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  21444. if m.wxs == nil {
  21445. m.wxs = make(map[uint64]struct{})
  21446. }
  21447. for i := range ids {
  21448. m.wxs[ids[i]] = struct{}{}
  21449. }
  21450. }
  21451. // ClearWxs clears the "wxs" edge to the Wx entity.
  21452. func (m *ServerMutation) ClearWxs() {
  21453. m.clearedwxs = true
  21454. }
  21455. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  21456. func (m *ServerMutation) WxsCleared() bool {
  21457. return m.clearedwxs
  21458. }
  21459. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  21460. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  21461. if m.removedwxs == nil {
  21462. m.removedwxs = make(map[uint64]struct{})
  21463. }
  21464. for i := range ids {
  21465. delete(m.wxs, ids[i])
  21466. m.removedwxs[ids[i]] = struct{}{}
  21467. }
  21468. }
  21469. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  21470. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  21471. for id := range m.removedwxs {
  21472. ids = append(ids, id)
  21473. }
  21474. return
  21475. }
  21476. // WxsIDs returns the "wxs" edge IDs in the mutation.
  21477. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  21478. for id := range m.wxs {
  21479. ids = append(ids, id)
  21480. }
  21481. return
  21482. }
  21483. // ResetWxs resets all changes to the "wxs" edge.
  21484. func (m *ServerMutation) ResetWxs() {
  21485. m.wxs = nil
  21486. m.clearedwxs = false
  21487. m.removedwxs = nil
  21488. }
  21489. // Where appends a list predicates to the ServerMutation builder.
  21490. func (m *ServerMutation) Where(ps ...predicate.Server) {
  21491. m.predicates = append(m.predicates, ps...)
  21492. }
  21493. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  21494. // users can use type-assertion to append predicates that do not depend on any generated package.
  21495. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  21496. p := make([]predicate.Server, len(ps))
  21497. for i := range ps {
  21498. p[i] = ps[i]
  21499. }
  21500. m.Where(p...)
  21501. }
  21502. // Op returns the operation name.
  21503. func (m *ServerMutation) Op() Op {
  21504. return m.op
  21505. }
  21506. // SetOp allows setting the mutation operation.
  21507. func (m *ServerMutation) SetOp(op Op) {
  21508. m.op = op
  21509. }
  21510. // Type returns the node type of this mutation (Server).
  21511. func (m *ServerMutation) Type() string {
  21512. return m.typ
  21513. }
  21514. // Fields returns all fields that were changed during this mutation. Note that in
  21515. // order to get all numeric fields that were incremented/decremented, call
  21516. // AddedFields().
  21517. func (m *ServerMutation) Fields() []string {
  21518. fields := make([]string, 0, 8)
  21519. if m.created_at != nil {
  21520. fields = append(fields, server.FieldCreatedAt)
  21521. }
  21522. if m.updated_at != nil {
  21523. fields = append(fields, server.FieldUpdatedAt)
  21524. }
  21525. if m.status != nil {
  21526. fields = append(fields, server.FieldStatus)
  21527. }
  21528. if m.deleted_at != nil {
  21529. fields = append(fields, server.FieldDeletedAt)
  21530. }
  21531. if m.name != nil {
  21532. fields = append(fields, server.FieldName)
  21533. }
  21534. if m.public_ip != nil {
  21535. fields = append(fields, server.FieldPublicIP)
  21536. }
  21537. if m.private_ip != nil {
  21538. fields = append(fields, server.FieldPrivateIP)
  21539. }
  21540. if m.admin_port != nil {
  21541. fields = append(fields, server.FieldAdminPort)
  21542. }
  21543. return fields
  21544. }
  21545. // Field returns the value of a field with the given name. The second boolean
  21546. // return value indicates that this field was not set, or was not defined in the
  21547. // schema.
  21548. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  21549. switch name {
  21550. case server.FieldCreatedAt:
  21551. return m.CreatedAt()
  21552. case server.FieldUpdatedAt:
  21553. return m.UpdatedAt()
  21554. case server.FieldStatus:
  21555. return m.Status()
  21556. case server.FieldDeletedAt:
  21557. return m.DeletedAt()
  21558. case server.FieldName:
  21559. return m.Name()
  21560. case server.FieldPublicIP:
  21561. return m.PublicIP()
  21562. case server.FieldPrivateIP:
  21563. return m.PrivateIP()
  21564. case server.FieldAdminPort:
  21565. return m.AdminPort()
  21566. }
  21567. return nil, false
  21568. }
  21569. // OldField returns the old value of the field from the database. An error is
  21570. // returned if the mutation operation is not UpdateOne, or the query to the
  21571. // database failed.
  21572. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21573. switch name {
  21574. case server.FieldCreatedAt:
  21575. return m.OldCreatedAt(ctx)
  21576. case server.FieldUpdatedAt:
  21577. return m.OldUpdatedAt(ctx)
  21578. case server.FieldStatus:
  21579. return m.OldStatus(ctx)
  21580. case server.FieldDeletedAt:
  21581. return m.OldDeletedAt(ctx)
  21582. case server.FieldName:
  21583. return m.OldName(ctx)
  21584. case server.FieldPublicIP:
  21585. return m.OldPublicIP(ctx)
  21586. case server.FieldPrivateIP:
  21587. return m.OldPrivateIP(ctx)
  21588. case server.FieldAdminPort:
  21589. return m.OldAdminPort(ctx)
  21590. }
  21591. return nil, fmt.Errorf("unknown Server field %s", name)
  21592. }
  21593. // SetField sets the value of a field with the given name. It returns an error if
  21594. // the field is not defined in the schema, or if the type mismatched the field
  21595. // type.
  21596. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  21597. switch name {
  21598. case server.FieldCreatedAt:
  21599. v, ok := value.(time.Time)
  21600. if !ok {
  21601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21602. }
  21603. m.SetCreatedAt(v)
  21604. return nil
  21605. case server.FieldUpdatedAt:
  21606. v, ok := value.(time.Time)
  21607. if !ok {
  21608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21609. }
  21610. m.SetUpdatedAt(v)
  21611. return nil
  21612. case server.FieldStatus:
  21613. v, ok := value.(uint8)
  21614. if !ok {
  21615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21616. }
  21617. m.SetStatus(v)
  21618. return nil
  21619. case server.FieldDeletedAt:
  21620. v, ok := value.(time.Time)
  21621. if !ok {
  21622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21623. }
  21624. m.SetDeletedAt(v)
  21625. return nil
  21626. case server.FieldName:
  21627. v, ok := value.(string)
  21628. if !ok {
  21629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21630. }
  21631. m.SetName(v)
  21632. return nil
  21633. case server.FieldPublicIP:
  21634. v, ok := value.(string)
  21635. if !ok {
  21636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21637. }
  21638. m.SetPublicIP(v)
  21639. return nil
  21640. case server.FieldPrivateIP:
  21641. v, ok := value.(string)
  21642. if !ok {
  21643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21644. }
  21645. m.SetPrivateIP(v)
  21646. return nil
  21647. case server.FieldAdminPort:
  21648. v, ok := value.(string)
  21649. if !ok {
  21650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21651. }
  21652. m.SetAdminPort(v)
  21653. return nil
  21654. }
  21655. return fmt.Errorf("unknown Server field %s", name)
  21656. }
  21657. // AddedFields returns all numeric fields that were incremented/decremented during
  21658. // this mutation.
  21659. func (m *ServerMutation) AddedFields() []string {
  21660. var fields []string
  21661. if m.addstatus != nil {
  21662. fields = append(fields, server.FieldStatus)
  21663. }
  21664. return fields
  21665. }
  21666. // AddedField returns the numeric value that was incremented/decremented on a field
  21667. // with the given name. The second boolean return value indicates that this field
  21668. // was not set, or was not defined in the schema.
  21669. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  21670. switch name {
  21671. case server.FieldStatus:
  21672. return m.AddedStatus()
  21673. }
  21674. return nil, false
  21675. }
  21676. // AddField adds the value to the field with the given name. It returns an error if
  21677. // the field is not defined in the schema, or if the type mismatched the field
  21678. // type.
  21679. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  21680. switch name {
  21681. case server.FieldStatus:
  21682. v, ok := value.(int8)
  21683. if !ok {
  21684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21685. }
  21686. m.AddStatus(v)
  21687. return nil
  21688. }
  21689. return fmt.Errorf("unknown Server numeric field %s", name)
  21690. }
  21691. // ClearedFields returns all nullable fields that were cleared during this
  21692. // mutation.
  21693. func (m *ServerMutation) ClearedFields() []string {
  21694. var fields []string
  21695. if m.FieldCleared(server.FieldStatus) {
  21696. fields = append(fields, server.FieldStatus)
  21697. }
  21698. if m.FieldCleared(server.FieldDeletedAt) {
  21699. fields = append(fields, server.FieldDeletedAt)
  21700. }
  21701. return fields
  21702. }
  21703. // FieldCleared returns a boolean indicating if a field with the given name was
  21704. // cleared in this mutation.
  21705. func (m *ServerMutation) FieldCleared(name string) bool {
  21706. _, ok := m.clearedFields[name]
  21707. return ok
  21708. }
  21709. // ClearField clears the value of the field with the given name. It returns an
  21710. // error if the field is not defined in the schema.
  21711. func (m *ServerMutation) ClearField(name string) error {
  21712. switch name {
  21713. case server.FieldStatus:
  21714. m.ClearStatus()
  21715. return nil
  21716. case server.FieldDeletedAt:
  21717. m.ClearDeletedAt()
  21718. return nil
  21719. }
  21720. return fmt.Errorf("unknown Server nullable field %s", name)
  21721. }
  21722. // ResetField resets all changes in the mutation for the field with the given name.
  21723. // It returns an error if the field is not defined in the schema.
  21724. func (m *ServerMutation) ResetField(name string) error {
  21725. switch name {
  21726. case server.FieldCreatedAt:
  21727. m.ResetCreatedAt()
  21728. return nil
  21729. case server.FieldUpdatedAt:
  21730. m.ResetUpdatedAt()
  21731. return nil
  21732. case server.FieldStatus:
  21733. m.ResetStatus()
  21734. return nil
  21735. case server.FieldDeletedAt:
  21736. m.ResetDeletedAt()
  21737. return nil
  21738. case server.FieldName:
  21739. m.ResetName()
  21740. return nil
  21741. case server.FieldPublicIP:
  21742. m.ResetPublicIP()
  21743. return nil
  21744. case server.FieldPrivateIP:
  21745. m.ResetPrivateIP()
  21746. return nil
  21747. case server.FieldAdminPort:
  21748. m.ResetAdminPort()
  21749. return nil
  21750. }
  21751. return fmt.Errorf("unknown Server field %s", name)
  21752. }
  21753. // AddedEdges returns all edge names that were set/added in this mutation.
  21754. func (m *ServerMutation) AddedEdges() []string {
  21755. edges := make([]string, 0, 1)
  21756. if m.wxs != nil {
  21757. edges = append(edges, server.EdgeWxs)
  21758. }
  21759. return edges
  21760. }
  21761. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21762. // name in this mutation.
  21763. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  21764. switch name {
  21765. case server.EdgeWxs:
  21766. ids := make([]ent.Value, 0, len(m.wxs))
  21767. for id := range m.wxs {
  21768. ids = append(ids, id)
  21769. }
  21770. return ids
  21771. }
  21772. return nil
  21773. }
  21774. // RemovedEdges returns all edge names that were removed in this mutation.
  21775. func (m *ServerMutation) RemovedEdges() []string {
  21776. edges := make([]string, 0, 1)
  21777. if m.removedwxs != nil {
  21778. edges = append(edges, server.EdgeWxs)
  21779. }
  21780. return edges
  21781. }
  21782. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21783. // the given name in this mutation.
  21784. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  21785. switch name {
  21786. case server.EdgeWxs:
  21787. ids := make([]ent.Value, 0, len(m.removedwxs))
  21788. for id := range m.removedwxs {
  21789. ids = append(ids, id)
  21790. }
  21791. return ids
  21792. }
  21793. return nil
  21794. }
  21795. // ClearedEdges returns all edge names that were cleared in this mutation.
  21796. func (m *ServerMutation) ClearedEdges() []string {
  21797. edges := make([]string, 0, 1)
  21798. if m.clearedwxs {
  21799. edges = append(edges, server.EdgeWxs)
  21800. }
  21801. return edges
  21802. }
  21803. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21804. // was cleared in this mutation.
  21805. func (m *ServerMutation) EdgeCleared(name string) bool {
  21806. switch name {
  21807. case server.EdgeWxs:
  21808. return m.clearedwxs
  21809. }
  21810. return false
  21811. }
  21812. // ClearEdge clears the value of the edge with the given name. It returns an error
  21813. // if that edge is not defined in the schema.
  21814. func (m *ServerMutation) ClearEdge(name string) error {
  21815. switch name {
  21816. }
  21817. return fmt.Errorf("unknown Server unique edge %s", name)
  21818. }
  21819. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21820. // It returns an error if the edge is not defined in the schema.
  21821. func (m *ServerMutation) ResetEdge(name string) error {
  21822. switch name {
  21823. case server.EdgeWxs:
  21824. m.ResetWxs()
  21825. return nil
  21826. }
  21827. return fmt.Errorf("unknown Server edge %s", name)
  21828. }
  21829. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  21830. type SopNodeMutation struct {
  21831. config
  21832. op Op
  21833. typ string
  21834. id *uint64
  21835. created_at *time.Time
  21836. updated_at *time.Time
  21837. status *uint8
  21838. addstatus *int8
  21839. deleted_at *time.Time
  21840. parent_id *uint64
  21841. addparent_id *int64
  21842. name *string
  21843. condition_type *int
  21844. addcondition_type *int
  21845. condition_list *[]string
  21846. appendcondition_list []string
  21847. no_reply_condition *uint64
  21848. addno_reply_condition *int64
  21849. no_reply_unit *string
  21850. action_message *[]custom_types.Action
  21851. appendaction_message []custom_types.Action
  21852. action_label_add *[]uint64
  21853. appendaction_label_add []uint64
  21854. action_label_del *[]uint64
  21855. appendaction_label_del []uint64
  21856. action_forward **custom_types.ActionForward
  21857. clearedFields map[string]struct{}
  21858. sop_stage *uint64
  21859. clearedsop_stage bool
  21860. node_messages map[uint64]struct{}
  21861. removednode_messages map[uint64]struct{}
  21862. clearednode_messages bool
  21863. done bool
  21864. oldValue func(context.Context) (*SopNode, error)
  21865. predicates []predicate.SopNode
  21866. }
  21867. var _ ent.Mutation = (*SopNodeMutation)(nil)
  21868. // sopnodeOption allows management of the mutation configuration using functional options.
  21869. type sopnodeOption func(*SopNodeMutation)
  21870. // newSopNodeMutation creates new mutation for the SopNode entity.
  21871. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  21872. m := &SopNodeMutation{
  21873. config: c,
  21874. op: op,
  21875. typ: TypeSopNode,
  21876. clearedFields: make(map[string]struct{}),
  21877. }
  21878. for _, opt := range opts {
  21879. opt(m)
  21880. }
  21881. return m
  21882. }
  21883. // withSopNodeID sets the ID field of the mutation.
  21884. func withSopNodeID(id uint64) sopnodeOption {
  21885. return func(m *SopNodeMutation) {
  21886. var (
  21887. err error
  21888. once sync.Once
  21889. value *SopNode
  21890. )
  21891. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  21892. once.Do(func() {
  21893. if m.done {
  21894. err = errors.New("querying old values post mutation is not allowed")
  21895. } else {
  21896. value, err = m.Client().SopNode.Get(ctx, id)
  21897. }
  21898. })
  21899. return value, err
  21900. }
  21901. m.id = &id
  21902. }
  21903. }
  21904. // withSopNode sets the old SopNode of the mutation.
  21905. func withSopNode(node *SopNode) sopnodeOption {
  21906. return func(m *SopNodeMutation) {
  21907. m.oldValue = func(context.Context) (*SopNode, error) {
  21908. return node, nil
  21909. }
  21910. m.id = &node.ID
  21911. }
  21912. }
  21913. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21914. // executed in a transaction (ent.Tx), a transactional client is returned.
  21915. func (m SopNodeMutation) Client() *Client {
  21916. client := &Client{config: m.config}
  21917. client.init()
  21918. return client
  21919. }
  21920. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21921. // it returns an error otherwise.
  21922. func (m SopNodeMutation) Tx() (*Tx, error) {
  21923. if _, ok := m.driver.(*txDriver); !ok {
  21924. return nil, errors.New("ent: mutation is not running in a transaction")
  21925. }
  21926. tx := &Tx{config: m.config}
  21927. tx.init()
  21928. return tx, nil
  21929. }
  21930. // SetID sets the value of the id field. Note that this
  21931. // operation is only accepted on creation of SopNode entities.
  21932. func (m *SopNodeMutation) SetID(id uint64) {
  21933. m.id = &id
  21934. }
  21935. // ID returns the ID value in the mutation. Note that the ID is only available
  21936. // if it was provided to the builder or after it was returned from the database.
  21937. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  21938. if m.id == nil {
  21939. return
  21940. }
  21941. return *m.id, true
  21942. }
  21943. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21944. // That means, if the mutation is applied within a transaction with an isolation level such
  21945. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21946. // or updated by the mutation.
  21947. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  21948. switch {
  21949. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21950. id, exists := m.ID()
  21951. if exists {
  21952. return []uint64{id}, nil
  21953. }
  21954. fallthrough
  21955. case m.op.Is(OpUpdate | OpDelete):
  21956. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  21957. default:
  21958. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21959. }
  21960. }
  21961. // SetCreatedAt sets the "created_at" field.
  21962. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  21963. m.created_at = &t
  21964. }
  21965. // CreatedAt returns the value of the "created_at" field in the mutation.
  21966. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  21967. v := m.created_at
  21968. if v == nil {
  21969. return
  21970. }
  21971. return *v, true
  21972. }
  21973. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  21974. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21976. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21977. if !m.op.Is(OpUpdateOne) {
  21978. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21979. }
  21980. if m.id == nil || m.oldValue == nil {
  21981. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21982. }
  21983. oldValue, err := m.oldValue(ctx)
  21984. if err != nil {
  21985. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21986. }
  21987. return oldValue.CreatedAt, nil
  21988. }
  21989. // ResetCreatedAt resets all changes to the "created_at" field.
  21990. func (m *SopNodeMutation) ResetCreatedAt() {
  21991. m.created_at = nil
  21992. }
  21993. // SetUpdatedAt sets the "updated_at" field.
  21994. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  21995. m.updated_at = &t
  21996. }
  21997. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21998. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  21999. v := m.updated_at
  22000. if v == nil {
  22001. return
  22002. }
  22003. return *v, true
  22004. }
  22005. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  22006. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22007. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22008. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22009. if !m.op.Is(OpUpdateOne) {
  22010. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22011. }
  22012. if m.id == nil || m.oldValue == nil {
  22013. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22014. }
  22015. oldValue, err := m.oldValue(ctx)
  22016. if err != nil {
  22017. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22018. }
  22019. return oldValue.UpdatedAt, nil
  22020. }
  22021. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22022. func (m *SopNodeMutation) ResetUpdatedAt() {
  22023. m.updated_at = nil
  22024. }
  22025. // SetStatus sets the "status" field.
  22026. func (m *SopNodeMutation) SetStatus(u uint8) {
  22027. m.status = &u
  22028. m.addstatus = nil
  22029. }
  22030. // Status returns the value of the "status" field in the mutation.
  22031. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  22032. v := m.status
  22033. if v == nil {
  22034. return
  22035. }
  22036. return *v, true
  22037. }
  22038. // OldStatus returns the old "status" field's value of the SopNode entity.
  22039. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22041. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22042. if !m.op.Is(OpUpdateOne) {
  22043. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22044. }
  22045. if m.id == nil || m.oldValue == nil {
  22046. return v, errors.New("OldStatus requires an ID field in the mutation")
  22047. }
  22048. oldValue, err := m.oldValue(ctx)
  22049. if err != nil {
  22050. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22051. }
  22052. return oldValue.Status, nil
  22053. }
  22054. // AddStatus adds u to the "status" field.
  22055. func (m *SopNodeMutation) AddStatus(u int8) {
  22056. if m.addstatus != nil {
  22057. *m.addstatus += u
  22058. } else {
  22059. m.addstatus = &u
  22060. }
  22061. }
  22062. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22063. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  22064. v := m.addstatus
  22065. if v == nil {
  22066. return
  22067. }
  22068. return *v, true
  22069. }
  22070. // ClearStatus clears the value of the "status" field.
  22071. func (m *SopNodeMutation) ClearStatus() {
  22072. m.status = nil
  22073. m.addstatus = nil
  22074. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  22075. }
  22076. // StatusCleared returns if the "status" field was cleared in this mutation.
  22077. func (m *SopNodeMutation) StatusCleared() bool {
  22078. _, ok := m.clearedFields[sopnode.FieldStatus]
  22079. return ok
  22080. }
  22081. // ResetStatus resets all changes to the "status" field.
  22082. func (m *SopNodeMutation) ResetStatus() {
  22083. m.status = nil
  22084. m.addstatus = nil
  22085. delete(m.clearedFields, sopnode.FieldStatus)
  22086. }
  22087. // SetDeletedAt sets the "deleted_at" field.
  22088. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  22089. m.deleted_at = &t
  22090. }
  22091. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22092. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  22093. v := m.deleted_at
  22094. if v == nil {
  22095. return
  22096. }
  22097. return *v, true
  22098. }
  22099. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  22100. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22102. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22103. if !m.op.Is(OpUpdateOne) {
  22104. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22105. }
  22106. if m.id == nil || m.oldValue == nil {
  22107. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22108. }
  22109. oldValue, err := m.oldValue(ctx)
  22110. if err != nil {
  22111. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22112. }
  22113. return oldValue.DeletedAt, nil
  22114. }
  22115. // ClearDeletedAt clears the value of the "deleted_at" field.
  22116. func (m *SopNodeMutation) ClearDeletedAt() {
  22117. m.deleted_at = nil
  22118. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  22119. }
  22120. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22121. func (m *SopNodeMutation) DeletedAtCleared() bool {
  22122. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  22123. return ok
  22124. }
  22125. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22126. func (m *SopNodeMutation) ResetDeletedAt() {
  22127. m.deleted_at = nil
  22128. delete(m.clearedFields, sopnode.FieldDeletedAt)
  22129. }
  22130. // SetStageID sets the "stage_id" field.
  22131. func (m *SopNodeMutation) SetStageID(u uint64) {
  22132. m.sop_stage = &u
  22133. }
  22134. // StageID returns the value of the "stage_id" field in the mutation.
  22135. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  22136. v := m.sop_stage
  22137. if v == nil {
  22138. return
  22139. }
  22140. return *v, true
  22141. }
  22142. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  22143. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22145. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  22146. if !m.op.Is(OpUpdateOne) {
  22147. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  22148. }
  22149. if m.id == nil || m.oldValue == nil {
  22150. return v, errors.New("OldStageID requires an ID field in the mutation")
  22151. }
  22152. oldValue, err := m.oldValue(ctx)
  22153. if err != nil {
  22154. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  22155. }
  22156. return oldValue.StageID, nil
  22157. }
  22158. // ResetStageID resets all changes to the "stage_id" field.
  22159. func (m *SopNodeMutation) ResetStageID() {
  22160. m.sop_stage = nil
  22161. }
  22162. // SetParentID sets the "parent_id" field.
  22163. func (m *SopNodeMutation) SetParentID(u uint64) {
  22164. m.parent_id = &u
  22165. m.addparent_id = nil
  22166. }
  22167. // ParentID returns the value of the "parent_id" field in the mutation.
  22168. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  22169. v := m.parent_id
  22170. if v == nil {
  22171. return
  22172. }
  22173. return *v, true
  22174. }
  22175. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  22176. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22178. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  22179. if !m.op.Is(OpUpdateOne) {
  22180. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  22181. }
  22182. if m.id == nil || m.oldValue == nil {
  22183. return v, errors.New("OldParentID requires an ID field in the mutation")
  22184. }
  22185. oldValue, err := m.oldValue(ctx)
  22186. if err != nil {
  22187. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  22188. }
  22189. return oldValue.ParentID, nil
  22190. }
  22191. // AddParentID adds u to the "parent_id" field.
  22192. func (m *SopNodeMutation) AddParentID(u int64) {
  22193. if m.addparent_id != nil {
  22194. *m.addparent_id += u
  22195. } else {
  22196. m.addparent_id = &u
  22197. }
  22198. }
  22199. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  22200. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  22201. v := m.addparent_id
  22202. if v == nil {
  22203. return
  22204. }
  22205. return *v, true
  22206. }
  22207. // ResetParentID resets all changes to the "parent_id" field.
  22208. func (m *SopNodeMutation) ResetParentID() {
  22209. m.parent_id = nil
  22210. m.addparent_id = nil
  22211. }
  22212. // SetName sets the "name" field.
  22213. func (m *SopNodeMutation) SetName(s string) {
  22214. m.name = &s
  22215. }
  22216. // Name returns the value of the "name" field in the mutation.
  22217. func (m *SopNodeMutation) Name() (r string, exists bool) {
  22218. v := m.name
  22219. if v == nil {
  22220. return
  22221. }
  22222. return *v, true
  22223. }
  22224. // OldName returns the old "name" field's value of the SopNode entity.
  22225. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22227. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  22228. if !m.op.Is(OpUpdateOne) {
  22229. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22230. }
  22231. if m.id == nil || m.oldValue == nil {
  22232. return v, errors.New("OldName requires an ID field in the mutation")
  22233. }
  22234. oldValue, err := m.oldValue(ctx)
  22235. if err != nil {
  22236. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22237. }
  22238. return oldValue.Name, nil
  22239. }
  22240. // ResetName resets all changes to the "name" field.
  22241. func (m *SopNodeMutation) ResetName() {
  22242. m.name = nil
  22243. }
  22244. // SetConditionType sets the "condition_type" field.
  22245. func (m *SopNodeMutation) SetConditionType(i int) {
  22246. m.condition_type = &i
  22247. m.addcondition_type = nil
  22248. }
  22249. // ConditionType returns the value of the "condition_type" field in the mutation.
  22250. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  22251. v := m.condition_type
  22252. if v == nil {
  22253. return
  22254. }
  22255. return *v, true
  22256. }
  22257. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  22258. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22260. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22261. if !m.op.Is(OpUpdateOne) {
  22262. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22263. }
  22264. if m.id == nil || m.oldValue == nil {
  22265. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22266. }
  22267. oldValue, err := m.oldValue(ctx)
  22268. if err != nil {
  22269. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22270. }
  22271. return oldValue.ConditionType, nil
  22272. }
  22273. // AddConditionType adds i to the "condition_type" field.
  22274. func (m *SopNodeMutation) AddConditionType(i int) {
  22275. if m.addcondition_type != nil {
  22276. *m.addcondition_type += i
  22277. } else {
  22278. m.addcondition_type = &i
  22279. }
  22280. }
  22281. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22282. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  22283. v := m.addcondition_type
  22284. if v == nil {
  22285. return
  22286. }
  22287. return *v, true
  22288. }
  22289. // ResetConditionType resets all changes to the "condition_type" field.
  22290. func (m *SopNodeMutation) ResetConditionType() {
  22291. m.condition_type = nil
  22292. m.addcondition_type = nil
  22293. }
  22294. // SetConditionList sets the "condition_list" field.
  22295. func (m *SopNodeMutation) SetConditionList(s []string) {
  22296. m.condition_list = &s
  22297. m.appendcondition_list = nil
  22298. }
  22299. // ConditionList returns the value of the "condition_list" field in the mutation.
  22300. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  22301. v := m.condition_list
  22302. if v == nil {
  22303. return
  22304. }
  22305. return *v, true
  22306. }
  22307. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  22308. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22310. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  22311. if !m.op.Is(OpUpdateOne) {
  22312. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22313. }
  22314. if m.id == nil || m.oldValue == nil {
  22315. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22316. }
  22317. oldValue, err := m.oldValue(ctx)
  22318. if err != nil {
  22319. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22320. }
  22321. return oldValue.ConditionList, nil
  22322. }
  22323. // AppendConditionList adds s to the "condition_list" field.
  22324. func (m *SopNodeMutation) AppendConditionList(s []string) {
  22325. m.appendcondition_list = append(m.appendcondition_list, s...)
  22326. }
  22327. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22328. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  22329. if len(m.appendcondition_list) == 0 {
  22330. return nil, false
  22331. }
  22332. return m.appendcondition_list, true
  22333. }
  22334. // ClearConditionList clears the value of the "condition_list" field.
  22335. func (m *SopNodeMutation) ClearConditionList() {
  22336. m.condition_list = nil
  22337. m.appendcondition_list = nil
  22338. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  22339. }
  22340. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  22341. func (m *SopNodeMutation) ConditionListCleared() bool {
  22342. _, ok := m.clearedFields[sopnode.FieldConditionList]
  22343. return ok
  22344. }
  22345. // ResetConditionList resets all changes to the "condition_list" field.
  22346. func (m *SopNodeMutation) ResetConditionList() {
  22347. m.condition_list = nil
  22348. m.appendcondition_list = nil
  22349. delete(m.clearedFields, sopnode.FieldConditionList)
  22350. }
  22351. // SetNoReplyCondition sets the "no_reply_condition" field.
  22352. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  22353. m.no_reply_condition = &u
  22354. m.addno_reply_condition = nil
  22355. }
  22356. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  22357. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  22358. v := m.no_reply_condition
  22359. if v == nil {
  22360. return
  22361. }
  22362. return *v, true
  22363. }
  22364. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  22365. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22367. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  22368. if !m.op.Is(OpUpdateOne) {
  22369. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  22370. }
  22371. if m.id == nil || m.oldValue == nil {
  22372. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  22373. }
  22374. oldValue, err := m.oldValue(ctx)
  22375. if err != nil {
  22376. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  22377. }
  22378. return oldValue.NoReplyCondition, nil
  22379. }
  22380. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  22381. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  22382. if m.addno_reply_condition != nil {
  22383. *m.addno_reply_condition += u
  22384. } else {
  22385. m.addno_reply_condition = &u
  22386. }
  22387. }
  22388. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  22389. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  22390. v := m.addno_reply_condition
  22391. if v == nil {
  22392. return
  22393. }
  22394. return *v, true
  22395. }
  22396. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  22397. func (m *SopNodeMutation) ResetNoReplyCondition() {
  22398. m.no_reply_condition = nil
  22399. m.addno_reply_condition = nil
  22400. }
  22401. // SetNoReplyUnit sets the "no_reply_unit" field.
  22402. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  22403. m.no_reply_unit = &s
  22404. }
  22405. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  22406. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  22407. v := m.no_reply_unit
  22408. if v == nil {
  22409. return
  22410. }
  22411. return *v, true
  22412. }
  22413. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  22414. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22416. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  22417. if !m.op.Is(OpUpdateOne) {
  22418. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  22419. }
  22420. if m.id == nil || m.oldValue == nil {
  22421. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  22422. }
  22423. oldValue, err := m.oldValue(ctx)
  22424. if err != nil {
  22425. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  22426. }
  22427. return oldValue.NoReplyUnit, nil
  22428. }
  22429. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  22430. func (m *SopNodeMutation) ResetNoReplyUnit() {
  22431. m.no_reply_unit = nil
  22432. }
  22433. // SetActionMessage sets the "action_message" field.
  22434. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  22435. m.action_message = &ct
  22436. m.appendaction_message = nil
  22437. }
  22438. // ActionMessage returns the value of the "action_message" field in the mutation.
  22439. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22440. v := m.action_message
  22441. if v == nil {
  22442. return
  22443. }
  22444. return *v, true
  22445. }
  22446. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  22447. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22449. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22450. if !m.op.Is(OpUpdateOne) {
  22451. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22452. }
  22453. if m.id == nil || m.oldValue == nil {
  22454. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22455. }
  22456. oldValue, err := m.oldValue(ctx)
  22457. if err != nil {
  22458. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22459. }
  22460. return oldValue.ActionMessage, nil
  22461. }
  22462. // AppendActionMessage adds ct to the "action_message" field.
  22463. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  22464. m.appendaction_message = append(m.appendaction_message, ct...)
  22465. }
  22466. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22467. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22468. if len(m.appendaction_message) == 0 {
  22469. return nil, false
  22470. }
  22471. return m.appendaction_message, true
  22472. }
  22473. // ClearActionMessage clears the value of the "action_message" field.
  22474. func (m *SopNodeMutation) ClearActionMessage() {
  22475. m.action_message = nil
  22476. m.appendaction_message = nil
  22477. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  22478. }
  22479. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22480. func (m *SopNodeMutation) ActionMessageCleared() bool {
  22481. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  22482. return ok
  22483. }
  22484. // ResetActionMessage resets all changes to the "action_message" field.
  22485. func (m *SopNodeMutation) ResetActionMessage() {
  22486. m.action_message = nil
  22487. m.appendaction_message = nil
  22488. delete(m.clearedFields, sopnode.FieldActionMessage)
  22489. }
  22490. // SetActionLabelAdd sets the "action_label_add" field.
  22491. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  22492. m.action_label_add = &u
  22493. m.appendaction_label_add = nil
  22494. }
  22495. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22496. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22497. v := m.action_label_add
  22498. if v == nil {
  22499. return
  22500. }
  22501. return *v, true
  22502. }
  22503. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  22504. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22506. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22507. if !m.op.Is(OpUpdateOne) {
  22508. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22509. }
  22510. if m.id == nil || m.oldValue == nil {
  22511. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22512. }
  22513. oldValue, err := m.oldValue(ctx)
  22514. if err != nil {
  22515. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22516. }
  22517. return oldValue.ActionLabelAdd, nil
  22518. }
  22519. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22520. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  22521. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22522. }
  22523. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22524. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22525. if len(m.appendaction_label_add) == 0 {
  22526. return nil, false
  22527. }
  22528. return m.appendaction_label_add, true
  22529. }
  22530. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22531. func (m *SopNodeMutation) ClearActionLabelAdd() {
  22532. m.action_label_add = nil
  22533. m.appendaction_label_add = nil
  22534. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  22535. }
  22536. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22537. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  22538. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  22539. return ok
  22540. }
  22541. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22542. func (m *SopNodeMutation) ResetActionLabelAdd() {
  22543. m.action_label_add = nil
  22544. m.appendaction_label_add = nil
  22545. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  22546. }
  22547. // SetActionLabelDel sets the "action_label_del" field.
  22548. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  22549. m.action_label_del = &u
  22550. m.appendaction_label_del = nil
  22551. }
  22552. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22553. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  22554. v := m.action_label_del
  22555. if v == nil {
  22556. return
  22557. }
  22558. return *v, true
  22559. }
  22560. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  22561. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22563. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22564. if !m.op.Is(OpUpdateOne) {
  22565. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22566. }
  22567. if m.id == nil || m.oldValue == nil {
  22568. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22569. }
  22570. oldValue, err := m.oldValue(ctx)
  22571. if err != nil {
  22572. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22573. }
  22574. return oldValue.ActionLabelDel, nil
  22575. }
  22576. // AppendActionLabelDel adds u to the "action_label_del" field.
  22577. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  22578. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22579. }
  22580. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22581. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22582. if len(m.appendaction_label_del) == 0 {
  22583. return nil, false
  22584. }
  22585. return m.appendaction_label_del, true
  22586. }
  22587. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22588. func (m *SopNodeMutation) ClearActionLabelDel() {
  22589. m.action_label_del = nil
  22590. m.appendaction_label_del = nil
  22591. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  22592. }
  22593. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22594. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  22595. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  22596. return ok
  22597. }
  22598. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22599. func (m *SopNodeMutation) ResetActionLabelDel() {
  22600. m.action_label_del = nil
  22601. m.appendaction_label_del = nil
  22602. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  22603. }
  22604. // SetActionForward sets the "action_forward" field.
  22605. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22606. m.action_forward = &ctf
  22607. }
  22608. // ActionForward returns the value of the "action_forward" field in the mutation.
  22609. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22610. v := m.action_forward
  22611. if v == nil {
  22612. return
  22613. }
  22614. return *v, true
  22615. }
  22616. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  22617. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  22618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22619. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22620. if !m.op.Is(OpUpdateOne) {
  22621. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22622. }
  22623. if m.id == nil || m.oldValue == nil {
  22624. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22625. }
  22626. oldValue, err := m.oldValue(ctx)
  22627. if err != nil {
  22628. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22629. }
  22630. return oldValue.ActionForward, nil
  22631. }
  22632. // ClearActionForward clears the value of the "action_forward" field.
  22633. func (m *SopNodeMutation) ClearActionForward() {
  22634. m.action_forward = nil
  22635. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  22636. }
  22637. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22638. func (m *SopNodeMutation) ActionForwardCleared() bool {
  22639. _, ok := m.clearedFields[sopnode.FieldActionForward]
  22640. return ok
  22641. }
  22642. // ResetActionForward resets all changes to the "action_forward" field.
  22643. func (m *SopNodeMutation) ResetActionForward() {
  22644. m.action_forward = nil
  22645. delete(m.clearedFields, sopnode.FieldActionForward)
  22646. }
  22647. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  22648. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  22649. m.sop_stage = &id
  22650. }
  22651. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  22652. func (m *SopNodeMutation) ClearSopStage() {
  22653. m.clearedsop_stage = true
  22654. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  22655. }
  22656. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  22657. func (m *SopNodeMutation) SopStageCleared() bool {
  22658. return m.clearedsop_stage
  22659. }
  22660. // SopStageID returns the "sop_stage" edge ID in the mutation.
  22661. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  22662. if m.sop_stage != nil {
  22663. return *m.sop_stage, true
  22664. }
  22665. return
  22666. }
  22667. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  22668. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22669. // SopStageID instead. It exists only for internal usage by the builders.
  22670. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  22671. if id := m.sop_stage; id != nil {
  22672. ids = append(ids, *id)
  22673. }
  22674. return
  22675. }
  22676. // ResetSopStage resets all changes to the "sop_stage" edge.
  22677. func (m *SopNodeMutation) ResetSopStage() {
  22678. m.sop_stage = nil
  22679. m.clearedsop_stage = false
  22680. }
  22681. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  22682. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  22683. if m.node_messages == nil {
  22684. m.node_messages = make(map[uint64]struct{})
  22685. }
  22686. for i := range ids {
  22687. m.node_messages[ids[i]] = struct{}{}
  22688. }
  22689. }
  22690. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  22691. func (m *SopNodeMutation) ClearNodeMessages() {
  22692. m.clearednode_messages = true
  22693. }
  22694. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  22695. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  22696. return m.clearednode_messages
  22697. }
  22698. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  22699. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  22700. if m.removednode_messages == nil {
  22701. m.removednode_messages = make(map[uint64]struct{})
  22702. }
  22703. for i := range ids {
  22704. delete(m.node_messages, ids[i])
  22705. m.removednode_messages[ids[i]] = struct{}{}
  22706. }
  22707. }
  22708. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  22709. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  22710. for id := range m.removednode_messages {
  22711. ids = append(ids, id)
  22712. }
  22713. return
  22714. }
  22715. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  22716. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  22717. for id := range m.node_messages {
  22718. ids = append(ids, id)
  22719. }
  22720. return
  22721. }
  22722. // ResetNodeMessages resets all changes to the "node_messages" edge.
  22723. func (m *SopNodeMutation) ResetNodeMessages() {
  22724. m.node_messages = nil
  22725. m.clearednode_messages = false
  22726. m.removednode_messages = nil
  22727. }
  22728. // Where appends a list predicates to the SopNodeMutation builder.
  22729. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  22730. m.predicates = append(m.predicates, ps...)
  22731. }
  22732. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  22733. // users can use type-assertion to append predicates that do not depend on any generated package.
  22734. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  22735. p := make([]predicate.SopNode, len(ps))
  22736. for i := range ps {
  22737. p[i] = ps[i]
  22738. }
  22739. m.Where(p...)
  22740. }
  22741. // Op returns the operation name.
  22742. func (m *SopNodeMutation) Op() Op {
  22743. return m.op
  22744. }
  22745. // SetOp allows setting the mutation operation.
  22746. func (m *SopNodeMutation) SetOp(op Op) {
  22747. m.op = op
  22748. }
  22749. // Type returns the node type of this mutation (SopNode).
  22750. func (m *SopNodeMutation) Type() string {
  22751. return m.typ
  22752. }
  22753. // Fields returns all fields that were changed during this mutation. Note that in
  22754. // order to get all numeric fields that were incremented/decremented, call
  22755. // AddedFields().
  22756. func (m *SopNodeMutation) Fields() []string {
  22757. fields := make([]string, 0, 15)
  22758. if m.created_at != nil {
  22759. fields = append(fields, sopnode.FieldCreatedAt)
  22760. }
  22761. if m.updated_at != nil {
  22762. fields = append(fields, sopnode.FieldUpdatedAt)
  22763. }
  22764. if m.status != nil {
  22765. fields = append(fields, sopnode.FieldStatus)
  22766. }
  22767. if m.deleted_at != nil {
  22768. fields = append(fields, sopnode.FieldDeletedAt)
  22769. }
  22770. if m.sop_stage != nil {
  22771. fields = append(fields, sopnode.FieldStageID)
  22772. }
  22773. if m.parent_id != nil {
  22774. fields = append(fields, sopnode.FieldParentID)
  22775. }
  22776. if m.name != nil {
  22777. fields = append(fields, sopnode.FieldName)
  22778. }
  22779. if m.condition_type != nil {
  22780. fields = append(fields, sopnode.FieldConditionType)
  22781. }
  22782. if m.condition_list != nil {
  22783. fields = append(fields, sopnode.FieldConditionList)
  22784. }
  22785. if m.no_reply_condition != nil {
  22786. fields = append(fields, sopnode.FieldNoReplyCondition)
  22787. }
  22788. if m.no_reply_unit != nil {
  22789. fields = append(fields, sopnode.FieldNoReplyUnit)
  22790. }
  22791. if m.action_message != nil {
  22792. fields = append(fields, sopnode.FieldActionMessage)
  22793. }
  22794. if m.action_label_add != nil {
  22795. fields = append(fields, sopnode.FieldActionLabelAdd)
  22796. }
  22797. if m.action_label_del != nil {
  22798. fields = append(fields, sopnode.FieldActionLabelDel)
  22799. }
  22800. if m.action_forward != nil {
  22801. fields = append(fields, sopnode.FieldActionForward)
  22802. }
  22803. return fields
  22804. }
  22805. // Field returns the value of a field with the given name. The second boolean
  22806. // return value indicates that this field was not set, or was not defined in the
  22807. // schema.
  22808. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  22809. switch name {
  22810. case sopnode.FieldCreatedAt:
  22811. return m.CreatedAt()
  22812. case sopnode.FieldUpdatedAt:
  22813. return m.UpdatedAt()
  22814. case sopnode.FieldStatus:
  22815. return m.Status()
  22816. case sopnode.FieldDeletedAt:
  22817. return m.DeletedAt()
  22818. case sopnode.FieldStageID:
  22819. return m.StageID()
  22820. case sopnode.FieldParentID:
  22821. return m.ParentID()
  22822. case sopnode.FieldName:
  22823. return m.Name()
  22824. case sopnode.FieldConditionType:
  22825. return m.ConditionType()
  22826. case sopnode.FieldConditionList:
  22827. return m.ConditionList()
  22828. case sopnode.FieldNoReplyCondition:
  22829. return m.NoReplyCondition()
  22830. case sopnode.FieldNoReplyUnit:
  22831. return m.NoReplyUnit()
  22832. case sopnode.FieldActionMessage:
  22833. return m.ActionMessage()
  22834. case sopnode.FieldActionLabelAdd:
  22835. return m.ActionLabelAdd()
  22836. case sopnode.FieldActionLabelDel:
  22837. return m.ActionLabelDel()
  22838. case sopnode.FieldActionForward:
  22839. return m.ActionForward()
  22840. }
  22841. return nil, false
  22842. }
  22843. // OldField returns the old value of the field from the database. An error is
  22844. // returned if the mutation operation is not UpdateOne, or the query to the
  22845. // database failed.
  22846. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22847. switch name {
  22848. case sopnode.FieldCreatedAt:
  22849. return m.OldCreatedAt(ctx)
  22850. case sopnode.FieldUpdatedAt:
  22851. return m.OldUpdatedAt(ctx)
  22852. case sopnode.FieldStatus:
  22853. return m.OldStatus(ctx)
  22854. case sopnode.FieldDeletedAt:
  22855. return m.OldDeletedAt(ctx)
  22856. case sopnode.FieldStageID:
  22857. return m.OldStageID(ctx)
  22858. case sopnode.FieldParentID:
  22859. return m.OldParentID(ctx)
  22860. case sopnode.FieldName:
  22861. return m.OldName(ctx)
  22862. case sopnode.FieldConditionType:
  22863. return m.OldConditionType(ctx)
  22864. case sopnode.FieldConditionList:
  22865. return m.OldConditionList(ctx)
  22866. case sopnode.FieldNoReplyCondition:
  22867. return m.OldNoReplyCondition(ctx)
  22868. case sopnode.FieldNoReplyUnit:
  22869. return m.OldNoReplyUnit(ctx)
  22870. case sopnode.FieldActionMessage:
  22871. return m.OldActionMessage(ctx)
  22872. case sopnode.FieldActionLabelAdd:
  22873. return m.OldActionLabelAdd(ctx)
  22874. case sopnode.FieldActionLabelDel:
  22875. return m.OldActionLabelDel(ctx)
  22876. case sopnode.FieldActionForward:
  22877. return m.OldActionForward(ctx)
  22878. }
  22879. return nil, fmt.Errorf("unknown SopNode field %s", name)
  22880. }
  22881. // SetField sets the value of a field with the given name. It returns an error if
  22882. // the field is not defined in the schema, or if the type mismatched the field
  22883. // type.
  22884. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  22885. switch name {
  22886. case sopnode.FieldCreatedAt:
  22887. v, ok := value.(time.Time)
  22888. if !ok {
  22889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22890. }
  22891. m.SetCreatedAt(v)
  22892. return nil
  22893. case sopnode.FieldUpdatedAt:
  22894. v, ok := value.(time.Time)
  22895. if !ok {
  22896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22897. }
  22898. m.SetUpdatedAt(v)
  22899. return nil
  22900. case sopnode.FieldStatus:
  22901. v, ok := value.(uint8)
  22902. if !ok {
  22903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22904. }
  22905. m.SetStatus(v)
  22906. return nil
  22907. case sopnode.FieldDeletedAt:
  22908. v, ok := value.(time.Time)
  22909. if !ok {
  22910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22911. }
  22912. m.SetDeletedAt(v)
  22913. return nil
  22914. case sopnode.FieldStageID:
  22915. v, ok := value.(uint64)
  22916. if !ok {
  22917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22918. }
  22919. m.SetStageID(v)
  22920. return nil
  22921. case sopnode.FieldParentID:
  22922. v, ok := value.(uint64)
  22923. if !ok {
  22924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22925. }
  22926. m.SetParentID(v)
  22927. return nil
  22928. case sopnode.FieldName:
  22929. v, ok := value.(string)
  22930. if !ok {
  22931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22932. }
  22933. m.SetName(v)
  22934. return nil
  22935. case sopnode.FieldConditionType:
  22936. v, ok := value.(int)
  22937. if !ok {
  22938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22939. }
  22940. m.SetConditionType(v)
  22941. return nil
  22942. case sopnode.FieldConditionList:
  22943. v, ok := value.([]string)
  22944. if !ok {
  22945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22946. }
  22947. m.SetConditionList(v)
  22948. return nil
  22949. case sopnode.FieldNoReplyCondition:
  22950. v, ok := value.(uint64)
  22951. if !ok {
  22952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22953. }
  22954. m.SetNoReplyCondition(v)
  22955. return nil
  22956. case sopnode.FieldNoReplyUnit:
  22957. v, ok := value.(string)
  22958. if !ok {
  22959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22960. }
  22961. m.SetNoReplyUnit(v)
  22962. return nil
  22963. case sopnode.FieldActionMessage:
  22964. v, ok := value.([]custom_types.Action)
  22965. if !ok {
  22966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22967. }
  22968. m.SetActionMessage(v)
  22969. return nil
  22970. case sopnode.FieldActionLabelAdd:
  22971. v, ok := value.([]uint64)
  22972. if !ok {
  22973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22974. }
  22975. m.SetActionLabelAdd(v)
  22976. return nil
  22977. case sopnode.FieldActionLabelDel:
  22978. v, ok := value.([]uint64)
  22979. if !ok {
  22980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22981. }
  22982. m.SetActionLabelDel(v)
  22983. return nil
  22984. case sopnode.FieldActionForward:
  22985. v, ok := value.(*custom_types.ActionForward)
  22986. if !ok {
  22987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22988. }
  22989. m.SetActionForward(v)
  22990. return nil
  22991. }
  22992. return fmt.Errorf("unknown SopNode field %s", name)
  22993. }
  22994. // AddedFields returns all numeric fields that were incremented/decremented during
  22995. // this mutation.
  22996. func (m *SopNodeMutation) AddedFields() []string {
  22997. var fields []string
  22998. if m.addstatus != nil {
  22999. fields = append(fields, sopnode.FieldStatus)
  23000. }
  23001. if m.addparent_id != nil {
  23002. fields = append(fields, sopnode.FieldParentID)
  23003. }
  23004. if m.addcondition_type != nil {
  23005. fields = append(fields, sopnode.FieldConditionType)
  23006. }
  23007. if m.addno_reply_condition != nil {
  23008. fields = append(fields, sopnode.FieldNoReplyCondition)
  23009. }
  23010. return fields
  23011. }
  23012. // AddedField returns the numeric value that was incremented/decremented on a field
  23013. // with the given name. The second boolean return value indicates that this field
  23014. // was not set, or was not defined in the schema.
  23015. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  23016. switch name {
  23017. case sopnode.FieldStatus:
  23018. return m.AddedStatus()
  23019. case sopnode.FieldParentID:
  23020. return m.AddedParentID()
  23021. case sopnode.FieldConditionType:
  23022. return m.AddedConditionType()
  23023. case sopnode.FieldNoReplyCondition:
  23024. return m.AddedNoReplyCondition()
  23025. }
  23026. return nil, false
  23027. }
  23028. // AddField adds the value to the field with the given name. It returns an error if
  23029. // the field is not defined in the schema, or if the type mismatched the field
  23030. // type.
  23031. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  23032. switch name {
  23033. case sopnode.FieldStatus:
  23034. v, ok := value.(int8)
  23035. if !ok {
  23036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23037. }
  23038. m.AddStatus(v)
  23039. return nil
  23040. case sopnode.FieldParentID:
  23041. v, ok := value.(int64)
  23042. if !ok {
  23043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23044. }
  23045. m.AddParentID(v)
  23046. return nil
  23047. case sopnode.FieldConditionType:
  23048. v, ok := value.(int)
  23049. if !ok {
  23050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23051. }
  23052. m.AddConditionType(v)
  23053. return nil
  23054. case sopnode.FieldNoReplyCondition:
  23055. v, ok := value.(int64)
  23056. if !ok {
  23057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23058. }
  23059. m.AddNoReplyCondition(v)
  23060. return nil
  23061. }
  23062. return fmt.Errorf("unknown SopNode numeric field %s", name)
  23063. }
  23064. // ClearedFields returns all nullable fields that were cleared during this
  23065. // mutation.
  23066. func (m *SopNodeMutation) ClearedFields() []string {
  23067. var fields []string
  23068. if m.FieldCleared(sopnode.FieldStatus) {
  23069. fields = append(fields, sopnode.FieldStatus)
  23070. }
  23071. if m.FieldCleared(sopnode.FieldDeletedAt) {
  23072. fields = append(fields, sopnode.FieldDeletedAt)
  23073. }
  23074. if m.FieldCleared(sopnode.FieldConditionList) {
  23075. fields = append(fields, sopnode.FieldConditionList)
  23076. }
  23077. if m.FieldCleared(sopnode.FieldActionMessage) {
  23078. fields = append(fields, sopnode.FieldActionMessage)
  23079. }
  23080. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  23081. fields = append(fields, sopnode.FieldActionLabelAdd)
  23082. }
  23083. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  23084. fields = append(fields, sopnode.FieldActionLabelDel)
  23085. }
  23086. if m.FieldCleared(sopnode.FieldActionForward) {
  23087. fields = append(fields, sopnode.FieldActionForward)
  23088. }
  23089. return fields
  23090. }
  23091. // FieldCleared returns a boolean indicating if a field with the given name was
  23092. // cleared in this mutation.
  23093. func (m *SopNodeMutation) FieldCleared(name string) bool {
  23094. _, ok := m.clearedFields[name]
  23095. return ok
  23096. }
  23097. // ClearField clears the value of the field with the given name. It returns an
  23098. // error if the field is not defined in the schema.
  23099. func (m *SopNodeMutation) ClearField(name string) error {
  23100. switch name {
  23101. case sopnode.FieldStatus:
  23102. m.ClearStatus()
  23103. return nil
  23104. case sopnode.FieldDeletedAt:
  23105. m.ClearDeletedAt()
  23106. return nil
  23107. case sopnode.FieldConditionList:
  23108. m.ClearConditionList()
  23109. return nil
  23110. case sopnode.FieldActionMessage:
  23111. m.ClearActionMessage()
  23112. return nil
  23113. case sopnode.FieldActionLabelAdd:
  23114. m.ClearActionLabelAdd()
  23115. return nil
  23116. case sopnode.FieldActionLabelDel:
  23117. m.ClearActionLabelDel()
  23118. return nil
  23119. case sopnode.FieldActionForward:
  23120. m.ClearActionForward()
  23121. return nil
  23122. }
  23123. return fmt.Errorf("unknown SopNode nullable field %s", name)
  23124. }
  23125. // ResetField resets all changes in the mutation for the field with the given name.
  23126. // It returns an error if the field is not defined in the schema.
  23127. func (m *SopNodeMutation) ResetField(name string) error {
  23128. switch name {
  23129. case sopnode.FieldCreatedAt:
  23130. m.ResetCreatedAt()
  23131. return nil
  23132. case sopnode.FieldUpdatedAt:
  23133. m.ResetUpdatedAt()
  23134. return nil
  23135. case sopnode.FieldStatus:
  23136. m.ResetStatus()
  23137. return nil
  23138. case sopnode.FieldDeletedAt:
  23139. m.ResetDeletedAt()
  23140. return nil
  23141. case sopnode.FieldStageID:
  23142. m.ResetStageID()
  23143. return nil
  23144. case sopnode.FieldParentID:
  23145. m.ResetParentID()
  23146. return nil
  23147. case sopnode.FieldName:
  23148. m.ResetName()
  23149. return nil
  23150. case sopnode.FieldConditionType:
  23151. m.ResetConditionType()
  23152. return nil
  23153. case sopnode.FieldConditionList:
  23154. m.ResetConditionList()
  23155. return nil
  23156. case sopnode.FieldNoReplyCondition:
  23157. m.ResetNoReplyCondition()
  23158. return nil
  23159. case sopnode.FieldNoReplyUnit:
  23160. m.ResetNoReplyUnit()
  23161. return nil
  23162. case sopnode.FieldActionMessage:
  23163. m.ResetActionMessage()
  23164. return nil
  23165. case sopnode.FieldActionLabelAdd:
  23166. m.ResetActionLabelAdd()
  23167. return nil
  23168. case sopnode.FieldActionLabelDel:
  23169. m.ResetActionLabelDel()
  23170. return nil
  23171. case sopnode.FieldActionForward:
  23172. m.ResetActionForward()
  23173. return nil
  23174. }
  23175. return fmt.Errorf("unknown SopNode field %s", name)
  23176. }
  23177. // AddedEdges returns all edge names that were set/added in this mutation.
  23178. func (m *SopNodeMutation) AddedEdges() []string {
  23179. edges := make([]string, 0, 2)
  23180. if m.sop_stage != nil {
  23181. edges = append(edges, sopnode.EdgeSopStage)
  23182. }
  23183. if m.node_messages != nil {
  23184. edges = append(edges, sopnode.EdgeNodeMessages)
  23185. }
  23186. return edges
  23187. }
  23188. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23189. // name in this mutation.
  23190. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  23191. switch name {
  23192. case sopnode.EdgeSopStage:
  23193. if id := m.sop_stage; id != nil {
  23194. return []ent.Value{*id}
  23195. }
  23196. case sopnode.EdgeNodeMessages:
  23197. ids := make([]ent.Value, 0, len(m.node_messages))
  23198. for id := range m.node_messages {
  23199. ids = append(ids, id)
  23200. }
  23201. return ids
  23202. }
  23203. return nil
  23204. }
  23205. // RemovedEdges returns all edge names that were removed in this mutation.
  23206. func (m *SopNodeMutation) RemovedEdges() []string {
  23207. edges := make([]string, 0, 2)
  23208. if m.removednode_messages != nil {
  23209. edges = append(edges, sopnode.EdgeNodeMessages)
  23210. }
  23211. return edges
  23212. }
  23213. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23214. // the given name in this mutation.
  23215. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  23216. switch name {
  23217. case sopnode.EdgeNodeMessages:
  23218. ids := make([]ent.Value, 0, len(m.removednode_messages))
  23219. for id := range m.removednode_messages {
  23220. ids = append(ids, id)
  23221. }
  23222. return ids
  23223. }
  23224. return nil
  23225. }
  23226. // ClearedEdges returns all edge names that were cleared in this mutation.
  23227. func (m *SopNodeMutation) ClearedEdges() []string {
  23228. edges := make([]string, 0, 2)
  23229. if m.clearedsop_stage {
  23230. edges = append(edges, sopnode.EdgeSopStage)
  23231. }
  23232. if m.clearednode_messages {
  23233. edges = append(edges, sopnode.EdgeNodeMessages)
  23234. }
  23235. return edges
  23236. }
  23237. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23238. // was cleared in this mutation.
  23239. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  23240. switch name {
  23241. case sopnode.EdgeSopStage:
  23242. return m.clearedsop_stage
  23243. case sopnode.EdgeNodeMessages:
  23244. return m.clearednode_messages
  23245. }
  23246. return false
  23247. }
  23248. // ClearEdge clears the value of the edge with the given name. It returns an error
  23249. // if that edge is not defined in the schema.
  23250. func (m *SopNodeMutation) ClearEdge(name string) error {
  23251. switch name {
  23252. case sopnode.EdgeSopStage:
  23253. m.ClearSopStage()
  23254. return nil
  23255. }
  23256. return fmt.Errorf("unknown SopNode unique edge %s", name)
  23257. }
  23258. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23259. // It returns an error if the edge is not defined in the schema.
  23260. func (m *SopNodeMutation) ResetEdge(name string) error {
  23261. switch name {
  23262. case sopnode.EdgeSopStage:
  23263. m.ResetSopStage()
  23264. return nil
  23265. case sopnode.EdgeNodeMessages:
  23266. m.ResetNodeMessages()
  23267. return nil
  23268. }
  23269. return fmt.Errorf("unknown SopNode edge %s", name)
  23270. }
  23271. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  23272. type SopStageMutation struct {
  23273. config
  23274. op Op
  23275. typ string
  23276. id *uint64
  23277. created_at *time.Time
  23278. updated_at *time.Time
  23279. status *uint8
  23280. addstatus *int8
  23281. deleted_at *time.Time
  23282. name *string
  23283. condition_type *int
  23284. addcondition_type *int
  23285. condition_operator *int
  23286. addcondition_operator *int
  23287. condition_list *[]custom_types.Condition
  23288. appendcondition_list []custom_types.Condition
  23289. action_message *[]custom_types.Action
  23290. appendaction_message []custom_types.Action
  23291. action_label_add *[]uint64
  23292. appendaction_label_add []uint64
  23293. action_label_del *[]uint64
  23294. appendaction_label_del []uint64
  23295. action_forward **custom_types.ActionForward
  23296. index_sort *int
  23297. addindex_sort *int
  23298. clearedFields map[string]struct{}
  23299. sop_task *uint64
  23300. clearedsop_task bool
  23301. stage_nodes map[uint64]struct{}
  23302. removedstage_nodes map[uint64]struct{}
  23303. clearedstage_nodes bool
  23304. stage_messages map[uint64]struct{}
  23305. removedstage_messages map[uint64]struct{}
  23306. clearedstage_messages bool
  23307. done bool
  23308. oldValue func(context.Context) (*SopStage, error)
  23309. predicates []predicate.SopStage
  23310. }
  23311. var _ ent.Mutation = (*SopStageMutation)(nil)
  23312. // sopstageOption allows management of the mutation configuration using functional options.
  23313. type sopstageOption func(*SopStageMutation)
  23314. // newSopStageMutation creates new mutation for the SopStage entity.
  23315. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  23316. m := &SopStageMutation{
  23317. config: c,
  23318. op: op,
  23319. typ: TypeSopStage,
  23320. clearedFields: make(map[string]struct{}),
  23321. }
  23322. for _, opt := range opts {
  23323. opt(m)
  23324. }
  23325. return m
  23326. }
  23327. // withSopStageID sets the ID field of the mutation.
  23328. func withSopStageID(id uint64) sopstageOption {
  23329. return func(m *SopStageMutation) {
  23330. var (
  23331. err error
  23332. once sync.Once
  23333. value *SopStage
  23334. )
  23335. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  23336. once.Do(func() {
  23337. if m.done {
  23338. err = errors.New("querying old values post mutation is not allowed")
  23339. } else {
  23340. value, err = m.Client().SopStage.Get(ctx, id)
  23341. }
  23342. })
  23343. return value, err
  23344. }
  23345. m.id = &id
  23346. }
  23347. }
  23348. // withSopStage sets the old SopStage of the mutation.
  23349. func withSopStage(node *SopStage) sopstageOption {
  23350. return func(m *SopStageMutation) {
  23351. m.oldValue = func(context.Context) (*SopStage, error) {
  23352. return node, nil
  23353. }
  23354. m.id = &node.ID
  23355. }
  23356. }
  23357. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23358. // executed in a transaction (ent.Tx), a transactional client is returned.
  23359. func (m SopStageMutation) Client() *Client {
  23360. client := &Client{config: m.config}
  23361. client.init()
  23362. return client
  23363. }
  23364. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23365. // it returns an error otherwise.
  23366. func (m SopStageMutation) Tx() (*Tx, error) {
  23367. if _, ok := m.driver.(*txDriver); !ok {
  23368. return nil, errors.New("ent: mutation is not running in a transaction")
  23369. }
  23370. tx := &Tx{config: m.config}
  23371. tx.init()
  23372. return tx, nil
  23373. }
  23374. // SetID sets the value of the id field. Note that this
  23375. // operation is only accepted on creation of SopStage entities.
  23376. func (m *SopStageMutation) SetID(id uint64) {
  23377. m.id = &id
  23378. }
  23379. // ID returns the ID value in the mutation. Note that the ID is only available
  23380. // if it was provided to the builder or after it was returned from the database.
  23381. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  23382. if m.id == nil {
  23383. return
  23384. }
  23385. return *m.id, true
  23386. }
  23387. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23388. // That means, if the mutation is applied within a transaction with an isolation level such
  23389. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23390. // or updated by the mutation.
  23391. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  23392. switch {
  23393. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23394. id, exists := m.ID()
  23395. if exists {
  23396. return []uint64{id}, nil
  23397. }
  23398. fallthrough
  23399. case m.op.Is(OpUpdate | OpDelete):
  23400. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  23401. default:
  23402. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23403. }
  23404. }
  23405. // SetCreatedAt sets the "created_at" field.
  23406. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  23407. m.created_at = &t
  23408. }
  23409. // CreatedAt returns the value of the "created_at" field in the mutation.
  23410. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  23411. v := m.created_at
  23412. if v == nil {
  23413. return
  23414. }
  23415. return *v, true
  23416. }
  23417. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  23418. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23420. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23421. if !m.op.Is(OpUpdateOne) {
  23422. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23423. }
  23424. if m.id == nil || m.oldValue == nil {
  23425. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23426. }
  23427. oldValue, err := m.oldValue(ctx)
  23428. if err != nil {
  23429. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23430. }
  23431. return oldValue.CreatedAt, nil
  23432. }
  23433. // ResetCreatedAt resets all changes to the "created_at" field.
  23434. func (m *SopStageMutation) ResetCreatedAt() {
  23435. m.created_at = nil
  23436. }
  23437. // SetUpdatedAt sets the "updated_at" field.
  23438. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  23439. m.updated_at = &t
  23440. }
  23441. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23442. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  23443. v := m.updated_at
  23444. if v == nil {
  23445. return
  23446. }
  23447. return *v, true
  23448. }
  23449. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  23450. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23452. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23453. if !m.op.Is(OpUpdateOne) {
  23454. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23455. }
  23456. if m.id == nil || m.oldValue == nil {
  23457. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23458. }
  23459. oldValue, err := m.oldValue(ctx)
  23460. if err != nil {
  23461. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23462. }
  23463. return oldValue.UpdatedAt, nil
  23464. }
  23465. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23466. func (m *SopStageMutation) ResetUpdatedAt() {
  23467. m.updated_at = nil
  23468. }
  23469. // SetStatus sets the "status" field.
  23470. func (m *SopStageMutation) SetStatus(u uint8) {
  23471. m.status = &u
  23472. m.addstatus = nil
  23473. }
  23474. // Status returns the value of the "status" field in the mutation.
  23475. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  23476. v := m.status
  23477. if v == nil {
  23478. return
  23479. }
  23480. return *v, true
  23481. }
  23482. // OldStatus returns the old "status" field's value of the SopStage entity.
  23483. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23485. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23486. if !m.op.Is(OpUpdateOne) {
  23487. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23488. }
  23489. if m.id == nil || m.oldValue == nil {
  23490. return v, errors.New("OldStatus requires an ID field in the mutation")
  23491. }
  23492. oldValue, err := m.oldValue(ctx)
  23493. if err != nil {
  23494. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23495. }
  23496. return oldValue.Status, nil
  23497. }
  23498. // AddStatus adds u to the "status" field.
  23499. func (m *SopStageMutation) AddStatus(u int8) {
  23500. if m.addstatus != nil {
  23501. *m.addstatus += u
  23502. } else {
  23503. m.addstatus = &u
  23504. }
  23505. }
  23506. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23507. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  23508. v := m.addstatus
  23509. if v == nil {
  23510. return
  23511. }
  23512. return *v, true
  23513. }
  23514. // ClearStatus clears the value of the "status" field.
  23515. func (m *SopStageMutation) ClearStatus() {
  23516. m.status = nil
  23517. m.addstatus = nil
  23518. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  23519. }
  23520. // StatusCleared returns if the "status" field was cleared in this mutation.
  23521. func (m *SopStageMutation) StatusCleared() bool {
  23522. _, ok := m.clearedFields[sopstage.FieldStatus]
  23523. return ok
  23524. }
  23525. // ResetStatus resets all changes to the "status" field.
  23526. func (m *SopStageMutation) ResetStatus() {
  23527. m.status = nil
  23528. m.addstatus = nil
  23529. delete(m.clearedFields, sopstage.FieldStatus)
  23530. }
  23531. // SetDeletedAt sets the "deleted_at" field.
  23532. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  23533. m.deleted_at = &t
  23534. }
  23535. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23536. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  23537. v := m.deleted_at
  23538. if v == nil {
  23539. return
  23540. }
  23541. return *v, true
  23542. }
  23543. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  23544. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23546. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23547. if !m.op.Is(OpUpdateOne) {
  23548. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23549. }
  23550. if m.id == nil || m.oldValue == nil {
  23551. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23552. }
  23553. oldValue, err := m.oldValue(ctx)
  23554. if err != nil {
  23555. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23556. }
  23557. return oldValue.DeletedAt, nil
  23558. }
  23559. // ClearDeletedAt clears the value of the "deleted_at" field.
  23560. func (m *SopStageMutation) ClearDeletedAt() {
  23561. m.deleted_at = nil
  23562. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  23563. }
  23564. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23565. func (m *SopStageMutation) DeletedAtCleared() bool {
  23566. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  23567. return ok
  23568. }
  23569. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23570. func (m *SopStageMutation) ResetDeletedAt() {
  23571. m.deleted_at = nil
  23572. delete(m.clearedFields, sopstage.FieldDeletedAt)
  23573. }
  23574. // SetTaskID sets the "task_id" field.
  23575. func (m *SopStageMutation) SetTaskID(u uint64) {
  23576. m.sop_task = &u
  23577. }
  23578. // TaskID returns the value of the "task_id" field in the mutation.
  23579. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  23580. v := m.sop_task
  23581. if v == nil {
  23582. return
  23583. }
  23584. return *v, true
  23585. }
  23586. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  23587. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23589. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  23590. if !m.op.Is(OpUpdateOne) {
  23591. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  23592. }
  23593. if m.id == nil || m.oldValue == nil {
  23594. return v, errors.New("OldTaskID requires an ID field in the mutation")
  23595. }
  23596. oldValue, err := m.oldValue(ctx)
  23597. if err != nil {
  23598. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  23599. }
  23600. return oldValue.TaskID, nil
  23601. }
  23602. // ResetTaskID resets all changes to the "task_id" field.
  23603. func (m *SopStageMutation) ResetTaskID() {
  23604. m.sop_task = nil
  23605. }
  23606. // SetName sets the "name" field.
  23607. func (m *SopStageMutation) SetName(s string) {
  23608. m.name = &s
  23609. }
  23610. // Name returns the value of the "name" field in the mutation.
  23611. func (m *SopStageMutation) Name() (r string, exists bool) {
  23612. v := m.name
  23613. if v == nil {
  23614. return
  23615. }
  23616. return *v, true
  23617. }
  23618. // OldName returns the old "name" field's value of the SopStage entity.
  23619. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23621. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  23622. if !m.op.Is(OpUpdateOne) {
  23623. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23624. }
  23625. if m.id == nil || m.oldValue == nil {
  23626. return v, errors.New("OldName requires an ID field in the mutation")
  23627. }
  23628. oldValue, err := m.oldValue(ctx)
  23629. if err != nil {
  23630. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23631. }
  23632. return oldValue.Name, nil
  23633. }
  23634. // ResetName resets all changes to the "name" field.
  23635. func (m *SopStageMutation) ResetName() {
  23636. m.name = nil
  23637. }
  23638. // SetConditionType sets the "condition_type" field.
  23639. func (m *SopStageMutation) SetConditionType(i int) {
  23640. m.condition_type = &i
  23641. m.addcondition_type = nil
  23642. }
  23643. // ConditionType returns the value of the "condition_type" field in the mutation.
  23644. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  23645. v := m.condition_type
  23646. if v == nil {
  23647. return
  23648. }
  23649. return *v, true
  23650. }
  23651. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  23652. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23654. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23655. if !m.op.Is(OpUpdateOne) {
  23656. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23657. }
  23658. if m.id == nil || m.oldValue == nil {
  23659. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23660. }
  23661. oldValue, err := m.oldValue(ctx)
  23662. if err != nil {
  23663. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23664. }
  23665. return oldValue.ConditionType, nil
  23666. }
  23667. // AddConditionType adds i to the "condition_type" field.
  23668. func (m *SopStageMutation) AddConditionType(i int) {
  23669. if m.addcondition_type != nil {
  23670. *m.addcondition_type += i
  23671. } else {
  23672. m.addcondition_type = &i
  23673. }
  23674. }
  23675. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23676. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  23677. v := m.addcondition_type
  23678. if v == nil {
  23679. return
  23680. }
  23681. return *v, true
  23682. }
  23683. // ResetConditionType resets all changes to the "condition_type" field.
  23684. func (m *SopStageMutation) ResetConditionType() {
  23685. m.condition_type = nil
  23686. m.addcondition_type = nil
  23687. }
  23688. // SetConditionOperator sets the "condition_operator" field.
  23689. func (m *SopStageMutation) SetConditionOperator(i int) {
  23690. m.condition_operator = &i
  23691. m.addcondition_operator = nil
  23692. }
  23693. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  23694. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  23695. v := m.condition_operator
  23696. if v == nil {
  23697. return
  23698. }
  23699. return *v, true
  23700. }
  23701. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  23702. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23704. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  23705. if !m.op.Is(OpUpdateOne) {
  23706. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  23707. }
  23708. if m.id == nil || m.oldValue == nil {
  23709. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  23710. }
  23711. oldValue, err := m.oldValue(ctx)
  23712. if err != nil {
  23713. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  23714. }
  23715. return oldValue.ConditionOperator, nil
  23716. }
  23717. // AddConditionOperator adds i to the "condition_operator" field.
  23718. func (m *SopStageMutation) AddConditionOperator(i int) {
  23719. if m.addcondition_operator != nil {
  23720. *m.addcondition_operator += i
  23721. } else {
  23722. m.addcondition_operator = &i
  23723. }
  23724. }
  23725. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  23726. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  23727. v := m.addcondition_operator
  23728. if v == nil {
  23729. return
  23730. }
  23731. return *v, true
  23732. }
  23733. // ResetConditionOperator resets all changes to the "condition_operator" field.
  23734. func (m *SopStageMutation) ResetConditionOperator() {
  23735. m.condition_operator = nil
  23736. m.addcondition_operator = nil
  23737. }
  23738. // SetConditionList sets the "condition_list" field.
  23739. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  23740. m.condition_list = &ct
  23741. m.appendcondition_list = nil
  23742. }
  23743. // ConditionList returns the value of the "condition_list" field in the mutation.
  23744. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  23745. v := m.condition_list
  23746. if v == nil {
  23747. return
  23748. }
  23749. return *v, true
  23750. }
  23751. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  23752. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23754. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  23755. if !m.op.Is(OpUpdateOne) {
  23756. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23757. }
  23758. if m.id == nil || m.oldValue == nil {
  23759. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23760. }
  23761. oldValue, err := m.oldValue(ctx)
  23762. if err != nil {
  23763. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23764. }
  23765. return oldValue.ConditionList, nil
  23766. }
  23767. // AppendConditionList adds ct to the "condition_list" field.
  23768. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  23769. m.appendcondition_list = append(m.appendcondition_list, ct...)
  23770. }
  23771. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23772. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  23773. if len(m.appendcondition_list) == 0 {
  23774. return nil, false
  23775. }
  23776. return m.appendcondition_list, true
  23777. }
  23778. // ResetConditionList resets all changes to the "condition_list" field.
  23779. func (m *SopStageMutation) ResetConditionList() {
  23780. m.condition_list = nil
  23781. m.appendcondition_list = nil
  23782. }
  23783. // SetActionMessage sets the "action_message" field.
  23784. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  23785. m.action_message = &ct
  23786. m.appendaction_message = nil
  23787. }
  23788. // ActionMessage returns the value of the "action_message" field in the mutation.
  23789. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23790. v := m.action_message
  23791. if v == nil {
  23792. return
  23793. }
  23794. return *v, true
  23795. }
  23796. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  23797. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23799. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23800. if !m.op.Is(OpUpdateOne) {
  23801. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23802. }
  23803. if m.id == nil || m.oldValue == nil {
  23804. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23805. }
  23806. oldValue, err := m.oldValue(ctx)
  23807. if err != nil {
  23808. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23809. }
  23810. return oldValue.ActionMessage, nil
  23811. }
  23812. // AppendActionMessage adds ct to the "action_message" field.
  23813. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  23814. m.appendaction_message = append(m.appendaction_message, ct...)
  23815. }
  23816. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23817. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23818. if len(m.appendaction_message) == 0 {
  23819. return nil, false
  23820. }
  23821. return m.appendaction_message, true
  23822. }
  23823. // ClearActionMessage clears the value of the "action_message" field.
  23824. func (m *SopStageMutation) ClearActionMessage() {
  23825. m.action_message = nil
  23826. m.appendaction_message = nil
  23827. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  23828. }
  23829. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  23830. func (m *SopStageMutation) ActionMessageCleared() bool {
  23831. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  23832. return ok
  23833. }
  23834. // ResetActionMessage resets all changes to the "action_message" field.
  23835. func (m *SopStageMutation) ResetActionMessage() {
  23836. m.action_message = nil
  23837. m.appendaction_message = nil
  23838. delete(m.clearedFields, sopstage.FieldActionMessage)
  23839. }
  23840. // SetActionLabelAdd sets the "action_label_add" field.
  23841. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  23842. m.action_label_add = &u
  23843. m.appendaction_label_add = nil
  23844. }
  23845. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23846. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23847. v := m.action_label_add
  23848. if v == nil {
  23849. return
  23850. }
  23851. return *v, true
  23852. }
  23853. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  23854. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23856. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23857. if !m.op.Is(OpUpdateOne) {
  23858. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23859. }
  23860. if m.id == nil || m.oldValue == nil {
  23861. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23862. }
  23863. oldValue, err := m.oldValue(ctx)
  23864. if err != nil {
  23865. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23866. }
  23867. return oldValue.ActionLabelAdd, nil
  23868. }
  23869. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23870. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  23871. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23872. }
  23873. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23874. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23875. if len(m.appendaction_label_add) == 0 {
  23876. return nil, false
  23877. }
  23878. return m.appendaction_label_add, true
  23879. }
  23880. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23881. func (m *SopStageMutation) ClearActionLabelAdd() {
  23882. m.action_label_add = nil
  23883. m.appendaction_label_add = nil
  23884. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  23885. }
  23886. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23887. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  23888. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  23889. return ok
  23890. }
  23891. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23892. func (m *SopStageMutation) ResetActionLabelAdd() {
  23893. m.action_label_add = nil
  23894. m.appendaction_label_add = nil
  23895. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  23896. }
  23897. // SetActionLabelDel sets the "action_label_del" field.
  23898. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  23899. m.action_label_del = &u
  23900. m.appendaction_label_del = nil
  23901. }
  23902. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23903. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  23904. v := m.action_label_del
  23905. if v == nil {
  23906. return
  23907. }
  23908. return *v, true
  23909. }
  23910. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  23911. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23913. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23914. if !m.op.Is(OpUpdateOne) {
  23915. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23916. }
  23917. if m.id == nil || m.oldValue == nil {
  23918. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23919. }
  23920. oldValue, err := m.oldValue(ctx)
  23921. if err != nil {
  23922. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23923. }
  23924. return oldValue.ActionLabelDel, nil
  23925. }
  23926. // AppendActionLabelDel adds u to the "action_label_del" field.
  23927. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  23928. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23929. }
  23930. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23931. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23932. if len(m.appendaction_label_del) == 0 {
  23933. return nil, false
  23934. }
  23935. return m.appendaction_label_del, true
  23936. }
  23937. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23938. func (m *SopStageMutation) ClearActionLabelDel() {
  23939. m.action_label_del = nil
  23940. m.appendaction_label_del = nil
  23941. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  23942. }
  23943. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23944. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  23945. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  23946. return ok
  23947. }
  23948. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23949. func (m *SopStageMutation) ResetActionLabelDel() {
  23950. m.action_label_del = nil
  23951. m.appendaction_label_del = nil
  23952. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  23953. }
  23954. // SetActionForward sets the "action_forward" field.
  23955. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  23956. m.action_forward = &ctf
  23957. }
  23958. // ActionForward returns the value of the "action_forward" field in the mutation.
  23959. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  23960. v := m.action_forward
  23961. if v == nil {
  23962. return
  23963. }
  23964. return *v, true
  23965. }
  23966. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  23967. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  23968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23969. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  23970. if !m.op.Is(OpUpdateOne) {
  23971. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  23972. }
  23973. if m.id == nil || m.oldValue == nil {
  23974. return v, errors.New("OldActionForward requires an ID field in the mutation")
  23975. }
  23976. oldValue, err := m.oldValue(ctx)
  23977. if err != nil {
  23978. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  23979. }
  23980. return oldValue.ActionForward, nil
  23981. }
  23982. // ClearActionForward clears the value of the "action_forward" field.
  23983. func (m *SopStageMutation) ClearActionForward() {
  23984. m.action_forward = nil
  23985. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  23986. }
  23987. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  23988. func (m *SopStageMutation) ActionForwardCleared() bool {
  23989. _, ok := m.clearedFields[sopstage.FieldActionForward]
  23990. return ok
  23991. }
  23992. // ResetActionForward resets all changes to the "action_forward" field.
  23993. func (m *SopStageMutation) ResetActionForward() {
  23994. m.action_forward = nil
  23995. delete(m.clearedFields, sopstage.FieldActionForward)
  23996. }
  23997. // SetIndexSort sets the "index_sort" field.
  23998. func (m *SopStageMutation) SetIndexSort(i int) {
  23999. m.index_sort = &i
  24000. m.addindex_sort = nil
  24001. }
  24002. // IndexSort returns the value of the "index_sort" field in the mutation.
  24003. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  24004. v := m.index_sort
  24005. if v == nil {
  24006. return
  24007. }
  24008. return *v, true
  24009. }
  24010. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  24011. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24013. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  24014. if !m.op.Is(OpUpdateOne) {
  24015. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  24016. }
  24017. if m.id == nil || m.oldValue == nil {
  24018. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  24019. }
  24020. oldValue, err := m.oldValue(ctx)
  24021. if err != nil {
  24022. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  24023. }
  24024. return oldValue.IndexSort, nil
  24025. }
  24026. // AddIndexSort adds i to the "index_sort" field.
  24027. func (m *SopStageMutation) AddIndexSort(i int) {
  24028. if m.addindex_sort != nil {
  24029. *m.addindex_sort += i
  24030. } else {
  24031. m.addindex_sort = &i
  24032. }
  24033. }
  24034. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  24035. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  24036. v := m.addindex_sort
  24037. if v == nil {
  24038. return
  24039. }
  24040. return *v, true
  24041. }
  24042. // ClearIndexSort clears the value of the "index_sort" field.
  24043. func (m *SopStageMutation) ClearIndexSort() {
  24044. m.index_sort = nil
  24045. m.addindex_sort = nil
  24046. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  24047. }
  24048. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  24049. func (m *SopStageMutation) IndexSortCleared() bool {
  24050. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  24051. return ok
  24052. }
  24053. // ResetIndexSort resets all changes to the "index_sort" field.
  24054. func (m *SopStageMutation) ResetIndexSort() {
  24055. m.index_sort = nil
  24056. m.addindex_sort = nil
  24057. delete(m.clearedFields, sopstage.FieldIndexSort)
  24058. }
  24059. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  24060. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  24061. m.sop_task = &id
  24062. }
  24063. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  24064. func (m *SopStageMutation) ClearSopTask() {
  24065. m.clearedsop_task = true
  24066. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  24067. }
  24068. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  24069. func (m *SopStageMutation) SopTaskCleared() bool {
  24070. return m.clearedsop_task
  24071. }
  24072. // SopTaskID returns the "sop_task" edge ID in the mutation.
  24073. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  24074. if m.sop_task != nil {
  24075. return *m.sop_task, true
  24076. }
  24077. return
  24078. }
  24079. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  24080. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24081. // SopTaskID instead. It exists only for internal usage by the builders.
  24082. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  24083. if id := m.sop_task; id != nil {
  24084. ids = append(ids, *id)
  24085. }
  24086. return
  24087. }
  24088. // ResetSopTask resets all changes to the "sop_task" edge.
  24089. func (m *SopStageMutation) ResetSopTask() {
  24090. m.sop_task = nil
  24091. m.clearedsop_task = false
  24092. }
  24093. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  24094. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  24095. if m.stage_nodes == nil {
  24096. m.stage_nodes = make(map[uint64]struct{})
  24097. }
  24098. for i := range ids {
  24099. m.stage_nodes[ids[i]] = struct{}{}
  24100. }
  24101. }
  24102. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  24103. func (m *SopStageMutation) ClearStageNodes() {
  24104. m.clearedstage_nodes = true
  24105. }
  24106. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  24107. func (m *SopStageMutation) StageNodesCleared() bool {
  24108. return m.clearedstage_nodes
  24109. }
  24110. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  24111. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  24112. if m.removedstage_nodes == nil {
  24113. m.removedstage_nodes = make(map[uint64]struct{})
  24114. }
  24115. for i := range ids {
  24116. delete(m.stage_nodes, ids[i])
  24117. m.removedstage_nodes[ids[i]] = struct{}{}
  24118. }
  24119. }
  24120. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  24121. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  24122. for id := range m.removedstage_nodes {
  24123. ids = append(ids, id)
  24124. }
  24125. return
  24126. }
  24127. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  24128. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  24129. for id := range m.stage_nodes {
  24130. ids = append(ids, id)
  24131. }
  24132. return
  24133. }
  24134. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  24135. func (m *SopStageMutation) ResetStageNodes() {
  24136. m.stage_nodes = nil
  24137. m.clearedstage_nodes = false
  24138. m.removedstage_nodes = nil
  24139. }
  24140. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  24141. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  24142. if m.stage_messages == nil {
  24143. m.stage_messages = make(map[uint64]struct{})
  24144. }
  24145. for i := range ids {
  24146. m.stage_messages[ids[i]] = struct{}{}
  24147. }
  24148. }
  24149. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  24150. func (m *SopStageMutation) ClearStageMessages() {
  24151. m.clearedstage_messages = true
  24152. }
  24153. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  24154. func (m *SopStageMutation) StageMessagesCleared() bool {
  24155. return m.clearedstage_messages
  24156. }
  24157. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  24158. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  24159. if m.removedstage_messages == nil {
  24160. m.removedstage_messages = make(map[uint64]struct{})
  24161. }
  24162. for i := range ids {
  24163. delete(m.stage_messages, ids[i])
  24164. m.removedstage_messages[ids[i]] = struct{}{}
  24165. }
  24166. }
  24167. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  24168. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  24169. for id := range m.removedstage_messages {
  24170. ids = append(ids, id)
  24171. }
  24172. return
  24173. }
  24174. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  24175. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  24176. for id := range m.stage_messages {
  24177. ids = append(ids, id)
  24178. }
  24179. return
  24180. }
  24181. // ResetStageMessages resets all changes to the "stage_messages" edge.
  24182. func (m *SopStageMutation) ResetStageMessages() {
  24183. m.stage_messages = nil
  24184. m.clearedstage_messages = false
  24185. m.removedstage_messages = nil
  24186. }
  24187. // Where appends a list predicates to the SopStageMutation builder.
  24188. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  24189. m.predicates = append(m.predicates, ps...)
  24190. }
  24191. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  24192. // users can use type-assertion to append predicates that do not depend on any generated package.
  24193. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  24194. p := make([]predicate.SopStage, len(ps))
  24195. for i := range ps {
  24196. p[i] = ps[i]
  24197. }
  24198. m.Where(p...)
  24199. }
  24200. // Op returns the operation name.
  24201. func (m *SopStageMutation) Op() Op {
  24202. return m.op
  24203. }
  24204. // SetOp allows setting the mutation operation.
  24205. func (m *SopStageMutation) SetOp(op Op) {
  24206. m.op = op
  24207. }
  24208. // Type returns the node type of this mutation (SopStage).
  24209. func (m *SopStageMutation) Type() string {
  24210. return m.typ
  24211. }
  24212. // Fields returns all fields that were changed during this mutation. Note that in
  24213. // order to get all numeric fields that were incremented/decremented, call
  24214. // AddedFields().
  24215. func (m *SopStageMutation) Fields() []string {
  24216. fields := make([]string, 0, 14)
  24217. if m.created_at != nil {
  24218. fields = append(fields, sopstage.FieldCreatedAt)
  24219. }
  24220. if m.updated_at != nil {
  24221. fields = append(fields, sopstage.FieldUpdatedAt)
  24222. }
  24223. if m.status != nil {
  24224. fields = append(fields, sopstage.FieldStatus)
  24225. }
  24226. if m.deleted_at != nil {
  24227. fields = append(fields, sopstage.FieldDeletedAt)
  24228. }
  24229. if m.sop_task != nil {
  24230. fields = append(fields, sopstage.FieldTaskID)
  24231. }
  24232. if m.name != nil {
  24233. fields = append(fields, sopstage.FieldName)
  24234. }
  24235. if m.condition_type != nil {
  24236. fields = append(fields, sopstage.FieldConditionType)
  24237. }
  24238. if m.condition_operator != nil {
  24239. fields = append(fields, sopstage.FieldConditionOperator)
  24240. }
  24241. if m.condition_list != nil {
  24242. fields = append(fields, sopstage.FieldConditionList)
  24243. }
  24244. if m.action_message != nil {
  24245. fields = append(fields, sopstage.FieldActionMessage)
  24246. }
  24247. if m.action_label_add != nil {
  24248. fields = append(fields, sopstage.FieldActionLabelAdd)
  24249. }
  24250. if m.action_label_del != nil {
  24251. fields = append(fields, sopstage.FieldActionLabelDel)
  24252. }
  24253. if m.action_forward != nil {
  24254. fields = append(fields, sopstage.FieldActionForward)
  24255. }
  24256. if m.index_sort != nil {
  24257. fields = append(fields, sopstage.FieldIndexSort)
  24258. }
  24259. return fields
  24260. }
  24261. // Field returns the value of a field with the given name. The second boolean
  24262. // return value indicates that this field was not set, or was not defined in the
  24263. // schema.
  24264. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  24265. switch name {
  24266. case sopstage.FieldCreatedAt:
  24267. return m.CreatedAt()
  24268. case sopstage.FieldUpdatedAt:
  24269. return m.UpdatedAt()
  24270. case sopstage.FieldStatus:
  24271. return m.Status()
  24272. case sopstage.FieldDeletedAt:
  24273. return m.DeletedAt()
  24274. case sopstage.FieldTaskID:
  24275. return m.TaskID()
  24276. case sopstage.FieldName:
  24277. return m.Name()
  24278. case sopstage.FieldConditionType:
  24279. return m.ConditionType()
  24280. case sopstage.FieldConditionOperator:
  24281. return m.ConditionOperator()
  24282. case sopstage.FieldConditionList:
  24283. return m.ConditionList()
  24284. case sopstage.FieldActionMessage:
  24285. return m.ActionMessage()
  24286. case sopstage.FieldActionLabelAdd:
  24287. return m.ActionLabelAdd()
  24288. case sopstage.FieldActionLabelDel:
  24289. return m.ActionLabelDel()
  24290. case sopstage.FieldActionForward:
  24291. return m.ActionForward()
  24292. case sopstage.FieldIndexSort:
  24293. return m.IndexSort()
  24294. }
  24295. return nil, false
  24296. }
  24297. // OldField returns the old value of the field from the database. An error is
  24298. // returned if the mutation operation is not UpdateOne, or the query to the
  24299. // database failed.
  24300. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24301. switch name {
  24302. case sopstage.FieldCreatedAt:
  24303. return m.OldCreatedAt(ctx)
  24304. case sopstage.FieldUpdatedAt:
  24305. return m.OldUpdatedAt(ctx)
  24306. case sopstage.FieldStatus:
  24307. return m.OldStatus(ctx)
  24308. case sopstage.FieldDeletedAt:
  24309. return m.OldDeletedAt(ctx)
  24310. case sopstage.FieldTaskID:
  24311. return m.OldTaskID(ctx)
  24312. case sopstage.FieldName:
  24313. return m.OldName(ctx)
  24314. case sopstage.FieldConditionType:
  24315. return m.OldConditionType(ctx)
  24316. case sopstage.FieldConditionOperator:
  24317. return m.OldConditionOperator(ctx)
  24318. case sopstage.FieldConditionList:
  24319. return m.OldConditionList(ctx)
  24320. case sopstage.FieldActionMessage:
  24321. return m.OldActionMessage(ctx)
  24322. case sopstage.FieldActionLabelAdd:
  24323. return m.OldActionLabelAdd(ctx)
  24324. case sopstage.FieldActionLabelDel:
  24325. return m.OldActionLabelDel(ctx)
  24326. case sopstage.FieldActionForward:
  24327. return m.OldActionForward(ctx)
  24328. case sopstage.FieldIndexSort:
  24329. return m.OldIndexSort(ctx)
  24330. }
  24331. return nil, fmt.Errorf("unknown SopStage field %s", name)
  24332. }
  24333. // SetField sets the value of a field with the given name. It returns an error if
  24334. // the field is not defined in the schema, or if the type mismatched the field
  24335. // type.
  24336. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  24337. switch name {
  24338. case sopstage.FieldCreatedAt:
  24339. v, ok := value.(time.Time)
  24340. if !ok {
  24341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24342. }
  24343. m.SetCreatedAt(v)
  24344. return nil
  24345. case sopstage.FieldUpdatedAt:
  24346. v, ok := value.(time.Time)
  24347. if !ok {
  24348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24349. }
  24350. m.SetUpdatedAt(v)
  24351. return nil
  24352. case sopstage.FieldStatus:
  24353. v, ok := value.(uint8)
  24354. if !ok {
  24355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24356. }
  24357. m.SetStatus(v)
  24358. return nil
  24359. case sopstage.FieldDeletedAt:
  24360. v, ok := value.(time.Time)
  24361. if !ok {
  24362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24363. }
  24364. m.SetDeletedAt(v)
  24365. return nil
  24366. case sopstage.FieldTaskID:
  24367. v, ok := value.(uint64)
  24368. if !ok {
  24369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24370. }
  24371. m.SetTaskID(v)
  24372. return nil
  24373. case sopstage.FieldName:
  24374. v, ok := value.(string)
  24375. if !ok {
  24376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24377. }
  24378. m.SetName(v)
  24379. return nil
  24380. case sopstage.FieldConditionType:
  24381. v, ok := value.(int)
  24382. if !ok {
  24383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24384. }
  24385. m.SetConditionType(v)
  24386. return nil
  24387. case sopstage.FieldConditionOperator:
  24388. v, ok := value.(int)
  24389. if !ok {
  24390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24391. }
  24392. m.SetConditionOperator(v)
  24393. return nil
  24394. case sopstage.FieldConditionList:
  24395. v, ok := value.([]custom_types.Condition)
  24396. if !ok {
  24397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24398. }
  24399. m.SetConditionList(v)
  24400. return nil
  24401. case sopstage.FieldActionMessage:
  24402. v, ok := value.([]custom_types.Action)
  24403. if !ok {
  24404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24405. }
  24406. m.SetActionMessage(v)
  24407. return nil
  24408. case sopstage.FieldActionLabelAdd:
  24409. v, ok := value.([]uint64)
  24410. if !ok {
  24411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24412. }
  24413. m.SetActionLabelAdd(v)
  24414. return nil
  24415. case sopstage.FieldActionLabelDel:
  24416. v, ok := value.([]uint64)
  24417. if !ok {
  24418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24419. }
  24420. m.SetActionLabelDel(v)
  24421. return nil
  24422. case sopstage.FieldActionForward:
  24423. v, ok := value.(*custom_types.ActionForward)
  24424. if !ok {
  24425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24426. }
  24427. m.SetActionForward(v)
  24428. return nil
  24429. case sopstage.FieldIndexSort:
  24430. v, ok := value.(int)
  24431. if !ok {
  24432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24433. }
  24434. m.SetIndexSort(v)
  24435. return nil
  24436. }
  24437. return fmt.Errorf("unknown SopStage field %s", name)
  24438. }
  24439. // AddedFields returns all numeric fields that were incremented/decremented during
  24440. // this mutation.
  24441. func (m *SopStageMutation) AddedFields() []string {
  24442. var fields []string
  24443. if m.addstatus != nil {
  24444. fields = append(fields, sopstage.FieldStatus)
  24445. }
  24446. if m.addcondition_type != nil {
  24447. fields = append(fields, sopstage.FieldConditionType)
  24448. }
  24449. if m.addcondition_operator != nil {
  24450. fields = append(fields, sopstage.FieldConditionOperator)
  24451. }
  24452. if m.addindex_sort != nil {
  24453. fields = append(fields, sopstage.FieldIndexSort)
  24454. }
  24455. return fields
  24456. }
  24457. // AddedField returns the numeric value that was incremented/decremented on a field
  24458. // with the given name. The second boolean return value indicates that this field
  24459. // was not set, or was not defined in the schema.
  24460. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  24461. switch name {
  24462. case sopstage.FieldStatus:
  24463. return m.AddedStatus()
  24464. case sopstage.FieldConditionType:
  24465. return m.AddedConditionType()
  24466. case sopstage.FieldConditionOperator:
  24467. return m.AddedConditionOperator()
  24468. case sopstage.FieldIndexSort:
  24469. return m.AddedIndexSort()
  24470. }
  24471. return nil, false
  24472. }
  24473. // AddField adds the value to the field with the given name. It returns an error if
  24474. // the field is not defined in the schema, or if the type mismatched the field
  24475. // type.
  24476. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  24477. switch name {
  24478. case sopstage.FieldStatus:
  24479. v, ok := value.(int8)
  24480. if !ok {
  24481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24482. }
  24483. m.AddStatus(v)
  24484. return nil
  24485. case sopstage.FieldConditionType:
  24486. v, ok := value.(int)
  24487. if !ok {
  24488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24489. }
  24490. m.AddConditionType(v)
  24491. return nil
  24492. case sopstage.FieldConditionOperator:
  24493. v, ok := value.(int)
  24494. if !ok {
  24495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24496. }
  24497. m.AddConditionOperator(v)
  24498. return nil
  24499. case sopstage.FieldIndexSort:
  24500. v, ok := value.(int)
  24501. if !ok {
  24502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24503. }
  24504. m.AddIndexSort(v)
  24505. return nil
  24506. }
  24507. return fmt.Errorf("unknown SopStage numeric field %s", name)
  24508. }
  24509. // ClearedFields returns all nullable fields that were cleared during this
  24510. // mutation.
  24511. func (m *SopStageMutation) ClearedFields() []string {
  24512. var fields []string
  24513. if m.FieldCleared(sopstage.FieldStatus) {
  24514. fields = append(fields, sopstage.FieldStatus)
  24515. }
  24516. if m.FieldCleared(sopstage.FieldDeletedAt) {
  24517. fields = append(fields, sopstage.FieldDeletedAt)
  24518. }
  24519. if m.FieldCleared(sopstage.FieldActionMessage) {
  24520. fields = append(fields, sopstage.FieldActionMessage)
  24521. }
  24522. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  24523. fields = append(fields, sopstage.FieldActionLabelAdd)
  24524. }
  24525. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  24526. fields = append(fields, sopstage.FieldActionLabelDel)
  24527. }
  24528. if m.FieldCleared(sopstage.FieldActionForward) {
  24529. fields = append(fields, sopstage.FieldActionForward)
  24530. }
  24531. if m.FieldCleared(sopstage.FieldIndexSort) {
  24532. fields = append(fields, sopstage.FieldIndexSort)
  24533. }
  24534. return fields
  24535. }
  24536. // FieldCleared returns a boolean indicating if a field with the given name was
  24537. // cleared in this mutation.
  24538. func (m *SopStageMutation) FieldCleared(name string) bool {
  24539. _, ok := m.clearedFields[name]
  24540. return ok
  24541. }
  24542. // ClearField clears the value of the field with the given name. It returns an
  24543. // error if the field is not defined in the schema.
  24544. func (m *SopStageMutation) ClearField(name string) error {
  24545. switch name {
  24546. case sopstage.FieldStatus:
  24547. m.ClearStatus()
  24548. return nil
  24549. case sopstage.FieldDeletedAt:
  24550. m.ClearDeletedAt()
  24551. return nil
  24552. case sopstage.FieldActionMessage:
  24553. m.ClearActionMessage()
  24554. return nil
  24555. case sopstage.FieldActionLabelAdd:
  24556. m.ClearActionLabelAdd()
  24557. return nil
  24558. case sopstage.FieldActionLabelDel:
  24559. m.ClearActionLabelDel()
  24560. return nil
  24561. case sopstage.FieldActionForward:
  24562. m.ClearActionForward()
  24563. return nil
  24564. case sopstage.FieldIndexSort:
  24565. m.ClearIndexSort()
  24566. return nil
  24567. }
  24568. return fmt.Errorf("unknown SopStage nullable field %s", name)
  24569. }
  24570. // ResetField resets all changes in the mutation for the field with the given name.
  24571. // It returns an error if the field is not defined in the schema.
  24572. func (m *SopStageMutation) ResetField(name string) error {
  24573. switch name {
  24574. case sopstage.FieldCreatedAt:
  24575. m.ResetCreatedAt()
  24576. return nil
  24577. case sopstage.FieldUpdatedAt:
  24578. m.ResetUpdatedAt()
  24579. return nil
  24580. case sopstage.FieldStatus:
  24581. m.ResetStatus()
  24582. return nil
  24583. case sopstage.FieldDeletedAt:
  24584. m.ResetDeletedAt()
  24585. return nil
  24586. case sopstage.FieldTaskID:
  24587. m.ResetTaskID()
  24588. return nil
  24589. case sopstage.FieldName:
  24590. m.ResetName()
  24591. return nil
  24592. case sopstage.FieldConditionType:
  24593. m.ResetConditionType()
  24594. return nil
  24595. case sopstage.FieldConditionOperator:
  24596. m.ResetConditionOperator()
  24597. return nil
  24598. case sopstage.FieldConditionList:
  24599. m.ResetConditionList()
  24600. return nil
  24601. case sopstage.FieldActionMessage:
  24602. m.ResetActionMessage()
  24603. return nil
  24604. case sopstage.FieldActionLabelAdd:
  24605. m.ResetActionLabelAdd()
  24606. return nil
  24607. case sopstage.FieldActionLabelDel:
  24608. m.ResetActionLabelDel()
  24609. return nil
  24610. case sopstage.FieldActionForward:
  24611. m.ResetActionForward()
  24612. return nil
  24613. case sopstage.FieldIndexSort:
  24614. m.ResetIndexSort()
  24615. return nil
  24616. }
  24617. return fmt.Errorf("unknown SopStage field %s", name)
  24618. }
  24619. // AddedEdges returns all edge names that were set/added in this mutation.
  24620. func (m *SopStageMutation) AddedEdges() []string {
  24621. edges := make([]string, 0, 3)
  24622. if m.sop_task != nil {
  24623. edges = append(edges, sopstage.EdgeSopTask)
  24624. }
  24625. if m.stage_nodes != nil {
  24626. edges = append(edges, sopstage.EdgeStageNodes)
  24627. }
  24628. if m.stage_messages != nil {
  24629. edges = append(edges, sopstage.EdgeStageMessages)
  24630. }
  24631. return edges
  24632. }
  24633. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24634. // name in this mutation.
  24635. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  24636. switch name {
  24637. case sopstage.EdgeSopTask:
  24638. if id := m.sop_task; id != nil {
  24639. return []ent.Value{*id}
  24640. }
  24641. case sopstage.EdgeStageNodes:
  24642. ids := make([]ent.Value, 0, len(m.stage_nodes))
  24643. for id := range m.stage_nodes {
  24644. ids = append(ids, id)
  24645. }
  24646. return ids
  24647. case sopstage.EdgeStageMessages:
  24648. ids := make([]ent.Value, 0, len(m.stage_messages))
  24649. for id := range m.stage_messages {
  24650. ids = append(ids, id)
  24651. }
  24652. return ids
  24653. }
  24654. return nil
  24655. }
  24656. // RemovedEdges returns all edge names that were removed in this mutation.
  24657. func (m *SopStageMutation) RemovedEdges() []string {
  24658. edges := make([]string, 0, 3)
  24659. if m.removedstage_nodes != nil {
  24660. edges = append(edges, sopstage.EdgeStageNodes)
  24661. }
  24662. if m.removedstage_messages != nil {
  24663. edges = append(edges, sopstage.EdgeStageMessages)
  24664. }
  24665. return edges
  24666. }
  24667. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24668. // the given name in this mutation.
  24669. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  24670. switch name {
  24671. case sopstage.EdgeStageNodes:
  24672. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  24673. for id := range m.removedstage_nodes {
  24674. ids = append(ids, id)
  24675. }
  24676. return ids
  24677. case sopstage.EdgeStageMessages:
  24678. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  24679. for id := range m.removedstage_messages {
  24680. ids = append(ids, id)
  24681. }
  24682. return ids
  24683. }
  24684. return nil
  24685. }
  24686. // ClearedEdges returns all edge names that were cleared in this mutation.
  24687. func (m *SopStageMutation) ClearedEdges() []string {
  24688. edges := make([]string, 0, 3)
  24689. if m.clearedsop_task {
  24690. edges = append(edges, sopstage.EdgeSopTask)
  24691. }
  24692. if m.clearedstage_nodes {
  24693. edges = append(edges, sopstage.EdgeStageNodes)
  24694. }
  24695. if m.clearedstage_messages {
  24696. edges = append(edges, sopstage.EdgeStageMessages)
  24697. }
  24698. return edges
  24699. }
  24700. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24701. // was cleared in this mutation.
  24702. func (m *SopStageMutation) EdgeCleared(name string) bool {
  24703. switch name {
  24704. case sopstage.EdgeSopTask:
  24705. return m.clearedsop_task
  24706. case sopstage.EdgeStageNodes:
  24707. return m.clearedstage_nodes
  24708. case sopstage.EdgeStageMessages:
  24709. return m.clearedstage_messages
  24710. }
  24711. return false
  24712. }
  24713. // ClearEdge clears the value of the edge with the given name. It returns an error
  24714. // if that edge is not defined in the schema.
  24715. func (m *SopStageMutation) ClearEdge(name string) error {
  24716. switch name {
  24717. case sopstage.EdgeSopTask:
  24718. m.ClearSopTask()
  24719. return nil
  24720. }
  24721. return fmt.Errorf("unknown SopStage unique edge %s", name)
  24722. }
  24723. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24724. // It returns an error if the edge is not defined in the schema.
  24725. func (m *SopStageMutation) ResetEdge(name string) error {
  24726. switch name {
  24727. case sopstage.EdgeSopTask:
  24728. m.ResetSopTask()
  24729. return nil
  24730. case sopstage.EdgeStageNodes:
  24731. m.ResetStageNodes()
  24732. return nil
  24733. case sopstage.EdgeStageMessages:
  24734. m.ResetStageMessages()
  24735. return nil
  24736. }
  24737. return fmt.Errorf("unknown SopStage edge %s", name)
  24738. }
  24739. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  24740. type SopTaskMutation struct {
  24741. config
  24742. op Op
  24743. typ string
  24744. id *uint64
  24745. created_at *time.Time
  24746. updated_at *time.Time
  24747. status *uint8
  24748. addstatus *int8
  24749. deleted_at *time.Time
  24750. name *string
  24751. bot_wxid_list *[]string
  24752. appendbot_wxid_list []string
  24753. _type *int
  24754. add_type *int
  24755. plan_start_time *time.Time
  24756. plan_end_time *time.Time
  24757. creator_id *string
  24758. organization_id *uint64
  24759. addorganization_id *int64
  24760. token *[]string
  24761. appendtoken []string
  24762. clearedFields map[string]struct{}
  24763. task_stages map[uint64]struct{}
  24764. removedtask_stages map[uint64]struct{}
  24765. clearedtask_stages bool
  24766. done bool
  24767. oldValue func(context.Context) (*SopTask, error)
  24768. predicates []predicate.SopTask
  24769. }
  24770. var _ ent.Mutation = (*SopTaskMutation)(nil)
  24771. // soptaskOption allows management of the mutation configuration using functional options.
  24772. type soptaskOption func(*SopTaskMutation)
  24773. // newSopTaskMutation creates new mutation for the SopTask entity.
  24774. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  24775. m := &SopTaskMutation{
  24776. config: c,
  24777. op: op,
  24778. typ: TypeSopTask,
  24779. clearedFields: make(map[string]struct{}),
  24780. }
  24781. for _, opt := range opts {
  24782. opt(m)
  24783. }
  24784. return m
  24785. }
  24786. // withSopTaskID sets the ID field of the mutation.
  24787. func withSopTaskID(id uint64) soptaskOption {
  24788. return func(m *SopTaskMutation) {
  24789. var (
  24790. err error
  24791. once sync.Once
  24792. value *SopTask
  24793. )
  24794. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  24795. once.Do(func() {
  24796. if m.done {
  24797. err = errors.New("querying old values post mutation is not allowed")
  24798. } else {
  24799. value, err = m.Client().SopTask.Get(ctx, id)
  24800. }
  24801. })
  24802. return value, err
  24803. }
  24804. m.id = &id
  24805. }
  24806. }
  24807. // withSopTask sets the old SopTask of the mutation.
  24808. func withSopTask(node *SopTask) soptaskOption {
  24809. return func(m *SopTaskMutation) {
  24810. m.oldValue = func(context.Context) (*SopTask, error) {
  24811. return node, nil
  24812. }
  24813. m.id = &node.ID
  24814. }
  24815. }
  24816. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24817. // executed in a transaction (ent.Tx), a transactional client is returned.
  24818. func (m SopTaskMutation) Client() *Client {
  24819. client := &Client{config: m.config}
  24820. client.init()
  24821. return client
  24822. }
  24823. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24824. // it returns an error otherwise.
  24825. func (m SopTaskMutation) Tx() (*Tx, error) {
  24826. if _, ok := m.driver.(*txDriver); !ok {
  24827. return nil, errors.New("ent: mutation is not running in a transaction")
  24828. }
  24829. tx := &Tx{config: m.config}
  24830. tx.init()
  24831. return tx, nil
  24832. }
  24833. // SetID sets the value of the id field. Note that this
  24834. // operation is only accepted on creation of SopTask entities.
  24835. func (m *SopTaskMutation) SetID(id uint64) {
  24836. m.id = &id
  24837. }
  24838. // ID returns the ID value in the mutation. Note that the ID is only available
  24839. // if it was provided to the builder or after it was returned from the database.
  24840. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  24841. if m.id == nil {
  24842. return
  24843. }
  24844. return *m.id, true
  24845. }
  24846. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24847. // That means, if the mutation is applied within a transaction with an isolation level such
  24848. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24849. // or updated by the mutation.
  24850. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  24851. switch {
  24852. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24853. id, exists := m.ID()
  24854. if exists {
  24855. return []uint64{id}, nil
  24856. }
  24857. fallthrough
  24858. case m.op.Is(OpUpdate | OpDelete):
  24859. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  24860. default:
  24861. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24862. }
  24863. }
  24864. // SetCreatedAt sets the "created_at" field.
  24865. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  24866. m.created_at = &t
  24867. }
  24868. // CreatedAt returns the value of the "created_at" field in the mutation.
  24869. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  24870. v := m.created_at
  24871. if v == nil {
  24872. return
  24873. }
  24874. return *v, true
  24875. }
  24876. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  24877. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24879. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24880. if !m.op.Is(OpUpdateOne) {
  24881. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24882. }
  24883. if m.id == nil || m.oldValue == nil {
  24884. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24885. }
  24886. oldValue, err := m.oldValue(ctx)
  24887. if err != nil {
  24888. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24889. }
  24890. return oldValue.CreatedAt, nil
  24891. }
  24892. // ResetCreatedAt resets all changes to the "created_at" field.
  24893. func (m *SopTaskMutation) ResetCreatedAt() {
  24894. m.created_at = nil
  24895. }
  24896. // SetUpdatedAt sets the "updated_at" field.
  24897. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  24898. m.updated_at = &t
  24899. }
  24900. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24901. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  24902. v := m.updated_at
  24903. if v == nil {
  24904. return
  24905. }
  24906. return *v, true
  24907. }
  24908. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  24909. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24911. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24912. if !m.op.Is(OpUpdateOne) {
  24913. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24914. }
  24915. if m.id == nil || m.oldValue == nil {
  24916. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24917. }
  24918. oldValue, err := m.oldValue(ctx)
  24919. if err != nil {
  24920. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24921. }
  24922. return oldValue.UpdatedAt, nil
  24923. }
  24924. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24925. func (m *SopTaskMutation) ResetUpdatedAt() {
  24926. m.updated_at = nil
  24927. }
  24928. // SetStatus sets the "status" field.
  24929. func (m *SopTaskMutation) SetStatus(u uint8) {
  24930. m.status = &u
  24931. m.addstatus = nil
  24932. }
  24933. // Status returns the value of the "status" field in the mutation.
  24934. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  24935. v := m.status
  24936. if v == nil {
  24937. return
  24938. }
  24939. return *v, true
  24940. }
  24941. // OldStatus returns the old "status" field's value of the SopTask entity.
  24942. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24944. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24945. if !m.op.Is(OpUpdateOne) {
  24946. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24947. }
  24948. if m.id == nil || m.oldValue == nil {
  24949. return v, errors.New("OldStatus requires an ID field in the mutation")
  24950. }
  24951. oldValue, err := m.oldValue(ctx)
  24952. if err != nil {
  24953. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24954. }
  24955. return oldValue.Status, nil
  24956. }
  24957. // AddStatus adds u to the "status" field.
  24958. func (m *SopTaskMutation) AddStatus(u int8) {
  24959. if m.addstatus != nil {
  24960. *m.addstatus += u
  24961. } else {
  24962. m.addstatus = &u
  24963. }
  24964. }
  24965. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24966. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  24967. v := m.addstatus
  24968. if v == nil {
  24969. return
  24970. }
  24971. return *v, true
  24972. }
  24973. // ClearStatus clears the value of the "status" field.
  24974. func (m *SopTaskMutation) ClearStatus() {
  24975. m.status = nil
  24976. m.addstatus = nil
  24977. m.clearedFields[soptask.FieldStatus] = struct{}{}
  24978. }
  24979. // StatusCleared returns if the "status" field was cleared in this mutation.
  24980. func (m *SopTaskMutation) StatusCleared() bool {
  24981. _, ok := m.clearedFields[soptask.FieldStatus]
  24982. return ok
  24983. }
  24984. // ResetStatus resets all changes to the "status" field.
  24985. func (m *SopTaskMutation) ResetStatus() {
  24986. m.status = nil
  24987. m.addstatus = nil
  24988. delete(m.clearedFields, soptask.FieldStatus)
  24989. }
  24990. // SetDeletedAt sets the "deleted_at" field.
  24991. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  24992. m.deleted_at = &t
  24993. }
  24994. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24995. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  24996. v := m.deleted_at
  24997. if v == nil {
  24998. return
  24999. }
  25000. return *v, true
  25001. }
  25002. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  25003. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25005. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25006. if !m.op.Is(OpUpdateOne) {
  25007. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25008. }
  25009. if m.id == nil || m.oldValue == nil {
  25010. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25011. }
  25012. oldValue, err := m.oldValue(ctx)
  25013. if err != nil {
  25014. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25015. }
  25016. return oldValue.DeletedAt, nil
  25017. }
  25018. // ClearDeletedAt clears the value of the "deleted_at" field.
  25019. func (m *SopTaskMutation) ClearDeletedAt() {
  25020. m.deleted_at = nil
  25021. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  25022. }
  25023. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25024. func (m *SopTaskMutation) DeletedAtCleared() bool {
  25025. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  25026. return ok
  25027. }
  25028. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25029. func (m *SopTaskMutation) ResetDeletedAt() {
  25030. m.deleted_at = nil
  25031. delete(m.clearedFields, soptask.FieldDeletedAt)
  25032. }
  25033. // SetName sets the "name" field.
  25034. func (m *SopTaskMutation) SetName(s string) {
  25035. m.name = &s
  25036. }
  25037. // Name returns the value of the "name" field in the mutation.
  25038. func (m *SopTaskMutation) Name() (r string, exists bool) {
  25039. v := m.name
  25040. if v == nil {
  25041. return
  25042. }
  25043. return *v, true
  25044. }
  25045. // OldName returns the old "name" field's value of the SopTask entity.
  25046. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25048. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  25049. if !m.op.Is(OpUpdateOne) {
  25050. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25051. }
  25052. if m.id == nil || m.oldValue == nil {
  25053. return v, errors.New("OldName requires an ID field in the mutation")
  25054. }
  25055. oldValue, err := m.oldValue(ctx)
  25056. if err != nil {
  25057. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25058. }
  25059. return oldValue.Name, nil
  25060. }
  25061. // ResetName resets all changes to the "name" field.
  25062. func (m *SopTaskMutation) ResetName() {
  25063. m.name = nil
  25064. }
  25065. // SetBotWxidList sets the "bot_wxid_list" field.
  25066. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  25067. m.bot_wxid_list = &s
  25068. m.appendbot_wxid_list = nil
  25069. }
  25070. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  25071. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  25072. v := m.bot_wxid_list
  25073. if v == nil {
  25074. return
  25075. }
  25076. return *v, true
  25077. }
  25078. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  25079. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25081. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  25082. if !m.op.Is(OpUpdateOne) {
  25083. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  25084. }
  25085. if m.id == nil || m.oldValue == nil {
  25086. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  25087. }
  25088. oldValue, err := m.oldValue(ctx)
  25089. if err != nil {
  25090. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  25091. }
  25092. return oldValue.BotWxidList, nil
  25093. }
  25094. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  25095. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  25096. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  25097. }
  25098. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  25099. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  25100. if len(m.appendbot_wxid_list) == 0 {
  25101. return nil, false
  25102. }
  25103. return m.appendbot_wxid_list, true
  25104. }
  25105. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  25106. func (m *SopTaskMutation) ClearBotWxidList() {
  25107. m.bot_wxid_list = nil
  25108. m.appendbot_wxid_list = nil
  25109. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  25110. }
  25111. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  25112. func (m *SopTaskMutation) BotWxidListCleared() bool {
  25113. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  25114. return ok
  25115. }
  25116. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  25117. func (m *SopTaskMutation) ResetBotWxidList() {
  25118. m.bot_wxid_list = nil
  25119. m.appendbot_wxid_list = nil
  25120. delete(m.clearedFields, soptask.FieldBotWxidList)
  25121. }
  25122. // SetType sets the "type" field.
  25123. func (m *SopTaskMutation) SetType(i int) {
  25124. m._type = &i
  25125. m.add_type = nil
  25126. }
  25127. // GetType returns the value of the "type" field in the mutation.
  25128. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  25129. v := m._type
  25130. if v == nil {
  25131. return
  25132. }
  25133. return *v, true
  25134. }
  25135. // OldType returns the old "type" field's value of the SopTask entity.
  25136. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25138. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  25139. if !m.op.Is(OpUpdateOne) {
  25140. return v, errors.New("OldType is only allowed on UpdateOne operations")
  25141. }
  25142. if m.id == nil || m.oldValue == nil {
  25143. return v, errors.New("OldType requires an ID field in the mutation")
  25144. }
  25145. oldValue, err := m.oldValue(ctx)
  25146. if err != nil {
  25147. return v, fmt.Errorf("querying old value for OldType: %w", err)
  25148. }
  25149. return oldValue.Type, nil
  25150. }
  25151. // AddType adds i to the "type" field.
  25152. func (m *SopTaskMutation) AddType(i int) {
  25153. if m.add_type != nil {
  25154. *m.add_type += i
  25155. } else {
  25156. m.add_type = &i
  25157. }
  25158. }
  25159. // AddedType returns the value that was added to the "type" field in this mutation.
  25160. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  25161. v := m.add_type
  25162. if v == nil {
  25163. return
  25164. }
  25165. return *v, true
  25166. }
  25167. // ResetType resets all changes to the "type" field.
  25168. func (m *SopTaskMutation) ResetType() {
  25169. m._type = nil
  25170. m.add_type = nil
  25171. }
  25172. // SetPlanStartTime sets the "plan_start_time" field.
  25173. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  25174. m.plan_start_time = &t
  25175. }
  25176. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  25177. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  25178. v := m.plan_start_time
  25179. if v == nil {
  25180. return
  25181. }
  25182. return *v, true
  25183. }
  25184. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  25185. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25187. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  25188. if !m.op.Is(OpUpdateOne) {
  25189. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  25190. }
  25191. if m.id == nil || m.oldValue == nil {
  25192. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  25193. }
  25194. oldValue, err := m.oldValue(ctx)
  25195. if err != nil {
  25196. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  25197. }
  25198. return oldValue.PlanStartTime, nil
  25199. }
  25200. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  25201. func (m *SopTaskMutation) ClearPlanStartTime() {
  25202. m.plan_start_time = nil
  25203. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  25204. }
  25205. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  25206. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  25207. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  25208. return ok
  25209. }
  25210. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  25211. func (m *SopTaskMutation) ResetPlanStartTime() {
  25212. m.plan_start_time = nil
  25213. delete(m.clearedFields, soptask.FieldPlanStartTime)
  25214. }
  25215. // SetPlanEndTime sets the "plan_end_time" field.
  25216. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  25217. m.plan_end_time = &t
  25218. }
  25219. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  25220. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  25221. v := m.plan_end_time
  25222. if v == nil {
  25223. return
  25224. }
  25225. return *v, true
  25226. }
  25227. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  25228. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25230. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  25231. if !m.op.Is(OpUpdateOne) {
  25232. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  25233. }
  25234. if m.id == nil || m.oldValue == nil {
  25235. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  25236. }
  25237. oldValue, err := m.oldValue(ctx)
  25238. if err != nil {
  25239. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  25240. }
  25241. return oldValue.PlanEndTime, nil
  25242. }
  25243. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  25244. func (m *SopTaskMutation) ClearPlanEndTime() {
  25245. m.plan_end_time = nil
  25246. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  25247. }
  25248. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  25249. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  25250. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  25251. return ok
  25252. }
  25253. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  25254. func (m *SopTaskMutation) ResetPlanEndTime() {
  25255. m.plan_end_time = nil
  25256. delete(m.clearedFields, soptask.FieldPlanEndTime)
  25257. }
  25258. // SetCreatorID sets the "creator_id" field.
  25259. func (m *SopTaskMutation) SetCreatorID(s string) {
  25260. m.creator_id = &s
  25261. }
  25262. // CreatorID returns the value of the "creator_id" field in the mutation.
  25263. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  25264. v := m.creator_id
  25265. if v == nil {
  25266. return
  25267. }
  25268. return *v, true
  25269. }
  25270. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  25271. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25273. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  25274. if !m.op.Is(OpUpdateOne) {
  25275. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  25276. }
  25277. if m.id == nil || m.oldValue == nil {
  25278. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  25279. }
  25280. oldValue, err := m.oldValue(ctx)
  25281. if err != nil {
  25282. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  25283. }
  25284. return oldValue.CreatorID, nil
  25285. }
  25286. // ClearCreatorID clears the value of the "creator_id" field.
  25287. func (m *SopTaskMutation) ClearCreatorID() {
  25288. m.creator_id = nil
  25289. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  25290. }
  25291. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  25292. func (m *SopTaskMutation) CreatorIDCleared() bool {
  25293. _, ok := m.clearedFields[soptask.FieldCreatorID]
  25294. return ok
  25295. }
  25296. // ResetCreatorID resets all changes to the "creator_id" field.
  25297. func (m *SopTaskMutation) ResetCreatorID() {
  25298. m.creator_id = nil
  25299. delete(m.clearedFields, soptask.FieldCreatorID)
  25300. }
  25301. // SetOrganizationID sets the "organization_id" field.
  25302. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  25303. m.organization_id = &u
  25304. m.addorganization_id = nil
  25305. }
  25306. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25307. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  25308. v := m.organization_id
  25309. if v == nil {
  25310. return
  25311. }
  25312. return *v, true
  25313. }
  25314. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  25315. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25317. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25318. if !m.op.Is(OpUpdateOne) {
  25319. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25320. }
  25321. if m.id == nil || m.oldValue == nil {
  25322. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25323. }
  25324. oldValue, err := m.oldValue(ctx)
  25325. if err != nil {
  25326. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25327. }
  25328. return oldValue.OrganizationID, nil
  25329. }
  25330. // AddOrganizationID adds u to the "organization_id" field.
  25331. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  25332. if m.addorganization_id != nil {
  25333. *m.addorganization_id += u
  25334. } else {
  25335. m.addorganization_id = &u
  25336. }
  25337. }
  25338. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25339. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  25340. v := m.addorganization_id
  25341. if v == nil {
  25342. return
  25343. }
  25344. return *v, true
  25345. }
  25346. // ClearOrganizationID clears the value of the "organization_id" field.
  25347. func (m *SopTaskMutation) ClearOrganizationID() {
  25348. m.organization_id = nil
  25349. m.addorganization_id = nil
  25350. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  25351. }
  25352. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  25353. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  25354. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  25355. return ok
  25356. }
  25357. // ResetOrganizationID resets all changes to the "organization_id" field.
  25358. func (m *SopTaskMutation) ResetOrganizationID() {
  25359. m.organization_id = nil
  25360. m.addorganization_id = nil
  25361. delete(m.clearedFields, soptask.FieldOrganizationID)
  25362. }
  25363. // SetToken sets the "token" field.
  25364. func (m *SopTaskMutation) SetToken(s []string) {
  25365. m.token = &s
  25366. m.appendtoken = nil
  25367. }
  25368. // Token returns the value of the "token" field in the mutation.
  25369. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  25370. v := m.token
  25371. if v == nil {
  25372. return
  25373. }
  25374. return *v, true
  25375. }
  25376. // OldToken returns the old "token" field's value of the SopTask entity.
  25377. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  25378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25379. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  25380. if !m.op.Is(OpUpdateOne) {
  25381. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25382. }
  25383. if m.id == nil || m.oldValue == nil {
  25384. return v, errors.New("OldToken requires an ID field in the mutation")
  25385. }
  25386. oldValue, err := m.oldValue(ctx)
  25387. if err != nil {
  25388. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25389. }
  25390. return oldValue.Token, nil
  25391. }
  25392. // AppendToken adds s to the "token" field.
  25393. func (m *SopTaskMutation) AppendToken(s []string) {
  25394. m.appendtoken = append(m.appendtoken, s...)
  25395. }
  25396. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  25397. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  25398. if len(m.appendtoken) == 0 {
  25399. return nil, false
  25400. }
  25401. return m.appendtoken, true
  25402. }
  25403. // ClearToken clears the value of the "token" field.
  25404. func (m *SopTaskMutation) ClearToken() {
  25405. m.token = nil
  25406. m.appendtoken = nil
  25407. m.clearedFields[soptask.FieldToken] = struct{}{}
  25408. }
  25409. // TokenCleared returns if the "token" field was cleared in this mutation.
  25410. func (m *SopTaskMutation) TokenCleared() bool {
  25411. _, ok := m.clearedFields[soptask.FieldToken]
  25412. return ok
  25413. }
  25414. // ResetToken resets all changes to the "token" field.
  25415. func (m *SopTaskMutation) ResetToken() {
  25416. m.token = nil
  25417. m.appendtoken = nil
  25418. delete(m.clearedFields, soptask.FieldToken)
  25419. }
  25420. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  25421. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  25422. if m.task_stages == nil {
  25423. m.task_stages = make(map[uint64]struct{})
  25424. }
  25425. for i := range ids {
  25426. m.task_stages[ids[i]] = struct{}{}
  25427. }
  25428. }
  25429. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  25430. func (m *SopTaskMutation) ClearTaskStages() {
  25431. m.clearedtask_stages = true
  25432. }
  25433. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  25434. func (m *SopTaskMutation) TaskStagesCleared() bool {
  25435. return m.clearedtask_stages
  25436. }
  25437. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  25438. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  25439. if m.removedtask_stages == nil {
  25440. m.removedtask_stages = make(map[uint64]struct{})
  25441. }
  25442. for i := range ids {
  25443. delete(m.task_stages, ids[i])
  25444. m.removedtask_stages[ids[i]] = struct{}{}
  25445. }
  25446. }
  25447. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  25448. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  25449. for id := range m.removedtask_stages {
  25450. ids = append(ids, id)
  25451. }
  25452. return
  25453. }
  25454. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  25455. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  25456. for id := range m.task_stages {
  25457. ids = append(ids, id)
  25458. }
  25459. return
  25460. }
  25461. // ResetTaskStages resets all changes to the "task_stages" edge.
  25462. func (m *SopTaskMutation) ResetTaskStages() {
  25463. m.task_stages = nil
  25464. m.clearedtask_stages = false
  25465. m.removedtask_stages = nil
  25466. }
  25467. // Where appends a list predicates to the SopTaskMutation builder.
  25468. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  25469. m.predicates = append(m.predicates, ps...)
  25470. }
  25471. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  25472. // users can use type-assertion to append predicates that do not depend on any generated package.
  25473. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  25474. p := make([]predicate.SopTask, len(ps))
  25475. for i := range ps {
  25476. p[i] = ps[i]
  25477. }
  25478. m.Where(p...)
  25479. }
  25480. // Op returns the operation name.
  25481. func (m *SopTaskMutation) Op() Op {
  25482. return m.op
  25483. }
  25484. // SetOp allows setting the mutation operation.
  25485. func (m *SopTaskMutation) SetOp(op Op) {
  25486. m.op = op
  25487. }
  25488. // Type returns the node type of this mutation (SopTask).
  25489. func (m *SopTaskMutation) Type() string {
  25490. return m.typ
  25491. }
  25492. // Fields returns all fields that were changed during this mutation. Note that in
  25493. // order to get all numeric fields that were incremented/decremented, call
  25494. // AddedFields().
  25495. func (m *SopTaskMutation) Fields() []string {
  25496. fields := make([]string, 0, 12)
  25497. if m.created_at != nil {
  25498. fields = append(fields, soptask.FieldCreatedAt)
  25499. }
  25500. if m.updated_at != nil {
  25501. fields = append(fields, soptask.FieldUpdatedAt)
  25502. }
  25503. if m.status != nil {
  25504. fields = append(fields, soptask.FieldStatus)
  25505. }
  25506. if m.deleted_at != nil {
  25507. fields = append(fields, soptask.FieldDeletedAt)
  25508. }
  25509. if m.name != nil {
  25510. fields = append(fields, soptask.FieldName)
  25511. }
  25512. if m.bot_wxid_list != nil {
  25513. fields = append(fields, soptask.FieldBotWxidList)
  25514. }
  25515. if m._type != nil {
  25516. fields = append(fields, soptask.FieldType)
  25517. }
  25518. if m.plan_start_time != nil {
  25519. fields = append(fields, soptask.FieldPlanStartTime)
  25520. }
  25521. if m.plan_end_time != nil {
  25522. fields = append(fields, soptask.FieldPlanEndTime)
  25523. }
  25524. if m.creator_id != nil {
  25525. fields = append(fields, soptask.FieldCreatorID)
  25526. }
  25527. if m.organization_id != nil {
  25528. fields = append(fields, soptask.FieldOrganizationID)
  25529. }
  25530. if m.token != nil {
  25531. fields = append(fields, soptask.FieldToken)
  25532. }
  25533. return fields
  25534. }
  25535. // Field returns the value of a field with the given name. The second boolean
  25536. // return value indicates that this field was not set, or was not defined in the
  25537. // schema.
  25538. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  25539. switch name {
  25540. case soptask.FieldCreatedAt:
  25541. return m.CreatedAt()
  25542. case soptask.FieldUpdatedAt:
  25543. return m.UpdatedAt()
  25544. case soptask.FieldStatus:
  25545. return m.Status()
  25546. case soptask.FieldDeletedAt:
  25547. return m.DeletedAt()
  25548. case soptask.FieldName:
  25549. return m.Name()
  25550. case soptask.FieldBotWxidList:
  25551. return m.BotWxidList()
  25552. case soptask.FieldType:
  25553. return m.GetType()
  25554. case soptask.FieldPlanStartTime:
  25555. return m.PlanStartTime()
  25556. case soptask.FieldPlanEndTime:
  25557. return m.PlanEndTime()
  25558. case soptask.FieldCreatorID:
  25559. return m.CreatorID()
  25560. case soptask.FieldOrganizationID:
  25561. return m.OrganizationID()
  25562. case soptask.FieldToken:
  25563. return m.Token()
  25564. }
  25565. return nil, false
  25566. }
  25567. // OldField returns the old value of the field from the database. An error is
  25568. // returned if the mutation operation is not UpdateOne, or the query to the
  25569. // database failed.
  25570. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25571. switch name {
  25572. case soptask.FieldCreatedAt:
  25573. return m.OldCreatedAt(ctx)
  25574. case soptask.FieldUpdatedAt:
  25575. return m.OldUpdatedAt(ctx)
  25576. case soptask.FieldStatus:
  25577. return m.OldStatus(ctx)
  25578. case soptask.FieldDeletedAt:
  25579. return m.OldDeletedAt(ctx)
  25580. case soptask.FieldName:
  25581. return m.OldName(ctx)
  25582. case soptask.FieldBotWxidList:
  25583. return m.OldBotWxidList(ctx)
  25584. case soptask.FieldType:
  25585. return m.OldType(ctx)
  25586. case soptask.FieldPlanStartTime:
  25587. return m.OldPlanStartTime(ctx)
  25588. case soptask.FieldPlanEndTime:
  25589. return m.OldPlanEndTime(ctx)
  25590. case soptask.FieldCreatorID:
  25591. return m.OldCreatorID(ctx)
  25592. case soptask.FieldOrganizationID:
  25593. return m.OldOrganizationID(ctx)
  25594. case soptask.FieldToken:
  25595. return m.OldToken(ctx)
  25596. }
  25597. return nil, fmt.Errorf("unknown SopTask field %s", name)
  25598. }
  25599. // SetField sets the value of a field with the given name. It returns an error if
  25600. // the field is not defined in the schema, or if the type mismatched the field
  25601. // type.
  25602. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  25603. switch name {
  25604. case soptask.FieldCreatedAt:
  25605. v, ok := value.(time.Time)
  25606. if !ok {
  25607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25608. }
  25609. m.SetCreatedAt(v)
  25610. return nil
  25611. case soptask.FieldUpdatedAt:
  25612. v, ok := value.(time.Time)
  25613. if !ok {
  25614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25615. }
  25616. m.SetUpdatedAt(v)
  25617. return nil
  25618. case soptask.FieldStatus:
  25619. v, ok := value.(uint8)
  25620. if !ok {
  25621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25622. }
  25623. m.SetStatus(v)
  25624. return nil
  25625. case soptask.FieldDeletedAt:
  25626. v, ok := value.(time.Time)
  25627. if !ok {
  25628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25629. }
  25630. m.SetDeletedAt(v)
  25631. return nil
  25632. case soptask.FieldName:
  25633. v, ok := value.(string)
  25634. if !ok {
  25635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25636. }
  25637. m.SetName(v)
  25638. return nil
  25639. case soptask.FieldBotWxidList:
  25640. v, ok := value.([]string)
  25641. if !ok {
  25642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25643. }
  25644. m.SetBotWxidList(v)
  25645. return nil
  25646. case soptask.FieldType:
  25647. v, ok := value.(int)
  25648. if !ok {
  25649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25650. }
  25651. m.SetType(v)
  25652. return nil
  25653. case soptask.FieldPlanStartTime:
  25654. v, ok := value.(time.Time)
  25655. if !ok {
  25656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25657. }
  25658. m.SetPlanStartTime(v)
  25659. return nil
  25660. case soptask.FieldPlanEndTime:
  25661. v, ok := value.(time.Time)
  25662. if !ok {
  25663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25664. }
  25665. m.SetPlanEndTime(v)
  25666. return nil
  25667. case soptask.FieldCreatorID:
  25668. v, ok := value.(string)
  25669. if !ok {
  25670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25671. }
  25672. m.SetCreatorID(v)
  25673. return nil
  25674. case soptask.FieldOrganizationID:
  25675. v, ok := value.(uint64)
  25676. if !ok {
  25677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25678. }
  25679. m.SetOrganizationID(v)
  25680. return nil
  25681. case soptask.FieldToken:
  25682. v, ok := value.([]string)
  25683. if !ok {
  25684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25685. }
  25686. m.SetToken(v)
  25687. return nil
  25688. }
  25689. return fmt.Errorf("unknown SopTask field %s", name)
  25690. }
  25691. // AddedFields returns all numeric fields that were incremented/decremented during
  25692. // this mutation.
  25693. func (m *SopTaskMutation) AddedFields() []string {
  25694. var fields []string
  25695. if m.addstatus != nil {
  25696. fields = append(fields, soptask.FieldStatus)
  25697. }
  25698. if m.add_type != nil {
  25699. fields = append(fields, soptask.FieldType)
  25700. }
  25701. if m.addorganization_id != nil {
  25702. fields = append(fields, soptask.FieldOrganizationID)
  25703. }
  25704. return fields
  25705. }
  25706. // AddedField returns the numeric value that was incremented/decremented on a field
  25707. // with the given name. The second boolean return value indicates that this field
  25708. // was not set, or was not defined in the schema.
  25709. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  25710. switch name {
  25711. case soptask.FieldStatus:
  25712. return m.AddedStatus()
  25713. case soptask.FieldType:
  25714. return m.AddedType()
  25715. case soptask.FieldOrganizationID:
  25716. return m.AddedOrganizationID()
  25717. }
  25718. return nil, false
  25719. }
  25720. // AddField adds the value to the field with the given name. It returns an error if
  25721. // the field is not defined in the schema, or if the type mismatched the field
  25722. // type.
  25723. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  25724. switch name {
  25725. case soptask.FieldStatus:
  25726. v, ok := value.(int8)
  25727. if !ok {
  25728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25729. }
  25730. m.AddStatus(v)
  25731. return nil
  25732. case soptask.FieldType:
  25733. v, ok := value.(int)
  25734. if !ok {
  25735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25736. }
  25737. m.AddType(v)
  25738. return nil
  25739. case soptask.FieldOrganizationID:
  25740. v, ok := value.(int64)
  25741. if !ok {
  25742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25743. }
  25744. m.AddOrganizationID(v)
  25745. return nil
  25746. }
  25747. return fmt.Errorf("unknown SopTask numeric field %s", name)
  25748. }
  25749. // ClearedFields returns all nullable fields that were cleared during this
  25750. // mutation.
  25751. func (m *SopTaskMutation) ClearedFields() []string {
  25752. var fields []string
  25753. if m.FieldCleared(soptask.FieldStatus) {
  25754. fields = append(fields, soptask.FieldStatus)
  25755. }
  25756. if m.FieldCleared(soptask.FieldDeletedAt) {
  25757. fields = append(fields, soptask.FieldDeletedAt)
  25758. }
  25759. if m.FieldCleared(soptask.FieldBotWxidList) {
  25760. fields = append(fields, soptask.FieldBotWxidList)
  25761. }
  25762. if m.FieldCleared(soptask.FieldPlanStartTime) {
  25763. fields = append(fields, soptask.FieldPlanStartTime)
  25764. }
  25765. if m.FieldCleared(soptask.FieldPlanEndTime) {
  25766. fields = append(fields, soptask.FieldPlanEndTime)
  25767. }
  25768. if m.FieldCleared(soptask.FieldCreatorID) {
  25769. fields = append(fields, soptask.FieldCreatorID)
  25770. }
  25771. if m.FieldCleared(soptask.FieldOrganizationID) {
  25772. fields = append(fields, soptask.FieldOrganizationID)
  25773. }
  25774. if m.FieldCleared(soptask.FieldToken) {
  25775. fields = append(fields, soptask.FieldToken)
  25776. }
  25777. return fields
  25778. }
  25779. // FieldCleared returns a boolean indicating if a field with the given name was
  25780. // cleared in this mutation.
  25781. func (m *SopTaskMutation) FieldCleared(name string) bool {
  25782. _, ok := m.clearedFields[name]
  25783. return ok
  25784. }
  25785. // ClearField clears the value of the field with the given name. It returns an
  25786. // error if the field is not defined in the schema.
  25787. func (m *SopTaskMutation) ClearField(name string) error {
  25788. switch name {
  25789. case soptask.FieldStatus:
  25790. m.ClearStatus()
  25791. return nil
  25792. case soptask.FieldDeletedAt:
  25793. m.ClearDeletedAt()
  25794. return nil
  25795. case soptask.FieldBotWxidList:
  25796. m.ClearBotWxidList()
  25797. return nil
  25798. case soptask.FieldPlanStartTime:
  25799. m.ClearPlanStartTime()
  25800. return nil
  25801. case soptask.FieldPlanEndTime:
  25802. m.ClearPlanEndTime()
  25803. return nil
  25804. case soptask.FieldCreatorID:
  25805. m.ClearCreatorID()
  25806. return nil
  25807. case soptask.FieldOrganizationID:
  25808. m.ClearOrganizationID()
  25809. return nil
  25810. case soptask.FieldToken:
  25811. m.ClearToken()
  25812. return nil
  25813. }
  25814. return fmt.Errorf("unknown SopTask nullable field %s", name)
  25815. }
  25816. // ResetField resets all changes in the mutation for the field with the given name.
  25817. // It returns an error if the field is not defined in the schema.
  25818. func (m *SopTaskMutation) ResetField(name string) error {
  25819. switch name {
  25820. case soptask.FieldCreatedAt:
  25821. m.ResetCreatedAt()
  25822. return nil
  25823. case soptask.FieldUpdatedAt:
  25824. m.ResetUpdatedAt()
  25825. return nil
  25826. case soptask.FieldStatus:
  25827. m.ResetStatus()
  25828. return nil
  25829. case soptask.FieldDeletedAt:
  25830. m.ResetDeletedAt()
  25831. return nil
  25832. case soptask.FieldName:
  25833. m.ResetName()
  25834. return nil
  25835. case soptask.FieldBotWxidList:
  25836. m.ResetBotWxidList()
  25837. return nil
  25838. case soptask.FieldType:
  25839. m.ResetType()
  25840. return nil
  25841. case soptask.FieldPlanStartTime:
  25842. m.ResetPlanStartTime()
  25843. return nil
  25844. case soptask.FieldPlanEndTime:
  25845. m.ResetPlanEndTime()
  25846. return nil
  25847. case soptask.FieldCreatorID:
  25848. m.ResetCreatorID()
  25849. return nil
  25850. case soptask.FieldOrganizationID:
  25851. m.ResetOrganizationID()
  25852. return nil
  25853. case soptask.FieldToken:
  25854. m.ResetToken()
  25855. return nil
  25856. }
  25857. return fmt.Errorf("unknown SopTask field %s", name)
  25858. }
  25859. // AddedEdges returns all edge names that were set/added in this mutation.
  25860. func (m *SopTaskMutation) AddedEdges() []string {
  25861. edges := make([]string, 0, 1)
  25862. if m.task_stages != nil {
  25863. edges = append(edges, soptask.EdgeTaskStages)
  25864. }
  25865. return edges
  25866. }
  25867. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25868. // name in this mutation.
  25869. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  25870. switch name {
  25871. case soptask.EdgeTaskStages:
  25872. ids := make([]ent.Value, 0, len(m.task_stages))
  25873. for id := range m.task_stages {
  25874. ids = append(ids, id)
  25875. }
  25876. return ids
  25877. }
  25878. return nil
  25879. }
  25880. // RemovedEdges returns all edge names that were removed in this mutation.
  25881. func (m *SopTaskMutation) RemovedEdges() []string {
  25882. edges := make([]string, 0, 1)
  25883. if m.removedtask_stages != nil {
  25884. edges = append(edges, soptask.EdgeTaskStages)
  25885. }
  25886. return edges
  25887. }
  25888. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25889. // the given name in this mutation.
  25890. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  25891. switch name {
  25892. case soptask.EdgeTaskStages:
  25893. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  25894. for id := range m.removedtask_stages {
  25895. ids = append(ids, id)
  25896. }
  25897. return ids
  25898. }
  25899. return nil
  25900. }
  25901. // ClearedEdges returns all edge names that were cleared in this mutation.
  25902. func (m *SopTaskMutation) ClearedEdges() []string {
  25903. edges := make([]string, 0, 1)
  25904. if m.clearedtask_stages {
  25905. edges = append(edges, soptask.EdgeTaskStages)
  25906. }
  25907. return edges
  25908. }
  25909. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25910. // was cleared in this mutation.
  25911. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  25912. switch name {
  25913. case soptask.EdgeTaskStages:
  25914. return m.clearedtask_stages
  25915. }
  25916. return false
  25917. }
  25918. // ClearEdge clears the value of the edge with the given name. It returns an error
  25919. // if that edge is not defined in the schema.
  25920. func (m *SopTaskMutation) ClearEdge(name string) error {
  25921. switch name {
  25922. }
  25923. return fmt.Errorf("unknown SopTask unique edge %s", name)
  25924. }
  25925. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25926. // It returns an error if the edge is not defined in the schema.
  25927. func (m *SopTaskMutation) ResetEdge(name string) error {
  25928. switch name {
  25929. case soptask.EdgeTaskStages:
  25930. m.ResetTaskStages()
  25931. return nil
  25932. }
  25933. return fmt.Errorf("unknown SopTask edge %s", name)
  25934. }
  25935. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  25936. type TokenMutation struct {
  25937. config
  25938. op Op
  25939. typ string
  25940. id *uint64
  25941. created_at *time.Time
  25942. updated_at *time.Time
  25943. deleted_at *time.Time
  25944. expire_at *time.Time
  25945. token *string
  25946. mac *string
  25947. organization_id *uint64
  25948. addorganization_id *int64
  25949. custom_agent_base *string
  25950. custom_agent_key *string
  25951. openai_base *string
  25952. openai_key *string
  25953. clearedFields map[string]struct{}
  25954. agent *uint64
  25955. clearedagent bool
  25956. done bool
  25957. oldValue func(context.Context) (*Token, error)
  25958. predicates []predicate.Token
  25959. }
  25960. var _ ent.Mutation = (*TokenMutation)(nil)
  25961. // tokenOption allows management of the mutation configuration using functional options.
  25962. type tokenOption func(*TokenMutation)
  25963. // newTokenMutation creates new mutation for the Token entity.
  25964. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  25965. m := &TokenMutation{
  25966. config: c,
  25967. op: op,
  25968. typ: TypeToken,
  25969. clearedFields: make(map[string]struct{}),
  25970. }
  25971. for _, opt := range opts {
  25972. opt(m)
  25973. }
  25974. return m
  25975. }
  25976. // withTokenID sets the ID field of the mutation.
  25977. func withTokenID(id uint64) tokenOption {
  25978. return func(m *TokenMutation) {
  25979. var (
  25980. err error
  25981. once sync.Once
  25982. value *Token
  25983. )
  25984. m.oldValue = func(ctx context.Context) (*Token, error) {
  25985. once.Do(func() {
  25986. if m.done {
  25987. err = errors.New("querying old values post mutation is not allowed")
  25988. } else {
  25989. value, err = m.Client().Token.Get(ctx, id)
  25990. }
  25991. })
  25992. return value, err
  25993. }
  25994. m.id = &id
  25995. }
  25996. }
  25997. // withToken sets the old Token of the mutation.
  25998. func withToken(node *Token) tokenOption {
  25999. return func(m *TokenMutation) {
  26000. m.oldValue = func(context.Context) (*Token, error) {
  26001. return node, nil
  26002. }
  26003. m.id = &node.ID
  26004. }
  26005. }
  26006. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26007. // executed in a transaction (ent.Tx), a transactional client is returned.
  26008. func (m TokenMutation) Client() *Client {
  26009. client := &Client{config: m.config}
  26010. client.init()
  26011. return client
  26012. }
  26013. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26014. // it returns an error otherwise.
  26015. func (m TokenMutation) Tx() (*Tx, error) {
  26016. if _, ok := m.driver.(*txDriver); !ok {
  26017. return nil, errors.New("ent: mutation is not running in a transaction")
  26018. }
  26019. tx := &Tx{config: m.config}
  26020. tx.init()
  26021. return tx, nil
  26022. }
  26023. // SetID sets the value of the id field. Note that this
  26024. // operation is only accepted on creation of Token entities.
  26025. func (m *TokenMutation) SetID(id uint64) {
  26026. m.id = &id
  26027. }
  26028. // ID returns the ID value in the mutation. Note that the ID is only available
  26029. // if it was provided to the builder or after it was returned from the database.
  26030. func (m *TokenMutation) ID() (id uint64, exists bool) {
  26031. if m.id == nil {
  26032. return
  26033. }
  26034. return *m.id, true
  26035. }
  26036. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26037. // That means, if the mutation is applied within a transaction with an isolation level such
  26038. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26039. // or updated by the mutation.
  26040. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  26041. switch {
  26042. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26043. id, exists := m.ID()
  26044. if exists {
  26045. return []uint64{id}, nil
  26046. }
  26047. fallthrough
  26048. case m.op.Is(OpUpdate | OpDelete):
  26049. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  26050. default:
  26051. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26052. }
  26053. }
  26054. // SetCreatedAt sets the "created_at" field.
  26055. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  26056. m.created_at = &t
  26057. }
  26058. // CreatedAt returns the value of the "created_at" field in the mutation.
  26059. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  26060. v := m.created_at
  26061. if v == nil {
  26062. return
  26063. }
  26064. return *v, true
  26065. }
  26066. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  26067. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26069. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26070. if !m.op.Is(OpUpdateOne) {
  26071. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26072. }
  26073. if m.id == nil || m.oldValue == nil {
  26074. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26075. }
  26076. oldValue, err := m.oldValue(ctx)
  26077. if err != nil {
  26078. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26079. }
  26080. return oldValue.CreatedAt, nil
  26081. }
  26082. // ResetCreatedAt resets all changes to the "created_at" field.
  26083. func (m *TokenMutation) ResetCreatedAt() {
  26084. m.created_at = nil
  26085. }
  26086. // SetUpdatedAt sets the "updated_at" field.
  26087. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  26088. m.updated_at = &t
  26089. }
  26090. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26091. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  26092. v := m.updated_at
  26093. if v == nil {
  26094. return
  26095. }
  26096. return *v, true
  26097. }
  26098. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  26099. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26101. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26102. if !m.op.Is(OpUpdateOne) {
  26103. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26104. }
  26105. if m.id == nil || m.oldValue == nil {
  26106. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26107. }
  26108. oldValue, err := m.oldValue(ctx)
  26109. if err != nil {
  26110. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26111. }
  26112. return oldValue.UpdatedAt, nil
  26113. }
  26114. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26115. func (m *TokenMutation) ResetUpdatedAt() {
  26116. m.updated_at = nil
  26117. }
  26118. // SetDeletedAt sets the "deleted_at" field.
  26119. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  26120. m.deleted_at = &t
  26121. }
  26122. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26123. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  26124. v := m.deleted_at
  26125. if v == nil {
  26126. return
  26127. }
  26128. return *v, true
  26129. }
  26130. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  26131. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26133. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26134. if !m.op.Is(OpUpdateOne) {
  26135. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26136. }
  26137. if m.id == nil || m.oldValue == nil {
  26138. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26139. }
  26140. oldValue, err := m.oldValue(ctx)
  26141. if err != nil {
  26142. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26143. }
  26144. return oldValue.DeletedAt, nil
  26145. }
  26146. // ClearDeletedAt clears the value of the "deleted_at" field.
  26147. func (m *TokenMutation) ClearDeletedAt() {
  26148. m.deleted_at = nil
  26149. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  26150. }
  26151. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26152. func (m *TokenMutation) DeletedAtCleared() bool {
  26153. _, ok := m.clearedFields[token.FieldDeletedAt]
  26154. return ok
  26155. }
  26156. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26157. func (m *TokenMutation) ResetDeletedAt() {
  26158. m.deleted_at = nil
  26159. delete(m.clearedFields, token.FieldDeletedAt)
  26160. }
  26161. // SetExpireAt sets the "expire_at" field.
  26162. func (m *TokenMutation) SetExpireAt(t time.Time) {
  26163. m.expire_at = &t
  26164. }
  26165. // ExpireAt returns the value of the "expire_at" field in the mutation.
  26166. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  26167. v := m.expire_at
  26168. if v == nil {
  26169. return
  26170. }
  26171. return *v, true
  26172. }
  26173. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  26174. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26176. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  26177. if !m.op.Is(OpUpdateOne) {
  26178. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  26179. }
  26180. if m.id == nil || m.oldValue == nil {
  26181. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  26182. }
  26183. oldValue, err := m.oldValue(ctx)
  26184. if err != nil {
  26185. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  26186. }
  26187. return oldValue.ExpireAt, nil
  26188. }
  26189. // ClearExpireAt clears the value of the "expire_at" field.
  26190. func (m *TokenMutation) ClearExpireAt() {
  26191. m.expire_at = nil
  26192. m.clearedFields[token.FieldExpireAt] = struct{}{}
  26193. }
  26194. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  26195. func (m *TokenMutation) ExpireAtCleared() bool {
  26196. _, ok := m.clearedFields[token.FieldExpireAt]
  26197. return ok
  26198. }
  26199. // ResetExpireAt resets all changes to the "expire_at" field.
  26200. func (m *TokenMutation) ResetExpireAt() {
  26201. m.expire_at = nil
  26202. delete(m.clearedFields, token.FieldExpireAt)
  26203. }
  26204. // SetToken sets the "token" field.
  26205. func (m *TokenMutation) SetToken(s string) {
  26206. m.token = &s
  26207. }
  26208. // Token returns the value of the "token" field in the mutation.
  26209. func (m *TokenMutation) Token() (r string, exists bool) {
  26210. v := m.token
  26211. if v == nil {
  26212. return
  26213. }
  26214. return *v, true
  26215. }
  26216. // OldToken returns the old "token" field's value of the Token entity.
  26217. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26219. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  26220. if !m.op.Is(OpUpdateOne) {
  26221. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26222. }
  26223. if m.id == nil || m.oldValue == nil {
  26224. return v, errors.New("OldToken requires an ID field in the mutation")
  26225. }
  26226. oldValue, err := m.oldValue(ctx)
  26227. if err != nil {
  26228. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26229. }
  26230. return oldValue.Token, nil
  26231. }
  26232. // ClearToken clears the value of the "token" field.
  26233. func (m *TokenMutation) ClearToken() {
  26234. m.token = nil
  26235. m.clearedFields[token.FieldToken] = struct{}{}
  26236. }
  26237. // TokenCleared returns if the "token" field was cleared in this mutation.
  26238. func (m *TokenMutation) TokenCleared() bool {
  26239. _, ok := m.clearedFields[token.FieldToken]
  26240. return ok
  26241. }
  26242. // ResetToken resets all changes to the "token" field.
  26243. func (m *TokenMutation) ResetToken() {
  26244. m.token = nil
  26245. delete(m.clearedFields, token.FieldToken)
  26246. }
  26247. // SetMAC sets the "mac" field.
  26248. func (m *TokenMutation) SetMAC(s string) {
  26249. m.mac = &s
  26250. }
  26251. // MAC returns the value of the "mac" field in the mutation.
  26252. func (m *TokenMutation) MAC() (r string, exists bool) {
  26253. v := m.mac
  26254. if v == nil {
  26255. return
  26256. }
  26257. return *v, true
  26258. }
  26259. // OldMAC returns the old "mac" field's value of the Token entity.
  26260. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26262. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  26263. if !m.op.Is(OpUpdateOne) {
  26264. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  26265. }
  26266. if m.id == nil || m.oldValue == nil {
  26267. return v, errors.New("OldMAC requires an ID field in the mutation")
  26268. }
  26269. oldValue, err := m.oldValue(ctx)
  26270. if err != nil {
  26271. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  26272. }
  26273. return oldValue.MAC, nil
  26274. }
  26275. // ClearMAC clears the value of the "mac" field.
  26276. func (m *TokenMutation) ClearMAC() {
  26277. m.mac = nil
  26278. m.clearedFields[token.FieldMAC] = struct{}{}
  26279. }
  26280. // MACCleared returns if the "mac" field was cleared in this mutation.
  26281. func (m *TokenMutation) MACCleared() bool {
  26282. _, ok := m.clearedFields[token.FieldMAC]
  26283. return ok
  26284. }
  26285. // ResetMAC resets all changes to the "mac" field.
  26286. func (m *TokenMutation) ResetMAC() {
  26287. m.mac = nil
  26288. delete(m.clearedFields, token.FieldMAC)
  26289. }
  26290. // SetOrganizationID sets the "organization_id" field.
  26291. func (m *TokenMutation) SetOrganizationID(u uint64) {
  26292. m.organization_id = &u
  26293. m.addorganization_id = nil
  26294. }
  26295. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26296. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  26297. v := m.organization_id
  26298. if v == nil {
  26299. return
  26300. }
  26301. return *v, true
  26302. }
  26303. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  26304. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26306. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26307. if !m.op.Is(OpUpdateOne) {
  26308. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26309. }
  26310. if m.id == nil || m.oldValue == nil {
  26311. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26312. }
  26313. oldValue, err := m.oldValue(ctx)
  26314. if err != nil {
  26315. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26316. }
  26317. return oldValue.OrganizationID, nil
  26318. }
  26319. // AddOrganizationID adds u to the "organization_id" field.
  26320. func (m *TokenMutation) AddOrganizationID(u int64) {
  26321. if m.addorganization_id != nil {
  26322. *m.addorganization_id += u
  26323. } else {
  26324. m.addorganization_id = &u
  26325. }
  26326. }
  26327. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26328. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  26329. v := m.addorganization_id
  26330. if v == nil {
  26331. return
  26332. }
  26333. return *v, true
  26334. }
  26335. // ResetOrganizationID resets all changes to the "organization_id" field.
  26336. func (m *TokenMutation) ResetOrganizationID() {
  26337. m.organization_id = nil
  26338. m.addorganization_id = nil
  26339. }
  26340. // SetAgentID sets the "agent_id" field.
  26341. func (m *TokenMutation) SetAgentID(u uint64) {
  26342. m.agent = &u
  26343. }
  26344. // AgentID returns the value of the "agent_id" field in the mutation.
  26345. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  26346. v := m.agent
  26347. if v == nil {
  26348. return
  26349. }
  26350. return *v, true
  26351. }
  26352. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  26353. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26355. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  26356. if !m.op.Is(OpUpdateOne) {
  26357. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  26358. }
  26359. if m.id == nil || m.oldValue == nil {
  26360. return v, errors.New("OldAgentID requires an ID field in the mutation")
  26361. }
  26362. oldValue, err := m.oldValue(ctx)
  26363. if err != nil {
  26364. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  26365. }
  26366. return oldValue.AgentID, nil
  26367. }
  26368. // ResetAgentID resets all changes to the "agent_id" field.
  26369. func (m *TokenMutation) ResetAgentID() {
  26370. m.agent = nil
  26371. }
  26372. // SetCustomAgentBase sets the "custom_agent_base" field.
  26373. func (m *TokenMutation) SetCustomAgentBase(s string) {
  26374. m.custom_agent_base = &s
  26375. }
  26376. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  26377. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  26378. v := m.custom_agent_base
  26379. if v == nil {
  26380. return
  26381. }
  26382. return *v, true
  26383. }
  26384. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  26385. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26387. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  26388. if !m.op.Is(OpUpdateOne) {
  26389. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  26390. }
  26391. if m.id == nil || m.oldValue == nil {
  26392. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  26393. }
  26394. oldValue, err := m.oldValue(ctx)
  26395. if err != nil {
  26396. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  26397. }
  26398. return oldValue.CustomAgentBase, nil
  26399. }
  26400. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  26401. func (m *TokenMutation) ClearCustomAgentBase() {
  26402. m.custom_agent_base = nil
  26403. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  26404. }
  26405. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  26406. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  26407. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  26408. return ok
  26409. }
  26410. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  26411. func (m *TokenMutation) ResetCustomAgentBase() {
  26412. m.custom_agent_base = nil
  26413. delete(m.clearedFields, token.FieldCustomAgentBase)
  26414. }
  26415. // SetCustomAgentKey sets the "custom_agent_key" field.
  26416. func (m *TokenMutation) SetCustomAgentKey(s string) {
  26417. m.custom_agent_key = &s
  26418. }
  26419. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  26420. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  26421. v := m.custom_agent_key
  26422. if v == nil {
  26423. return
  26424. }
  26425. return *v, true
  26426. }
  26427. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  26428. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26430. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  26431. if !m.op.Is(OpUpdateOne) {
  26432. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  26433. }
  26434. if m.id == nil || m.oldValue == nil {
  26435. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  26436. }
  26437. oldValue, err := m.oldValue(ctx)
  26438. if err != nil {
  26439. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  26440. }
  26441. return oldValue.CustomAgentKey, nil
  26442. }
  26443. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  26444. func (m *TokenMutation) ClearCustomAgentKey() {
  26445. m.custom_agent_key = nil
  26446. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  26447. }
  26448. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  26449. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  26450. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  26451. return ok
  26452. }
  26453. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  26454. func (m *TokenMutation) ResetCustomAgentKey() {
  26455. m.custom_agent_key = nil
  26456. delete(m.clearedFields, token.FieldCustomAgentKey)
  26457. }
  26458. // SetOpenaiBase sets the "openai_base" field.
  26459. func (m *TokenMutation) SetOpenaiBase(s string) {
  26460. m.openai_base = &s
  26461. }
  26462. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  26463. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  26464. v := m.openai_base
  26465. if v == nil {
  26466. return
  26467. }
  26468. return *v, true
  26469. }
  26470. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  26471. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26473. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  26474. if !m.op.Is(OpUpdateOne) {
  26475. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  26476. }
  26477. if m.id == nil || m.oldValue == nil {
  26478. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  26479. }
  26480. oldValue, err := m.oldValue(ctx)
  26481. if err != nil {
  26482. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  26483. }
  26484. return oldValue.OpenaiBase, nil
  26485. }
  26486. // ClearOpenaiBase clears the value of the "openai_base" field.
  26487. func (m *TokenMutation) ClearOpenaiBase() {
  26488. m.openai_base = nil
  26489. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  26490. }
  26491. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  26492. func (m *TokenMutation) OpenaiBaseCleared() bool {
  26493. _, ok := m.clearedFields[token.FieldOpenaiBase]
  26494. return ok
  26495. }
  26496. // ResetOpenaiBase resets all changes to the "openai_base" field.
  26497. func (m *TokenMutation) ResetOpenaiBase() {
  26498. m.openai_base = nil
  26499. delete(m.clearedFields, token.FieldOpenaiBase)
  26500. }
  26501. // SetOpenaiKey sets the "openai_key" field.
  26502. func (m *TokenMutation) SetOpenaiKey(s string) {
  26503. m.openai_key = &s
  26504. }
  26505. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  26506. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  26507. v := m.openai_key
  26508. if v == nil {
  26509. return
  26510. }
  26511. return *v, true
  26512. }
  26513. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  26514. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  26515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26516. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  26517. if !m.op.Is(OpUpdateOne) {
  26518. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  26519. }
  26520. if m.id == nil || m.oldValue == nil {
  26521. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  26522. }
  26523. oldValue, err := m.oldValue(ctx)
  26524. if err != nil {
  26525. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  26526. }
  26527. return oldValue.OpenaiKey, nil
  26528. }
  26529. // ClearOpenaiKey clears the value of the "openai_key" field.
  26530. func (m *TokenMutation) ClearOpenaiKey() {
  26531. m.openai_key = nil
  26532. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  26533. }
  26534. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  26535. func (m *TokenMutation) OpenaiKeyCleared() bool {
  26536. _, ok := m.clearedFields[token.FieldOpenaiKey]
  26537. return ok
  26538. }
  26539. // ResetOpenaiKey resets all changes to the "openai_key" field.
  26540. func (m *TokenMutation) ResetOpenaiKey() {
  26541. m.openai_key = nil
  26542. delete(m.clearedFields, token.FieldOpenaiKey)
  26543. }
  26544. // ClearAgent clears the "agent" edge to the Agent entity.
  26545. func (m *TokenMutation) ClearAgent() {
  26546. m.clearedagent = true
  26547. m.clearedFields[token.FieldAgentID] = struct{}{}
  26548. }
  26549. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  26550. func (m *TokenMutation) AgentCleared() bool {
  26551. return m.clearedagent
  26552. }
  26553. // AgentIDs returns the "agent" edge IDs in the mutation.
  26554. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26555. // AgentID instead. It exists only for internal usage by the builders.
  26556. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  26557. if id := m.agent; id != nil {
  26558. ids = append(ids, *id)
  26559. }
  26560. return
  26561. }
  26562. // ResetAgent resets all changes to the "agent" edge.
  26563. func (m *TokenMutation) ResetAgent() {
  26564. m.agent = nil
  26565. m.clearedagent = false
  26566. }
  26567. // Where appends a list predicates to the TokenMutation builder.
  26568. func (m *TokenMutation) Where(ps ...predicate.Token) {
  26569. m.predicates = append(m.predicates, ps...)
  26570. }
  26571. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  26572. // users can use type-assertion to append predicates that do not depend on any generated package.
  26573. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  26574. p := make([]predicate.Token, len(ps))
  26575. for i := range ps {
  26576. p[i] = ps[i]
  26577. }
  26578. m.Where(p...)
  26579. }
  26580. // Op returns the operation name.
  26581. func (m *TokenMutation) Op() Op {
  26582. return m.op
  26583. }
  26584. // SetOp allows setting the mutation operation.
  26585. func (m *TokenMutation) SetOp(op Op) {
  26586. m.op = op
  26587. }
  26588. // Type returns the node type of this mutation (Token).
  26589. func (m *TokenMutation) Type() string {
  26590. return m.typ
  26591. }
  26592. // Fields returns all fields that were changed during this mutation. Note that in
  26593. // order to get all numeric fields that were incremented/decremented, call
  26594. // AddedFields().
  26595. func (m *TokenMutation) Fields() []string {
  26596. fields := make([]string, 0, 12)
  26597. if m.created_at != nil {
  26598. fields = append(fields, token.FieldCreatedAt)
  26599. }
  26600. if m.updated_at != nil {
  26601. fields = append(fields, token.FieldUpdatedAt)
  26602. }
  26603. if m.deleted_at != nil {
  26604. fields = append(fields, token.FieldDeletedAt)
  26605. }
  26606. if m.expire_at != nil {
  26607. fields = append(fields, token.FieldExpireAt)
  26608. }
  26609. if m.token != nil {
  26610. fields = append(fields, token.FieldToken)
  26611. }
  26612. if m.mac != nil {
  26613. fields = append(fields, token.FieldMAC)
  26614. }
  26615. if m.organization_id != nil {
  26616. fields = append(fields, token.FieldOrganizationID)
  26617. }
  26618. if m.agent != nil {
  26619. fields = append(fields, token.FieldAgentID)
  26620. }
  26621. if m.custom_agent_base != nil {
  26622. fields = append(fields, token.FieldCustomAgentBase)
  26623. }
  26624. if m.custom_agent_key != nil {
  26625. fields = append(fields, token.FieldCustomAgentKey)
  26626. }
  26627. if m.openai_base != nil {
  26628. fields = append(fields, token.FieldOpenaiBase)
  26629. }
  26630. if m.openai_key != nil {
  26631. fields = append(fields, token.FieldOpenaiKey)
  26632. }
  26633. return fields
  26634. }
  26635. // Field returns the value of a field with the given name. The second boolean
  26636. // return value indicates that this field was not set, or was not defined in the
  26637. // schema.
  26638. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  26639. switch name {
  26640. case token.FieldCreatedAt:
  26641. return m.CreatedAt()
  26642. case token.FieldUpdatedAt:
  26643. return m.UpdatedAt()
  26644. case token.FieldDeletedAt:
  26645. return m.DeletedAt()
  26646. case token.FieldExpireAt:
  26647. return m.ExpireAt()
  26648. case token.FieldToken:
  26649. return m.Token()
  26650. case token.FieldMAC:
  26651. return m.MAC()
  26652. case token.FieldOrganizationID:
  26653. return m.OrganizationID()
  26654. case token.FieldAgentID:
  26655. return m.AgentID()
  26656. case token.FieldCustomAgentBase:
  26657. return m.CustomAgentBase()
  26658. case token.FieldCustomAgentKey:
  26659. return m.CustomAgentKey()
  26660. case token.FieldOpenaiBase:
  26661. return m.OpenaiBase()
  26662. case token.FieldOpenaiKey:
  26663. return m.OpenaiKey()
  26664. }
  26665. return nil, false
  26666. }
  26667. // OldField returns the old value of the field from the database. An error is
  26668. // returned if the mutation operation is not UpdateOne, or the query to the
  26669. // database failed.
  26670. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26671. switch name {
  26672. case token.FieldCreatedAt:
  26673. return m.OldCreatedAt(ctx)
  26674. case token.FieldUpdatedAt:
  26675. return m.OldUpdatedAt(ctx)
  26676. case token.FieldDeletedAt:
  26677. return m.OldDeletedAt(ctx)
  26678. case token.FieldExpireAt:
  26679. return m.OldExpireAt(ctx)
  26680. case token.FieldToken:
  26681. return m.OldToken(ctx)
  26682. case token.FieldMAC:
  26683. return m.OldMAC(ctx)
  26684. case token.FieldOrganizationID:
  26685. return m.OldOrganizationID(ctx)
  26686. case token.FieldAgentID:
  26687. return m.OldAgentID(ctx)
  26688. case token.FieldCustomAgentBase:
  26689. return m.OldCustomAgentBase(ctx)
  26690. case token.FieldCustomAgentKey:
  26691. return m.OldCustomAgentKey(ctx)
  26692. case token.FieldOpenaiBase:
  26693. return m.OldOpenaiBase(ctx)
  26694. case token.FieldOpenaiKey:
  26695. return m.OldOpenaiKey(ctx)
  26696. }
  26697. return nil, fmt.Errorf("unknown Token field %s", name)
  26698. }
  26699. // SetField sets the value of a field with the given name. It returns an error if
  26700. // the field is not defined in the schema, or if the type mismatched the field
  26701. // type.
  26702. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  26703. switch name {
  26704. case token.FieldCreatedAt:
  26705. v, ok := value.(time.Time)
  26706. if !ok {
  26707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26708. }
  26709. m.SetCreatedAt(v)
  26710. return nil
  26711. case token.FieldUpdatedAt:
  26712. v, ok := value.(time.Time)
  26713. if !ok {
  26714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26715. }
  26716. m.SetUpdatedAt(v)
  26717. return nil
  26718. case token.FieldDeletedAt:
  26719. v, ok := value.(time.Time)
  26720. if !ok {
  26721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26722. }
  26723. m.SetDeletedAt(v)
  26724. return nil
  26725. case token.FieldExpireAt:
  26726. v, ok := value.(time.Time)
  26727. if !ok {
  26728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26729. }
  26730. m.SetExpireAt(v)
  26731. return nil
  26732. case token.FieldToken:
  26733. v, ok := value.(string)
  26734. if !ok {
  26735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26736. }
  26737. m.SetToken(v)
  26738. return nil
  26739. case token.FieldMAC:
  26740. v, ok := value.(string)
  26741. if !ok {
  26742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26743. }
  26744. m.SetMAC(v)
  26745. return nil
  26746. case token.FieldOrganizationID:
  26747. v, ok := value.(uint64)
  26748. if !ok {
  26749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26750. }
  26751. m.SetOrganizationID(v)
  26752. return nil
  26753. case token.FieldAgentID:
  26754. v, ok := value.(uint64)
  26755. if !ok {
  26756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26757. }
  26758. m.SetAgentID(v)
  26759. return nil
  26760. case token.FieldCustomAgentBase:
  26761. v, ok := value.(string)
  26762. if !ok {
  26763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26764. }
  26765. m.SetCustomAgentBase(v)
  26766. return nil
  26767. case token.FieldCustomAgentKey:
  26768. v, ok := value.(string)
  26769. if !ok {
  26770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26771. }
  26772. m.SetCustomAgentKey(v)
  26773. return nil
  26774. case token.FieldOpenaiBase:
  26775. v, ok := value.(string)
  26776. if !ok {
  26777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26778. }
  26779. m.SetOpenaiBase(v)
  26780. return nil
  26781. case token.FieldOpenaiKey:
  26782. v, ok := value.(string)
  26783. if !ok {
  26784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26785. }
  26786. m.SetOpenaiKey(v)
  26787. return nil
  26788. }
  26789. return fmt.Errorf("unknown Token field %s", name)
  26790. }
  26791. // AddedFields returns all numeric fields that were incremented/decremented during
  26792. // this mutation.
  26793. func (m *TokenMutation) AddedFields() []string {
  26794. var fields []string
  26795. if m.addorganization_id != nil {
  26796. fields = append(fields, token.FieldOrganizationID)
  26797. }
  26798. return fields
  26799. }
  26800. // AddedField returns the numeric value that was incremented/decremented on a field
  26801. // with the given name. The second boolean return value indicates that this field
  26802. // was not set, or was not defined in the schema.
  26803. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  26804. switch name {
  26805. case token.FieldOrganizationID:
  26806. return m.AddedOrganizationID()
  26807. }
  26808. return nil, false
  26809. }
  26810. // AddField adds the value to the field with the given name. It returns an error if
  26811. // the field is not defined in the schema, or if the type mismatched the field
  26812. // type.
  26813. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  26814. switch name {
  26815. case token.FieldOrganizationID:
  26816. v, ok := value.(int64)
  26817. if !ok {
  26818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26819. }
  26820. m.AddOrganizationID(v)
  26821. return nil
  26822. }
  26823. return fmt.Errorf("unknown Token numeric field %s", name)
  26824. }
  26825. // ClearedFields returns all nullable fields that were cleared during this
  26826. // mutation.
  26827. func (m *TokenMutation) ClearedFields() []string {
  26828. var fields []string
  26829. if m.FieldCleared(token.FieldDeletedAt) {
  26830. fields = append(fields, token.FieldDeletedAt)
  26831. }
  26832. if m.FieldCleared(token.FieldExpireAt) {
  26833. fields = append(fields, token.FieldExpireAt)
  26834. }
  26835. if m.FieldCleared(token.FieldToken) {
  26836. fields = append(fields, token.FieldToken)
  26837. }
  26838. if m.FieldCleared(token.FieldMAC) {
  26839. fields = append(fields, token.FieldMAC)
  26840. }
  26841. if m.FieldCleared(token.FieldCustomAgentBase) {
  26842. fields = append(fields, token.FieldCustomAgentBase)
  26843. }
  26844. if m.FieldCleared(token.FieldCustomAgentKey) {
  26845. fields = append(fields, token.FieldCustomAgentKey)
  26846. }
  26847. if m.FieldCleared(token.FieldOpenaiBase) {
  26848. fields = append(fields, token.FieldOpenaiBase)
  26849. }
  26850. if m.FieldCleared(token.FieldOpenaiKey) {
  26851. fields = append(fields, token.FieldOpenaiKey)
  26852. }
  26853. return fields
  26854. }
  26855. // FieldCleared returns a boolean indicating if a field with the given name was
  26856. // cleared in this mutation.
  26857. func (m *TokenMutation) FieldCleared(name string) bool {
  26858. _, ok := m.clearedFields[name]
  26859. return ok
  26860. }
  26861. // ClearField clears the value of the field with the given name. It returns an
  26862. // error if the field is not defined in the schema.
  26863. func (m *TokenMutation) ClearField(name string) error {
  26864. switch name {
  26865. case token.FieldDeletedAt:
  26866. m.ClearDeletedAt()
  26867. return nil
  26868. case token.FieldExpireAt:
  26869. m.ClearExpireAt()
  26870. return nil
  26871. case token.FieldToken:
  26872. m.ClearToken()
  26873. return nil
  26874. case token.FieldMAC:
  26875. m.ClearMAC()
  26876. return nil
  26877. case token.FieldCustomAgentBase:
  26878. m.ClearCustomAgentBase()
  26879. return nil
  26880. case token.FieldCustomAgentKey:
  26881. m.ClearCustomAgentKey()
  26882. return nil
  26883. case token.FieldOpenaiBase:
  26884. m.ClearOpenaiBase()
  26885. return nil
  26886. case token.FieldOpenaiKey:
  26887. m.ClearOpenaiKey()
  26888. return nil
  26889. }
  26890. return fmt.Errorf("unknown Token nullable field %s", name)
  26891. }
  26892. // ResetField resets all changes in the mutation for the field with the given name.
  26893. // It returns an error if the field is not defined in the schema.
  26894. func (m *TokenMutation) ResetField(name string) error {
  26895. switch name {
  26896. case token.FieldCreatedAt:
  26897. m.ResetCreatedAt()
  26898. return nil
  26899. case token.FieldUpdatedAt:
  26900. m.ResetUpdatedAt()
  26901. return nil
  26902. case token.FieldDeletedAt:
  26903. m.ResetDeletedAt()
  26904. return nil
  26905. case token.FieldExpireAt:
  26906. m.ResetExpireAt()
  26907. return nil
  26908. case token.FieldToken:
  26909. m.ResetToken()
  26910. return nil
  26911. case token.FieldMAC:
  26912. m.ResetMAC()
  26913. return nil
  26914. case token.FieldOrganizationID:
  26915. m.ResetOrganizationID()
  26916. return nil
  26917. case token.FieldAgentID:
  26918. m.ResetAgentID()
  26919. return nil
  26920. case token.FieldCustomAgentBase:
  26921. m.ResetCustomAgentBase()
  26922. return nil
  26923. case token.FieldCustomAgentKey:
  26924. m.ResetCustomAgentKey()
  26925. return nil
  26926. case token.FieldOpenaiBase:
  26927. m.ResetOpenaiBase()
  26928. return nil
  26929. case token.FieldOpenaiKey:
  26930. m.ResetOpenaiKey()
  26931. return nil
  26932. }
  26933. return fmt.Errorf("unknown Token field %s", name)
  26934. }
  26935. // AddedEdges returns all edge names that were set/added in this mutation.
  26936. func (m *TokenMutation) AddedEdges() []string {
  26937. edges := make([]string, 0, 1)
  26938. if m.agent != nil {
  26939. edges = append(edges, token.EdgeAgent)
  26940. }
  26941. return edges
  26942. }
  26943. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26944. // name in this mutation.
  26945. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  26946. switch name {
  26947. case token.EdgeAgent:
  26948. if id := m.agent; id != nil {
  26949. return []ent.Value{*id}
  26950. }
  26951. }
  26952. return nil
  26953. }
  26954. // RemovedEdges returns all edge names that were removed in this mutation.
  26955. func (m *TokenMutation) RemovedEdges() []string {
  26956. edges := make([]string, 0, 1)
  26957. return edges
  26958. }
  26959. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26960. // the given name in this mutation.
  26961. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  26962. return nil
  26963. }
  26964. // ClearedEdges returns all edge names that were cleared in this mutation.
  26965. func (m *TokenMutation) ClearedEdges() []string {
  26966. edges := make([]string, 0, 1)
  26967. if m.clearedagent {
  26968. edges = append(edges, token.EdgeAgent)
  26969. }
  26970. return edges
  26971. }
  26972. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26973. // was cleared in this mutation.
  26974. func (m *TokenMutation) EdgeCleared(name string) bool {
  26975. switch name {
  26976. case token.EdgeAgent:
  26977. return m.clearedagent
  26978. }
  26979. return false
  26980. }
  26981. // ClearEdge clears the value of the edge with the given name. It returns an error
  26982. // if that edge is not defined in the schema.
  26983. func (m *TokenMutation) ClearEdge(name string) error {
  26984. switch name {
  26985. case token.EdgeAgent:
  26986. m.ClearAgent()
  26987. return nil
  26988. }
  26989. return fmt.Errorf("unknown Token unique edge %s", name)
  26990. }
  26991. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26992. // It returns an error if the edge is not defined in the schema.
  26993. func (m *TokenMutation) ResetEdge(name string) error {
  26994. switch name {
  26995. case token.EdgeAgent:
  26996. m.ResetAgent()
  26997. return nil
  26998. }
  26999. return fmt.Errorf("unknown Token edge %s", name)
  27000. }
  27001. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  27002. type TutorialMutation struct {
  27003. config
  27004. op Op
  27005. typ string
  27006. id *uint64
  27007. created_at *time.Time
  27008. updated_at *time.Time
  27009. deleted_at *time.Time
  27010. index *int
  27011. addindex *int
  27012. title *string
  27013. content *string
  27014. organization_id *uint64
  27015. addorganization_id *int64
  27016. clearedFields map[string]struct{}
  27017. employee *uint64
  27018. clearedemployee bool
  27019. done bool
  27020. oldValue func(context.Context) (*Tutorial, error)
  27021. predicates []predicate.Tutorial
  27022. }
  27023. var _ ent.Mutation = (*TutorialMutation)(nil)
  27024. // tutorialOption allows management of the mutation configuration using functional options.
  27025. type tutorialOption func(*TutorialMutation)
  27026. // newTutorialMutation creates new mutation for the Tutorial entity.
  27027. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  27028. m := &TutorialMutation{
  27029. config: c,
  27030. op: op,
  27031. typ: TypeTutorial,
  27032. clearedFields: make(map[string]struct{}),
  27033. }
  27034. for _, opt := range opts {
  27035. opt(m)
  27036. }
  27037. return m
  27038. }
  27039. // withTutorialID sets the ID field of the mutation.
  27040. func withTutorialID(id uint64) tutorialOption {
  27041. return func(m *TutorialMutation) {
  27042. var (
  27043. err error
  27044. once sync.Once
  27045. value *Tutorial
  27046. )
  27047. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  27048. once.Do(func() {
  27049. if m.done {
  27050. err = errors.New("querying old values post mutation is not allowed")
  27051. } else {
  27052. value, err = m.Client().Tutorial.Get(ctx, id)
  27053. }
  27054. })
  27055. return value, err
  27056. }
  27057. m.id = &id
  27058. }
  27059. }
  27060. // withTutorial sets the old Tutorial of the mutation.
  27061. func withTutorial(node *Tutorial) tutorialOption {
  27062. return func(m *TutorialMutation) {
  27063. m.oldValue = func(context.Context) (*Tutorial, error) {
  27064. return node, nil
  27065. }
  27066. m.id = &node.ID
  27067. }
  27068. }
  27069. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27070. // executed in a transaction (ent.Tx), a transactional client is returned.
  27071. func (m TutorialMutation) Client() *Client {
  27072. client := &Client{config: m.config}
  27073. client.init()
  27074. return client
  27075. }
  27076. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27077. // it returns an error otherwise.
  27078. func (m TutorialMutation) Tx() (*Tx, error) {
  27079. if _, ok := m.driver.(*txDriver); !ok {
  27080. return nil, errors.New("ent: mutation is not running in a transaction")
  27081. }
  27082. tx := &Tx{config: m.config}
  27083. tx.init()
  27084. return tx, nil
  27085. }
  27086. // SetID sets the value of the id field. Note that this
  27087. // operation is only accepted on creation of Tutorial entities.
  27088. func (m *TutorialMutation) SetID(id uint64) {
  27089. m.id = &id
  27090. }
  27091. // ID returns the ID value in the mutation. Note that the ID is only available
  27092. // if it was provided to the builder or after it was returned from the database.
  27093. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  27094. if m.id == nil {
  27095. return
  27096. }
  27097. return *m.id, true
  27098. }
  27099. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27100. // That means, if the mutation is applied within a transaction with an isolation level such
  27101. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27102. // or updated by the mutation.
  27103. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  27104. switch {
  27105. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27106. id, exists := m.ID()
  27107. if exists {
  27108. return []uint64{id}, nil
  27109. }
  27110. fallthrough
  27111. case m.op.Is(OpUpdate | OpDelete):
  27112. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  27113. default:
  27114. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27115. }
  27116. }
  27117. // SetCreatedAt sets the "created_at" field.
  27118. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  27119. m.created_at = &t
  27120. }
  27121. // CreatedAt returns the value of the "created_at" field in the mutation.
  27122. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  27123. v := m.created_at
  27124. if v == nil {
  27125. return
  27126. }
  27127. return *v, true
  27128. }
  27129. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  27130. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27132. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27133. if !m.op.Is(OpUpdateOne) {
  27134. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27135. }
  27136. if m.id == nil || m.oldValue == nil {
  27137. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27138. }
  27139. oldValue, err := m.oldValue(ctx)
  27140. if err != nil {
  27141. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27142. }
  27143. return oldValue.CreatedAt, nil
  27144. }
  27145. // ResetCreatedAt resets all changes to the "created_at" field.
  27146. func (m *TutorialMutation) ResetCreatedAt() {
  27147. m.created_at = nil
  27148. }
  27149. // SetUpdatedAt sets the "updated_at" field.
  27150. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  27151. m.updated_at = &t
  27152. }
  27153. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27154. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  27155. v := m.updated_at
  27156. if v == nil {
  27157. return
  27158. }
  27159. return *v, true
  27160. }
  27161. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  27162. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27164. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27165. if !m.op.Is(OpUpdateOne) {
  27166. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27167. }
  27168. if m.id == nil || m.oldValue == nil {
  27169. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27170. }
  27171. oldValue, err := m.oldValue(ctx)
  27172. if err != nil {
  27173. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27174. }
  27175. return oldValue.UpdatedAt, nil
  27176. }
  27177. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27178. func (m *TutorialMutation) ResetUpdatedAt() {
  27179. m.updated_at = nil
  27180. }
  27181. // SetDeletedAt sets the "deleted_at" field.
  27182. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  27183. m.deleted_at = &t
  27184. }
  27185. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27186. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  27187. v := m.deleted_at
  27188. if v == nil {
  27189. return
  27190. }
  27191. return *v, true
  27192. }
  27193. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  27194. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27196. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27197. if !m.op.Is(OpUpdateOne) {
  27198. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27199. }
  27200. if m.id == nil || m.oldValue == nil {
  27201. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27202. }
  27203. oldValue, err := m.oldValue(ctx)
  27204. if err != nil {
  27205. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27206. }
  27207. return oldValue.DeletedAt, nil
  27208. }
  27209. // ClearDeletedAt clears the value of the "deleted_at" field.
  27210. func (m *TutorialMutation) ClearDeletedAt() {
  27211. m.deleted_at = nil
  27212. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  27213. }
  27214. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27215. func (m *TutorialMutation) DeletedAtCleared() bool {
  27216. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  27217. return ok
  27218. }
  27219. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27220. func (m *TutorialMutation) ResetDeletedAt() {
  27221. m.deleted_at = nil
  27222. delete(m.clearedFields, tutorial.FieldDeletedAt)
  27223. }
  27224. // SetEmployeeID sets the "employee_id" field.
  27225. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  27226. m.employee = &u
  27227. }
  27228. // EmployeeID returns the value of the "employee_id" field in the mutation.
  27229. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  27230. v := m.employee
  27231. if v == nil {
  27232. return
  27233. }
  27234. return *v, true
  27235. }
  27236. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  27237. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27239. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  27240. if !m.op.Is(OpUpdateOne) {
  27241. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  27242. }
  27243. if m.id == nil || m.oldValue == nil {
  27244. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  27245. }
  27246. oldValue, err := m.oldValue(ctx)
  27247. if err != nil {
  27248. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  27249. }
  27250. return oldValue.EmployeeID, nil
  27251. }
  27252. // ResetEmployeeID resets all changes to the "employee_id" field.
  27253. func (m *TutorialMutation) ResetEmployeeID() {
  27254. m.employee = nil
  27255. }
  27256. // SetIndex sets the "index" field.
  27257. func (m *TutorialMutation) SetIndex(i int) {
  27258. m.index = &i
  27259. m.addindex = nil
  27260. }
  27261. // Index returns the value of the "index" field in the mutation.
  27262. func (m *TutorialMutation) Index() (r int, exists bool) {
  27263. v := m.index
  27264. if v == nil {
  27265. return
  27266. }
  27267. return *v, true
  27268. }
  27269. // OldIndex returns the old "index" field's value of the Tutorial entity.
  27270. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27272. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  27273. if !m.op.Is(OpUpdateOne) {
  27274. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  27275. }
  27276. if m.id == nil || m.oldValue == nil {
  27277. return v, errors.New("OldIndex requires an ID field in the mutation")
  27278. }
  27279. oldValue, err := m.oldValue(ctx)
  27280. if err != nil {
  27281. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  27282. }
  27283. return oldValue.Index, nil
  27284. }
  27285. // AddIndex adds i to the "index" field.
  27286. func (m *TutorialMutation) AddIndex(i int) {
  27287. if m.addindex != nil {
  27288. *m.addindex += i
  27289. } else {
  27290. m.addindex = &i
  27291. }
  27292. }
  27293. // AddedIndex returns the value that was added to the "index" field in this mutation.
  27294. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  27295. v := m.addindex
  27296. if v == nil {
  27297. return
  27298. }
  27299. return *v, true
  27300. }
  27301. // ResetIndex resets all changes to the "index" field.
  27302. func (m *TutorialMutation) ResetIndex() {
  27303. m.index = nil
  27304. m.addindex = nil
  27305. }
  27306. // SetTitle sets the "title" field.
  27307. func (m *TutorialMutation) SetTitle(s string) {
  27308. m.title = &s
  27309. }
  27310. // Title returns the value of the "title" field in the mutation.
  27311. func (m *TutorialMutation) Title() (r string, exists bool) {
  27312. v := m.title
  27313. if v == nil {
  27314. return
  27315. }
  27316. return *v, true
  27317. }
  27318. // OldTitle returns the old "title" field's value of the Tutorial entity.
  27319. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27321. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  27322. if !m.op.Is(OpUpdateOne) {
  27323. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  27324. }
  27325. if m.id == nil || m.oldValue == nil {
  27326. return v, errors.New("OldTitle requires an ID field in the mutation")
  27327. }
  27328. oldValue, err := m.oldValue(ctx)
  27329. if err != nil {
  27330. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  27331. }
  27332. return oldValue.Title, nil
  27333. }
  27334. // ResetTitle resets all changes to the "title" field.
  27335. func (m *TutorialMutation) ResetTitle() {
  27336. m.title = nil
  27337. }
  27338. // SetContent sets the "content" field.
  27339. func (m *TutorialMutation) SetContent(s string) {
  27340. m.content = &s
  27341. }
  27342. // Content returns the value of the "content" field in the mutation.
  27343. func (m *TutorialMutation) Content() (r string, exists bool) {
  27344. v := m.content
  27345. if v == nil {
  27346. return
  27347. }
  27348. return *v, true
  27349. }
  27350. // OldContent returns the old "content" field's value of the Tutorial entity.
  27351. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27353. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  27354. if !m.op.Is(OpUpdateOne) {
  27355. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  27356. }
  27357. if m.id == nil || m.oldValue == nil {
  27358. return v, errors.New("OldContent requires an ID field in the mutation")
  27359. }
  27360. oldValue, err := m.oldValue(ctx)
  27361. if err != nil {
  27362. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  27363. }
  27364. return oldValue.Content, nil
  27365. }
  27366. // ResetContent resets all changes to the "content" field.
  27367. func (m *TutorialMutation) ResetContent() {
  27368. m.content = nil
  27369. }
  27370. // SetOrganizationID sets the "organization_id" field.
  27371. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  27372. m.organization_id = &u
  27373. m.addorganization_id = nil
  27374. }
  27375. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27376. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  27377. v := m.organization_id
  27378. if v == nil {
  27379. return
  27380. }
  27381. return *v, true
  27382. }
  27383. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  27384. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  27385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27386. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27387. if !m.op.Is(OpUpdateOne) {
  27388. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27389. }
  27390. if m.id == nil || m.oldValue == nil {
  27391. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27392. }
  27393. oldValue, err := m.oldValue(ctx)
  27394. if err != nil {
  27395. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27396. }
  27397. return oldValue.OrganizationID, nil
  27398. }
  27399. // AddOrganizationID adds u to the "organization_id" field.
  27400. func (m *TutorialMutation) AddOrganizationID(u int64) {
  27401. if m.addorganization_id != nil {
  27402. *m.addorganization_id += u
  27403. } else {
  27404. m.addorganization_id = &u
  27405. }
  27406. }
  27407. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27408. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  27409. v := m.addorganization_id
  27410. if v == nil {
  27411. return
  27412. }
  27413. return *v, true
  27414. }
  27415. // ResetOrganizationID resets all changes to the "organization_id" field.
  27416. func (m *TutorialMutation) ResetOrganizationID() {
  27417. m.organization_id = nil
  27418. m.addorganization_id = nil
  27419. }
  27420. // ClearEmployee clears the "employee" edge to the Employee entity.
  27421. func (m *TutorialMutation) ClearEmployee() {
  27422. m.clearedemployee = true
  27423. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  27424. }
  27425. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  27426. func (m *TutorialMutation) EmployeeCleared() bool {
  27427. return m.clearedemployee
  27428. }
  27429. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  27430. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27431. // EmployeeID instead. It exists only for internal usage by the builders.
  27432. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  27433. if id := m.employee; id != nil {
  27434. ids = append(ids, *id)
  27435. }
  27436. return
  27437. }
  27438. // ResetEmployee resets all changes to the "employee" edge.
  27439. func (m *TutorialMutation) ResetEmployee() {
  27440. m.employee = nil
  27441. m.clearedemployee = false
  27442. }
  27443. // Where appends a list predicates to the TutorialMutation builder.
  27444. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  27445. m.predicates = append(m.predicates, ps...)
  27446. }
  27447. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  27448. // users can use type-assertion to append predicates that do not depend on any generated package.
  27449. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  27450. p := make([]predicate.Tutorial, len(ps))
  27451. for i := range ps {
  27452. p[i] = ps[i]
  27453. }
  27454. m.Where(p...)
  27455. }
  27456. // Op returns the operation name.
  27457. func (m *TutorialMutation) Op() Op {
  27458. return m.op
  27459. }
  27460. // SetOp allows setting the mutation operation.
  27461. func (m *TutorialMutation) SetOp(op Op) {
  27462. m.op = op
  27463. }
  27464. // Type returns the node type of this mutation (Tutorial).
  27465. func (m *TutorialMutation) Type() string {
  27466. return m.typ
  27467. }
  27468. // Fields returns all fields that were changed during this mutation. Note that in
  27469. // order to get all numeric fields that were incremented/decremented, call
  27470. // AddedFields().
  27471. func (m *TutorialMutation) Fields() []string {
  27472. fields := make([]string, 0, 8)
  27473. if m.created_at != nil {
  27474. fields = append(fields, tutorial.FieldCreatedAt)
  27475. }
  27476. if m.updated_at != nil {
  27477. fields = append(fields, tutorial.FieldUpdatedAt)
  27478. }
  27479. if m.deleted_at != nil {
  27480. fields = append(fields, tutorial.FieldDeletedAt)
  27481. }
  27482. if m.employee != nil {
  27483. fields = append(fields, tutorial.FieldEmployeeID)
  27484. }
  27485. if m.index != nil {
  27486. fields = append(fields, tutorial.FieldIndex)
  27487. }
  27488. if m.title != nil {
  27489. fields = append(fields, tutorial.FieldTitle)
  27490. }
  27491. if m.content != nil {
  27492. fields = append(fields, tutorial.FieldContent)
  27493. }
  27494. if m.organization_id != nil {
  27495. fields = append(fields, tutorial.FieldOrganizationID)
  27496. }
  27497. return fields
  27498. }
  27499. // Field returns the value of a field with the given name. The second boolean
  27500. // return value indicates that this field was not set, or was not defined in the
  27501. // schema.
  27502. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  27503. switch name {
  27504. case tutorial.FieldCreatedAt:
  27505. return m.CreatedAt()
  27506. case tutorial.FieldUpdatedAt:
  27507. return m.UpdatedAt()
  27508. case tutorial.FieldDeletedAt:
  27509. return m.DeletedAt()
  27510. case tutorial.FieldEmployeeID:
  27511. return m.EmployeeID()
  27512. case tutorial.FieldIndex:
  27513. return m.Index()
  27514. case tutorial.FieldTitle:
  27515. return m.Title()
  27516. case tutorial.FieldContent:
  27517. return m.Content()
  27518. case tutorial.FieldOrganizationID:
  27519. return m.OrganizationID()
  27520. }
  27521. return nil, false
  27522. }
  27523. // OldField returns the old value of the field from the database. An error is
  27524. // returned if the mutation operation is not UpdateOne, or the query to the
  27525. // database failed.
  27526. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27527. switch name {
  27528. case tutorial.FieldCreatedAt:
  27529. return m.OldCreatedAt(ctx)
  27530. case tutorial.FieldUpdatedAt:
  27531. return m.OldUpdatedAt(ctx)
  27532. case tutorial.FieldDeletedAt:
  27533. return m.OldDeletedAt(ctx)
  27534. case tutorial.FieldEmployeeID:
  27535. return m.OldEmployeeID(ctx)
  27536. case tutorial.FieldIndex:
  27537. return m.OldIndex(ctx)
  27538. case tutorial.FieldTitle:
  27539. return m.OldTitle(ctx)
  27540. case tutorial.FieldContent:
  27541. return m.OldContent(ctx)
  27542. case tutorial.FieldOrganizationID:
  27543. return m.OldOrganizationID(ctx)
  27544. }
  27545. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  27546. }
  27547. // SetField sets the value of a field with the given name. It returns an error if
  27548. // the field is not defined in the schema, or if the type mismatched the field
  27549. // type.
  27550. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  27551. switch name {
  27552. case tutorial.FieldCreatedAt:
  27553. v, ok := value.(time.Time)
  27554. if !ok {
  27555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27556. }
  27557. m.SetCreatedAt(v)
  27558. return nil
  27559. case tutorial.FieldUpdatedAt:
  27560. v, ok := value.(time.Time)
  27561. if !ok {
  27562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27563. }
  27564. m.SetUpdatedAt(v)
  27565. return nil
  27566. case tutorial.FieldDeletedAt:
  27567. v, ok := value.(time.Time)
  27568. if !ok {
  27569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27570. }
  27571. m.SetDeletedAt(v)
  27572. return nil
  27573. case tutorial.FieldEmployeeID:
  27574. v, ok := value.(uint64)
  27575. if !ok {
  27576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27577. }
  27578. m.SetEmployeeID(v)
  27579. return nil
  27580. case tutorial.FieldIndex:
  27581. v, ok := value.(int)
  27582. if !ok {
  27583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27584. }
  27585. m.SetIndex(v)
  27586. return nil
  27587. case tutorial.FieldTitle:
  27588. v, ok := value.(string)
  27589. if !ok {
  27590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27591. }
  27592. m.SetTitle(v)
  27593. return nil
  27594. case tutorial.FieldContent:
  27595. v, ok := value.(string)
  27596. if !ok {
  27597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27598. }
  27599. m.SetContent(v)
  27600. return nil
  27601. case tutorial.FieldOrganizationID:
  27602. v, ok := value.(uint64)
  27603. if !ok {
  27604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27605. }
  27606. m.SetOrganizationID(v)
  27607. return nil
  27608. }
  27609. return fmt.Errorf("unknown Tutorial field %s", name)
  27610. }
  27611. // AddedFields returns all numeric fields that were incremented/decremented during
  27612. // this mutation.
  27613. func (m *TutorialMutation) AddedFields() []string {
  27614. var fields []string
  27615. if m.addindex != nil {
  27616. fields = append(fields, tutorial.FieldIndex)
  27617. }
  27618. if m.addorganization_id != nil {
  27619. fields = append(fields, tutorial.FieldOrganizationID)
  27620. }
  27621. return fields
  27622. }
  27623. // AddedField returns the numeric value that was incremented/decremented on a field
  27624. // with the given name. The second boolean return value indicates that this field
  27625. // was not set, or was not defined in the schema.
  27626. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  27627. switch name {
  27628. case tutorial.FieldIndex:
  27629. return m.AddedIndex()
  27630. case tutorial.FieldOrganizationID:
  27631. return m.AddedOrganizationID()
  27632. }
  27633. return nil, false
  27634. }
  27635. // AddField adds the value to the field with the given name. It returns an error if
  27636. // the field is not defined in the schema, or if the type mismatched the field
  27637. // type.
  27638. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  27639. switch name {
  27640. case tutorial.FieldIndex:
  27641. v, ok := value.(int)
  27642. if !ok {
  27643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27644. }
  27645. m.AddIndex(v)
  27646. return nil
  27647. case tutorial.FieldOrganizationID:
  27648. v, ok := value.(int64)
  27649. if !ok {
  27650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27651. }
  27652. m.AddOrganizationID(v)
  27653. return nil
  27654. }
  27655. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  27656. }
  27657. // ClearedFields returns all nullable fields that were cleared during this
  27658. // mutation.
  27659. func (m *TutorialMutation) ClearedFields() []string {
  27660. var fields []string
  27661. if m.FieldCleared(tutorial.FieldDeletedAt) {
  27662. fields = append(fields, tutorial.FieldDeletedAt)
  27663. }
  27664. return fields
  27665. }
  27666. // FieldCleared returns a boolean indicating if a field with the given name was
  27667. // cleared in this mutation.
  27668. func (m *TutorialMutation) FieldCleared(name string) bool {
  27669. _, ok := m.clearedFields[name]
  27670. return ok
  27671. }
  27672. // ClearField clears the value of the field with the given name. It returns an
  27673. // error if the field is not defined in the schema.
  27674. func (m *TutorialMutation) ClearField(name string) error {
  27675. switch name {
  27676. case tutorial.FieldDeletedAt:
  27677. m.ClearDeletedAt()
  27678. return nil
  27679. }
  27680. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  27681. }
  27682. // ResetField resets all changes in the mutation for the field with the given name.
  27683. // It returns an error if the field is not defined in the schema.
  27684. func (m *TutorialMutation) ResetField(name string) error {
  27685. switch name {
  27686. case tutorial.FieldCreatedAt:
  27687. m.ResetCreatedAt()
  27688. return nil
  27689. case tutorial.FieldUpdatedAt:
  27690. m.ResetUpdatedAt()
  27691. return nil
  27692. case tutorial.FieldDeletedAt:
  27693. m.ResetDeletedAt()
  27694. return nil
  27695. case tutorial.FieldEmployeeID:
  27696. m.ResetEmployeeID()
  27697. return nil
  27698. case tutorial.FieldIndex:
  27699. m.ResetIndex()
  27700. return nil
  27701. case tutorial.FieldTitle:
  27702. m.ResetTitle()
  27703. return nil
  27704. case tutorial.FieldContent:
  27705. m.ResetContent()
  27706. return nil
  27707. case tutorial.FieldOrganizationID:
  27708. m.ResetOrganizationID()
  27709. return nil
  27710. }
  27711. return fmt.Errorf("unknown Tutorial field %s", name)
  27712. }
  27713. // AddedEdges returns all edge names that were set/added in this mutation.
  27714. func (m *TutorialMutation) AddedEdges() []string {
  27715. edges := make([]string, 0, 1)
  27716. if m.employee != nil {
  27717. edges = append(edges, tutorial.EdgeEmployee)
  27718. }
  27719. return edges
  27720. }
  27721. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27722. // name in this mutation.
  27723. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  27724. switch name {
  27725. case tutorial.EdgeEmployee:
  27726. if id := m.employee; id != nil {
  27727. return []ent.Value{*id}
  27728. }
  27729. }
  27730. return nil
  27731. }
  27732. // RemovedEdges returns all edge names that were removed in this mutation.
  27733. func (m *TutorialMutation) RemovedEdges() []string {
  27734. edges := make([]string, 0, 1)
  27735. return edges
  27736. }
  27737. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27738. // the given name in this mutation.
  27739. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  27740. return nil
  27741. }
  27742. // ClearedEdges returns all edge names that were cleared in this mutation.
  27743. func (m *TutorialMutation) ClearedEdges() []string {
  27744. edges := make([]string, 0, 1)
  27745. if m.clearedemployee {
  27746. edges = append(edges, tutorial.EdgeEmployee)
  27747. }
  27748. return edges
  27749. }
  27750. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27751. // was cleared in this mutation.
  27752. func (m *TutorialMutation) EdgeCleared(name string) bool {
  27753. switch name {
  27754. case tutorial.EdgeEmployee:
  27755. return m.clearedemployee
  27756. }
  27757. return false
  27758. }
  27759. // ClearEdge clears the value of the edge with the given name. It returns an error
  27760. // if that edge is not defined in the schema.
  27761. func (m *TutorialMutation) ClearEdge(name string) error {
  27762. switch name {
  27763. case tutorial.EdgeEmployee:
  27764. m.ClearEmployee()
  27765. return nil
  27766. }
  27767. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  27768. }
  27769. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27770. // It returns an error if the edge is not defined in the schema.
  27771. func (m *TutorialMutation) ResetEdge(name string) error {
  27772. switch name {
  27773. case tutorial.EdgeEmployee:
  27774. m.ResetEmployee()
  27775. return nil
  27776. }
  27777. return fmt.Errorf("unknown Tutorial edge %s", name)
  27778. }
  27779. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  27780. type UsageDetailMutation struct {
  27781. config
  27782. op Op
  27783. typ string
  27784. id *uint64
  27785. created_at *time.Time
  27786. updated_at *time.Time
  27787. status *uint8
  27788. addstatus *int8
  27789. _type *int
  27790. add_type *int
  27791. bot_id *string
  27792. receiver_id *string
  27793. app *int
  27794. addapp *int
  27795. session_id *uint64
  27796. addsession_id *int64
  27797. request *string
  27798. response *string
  27799. original_data *custom_types.OriginalData
  27800. total_tokens *uint64
  27801. addtotal_tokens *int64
  27802. prompt_tokens *uint64
  27803. addprompt_tokens *int64
  27804. completion_tokens *uint64
  27805. addcompletion_tokens *int64
  27806. organization_id *uint64
  27807. addorganization_id *int64
  27808. clearedFields map[string]struct{}
  27809. done bool
  27810. oldValue func(context.Context) (*UsageDetail, error)
  27811. predicates []predicate.UsageDetail
  27812. }
  27813. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  27814. // usagedetailOption allows management of the mutation configuration using functional options.
  27815. type usagedetailOption func(*UsageDetailMutation)
  27816. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  27817. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  27818. m := &UsageDetailMutation{
  27819. config: c,
  27820. op: op,
  27821. typ: TypeUsageDetail,
  27822. clearedFields: make(map[string]struct{}),
  27823. }
  27824. for _, opt := range opts {
  27825. opt(m)
  27826. }
  27827. return m
  27828. }
  27829. // withUsageDetailID sets the ID field of the mutation.
  27830. func withUsageDetailID(id uint64) usagedetailOption {
  27831. return func(m *UsageDetailMutation) {
  27832. var (
  27833. err error
  27834. once sync.Once
  27835. value *UsageDetail
  27836. )
  27837. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  27838. once.Do(func() {
  27839. if m.done {
  27840. err = errors.New("querying old values post mutation is not allowed")
  27841. } else {
  27842. value, err = m.Client().UsageDetail.Get(ctx, id)
  27843. }
  27844. })
  27845. return value, err
  27846. }
  27847. m.id = &id
  27848. }
  27849. }
  27850. // withUsageDetail sets the old UsageDetail of the mutation.
  27851. func withUsageDetail(node *UsageDetail) usagedetailOption {
  27852. return func(m *UsageDetailMutation) {
  27853. m.oldValue = func(context.Context) (*UsageDetail, error) {
  27854. return node, nil
  27855. }
  27856. m.id = &node.ID
  27857. }
  27858. }
  27859. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27860. // executed in a transaction (ent.Tx), a transactional client is returned.
  27861. func (m UsageDetailMutation) Client() *Client {
  27862. client := &Client{config: m.config}
  27863. client.init()
  27864. return client
  27865. }
  27866. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27867. // it returns an error otherwise.
  27868. func (m UsageDetailMutation) Tx() (*Tx, error) {
  27869. if _, ok := m.driver.(*txDriver); !ok {
  27870. return nil, errors.New("ent: mutation is not running in a transaction")
  27871. }
  27872. tx := &Tx{config: m.config}
  27873. tx.init()
  27874. return tx, nil
  27875. }
  27876. // SetID sets the value of the id field. Note that this
  27877. // operation is only accepted on creation of UsageDetail entities.
  27878. func (m *UsageDetailMutation) SetID(id uint64) {
  27879. m.id = &id
  27880. }
  27881. // ID returns the ID value in the mutation. Note that the ID is only available
  27882. // if it was provided to the builder or after it was returned from the database.
  27883. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  27884. if m.id == nil {
  27885. return
  27886. }
  27887. return *m.id, true
  27888. }
  27889. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27890. // That means, if the mutation is applied within a transaction with an isolation level such
  27891. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27892. // or updated by the mutation.
  27893. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  27894. switch {
  27895. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27896. id, exists := m.ID()
  27897. if exists {
  27898. return []uint64{id}, nil
  27899. }
  27900. fallthrough
  27901. case m.op.Is(OpUpdate | OpDelete):
  27902. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  27903. default:
  27904. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27905. }
  27906. }
  27907. // SetCreatedAt sets the "created_at" field.
  27908. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  27909. m.created_at = &t
  27910. }
  27911. // CreatedAt returns the value of the "created_at" field in the mutation.
  27912. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  27913. v := m.created_at
  27914. if v == nil {
  27915. return
  27916. }
  27917. return *v, true
  27918. }
  27919. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  27920. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27922. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27923. if !m.op.Is(OpUpdateOne) {
  27924. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27925. }
  27926. if m.id == nil || m.oldValue == nil {
  27927. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27928. }
  27929. oldValue, err := m.oldValue(ctx)
  27930. if err != nil {
  27931. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27932. }
  27933. return oldValue.CreatedAt, nil
  27934. }
  27935. // ResetCreatedAt resets all changes to the "created_at" field.
  27936. func (m *UsageDetailMutation) ResetCreatedAt() {
  27937. m.created_at = nil
  27938. }
  27939. // SetUpdatedAt sets the "updated_at" field.
  27940. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  27941. m.updated_at = &t
  27942. }
  27943. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27944. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  27945. v := m.updated_at
  27946. if v == nil {
  27947. return
  27948. }
  27949. return *v, true
  27950. }
  27951. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  27952. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27954. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27955. if !m.op.Is(OpUpdateOne) {
  27956. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27957. }
  27958. if m.id == nil || m.oldValue == nil {
  27959. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27960. }
  27961. oldValue, err := m.oldValue(ctx)
  27962. if err != nil {
  27963. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27964. }
  27965. return oldValue.UpdatedAt, nil
  27966. }
  27967. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27968. func (m *UsageDetailMutation) ResetUpdatedAt() {
  27969. m.updated_at = nil
  27970. }
  27971. // SetStatus sets the "status" field.
  27972. func (m *UsageDetailMutation) SetStatus(u uint8) {
  27973. m.status = &u
  27974. m.addstatus = nil
  27975. }
  27976. // Status returns the value of the "status" field in the mutation.
  27977. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  27978. v := m.status
  27979. if v == nil {
  27980. return
  27981. }
  27982. return *v, true
  27983. }
  27984. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  27985. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27987. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27988. if !m.op.Is(OpUpdateOne) {
  27989. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27990. }
  27991. if m.id == nil || m.oldValue == nil {
  27992. return v, errors.New("OldStatus requires an ID field in the mutation")
  27993. }
  27994. oldValue, err := m.oldValue(ctx)
  27995. if err != nil {
  27996. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27997. }
  27998. return oldValue.Status, nil
  27999. }
  28000. // AddStatus adds u to the "status" field.
  28001. func (m *UsageDetailMutation) AddStatus(u int8) {
  28002. if m.addstatus != nil {
  28003. *m.addstatus += u
  28004. } else {
  28005. m.addstatus = &u
  28006. }
  28007. }
  28008. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28009. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  28010. v := m.addstatus
  28011. if v == nil {
  28012. return
  28013. }
  28014. return *v, true
  28015. }
  28016. // ClearStatus clears the value of the "status" field.
  28017. func (m *UsageDetailMutation) ClearStatus() {
  28018. m.status = nil
  28019. m.addstatus = nil
  28020. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  28021. }
  28022. // StatusCleared returns if the "status" field was cleared in this mutation.
  28023. func (m *UsageDetailMutation) StatusCleared() bool {
  28024. _, ok := m.clearedFields[usagedetail.FieldStatus]
  28025. return ok
  28026. }
  28027. // ResetStatus resets all changes to the "status" field.
  28028. func (m *UsageDetailMutation) ResetStatus() {
  28029. m.status = nil
  28030. m.addstatus = nil
  28031. delete(m.clearedFields, usagedetail.FieldStatus)
  28032. }
  28033. // SetType sets the "type" field.
  28034. func (m *UsageDetailMutation) SetType(i int) {
  28035. m._type = &i
  28036. m.add_type = nil
  28037. }
  28038. // GetType returns the value of the "type" field in the mutation.
  28039. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  28040. v := m._type
  28041. if v == nil {
  28042. return
  28043. }
  28044. return *v, true
  28045. }
  28046. // OldType returns the old "type" field's value of the UsageDetail entity.
  28047. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28049. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  28050. if !m.op.Is(OpUpdateOne) {
  28051. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28052. }
  28053. if m.id == nil || m.oldValue == nil {
  28054. return v, errors.New("OldType requires an ID field in the mutation")
  28055. }
  28056. oldValue, err := m.oldValue(ctx)
  28057. if err != nil {
  28058. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28059. }
  28060. return oldValue.Type, nil
  28061. }
  28062. // AddType adds i to the "type" field.
  28063. func (m *UsageDetailMutation) AddType(i int) {
  28064. if m.add_type != nil {
  28065. *m.add_type += i
  28066. } else {
  28067. m.add_type = &i
  28068. }
  28069. }
  28070. // AddedType returns the value that was added to the "type" field in this mutation.
  28071. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  28072. v := m.add_type
  28073. if v == nil {
  28074. return
  28075. }
  28076. return *v, true
  28077. }
  28078. // ClearType clears the value of the "type" field.
  28079. func (m *UsageDetailMutation) ClearType() {
  28080. m._type = nil
  28081. m.add_type = nil
  28082. m.clearedFields[usagedetail.FieldType] = struct{}{}
  28083. }
  28084. // TypeCleared returns if the "type" field was cleared in this mutation.
  28085. func (m *UsageDetailMutation) TypeCleared() bool {
  28086. _, ok := m.clearedFields[usagedetail.FieldType]
  28087. return ok
  28088. }
  28089. // ResetType resets all changes to the "type" field.
  28090. func (m *UsageDetailMutation) ResetType() {
  28091. m._type = nil
  28092. m.add_type = nil
  28093. delete(m.clearedFields, usagedetail.FieldType)
  28094. }
  28095. // SetBotID sets the "bot_id" field.
  28096. func (m *UsageDetailMutation) SetBotID(s string) {
  28097. m.bot_id = &s
  28098. }
  28099. // BotID returns the value of the "bot_id" field in the mutation.
  28100. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  28101. v := m.bot_id
  28102. if v == nil {
  28103. return
  28104. }
  28105. return *v, true
  28106. }
  28107. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  28108. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28110. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  28111. if !m.op.Is(OpUpdateOne) {
  28112. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28113. }
  28114. if m.id == nil || m.oldValue == nil {
  28115. return v, errors.New("OldBotID requires an ID field in the mutation")
  28116. }
  28117. oldValue, err := m.oldValue(ctx)
  28118. if err != nil {
  28119. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28120. }
  28121. return oldValue.BotID, nil
  28122. }
  28123. // ResetBotID resets all changes to the "bot_id" field.
  28124. func (m *UsageDetailMutation) ResetBotID() {
  28125. m.bot_id = nil
  28126. }
  28127. // SetReceiverID sets the "receiver_id" field.
  28128. func (m *UsageDetailMutation) SetReceiverID(s string) {
  28129. m.receiver_id = &s
  28130. }
  28131. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  28132. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  28133. v := m.receiver_id
  28134. if v == nil {
  28135. return
  28136. }
  28137. return *v, true
  28138. }
  28139. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  28140. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28142. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  28143. if !m.op.Is(OpUpdateOne) {
  28144. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  28145. }
  28146. if m.id == nil || m.oldValue == nil {
  28147. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  28148. }
  28149. oldValue, err := m.oldValue(ctx)
  28150. if err != nil {
  28151. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  28152. }
  28153. return oldValue.ReceiverID, nil
  28154. }
  28155. // ResetReceiverID resets all changes to the "receiver_id" field.
  28156. func (m *UsageDetailMutation) ResetReceiverID() {
  28157. m.receiver_id = nil
  28158. }
  28159. // SetApp sets the "app" field.
  28160. func (m *UsageDetailMutation) SetApp(i int) {
  28161. m.app = &i
  28162. m.addapp = nil
  28163. }
  28164. // App returns the value of the "app" field in the mutation.
  28165. func (m *UsageDetailMutation) App() (r int, exists bool) {
  28166. v := m.app
  28167. if v == nil {
  28168. return
  28169. }
  28170. return *v, true
  28171. }
  28172. // OldApp returns the old "app" field's value of the UsageDetail entity.
  28173. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28175. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  28176. if !m.op.Is(OpUpdateOne) {
  28177. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  28178. }
  28179. if m.id == nil || m.oldValue == nil {
  28180. return v, errors.New("OldApp requires an ID field in the mutation")
  28181. }
  28182. oldValue, err := m.oldValue(ctx)
  28183. if err != nil {
  28184. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  28185. }
  28186. return oldValue.App, nil
  28187. }
  28188. // AddApp adds i to the "app" field.
  28189. func (m *UsageDetailMutation) AddApp(i int) {
  28190. if m.addapp != nil {
  28191. *m.addapp += i
  28192. } else {
  28193. m.addapp = &i
  28194. }
  28195. }
  28196. // AddedApp returns the value that was added to the "app" field in this mutation.
  28197. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  28198. v := m.addapp
  28199. if v == nil {
  28200. return
  28201. }
  28202. return *v, true
  28203. }
  28204. // ClearApp clears the value of the "app" field.
  28205. func (m *UsageDetailMutation) ClearApp() {
  28206. m.app = nil
  28207. m.addapp = nil
  28208. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  28209. }
  28210. // AppCleared returns if the "app" field was cleared in this mutation.
  28211. func (m *UsageDetailMutation) AppCleared() bool {
  28212. _, ok := m.clearedFields[usagedetail.FieldApp]
  28213. return ok
  28214. }
  28215. // ResetApp resets all changes to the "app" field.
  28216. func (m *UsageDetailMutation) ResetApp() {
  28217. m.app = nil
  28218. m.addapp = nil
  28219. delete(m.clearedFields, usagedetail.FieldApp)
  28220. }
  28221. // SetSessionID sets the "session_id" field.
  28222. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  28223. m.session_id = &u
  28224. m.addsession_id = nil
  28225. }
  28226. // SessionID returns the value of the "session_id" field in the mutation.
  28227. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  28228. v := m.session_id
  28229. if v == nil {
  28230. return
  28231. }
  28232. return *v, true
  28233. }
  28234. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  28235. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28237. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  28238. if !m.op.Is(OpUpdateOne) {
  28239. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  28240. }
  28241. if m.id == nil || m.oldValue == nil {
  28242. return v, errors.New("OldSessionID requires an ID field in the mutation")
  28243. }
  28244. oldValue, err := m.oldValue(ctx)
  28245. if err != nil {
  28246. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  28247. }
  28248. return oldValue.SessionID, nil
  28249. }
  28250. // AddSessionID adds u to the "session_id" field.
  28251. func (m *UsageDetailMutation) AddSessionID(u int64) {
  28252. if m.addsession_id != nil {
  28253. *m.addsession_id += u
  28254. } else {
  28255. m.addsession_id = &u
  28256. }
  28257. }
  28258. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  28259. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  28260. v := m.addsession_id
  28261. if v == nil {
  28262. return
  28263. }
  28264. return *v, true
  28265. }
  28266. // ClearSessionID clears the value of the "session_id" field.
  28267. func (m *UsageDetailMutation) ClearSessionID() {
  28268. m.session_id = nil
  28269. m.addsession_id = nil
  28270. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  28271. }
  28272. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  28273. func (m *UsageDetailMutation) SessionIDCleared() bool {
  28274. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  28275. return ok
  28276. }
  28277. // ResetSessionID resets all changes to the "session_id" field.
  28278. func (m *UsageDetailMutation) ResetSessionID() {
  28279. m.session_id = nil
  28280. m.addsession_id = nil
  28281. delete(m.clearedFields, usagedetail.FieldSessionID)
  28282. }
  28283. // SetRequest sets the "request" field.
  28284. func (m *UsageDetailMutation) SetRequest(s string) {
  28285. m.request = &s
  28286. }
  28287. // Request returns the value of the "request" field in the mutation.
  28288. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  28289. v := m.request
  28290. if v == nil {
  28291. return
  28292. }
  28293. return *v, true
  28294. }
  28295. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  28296. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28298. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  28299. if !m.op.Is(OpUpdateOne) {
  28300. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  28301. }
  28302. if m.id == nil || m.oldValue == nil {
  28303. return v, errors.New("OldRequest requires an ID field in the mutation")
  28304. }
  28305. oldValue, err := m.oldValue(ctx)
  28306. if err != nil {
  28307. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  28308. }
  28309. return oldValue.Request, nil
  28310. }
  28311. // ResetRequest resets all changes to the "request" field.
  28312. func (m *UsageDetailMutation) ResetRequest() {
  28313. m.request = nil
  28314. }
  28315. // SetResponse sets the "response" field.
  28316. func (m *UsageDetailMutation) SetResponse(s string) {
  28317. m.response = &s
  28318. }
  28319. // Response returns the value of the "response" field in the mutation.
  28320. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  28321. v := m.response
  28322. if v == nil {
  28323. return
  28324. }
  28325. return *v, true
  28326. }
  28327. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  28328. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28330. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  28331. if !m.op.Is(OpUpdateOne) {
  28332. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  28333. }
  28334. if m.id == nil || m.oldValue == nil {
  28335. return v, errors.New("OldResponse requires an ID field in the mutation")
  28336. }
  28337. oldValue, err := m.oldValue(ctx)
  28338. if err != nil {
  28339. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  28340. }
  28341. return oldValue.Response, nil
  28342. }
  28343. // ResetResponse resets all changes to the "response" field.
  28344. func (m *UsageDetailMutation) ResetResponse() {
  28345. m.response = nil
  28346. }
  28347. // SetOriginalData sets the "original_data" field.
  28348. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  28349. m.original_data = &ctd
  28350. }
  28351. // OriginalData returns the value of the "original_data" field in the mutation.
  28352. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  28353. v := m.original_data
  28354. if v == nil {
  28355. return
  28356. }
  28357. return *v, true
  28358. }
  28359. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  28360. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28362. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  28363. if !m.op.Is(OpUpdateOne) {
  28364. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  28365. }
  28366. if m.id == nil || m.oldValue == nil {
  28367. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  28368. }
  28369. oldValue, err := m.oldValue(ctx)
  28370. if err != nil {
  28371. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  28372. }
  28373. return oldValue.OriginalData, nil
  28374. }
  28375. // ResetOriginalData resets all changes to the "original_data" field.
  28376. func (m *UsageDetailMutation) ResetOriginalData() {
  28377. m.original_data = nil
  28378. }
  28379. // SetTotalTokens sets the "total_tokens" field.
  28380. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  28381. m.total_tokens = &u
  28382. m.addtotal_tokens = nil
  28383. }
  28384. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  28385. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  28386. v := m.total_tokens
  28387. if v == nil {
  28388. return
  28389. }
  28390. return *v, true
  28391. }
  28392. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  28393. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28395. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  28396. if !m.op.Is(OpUpdateOne) {
  28397. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  28398. }
  28399. if m.id == nil || m.oldValue == nil {
  28400. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  28401. }
  28402. oldValue, err := m.oldValue(ctx)
  28403. if err != nil {
  28404. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  28405. }
  28406. return oldValue.TotalTokens, nil
  28407. }
  28408. // AddTotalTokens adds u to the "total_tokens" field.
  28409. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  28410. if m.addtotal_tokens != nil {
  28411. *m.addtotal_tokens += u
  28412. } else {
  28413. m.addtotal_tokens = &u
  28414. }
  28415. }
  28416. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  28417. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  28418. v := m.addtotal_tokens
  28419. if v == nil {
  28420. return
  28421. }
  28422. return *v, true
  28423. }
  28424. // ClearTotalTokens clears the value of the "total_tokens" field.
  28425. func (m *UsageDetailMutation) ClearTotalTokens() {
  28426. m.total_tokens = nil
  28427. m.addtotal_tokens = nil
  28428. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  28429. }
  28430. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  28431. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  28432. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  28433. return ok
  28434. }
  28435. // ResetTotalTokens resets all changes to the "total_tokens" field.
  28436. func (m *UsageDetailMutation) ResetTotalTokens() {
  28437. m.total_tokens = nil
  28438. m.addtotal_tokens = nil
  28439. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  28440. }
  28441. // SetPromptTokens sets the "prompt_tokens" field.
  28442. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  28443. m.prompt_tokens = &u
  28444. m.addprompt_tokens = nil
  28445. }
  28446. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  28447. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  28448. v := m.prompt_tokens
  28449. if v == nil {
  28450. return
  28451. }
  28452. return *v, true
  28453. }
  28454. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  28455. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28457. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  28458. if !m.op.Is(OpUpdateOne) {
  28459. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  28460. }
  28461. if m.id == nil || m.oldValue == nil {
  28462. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  28463. }
  28464. oldValue, err := m.oldValue(ctx)
  28465. if err != nil {
  28466. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  28467. }
  28468. return oldValue.PromptTokens, nil
  28469. }
  28470. // AddPromptTokens adds u to the "prompt_tokens" field.
  28471. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  28472. if m.addprompt_tokens != nil {
  28473. *m.addprompt_tokens += u
  28474. } else {
  28475. m.addprompt_tokens = &u
  28476. }
  28477. }
  28478. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  28479. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  28480. v := m.addprompt_tokens
  28481. if v == nil {
  28482. return
  28483. }
  28484. return *v, true
  28485. }
  28486. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  28487. func (m *UsageDetailMutation) ClearPromptTokens() {
  28488. m.prompt_tokens = nil
  28489. m.addprompt_tokens = nil
  28490. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  28491. }
  28492. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  28493. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  28494. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  28495. return ok
  28496. }
  28497. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  28498. func (m *UsageDetailMutation) ResetPromptTokens() {
  28499. m.prompt_tokens = nil
  28500. m.addprompt_tokens = nil
  28501. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  28502. }
  28503. // SetCompletionTokens sets the "completion_tokens" field.
  28504. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  28505. m.completion_tokens = &u
  28506. m.addcompletion_tokens = nil
  28507. }
  28508. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  28509. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  28510. v := m.completion_tokens
  28511. if v == nil {
  28512. return
  28513. }
  28514. return *v, true
  28515. }
  28516. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  28517. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28519. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  28520. if !m.op.Is(OpUpdateOne) {
  28521. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  28522. }
  28523. if m.id == nil || m.oldValue == nil {
  28524. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  28525. }
  28526. oldValue, err := m.oldValue(ctx)
  28527. if err != nil {
  28528. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  28529. }
  28530. return oldValue.CompletionTokens, nil
  28531. }
  28532. // AddCompletionTokens adds u to the "completion_tokens" field.
  28533. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  28534. if m.addcompletion_tokens != nil {
  28535. *m.addcompletion_tokens += u
  28536. } else {
  28537. m.addcompletion_tokens = &u
  28538. }
  28539. }
  28540. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  28541. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  28542. v := m.addcompletion_tokens
  28543. if v == nil {
  28544. return
  28545. }
  28546. return *v, true
  28547. }
  28548. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  28549. func (m *UsageDetailMutation) ClearCompletionTokens() {
  28550. m.completion_tokens = nil
  28551. m.addcompletion_tokens = nil
  28552. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  28553. }
  28554. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  28555. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  28556. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  28557. return ok
  28558. }
  28559. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  28560. func (m *UsageDetailMutation) ResetCompletionTokens() {
  28561. m.completion_tokens = nil
  28562. m.addcompletion_tokens = nil
  28563. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  28564. }
  28565. // SetOrganizationID sets the "organization_id" field.
  28566. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  28567. m.organization_id = &u
  28568. m.addorganization_id = nil
  28569. }
  28570. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28571. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  28572. v := m.organization_id
  28573. if v == nil {
  28574. return
  28575. }
  28576. return *v, true
  28577. }
  28578. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  28579. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  28580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28581. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28582. if !m.op.Is(OpUpdateOne) {
  28583. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28584. }
  28585. if m.id == nil || m.oldValue == nil {
  28586. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28587. }
  28588. oldValue, err := m.oldValue(ctx)
  28589. if err != nil {
  28590. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28591. }
  28592. return oldValue.OrganizationID, nil
  28593. }
  28594. // AddOrganizationID adds u to the "organization_id" field.
  28595. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  28596. if m.addorganization_id != nil {
  28597. *m.addorganization_id += u
  28598. } else {
  28599. m.addorganization_id = &u
  28600. }
  28601. }
  28602. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28603. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  28604. v := m.addorganization_id
  28605. if v == nil {
  28606. return
  28607. }
  28608. return *v, true
  28609. }
  28610. // ClearOrganizationID clears the value of the "organization_id" field.
  28611. func (m *UsageDetailMutation) ClearOrganizationID() {
  28612. m.organization_id = nil
  28613. m.addorganization_id = nil
  28614. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  28615. }
  28616. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28617. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  28618. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  28619. return ok
  28620. }
  28621. // ResetOrganizationID resets all changes to the "organization_id" field.
  28622. func (m *UsageDetailMutation) ResetOrganizationID() {
  28623. m.organization_id = nil
  28624. m.addorganization_id = nil
  28625. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  28626. }
  28627. // Where appends a list predicates to the UsageDetailMutation builder.
  28628. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  28629. m.predicates = append(m.predicates, ps...)
  28630. }
  28631. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  28632. // users can use type-assertion to append predicates that do not depend on any generated package.
  28633. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  28634. p := make([]predicate.UsageDetail, len(ps))
  28635. for i := range ps {
  28636. p[i] = ps[i]
  28637. }
  28638. m.Where(p...)
  28639. }
  28640. // Op returns the operation name.
  28641. func (m *UsageDetailMutation) Op() Op {
  28642. return m.op
  28643. }
  28644. // SetOp allows setting the mutation operation.
  28645. func (m *UsageDetailMutation) SetOp(op Op) {
  28646. m.op = op
  28647. }
  28648. // Type returns the node type of this mutation (UsageDetail).
  28649. func (m *UsageDetailMutation) Type() string {
  28650. return m.typ
  28651. }
  28652. // Fields returns all fields that were changed during this mutation. Note that in
  28653. // order to get all numeric fields that were incremented/decremented, call
  28654. // AddedFields().
  28655. func (m *UsageDetailMutation) Fields() []string {
  28656. fields := make([]string, 0, 15)
  28657. if m.created_at != nil {
  28658. fields = append(fields, usagedetail.FieldCreatedAt)
  28659. }
  28660. if m.updated_at != nil {
  28661. fields = append(fields, usagedetail.FieldUpdatedAt)
  28662. }
  28663. if m.status != nil {
  28664. fields = append(fields, usagedetail.FieldStatus)
  28665. }
  28666. if m._type != nil {
  28667. fields = append(fields, usagedetail.FieldType)
  28668. }
  28669. if m.bot_id != nil {
  28670. fields = append(fields, usagedetail.FieldBotID)
  28671. }
  28672. if m.receiver_id != nil {
  28673. fields = append(fields, usagedetail.FieldReceiverID)
  28674. }
  28675. if m.app != nil {
  28676. fields = append(fields, usagedetail.FieldApp)
  28677. }
  28678. if m.session_id != nil {
  28679. fields = append(fields, usagedetail.FieldSessionID)
  28680. }
  28681. if m.request != nil {
  28682. fields = append(fields, usagedetail.FieldRequest)
  28683. }
  28684. if m.response != nil {
  28685. fields = append(fields, usagedetail.FieldResponse)
  28686. }
  28687. if m.original_data != nil {
  28688. fields = append(fields, usagedetail.FieldOriginalData)
  28689. }
  28690. if m.total_tokens != nil {
  28691. fields = append(fields, usagedetail.FieldTotalTokens)
  28692. }
  28693. if m.prompt_tokens != nil {
  28694. fields = append(fields, usagedetail.FieldPromptTokens)
  28695. }
  28696. if m.completion_tokens != nil {
  28697. fields = append(fields, usagedetail.FieldCompletionTokens)
  28698. }
  28699. if m.organization_id != nil {
  28700. fields = append(fields, usagedetail.FieldOrganizationID)
  28701. }
  28702. return fields
  28703. }
  28704. // Field returns the value of a field with the given name. The second boolean
  28705. // return value indicates that this field was not set, or was not defined in the
  28706. // schema.
  28707. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  28708. switch name {
  28709. case usagedetail.FieldCreatedAt:
  28710. return m.CreatedAt()
  28711. case usagedetail.FieldUpdatedAt:
  28712. return m.UpdatedAt()
  28713. case usagedetail.FieldStatus:
  28714. return m.Status()
  28715. case usagedetail.FieldType:
  28716. return m.GetType()
  28717. case usagedetail.FieldBotID:
  28718. return m.BotID()
  28719. case usagedetail.FieldReceiverID:
  28720. return m.ReceiverID()
  28721. case usagedetail.FieldApp:
  28722. return m.App()
  28723. case usagedetail.FieldSessionID:
  28724. return m.SessionID()
  28725. case usagedetail.FieldRequest:
  28726. return m.Request()
  28727. case usagedetail.FieldResponse:
  28728. return m.Response()
  28729. case usagedetail.FieldOriginalData:
  28730. return m.OriginalData()
  28731. case usagedetail.FieldTotalTokens:
  28732. return m.TotalTokens()
  28733. case usagedetail.FieldPromptTokens:
  28734. return m.PromptTokens()
  28735. case usagedetail.FieldCompletionTokens:
  28736. return m.CompletionTokens()
  28737. case usagedetail.FieldOrganizationID:
  28738. return m.OrganizationID()
  28739. }
  28740. return nil, false
  28741. }
  28742. // OldField returns the old value of the field from the database. An error is
  28743. // returned if the mutation operation is not UpdateOne, or the query to the
  28744. // database failed.
  28745. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28746. switch name {
  28747. case usagedetail.FieldCreatedAt:
  28748. return m.OldCreatedAt(ctx)
  28749. case usagedetail.FieldUpdatedAt:
  28750. return m.OldUpdatedAt(ctx)
  28751. case usagedetail.FieldStatus:
  28752. return m.OldStatus(ctx)
  28753. case usagedetail.FieldType:
  28754. return m.OldType(ctx)
  28755. case usagedetail.FieldBotID:
  28756. return m.OldBotID(ctx)
  28757. case usagedetail.FieldReceiverID:
  28758. return m.OldReceiverID(ctx)
  28759. case usagedetail.FieldApp:
  28760. return m.OldApp(ctx)
  28761. case usagedetail.FieldSessionID:
  28762. return m.OldSessionID(ctx)
  28763. case usagedetail.FieldRequest:
  28764. return m.OldRequest(ctx)
  28765. case usagedetail.FieldResponse:
  28766. return m.OldResponse(ctx)
  28767. case usagedetail.FieldOriginalData:
  28768. return m.OldOriginalData(ctx)
  28769. case usagedetail.FieldTotalTokens:
  28770. return m.OldTotalTokens(ctx)
  28771. case usagedetail.FieldPromptTokens:
  28772. return m.OldPromptTokens(ctx)
  28773. case usagedetail.FieldCompletionTokens:
  28774. return m.OldCompletionTokens(ctx)
  28775. case usagedetail.FieldOrganizationID:
  28776. return m.OldOrganizationID(ctx)
  28777. }
  28778. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  28779. }
  28780. // SetField sets the value of a field with the given name. It returns an error if
  28781. // the field is not defined in the schema, or if the type mismatched the field
  28782. // type.
  28783. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  28784. switch name {
  28785. case usagedetail.FieldCreatedAt:
  28786. v, ok := value.(time.Time)
  28787. if !ok {
  28788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28789. }
  28790. m.SetCreatedAt(v)
  28791. return nil
  28792. case usagedetail.FieldUpdatedAt:
  28793. v, ok := value.(time.Time)
  28794. if !ok {
  28795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28796. }
  28797. m.SetUpdatedAt(v)
  28798. return nil
  28799. case usagedetail.FieldStatus:
  28800. v, ok := value.(uint8)
  28801. if !ok {
  28802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28803. }
  28804. m.SetStatus(v)
  28805. return nil
  28806. case usagedetail.FieldType:
  28807. v, ok := value.(int)
  28808. if !ok {
  28809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28810. }
  28811. m.SetType(v)
  28812. return nil
  28813. case usagedetail.FieldBotID:
  28814. v, ok := value.(string)
  28815. if !ok {
  28816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28817. }
  28818. m.SetBotID(v)
  28819. return nil
  28820. case usagedetail.FieldReceiverID:
  28821. v, ok := value.(string)
  28822. if !ok {
  28823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28824. }
  28825. m.SetReceiverID(v)
  28826. return nil
  28827. case usagedetail.FieldApp:
  28828. v, ok := value.(int)
  28829. if !ok {
  28830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28831. }
  28832. m.SetApp(v)
  28833. return nil
  28834. case usagedetail.FieldSessionID:
  28835. v, ok := value.(uint64)
  28836. if !ok {
  28837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28838. }
  28839. m.SetSessionID(v)
  28840. return nil
  28841. case usagedetail.FieldRequest:
  28842. v, ok := value.(string)
  28843. if !ok {
  28844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28845. }
  28846. m.SetRequest(v)
  28847. return nil
  28848. case usagedetail.FieldResponse:
  28849. v, ok := value.(string)
  28850. if !ok {
  28851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28852. }
  28853. m.SetResponse(v)
  28854. return nil
  28855. case usagedetail.FieldOriginalData:
  28856. v, ok := value.(custom_types.OriginalData)
  28857. if !ok {
  28858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28859. }
  28860. m.SetOriginalData(v)
  28861. return nil
  28862. case usagedetail.FieldTotalTokens:
  28863. v, ok := value.(uint64)
  28864. if !ok {
  28865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28866. }
  28867. m.SetTotalTokens(v)
  28868. return nil
  28869. case usagedetail.FieldPromptTokens:
  28870. v, ok := value.(uint64)
  28871. if !ok {
  28872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28873. }
  28874. m.SetPromptTokens(v)
  28875. return nil
  28876. case usagedetail.FieldCompletionTokens:
  28877. v, ok := value.(uint64)
  28878. if !ok {
  28879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28880. }
  28881. m.SetCompletionTokens(v)
  28882. return nil
  28883. case usagedetail.FieldOrganizationID:
  28884. v, ok := value.(uint64)
  28885. if !ok {
  28886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28887. }
  28888. m.SetOrganizationID(v)
  28889. return nil
  28890. }
  28891. return fmt.Errorf("unknown UsageDetail field %s", name)
  28892. }
  28893. // AddedFields returns all numeric fields that were incremented/decremented during
  28894. // this mutation.
  28895. func (m *UsageDetailMutation) AddedFields() []string {
  28896. var fields []string
  28897. if m.addstatus != nil {
  28898. fields = append(fields, usagedetail.FieldStatus)
  28899. }
  28900. if m.add_type != nil {
  28901. fields = append(fields, usagedetail.FieldType)
  28902. }
  28903. if m.addapp != nil {
  28904. fields = append(fields, usagedetail.FieldApp)
  28905. }
  28906. if m.addsession_id != nil {
  28907. fields = append(fields, usagedetail.FieldSessionID)
  28908. }
  28909. if m.addtotal_tokens != nil {
  28910. fields = append(fields, usagedetail.FieldTotalTokens)
  28911. }
  28912. if m.addprompt_tokens != nil {
  28913. fields = append(fields, usagedetail.FieldPromptTokens)
  28914. }
  28915. if m.addcompletion_tokens != nil {
  28916. fields = append(fields, usagedetail.FieldCompletionTokens)
  28917. }
  28918. if m.addorganization_id != nil {
  28919. fields = append(fields, usagedetail.FieldOrganizationID)
  28920. }
  28921. return fields
  28922. }
  28923. // AddedField returns the numeric value that was incremented/decremented on a field
  28924. // with the given name. The second boolean return value indicates that this field
  28925. // was not set, or was not defined in the schema.
  28926. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  28927. switch name {
  28928. case usagedetail.FieldStatus:
  28929. return m.AddedStatus()
  28930. case usagedetail.FieldType:
  28931. return m.AddedType()
  28932. case usagedetail.FieldApp:
  28933. return m.AddedApp()
  28934. case usagedetail.FieldSessionID:
  28935. return m.AddedSessionID()
  28936. case usagedetail.FieldTotalTokens:
  28937. return m.AddedTotalTokens()
  28938. case usagedetail.FieldPromptTokens:
  28939. return m.AddedPromptTokens()
  28940. case usagedetail.FieldCompletionTokens:
  28941. return m.AddedCompletionTokens()
  28942. case usagedetail.FieldOrganizationID:
  28943. return m.AddedOrganizationID()
  28944. }
  28945. return nil, false
  28946. }
  28947. // AddField adds the value to the field with the given name. It returns an error if
  28948. // the field is not defined in the schema, or if the type mismatched the field
  28949. // type.
  28950. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  28951. switch name {
  28952. case usagedetail.FieldStatus:
  28953. v, ok := value.(int8)
  28954. if !ok {
  28955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28956. }
  28957. m.AddStatus(v)
  28958. return nil
  28959. case usagedetail.FieldType:
  28960. v, ok := value.(int)
  28961. if !ok {
  28962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28963. }
  28964. m.AddType(v)
  28965. return nil
  28966. case usagedetail.FieldApp:
  28967. v, ok := value.(int)
  28968. if !ok {
  28969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28970. }
  28971. m.AddApp(v)
  28972. return nil
  28973. case usagedetail.FieldSessionID:
  28974. v, ok := value.(int64)
  28975. if !ok {
  28976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28977. }
  28978. m.AddSessionID(v)
  28979. return nil
  28980. case usagedetail.FieldTotalTokens:
  28981. v, ok := value.(int64)
  28982. if !ok {
  28983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28984. }
  28985. m.AddTotalTokens(v)
  28986. return nil
  28987. case usagedetail.FieldPromptTokens:
  28988. v, ok := value.(int64)
  28989. if !ok {
  28990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28991. }
  28992. m.AddPromptTokens(v)
  28993. return nil
  28994. case usagedetail.FieldCompletionTokens:
  28995. v, ok := value.(int64)
  28996. if !ok {
  28997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28998. }
  28999. m.AddCompletionTokens(v)
  29000. return nil
  29001. case usagedetail.FieldOrganizationID:
  29002. v, ok := value.(int64)
  29003. if !ok {
  29004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29005. }
  29006. m.AddOrganizationID(v)
  29007. return nil
  29008. }
  29009. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  29010. }
  29011. // ClearedFields returns all nullable fields that were cleared during this
  29012. // mutation.
  29013. func (m *UsageDetailMutation) ClearedFields() []string {
  29014. var fields []string
  29015. if m.FieldCleared(usagedetail.FieldStatus) {
  29016. fields = append(fields, usagedetail.FieldStatus)
  29017. }
  29018. if m.FieldCleared(usagedetail.FieldType) {
  29019. fields = append(fields, usagedetail.FieldType)
  29020. }
  29021. if m.FieldCleared(usagedetail.FieldApp) {
  29022. fields = append(fields, usagedetail.FieldApp)
  29023. }
  29024. if m.FieldCleared(usagedetail.FieldSessionID) {
  29025. fields = append(fields, usagedetail.FieldSessionID)
  29026. }
  29027. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  29028. fields = append(fields, usagedetail.FieldTotalTokens)
  29029. }
  29030. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  29031. fields = append(fields, usagedetail.FieldPromptTokens)
  29032. }
  29033. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  29034. fields = append(fields, usagedetail.FieldCompletionTokens)
  29035. }
  29036. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  29037. fields = append(fields, usagedetail.FieldOrganizationID)
  29038. }
  29039. return fields
  29040. }
  29041. // FieldCleared returns a boolean indicating if a field with the given name was
  29042. // cleared in this mutation.
  29043. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  29044. _, ok := m.clearedFields[name]
  29045. return ok
  29046. }
  29047. // ClearField clears the value of the field with the given name. It returns an
  29048. // error if the field is not defined in the schema.
  29049. func (m *UsageDetailMutation) ClearField(name string) error {
  29050. switch name {
  29051. case usagedetail.FieldStatus:
  29052. m.ClearStatus()
  29053. return nil
  29054. case usagedetail.FieldType:
  29055. m.ClearType()
  29056. return nil
  29057. case usagedetail.FieldApp:
  29058. m.ClearApp()
  29059. return nil
  29060. case usagedetail.FieldSessionID:
  29061. m.ClearSessionID()
  29062. return nil
  29063. case usagedetail.FieldTotalTokens:
  29064. m.ClearTotalTokens()
  29065. return nil
  29066. case usagedetail.FieldPromptTokens:
  29067. m.ClearPromptTokens()
  29068. return nil
  29069. case usagedetail.FieldCompletionTokens:
  29070. m.ClearCompletionTokens()
  29071. return nil
  29072. case usagedetail.FieldOrganizationID:
  29073. m.ClearOrganizationID()
  29074. return nil
  29075. }
  29076. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  29077. }
  29078. // ResetField resets all changes in the mutation for the field with the given name.
  29079. // It returns an error if the field is not defined in the schema.
  29080. func (m *UsageDetailMutation) ResetField(name string) error {
  29081. switch name {
  29082. case usagedetail.FieldCreatedAt:
  29083. m.ResetCreatedAt()
  29084. return nil
  29085. case usagedetail.FieldUpdatedAt:
  29086. m.ResetUpdatedAt()
  29087. return nil
  29088. case usagedetail.FieldStatus:
  29089. m.ResetStatus()
  29090. return nil
  29091. case usagedetail.FieldType:
  29092. m.ResetType()
  29093. return nil
  29094. case usagedetail.FieldBotID:
  29095. m.ResetBotID()
  29096. return nil
  29097. case usagedetail.FieldReceiverID:
  29098. m.ResetReceiverID()
  29099. return nil
  29100. case usagedetail.FieldApp:
  29101. m.ResetApp()
  29102. return nil
  29103. case usagedetail.FieldSessionID:
  29104. m.ResetSessionID()
  29105. return nil
  29106. case usagedetail.FieldRequest:
  29107. m.ResetRequest()
  29108. return nil
  29109. case usagedetail.FieldResponse:
  29110. m.ResetResponse()
  29111. return nil
  29112. case usagedetail.FieldOriginalData:
  29113. m.ResetOriginalData()
  29114. return nil
  29115. case usagedetail.FieldTotalTokens:
  29116. m.ResetTotalTokens()
  29117. return nil
  29118. case usagedetail.FieldPromptTokens:
  29119. m.ResetPromptTokens()
  29120. return nil
  29121. case usagedetail.FieldCompletionTokens:
  29122. m.ResetCompletionTokens()
  29123. return nil
  29124. case usagedetail.FieldOrganizationID:
  29125. m.ResetOrganizationID()
  29126. return nil
  29127. }
  29128. return fmt.Errorf("unknown UsageDetail field %s", name)
  29129. }
  29130. // AddedEdges returns all edge names that were set/added in this mutation.
  29131. func (m *UsageDetailMutation) AddedEdges() []string {
  29132. edges := make([]string, 0, 0)
  29133. return edges
  29134. }
  29135. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29136. // name in this mutation.
  29137. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  29138. return nil
  29139. }
  29140. // RemovedEdges returns all edge names that were removed in this mutation.
  29141. func (m *UsageDetailMutation) RemovedEdges() []string {
  29142. edges := make([]string, 0, 0)
  29143. return edges
  29144. }
  29145. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29146. // the given name in this mutation.
  29147. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  29148. return nil
  29149. }
  29150. // ClearedEdges returns all edge names that were cleared in this mutation.
  29151. func (m *UsageDetailMutation) ClearedEdges() []string {
  29152. edges := make([]string, 0, 0)
  29153. return edges
  29154. }
  29155. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29156. // was cleared in this mutation.
  29157. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  29158. return false
  29159. }
  29160. // ClearEdge clears the value of the edge with the given name. It returns an error
  29161. // if that edge is not defined in the schema.
  29162. func (m *UsageDetailMutation) ClearEdge(name string) error {
  29163. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  29164. }
  29165. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29166. // It returns an error if the edge is not defined in the schema.
  29167. func (m *UsageDetailMutation) ResetEdge(name string) error {
  29168. return fmt.Errorf("unknown UsageDetail edge %s", name)
  29169. }
  29170. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  29171. type UsageStatisticDayMutation struct {
  29172. config
  29173. op Op
  29174. typ string
  29175. id *uint64
  29176. created_at *time.Time
  29177. updated_at *time.Time
  29178. status *uint8
  29179. addstatus *int8
  29180. deleted_at *time.Time
  29181. addtime *uint64
  29182. addaddtime *int64
  29183. _type *int
  29184. add_type *int
  29185. bot_id *string
  29186. organization_id *uint64
  29187. addorganization_id *int64
  29188. ai_response *uint64
  29189. addai_response *int64
  29190. sop_run *uint64
  29191. addsop_run *int64
  29192. total_friend *uint64
  29193. addtotal_friend *int64
  29194. total_group *uint64
  29195. addtotal_group *int64
  29196. account_balance *uint64
  29197. addaccount_balance *int64
  29198. consume_token *uint64
  29199. addconsume_token *int64
  29200. active_user *uint64
  29201. addactive_user *int64
  29202. new_user *int64
  29203. addnew_user *int64
  29204. label_dist *[]custom_types.LabelDist
  29205. appendlabel_dist []custom_types.LabelDist
  29206. clearedFields map[string]struct{}
  29207. done bool
  29208. oldValue func(context.Context) (*UsageStatisticDay, error)
  29209. predicates []predicate.UsageStatisticDay
  29210. }
  29211. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  29212. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  29213. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  29214. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  29215. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  29216. m := &UsageStatisticDayMutation{
  29217. config: c,
  29218. op: op,
  29219. typ: TypeUsageStatisticDay,
  29220. clearedFields: make(map[string]struct{}),
  29221. }
  29222. for _, opt := range opts {
  29223. opt(m)
  29224. }
  29225. return m
  29226. }
  29227. // withUsageStatisticDayID sets the ID field of the mutation.
  29228. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  29229. return func(m *UsageStatisticDayMutation) {
  29230. var (
  29231. err error
  29232. once sync.Once
  29233. value *UsageStatisticDay
  29234. )
  29235. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  29236. once.Do(func() {
  29237. if m.done {
  29238. err = errors.New("querying old values post mutation is not allowed")
  29239. } else {
  29240. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  29241. }
  29242. })
  29243. return value, err
  29244. }
  29245. m.id = &id
  29246. }
  29247. }
  29248. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  29249. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  29250. return func(m *UsageStatisticDayMutation) {
  29251. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  29252. return node, nil
  29253. }
  29254. m.id = &node.ID
  29255. }
  29256. }
  29257. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29258. // executed in a transaction (ent.Tx), a transactional client is returned.
  29259. func (m UsageStatisticDayMutation) Client() *Client {
  29260. client := &Client{config: m.config}
  29261. client.init()
  29262. return client
  29263. }
  29264. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29265. // it returns an error otherwise.
  29266. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  29267. if _, ok := m.driver.(*txDriver); !ok {
  29268. return nil, errors.New("ent: mutation is not running in a transaction")
  29269. }
  29270. tx := &Tx{config: m.config}
  29271. tx.init()
  29272. return tx, nil
  29273. }
  29274. // SetID sets the value of the id field. Note that this
  29275. // operation is only accepted on creation of UsageStatisticDay entities.
  29276. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  29277. m.id = &id
  29278. }
  29279. // ID returns the ID value in the mutation. Note that the ID is only available
  29280. // if it was provided to the builder or after it was returned from the database.
  29281. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  29282. if m.id == nil {
  29283. return
  29284. }
  29285. return *m.id, true
  29286. }
  29287. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29288. // That means, if the mutation is applied within a transaction with an isolation level such
  29289. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29290. // or updated by the mutation.
  29291. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  29292. switch {
  29293. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29294. id, exists := m.ID()
  29295. if exists {
  29296. return []uint64{id}, nil
  29297. }
  29298. fallthrough
  29299. case m.op.Is(OpUpdate | OpDelete):
  29300. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  29301. default:
  29302. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29303. }
  29304. }
  29305. // SetCreatedAt sets the "created_at" field.
  29306. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  29307. m.created_at = &t
  29308. }
  29309. // CreatedAt returns the value of the "created_at" field in the mutation.
  29310. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  29311. v := m.created_at
  29312. if v == nil {
  29313. return
  29314. }
  29315. return *v, true
  29316. }
  29317. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  29318. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29320. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29321. if !m.op.Is(OpUpdateOne) {
  29322. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29323. }
  29324. if m.id == nil || m.oldValue == nil {
  29325. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29326. }
  29327. oldValue, err := m.oldValue(ctx)
  29328. if err != nil {
  29329. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29330. }
  29331. return oldValue.CreatedAt, nil
  29332. }
  29333. // ResetCreatedAt resets all changes to the "created_at" field.
  29334. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  29335. m.created_at = nil
  29336. }
  29337. // SetUpdatedAt sets the "updated_at" field.
  29338. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  29339. m.updated_at = &t
  29340. }
  29341. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29342. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  29343. v := m.updated_at
  29344. if v == nil {
  29345. return
  29346. }
  29347. return *v, true
  29348. }
  29349. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  29350. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29352. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29353. if !m.op.Is(OpUpdateOne) {
  29354. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29355. }
  29356. if m.id == nil || m.oldValue == nil {
  29357. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29358. }
  29359. oldValue, err := m.oldValue(ctx)
  29360. if err != nil {
  29361. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29362. }
  29363. return oldValue.UpdatedAt, nil
  29364. }
  29365. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29366. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  29367. m.updated_at = nil
  29368. }
  29369. // SetStatus sets the "status" field.
  29370. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  29371. m.status = &u
  29372. m.addstatus = nil
  29373. }
  29374. // Status returns the value of the "status" field in the mutation.
  29375. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  29376. v := m.status
  29377. if v == nil {
  29378. return
  29379. }
  29380. return *v, true
  29381. }
  29382. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  29383. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29385. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29386. if !m.op.Is(OpUpdateOne) {
  29387. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29388. }
  29389. if m.id == nil || m.oldValue == nil {
  29390. return v, errors.New("OldStatus requires an ID field in the mutation")
  29391. }
  29392. oldValue, err := m.oldValue(ctx)
  29393. if err != nil {
  29394. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29395. }
  29396. return oldValue.Status, nil
  29397. }
  29398. // AddStatus adds u to the "status" field.
  29399. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  29400. if m.addstatus != nil {
  29401. *m.addstatus += u
  29402. } else {
  29403. m.addstatus = &u
  29404. }
  29405. }
  29406. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29407. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  29408. v := m.addstatus
  29409. if v == nil {
  29410. return
  29411. }
  29412. return *v, true
  29413. }
  29414. // ClearStatus clears the value of the "status" field.
  29415. func (m *UsageStatisticDayMutation) ClearStatus() {
  29416. m.status = nil
  29417. m.addstatus = nil
  29418. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  29419. }
  29420. // StatusCleared returns if the "status" field was cleared in this mutation.
  29421. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  29422. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  29423. return ok
  29424. }
  29425. // ResetStatus resets all changes to the "status" field.
  29426. func (m *UsageStatisticDayMutation) ResetStatus() {
  29427. m.status = nil
  29428. m.addstatus = nil
  29429. delete(m.clearedFields, usagestatisticday.FieldStatus)
  29430. }
  29431. // SetDeletedAt sets the "deleted_at" field.
  29432. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  29433. m.deleted_at = &t
  29434. }
  29435. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29436. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  29437. v := m.deleted_at
  29438. if v == nil {
  29439. return
  29440. }
  29441. return *v, true
  29442. }
  29443. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  29444. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29446. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29447. if !m.op.Is(OpUpdateOne) {
  29448. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29449. }
  29450. if m.id == nil || m.oldValue == nil {
  29451. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29452. }
  29453. oldValue, err := m.oldValue(ctx)
  29454. if err != nil {
  29455. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29456. }
  29457. return oldValue.DeletedAt, nil
  29458. }
  29459. // ClearDeletedAt clears the value of the "deleted_at" field.
  29460. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  29461. m.deleted_at = nil
  29462. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  29463. }
  29464. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29465. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  29466. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  29467. return ok
  29468. }
  29469. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29470. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  29471. m.deleted_at = nil
  29472. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  29473. }
  29474. // SetAddtime sets the "addtime" field.
  29475. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  29476. m.addtime = &u
  29477. m.addaddtime = nil
  29478. }
  29479. // Addtime returns the value of the "addtime" field in the mutation.
  29480. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  29481. v := m.addtime
  29482. if v == nil {
  29483. return
  29484. }
  29485. return *v, true
  29486. }
  29487. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  29488. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29490. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29491. if !m.op.Is(OpUpdateOne) {
  29492. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29493. }
  29494. if m.id == nil || m.oldValue == nil {
  29495. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29496. }
  29497. oldValue, err := m.oldValue(ctx)
  29498. if err != nil {
  29499. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29500. }
  29501. return oldValue.Addtime, nil
  29502. }
  29503. // AddAddtime adds u to the "addtime" field.
  29504. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  29505. if m.addaddtime != nil {
  29506. *m.addaddtime += u
  29507. } else {
  29508. m.addaddtime = &u
  29509. }
  29510. }
  29511. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29512. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  29513. v := m.addaddtime
  29514. if v == nil {
  29515. return
  29516. }
  29517. return *v, true
  29518. }
  29519. // ResetAddtime resets all changes to the "addtime" field.
  29520. func (m *UsageStatisticDayMutation) ResetAddtime() {
  29521. m.addtime = nil
  29522. m.addaddtime = nil
  29523. }
  29524. // SetType sets the "type" field.
  29525. func (m *UsageStatisticDayMutation) SetType(i int) {
  29526. m._type = &i
  29527. m.add_type = nil
  29528. }
  29529. // GetType returns the value of the "type" field in the mutation.
  29530. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  29531. v := m._type
  29532. if v == nil {
  29533. return
  29534. }
  29535. return *v, true
  29536. }
  29537. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  29538. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29540. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  29541. if !m.op.Is(OpUpdateOne) {
  29542. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29543. }
  29544. if m.id == nil || m.oldValue == nil {
  29545. return v, errors.New("OldType requires an ID field in the mutation")
  29546. }
  29547. oldValue, err := m.oldValue(ctx)
  29548. if err != nil {
  29549. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29550. }
  29551. return oldValue.Type, nil
  29552. }
  29553. // AddType adds i to the "type" field.
  29554. func (m *UsageStatisticDayMutation) AddType(i int) {
  29555. if m.add_type != nil {
  29556. *m.add_type += i
  29557. } else {
  29558. m.add_type = &i
  29559. }
  29560. }
  29561. // AddedType returns the value that was added to the "type" field in this mutation.
  29562. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  29563. v := m.add_type
  29564. if v == nil {
  29565. return
  29566. }
  29567. return *v, true
  29568. }
  29569. // ResetType resets all changes to the "type" field.
  29570. func (m *UsageStatisticDayMutation) ResetType() {
  29571. m._type = nil
  29572. m.add_type = nil
  29573. }
  29574. // SetBotID sets the "bot_id" field.
  29575. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  29576. m.bot_id = &s
  29577. }
  29578. // BotID returns the value of the "bot_id" field in the mutation.
  29579. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  29580. v := m.bot_id
  29581. if v == nil {
  29582. return
  29583. }
  29584. return *v, true
  29585. }
  29586. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  29587. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29589. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  29590. if !m.op.Is(OpUpdateOne) {
  29591. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29592. }
  29593. if m.id == nil || m.oldValue == nil {
  29594. return v, errors.New("OldBotID requires an ID field in the mutation")
  29595. }
  29596. oldValue, err := m.oldValue(ctx)
  29597. if err != nil {
  29598. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29599. }
  29600. return oldValue.BotID, nil
  29601. }
  29602. // ClearBotID clears the value of the "bot_id" field.
  29603. func (m *UsageStatisticDayMutation) ClearBotID() {
  29604. m.bot_id = nil
  29605. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  29606. }
  29607. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  29608. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  29609. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  29610. return ok
  29611. }
  29612. // ResetBotID resets all changes to the "bot_id" field.
  29613. func (m *UsageStatisticDayMutation) ResetBotID() {
  29614. m.bot_id = nil
  29615. delete(m.clearedFields, usagestatisticday.FieldBotID)
  29616. }
  29617. // SetOrganizationID sets the "organization_id" field.
  29618. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  29619. m.organization_id = &u
  29620. m.addorganization_id = nil
  29621. }
  29622. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29623. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  29624. v := m.organization_id
  29625. if v == nil {
  29626. return
  29627. }
  29628. return *v, true
  29629. }
  29630. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  29631. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29633. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29634. if !m.op.Is(OpUpdateOne) {
  29635. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29636. }
  29637. if m.id == nil || m.oldValue == nil {
  29638. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29639. }
  29640. oldValue, err := m.oldValue(ctx)
  29641. if err != nil {
  29642. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29643. }
  29644. return oldValue.OrganizationID, nil
  29645. }
  29646. // AddOrganizationID adds u to the "organization_id" field.
  29647. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  29648. if m.addorganization_id != nil {
  29649. *m.addorganization_id += u
  29650. } else {
  29651. m.addorganization_id = &u
  29652. }
  29653. }
  29654. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29655. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  29656. v := m.addorganization_id
  29657. if v == nil {
  29658. return
  29659. }
  29660. return *v, true
  29661. }
  29662. // ClearOrganizationID clears the value of the "organization_id" field.
  29663. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  29664. m.organization_id = nil
  29665. m.addorganization_id = nil
  29666. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  29667. }
  29668. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29669. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  29670. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  29671. return ok
  29672. }
  29673. // ResetOrganizationID resets all changes to the "organization_id" field.
  29674. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  29675. m.organization_id = nil
  29676. m.addorganization_id = nil
  29677. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  29678. }
  29679. // SetAiResponse sets the "ai_response" field.
  29680. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  29681. m.ai_response = &u
  29682. m.addai_response = nil
  29683. }
  29684. // AiResponse returns the value of the "ai_response" field in the mutation.
  29685. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  29686. v := m.ai_response
  29687. if v == nil {
  29688. return
  29689. }
  29690. return *v, true
  29691. }
  29692. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  29693. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29695. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  29696. if !m.op.Is(OpUpdateOne) {
  29697. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  29698. }
  29699. if m.id == nil || m.oldValue == nil {
  29700. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  29701. }
  29702. oldValue, err := m.oldValue(ctx)
  29703. if err != nil {
  29704. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  29705. }
  29706. return oldValue.AiResponse, nil
  29707. }
  29708. // AddAiResponse adds u to the "ai_response" field.
  29709. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  29710. if m.addai_response != nil {
  29711. *m.addai_response += u
  29712. } else {
  29713. m.addai_response = &u
  29714. }
  29715. }
  29716. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  29717. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  29718. v := m.addai_response
  29719. if v == nil {
  29720. return
  29721. }
  29722. return *v, true
  29723. }
  29724. // ResetAiResponse resets all changes to the "ai_response" field.
  29725. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  29726. m.ai_response = nil
  29727. m.addai_response = nil
  29728. }
  29729. // SetSopRun sets the "sop_run" field.
  29730. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  29731. m.sop_run = &u
  29732. m.addsop_run = nil
  29733. }
  29734. // SopRun returns the value of the "sop_run" field in the mutation.
  29735. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  29736. v := m.sop_run
  29737. if v == nil {
  29738. return
  29739. }
  29740. return *v, true
  29741. }
  29742. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  29743. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29745. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  29746. if !m.op.Is(OpUpdateOne) {
  29747. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  29748. }
  29749. if m.id == nil || m.oldValue == nil {
  29750. return v, errors.New("OldSopRun requires an ID field in the mutation")
  29751. }
  29752. oldValue, err := m.oldValue(ctx)
  29753. if err != nil {
  29754. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  29755. }
  29756. return oldValue.SopRun, nil
  29757. }
  29758. // AddSopRun adds u to the "sop_run" field.
  29759. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  29760. if m.addsop_run != nil {
  29761. *m.addsop_run += u
  29762. } else {
  29763. m.addsop_run = &u
  29764. }
  29765. }
  29766. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  29767. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  29768. v := m.addsop_run
  29769. if v == nil {
  29770. return
  29771. }
  29772. return *v, true
  29773. }
  29774. // ResetSopRun resets all changes to the "sop_run" field.
  29775. func (m *UsageStatisticDayMutation) ResetSopRun() {
  29776. m.sop_run = nil
  29777. m.addsop_run = nil
  29778. }
  29779. // SetTotalFriend sets the "total_friend" field.
  29780. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  29781. m.total_friend = &u
  29782. m.addtotal_friend = nil
  29783. }
  29784. // TotalFriend returns the value of the "total_friend" field in the mutation.
  29785. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  29786. v := m.total_friend
  29787. if v == nil {
  29788. return
  29789. }
  29790. return *v, true
  29791. }
  29792. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  29793. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29795. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  29796. if !m.op.Is(OpUpdateOne) {
  29797. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  29798. }
  29799. if m.id == nil || m.oldValue == nil {
  29800. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  29801. }
  29802. oldValue, err := m.oldValue(ctx)
  29803. if err != nil {
  29804. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  29805. }
  29806. return oldValue.TotalFriend, nil
  29807. }
  29808. // AddTotalFriend adds u to the "total_friend" field.
  29809. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  29810. if m.addtotal_friend != nil {
  29811. *m.addtotal_friend += u
  29812. } else {
  29813. m.addtotal_friend = &u
  29814. }
  29815. }
  29816. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  29817. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  29818. v := m.addtotal_friend
  29819. if v == nil {
  29820. return
  29821. }
  29822. return *v, true
  29823. }
  29824. // ResetTotalFriend resets all changes to the "total_friend" field.
  29825. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  29826. m.total_friend = nil
  29827. m.addtotal_friend = nil
  29828. }
  29829. // SetTotalGroup sets the "total_group" field.
  29830. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  29831. m.total_group = &u
  29832. m.addtotal_group = nil
  29833. }
  29834. // TotalGroup returns the value of the "total_group" field in the mutation.
  29835. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  29836. v := m.total_group
  29837. if v == nil {
  29838. return
  29839. }
  29840. return *v, true
  29841. }
  29842. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  29843. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29845. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  29846. if !m.op.Is(OpUpdateOne) {
  29847. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  29848. }
  29849. if m.id == nil || m.oldValue == nil {
  29850. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  29851. }
  29852. oldValue, err := m.oldValue(ctx)
  29853. if err != nil {
  29854. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  29855. }
  29856. return oldValue.TotalGroup, nil
  29857. }
  29858. // AddTotalGroup adds u to the "total_group" field.
  29859. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  29860. if m.addtotal_group != nil {
  29861. *m.addtotal_group += u
  29862. } else {
  29863. m.addtotal_group = &u
  29864. }
  29865. }
  29866. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  29867. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  29868. v := m.addtotal_group
  29869. if v == nil {
  29870. return
  29871. }
  29872. return *v, true
  29873. }
  29874. // ResetTotalGroup resets all changes to the "total_group" field.
  29875. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  29876. m.total_group = nil
  29877. m.addtotal_group = nil
  29878. }
  29879. // SetAccountBalance sets the "account_balance" field.
  29880. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  29881. m.account_balance = &u
  29882. m.addaccount_balance = nil
  29883. }
  29884. // AccountBalance returns the value of the "account_balance" field in the mutation.
  29885. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  29886. v := m.account_balance
  29887. if v == nil {
  29888. return
  29889. }
  29890. return *v, true
  29891. }
  29892. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  29893. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29895. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  29896. if !m.op.Is(OpUpdateOne) {
  29897. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  29898. }
  29899. if m.id == nil || m.oldValue == nil {
  29900. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  29901. }
  29902. oldValue, err := m.oldValue(ctx)
  29903. if err != nil {
  29904. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  29905. }
  29906. return oldValue.AccountBalance, nil
  29907. }
  29908. // AddAccountBalance adds u to the "account_balance" field.
  29909. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  29910. if m.addaccount_balance != nil {
  29911. *m.addaccount_balance += u
  29912. } else {
  29913. m.addaccount_balance = &u
  29914. }
  29915. }
  29916. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  29917. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  29918. v := m.addaccount_balance
  29919. if v == nil {
  29920. return
  29921. }
  29922. return *v, true
  29923. }
  29924. // ResetAccountBalance resets all changes to the "account_balance" field.
  29925. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  29926. m.account_balance = nil
  29927. m.addaccount_balance = nil
  29928. }
  29929. // SetConsumeToken sets the "consume_token" field.
  29930. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  29931. m.consume_token = &u
  29932. m.addconsume_token = nil
  29933. }
  29934. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  29935. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  29936. v := m.consume_token
  29937. if v == nil {
  29938. return
  29939. }
  29940. return *v, true
  29941. }
  29942. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  29943. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29945. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  29946. if !m.op.Is(OpUpdateOne) {
  29947. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  29948. }
  29949. if m.id == nil || m.oldValue == nil {
  29950. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  29951. }
  29952. oldValue, err := m.oldValue(ctx)
  29953. if err != nil {
  29954. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  29955. }
  29956. return oldValue.ConsumeToken, nil
  29957. }
  29958. // AddConsumeToken adds u to the "consume_token" field.
  29959. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  29960. if m.addconsume_token != nil {
  29961. *m.addconsume_token += u
  29962. } else {
  29963. m.addconsume_token = &u
  29964. }
  29965. }
  29966. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  29967. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  29968. v := m.addconsume_token
  29969. if v == nil {
  29970. return
  29971. }
  29972. return *v, true
  29973. }
  29974. // ResetConsumeToken resets all changes to the "consume_token" field.
  29975. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  29976. m.consume_token = nil
  29977. m.addconsume_token = nil
  29978. }
  29979. // SetActiveUser sets the "active_user" field.
  29980. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  29981. m.active_user = &u
  29982. m.addactive_user = nil
  29983. }
  29984. // ActiveUser returns the value of the "active_user" field in the mutation.
  29985. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  29986. v := m.active_user
  29987. if v == nil {
  29988. return
  29989. }
  29990. return *v, true
  29991. }
  29992. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  29993. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  29994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29995. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  29996. if !m.op.Is(OpUpdateOne) {
  29997. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  29998. }
  29999. if m.id == nil || m.oldValue == nil {
  30000. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30001. }
  30002. oldValue, err := m.oldValue(ctx)
  30003. if err != nil {
  30004. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30005. }
  30006. return oldValue.ActiveUser, nil
  30007. }
  30008. // AddActiveUser adds u to the "active_user" field.
  30009. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  30010. if m.addactive_user != nil {
  30011. *m.addactive_user += u
  30012. } else {
  30013. m.addactive_user = &u
  30014. }
  30015. }
  30016. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30017. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  30018. v := m.addactive_user
  30019. if v == nil {
  30020. return
  30021. }
  30022. return *v, true
  30023. }
  30024. // ResetActiveUser resets all changes to the "active_user" field.
  30025. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  30026. m.active_user = nil
  30027. m.addactive_user = nil
  30028. }
  30029. // SetNewUser sets the "new_user" field.
  30030. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  30031. m.new_user = &i
  30032. m.addnew_user = nil
  30033. }
  30034. // NewUser returns the value of the "new_user" field in the mutation.
  30035. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  30036. v := m.new_user
  30037. if v == nil {
  30038. return
  30039. }
  30040. return *v, true
  30041. }
  30042. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  30043. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30045. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30046. if !m.op.Is(OpUpdateOne) {
  30047. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30048. }
  30049. if m.id == nil || m.oldValue == nil {
  30050. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30051. }
  30052. oldValue, err := m.oldValue(ctx)
  30053. if err != nil {
  30054. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30055. }
  30056. return oldValue.NewUser, nil
  30057. }
  30058. // AddNewUser adds i to the "new_user" field.
  30059. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  30060. if m.addnew_user != nil {
  30061. *m.addnew_user += i
  30062. } else {
  30063. m.addnew_user = &i
  30064. }
  30065. }
  30066. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30067. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  30068. v := m.addnew_user
  30069. if v == nil {
  30070. return
  30071. }
  30072. return *v, true
  30073. }
  30074. // ResetNewUser resets all changes to the "new_user" field.
  30075. func (m *UsageStatisticDayMutation) ResetNewUser() {
  30076. m.new_user = nil
  30077. m.addnew_user = nil
  30078. }
  30079. // SetLabelDist sets the "label_dist" field.
  30080. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30081. m.label_dist = &ctd
  30082. m.appendlabel_dist = nil
  30083. }
  30084. // LabelDist returns the value of the "label_dist" field in the mutation.
  30085. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30086. v := m.label_dist
  30087. if v == nil {
  30088. return
  30089. }
  30090. return *v, true
  30091. }
  30092. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  30093. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30095. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30096. if !m.op.Is(OpUpdateOne) {
  30097. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30098. }
  30099. if m.id == nil || m.oldValue == nil {
  30100. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30101. }
  30102. oldValue, err := m.oldValue(ctx)
  30103. if err != nil {
  30104. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30105. }
  30106. return oldValue.LabelDist, nil
  30107. }
  30108. // AppendLabelDist adds ctd to the "label_dist" field.
  30109. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30110. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30111. }
  30112. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30113. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30114. if len(m.appendlabel_dist) == 0 {
  30115. return nil, false
  30116. }
  30117. return m.appendlabel_dist, true
  30118. }
  30119. // ResetLabelDist resets all changes to the "label_dist" field.
  30120. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  30121. m.label_dist = nil
  30122. m.appendlabel_dist = nil
  30123. }
  30124. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  30125. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  30126. m.predicates = append(m.predicates, ps...)
  30127. }
  30128. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  30129. // users can use type-assertion to append predicates that do not depend on any generated package.
  30130. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  30131. p := make([]predicate.UsageStatisticDay, len(ps))
  30132. for i := range ps {
  30133. p[i] = ps[i]
  30134. }
  30135. m.Where(p...)
  30136. }
  30137. // Op returns the operation name.
  30138. func (m *UsageStatisticDayMutation) Op() Op {
  30139. return m.op
  30140. }
  30141. // SetOp allows setting the mutation operation.
  30142. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  30143. m.op = op
  30144. }
  30145. // Type returns the node type of this mutation (UsageStatisticDay).
  30146. func (m *UsageStatisticDayMutation) Type() string {
  30147. return m.typ
  30148. }
  30149. // Fields returns all fields that were changed during this mutation. Note that in
  30150. // order to get all numeric fields that were incremented/decremented, call
  30151. // AddedFields().
  30152. func (m *UsageStatisticDayMutation) Fields() []string {
  30153. fields := make([]string, 0, 17)
  30154. if m.created_at != nil {
  30155. fields = append(fields, usagestatisticday.FieldCreatedAt)
  30156. }
  30157. if m.updated_at != nil {
  30158. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  30159. }
  30160. if m.status != nil {
  30161. fields = append(fields, usagestatisticday.FieldStatus)
  30162. }
  30163. if m.deleted_at != nil {
  30164. fields = append(fields, usagestatisticday.FieldDeletedAt)
  30165. }
  30166. if m.addtime != nil {
  30167. fields = append(fields, usagestatisticday.FieldAddtime)
  30168. }
  30169. if m._type != nil {
  30170. fields = append(fields, usagestatisticday.FieldType)
  30171. }
  30172. if m.bot_id != nil {
  30173. fields = append(fields, usagestatisticday.FieldBotID)
  30174. }
  30175. if m.organization_id != nil {
  30176. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30177. }
  30178. if m.ai_response != nil {
  30179. fields = append(fields, usagestatisticday.FieldAiResponse)
  30180. }
  30181. if m.sop_run != nil {
  30182. fields = append(fields, usagestatisticday.FieldSopRun)
  30183. }
  30184. if m.total_friend != nil {
  30185. fields = append(fields, usagestatisticday.FieldTotalFriend)
  30186. }
  30187. if m.total_group != nil {
  30188. fields = append(fields, usagestatisticday.FieldTotalGroup)
  30189. }
  30190. if m.account_balance != nil {
  30191. fields = append(fields, usagestatisticday.FieldAccountBalance)
  30192. }
  30193. if m.consume_token != nil {
  30194. fields = append(fields, usagestatisticday.FieldConsumeToken)
  30195. }
  30196. if m.active_user != nil {
  30197. fields = append(fields, usagestatisticday.FieldActiveUser)
  30198. }
  30199. if m.new_user != nil {
  30200. fields = append(fields, usagestatisticday.FieldNewUser)
  30201. }
  30202. if m.label_dist != nil {
  30203. fields = append(fields, usagestatisticday.FieldLabelDist)
  30204. }
  30205. return fields
  30206. }
  30207. // Field returns the value of a field with the given name. The second boolean
  30208. // return value indicates that this field was not set, or was not defined in the
  30209. // schema.
  30210. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  30211. switch name {
  30212. case usagestatisticday.FieldCreatedAt:
  30213. return m.CreatedAt()
  30214. case usagestatisticday.FieldUpdatedAt:
  30215. return m.UpdatedAt()
  30216. case usagestatisticday.FieldStatus:
  30217. return m.Status()
  30218. case usagestatisticday.FieldDeletedAt:
  30219. return m.DeletedAt()
  30220. case usagestatisticday.FieldAddtime:
  30221. return m.Addtime()
  30222. case usagestatisticday.FieldType:
  30223. return m.GetType()
  30224. case usagestatisticday.FieldBotID:
  30225. return m.BotID()
  30226. case usagestatisticday.FieldOrganizationID:
  30227. return m.OrganizationID()
  30228. case usagestatisticday.FieldAiResponse:
  30229. return m.AiResponse()
  30230. case usagestatisticday.FieldSopRun:
  30231. return m.SopRun()
  30232. case usagestatisticday.FieldTotalFriend:
  30233. return m.TotalFriend()
  30234. case usagestatisticday.FieldTotalGroup:
  30235. return m.TotalGroup()
  30236. case usagestatisticday.FieldAccountBalance:
  30237. return m.AccountBalance()
  30238. case usagestatisticday.FieldConsumeToken:
  30239. return m.ConsumeToken()
  30240. case usagestatisticday.FieldActiveUser:
  30241. return m.ActiveUser()
  30242. case usagestatisticday.FieldNewUser:
  30243. return m.NewUser()
  30244. case usagestatisticday.FieldLabelDist:
  30245. return m.LabelDist()
  30246. }
  30247. return nil, false
  30248. }
  30249. // OldField returns the old value of the field from the database. An error is
  30250. // returned if the mutation operation is not UpdateOne, or the query to the
  30251. // database failed.
  30252. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30253. switch name {
  30254. case usagestatisticday.FieldCreatedAt:
  30255. return m.OldCreatedAt(ctx)
  30256. case usagestatisticday.FieldUpdatedAt:
  30257. return m.OldUpdatedAt(ctx)
  30258. case usagestatisticday.FieldStatus:
  30259. return m.OldStatus(ctx)
  30260. case usagestatisticday.FieldDeletedAt:
  30261. return m.OldDeletedAt(ctx)
  30262. case usagestatisticday.FieldAddtime:
  30263. return m.OldAddtime(ctx)
  30264. case usagestatisticday.FieldType:
  30265. return m.OldType(ctx)
  30266. case usagestatisticday.FieldBotID:
  30267. return m.OldBotID(ctx)
  30268. case usagestatisticday.FieldOrganizationID:
  30269. return m.OldOrganizationID(ctx)
  30270. case usagestatisticday.FieldAiResponse:
  30271. return m.OldAiResponse(ctx)
  30272. case usagestatisticday.FieldSopRun:
  30273. return m.OldSopRun(ctx)
  30274. case usagestatisticday.FieldTotalFriend:
  30275. return m.OldTotalFriend(ctx)
  30276. case usagestatisticday.FieldTotalGroup:
  30277. return m.OldTotalGroup(ctx)
  30278. case usagestatisticday.FieldAccountBalance:
  30279. return m.OldAccountBalance(ctx)
  30280. case usagestatisticday.FieldConsumeToken:
  30281. return m.OldConsumeToken(ctx)
  30282. case usagestatisticday.FieldActiveUser:
  30283. return m.OldActiveUser(ctx)
  30284. case usagestatisticday.FieldNewUser:
  30285. return m.OldNewUser(ctx)
  30286. case usagestatisticday.FieldLabelDist:
  30287. return m.OldLabelDist(ctx)
  30288. }
  30289. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30290. }
  30291. // SetField sets the value of a field with the given name. It returns an error if
  30292. // the field is not defined in the schema, or if the type mismatched the field
  30293. // type.
  30294. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  30295. switch name {
  30296. case usagestatisticday.FieldCreatedAt:
  30297. v, ok := value.(time.Time)
  30298. if !ok {
  30299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30300. }
  30301. m.SetCreatedAt(v)
  30302. return nil
  30303. case usagestatisticday.FieldUpdatedAt:
  30304. v, ok := value.(time.Time)
  30305. if !ok {
  30306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30307. }
  30308. m.SetUpdatedAt(v)
  30309. return nil
  30310. case usagestatisticday.FieldStatus:
  30311. v, ok := value.(uint8)
  30312. if !ok {
  30313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30314. }
  30315. m.SetStatus(v)
  30316. return nil
  30317. case usagestatisticday.FieldDeletedAt:
  30318. v, ok := value.(time.Time)
  30319. if !ok {
  30320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30321. }
  30322. m.SetDeletedAt(v)
  30323. return nil
  30324. case usagestatisticday.FieldAddtime:
  30325. v, ok := value.(uint64)
  30326. if !ok {
  30327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30328. }
  30329. m.SetAddtime(v)
  30330. return nil
  30331. case usagestatisticday.FieldType:
  30332. v, ok := value.(int)
  30333. if !ok {
  30334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30335. }
  30336. m.SetType(v)
  30337. return nil
  30338. case usagestatisticday.FieldBotID:
  30339. v, ok := value.(string)
  30340. if !ok {
  30341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30342. }
  30343. m.SetBotID(v)
  30344. return nil
  30345. case usagestatisticday.FieldOrganizationID:
  30346. v, ok := value.(uint64)
  30347. if !ok {
  30348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30349. }
  30350. m.SetOrganizationID(v)
  30351. return nil
  30352. case usagestatisticday.FieldAiResponse:
  30353. v, ok := value.(uint64)
  30354. if !ok {
  30355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30356. }
  30357. m.SetAiResponse(v)
  30358. return nil
  30359. case usagestatisticday.FieldSopRun:
  30360. v, ok := value.(uint64)
  30361. if !ok {
  30362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30363. }
  30364. m.SetSopRun(v)
  30365. return nil
  30366. case usagestatisticday.FieldTotalFriend:
  30367. v, ok := value.(uint64)
  30368. if !ok {
  30369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30370. }
  30371. m.SetTotalFriend(v)
  30372. return nil
  30373. case usagestatisticday.FieldTotalGroup:
  30374. v, ok := value.(uint64)
  30375. if !ok {
  30376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30377. }
  30378. m.SetTotalGroup(v)
  30379. return nil
  30380. case usagestatisticday.FieldAccountBalance:
  30381. v, ok := value.(uint64)
  30382. if !ok {
  30383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30384. }
  30385. m.SetAccountBalance(v)
  30386. return nil
  30387. case usagestatisticday.FieldConsumeToken:
  30388. v, ok := value.(uint64)
  30389. if !ok {
  30390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30391. }
  30392. m.SetConsumeToken(v)
  30393. return nil
  30394. case usagestatisticday.FieldActiveUser:
  30395. v, ok := value.(uint64)
  30396. if !ok {
  30397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30398. }
  30399. m.SetActiveUser(v)
  30400. return nil
  30401. case usagestatisticday.FieldNewUser:
  30402. v, ok := value.(int64)
  30403. if !ok {
  30404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30405. }
  30406. m.SetNewUser(v)
  30407. return nil
  30408. case usagestatisticday.FieldLabelDist:
  30409. v, ok := value.([]custom_types.LabelDist)
  30410. if !ok {
  30411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30412. }
  30413. m.SetLabelDist(v)
  30414. return nil
  30415. }
  30416. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30417. }
  30418. // AddedFields returns all numeric fields that were incremented/decremented during
  30419. // this mutation.
  30420. func (m *UsageStatisticDayMutation) AddedFields() []string {
  30421. var fields []string
  30422. if m.addstatus != nil {
  30423. fields = append(fields, usagestatisticday.FieldStatus)
  30424. }
  30425. if m.addaddtime != nil {
  30426. fields = append(fields, usagestatisticday.FieldAddtime)
  30427. }
  30428. if m.add_type != nil {
  30429. fields = append(fields, usagestatisticday.FieldType)
  30430. }
  30431. if m.addorganization_id != nil {
  30432. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30433. }
  30434. if m.addai_response != nil {
  30435. fields = append(fields, usagestatisticday.FieldAiResponse)
  30436. }
  30437. if m.addsop_run != nil {
  30438. fields = append(fields, usagestatisticday.FieldSopRun)
  30439. }
  30440. if m.addtotal_friend != nil {
  30441. fields = append(fields, usagestatisticday.FieldTotalFriend)
  30442. }
  30443. if m.addtotal_group != nil {
  30444. fields = append(fields, usagestatisticday.FieldTotalGroup)
  30445. }
  30446. if m.addaccount_balance != nil {
  30447. fields = append(fields, usagestatisticday.FieldAccountBalance)
  30448. }
  30449. if m.addconsume_token != nil {
  30450. fields = append(fields, usagestatisticday.FieldConsumeToken)
  30451. }
  30452. if m.addactive_user != nil {
  30453. fields = append(fields, usagestatisticday.FieldActiveUser)
  30454. }
  30455. if m.addnew_user != nil {
  30456. fields = append(fields, usagestatisticday.FieldNewUser)
  30457. }
  30458. return fields
  30459. }
  30460. // AddedField returns the numeric value that was incremented/decremented on a field
  30461. // with the given name. The second boolean return value indicates that this field
  30462. // was not set, or was not defined in the schema.
  30463. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  30464. switch name {
  30465. case usagestatisticday.FieldStatus:
  30466. return m.AddedStatus()
  30467. case usagestatisticday.FieldAddtime:
  30468. return m.AddedAddtime()
  30469. case usagestatisticday.FieldType:
  30470. return m.AddedType()
  30471. case usagestatisticday.FieldOrganizationID:
  30472. return m.AddedOrganizationID()
  30473. case usagestatisticday.FieldAiResponse:
  30474. return m.AddedAiResponse()
  30475. case usagestatisticday.FieldSopRun:
  30476. return m.AddedSopRun()
  30477. case usagestatisticday.FieldTotalFriend:
  30478. return m.AddedTotalFriend()
  30479. case usagestatisticday.FieldTotalGroup:
  30480. return m.AddedTotalGroup()
  30481. case usagestatisticday.FieldAccountBalance:
  30482. return m.AddedAccountBalance()
  30483. case usagestatisticday.FieldConsumeToken:
  30484. return m.AddedConsumeToken()
  30485. case usagestatisticday.FieldActiveUser:
  30486. return m.AddedActiveUser()
  30487. case usagestatisticday.FieldNewUser:
  30488. return m.AddedNewUser()
  30489. }
  30490. return nil, false
  30491. }
  30492. // AddField adds the value to the field with the given name. It returns an error if
  30493. // the field is not defined in the schema, or if the type mismatched the field
  30494. // type.
  30495. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  30496. switch name {
  30497. case usagestatisticday.FieldStatus:
  30498. v, ok := value.(int8)
  30499. if !ok {
  30500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30501. }
  30502. m.AddStatus(v)
  30503. return nil
  30504. case usagestatisticday.FieldAddtime:
  30505. v, ok := value.(int64)
  30506. if !ok {
  30507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30508. }
  30509. m.AddAddtime(v)
  30510. return nil
  30511. case usagestatisticday.FieldType:
  30512. v, ok := value.(int)
  30513. if !ok {
  30514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30515. }
  30516. m.AddType(v)
  30517. return nil
  30518. case usagestatisticday.FieldOrganizationID:
  30519. v, ok := value.(int64)
  30520. if !ok {
  30521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30522. }
  30523. m.AddOrganizationID(v)
  30524. return nil
  30525. case usagestatisticday.FieldAiResponse:
  30526. v, ok := value.(int64)
  30527. if !ok {
  30528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30529. }
  30530. m.AddAiResponse(v)
  30531. return nil
  30532. case usagestatisticday.FieldSopRun:
  30533. v, ok := value.(int64)
  30534. if !ok {
  30535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30536. }
  30537. m.AddSopRun(v)
  30538. return nil
  30539. case usagestatisticday.FieldTotalFriend:
  30540. v, ok := value.(int64)
  30541. if !ok {
  30542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30543. }
  30544. m.AddTotalFriend(v)
  30545. return nil
  30546. case usagestatisticday.FieldTotalGroup:
  30547. v, ok := value.(int64)
  30548. if !ok {
  30549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30550. }
  30551. m.AddTotalGroup(v)
  30552. return nil
  30553. case usagestatisticday.FieldAccountBalance:
  30554. v, ok := value.(int64)
  30555. if !ok {
  30556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30557. }
  30558. m.AddAccountBalance(v)
  30559. return nil
  30560. case usagestatisticday.FieldConsumeToken:
  30561. v, ok := value.(int64)
  30562. if !ok {
  30563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30564. }
  30565. m.AddConsumeToken(v)
  30566. return nil
  30567. case usagestatisticday.FieldActiveUser:
  30568. v, ok := value.(int64)
  30569. if !ok {
  30570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30571. }
  30572. m.AddActiveUser(v)
  30573. return nil
  30574. case usagestatisticday.FieldNewUser:
  30575. v, ok := value.(int64)
  30576. if !ok {
  30577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30578. }
  30579. m.AddNewUser(v)
  30580. return nil
  30581. }
  30582. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  30583. }
  30584. // ClearedFields returns all nullable fields that were cleared during this
  30585. // mutation.
  30586. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  30587. var fields []string
  30588. if m.FieldCleared(usagestatisticday.FieldStatus) {
  30589. fields = append(fields, usagestatisticday.FieldStatus)
  30590. }
  30591. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  30592. fields = append(fields, usagestatisticday.FieldDeletedAt)
  30593. }
  30594. if m.FieldCleared(usagestatisticday.FieldBotID) {
  30595. fields = append(fields, usagestatisticday.FieldBotID)
  30596. }
  30597. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  30598. fields = append(fields, usagestatisticday.FieldOrganizationID)
  30599. }
  30600. return fields
  30601. }
  30602. // FieldCleared returns a boolean indicating if a field with the given name was
  30603. // cleared in this mutation.
  30604. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  30605. _, ok := m.clearedFields[name]
  30606. return ok
  30607. }
  30608. // ClearField clears the value of the field with the given name. It returns an
  30609. // error if the field is not defined in the schema.
  30610. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  30611. switch name {
  30612. case usagestatisticday.FieldStatus:
  30613. m.ClearStatus()
  30614. return nil
  30615. case usagestatisticday.FieldDeletedAt:
  30616. m.ClearDeletedAt()
  30617. return nil
  30618. case usagestatisticday.FieldBotID:
  30619. m.ClearBotID()
  30620. return nil
  30621. case usagestatisticday.FieldOrganizationID:
  30622. m.ClearOrganizationID()
  30623. return nil
  30624. }
  30625. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  30626. }
  30627. // ResetField resets all changes in the mutation for the field with the given name.
  30628. // It returns an error if the field is not defined in the schema.
  30629. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  30630. switch name {
  30631. case usagestatisticday.FieldCreatedAt:
  30632. m.ResetCreatedAt()
  30633. return nil
  30634. case usagestatisticday.FieldUpdatedAt:
  30635. m.ResetUpdatedAt()
  30636. return nil
  30637. case usagestatisticday.FieldStatus:
  30638. m.ResetStatus()
  30639. return nil
  30640. case usagestatisticday.FieldDeletedAt:
  30641. m.ResetDeletedAt()
  30642. return nil
  30643. case usagestatisticday.FieldAddtime:
  30644. m.ResetAddtime()
  30645. return nil
  30646. case usagestatisticday.FieldType:
  30647. m.ResetType()
  30648. return nil
  30649. case usagestatisticday.FieldBotID:
  30650. m.ResetBotID()
  30651. return nil
  30652. case usagestatisticday.FieldOrganizationID:
  30653. m.ResetOrganizationID()
  30654. return nil
  30655. case usagestatisticday.FieldAiResponse:
  30656. m.ResetAiResponse()
  30657. return nil
  30658. case usagestatisticday.FieldSopRun:
  30659. m.ResetSopRun()
  30660. return nil
  30661. case usagestatisticday.FieldTotalFriend:
  30662. m.ResetTotalFriend()
  30663. return nil
  30664. case usagestatisticday.FieldTotalGroup:
  30665. m.ResetTotalGroup()
  30666. return nil
  30667. case usagestatisticday.FieldAccountBalance:
  30668. m.ResetAccountBalance()
  30669. return nil
  30670. case usagestatisticday.FieldConsumeToken:
  30671. m.ResetConsumeToken()
  30672. return nil
  30673. case usagestatisticday.FieldActiveUser:
  30674. m.ResetActiveUser()
  30675. return nil
  30676. case usagestatisticday.FieldNewUser:
  30677. m.ResetNewUser()
  30678. return nil
  30679. case usagestatisticday.FieldLabelDist:
  30680. m.ResetLabelDist()
  30681. return nil
  30682. }
  30683. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  30684. }
  30685. // AddedEdges returns all edge names that were set/added in this mutation.
  30686. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  30687. edges := make([]string, 0, 0)
  30688. return edges
  30689. }
  30690. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30691. // name in this mutation.
  30692. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  30693. return nil
  30694. }
  30695. // RemovedEdges returns all edge names that were removed in this mutation.
  30696. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  30697. edges := make([]string, 0, 0)
  30698. return edges
  30699. }
  30700. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30701. // the given name in this mutation.
  30702. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  30703. return nil
  30704. }
  30705. // ClearedEdges returns all edge names that were cleared in this mutation.
  30706. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  30707. edges := make([]string, 0, 0)
  30708. return edges
  30709. }
  30710. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30711. // was cleared in this mutation.
  30712. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  30713. return false
  30714. }
  30715. // ClearEdge clears the value of the edge with the given name. It returns an error
  30716. // if that edge is not defined in the schema.
  30717. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  30718. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  30719. }
  30720. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30721. // It returns an error if the edge is not defined in the schema.
  30722. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  30723. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  30724. }
  30725. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  30726. type UsageStatisticHourMutation struct {
  30727. config
  30728. op Op
  30729. typ string
  30730. id *uint64
  30731. created_at *time.Time
  30732. updated_at *time.Time
  30733. status *uint8
  30734. addstatus *int8
  30735. deleted_at *time.Time
  30736. addtime *uint64
  30737. addaddtime *int64
  30738. _type *int
  30739. add_type *int
  30740. bot_id *string
  30741. organization_id *uint64
  30742. addorganization_id *int64
  30743. ai_response *uint64
  30744. addai_response *int64
  30745. sop_run *uint64
  30746. addsop_run *int64
  30747. total_friend *uint64
  30748. addtotal_friend *int64
  30749. total_group *uint64
  30750. addtotal_group *int64
  30751. account_balance *uint64
  30752. addaccount_balance *int64
  30753. consume_token *uint64
  30754. addconsume_token *int64
  30755. active_user *uint64
  30756. addactive_user *int64
  30757. new_user *int64
  30758. addnew_user *int64
  30759. label_dist *[]custom_types.LabelDist
  30760. appendlabel_dist []custom_types.LabelDist
  30761. clearedFields map[string]struct{}
  30762. done bool
  30763. oldValue func(context.Context) (*UsageStatisticHour, error)
  30764. predicates []predicate.UsageStatisticHour
  30765. }
  30766. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  30767. // usagestatistichourOption allows management of the mutation configuration using functional options.
  30768. type usagestatistichourOption func(*UsageStatisticHourMutation)
  30769. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  30770. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  30771. m := &UsageStatisticHourMutation{
  30772. config: c,
  30773. op: op,
  30774. typ: TypeUsageStatisticHour,
  30775. clearedFields: make(map[string]struct{}),
  30776. }
  30777. for _, opt := range opts {
  30778. opt(m)
  30779. }
  30780. return m
  30781. }
  30782. // withUsageStatisticHourID sets the ID field of the mutation.
  30783. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  30784. return func(m *UsageStatisticHourMutation) {
  30785. var (
  30786. err error
  30787. once sync.Once
  30788. value *UsageStatisticHour
  30789. )
  30790. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  30791. once.Do(func() {
  30792. if m.done {
  30793. err = errors.New("querying old values post mutation is not allowed")
  30794. } else {
  30795. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  30796. }
  30797. })
  30798. return value, err
  30799. }
  30800. m.id = &id
  30801. }
  30802. }
  30803. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  30804. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  30805. return func(m *UsageStatisticHourMutation) {
  30806. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  30807. return node, nil
  30808. }
  30809. m.id = &node.ID
  30810. }
  30811. }
  30812. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30813. // executed in a transaction (ent.Tx), a transactional client is returned.
  30814. func (m UsageStatisticHourMutation) Client() *Client {
  30815. client := &Client{config: m.config}
  30816. client.init()
  30817. return client
  30818. }
  30819. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30820. // it returns an error otherwise.
  30821. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  30822. if _, ok := m.driver.(*txDriver); !ok {
  30823. return nil, errors.New("ent: mutation is not running in a transaction")
  30824. }
  30825. tx := &Tx{config: m.config}
  30826. tx.init()
  30827. return tx, nil
  30828. }
  30829. // SetID sets the value of the id field. Note that this
  30830. // operation is only accepted on creation of UsageStatisticHour entities.
  30831. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  30832. m.id = &id
  30833. }
  30834. // ID returns the ID value in the mutation. Note that the ID is only available
  30835. // if it was provided to the builder or after it was returned from the database.
  30836. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  30837. if m.id == nil {
  30838. return
  30839. }
  30840. return *m.id, true
  30841. }
  30842. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30843. // That means, if the mutation is applied within a transaction with an isolation level such
  30844. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30845. // or updated by the mutation.
  30846. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  30847. switch {
  30848. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30849. id, exists := m.ID()
  30850. if exists {
  30851. return []uint64{id}, nil
  30852. }
  30853. fallthrough
  30854. case m.op.Is(OpUpdate | OpDelete):
  30855. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  30856. default:
  30857. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30858. }
  30859. }
  30860. // SetCreatedAt sets the "created_at" field.
  30861. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  30862. m.created_at = &t
  30863. }
  30864. // CreatedAt returns the value of the "created_at" field in the mutation.
  30865. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  30866. v := m.created_at
  30867. if v == nil {
  30868. return
  30869. }
  30870. return *v, true
  30871. }
  30872. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  30873. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30875. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30876. if !m.op.Is(OpUpdateOne) {
  30877. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30878. }
  30879. if m.id == nil || m.oldValue == nil {
  30880. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30881. }
  30882. oldValue, err := m.oldValue(ctx)
  30883. if err != nil {
  30884. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30885. }
  30886. return oldValue.CreatedAt, nil
  30887. }
  30888. // ResetCreatedAt resets all changes to the "created_at" field.
  30889. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  30890. m.created_at = nil
  30891. }
  30892. // SetUpdatedAt sets the "updated_at" field.
  30893. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  30894. m.updated_at = &t
  30895. }
  30896. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30897. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  30898. v := m.updated_at
  30899. if v == nil {
  30900. return
  30901. }
  30902. return *v, true
  30903. }
  30904. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  30905. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30907. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30908. if !m.op.Is(OpUpdateOne) {
  30909. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30910. }
  30911. if m.id == nil || m.oldValue == nil {
  30912. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30913. }
  30914. oldValue, err := m.oldValue(ctx)
  30915. if err != nil {
  30916. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30917. }
  30918. return oldValue.UpdatedAt, nil
  30919. }
  30920. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30921. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  30922. m.updated_at = nil
  30923. }
  30924. // SetStatus sets the "status" field.
  30925. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  30926. m.status = &u
  30927. m.addstatus = nil
  30928. }
  30929. // Status returns the value of the "status" field in the mutation.
  30930. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  30931. v := m.status
  30932. if v == nil {
  30933. return
  30934. }
  30935. return *v, true
  30936. }
  30937. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  30938. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30940. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30941. if !m.op.Is(OpUpdateOne) {
  30942. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30943. }
  30944. if m.id == nil || m.oldValue == nil {
  30945. return v, errors.New("OldStatus requires an ID field in the mutation")
  30946. }
  30947. oldValue, err := m.oldValue(ctx)
  30948. if err != nil {
  30949. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30950. }
  30951. return oldValue.Status, nil
  30952. }
  30953. // AddStatus adds u to the "status" field.
  30954. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  30955. if m.addstatus != nil {
  30956. *m.addstatus += u
  30957. } else {
  30958. m.addstatus = &u
  30959. }
  30960. }
  30961. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30962. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  30963. v := m.addstatus
  30964. if v == nil {
  30965. return
  30966. }
  30967. return *v, true
  30968. }
  30969. // ClearStatus clears the value of the "status" field.
  30970. func (m *UsageStatisticHourMutation) ClearStatus() {
  30971. m.status = nil
  30972. m.addstatus = nil
  30973. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  30974. }
  30975. // StatusCleared returns if the "status" field was cleared in this mutation.
  30976. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  30977. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  30978. return ok
  30979. }
  30980. // ResetStatus resets all changes to the "status" field.
  30981. func (m *UsageStatisticHourMutation) ResetStatus() {
  30982. m.status = nil
  30983. m.addstatus = nil
  30984. delete(m.clearedFields, usagestatistichour.FieldStatus)
  30985. }
  30986. // SetDeletedAt sets the "deleted_at" field.
  30987. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  30988. m.deleted_at = &t
  30989. }
  30990. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30991. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  30992. v := m.deleted_at
  30993. if v == nil {
  30994. return
  30995. }
  30996. return *v, true
  30997. }
  30998. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  30999. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31001. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31002. if !m.op.Is(OpUpdateOne) {
  31003. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31004. }
  31005. if m.id == nil || m.oldValue == nil {
  31006. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31007. }
  31008. oldValue, err := m.oldValue(ctx)
  31009. if err != nil {
  31010. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31011. }
  31012. return oldValue.DeletedAt, nil
  31013. }
  31014. // ClearDeletedAt clears the value of the "deleted_at" field.
  31015. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  31016. m.deleted_at = nil
  31017. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  31018. }
  31019. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31020. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  31021. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  31022. return ok
  31023. }
  31024. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31025. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  31026. m.deleted_at = nil
  31027. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  31028. }
  31029. // SetAddtime sets the "addtime" field.
  31030. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  31031. m.addtime = &u
  31032. m.addaddtime = nil
  31033. }
  31034. // Addtime returns the value of the "addtime" field in the mutation.
  31035. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  31036. v := m.addtime
  31037. if v == nil {
  31038. return
  31039. }
  31040. return *v, true
  31041. }
  31042. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  31043. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31045. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31046. if !m.op.Is(OpUpdateOne) {
  31047. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31048. }
  31049. if m.id == nil || m.oldValue == nil {
  31050. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31051. }
  31052. oldValue, err := m.oldValue(ctx)
  31053. if err != nil {
  31054. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31055. }
  31056. return oldValue.Addtime, nil
  31057. }
  31058. // AddAddtime adds u to the "addtime" field.
  31059. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  31060. if m.addaddtime != nil {
  31061. *m.addaddtime += u
  31062. } else {
  31063. m.addaddtime = &u
  31064. }
  31065. }
  31066. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31067. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  31068. v := m.addaddtime
  31069. if v == nil {
  31070. return
  31071. }
  31072. return *v, true
  31073. }
  31074. // ResetAddtime resets all changes to the "addtime" field.
  31075. func (m *UsageStatisticHourMutation) ResetAddtime() {
  31076. m.addtime = nil
  31077. m.addaddtime = nil
  31078. }
  31079. // SetType sets the "type" field.
  31080. func (m *UsageStatisticHourMutation) SetType(i int) {
  31081. m._type = &i
  31082. m.add_type = nil
  31083. }
  31084. // GetType returns the value of the "type" field in the mutation.
  31085. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  31086. v := m._type
  31087. if v == nil {
  31088. return
  31089. }
  31090. return *v, true
  31091. }
  31092. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  31093. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31095. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  31096. if !m.op.Is(OpUpdateOne) {
  31097. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31098. }
  31099. if m.id == nil || m.oldValue == nil {
  31100. return v, errors.New("OldType requires an ID field in the mutation")
  31101. }
  31102. oldValue, err := m.oldValue(ctx)
  31103. if err != nil {
  31104. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31105. }
  31106. return oldValue.Type, nil
  31107. }
  31108. // AddType adds i to the "type" field.
  31109. func (m *UsageStatisticHourMutation) AddType(i int) {
  31110. if m.add_type != nil {
  31111. *m.add_type += i
  31112. } else {
  31113. m.add_type = &i
  31114. }
  31115. }
  31116. // AddedType returns the value that was added to the "type" field in this mutation.
  31117. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  31118. v := m.add_type
  31119. if v == nil {
  31120. return
  31121. }
  31122. return *v, true
  31123. }
  31124. // ResetType resets all changes to the "type" field.
  31125. func (m *UsageStatisticHourMutation) ResetType() {
  31126. m._type = nil
  31127. m.add_type = nil
  31128. }
  31129. // SetBotID sets the "bot_id" field.
  31130. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  31131. m.bot_id = &s
  31132. }
  31133. // BotID returns the value of the "bot_id" field in the mutation.
  31134. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  31135. v := m.bot_id
  31136. if v == nil {
  31137. return
  31138. }
  31139. return *v, true
  31140. }
  31141. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  31142. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31144. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  31145. if !m.op.Is(OpUpdateOne) {
  31146. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31147. }
  31148. if m.id == nil || m.oldValue == nil {
  31149. return v, errors.New("OldBotID requires an ID field in the mutation")
  31150. }
  31151. oldValue, err := m.oldValue(ctx)
  31152. if err != nil {
  31153. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31154. }
  31155. return oldValue.BotID, nil
  31156. }
  31157. // ClearBotID clears the value of the "bot_id" field.
  31158. func (m *UsageStatisticHourMutation) ClearBotID() {
  31159. m.bot_id = nil
  31160. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  31161. }
  31162. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31163. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  31164. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  31165. return ok
  31166. }
  31167. // ResetBotID resets all changes to the "bot_id" field.
  31168. func (m *UsageStatisticHourMutation) ResetBotID() {
  31169. m.bot_id = nil
  31170. delete(m.clearedFields, usagestatistichour.FieldBotID)
  31171. }
  31172. // SetOrganizationID sets the "organization_id" field.
  31173. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  31174. m.organization_id = &u
  31175. m.addorganization_id = nil
  31176. }
  31177. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31178. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  31179. v := m.organization_id
  31180. if v == nil {
  31181. return
  31182. }
  31183. return *v, true
  31184. }
  31185. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  31186. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31188. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31189. if !m.op.Is(OpUpdateOne) {
  31190. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31191. }
  31192. if m.id == nil || m.oldValue == nil {
  31193. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31194. }
  31195. oldValue, err := m.oldValue(ctx)
  31196. if err != nil {
  31197. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31198. }
  31199. return oldValue.OrganizationID, nil
  31200. }
  31201. // AddOrganizationID adds u to the "organization_id" field.
  31202. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  31203. if m.addorganization_id != nil {
  31204. *m.addorganization_id += u
  31205. } else {
  31206. m.addorganization_id = &u
  31207. }
  31208. }
  31209. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31210. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  31211. v := m.addorganization_id
  31212. if v == nil {
  31213. return
  31214. }
  31215. return *v, true
  31216. }
  31217. // ClearOrganizationID clears the value of the "organization_id" field.
  31218. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  31219. m.organization_id = nil
  31220. m.addorganization_id = nil
  31221. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  31222. }
  31223. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31224. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  31225. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  31226. return ok
  31227. }
  31228. // ResetOrganizationID resets all changes to the "organization_id" field.
  31229. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  31230. m.organization_id = nil
  31231. m.addorganization_id = nil
  31232. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  31233. }
  31234. // SetAiResponse sets the "ai_response" field.
  31235. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  31236. m.ai_response = &u
  31237. m.addai_response = nil
  31238. }
  31239. // AiResponse returns the value of the "ai_response" field in the mutation.
  31240. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  31241. v := m.ai_response
  31242. if v == nil {
  31243. return
  31244. }
  31245. return *v, true
  31246. }
  31247. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  31248. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31250. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31251. if !m.op.Is(OpUpdateOne) {
  31252. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31253. }
  31254. if m.id == nil || m.oldValue == nil {
  31255. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31256. }
  31257. oldValue, err := m.oldValue(ctx)
  31258. if err != nil {
  31259. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31260. }
  31261. return oldValue.AiResponse, nil
  31262. }
  31263. // AddAiResponse adds u to the "ai_response" field.
  31264. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  31265. if m.addai_response != nil {
  31266. *m.addai_response += u
  31267. } else {
  31268. m.addai_response = &u
  31269. }
  31270. }
  31271. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31272. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  31273. v := m.addai_response
  31274. if v == nil {
  31275. return
  31276. }
  31277. return *v, true
  31278. }
  31279. // ResetAiResponse resets all changes to the "ai_response" field.
  31280. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  31281. m.ai_response = nil
  31282. m.addai_response = nil
  31283. }
  31284. // SetSopRun sets the "sop_run" field.
  31285. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  31286. m.sop_run = &u
  31287. m.addsop_run = nil
  31288. }
  31289. // SopRun returns the value of the "sop_run" field in the mutation.
  31290. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  31291. v := m.sop_run
  31292. if v == nil {
  31293. return
  31294. }
  31295. return *v, true
  31296. }
  31297. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  31298. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31300. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31301. if !m.op.Is(OpUpdateOne) {
  31302. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31303. }
  31304. if m.id == nil || m.oldValue == nil {
  31305. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31306. }
  31307. oldValue, err := m.oldValue(ctx)
  31308. if err != nil {
  31309. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31310. }
  31311. return oldValue.SopRun, nil
  31312. }
  31313. // AddSopRun adds u to the "sop_run" field.
  31314. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  31315. if m.addsop_run != nil {
  31316. *m.addsop_run += u
  31317. } else {
  31318. m.addsop_run = &u
  31319. }
  31320. }
  31321. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31322. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  31323. v := m.addsop_run
  31324. if v == nil {
  31325. return
  31326. }
  31327. return *v, true
  31328. }
  31329. // ResetSopRun resets all changes to the "sop_run" field.
  31330. func (m *UsageStatisticHourMutation) ResetSopRun() {
  31331. m.sop_run = nil
  31332. m.addsop_run = nil
  31333. }
  31334. // SetTotalFriend sets the "total_friend" field.
  31335. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  31336. m.total_friend = &u
  31337. m.addtotal_friend = nil
  31338. }
  31339. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31340. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  31341. v := m.total_friend
  31342. if v == nil {
  31343. return
  31344. }
  31345. return *v, true
  31346. }
  31347. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  31348. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31350. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31351. if !m.op.Is(OpUpdateOne) {
  31352. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31353. }
  31354. if m.id == nil || m.oldValue == nil {
  31355. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31356. }
  31357. oldValue, err := m.oldValue(ctx)
  31358. if err != nil {
  31359. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31360. }
  31361. return oldValue.TotalFriend, nil
  31362. }
  31363. // AddTotalFriend adds u to the "total_friend" field.
  31364. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  31365. if m.addtotal_friend != nil {
  31366. *m.addtotal_friend += u
  31367. } else {
  31368. m.addtotal_friend = &u
  31369. }
  31370. }
  31371. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31372. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  31373. v := m.addtotal_friend
  31374. if v == nil {
  31375. return
  31376. }
  31377. return *v, true
  31378. }
  31379. // ResetTotalFriend resets all changes to the "total_friend" field.
  31380. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  31381. m.total_friend = nil
  31382. m.addtotal_friend = nil
  31383. }
  31384. // SetTotalGroup sets the "total_group" field.
  31385. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  31386. m.total_group = &u
  31387. m.addtotal_group = nil
  31388. }
  31389. // TotalGroup returns the value of the "total_group" field in the mutation.
  31390. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  31391. v := m.total_group
  31392. if v == nil {
  31393. return
  31394. }
  31395. return *v, true
  31396. }
  31397. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  31398. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31400. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31401. if !m.op.Is(OpUpdateOne) {
  31402. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31403. }
  31404. if m.id == nil || m.oldValue == nil {
  31405. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31406. }
  31407. oldValue, err := m.oldValue(ctx)
  31408. if err != nil {
  31409. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31410. }
  31411. return oldValue.TotalGroup, nil
  31412. }
  31413. // AddTotalGroup adds u to the "total_group" field.
  31414. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  31415. if m.addtotal_group != nil {
  31416. *m.addtotal_group += u
  31417. } else {
  31418. m.addtotal_group = &u
  31419. }
  31420. }
  31421. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31422. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  31423. v := m.addtotal_group
  31424. if v == nil {
  31425. return
  31426. }
  31427. return *v, true
  31428. }
  31429. // ResetTotalGroup resets all changes to the "total_group" field.
  31430. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  31431. m.total_group = nil
  31432. m.addtotal_group = nil
  31433. }
  31434. // SetAccountBalance sets the "account_balance" field.
  31435. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  31436. m.account_balance = &u
  31437. m.addaccount_balance = nil
  31438. }
  31439. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31440. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  31441. v := m.account_balance
  31442. if v == nil {
  31443. return
  31444. }
  31445. return *v, true
  31446. }
  31447. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  31448. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31450. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31451. if !m.op.Is(OpUpdateOne) {
  31452. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31453. }
  31454. if m.id == nil || m.oldValue == nil {
  31455. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31456. }
  31457. oldValue, err := m.oldValue(ctx)
  31458. if err != nil {
  31459. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31460. }
  31461. return oldValue.AccountBalance, nil
  31462. }
  31463. // AddAccountBalance adds u to the "account_balance" field.
  31464. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  31465. if m.addaccount_balance != nil {
  31466. *m.addaccount_balance += u
  31467. } else {
  31468. m.addaccount_balance = &u
  31469. }
  31470. }
  31471. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31472. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  31473. v := m.addaccount_balance
  31474. if v == nil {
  31475. return
  31476. }
  31477. return *v, true
  31478. }
  31479. // ResetAccountBalance resets all changes to the "account_balance" field.
  31480. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  31481. m.account_balance = nil
  31482. m.addaccount_balance = nil
  31483. }
  31484. // SetConsumeToken sets the "consume_token" field.
  31485. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  31486. m.consume_token = &u
  31487. m.addconsume_token = nil
  31488. }
  31489. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31490. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  31491. v := m.consume_token
  31492. if v == nil {
  31493. return
  31494. }
  31495. return *v, true
  31496. }
  31497. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  31498. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31500. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31501. if !m.op.Is(OpUpdateOne) {
  31502. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31503. }
  31504. if m.id == nil || m.oldValue == nil {
  31505. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31506. }
  31507. oldValue, err := m.oldValue(ctx)
  31508. if err != nil {
  31509. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31510. }
  31511. return oldValue.ConsumeToken, nil
  31512. }
  31513. // AddConsumeToken adds u to the "consume_token" field.
  31514. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  31515. if m.addconsume_token != nil {
  31516. *m.addconsume_token += u
  31517. } else {
  31518. m.addconsume_token = &u
  31519. }
  31520. }
  31521. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31522. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  31523. v := m.addconsume_token
  31524. if v == nil {
  31525. return
  31526. }
  31527. return *v, true
  31528. }
  31529. // ResetConsumeToken resets all changes to the "consume_token" field.
  31530. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  31531. m.consume_token = nil
  31532. m.addconsume_token = nil
  31533. }
  31534. // SetActiveUser sets the "active_user" field.
  31535. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  31536. m.active_user = &u
  31537. m.addactive_user = nil
  31538. }
  31539. // ActiveUser returns the value of the "active_user" field in the mutation.
  31540. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  31541. v := m.active_user
  31542. if v == nil {
  31543. return
  31544. }
  31545. return *v, true
  31546. }
  31547. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  31548. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31550. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31551. if !m.op.Is(OpUpdateOne) {
  31552. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31553. }
  31554. if m.id == nil || m.oldValue == nil {
  31555. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31556. }
  31557. oldValue, err := m.oldValue(ctx)
  31558. if err != nil {
  31559. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31560. }
  31561. return oldValue.ActiveUser, nil
  31562. }
  31563. // AddActiveUser adds u to the "active_user" field.
  31564. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  31565. if m.addactive_user != nil {
  31566. *m.addactive_user += u
  31567. } else {
  31568. m.addactive_user = &u
  31569. }
  31570. }
  31571. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31572. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  31573. v := m.addactive_user
  31574. if v == nil {
  31575. return
  31576. }
  31577. return *v, true
  31578. }
  31579. // ResetActiveUser resets all changes to the "active_user" field.
  31580. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  31581. m.active_user = nil
  31582. m.addactive_user = nil
  31583. }
  31584. // SetNewUser sets the "new_user" field.
  31585. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  31586. m.new_user = &i
  31587. m.addnew_user = nil
  31588. }
  31589. // NewUser returns the value of the "new_user" field in the mutation.
  31590. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  31591. v := m.new_user
  31592. if v == nil {
  31593. return
  31594. }
  31595. return *v, true
  31596. }
  31597. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  31598. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31600. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31601. if !m.op.Is(OpUpdateOne) {
  31602. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31603. }
  31604. if m.id == nil || m.oldValue == nil {
  31605. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31606. }
  31607. oldValue, err := m.oldValue(ctx)
  31608. if err != nil {
  31609. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31610. }
  31611. return oldValue.NewUser, nil
  31612. }
  31613. // AddNewUser adds i to the "new_user" field.
  31614. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  31615. if m.addnew_user != nil {
  31616. *m.addnew_user += i
  31617. } else {
  31618. m.addnew_user = &i
  31619. }
  31620. }
  31621. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31622. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  31623. v := m.addnew_user
  31624. if v == nil {
  31625. return
  31626. }
  31627. return *v, true
  31628. }
  31629. // ResetNewUser resets all changes to the "new_user" field.
  31630. func (m *UsageStatisticHourMutation) ResetNewUser() {
  31631. m.new_user = nil
  31632. m.addnew_user = nil
  31633. }
  31634. // SetLabelDist sets the "label_dist" field.
  31635. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31636. m.label_dist = &ctd
  31637. m.appendlabel_dist = nil
  31638. }
  31639. // LabelDist returns the value of the "label_dist" field in the mutation.
  31640. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31641. v := m.label_dist
  31642. if v == nil {
  31643. return
  31644. }
  31645. return *v, true
  31646. }
  31647. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  31648. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  31649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31650. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31651. if !m.op.Is(OpUpdateOne) {
  31652. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31653. }
  31654. if m.id == nil || m.oldValue == nil {
  31655. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31656. }
  31657. oldValue, err := m.oldValue(ctx)
  31658. if err != nil {
  31659. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31660. }
  31661. return oldValue.LabelDist, nil
  31662. }
  31663. // AppendLabelDist adds ctd to the "label_dist" field.
  31664. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31665. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31666. }
  31667. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31668. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31669. if len(m.appendlabel_dist) == 0 {
  31670. return nil, false
  31671. }
  31672. return m.appendlabel_dist, true
  31673. }
  31674. // ResetLabelDist resets all changes to the "label_dist" field.
  31675. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  31676. m.label_dist = nil
  31677. m.appendlabel_dist = nil
  31678. }
  31679. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  31680. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  31681. m.predicates = append(m.predicates, ps...)
  31682. }
  31683. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  31684. // users can use type-assertion to append predicates that do not depend on any generated package.
  31685. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  31686. p := make([]predicate.UsageStatisticHour, len(ps))
  31687. for i := range ps {
  31688. p[i] = ps[i]
  31689. }
  31690. m.Where(p...)
  31691. }
  31692. // Op returns the operation name.
  31693. func (m *UsageStatisticHourMutation) Op() Op {
  31694. return m.op
  31695. }
  31696. // SetOp allows setting the mutation operation.
  31697. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  31698. m.op = op
  31699. }
  31700. // Type returns the node type of this mutation (UsageStatisticHour).
  31701. func (m *UsageStatisticHourMutation) Type() string {
  31702. return m.typ
  31703. }
  31704. // Fields returns all fields that were changed during this mutation. Note that in
  31705. // order to get all numeric fields that were incremented/decremented, call
  31706. // AddedFields().
  31707. func (m *UsageStatisticHourMutation) Fields() []string {
  31708. fields := make([]string, 0, 17)
  31709. if m.created_at != nil {
  31710. fields = append(fields, usagestatistichour.FieldCreatedAt)
  31711. }
  31712. if m.updated_at != nil {
  31713. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  31714. }
  31715. if m.status != nil {
  31716. fields = append(fields, usagestatistichour.FieldStatus)
  31717. }
  31718. if m.deleted_at != nil {
  31719. fields = append(fields, usagestatistichour.FieldDeletedAt)
  31720. }
  31721. if m.addtime != nil {
  31722. fields = append(fields, usagestatistichour.FieldAddtime)
  31723. }
  31724. if m._type != nil {
  31725. fields = append(fields, usagestatistichour.FieldType)
  31726. }
  31727. if m.bot_id != nil {
  31728. fields = append(fields, usagestatistichour.FieldBotID)
  31729. }
  31730. if m.organization_id != nil {
  31731. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31732. }
  31733. if m.ai_response != nil {
  31734. fields = append(fields, usagestatistichour.FieldAiResponse)
  31735. }
  31736. if m.sop_run != nil {
  31737. fields = append(fields, usagestatistichour.FieldSopRun)
  31738. }
  31739. if m.total_friend != nil {
  31740. fields = append(fields, usagestatistichour.FieldTotalFriend)
  31741. }
  31742. if m.total_group != nil {
  31743. fields = append(fields, usagestatistichour.FieldTotalGroup)
  31744. }
  31745. if m.account_balance != nil {
  31746. fields = append(fields, usagestatistichour.FieldAccountBalance)
  31747. }
  31748. if m.consume_token != nil {
  31749. fields = append(fields, usagestatistichour.FieldConsumeToken)
  31750. }
  31751. if m.active_user != nil {
  31752. fields = append(fields, usagestatistichour.FieldActiveUser)
  31753. }
  31754. if m.new_user != nil {
  31755. fields = append(fields, usagestatistichour.FieldNewUser)
  31756. }
  31757. if m.label_dist != nil {
  31758. fields = append(fields, usagestatistichour.FieldLabelDist)
  31759. }
  31760. return fields
  31761. }
  31762. // Field returns the value of a field with the given name. The second boolean
  31763. // return value indicates that this field was not set, or was not defined in the
  31764. // schema.
  31765. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  31766. switch name {
  31767. case usagestatistichour.FieldCreatedAt:
  31768. return m.CreatedAt()
  31769. case usagestatistichour.FieldUpdatedAt:
  31770. return m.UpdatedAt()
  31771. case usagestatistichour.FieldStatus:
  31772. return m.Status()
  31773. case usagestatistichour.FieldDeletedAt:
  31774. return m.DeletedAt()
  31775. case usagestatistichour.FieldAddtime:
  31776. return m.Addtime()
  31777. case usagestatistichour.FieldType:
  31778. return m.GetType()
  31779. case usagestatistichour.FieldBotID:
  31780. return m.BotID()
  31781. case usagestatistichour.FieldOrganizationID:
  31782. return m.OrganizationID()
  31783. case usagestatistichour.FieldAiResponse:
  31784. return m.AiResponse()
  31785. case usagestatistichour.FieldSopRun:
  31786. return m.SopRun()
  31787. case usagestatistichour.FieldTotalFriend:
  31788. return m.TotalFriend()
  31789. case usagestatistichour.FieldTotalGroup:
  31790. return m.TotalGroup()
  31791. case usagestatistichour.FieldAccountBalance:
  31792. return m.AccountBalance()
  31793. case usagestatistichour.FieldConsumeToken:
  31794. return m.ConsumeToken()
  31795. case usagestatistichour.FieldActiveUser:
  31796. return m.ActiveUser()
  31797. case usagestatistichour.FieldNewUser:
  31798. return m.NewUser()
  31799. case usagestatistichour.FieldLabelDist:
  31800. return m.LabelDist()
  31801. }
  31802. return nil, false
  31803. }
  31804. // OldField returns the old value of the field from the database. An error is
  31805. // returned if the mutation operation is not UpdateOne, or the query to the
  31806. // database failed.
  31807. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31808. switch name {
  31809. case usagestatistichour.FieldCreatedAt:
  31810. return m.OldCreatedAt(ctx)
  31811. case usagestatistichour.FieldUpdatedAt:
  31812. return m.OldUpdatedAt(ctx)
  31813. case usagestatistichour.FieldStatus:
  31814. return m.OldStatus(ctx)
  31815. case usagestatistichour.FieldDeletedAt:
  31816. return m.OldDeletedAt(ctx)
  31817. case usagestatistichour.FieldAddtime:
  31818. return m.OldAddtime(ctx)
  31819. case usagestatistichour.FieldType:
  31820. return m.OldType(ctx)
  31821. case usagestatistichour.FieldBotID:
  31822. return m.OldBotID(ctx)
  31823. case usagestatistichour.FieldOrganizationID:
  31824. return m.OldOrganizationID(ctx)
  31825. case usagestatistichour.FieldAiResponse:
  31826. return m.OldAiResponse(ctx)
  31827. case usagestatistichour.FieldSopRun:
  31828. return m.OldSopRun(ctx)
  31829. case usagestatistichour.FieldTotalFriend:
  31830. return m.OldTotalFriend(ctx)
  31831. case usagestatistichour.FieldTotalGroup:
  31832. return m.OldTotalGroup(ctx)
  31833. case usagestatistichour.FieldAccountBalance:
  31834. return m.OldAccountBalance(ctx)
  31835. case usagestatistichour.FieldConsumeToken:
  31836. return m.OldConsumeToken(ctx)
  31837. case usagestatistichour.FieldActiveUser:
  31838. return m.OldActiveUser(ctx)
  31839. case usagestatistichour.FieldNewUser:
  31840. return m.OldNewUser(ctx)
  31841. case usagestatistichour.FieldLabelDist:
  31842. return m.OldLabelDist(ctx)
  31843. }
  31844. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31845. }
  31846. // SetField sets the value of a field with the given name. It returns an error if
  31847. // the field is not defined in the schema, or if the type mismatched the field
  31848. // type.
  31849. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  31850. switch name {
  31851. case usagestatistichour.FieldCreatedAt:
  31852. v, ok := value.(time.Time)
  31853. if !ok {
  31854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31855. }
  31856. m.SetCreatedAt(v)
  31857. return nil
  31858. case usagestatistichour.FieldUpdatedAt:
  31859. v, ok := value.(time.Time)
  31860. if !ok {
  31861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31862. }
  31863. m.SetUpdatedAt(v)
  31864. return nil
  31865. case usagestatistichour.FieldStatus:
  31866. v, ok := value.(uint8)
  31867. if !ok {
  31868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31869. }
  31870. m.SetStatus(v)
  31871. return nil
  31872. case usagestatistichour.FieldDeletedAt:
  31873. v, ok := value.(time.Time)
  31874. if !ok {
  31875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31876. }
  31877. m.SetDeletedAt(v)
  31878. return nil
  31879. case usagestatistichour.FieldAddtime:
  31880. v, ok := value.(uint64)
  31881. if !ok {
  31882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31883. }
  31884. m.SetAddtime(v)
  31885. return nil
  31886. case usagestatistichour.FieldType:
  31887. v, ok := value.(int)
  31888. if !ok {
  31889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31890. }
  31891. m.SetType(v)
  31892. return nil
  31893. case usagestatistichour.FieldBotID:
  31894. v, ok := value.(string)
  31895. if !ok {
  31896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31897. }
  31898. m.SetBotID(v)
  31899. return nil
  31900. case usagestatistichour.FieldOrganizationID:
  31901. v, ok := value.(uint64)
  31902. if !ok {
  31903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31904. }
  31905. m.SetOrganizationID(v)
  31906. return nil
  31907. case usagestatistichour.FieldAiResponse:
  31908. v, ok := value.(uint64)
  31909. if !ok {
  31910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31911. }
  31912. m.SetAiResponse(v)
  31913. return nil
  31914. case usagestatistichour.FieldSopRun:
  31915. v, ok := value.(uint64)
  31916. if !ok {
  31917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31918. }
  31919. m.SetSopRun(v)
  31920. return nil
  31921. case usagestatistichour.FieldTotalFriend:
  31922. v, ok := value.(uint64)
  31923. if !ok {
  31924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31925. }
  31926. m.SetTotalFriend(v)
  31927. return nil
  31928. case usagestatistichour.FieldTotalGroup:
  31929. v, ok := value.(uint64)
  31930. if !ok {
  31931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31932. }
  31933. m.SetTotalGroup(v)
  31934. return nil
  31935. case usagestatistichour.FieldAccountBalance:
  31936. v, ok := value.(uint64)
  31937. if !ok {
  31938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31939. }
  31940. m.SetAccountBalance(v)
  31941. return nil
  31942. case usagestatistichour.FieldConsumeToken:
  31943. v, ok := value.(uint64)
  31944. if !ok {
  31945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31946. }
  31947. m.SetConsumeToken(v)
  31948. return nil
  31949. case usagestatistichour.FieldActiveUser:
  31950. v, ok := value.(uint64)
  31951. if !ok {
  31952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31953. }
  31954. m.SetActiveUser(v)
  31955. return nil
  31956. case usagestatistichour.FieldNewUser:
  31957. v, ok := value.(int64)
  31958. if !ok {
  31959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31960. }
  31961. m.SetNewUser(v)
  31962. return nil
  31963. case usagestatistichour.FieldLabelDist:
  31964. v, ok := value.([]custom_types.LabelDist)
  31965. if !ok {
  31966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31967. }
  31968. m.SetLabelDist(v)
  31969. return nil
  31970. }
  31971. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31972. }
  31973. // AddedFields returns all numeric fields that were incremented/decremented during
  31974. // this mutation.
  31975. func (m *UsageStatisticHourMutation) AddedFields() []string {
  31976. var fields []string
  31977. if m.addstatus != nil {
  31978. fields = append(fields, usagestatistichour.FieldStatus)
  31979. }
  31980. if m.addaddtime != nil {
  31981. fields = append(fields, usagestatistichour.FieldAddtime)
  31982. }
  31983. if m.add_type != nil {
  31984. fields = append(fields, usagestatistichour.FieldType)
  31985. }
  31986. if m.addorganization_id != nil {
  31987. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31988. }
  31989. if m.addai_response != nil {
  31990. fields = append(fields, usagestatistichour.FieldAiResponse)
  31991. }
  31992. if m.addsop_run != nil {
  31993. fields = append(fields, usagestatistichour.FieldSopRun)
  31994. }
  31995. if m.addtotal_friend != nil {
  31996. fields = append(fields, usagestatistichour.FieldTotalFriend)
  31997. }
  31998. if m.addtotal_group != nil {
  31999. fields = append(fields, usagestatistichour.FieldTotalGroup)
  32000. }
  32001. if m.addaccount_balance != nil {
  32002. fields = append(fields, usagestatistichour.FieldAccountBalance)
  32003. }
  32004. if m.addconsume_token != nil {
  32005. fields = append(fields, usagestatistichour.FieldConsumeToken)
  32006. }
  32007. if m.addactive_user != nil {
  32008. fields = append(fields, usagestatistichour.FieldActiveUser)
  32009. }
  32010. if m.addnew_user != nil {
  32011. fields = append(fields, usagestatistichour.FieldNewUser)
  32012. }
  32013. return fields
  32014. }
  32015. // AddedField returns the numeric value that was incremented/decremented on a field
  32016. // with the given name. The second boolean return value indicates that this field
  32017. // was not set, or was not defined in the schema.
  32018. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  32019. switch name {
  32020. case usagestatistichour.FieldStatus:
  32021. return m.AddedStatus()
  32022. case usagestatistichour.FieldAddtime:
  32023. return m.AddedAddtime()
  32024. case usagestatistichour.FieldType:
  32025. return m.AddedType()
  32026. case usagestatistichour.FieldOrganizationID:
  32027. return m.AddedOrganizationID()
  32028. case usagestatistichour.FieldAiResponse:
  32029. return m.AddedAiResponse()
  32030. case usagestatistichour.FieldSopRun:
  32031. return m.AddedSopRun()
  32032. case usagestatistichour.FieldTotalFriend:
  32033. return m.AddedTotalFriend()
  32034. case usagestatistichour.FieldTotalGroup:
  32035. return m.AddedTotalGroup()
  32036. case usagestatistichour.FieldAccountBalance:
  32037. return m.AddedAccountBalance()
  32038. case usagestatistichour.FieldConsumeToken:
  32039. return m.AddedConsumeToken()
  32040. case usagestatistichour.FieldActiveUser:
  32041. return m.AddedActiveUser()
  32042. case usagestatistichour.FieldNewUser:
  32043. return m.AddedNewUser()
  32044. }
  32045. return nil, false
  32046. }
  32047. // AddField adds the value to the field with the given name. It returns an error if
  32048. // the field is not defined in the schema, or if the type mismatched the field
  32049. // type.
  32050. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  32051. switch name {
  32052. case usagestatistichour.FieldStatus:
  32053. v, ok := value.(int8)
  32054. if !ok {
  32055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32056. }
  32057. m.AddStatus(v)
  32058. return nil
  32059. case usagestatistichour.FieldAddtime:
  32060. v, ok := value.(int64)
  32061. if !ok {
  32062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32063. }
  32064. m.AddAddtime(v)
  32065. return nil
  32066. case usagestatistichour.FieldType:
  32067. v, ok := value.(int)
  32068. if !ok {
  32069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32070. }
  32071. m.AddType(v)
  32072. return nil
  32073. case usagestatistichour.FieldOrganizationID:
  32074. v, ok := value.(int64)
  32075. if !ok {
  32076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32077. }
  32078. m.AddOrganizationID(v)
  32079. return nil
  32080. case usagestatistichour.FieldAiResponse:
  32081. v, ok := value.(int64)
  32082. if !ok {
  32083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32084. }
  32085. m.AddAiResponse(v)
  32086. return nil
  32087. case usagestatistichour.FieldSopRun:
  32088. v, ok := value.(int64)
  32089. if !ok {
  32090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32091. }
  32092. m.AddSopRun(v)
  32093. return nil
  32094. case usagestatistichour.FieldTotalFriend:
  32095. v, ok := value.(int64)
  32096. if !ok {
  32097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32098. }
  32099. m.AddTotalFriend(v)
  32100. return nil
  32101. case usagestatistichour.FieldTotalGroup:
  32102. v, ok := value.(int64)
  32103. if !ok {
  32104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32105. }
  32106. m.AddTotalGroup(v)
  32107. return nil
  32108. case usagestatistichour.FieldAccountBalance:
  32109. v, ok := value.(int64)
  32110. if !ok {
  32111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32112. }
  32113. m.AddAccountBalance(v)
  32114. return nil
  32115. case usagestatistichour.FieldConsumeToken:
  32116. v, ok := value.(int64)
  32117. if !ok {
  32118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32119. }
  32120. m.AddConsumeToken(v)
  32121. return nil
  32122. case usagestatistichour.FieldActiveUser:
  32123. v, ok := value.(int64)
  32124. if !ok {
  32125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32126. }
  32127. m.AddActiveUser(v)
  32128. return nil
  32129. case usagestatistichour.FieldNewUser:
  32130. v, ok := value.(int64)
  32131. if !ok {
  32132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32133. }
  32134. m.AddNewUser(v)
  32135. return nil
  32136. }
  32137. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  32138. }
  32139. // ClearedFields returns all nullable fields that were cleared during this
  32140. // mutation.
  32141. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  32142. var fields []string
  32143. if m.FieldCleared(usagestatistichour.FieldStatus) {
  32144. fields = append(fields, usagestatistichour.FieldStatus)
  32145. }
  32146. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  32147. fields = append(fields, usagestatistichour.FieldDeletedAt)
  32148. }
  32149. if m.FieldCleared(usagestatistichour.FieldBotID) {
  32150. fields = append(fields, usagestatistichour.FieldBotID)
  32151. }
  32152. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  32153. fields = append(fields, usagestatistichour.FieldOrganizationID)
  32154. }
  32155. return fields
  32156. }
  32157. // FieldCleared returns a boolean indicating if a field with the given name was
  32158. // cleared in this mutation.
  32159. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  32160. _, ok := m.clearedFields[name]
  32161. return ok
  32162. }
  32163. // ClearField clears the value of the field with the given name. It returns an
  32164. // error if the field is not defined in the schema.
  32165. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  32166. switch name {
  32167. case usagestatistichour.FieldStatus:
  32168. m.ClearStatus()
  32169. return nil
  32170. case usagestatistichour.FieldDeletedAt:
  32171. m.ClearDeletedAt()
  32172. return nil
  32173. case usagestatistichour.FieldBotID:
  32174. m.ClearBotID()
  32175. return nil
  32176. case usagestatistichour.FieldOrganizationID:
  32177. m.ClearOrganizationID()
  32178. return nil
  32179. }
  32180. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  32181. }
  32182. // ResetField resets all changes in the mutation for the field with the given name.
  32183. // It returns an error if the field is not defined in the schema.
  32184. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  32185. switch name {
  32186. case usagestatistichour.FieldCreatedAt:
  32187. m.ResetCreatedAt()
  32188. return nil
  32189. case usagestatistichour.FieldUpdatedAt:
  32190. m.ResetUpdatedAt()
  32191. return nil
  32192. case usagestatistichour.FieldStatus:
  32193. m.ResetStatus()
  32194. return nil
  32195. case usagestatistichour.FieldDeletedAt:
  32196. m.ResetDeletedAt()
  32197. return nil
  32198. case usagestatistichour.FieldAddtime:
  32199. m.ResetAddtime()
  32200. return nil
  32201. case usagestatistichour.FieldType:
  32202. m.ResetType()
  32203. return nil
  32204. case usagestatistichour.FieldBotID:
  32205. m.ResetBotID()
  32206. return nil
  32207. case usagestatistichour.FieldOrganizationID:
  32208. m.ResetOrganizationID()
  32209. return nil
  32210. case usagestatistichour.FieldAiResponse:
  32211. m.ResetAiResponse()
  32212. return nil
  32213. case usagestatistichour.FieldSopRun:
  32214. m.ResetSopRun()
  32215. return nil
  32216. case usagestatistichour.FieldTotalFriend:
  32217. m.ResetTotalFriend()
  32218. return nil
  32219. case usagestatistichour.FieldTotalGroup:
  32220. m.ResetTotalGroup()
  32221. return nil
  32222. case usagestatistichour.FieldAccountBalance:
  32223. m.ResetAccountBalance()
  32224. return nil
  32225. case usagestatistichour.FieldConsumeToken:
  32226. m.ResetConsumeToken()
  32227. return nil
  32228. case usagestatistichour.FieldActiveUser:
  32229. m.ResetActiveUser()
  32230. return nil
  32231. case usagestatistichour.FieldNewUser:
  32232. m.ResetNewUser()
  32233. return nil
  32234. case usagestatistichour.FieldLabelDist:
  32235. m.ResetLabelDist()
  32236. return nil
  32237. }
  32238. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  32239. }
  32240. // AddedEdges returns all edge names that were set/added in this mutation.
  32241. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  32242. edges := make([]string, 0, 0)
  32243. return edges
  32244. }
  32245. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32246. // name in this mutation.
  32247. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  32248. return nil
  32249. }
  32250. // RemovedEdges returns all edge names that were removed in this mutation.
  32251. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  32252. edges := make([]string, 0, 0)
  32253. return edges
  32254. }
  32255. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32256. // the given name in this mutation.
  32257. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  32258. return nil
  32259. }
  32260. // ClearedEdges returns all edge names that were cleared in this mutation.
  32261. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  32262. edges := make([]string, 0, 0)
  32263. return edges
  32264. }
  32265. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32266. // was cleared in this mutation.
  32267. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  32268. return false
  32269. }
  32270. // ClearEdge clears the value of the edge with the given name. It returns an error
  32271. // if that edge is not defined in the schema.
  32272. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  32273. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  32274. }
  32275. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32276. // It returns an error if the edge is not defined in the schema.
  32277. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  32278. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  32279. }
  32280. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  32281. type UsageStatisticMonthMutation struct {
  32282. config
  32283. op Op
  32284. typ string
  32285. id *uint64
  32286. created_at *time.Time
  32287. updated_at *time.Time
  32288. status *uint8
  32289. addstatus *int8
  32290. deleted_at *time.Time
  32291. addtime *uint64
  32292. addaddtime *int64
  32293. _type *int
  32294. add_type *int
  32295. bot_id *string
  32296. organization_id *uint64
  32297. addorganization_id *int64
  32298. ai_response *uint64
  32299. addai_response *int64
  32300. sop_run *uint64
  32301. addsop_run *int64
  32302. total_friend *uint64
  32303. addtotal_friend *int64
  32304. total_group *uint64
  32305. addtotal_group *int64
  32306. account_balance *uint64
  32307. addaccount_balance *int64
  32308. consume_token *uint64
  32309. addconsume_token *int64
  32310. active_user *uint64
  32311. addactive_user *int64
  32312. new_user *int64
  32313. addnew_user *int64
  32314. label_dist *[]custom_types.LabelDist
  32315. appendlabel_dist []custom_types.LabelDist
  32316. clearedFields map[string]struct{}
  32317. done bool
  32318. oldValue func(context.Context) (*UsageStatisticMonth, error)
  32319. predicates []predicate.UsageStatisticMonth
  32320. }
  32321. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  32322. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  32323. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  32324. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  32325. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  32326. m := &UsageStatisticMonthMutation{
  32327. config: c,
  32328. op: op,
  32329. typ: TypeUsageStatisticMonth,
  32330. clearedFields: make(map[string]struct{}),
  32331. }
  32332. for _, opt := range opts {
  32333. opt(m)
  32334. }
  32335. return m
  32336. }
  32337. // withUsageStatisticMonthID sets the ID field of the mutation.
  32338. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  32339. return func(m *UsageStatisticMonthMutation) {
  32340. var (
  32341. err error
  32342. once sync.Once
  32343. value *UsageStatisticMonth
  32344. )
  32345. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  32346. once.Do(func() {
  32347. if m.done {
  32348. err = errors.New("querying old values post mutation is not allowed")
  32349. } else {
  32350. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  32351. }
  32352. })
  32353. return value, err
  32354. }
  32355. m.id = &id
  32356. }
  32357. }
  32358. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  32359. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  32360. return func(m *UsageStatisticMonthMutation) {
  32361. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  32362. return node, nil
  32363. }
  32364. m.id = &node.ID
  32365. }
  32366. }
  32367. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32368. // executed in a transaction (ent.Tx), a transactional client is returned.
  32369. func (m UsageStatisticMonthMutation) Client() *Client {
  32370. client := &Client{config: m.config}
  32371. client.init()
  32372. return client
  32373. }
  32374. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32375. // it returns an error otherwise.
  32376. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  32377. if _, ok := m.driver.(*txDriver); !ok {
  32378. return nil, errors.New("ent: mutation is not running in a transaction")
  32379. }
  32380. tx := &Tx{config: m.config}
  32381. tx.init()
  32382. return tx, nil
  32383. }
  32384. // SetID sets the value of the id field. Note that this
  32385. // operation is only accepted on creation of UsageStatisticMonth entities.
  32386. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  32387. m.id = &id
  32388. }
  32389. // ID returns the ID value in the mutation. Note that the ID is only available
  32390. // if it was provided to the builder or after it was returned from the database.
  32391. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  32392. if m.id == nil {
  32393. return
  32394. }
  32395. return *m.id, true
  32396. }
  32397. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32398. // That means, if the mutation is applied within a transaction with an isolation level such
  32399. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32400. // or updated by the mutation.
  32401. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  32402. switch {
  32403. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32404. id, exists := m.ID()
  32405. if exists {
  32406. return []uint64{id}, nil
  32407. }
  32408. fallthrough
  32409. case m.op.Is(OpUpdate | OpDelete):
  32410. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  32411. default:
  32412. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32413. }
  32414. }
  32415. // SetCreatedAt sets the "created_at" field.
  32416. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  32417. m.created_at = &t
  32418. }
  32419. // CreatedAt returns the value of the "created_at" field in the mutation.
  32420. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  32421. v := m.created_at
  32422. if v == nil {
  32423. return
  32424. }
  32425. return *v, true
  32426. }
  32427. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  32428. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32430. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32431. if !m.op.Is(OpUpdateOne) {
  32432. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32433. }
  32434. if m.id == nil || m.oldValue == nil {
  32435. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32436. }
  32437. oldValue, err := m.oldValue(ctx)
  32438. if err != nil {
  32439. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32440. }
  32441. return oldValue.CreatedAt, nil
  32442. }
  32443. // ResetCreatedAt resets all changes to the "created_at" field.
  32444. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  32445. m.created_at = nil
  32446. }
  32447. // SetUpdatedAt sets the "updated_at" field.
  32448. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  32449. m.updated_at = &t
  32450. }
  32451. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32452. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  32453. v := m.updated_at
  32454. if v == nil {
  32455. return
  32456. }
  32457. return *v, true
  32458. }
  32459. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  32460. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32462. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32463. if !m.op.Is(OpUpdateOne) {
  32464. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32465. }
  32466. if m.id == nil || m.oldValue == nil {
  32467. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32468. }
  32469. oldValue, err := m.oldValue(ctx)
  32470. if err != nil {
  32471. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32472. }
  32473. return oldValue.UpdatedAt, nil
  32474. }
  32475. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32476. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  32477. m.updated_at = nil
  32478. }
  32479. // SetStatus sets the "status" field.
  32480. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  32481. m.status = &u
  32482. m.addstatus = nil
  32483. }
  32484. // Status returns the value of the "status" field in the mutation.
  32485. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  32486. v := m.status
  32487. if v == nil {
  32488. return
  32489. }
  32490. return *v, true
  32491. }
  32492. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  32493. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32495. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32496. if !m.op.Is(OpUpdateOne) {
  32497. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32498. }
  32499. if m.id == nil || m.oldValue == nil {
  32500. return v, errors.New("OldStatus requires an ID field in the mutation")
  32501. }
  32502. oldValue, err := m.oldValue(ctx)
  32503. if err != nil {
  32504. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32505. }
  32506. return oldValue.Status, nil
  32507. }
  32508. // AddStatus adds u to the "status" field.
  32509. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  32510. if m.addstatus != nil {
  32511. *m.addstatus += u
  32512. } else {
  32513. m.addstatus = &u
  32514. }
  32515. }
  32516. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32517. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  32518. v := m.addstatus
  32519. if v == nil {
  32520. return
  32521. }
  32522. return *v, true
  32523. }
  32524. // ClearStatus clears the value of the "status" field.
  32525. func (m *UsageStatisticMonthMutation) ClearStatus() {
  32526. m.status = nil
  32527. m.addstatus = nil
  32528. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  32529. }
  32530. // StatusCleared returns if the "status" field was cleared in this mutation.
  32531. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  32532. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  32533. return ok
  32534. }
  32535. // ResetStatus resets all changes to the "status" field.
  32536. func (m *UsageStatisticMonthMutation) ResetStatus() {
  32537. m.status = nil
  32538. m.addstatus = nil
  32539. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  32540. }
  32541. // SetDeletedAt sets the "deleted_at" field.
  32542. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  32543. m.deleted_at = &t
  32544. }
  32545. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32546. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  32547. v := m.deleted_at
  32548. if v == nil {
  32549. return
  32550. }
  32551. return *v, true
  32552. }
  32553. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  32554. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32556. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32557. if !m.op.Is(OpUpdateOne) {
  32558. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32559. }
  32560. if m.id == nil || m.oldValue == nil {
  32561. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32562. }
  32563. oldValue, err := m.oldValue(ctx)
  32564. if err != nil {
  32565. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32566. }
  32567. return oldValue.DeletedAt, nil
  32568. }
  32569. // ClearDeletedAt clears the value of the "deleted_at" field.
  32570. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  32571. m.deleted_at = nil
  32572. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  32573. }
  32574. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32575. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  32576. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  32577. return ok
  32578. }
  32579. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32580. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  32581. m.deleted_at = nil
  32582. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  32583. }
  32584. // SetAddtime sets the "addtime" field.
  32585. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  32586. m.addtime = &u
  32587. m.addaddtime = nil
  32588. }
  32589. // Addtime returns the value of the "addtime" field in the mutation.
  32590. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  32591. v := m.addtime
  32592. if v == nil {
  32593. return
  32594. }
  32595. return *v, true
  32596. }
  32597. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  32598. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32600. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32601. if !m.op.Is(OpUpdateOne) {
  32602. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32603. }
  32604. if m.id == nil || m.oldValue == nil {
  32605. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32606. }
  32607. oldValue, err := m.oldValue(ctx)
  32608. if err != nil {
  32609. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32610. }
  32611. return oldValue.Addtime, nil
  32612. }
  32613. // AddAddtime adds u to the "addtime" field.
  32614. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  32615. if m.addaddtime != nil {
  32616. *m.addaddtime += u
  32617. } else {
  32618. m.addaddtime = &u
  32619. }
  32620. }
  32621. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32622. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  32623. v := m.addaddtime
  32624. if v == nil {
  32625. return
  32626. }
  32627. return *v, true
  32628. }
  32629. // ResetAddtime resets all changes to the "addtime" field.
  32630. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  32631. m.addtime = nil
  32632. m.addaddtime = nil
  32633. }
  32634. // SetType sets the "type" field.
  32635. func (m *UsageStatisticMonthMutation) SetType(i int) {
  32636. m._type = &i
  32637. m.add_type = nil
  32638. }
  32639. // GetType returns the value of the "type" field in the mutation.
  32640. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  32641. v := m._type
  32642. if v == nil {
  32643. return
  32644. }
  32645. return *v, true
  32646. }
  32647. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  32648. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32650. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  32651. if !m.op.Is(OpUpdateOne) {
  32652. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32653. }
  32654. if m.id == nil || m.oldValue == nil {
  32655. return v, errors.New("OldType requires an ID field in the mutation")
  32656. }
  32657. oldValue, err := m.oldValue(ctx)
  32658. if err != nil {
  32659. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32660. }
  32661. return oldValue.Type, nil
  32662. }
  32663. // AddType adds i to the "type" field.
  32664. func (m *UsageStatisticMonthMutation) AddType(i int) {
  32665. if m.add_type != nil {
  32666. *m.add_type += i
  32667. } else {
  32668. m.add_type = &i
  32669. }
  32670. }
  32671. // AddedType returns the value that was added to the "type" field in this mutation.
  32672. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  32673. v := m.add_type
  32674. if v == nil {
  32675. return
  32676. }
  32677. return *v, true
  32678. }
  32679. // ResetType resets all changes to the "type" field.
  32680. func (m *UsageStatisticMonthMutation) ResetType() {
  32681. m._type = nil
  32682. m.add_type = nil
  32683. }
  32684. // SetBotID sets the "bot_id" field.
  32685. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  32686. m.bot_id = &s
  32687. }
  32688. // BotID returns the value of the "bot_id" field in the mutation.
  32689. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  32690. v := m.bot_id
  32691. if v == nil {
  32692. return
  32693. }
  32694. return *v, true
  32695. }
  32696. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  32697. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32699. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  32700. if !m.op.Is(OpUpdateOne) {
  32701. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32702. }
  32703. if m.id == nil || m.oldValue == nil {
  32704. return v, errors.New("OldBotID requires an ID field in the mutation")
  32705. }
  32706. oldValue, err := m.oldValue(ctx)
  32707. if err != nil {
  32708. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32709. }
  32710. return oldValue.BotID, nil
  32711. }
  32712. // ClearBotID clears the value of the "bot_id" field.
  32713. func (m *UsageStatisticMonthMutation) ClearBotID() {
  32714. m.bot_id = nil
  32715. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  32716. }
  32717. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32718. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  32719. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  32720. return ok
  32721. }
  32722. // ResetBotID resets all changes to the "bot_id" field.
  32723. func (m *UsageStatisticMonthMutation) ResetBotID() {
  32724. m.bot_id = nil
  32725. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  32726. }
  32727. // SetOrganizationID sets the "organization_id" field.
  32728. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  32729. m.organization_id = &u
  32730. m.addorganization_id = nil
  32731. }
  32732. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32733. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  32734. v := m.organization_id
  32735. if v == nil {
  32736. return
  32737. }
  32738. return *v, true
  32739. }
  32740. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  32741. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32743. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32744. if !m.op.Is(OpUpdateOne) {
  32745. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32746. }
  32747. if m.id == nil || m.oldValue == nil {
  32748. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32749. }
  32750. oldValue, err := m.oldValue(ctx)
  32751. if err != nil {
  32752. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32753. }
  32754. return oldValue.OrganizationID, nil
  32755. }
  32756. // AddOrganizationID adds u to the "organization_id" field.
  32757. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  32758. if m.addorganization_id != nil {
  32759. *m.addorganization_id += u
  32760. } else {
  32761. m.addorganization_id = &u
  32762. }
  32763. }
  32764. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32765. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  32766. v := m.addorganization_id
  32767. if v == nil {
  32768. return
  32769. }
  32770. return *v, true
  32771. }
  32772. // ClearOrganizationID clears the value of the "organization_id" field.
  32773. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  32774. m.organization_id = nil
  32775. m.addorganization_id = nil
  32776. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  32777. }
  32778. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32779. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  32780. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  32781. return ok
  32782. }
  32783. // ResetOrganizationID resets all changes to the "organization_id" field.
  32784. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  32785. m.organization_id = nil
  32786. m.addorganization_id = nil
  32787. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  32788. }
  32789. // SetAiResponse sets the "ai_response" field.
  32790. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  32791. m.ai_response = &u
  32792. m.addai_response = nil
  32793. }
  32794. // AiResponse returns the value of the "ai_response" field in the mutation.
  32795. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  32796. v := m.ai_response
  32797. if v == nil {
  32798. return
  32799. }
  32800. return *v, true
  32801. }
  32802. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  32803. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32805. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32806. if !m.op.Is(OpUpdateOne) {
  32807. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32808. }
  32809. if m.id == nil || m.oldValue == nil {
  32810. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32811. }
  32812. oldValue, err := m.oldValue(ctx)
  32813. if err != nil {
  32814. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32815. }
  32816. return oldValue.AiResponse, nil
  32817. }
  32818. // AddAiResponse adds u to the "ai_response" field.
  32819. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  32820. if m.addai_response != nil {
  32821. *m.addai_response += u
  32822. } else {
  32823. m.addai_response = &u
  32824. }
  32825. }
  32826. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32827. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  32828. v := m.addai_response
  32829. if v == nil {
  32830. return
  32831. }
  32832. return *v, true
  32833. }
  32834. // ResetAiResponse resets all changes to the "ai_response" field.
  32835. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  32836. m.ai_response = nil
  32837. m.addai_response = nil
  32838. }
  32839. // SetSopRun sets the "sop_run" field.
  32840. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  32841. m.sop_run = &u
  32842. m.addsop_run = nil
  32843. }
  32844. // SopRun returns the value of the "sop_run" field in the mutation.
  32845. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  32846. v := m.sop_run
  32847. if v == nil {
  32848. return
  32849. }
  32850. return *v, true
  32851. }
  32852. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  32853. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32855. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32856. if !m.op.Is(OpUpdateOne) {
  32857. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32858. }
  32859. if m.id == nil || m.oldValue == nil {
  32860. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32861. }
  32862. oldValue, err := m.oldValue(ctx)
  32863. if err != nil {
  32864. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32865. }
  32866. return oldValue.SopRun, nil
  32867. }
  32868. // AddSopRun adds u to the "sop_run" field.
  32869. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  32870. if m.addsop_run != nil {
  32871. *m.addsop_run += u
  32872. } else {
  32873. m.addsop_run = &u
  32874. }
  32875. }
  32876. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32877. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  32878. v := m.addsop_run
  32879. if v == nil {
  32880. return
  32881. }
  32882. return *v, true
  32883. }
  32884. // ResetSopRun resets all changes to the "sop_run" field.
  32885. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  32886. m.sop_run = nil
  32887. m.addsop_run = nil
  32888. }
  32889. // SetTotalFriend sets the "total_friend" field.
  32890. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  32891. m.total_friend = &u
  32892. m.addtotal_friend = nil
  32893. }
  32894. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32895. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  32896. v := m.total_friend
  32897. if v == nil {
  32898. return
  32899. }
  32900. return *v, true
  32901. }
  32902. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  32903. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32905. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32906. if !m.op.Is(OpUpdateOne) {
  32907. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32908. }
  32909. if m.id == nil || m.oldValue == nil {
  32910. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32911. }
  32912. oldValue, err := m.oldValue(ctx)
  32913. if err != nil {
  32914. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32915. }
  32916. return oldValue.TotalFriend, nil
  32917. }
  32918. // AddTotalFriend adds u to the "total_friend" field.
  32919. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  32920. if m.addtotal_friend != nil {
  32921. *m.addtotal_friend += u
  32922. } else {
  32923. m.addtotal_friend = &u
  32924. }
  32925. }
  32926. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32927. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  32928. v := m.addtotal_friend
  32929. if v == nil {
  32930. return
  32931. }
  32932. return *v, true
  32933. }
  32934. // ResetTotalFriend resets all changes to the "total_friend" field.
  32935. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  32936. m.total_friend = nil
  32937. m.addtotal_friend = nil
  32938. }
  32939. // SetTotalGroup sets the "total_group" field.
  32940. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  32941. m.total_group = &u
  32942. m.addtotal_group = nil
  32943. }
  32944. // TotalGroup returns the value of the "total_group" field in the mutation.
  32945. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  32946. v := m.total_group
  32947. if v == nil {
  32948. return
  32949. }
  32950. return *v, true
  32951. }
  32952. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  32953. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32955. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32956. if !m.op.Is(OpUpdateOne) {
  32957. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32958. }
  32959. if m.id == nil || m.oldValue == nil {
  32960. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32961. }
  32962. oldValue, err := m.oldValue(ctx)
  32963. if err != nil {
  32964. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32965. }
  32966. return oldValue.TotalGroup, nil
  32967. }
  32968. // AddTotalGroup adds u to the "total_group" field.
  32969. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  32970. if m.addtotal_group != nil {
  32971. *m.addtotal_group += u
  32972. } else {
  32973. m.addtotal_group = &u
  32974. }
  32975. }
  32976. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32977. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  32978. v := m.addtotal_group
  32979. if v == nil {
  32980. return
  32981. }
  32982. return *v, true
  32983. }
  32984. // ResetTotalGroup resets all changes to the "total_group" field.
  32985. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  32986. m.total_group = nil
  32987. m.addtotal_group = nil
  32988. }
  32989. // SetAccountBalance sets the "account_balance" field.
  32990. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  32991. m.account_balance = &u
  32992. m.addaccount_balance = nil
  32993. }
  32994. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32995. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  32996. v := m.account_balance
  32997. if v == nil {
  32998. return
  32999. }
  33000. return *v, true
  33001. }
  33002. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  33003. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33005. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  33006. if !m.op.Is(OpUpdateOne) {
  33007. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  33008. }
  33009. if m.id == nil || m.oldValue == nil {
  33010. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  33011. }
  33012. oldValue, err := m.oldValue(ctx)
  33013. if err != nil {
  33014. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  33015. }
  33016. return oldValue.AccountBalance, nil
  33017. }
  33018. // AddAccountBalance adds u to the "account_balance" field.
  33019. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  33020. if m.addaccount_balance != nil {
  33021. *m.addaccount_balance += u
  33022. } else {
  33023. m.addaccount_balance = &u
  33024. }
  33025. }
  33026. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  33027. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  33028. v := m.addaccount_balance
  33029. if v == nil {
  33030. return
  33031. }
  33032. return *v, true
  33033. }
  33034. // ResetAccountBalance resets all changes to the "account_balance" field.
  33035. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  33036. m.account_balance = nil
  33037. m.addaccount_balance = nil
  33038. }
  33039. // SetConsumeToken sets the "consume_token" field.
  33040. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  33041. m.consume_token = &u
  33042. m.addconsume_token = nil
  33043. }
  33044. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  33045. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  33046. v := m.consume_token
  33047. if v == nil {
  33048. return
  33049. }
  33050. return *v, true
  33051. }
  33052. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  33053. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33055. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  33056. if !m.op.Is(OpUpdateOne) {
  33057. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  33058. }
  33059. if m.id == nil || m.oldValue == nil {
  33060. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  33061. }
  33062. oldValue, err := m.oldValue(ctx)
  33063. if err != nil {
  33064. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  33065. }
  33066. return oldValue.ConsumeToken, nil
  33067. }
  33068. // AddConsumeToken adds u to the "consume_token" field.
  33069. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  33070. if m.addconsume_token != nil {
  33071. *m.addconsume_token += u
  33072. } else {
  33073. m.addconsume_token = &u
  33074. }
  33075. }
  33076. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  33077. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  33078. v := m.addconsume_token
  33079. if v == nil {
  33080. return
  33081. }
  33082. return *v, true
  33083. }
  33084. // ResetConsumeToken resets all changes to the "consume_token" field.
  33085. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  33086. m.consume_token = nil
  33087. m.addconsume_token = nil
  33088. }
  33089. // SetActiveUser sets the "active_user" field.
  33090. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  33091. m.active_user = &u
  33092. m.addactive_user = nil
  33093. }
  33094. // ActiveUser returns the value of the "active_user" field in the mutation.
  33095. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  33096. v := m.active_user
  33097. if v == nil {
  33098. return
  33099. }
  33100. return *v, true
  33101. }
  33102. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  33103. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33105. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  33106. if !m.op.Is(OpUpdateOne) {
  33107. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  33108. }
  33109. if m.id == nil || m.oldValue == nil {
  33110. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  33111. }
  33112. oldValue, err := m.oldValue(ctx)
  33113. if err != nil {
  33114. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  33115. }
  33116. return oldValue.ActiveUser, nil
  33117. }
  33118. // AddActiveUser adds u to the "active_user" field.
  33119. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  33120. if m.addactive_user != nil {
  33121. *m.addactive_user += u
  33122. } else {
  33123. m.addactive_user = &u
  33124. }
  33125. }
  33126. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  33127. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  33128. v := m.addactive_user
  33129. if v == nil {
  33130. return
  33131. }
  33132. return *v, true
  33133. }
  33134. // ResetActiveUser resets all changes to the "active_user" field.
  33135. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  33136. m.active_user = nil
  33137. m.addactive_user = nil
  33138. }
  33139. // SetNewUser sets the "new_user" field.
  33140. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  33141. m.new_user = &i
  33142. m.addnew_user = nil
  33143. }
  33144. // NewUser returns the value of the "new_user" field in the mutation.
  33145. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  33146. v := m.new_user
  33147. if v == nil {
  33148. return
  33149. }
  33150. return *v, true
  33151. }
  33152. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  33153. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33155. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  33156. if !m.op.Is(OpUpdateOne) {
  33157. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  33158. }
  33159. if m.id == nil || m.oldValue == nil {
  33160. return v, errors.New("OldNewUser requires an ID field in the mutation")
  33161. }
  33162. oldValue, err := m.oldValue(ctx)
  33163. if err != nil {
  33164. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  33165. }
  33166. return oldValue.NewUser, nil
  33167. }
  33168. // AddNewUser adds i to the "new_user" field.
  33169. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  33170. if m.addnew_user != nil {
  33171. *m.addnew_user += i
  33172. } else {
  33173. m.addnew_user = &i
  33174. }
  33175. }
  33176. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  33177. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  33178. v := m.addnew_user
  33179. if v == nil {
  33180. return
  33181. }
  33182. return *v, true
  33183. }
  33184. // ResetNewUser resets all changes to the "new_user" field.
  33185. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  33186. m.new_user = nil
  33187. m.addnew_user = nil
  33188. }
  33189. // SetLabelDist sets the "label_dist" field.
  33190. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  33191. m.label_dist = &ctd
  33192. m.appendlabel_dist = nil
  33193. }
  33194. // LabelDist returns the value of the "label_dist" field in the mutation.
  33195. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  33196. v := m.label_dist
  33197. if v == nil {
  33198. return
  33199. }
  33200. return *v, true
  33201. }
  33202. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  33203. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33205. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33206. if !m.op.Is(OpUpdateOne) {
  33207. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33208. }
  33209. if m.id == nil || m.oldValue == nil {
  33210. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  33211. }
  33212. oldValue, err := m.oldValue(ctx)
  33213. if err != nil {
  33214. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  33215. }
  33216. return oldValue.LabelDist, nil
  33217. }
  33218. // AppendLabelDist adds ctd to the "label_dist" field.
  33219. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33220. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33221. }
  33222. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33223. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33224. if len(m.appendlabel_dist) == 0 {
  33225. return nil, false
  33226. }
  33227. return m.appendlabel_dist, true
  33228. }
  33229. // ResetLabelDist resets all changes to the "label_dist" field.
  33230. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  33231. m.label_dist = nil
  33232. m.appendlabel_dist = nil
  33233. }
  33234. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  33235. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  33236. m.predicates = append(m.predicates, ps...)
  33237. }
  33238. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  33239. // users can use type-assertion to append predicates that do not depend on any generated package.
  33240. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  33241. p := make([]predicate.UsageStatisticMonth, len(ps))
  33242. for i := range ps {
  33243. p[i] = ps[i]
  33244. }
  33245. m.Where(p...)
  33246. }
  33247. // Op returns the operation name.
  33248. func (m *UsageStatisticMonthMutation) Op() Op {
  33249. return m.op
  33250. }
  33251. // SetOp allows setting the mutation operation.
  33252. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  33253. m.op = op
  33254. }
  33255. // Type returns the node type of this mutation (UsageStatisticMonth).
  33256. func (m *UsageStatisticMonthMutation) Type() string {
  33257. return m.typ
  33258. }
  33259. // Fields returns all fields that were changed during this mutation. Note that in
  33260. // order to get all numeric fields that were incremented/decremented, call
  33261. // AddedFields().
  33262. func (m *UsageStatisticMonthMutation) Fields() []string {
  33263. fields := make([]string, 0, 17)
  33264. if m.created_at != nil {
  33265. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  33266. }
  33267. if m.updated_at != nil {
  33268. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  33269. }
  33270. if m.status != nil {
  33271. fields = append(fields, usagestatisticmonth.FieldStatus)
  33272. }
  33273. if m.deleted_at != nil {
  33274. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  33275. }
  33276. if m.addtime != nil {
  33277. fields = append(fields, usagestatisticmonth.FieldAddtime)
  33278. }
  33279. if m._type != nil {
  33280. fields = append(fields, usagestatisticmonth.FieldType)
  33281. }
  33282. if m.bot_id != nil {
  33283. fields = append(fields, usagestatisticmonth.FieldBotID)
  33284. }
  33285. if m.organization_id != nil {
  33286. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33287. }
  33288. if m.ai_response != nil {
  33289. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  33290. }
  33291. if m.sop_run != nil {
  33292. fields = append(fields, usagestatisticmonth.FieldSopRun)
  33293. }
  33294. if m.total_friend != nil {
  33295. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  33296. }
  33297. if m.total_group != nil {
  33298. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  33299. }
  33300. if m.account_balance != nil {
  33301. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  33302. }
  33303. if m.consume_token != nil {
  33304. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  33305. }
  33306. if m.active_user != nil {
  33307. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  33308. }
  33309. if m.new_user != nil {
  33310. fields = append(fields, usagestatisticmonth.FieldNewUser)
  33311. }
  33312. if m.label_dist != nil {
  33313. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  33314. }
  33315. return fields
  33316. }
  33317. // Field returns the value of a field with the given name. The second boolean
  33318. // return value indicates that this field was not set, or was not defined in the
  33319. // schema.
  33320. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  33321. switch name {
  33322. case usagestatisticmonth.FieldCreatedAt:
  33323. return m.CreatedAt()
  33324. case usagestatisticmonth.FieldUpdatedAt:
  33325. return m.UpdatedAt()
  33326. case usagestatisticmonth.FieldStatus:
  33327. return m.Status()
  33328. case usagestatisticmonth.FieldDeletedAt:
  33329. return m.DeletedAt()
  33330. case usagestatisticmonth.FieldAddtime:
  33331. return m.Addtime()
  33332. case usagestatisticmonth.FieldType:
  33333. return m.GetType()
  33334. case usagestatisticmonth.FieldBotID:
  33335. return m.BotID()
  33336. case usagestatisticmonth.FieldOrganizationID:
  33337. return m.OrganizationID()
  33338. case usagestatisticmonth.FieldAiResponse:
  33339. return m.AiResponse()
  33340. case usagestatisticmonth.FieldSopRun:
  33341. return m.SopRun()
  33342. case usagestatisticmonth.FieldTotalFriend:
  33343. return m.TotalFriend()
  33344. case usagestatisticmonth.FieldTotalGroup:
  33345. return m.TotalGroup()
  33346. case usagestatisticmonth.FieldAccountBalance:
  33347. return m.AccountBalance()
  33348. case usagestatisticmonth.FieldConsumeToken:
  33349. return m.ConsumeToken()
  33350. case usagestatisticmonth.FieldActiveUser:
  33351. return m.ActiveUser()
  33352. case usagestatisticmonth.FieldNewUser:
  33353. return m.NewUser()
  33354. case usagestatisticmonth.FieldLabelDist:
  33355. return m.LabelDist()
  33356. }
  33357. return nil, false
  33358. }
  33359. // OldField returns the old value of the field from the database. An error is
  33360. // returned if the mutation operation is not UpdateOne, or the query to the
  33361. // database failed.
  33362. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33363. switch name {
  33364. case usagestatisticmonth.FieldCreatedAt:
  33365. return m.OldCreatedAt(ctx)
  33366. case usagestatisticmonth.FieldUpdatedAt:
  33367. return m.OldUpdatedAt(ctx)
  33368. case usagestatisticmonth.FieldStatus:
  33369. return m.OldStatus(ctx)
  33370. case usagestatisticmonth.FieldDeletedAt:
  33371. return m.OldDeletedAt(ctx)
  33372. case usagestatisticmonth.FieldAddtime:
  33373. return m.OldAddtime(ctx)
  33374. case usagestatisticmonth.FieldType:
  33375. return m.OldType(ctx)
  33376. case usagestatisticmonth.FieldBotID:
  33377. return m.OldBotID(ctx)
  33378. case usagestatisticmonth.FieldOrganizationID:
  33379. return m.OldOrganizationID(ctx)
  33380. case usagestatisticmonth.FieldAiResponse:
  33381. return m.OldAiResponse(ctx)
  33382. case usagestatisticmonth.FieldSopRun:
  33383. return m.OldSopRun(ctx)
  33384. case usagestatisticmonth.FieldTotalFriend:
  33385. return m.OldTotalFriend(ctx)
  33386. case usagestatisticmonth.FieldTotalGroup:
  33387. return m.OldTotalGroup(ctx)
  33388. case usagestatisticmonth.FieldAccountBalance:
  33389. return m.OldAccountBalance(ctx)
  33390. case usagestatisticmonth.FieldConsumeToken:
  33391. return m.OldConsumeToken(ctx)
  33392. case usagestatisticmonth.FieldActiveUser:
  33393. return m.OldActiveUser(ctx)
  33394. case usagestatisticmonth.FieldNewUser:
  33395. return m.OldNewUser(ctx)
  33396. case usagestatisticmonth.FieldLabelDist:
  33397. return m.OldLabelDist(ctx)
  33398. }
  33399. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33400. }
  33401. // SetField sets the value of a field with the given name. It returns an error if
  33402. // the field is not defined in the schema, or if the type mismatched the field
  33403. // type.
  33404. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  33405. switch name {
  33406. case usagestatisticmonth.FieldCreatedAt:
  33407. v, ok := value.(time.Time)
  33408. if !ok {
  33409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33410. }
  33411. m.SetCreatedAt(v)
  33412. return nil
  33413. case usagestatisticmonth.FieldUpdatedAt:
  33414. v, ok := value.(time.Time)
  33415. if !ok {
  33416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33417. }
  33418. m.SetUpdatedAt(v)
  33419. return nil
  33420. case usagestatisticmonth.FieldStatus:
  33421. v, ok := value.(uint8)
  33422. if !ok {
  33423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33424. }
  33425. m.SetStatus(v)
  33426. return nil
  33427. case usagestatisticmonth.FieldDeletedAt:
  33428. v, ok := value.(time.Time)
  33429. if !ok {
  33430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33431. }
  33432. m.SetDeletedAt(v)
  33433. return nil
  33434. case usagestatisticmonth.FieldAddtime:
  33435. v, ok := value.(uint64)
  33436. if !ok {
  33437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33438. }
  33439. m.SetAddtime(v)
  33440. return nil
  33441. case usagestatisticmonth.FieldType:
  33442. v, ok := value.(int)
  33443. if !ok {
  33444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33445. }
  33446. m.SetType(v)
  33447. return nil
  33448. case usagestatisticmonth.FieldBotID:
  33449. v, ok := value.(string)
  33450. if !ok {
  33451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33452. }
  33453. m.SetBotID(v)
  33454. return nil
  33455. case usagestatisticmonth.FieldOrganizationID:
  33456. v, ok := value.(uint64)
  33457. if !ok {
  33458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33459. }
  33460. m.SetOrganizationID(v)
  33461. return nil
  33462. case usagestatisticmonth.FieldAiResponse:
  33463. v, ok := value.(uint64)
  33464. if !ok {
  33465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33466. }
  33467. m.SetAiResponse(v)
  33468. return nil
  33469. case usagestatisticmonth.FieldSopRun:
  33470. v, ok := value.(uint64)
  33471. if !ok {
  33472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33473. }
  33474. m.SetSopRun(v)
  33475. return nil
  33476. case usagestatisticmonth.FieldTotalFriend:
  33477. v, ok := value.(uint64)
  33478. if !ok {
  33479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33480. }
  33481. m.SetTotalFriend(v)
  33482. return nil
  33483. case usagestatisticmonth.FieldTotalGroup:
  33484. v, ok := value.(uint64)
  33485. if !ok {
  33486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33487. }
  33488. m.SetTotalGroup(v)
  33489. return nil
  33490. case usagestatisticmonth.FieldAccountBalance:
  33491. v, ok := value.(uint64)
  33492. if !ok {
  33493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33494. }
  33495. m.SetAccountBalance(v)
  33496. return nil
  33497. case usagestatisticmonth.FieldConsumeToken:
  33498. v, ok := value.(uint64)
  33499. if !ok {
  33500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33501. }
  33502. m.SetConsumeToken(v)
  33503. return nil
  33504. case usagestatisticmonth.FieldActiveUser:
  33505. v, ok := value.(uint64)
  33506. if !ok {
  33507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33508. }
  33509. m.SetActiveUser(v)
  33510. return nil
  33511. case usagestatisticmonth.FieldNewUser:
  33512. v, ok := value.(int64)
  33513. if !ok {
  33514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33515. }
  33516. m.SetNewUser(v)
  33517. return nil
  33518. case usagestatisticmonth.FieldLabelDist:
  33519. v, ok := value.([]custom_types.LabelDist)
  33520. if !ok {
  33521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33522. }
  33523. m.SetLabelDist(v)
  33524. return nil
  33525. }
  33526. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33527. }
  33528. // AddedFields returns all numeric fields that were incremented/decremented during
  33529. // this mutation.
  33530. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  33531. var fields []string
  33532. if m.addstatus != nil {
  33533. fields = append(fields, usagestatisticmonth.FieldStatus)
  33534. }
  33535. if m.addaddtime != nil {
  33536. fields = append(fields, usagestatisticmonth.FieldAddtime)
  33537. }
  33538. if m.add_type != nil {
  33539. fields = append(fields, usagestatisticmonth.FieldType)
  33540. }
  33541. if m.addorganization_id != nil {
  33542. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33543. }
  33544. if m.addai_response != nil {
  33545. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  33546. }
  33547. if m.addsop_run != nil {
  33548. fields = append(fields, usagestatisticmonth.FieldSopRun)
  33549. }
  33550. if m.addtotal_friend != nil {
  33551. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  33552. }
  33553. if m.addtotal_group != nil {
  33554. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  33555. }
  33556. if m.addaccount_balance != nil {
  33557. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  33558. }
  33559. if m.addconsume_token != nil {
  33560. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  33561. }
  33562. if m.addactive_user != nil {
  33563. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  33564. }
  33565. if m.addnew_user != nil {
  33566. fields = append(fields, usagestatisticmonth.FieldNewUser)
  33567. }
  33568. return fields
  33569. }
  33570. // AddedField returns the numeric value that was incremented/decremented on a field
  33571. // with the given name. The second boolean return value indicates that this field
  33572. // was not set, or was not defined in the schema.
  33573. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  33574. switch name {
  33575. case usagestatisticmonth.FieldStatus:
  33576. return m.AddedStatus()
  33577. case usagestatisticmonth.FieldAddtime:
  33578. return m.AddedAddtime()
  33579. case usagestatisticmonth.FieldType:
  33580. return m.AddedType()
  33581. case usagestatisticmonth.FieldOrganizationID:
  33582. return m.AddedOrganizationID()
  33583. case usagestatisticmonth.FieldAiResponse:
  33584. return m.AddedAiResponse()
  33585. case usagestatisticmonth.FieldSopRun:
  33586. return m.AddedSopRun()
  33587. case usagestatisticmonth.FieldTotalFriend:
  33588. return m.AddedTotalFriend()
  33589. case usagestatisticmonth.FieldTotalGroup:
  33590. return m.AddedTotalGroup()
  33591. case usagestatisticmonth.FieldAccountBalance:
  33592. return m.AddedAccountBalance()
  33593. case usagestatisticmonth.FieldConsumeToken:
  33594. return m.AddedConsumeToken()
  33595. case usagestatisticmonth.FieldActiveUser:
  33596. return m.AddedActiveUser()
  33597. case usagestatisticmonth.FieldNewUser:
  33598. return m.AddedNewUser()
  33599. }
  33600. return nil, false
  33601. }
  33602. // AddField adds the value to the field with the given name. It returns an error if
  33603. // the field is not defined in the schema, or if the type mismatched the field
  33604. // type.
  33605. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  33606. switch name {
  33607. case usagestatisticmonth.FieldStatus:
  33608. v, ok := value.(int8)
  33609. if !ok {
  33610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33611. }
  33612. m.AddStatus(v)
  33613. return nil
  33614. case usagestatisticmonth.FieldAddtime:
  33615. v, ok := value.(int64)
  33616. if !ok {
  33617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33618. }
  33619. m.AddAddtime(v)
  33620. return nil
  33621. case usagestatisticmonth.FieldType:
  33622. v, ok := value.(int)
  33623. if !ok {
  33624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33625. }
  33626. m.AddType(v)
  33627. return nil
  33628. case usagestatisticmonth.FieldOrganizationID:
  33629. v, ok := value.(int64)
  33630. if !ok {
  33631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33632. }
  33633. m.AddOrganizationID(v)
  33634. return nil
  33635. case usagestatisticmonth.FieldAiResponse:
  33636. v, ok := value.(int64)
  33637. if !ok {
  33638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33639. }
  33640. m.AddAiResponse(v)
  33641. return nil
  33642. case usagestatisticmonth.FieldSopRun:
  33643. v, ok := value.(int64)
  33644. if !ok {
  33645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33646. }
  33647. m.AddSopRun(v)
  33648. return nil
  33649. case usagestatisticmonth.FieldTotalFriend:
  33650. v, ok := value.(int64)
  33651. if !ok {
  33652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33653. }
  33654. m.AddTotalFriend(v)
  33655. return nil
  33656. case usagestatisticmonth.FieldTotalGroup:
  33657. v, ok := value.(int64)
  33658. if !ok {
  33659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33660. }
  33661. m.AddTotalGroup(v)
  33662. return nil
  33663. case usagestatisticmonth.FieldAccountBalance:
  33664. v, ok := value.(int64)
  33665. if !ok {
  33666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33667. }
  33668. m.AddAccountBalance(v)
  33669. return nil
  33670. case usagestatisticmonth.FieldConsumeToken:
  33671. v, ok := value.(int64)
  33672. if !ok {
  33673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33674. }
  33675. m.AddConsumeToken(v)
  33676. return nil
  33677. case usagestatisticmonth.FieldActiveUser:
  33678. v, ok := value.(int64)
  33679. if !ok {
  33680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33681. }
  33682. m.AddActiveUser(v)
  33683. return nil
  33684. case usagestatisticmonth.FieldNewUser:
  33685. v, ok := value.(int64)
  33686. if !ok {
  33687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33688. }
  33689. m.AddNewUser(v)
  33690. return nil
  33691. }
  33692. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  33693. }
  33694. // ClearedFields returns all nullable fields that were cleared during this
  33695. // mutation.
  33696. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  33697. var fields []string
  33698. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  33699. fields = append(fields, usagestatisticmonth.FieldStatus)
  33700. }
  33701. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  33702. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  33703. }
  33704. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  33705. fields = append(fields, usagestatisticmonth.FieldBotID)
  33706. }
  33707. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  33708. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  33709. }
  33710. return fields
  33711. }
  33712. // FieldCleared returns a boolean indicating if a field with the given name was
  33713. // cleared in this mutation.
  33714. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  33715. _, ok := m.clearedFields[name]
  33716. return ok
  33717. }
  33718. // ClearField clears the value of the field with the given name. It returns an
  33719. // error if the field is not defined in the schema.
  33720. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  33721. switch name {
  33722. case usagestatisticmonth.FieldStatus:
  33723. m.ClearStatus()
  33724. return nil
  33725. case usagestatisticmonth.FieldDeletedAt:
  33726. m.ClearDeletedAt()
  33727. return nil
  33728. case usagestatisticmonth.FieldBotID:
  33729. m.ClearBotID()
  33730. return nil
  33731. case usagestatisticmonth.FieldOrganizationID:
  33732. m.ClearOrganizationID()
  33733. return nil
  33734. }
  33735. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  33736. }
  33737. // ResetField resets all changes in the mutation for the field with the given name.
  33738. // It returns an error if the field is not defined in the schema.
  33739. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  33740. switch name {
  33741. case usagestatisticmonth.FieldCreatedAt:
  33742. m.ResetCreatedAt()
  33743. return nil
  33744. case usagestatisticmonth.FieldUpdatedAt:
  33745. m.ResetUpdatedAt()
  33746. return nil
  33747. case usagestatisticmonth.FieldStatus:
  33748. m.ResetStatus()
  33749. return nil
  33750. case usagestatisticmonth.FieldDeletedAt:
  33751. m.ResetDeletedAt()
  33752. return nil
  33753. case usagestatisticmonth.FieldAddtime:
  33754. m.ResetAddtime()
  33755. return nil
  33756. case usagestatisticmonth.FieldType:
  33757. m.ResetType()
  33758. return nil
  33759. case usagestatisticmonth.FieldBotID:
  33760. m.ResetBotID()
  33761. return nil
  33762. case usagestatisticmonth.FieldOrganizationID:
  33763. m.ResetOrganizationID()
  33764. return nil
  33765. case usagestatisticmonth.FieldAiResponse:
  33766. m.ResetAiResponse()
  33767. return nil
  33768. case usagestatisticmonth.FieldSopRun:
  33769. m.ResetSopRun()
  33770. return nil
  33771. case usagestatisticmonth.FieldTotalFriend:
  33772. m.ResetTotalFriend()
  33773. return nil
  33774. case usagestatisticmonth.FieldTotalGroup:
  33775. m.ResetTotalGroup()
  33776. return nil
  33777. case usagestatisticmonth.FieldAccountBalance:
  33778. m.ResetAccountBalance()
  33779. return nil
  33780. case usagestatisticmonth.FieldConsumeToken:
  33781. m.ResetConsumeToken()
  33782. return nil
  33783. case usagestatisticmonth.FieldActiveUser:
  33784. m.ResetActiveUser()
  33785. return nil
  33786. case usagestatisticmonth.FieldNewUser:
  33787. m.ResetNewUser()
  33788. return nil
  33789. case usagestatisticmonth.FieldLabelDist:
  33790. m.ResetLabelDist()
  33791. return nil
  33792. }
  33793. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  33794. }
  33795. // AddedEdges returns all edge names that were set/added in this mutation.
  33796. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  33797. edges := make([]string, 0, 0)
  33798. return edges
  33799. }
  33800. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33801. // name in this mutation.
  33802. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  33803. return nil
  33804. }
  33805. // RemovedEdges returns all edge names that were removed in this mutation.
  33806. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  33807. edges := make([]string, 0, 0)
  33808. return edges
  33809. }
  33810. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33811. // the given name in this mutation.
  33812. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  33813. return nil
  33814. }
  33815. // ClearedEdges returns all edge names that were cleared in this mutation.
  33816. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  33817. edges := make([]string, 0, 0)
  33818. return edges
  33819. }
  33820. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33821. // was cleared in this mutation.
  33822. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  33823. return false
  33824. }
  33825. // ClearEdge clears the value of the edge with the given name. It returns an error
  33826. // if that edge is not defined in the schema.
  33827. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  33828. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  33829. }
  33830. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33831. // It returns an error if the edge is not defined in the schema.
  33832. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  33833. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  33834. }
  33835. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  33836. type UsageTotalMutation struct {
  33837. config
  33838. op Op
  33839. typ string
  33840. id *uint64
  33841. created_at *time.Time
  33842. updated_at *time.Time
  33843. status *uint8
  33844. addstatus *int8
  33845. _type *int
  33846. add_type *int
  33847. bot_id *string
  33848. total_tokens *uint64
  33849. addtotal_tokens *int64
  33850. start_index *uint64
  33851. addstart_index *int64
  33852. end_index *uint64
  33853. addend_index *int64
  33854. organization_id *uint64
  33855. addorganization_id *int64
  33856. clearedFields map[string]struct{}
  33857. done bool
  33858. oldValue func(context.Context) (*UsageTotal, error)
  33859. predicates []predicate.UsageTotal
  33860. }
  33861. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  33862. // usagetotalOption allows management of the mutation configuration using functional options.
  33863. type usagetotalOption func(*UsageTotalMutation)
  33864. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  33865. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  33866. m := &UsageTotalMutation{
  33867. config: c,
  33868. op: op,
  33869. typ: TypeUsageTotal,
  33870. clearedFields: make(map[string]struct{}),
  33871. }
  33872. for _, opt := range opts {
  33873. opt(m)
  33874. }
  33875. return m
  33876. }
  33877. // withUsageTotalID sets the ID field of the mutation.
  33878. func withUsageTotalID(id uint64) usagetotalOption {
  33879. return func(m *UsageTotalMutation) {
  33880. var (
  33881. err error
  33882. once sync.Once
  33883. value *UsageTotal
  33884. )
  33885. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  33886. once.Do(func() {
  33887. if m.done {
  33888. err = errors.New("querying old values post mutation is not allowed")
  33889. } else {
  33890. value, err = m.Client().UsageTotal.Get(ctx, id)
  33891. }
  33892. })
  33893. return value, err
  33894. }
  33895. m.id = &id
  33896. }
  33897. }
  33898. // withUsageTotal sets the old UsageTotal of the mutation.
  33899. func withUsageTotal(node *UsageTotal) usagetotalOption {
  33900. return func(m *UsageTotalMutation) {
  33901. m.oldValue = func(context.Context) (*UsageTotal, error) {
  33902. return node, nil
  33903. }
  33904. m.id = &node.ID
  33905. }
  33906. }
  33907. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33908. // executed in a transaction (ent.Tx), a transactional client is returned.
  33909. func (m UsageTotalMutation) Client() *Client {
  33910. client := &Client{config: m.config}
  33911. client.init()
  33912. return client
  33913. }
  33914. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33915. // it returns an error otherwise.
  33916. func (m UsageTotalMutation) Tx() (*Tx, error) {
  33917. if _, ok := m.driver.(*txDriver); !ok {
  33918. return nil, errors.New("ent: mutation is not running in a transaction")
  33919. }
  33920. tx := &Tx{config: m.config}
  33921. tx.init()
  33922. return tx, nil
  33923. }
  33924. // SetID sets the value of the id field. Note that this
  33925. // operation is only accepted on creation of UsageTotal entities.
  33926. func (m *UsageTotalMutation) SetID(id uint64) {
  33927. m.id = &id
  33928. }
  33929. // ID returns the ID value in the mutation. Note that the ID is only available
  33930. // if it was provided to the builder or after it was returned from the database.
  33931. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  33932. if m.id == nil {
  33933. return
  33934. }
  33935. return *m.id, true
  33936. }
  33937. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33938. // That means, if the mutation is applied within a transaction with an isolation level such
  33939. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33940. // or updated by the mutation.
  33941. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  33942. switch {
  33943. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33944. id, exists := m.ID()
  33945. if exists {
  33946. return []uint64{id}, nil
  33947. }
  33948. fallthrough
  33949. case m.op.Is(OpUpdate | OpDelete):
  33950. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  33951. default:
  33952. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33953. }
  33954. }
  33955. // SetCreatedAt sets the "created_at" field.
  33956. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  33957. m.created_at = &t
  33958. }
  33959. // CreatedAt returns the value of the "created_at" field in the mutation.
  33960. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  33961. v := m.created_at
  33962. if v == nil {
  33963. return
  33964. }
  33965. return *v, true
  33966. }
  33967. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  33968. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33970. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33971. if !m.op.Is(OpUpdateOne) {
  33972. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33973. }
  33974. if m.id == nil || m.oldValue == nil {
  33975. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33976. }
  33977. oldValue, err := m.oldValue(ctx)
  33978. if err != nil {
  33979. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33980. }
  33981. return oldValue.CreatedAt, nil
  33982. }
  33983. // ResetCreatedAt resets all changes to the "created_at" field.
  33984. func (m *UsageTotalMutation) ResetCreatedAt() {
  33985. m.created_at = nil
  33986. }
  33987. // SetUpdatedAt sets the "updated_at" field.
  33988. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  33989. m.updated_at = &t
  33990. }
  33991. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33992. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  33993. v := m.updated_at
  33994. if v == nil {
  33995. return
  33996. }
  33997. return *v, true
  33998. }
  33999. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  34000. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34002. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34003. if !m.op.Is(OpUpdateOne) {
  34004. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34005. }
  34006. if m.id == nil || m.oldValue == nil {
  34007. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34008. }
  34009. oldValue, err := m.oldValue(ctx)
  34010. if err != nil {
  34011. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34012. }
  34013. return oldValue.UpdatedAt, nil
  34014. }
  34015. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34016. func (m *UsageTotalMutation) ResetUpdatedAt() {
  34017. m.updated_at = nil
  34018. }
  34019. // SetStatus sets the "status" field.
  34020. func (m *UsageTotalMutation) SetStatus(u uint8) {
  34021. m.status = &u
  34022. m.addstatus = nil
  34023. }
  34024. // Status returns the value of the "status" field in the mutation.
  34025. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  34026. v := m.status
  34027. if v == nil {
  34028. return
  34029. }
  34030. return *v, true
  34031. }
  34032. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  34033. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34035. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34036. if !m.op.Is(OpUpdateOne) {
  34037. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34038. }
  34039. if m.id == nil || m.oldValue == nil {
  34040. return v, errors.New("OldStatus requires an ID field in the mutation")
  34041. }
  34042. oldValue, err := m.oldValue(ctx)
  34043. if err != nil {
  34044. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34045. }
  34046. return oldValue.Status, nil
  34047. }
  34048. // AddStatus adds u to the "status" field.
  34049. func (m *UsageTotalMutation) AddStatus(u int8) {
  34050. if m.addstatus != nil {
  34051. *m.addstatus += u
  34052. } else {
  34053. m.addstatus = &u
  34054. }
  34055. }
  34056. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34057. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  34058. v := m.addstatus
  34059. if v == nil {
  34060. return
  34061. }
  34062. return *v, true
  34063. }
  34064. // ClearStatus clears the value of the "status" field.
  34065. func (m *UsageTotalMutation) ClearStatus() {
  34066. m.status = nil
  34067. m.addstatus = nil
  34068. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  34069. }
  34070. // StatusCleared returns if the "status" field was cleared in this mutation.
  34071. func (m *UsageTotalMutation) StatusCleared() bool {
  34072. _, ok := m.clearedFields[usagetotal.FieldStatus]
  34073. return ok
  34074. }
  34075. // ResetStatus resets all changes to the "status" field.
  34076. func (m *UsageTotalMutation) ResetStatus() {
  34077. m.status = nil
  34078. m.addstatus = nil
  34079. delete(m.clearedFields, usagetotal.FieldStatus)
  34080. }
  34081. // SetType sets the "type" field.
  34082. func (m *UsageTotalMutation) SetType(i int) {
  34083. m._type = &i
  34084. m.add_type = nil
  34085. }
  34086. // GetType returns the value of the "type" field in the mutation.
  34087. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  34088. v := m._type
  34089. if v == nil {
  34090. return
  34091. }
  34092. return *v, true
  34093. }
  34094. // OldType returns the old "type" field's value of the UsageTotal entity.
  34095. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34097. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  34098. if !m.op.Is(OpUpdateOne) {
  34099. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34100. }
  34101. if m.id == nil || m.oldValue == nil {
  34102. return v, errors.New("OldType requires an ID field in the mutation")
  34103. }
  34104. oldValue, err := m.oldValue(ctx)
  34105. if err != nil {
  34106. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34107. }
  34108. return oldValue.Type, nil
  34109. }
  34110. // AddType adds i to the "type" field.
  34111. func (m *UsageTotalMutation) AddType(i int) {
  34112. if m.add_type != nil {
  34113. *m.add_type += i
  34114. } else {
  34115. m.add_type = &i
  34116. }
  34117. }
  34118. // AddedType returns the value that was added to the "type" field in this mutation.
  34119. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  34120. v := m.add_type
  34121. if v == nil {
  34122. return
  34123. }
  34124. return *v, true
  34125. }
  34126. // ClearType clears the value of the "type" field.
  34127. func (m *UsageTotalMutation) ClearType() {
  34128. m._type = nil
  34129. m.add_type = nil
  34130. m.clearedFields[usagetotal.FieldType] = struct{}{}
  34131. }
  34132. // TypeCleared returns if the "type" field was cleared in this mutation.
  34133. func (m *UsageTotalMutation) TypeCleared() bool {
  34134. _, ok := m.clearedFields[usagetotal.FieldType]
  34135. return ok
  34136. }
  34137. // ResetType resets all changes to the "type" field.
  34138. func (m *UsageTotalMutation) ResetType() {
  34139. m._type = nil
  34140. m.add_type = nil
  34141. delete(m.clearedFields, usagetotal.FieldType)
  34142. }
  34143. // SetBotID sets the "bot_id" field.
  34144. func (m *UsageTotalMutation) SetBotID(s string) {
  34145. m.bot_id = &s
  34146. }
  34147. // BotID returns the value of the "bot_id" field in the mutation.
  34148. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  34149. v := m.bot_id
  34150. if v == nil {
  34151. return
  34152. }
  34153. return *v, true
  34154. }
  34155. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  34156. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34158. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  34159. if !m.op.Is(OpUpdateOne) {
  34160. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34161. }
  34162. if m.id == nil || m.oldValue == nil {
  34163. return v, errors.New("OldBotID requires an ID field in the mutation")
  34164. }
  34165. oldValue, err := m.oldValue(ctx)
  34166. if err != nil {
  34167. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34168. }
  34169. return oldValue.BotID, nil
  34170. }
  34171. // ResetBotID resets all changes to the "bot_id" field.
  34172. func (m *UsageTotalMutation) ResetBotID() {
  34173. m.bot_id = nil
  34174. }
  34175. // SetTotalTokens sets the "total_tokens" field.
  34176. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  34177. m.total_tokens = &u
  34178. m.addtotal_tokens = nil
  34179. }
  34180. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  34181. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  34182. v := m.total_tokens
  34183. if v == nil {
  34184. return
  34185. }
  34186. return *v, true
  34187. }
  34188. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  34189. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34191. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  34192. if !m.op.Is(OpUpdateOne) {
  34193. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  34194. }
  34195. if m.id == nil || m.oldValue == nil {
  34196. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  34197. }
  34198. oldValue, err := m.oldValue(ctx)
  34199. if err != nil {
  34200. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  34201. }
  34202. return oldValue.TotalTokens, nil
  34203. }
  34204. // AddTotalTokens adds u to the "total_tokens" field.
  34205. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  34206. if m.addtotal_tokens != nil {
  34207. *m.addtotal_tokens += u
  34208. } else {
  34209. m.addtotal_tokens = &u
  34210. }
  34211. }
  34212. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  34213. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  34214. v := m.addtotal_tokens
  34215. if v == nil {
  34216. return
  34217. }
  34218. return *v, true
  34219. }
  34220. // ClearTotalTokens clears the value of the "total_tokens" field.
  34221. func (m *UsageTotalMutation) ClearTotalTokens() {
  34222. m.total_tokens = nil
  34223. m.addtotal_tokens = nil
  34224. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  34225. }
  34226. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  34227. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  34228. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  34229. return ok
  34230. }
  34231. // ResetTotalTokens resets all changes to the "total_tokens" field.
  34232. func (m *UsageTotalMutation) ResetTotalTokens() {
  34233. m.total_tokens = nil
  34234. m.addtotal_tokens = nil
  34235. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  34236. }
  34237. // SetStartIndex sets the "start_index" field.
  34238. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  34239. m.start_index = &u
  34240. m.addstart_index = nil
  34241. }
  34242. // StartIndex returns the value of the "start_index" field in the mutation.
  34243. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  34244. v := m.start_index
  34245. if v == nil {
  34246. return
  34247. }
  34248. return *v, true
  34249. }
  34250. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  34251. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34253. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  34254. if !m.op.Is(OpUpdateOne) {
  34255. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  34256. }
  34257. if m.id == nil || m.oldValue == nil {
  34258. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  34259. }
  34260. oldValue, err := m.oldValue(ctx)
  34261. if err != nil {
  34262. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  34263. }
  34264. return oldValue.StartIndex, nil
  34265. }
  34266. // AddStartIndex adds u to the "start_index" field.
  34267. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  34268. if m.addstart_index != nil {
  34269. *m.addstart_index += u
  34270. } else {
  34271. m.addstart_index = &u
  34272. }
  34273. }
  34274. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  34275. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  34276. v := m.addstart_index
  34277. if v == nil {
  34278. return
  34279. }
  34280. return *v, true
  34281. }
  34282. // ClearStartIndex clears the value of the "start_index" field.
  34283. func (m *UsageTotalMutation) ClearStartIndex() {
  34284. m.start_index = nil
  34285. m.addstart_index = nil
  34286. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  34287. }
  34288. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  34289. func (m *UsageTotalMutation) StartIndexCleared() bool {
  34290. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  34291. return ok
  34292. }
  34293. // ResetStartIndex resets all changes to the "start_index" field.
  34294. func (m *UsageTotalMutation) ResetStartIndex() {
  34295. m.start_index = nil
  34296. m.addstart_index = nil
  34297. delete(m.clearedFields, usagetotal.FieldStartIndex)
  34298. }
  34299. // SetEndIndex sets the "end_index" field.
  34300. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  34301. m.end_index = &u
  34302. m.addend_index = nil
  34303. }
  34304. // EndIndex returns the value of the "end_index" field in the mutation.
  34305. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  34306. v := m.end_index
  34307. if v == nil {
  34308. return
  34309. }
  34310. return *v, true
  34311. }
  34312. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  34313. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34315. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  34316. if !m.op.Is(OpUpdateOne) {
  34317. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  34318. }
  34319. if m.id == nil || m.oldValue == nil {
  34320. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  34321. }
  34322. oldValue, err := m.oldValue(ctx)
  34323. if err != nil {
  34324. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  34325. }
  34326. return oldValue.EndIndex, nil
  34327. }
  34328. // AddEndIndex adds u to the "end_index" field.
  34329. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  34330. if m.addend_index != nil {
  34331. *m.addend_index += u
  34332. } else {
  34333. m.addend_index = &u
  34334. }
  34335. }
  34336. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  34337. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  34338. v := m.addend_index
  34339. if v == nil {
  34340. return
  34341. }
  34342. return *v, true
  34343. }
  34344. // ClearEndIndex clears the value of the "end_index" field.
  34345. func (m *UsageTotalMutation) ClearEndIndex() {
  34346. m.end_index = nil
  34347. m.addend_index = nil
  34348. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  34349. }
  34350. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  34351. func (m *UsageTotalMutation) EndIndexCleared() bool {
  34352. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  34353. return ok
  34354. }
  34355. // ResetEndIndex resets all changes to the "end_index" field.
  34356. func (m *UsageTotalMutation) ResetEndIndex() {
  34357. m.end_index = nil
  34358. m.addend_index = nil
  34359. delete(m.clearedFields, usagetotal.FieldEndIndex)
  34360. }
  34361. // SetOrganizationID sets the "organization_id" field.
  34362. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  34363. m.organization_id = &u
  34364. m.addorganization_id = nil
  34365. }
  34366. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34367. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  34368. v := m.organization_id
  34369. if v == nil {
  34370. return
  34371. }
  34372. return *v, true
  34373. }
  34374. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  34375. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  34376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34377. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34378. if !m.op.Is(OpUpdateOne) {
  34379. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34380. }
  34381. if m.id == nil || m.oldValue == nil {
  34382. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34383. }
  34384. oldValue, err := m.oldValue(ctx)
  34385. if err != nil {
  34386. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34387. }
  34388. return oldValue.OrganizationID, nil
  34389. }
  34390. // AddOrganizationID adds u to the "organization_id" field.
  34391. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  34392. if m.addorganization_id != nil {
  34393. *m.addorganization_id += u
  34394. } else {
  34395. m.addorganization_id = &u
  34396. }
  34397. }
  34398. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34399. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  34400. v := m.addorganization_id
  34401. if v == nil {
  34402. return
  34403. }
  34404. return *v, true
  34405. }
  34406. // ClearOrganizationID clears the value of the "organization_id" field.
  34407. func (m *UsageTotalMutation) ClearOrganizationID() {
  34408. m.organization_id = nil
  34409. m.addorganization_id = nil
  34410. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  34411. }
  34412. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34413. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  34414. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  34415. return ok
  34416. }
  34417. // ResetOrganizationID resets all changes to the "organization_id" field.
  34418. func (m *UsageTotalMutation) ResetOrganizationID() {
  34419. m.organization_id = nil
  34420. m.addorganization_id = nil
  34421. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  34422. }
  34423. // Where appends a list predicates to the UsageTotalMutation builder.
  34424. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  34425. m.predicates = append(m.predicates, ps...)
  34426. }
  34427. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  34428. // users can use type-assertion to append predicates that do not depend on any generated package.
  34429. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  34430. p := make([]predicate.UsageTotal, len(ps))
  34431. for i := range ps {
  34432. p[i] = ps[i]
  34433. }
  34434. m.Where(p...)
  34435. }
  34436. // Op returns the operation name.
  34437. func (m *UsageTotalMutation) Op() Op {
  34438. return m.op
  34439. }
  34440. // SetOp allows setting the mutation operation.
  34441. func (m *UsageTotalMutation) SetOp(op Op) {
  34442. m.op = op
  34443. }
  34444. // Type returns the node type of this mutation (UsageTotal).
  34445. func (m *UsageTotalMutation) Type() string {
  34446. return m.typ
  34447. }
  34448. // Fields returns all fields that were changed during this mutation. Note that in
  34449. // order to get all numeric fields that were incremented/decremented, call
  34450. // AddedFields().
  34451. func (m *UsageTotalMutation) Fields() []string {
  34452. fields := make([]string, 0, 9)
  34453. if m.created_at != nil {
  34454. fields = append(fields, usagetotal.FieldCreatedAt)
  34455. }
  34456. if m.updated_at != nil {
  34457. fields = append(fields, usagetotal.FieldUpdatedAt)
  34458. }
  34459. if m.status != nil {
  34460. fields = append(fields, usagetotal.FieldStatus)
  34461. }
  34462. if m._type != nil {
  34463. fields = append(fields, usagetotal.FieldType)
  34464. }
  34465. if m.bot_id != nil {
  34466. fields = append(fields, usagetotal.FieldBotID)
  34467. }
  34468. if m.total_tokens != nil {
  34469. fields = append(fields, usagetotal.FieldTotalTokens)
  34470. }
  34471. if m.start_index != nil {
  34472. fields = append(fields, usagetotal.FieldStartIndex)
  34473. }
  34474. if m.end_index != nil {
  34475. fields = append(fields, usagetotal.FieldEndIndex)
  34476. }
  34477. if m.organization_id != nil {
  34478. fields = append(fields, usagetotal.FieldOrganizationID)
  34479. }
  34480. return fields
  34481. }
  34482. // Field returns the value of a field with the given name. The second boolean
  34483. // return value indicates that this field was not set, or was not defined in the
  34484. // schema.
  34485. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  34486. switch name {
  34487. case usagetotal.FieldCreatedAt:
  34488. return m.CreatedAt()
  34489. case usagetotal.FieldUpdatedAt:
  34490. return m.UpdatedAt()
  34491. case usagetotal.FieldStatus:
  34492. return m.Status()
  34493. case usagetotal.FieldType:
  34494. return m.GetType()
  34495. case usagetotal.FieldBotID:
  34496. return m.BotID()
  34497. case usagetotal.FieldTotalTokens:
  34498. return m.TotalTokens()
  34499. case usagetotal.FieldStartIndex:
  34500. return m.StartIndex()
  34501. case usagetotal.FieldEndIndex:
  34502. return m.EndIndex()
  34503. case usagetotal.FieldOrganizationID:
  34504. return m.OrganizationID()
  34505. }
  34506. return nil, false
  34507. }
  34508. // OldField returns the old value of the field from the database. An error is
  34509. // returned if the mutation operation is not UpdateOne, or the query to the
  34510. // database failed.
  34511. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34512. switch name {
  34513. case usagetotal.FieldCreatedAt:
  34514. return m.OldCreatedAt(ctx)
  34515. case usagetotal.FieldUpdatedAt:
  34516. return m.OldUpdatedAt(ctx)
  34517. case usagetotal.FieldStatus:
  34518. return m.OldStatus(ctx)
  34519. case usagetotal.FieldType:
  34520. return m.OldType(ctx)
  34521. case usagetotal.FieldBotID:
  34522. return m.OldBotID(ctx)
  34523. case usagetotal.FieldTotalTokens:
  34524. return m.OldTotalTokens(ctx)
  34525. case usagetotal.FieldStartIndex:
  34526. return m.OldStartIndex(ctx)
  34527. case usagetotal.FieldEndIndex:
  34528. return m.OldEndIndex(ctx)
  34529. case usagetotal.FieldOrganizationID:
  34530. return m.OldOrganizationID(ctx)
  34531. }
  34532. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  34533. }
  34534. // SetField sets the value of a field with the given name. It returns an error if
  34535. // the field is not defined in the schema, or if the type mismatched the field
  34536. // type.
  34537. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  34538. switch name {
  34539. case usagetotal.FieldCreatedAt:
  34540. v, ok := value.(time.Time)
  34541. if !ok {
  34542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34543. }
  34544. m.SetCreatedAt(v)
  34545. return nil
  34546. case usagetotal.FieldUpdatedAt:
  34547. v, ok := value.(time.Time)
  34548. if !ok {
  34549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34550. }
  34551. m.SetUpdatedAt(v)
  34552. return nil
  34553. case usagetotal.FieldStatus:
  34554. v, ok := value.(uint8)
  34555. if !ok {
  34556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34557. }
  34558. m.SetStatus(v)
  34559. return nil
  34560. case usagetotal.FieldType:
  34561. v, ok := value.(int)
  34562. if !ok {
  34563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34564. }
  34565. m.SetType(v)
  34566. return nil
  34567. case usagetotal.FieldBotID:
  34568. v, ok := value.(string)
  34569. if !ok {
  34570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34571. }
  34572. m.SetBotID(v)
  34573. return nil
  34574. case usagetotal.FieldTotalTokens:
  34575. v, ok := value.(uint64)
  34576. if !ok {
  34577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34578. }
  34579. m.SetTotalTokens(v)
  34580. return nil
  34581. case usagetotal.FieldStartIndex:
  34582. v, ok := value.(uint64)
  34583. if !ok {
  34584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34585. }
  34586. m.SetStartIndex(v)
  34587. return nil
  34588. case usagetotal.FieldEndIndex:
  34589. v, ok := value.(uint64)
  34590. if !ok {
  34591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34592. }
  34593. m.SetEndIndex(v)
  34594. return nil
  34595. case usagetotal.FieldOrganizationID:
  34596. v, ok := value.(uint64)
  34597. if !ok {
  34598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34599. }
  34600. m.SetOrganizationID(v)
  34601. return nil
  34602. }
  34603. return fmt.Errorf("unknown UsageTotal field %s", name)
  34604. }
  34605. // AddedFields returns all numeric fields that were incremented/decremented during
  34606. // this mutation.
  34607. func (m *UsageTotalMutation) AddedFields() []string {
  34608. var fields []string
  34609. if m.addstatus != nil {
  34610. fields = append(fields, usagetotal.FieldStatus)
  34611. }
  34612. if m.add_type != nil {
  34613. fields = append(fields, usagetotal.FieldType)
  34614. }
  34615. if m.addtotal_tokens != nil {
  34616. fields = append(fields, usagetotal.FieldTotalTokens)
  34617. }
  34618. if m.addstart_index != nil {
  34619. fields = append(fields, usagetotal.FieldStartIndex)
  34620. }
  34621. if m.addend_index != nil {
  34622. fields = append(fields, usagetotal.FieldEndIndex)
  34623. }
  34624. if m.addorganization_id != nil {
  34625. fields = append(fields, usagetotal.FieldOrganizationID)
  34626. }
  34627. return fields
  34628. }
  34629. // AddedField returns the numeric value that was incremented/decremented on a field
  34630. // with the given name. The second boolean return value indicates that this field
  34631. // was not set, or was not defined in the schema.
  34632. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  34633. switch name {
  34634. case usagetotal.FieldStatus:
  34635. return m.AddedStatus()
  34636. case usagetotal.FieldType:
  34637. return m.AddedType()
  34638. case usagetotal.FieldTotalTokens:
  34639. return m.AddedTotalTokens()
  34640. case usagetotal.FieldStartIndex:
  34641. return m.AddedStartIndex()
  34642. case usagetotal.FieldEndIndex:
  34643. return m.AddedEndIndex()
  34644. case usagetotal.FieldOrganizationID:
  34645. return m.AddedOrganizationID()
  34646. }
  34647. return nil, false
  34648. }
  34649. // AddField adds the value to the field with the given name. It returns an error if
  34650. // the field is not defined in the schema, or if the type mismatched the field
  34651. // type.
  34652. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  34653. switch name {
  34654. case usagetotal.FieldStatus:
  34655. v, ok := value.(int8)
  34656. if !ok {
  34657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34658. }
  34659. m.AddStatus(v)
  34660. return nil
  34661. case usagetotal.FieldType:
  34662. v, ok := value.(int)
  34663. if !ok {
  34664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34665. }
  34666. m.AddType(v)
  34667. return nil
  34668. case usagetotal.FieldTotalTokens:
  34669. v, ok := value.(int64)
  34670. if !ok {
  34671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34672. }
  34673. m.AddTotalTokens(v)
  34674. return nil
  34675. case usagetotal.FieldStartIndex:
  34676. v, ok := value.(int64)
  34677. if !ok {
  34678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34679. }
  34680. m.AddStartIndex(v)
  34681. return nil
  34682. case usagetotal.FieldEndIndex:
  34683. v, ok := value.(int64)
  34684. if !ok {
  34685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34686. }
  34687. m.AddEndIndex(v)
  34688. return nil
  34689. case usagetotal.FieldOrganizationID:
  34690. v, ok := value.(int64)
  34691. if !ok {
  34692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34693. }
  34694. m.AddOrganizationID(v)
  34695. return nil
  34696. }
  34697. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  34698. }
  34699. // ClearedFields returns all nullable fields that were cleared during this
  34700. // mutation.
  34701. func (m *UsageTotalMutation) ClearedFields() []string {
  34702. var fields []string
  34703. if m.FieldCleared(usagetotal.FieldStatus) {
  34704. fields = append(fields, usagetotal.FieldStatus)
  34705. }
  34706. if m.FieldCleared(usagetotal.FieldType) {
  34707. fields = append(fields, usagetotal.FieldType)
  34708. }
  34709. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  34710. fields = append(fields, usagetotal.FieldTotalTokens)
  34711. }
  34712. if m.FieldCleared(usagetotal.FieldStartIndex) {
  34713. fields = append(fields, usagetotal.FieldStartIndex)
  34714. }
  34715. if m.FieldCleared(usagetotal.FieldEndIndex) {
  34716. fields = append(fields, usagetotal.FieldEndIndex)
  34717. }
  34718. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  34719. fields = append(fields, usagetotal.FieldOrganizationID)
  34720. }
  34721. return fields
  34722. }
  34723. // FieldCleared returns a boolean indicating if a field with the given name was
  34724. // cleared in this mutation.
  34725. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  34726. _, ok := m.clearedFields[name]
  34727. return ok
  34728. }
  34729. // ClearField clears the value of the field with the given name. It returns an
  34730. // error if the field is not defined in the schema.
  34731. func (m *UsageTotalMutation) ClearField(name string) error {
  34732. switch name {
  34733. case usagetotal.FieldStatus:
  34734. m.ClearStatus()
  34735. return nil
  34736. case usagetotal.FieldType:
  34737. m.ClearType()
  34738. return nil
  34739. case usagetotal.FieldTotalTokens:
  34740. m.ClearTotalTokens()
  34741. return nil
  34742. case usagetotal.FieldStartIndex:
  34743. m.ClearStartIndex()
  34744. return nil
  34745. case usagetotal.FieldEndIndex:
  34746. m.ClearEndIndex()
  34747. return nil
  34748. case usagetotal.FieldOrganizationID:
  34749. m.ClearOrganizationID()
  34750. return nil
  34751. }
  34752. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  34753. }
  34754. // ResetField resets all changes in the mutation for the field with the given name.
  34755. // It returns an error if the field is not defined in the schema.
  34756. func (m *UsageTotalMutation) ResetField(name string) error {
  34757. switch name {
  34758. case usagetotal.FieldCreatedAt:
  34759. m.ResetCreatedAt()
  34760. return nil
  34761. case usagetotal.FieldUpdatedAt:
  34762. m.ResetUpdatedAt()
  34763. return nil
  34764. case usagetotal.FieldStatus:
  34765. m.ResetStatus()
  34766. return nil
  34767. case usagetotal.FieldType:
  34768. m.ResetType()
  34769. return nil
  34770. case usagetotal.FieldBotID:
  34771. m.ResetBotID()
  34772. return nil
  34773. case usagetotal.FieldTotalTokens:
  34774. m.ResetTotalTokens()
  34775. return nil
  34776. case usagetotal.FieldStartIndex:
  34777. m.ResetStartIndex()
  34778. return nil
  34779. case usagetotal.FieldEndIndex:
  34780. m.ResetEndIndex()
  34781. return nil
  34782. case usagetotal.FieldOrganizationID:
  34783. m.ResetOrganizationID()
  34784. return nil
  34785. }
  34786. return fmt.Errorf("unknown UsageTotal field %s", name)
  34787. }
  34788. // AddedEdges returns all edge names that were set/added in this mutation.
  34789. func (m *UsageTotalMutation) AddedEdges() []string {
  34790. edges := make([]string, 0, 0)
  34791. return edges
  34792. }
  34793. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34794. // name in this mutation.
  34795. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  34796. return nil
  34797. }
  34798. // RemovedEdges returns all edge names that were removed in this mutation.
  34799. func (m *UsageTotalMutation) RemovedEdges() []string {
  34800. edges := make([]string, 0, 0)
  34801. return edges
  34802. }
  34803. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34804. // the given name in this mutation.
  34805. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  34806. return nil
  34807. }
  34808. // ClearedEdges returns all edge names that were cleared in this mutation.
  34809. func (m *UsageTotalMutation) ClearedEdges() []string {
  34810. edges := make([]string, 0, 0)
  34811. return edges
  34812. }
  34813. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34814. // was cleared in this mutation.
  34815. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  34816. return false
  34817. }
  34818. // ClearEdge clears the value of the edge with the given name. It returns an error
  34819. // if that edge is not defined in the schema.
  34820. func (m *UsageTotalMutation) ClearEdge(name string) error {
  34821. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  34822. }
  34823. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34824. // It returns an error if the edge is not defined in the schema.
  34825. func (m *UsageTotalMutation) ResetEdge(name string) error {
  34826. return fmt.Errorf("unknown UsageTotal edge %s", name)
  34827. }
  34828. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  34829. type WhatsappMutation struct {
  34830. config
  34831. op Op
  34832. typ string
  34833. id *uint64
  34834. created_at *time.Time
  34835. updated_at *time.Time
  34836. status *uint8
  34837. addstatus *int8
  34838. deleted_at *time.Time
  34839. wa_id *string
  34840. wa_name *string
  34841. callback *string
  34842. account *string
  34843. cc *string
  34844. phone *string
  34845. cc_phone *string
  34846. phone_name *string
  34847. phone_status *int8
  34848. addphone_status *int8
  34849. organization_id *uint64
  34850. addorganization_id *int64
  34851. api_base *string
  34852. api_key *string
  34853. allow_list *[]string
  34854. appendallow_list []string
  34855. group_allow_list *[]string
  34856. appendgroup_allow_list []string
  34857. block_list *[]string
  34858. appendblock_list []string
  34859. group_block_list *[]string
  34860. appendgroup_block_list []string
  34861. clearedFields map[string]struct{}
  34862. agent *uint64
  34863. clearedagent bool
  34864. done bool
  34865. oldValue func(context.Context) (*Whatsapp, error)
  34866. predicates []predicate.Whatsapp
  34867. }
  34868. var _ ent.Mutation = (*WhatsappMutation)(nil)
  34869. // whatsappOption allows management of the mutation configuration using functional options.
  34870. type whatsappOption func(*WhatsappMutation)
  34871. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  34872. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  34873. m := &WhatsappMutation{
  34874. config: c,
  34875. op: op,
  34876. typ: TypeWhatsapp,
  34877. clearedFields: make(map[string]struct{}),
  34878. }
  34879. for _, opt := range opts {
  34880. opt(m)
  34881. }
  34882. return m
  34883. }
  34884. // withWhatsappID sets the ID field of the mutation.
  34885. func withWhatsappID(id uint64) whatsappOption {
  34886. return func(m *WhatsappMutation) {
  34887. var (
  34888. err error
  34889. once sync.Once
  34890. value *Whatsapp
  34891. )
  34892. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  34893. once.Do(func() {
  34894. if m.done {
  34895. err = errors.New("querying old values post mutation is not allowed")
  34896. } else {
  34897. value, err = m.Client().Whatsapp.Get(ctx, id)
  34898. }
  34899. })
  34900. return value, err
  34901. }
  34902. m.id = &id
  34903. }
  34904. }
  34905. // withWhatsapp sets the old Whatsapp of the mutation.
  34906. func withWhatsapp(node *Whatsapp) whatsappOption {
  34907. return func(m *WhatsappMutation) {
  34908. m.oldValue = func(context.Context) (*Whatsapp, error) {
  34909. return node, nil
  34910. }
  34911. m.id = &node.ID
  34912. }
  34913. }
  34914. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34915. // executed in a transaction (ent.Tx), a transactional client is returned.
  34916. func (m WhatsappMutation) Client() *Client {
  34917. client := &Client{config: m.config}
  34918. client.init()
  34919. return client
  34920. }
  34921. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34922. // it returns an error otherwise.
  34923. func (m WhatsappMutation) Tx() (*Tx, error) {
  34924. if _, ok := m.driver.(*txDriver); !ok {
  34925. return nil, errors.New("ent: mutation is not running in a transaction")
  34926. }
  34927. tx := &Tx{config: m.config}
  34928. tx.init()
  34929. return tx, nil
  34930. }
  34931. // SetID sets the value of the id field. Note that this
  34932. // operation is only accepted on creation of Whatsapp entities.
  34933. func (m *WhatsappMutation) SetID(id uint64) {
  34934. m.id = &id
  34935. }
  34936. // ID returns the ID value in the mutation. Note that the ID is only available
  34937. // if it was provided to the builder or after it was returned from the database.
  34938. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  34939. if m.id == nil {
  34940. return
  34941. }
  34942. return *m.id, true
  34943. }
  34944. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34945. // That means, if the mutation is applied within a transaction with an isolation level such
  34946. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34947. // or updated by the mutation.
  34948. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  34949. switch {
  34950. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34951. id, exists := m.ID()
  34952. if exists {
  34953. return []uint64{id}, nil
  34954. }
  34955. fallthrough
  34956. case m.op.Is(OpUpdate | OpDelete):
  34957. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  34958. default:
  34959. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34960. }
  34961. }
  34962. // SetCreatedAt sets the "created_at" field.
  34963. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  34964. m.created_at = &t
  34965. }
  34966. // CreatedAt returns the value of the "created_at" field in the mutation.
  34967. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  34968. v := m.created_at
  34969. if v == nil {
  34970. return
  34971. }
  34972. return *v, true
  34973. }
  34974. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  34975. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34977. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34978. if !m.op.Is(OpUpdateOne) {
  34979. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34980. }
  34981. if m.id == nil || m.oldValue == nil {
  34982. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34983. }
  34984. oldValue, err := m.oldValue(ctx)
  34985. if err != nil {
  34986. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34987. }
  34988. return oldValue.CreatedAt, nil
  34989. }
  34990. // ResetCreatedAt resets all changes to the "created_at" field.
  34991. func (m *WhatsappMutation) ResetCreatedAt() {
  34992. m.created_at = nil
  34993. }
  34994. // SetUpdatedAt sets the "updated_at" field.
  34995. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  34996. m.updated_at = &t
  34997. }
  34998. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34999. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  35000. v := m.updated_at
  35001. if v == nil {
  35002. return
  35003. }
  35004. return *v, true
  35005. }
  35006. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  35007. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35009. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35010. if !m.op.Is(OpUpdateOne) {
  35011. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35012. }
  35013. if m.id == nil || m.oldValue == nil {
  35014. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35015. }
  35016. oldValue, err := m.oldValue(ctx)
  35017. if err != nil {
  35018. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35019. }
  35020. return oldValue.UpdatedAt, nil
  35021. }
  35022. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35023. func (m *WhatsappMutation) ResetUpdatedAt() {
  35024. m.updated_at = nil
  35025. }
  35026. // SetStatus sets the "status" field.
  35027. func (m *WhatsappMutation) SetStatus(u uint8) {
  35028. m.status = &u
  35029. m.addstatus = nil
  35030. }
  35031. // Status returns the value of the "status" field in the mutation.
  35032. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  35033. v := m.status
  35034. if v == nil {
  35035. return
  35036. }
  35037. return *v, true
  35038. }
  35039. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  35040. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35042. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35043. if !m.op.Is(OpUpdateOne) {
  35044. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35045. }
  35046. if m.id == nil || m.oldValue == nil {
  35047. return v, errors.New("OldStatus requires an ID field in the mutation")
  35048. }
  35049. oldValue, err := m.oldValue(ctx)
  35050. if err != nil {
  35051. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35052. }
  35053. return oldValue.Status, nil
  35054. }
  35055. // AddStatus adds u to the "status" field.
  35056. func (m *WhatsappMutation) AddStatus(u int8) {
  35057. if m.addstatus != nil {
  35058. *m.addstatus += u
  35059. } else {
  35060. m.addstatus = &u
  35061. }
  35062. }
  35063. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35064. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  35065. v := m.addstatus
  35066. if v == nil {
  35067. return
  35068. }
  35069. return *v, true
  35070. }
  35071. // ClearStatus clears the value of the "status" field.
  35072. func (m *WhatsappMutation) ClearStatus() {
  35073. m.status = nil
  35074. m.addstatus = nil
  35075. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  35076. }
  35077. // StatusCleared returns if the "status" field was cleared in this mutation.
  35078. func (m *WhatsappMutation) StatusCleared() bool {
  35079. _, ok := m.clearedFields[whatsapp.FieldStatus]
  35080. return ok
  35081. }
  35082. // ResetStatus resets all changes to the "status" field.
  35083. func (m *WhatsappMutation) ResetStatus() {
  35084. m.status = nil
  35085. m.addstatus = nil
  35086. delete(m.clearedFields, whatsapp.FieldStatus)
  35087. }
  35088. // SetDeletedAt sets the "deleted_at" field.
  35089. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  35090. m.deleted_at = &t
  35091. }
  35092. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35093. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  35094. v := m.deleted_at
  35095. if v == nil {
  35096. return
  35097. }
  35098. return *v, true
  35099. }
  35100. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  35101. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35103. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35104. if !m.op.Is(OpUpdateOne) {
  35105. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35106. }
  35107. if m.id == nil || m.oldValue == nil {
  35108. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35109. }
  35110. oldValue, err := m.oldValue(ctx)
  35111. if err != nil {
  35112. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35113. }
  35114. return oldValue.DeletedAt, nil
  35115. }
  35116. // ClearDeletedAt clears the value of the "deleted_at" field.
  35117. func (m *WhatsappMutation) ClearDeletedAt() {
  35118. m.deleted_at = nil
  35119. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  35120. }
  35121. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35122. func (m *WhatsappMutation) DeletedAtCleared() bool {
  35123. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  35124. return ok
  35125. }
  35126. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35127. func (m *WhatsappMutation) ResetDeletedAt() {
  35128. m.deleted_at = nil
  35129. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  35130. }
  35131. // SetWaID sets the "wa_id" field.
  35132. func (m *WhatsappMutation) SetWaID(s string) {
  35133. m.wa_id = &s
  35134. }
  35135. // WaID returns the value of the "wa_id" field in the mutation.
  35136. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  35137. v := m.wa_id
  35138. if v == nil {
  35139. return
  35140. }
  35141. return *v, true
  35142. }
  35143. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  35144. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35146. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  35147. if !m.op.Is(OpUpdateOne) {
  35148. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  35149. }
  35150. if m.id == nil || m.oldValue == nil {
  35151. return v, errors.New("OldWaID requires an ID field in the mutation")
  35152. }
  35153. oldValue, err := m.oldValue(ctx)
  35154. if err != nil {
  35155. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  35156. }
  35157. return oldValue.WaID, nil
  35158. }
  35159. // ClearWaID clears the value of the "wa_id" field.
  35160. func (m *WhatsappMutation) ClearWaID() {
  35161. m.wa_id = nil
  35162. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  35163. }
  35164. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  35165. func (m *WhatsappMutation) WaIDCleared() bool {
  35166. _, ok := m.clearedFields[whatsapp.FieldWaID]
  35167. return ok
  35168. }
  35169. // ResetWaID resets all changes to the "wa_id" field.
  35170. func (m *WhatsappMutation) ResetWaID() {
  35171. m.wa_id = nil
  35172. delete(m.clearedFields, whatsapp.FieldWaID)
  35173. }
  35174. // SetWaName sets the "wa_name" field.
  35175. func (m *WhatsappMutation) SetWaName(s string) {
  35176. m.wa_name = &s
  35177. }
  35178. // WaName returns the value of the "wa_name" field in the mutation.
  35179. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  35180. v := m.wa_name
  35181. if v == nil {
  35182. return
  35183. }
  35184. return *v, true
  35185. }
  35186. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  35187. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35189. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  35190. if !m.op.Is(OpUpdateOne) {
  35191. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  35192. }
  35193. if m.id == nil || m.oldValue == nil {
  35194. return v, errors.New("OldWaName requires an ID field in the mutation")
  35195. }
  35196. oldValue, err := m.oldValue(ctx)
  35197. if err != nil {
  35198. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  35199. }
  35200. return oldValue.WaName, nil
  35201. }
  35202. // ClearWaName clears the value of the "wa_name" field.
  35203. func (m *WhatsappMutation) ClearWaName() {
  35204. m.wa_name = nil
  35205. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  35206. }
  35207. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  35208. func (m *WhatsappMutation) WaNameCleared() bool {
  35209. _, ok := m.clearedFields[whatsapp.FieldWaName]
  35210. return ok
  35211. }
  35212. // ResetWaName resets all changes to the "wa_name" field.
  35213. func (m *WhatsappMutation) ResetWaName() {
  35214. m.wa_name = nil
  35215. delete(m.clearedFields, whatsapp.FieldWaName)
  35216. }
  35217. // SetCallback sets the "callback" field.
  35218. func (m *WhatsappMutation) SetCallback(s string) {
  35219. m.callback = &s
  35220. }
  35221. // Callback returns the value of the "callback" field in the mutation.
  35222. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  35223. v := m.callback
  35224. if v == nil {
  35225. return
  35226. }
  35227. return *v, true
  35228. }
  35229. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  35230. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35232. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  35233. if !m.op.Is(OpUpdateOne) {
  35234. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  35235. }
  35236. if m.id == nil || m.oldValue == nil {
  35237. return v, errors.New("OldCallback requires an ID field in the mutation")
  35238. }
  35239. oldValue, err := m.oldValue(ctx)
  35240. if err != nil {
  35241. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  35242. }
  35243. return oldValue.Callback, nil
  35244. }
  35245. // ClearCallback clears the value of the "callback" field.
  35246. func (m *WhatsappMutation) ClearCallback() {
  35247. m.callback = nil
  35248. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  35249. }
  35250. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  35251. func (m *WhatsappMutation) CallbackCleared() bool {
  35252. _, ok := m.clearedFields[whatsapp.FieldCallback]
  35253. return ok
  35254. }
  35255. // ResetCallback resets all changes to the "callback" field.
  35256. func (m *WhatsappMutation) ResetCallback() {
  35257. m.callback = nil
  35258. delete(m.clearedFields, whatsapp.FieldCallback)
  35259. }
  35260. // SetAgentID sets the "agent_id" field.
  35261. func (m *WhatsappMutation) SetAgentID(u uint64) {
  35262. m.agent = &u
  35263. }
  35264. // AgentID returns the value of the "agent_id" field in the mutation.
  35265. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  35266. v := m.agent
  35267. if v == nil {
  35268. return
  35269. }
  35270. return *v, true
  35271. }
  35272. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  35273. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35275. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  35276. if !m.op.Is(OpUpdateOne) {
  35277. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  35278. }
  35279. if m.id == nil || m.oldValue == nil {
  35280. return v, errors.New("OldAgentID requires an ID field in the mutation")
  35281. }
  35282. oldValue, err := m.oldValue(ctx)
  35283. if err != nil {
  35284. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  35285. }
  35286. return oldValue.AgentID, nil
  35287. }
  35288. // ResetAgentID resets all changes to the "agent_id" field.
  35289. func (m *WhatsappMutation) ResetAgentID() {
  35290. m.agent = nil
  35291. }
  35292. // SetAccount sets the "account" field.
  35293. func (m *WhatsappMutation) SetAccount(s string) {
  35294. m.account = &s
  35295. }
  35296. // Account returns the value of the "account" field in the mutation.
  35297. func (m *WhatsappMutation) Account() (r string, exists bool) {
  35298. v := m.account
  35299. if v == nil {
  35300. return
  35301. }
  35302. return *v, true
  35303. }
  35304. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  35305. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35307. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  35308. if !m.op.Is(OpUpdateOne) {
  35309. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  35310. }
  35311. if m.id == nil || m.oldValue == nil {
  35312. return v, errors.New("OldAccount requires an ID field in the mutation")
  35313. }
  35314. oldValue, err := m.oldValue(ctx)
  35315. if err != nil {
  35316. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  35317. }
  35318. return oldValue.Account, nil
  35319. }
  35320. // ClearAccount clears the value of the "account" field.
  35321. func (m *WhatsappMutation) ClearAccount() {
  35322. m.account = nil
  35323. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  35324. }
  35325. // AccountCleared returns if the "account" field was cleared in this mutation.
  35326. func (m *WhatsappMutation) AccountCleared() bool {
  35327. _, ok := m.clearedFields[whatsapp.FieldAccount]
  35328. return ok
  35329. }
  35330. // ResetAccount resets all changes to the "account" field.
  35331. func (m *WhatsappMutation) ResetAccount() {
  35332. m.account = nil
  35333. delete(m.clearedFields, whatsapp.FieldAccount)
  35334. }
  35335. // SetCc sets the "cc" field.
  35336. func (m *WhatsappMutation) SetCc(s string) {
  35337. m.cc = &s
  35338. }
  35339. // Cc returns the value of the "cc" field in the mutation.
  35340. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  35341. v := m.cc
  35342. if v == nil {
  35343. return
  35344. }
  35345. return *v, true
  35346. }
  35347. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  35348. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35350. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  35351. if !m.op.Is(OpUpdateOne) {
  35352. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  35353. }
  35354. if m.id == nil || m.oldValue == nil {
  35355. return v, errors.New("OldCc requires an ID field in the mutation")
  35356. }
  35357. oldValue, err := m.oldValue(ctx)
  35358. if err != nil {
  35359. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  35360. }
  35361. return oldValue.Cc, nil
  35362. }
  35363. // ResetCc resets all changes to the "cc" field.
  35364. func (m *WhatsappMutation) ResetCc() {
  35365. m.cc = nil
  35366. }
  35367. // SetPhone sets the "phone" field.
  35368. func (m *WhatsappMutation) SetPhone(s string) {
  35369. m.phone = &s
  35370. }
  35371. // Phone returns the value of the "phone" field in the mutation.
  35372. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  35373. v := m.phone
  35374. if v == nil {
  35375. return
  35376. }
  35377. return *v, true
  35378. }
  35379. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  35380. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35382. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  35383. if !m.op.Is(OpUpdateOne) {
  35384. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  35385. }
  35386. if m.id == nil || m.oldValue == nil {
  35387. return v, errors.New("OldPhone requires an ID field in the mutation")
  35388. }
  35389. oldValue, err := m.oldValue(ctx)
  35390. if err != nil {
  35391. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  35392. }
  35393. return oldValue.Phone, nil
  35394. }
  35395. // ResetPhone resets all changes to the "phone" field.
  35396. func (m *WhatsappMutation) ResetPhone() {
  35397. m.phone = nil
  35398. }
  35399. // SetCcPhone sets the "cc_phone" field.
  35400. func (m *WhatsappMutation) SetCcPhone(s string) {
  35401. m.cc_phone = &s
  35402. }
  35403. // CcPhone returns the value of the "cc_phone" field in the mutation.
  35404. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  35405. v := m.cc_phone
  35406. if v == nil {
  35407. return
  35408. }
  35409. return *v, true
  35410. }
  35411. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  35412. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35414. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  35415. if !m.op.Is(OpUpdateOne) {
  35416. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  35417. }
  35418. if m.id == nil || m.oldValue == nil {
  35419. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  35420. }
  35421. oldValue, err := m.oldValue(ctx)
  35422. if err != nil {
  35423. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  35424. }
  35425. return oldValue.CcPhone, nil
  35426. }
  35427. // ResetCcPhone resets all changes to the "cc_phone" field.
  35428. func (m *WhatsappMutation) ResetCcPhone() {
  35429. m.cc_phone = nil
  35430. }
  35431. // SetPhoneName sets the "phone_name" field.
  35432. func (m *WhatsappMutation) SetPhoneName(s string) {
  35433. m.phone_name = &s
  35434. }
  35435. // PhoneName returns the value of the "phone_name" field in the mutation.
  35436. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  35437. v := m.phone_name
  35438. if v == nil {
  35439. return
  35440. }
  35441. return *v, true
  35442. }
  35443. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  35444. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35446. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  35447. if !m.op.Is(OpUpdateOne) {
  35448. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  35449. }
  35450. if m.id == nil || m.oldValue == nil {
  35451. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  35452. }
  35453. oldValue, err := m.oldValue(ctx)
  35454. if err != nil {
  35455. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  35456. }
  35457. return oldValue.PhoneName, nil
  35458. }
  35459. // ResetPhoneName resets all changes to the "phone_name" field.
  35460. func (m *WhatsappMutation) ResetPhoneName() {
  35461. m.phone_name = nil
  35462. }
  35463. // SetPhoneStatus sets the "phone_status" field.
  35464. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  35465. m.phone_status = &i
  35466. m.addphone_status = nil
  35467. }
  35468. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  35469. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  35470. v := m.phone_status
  35471. if v == nil {
  35472. return
  35473. }
  35474. return *v, true
  35475. }
  35476. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  35477. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35479. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  35480. if !m.op.Is(OpUpdateOne) {
  35481. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  35482. }
  35483. if m.id == nil || m.oldValue == nil {
  35484. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  35485. }
  35486. oldValue, err := m.oldValue(ctx)
  35487. if err != nil {
  35488. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  35489. }
  35490. return oldValue.PhoneStatus, nil
  35491. }
  35492. // AddPhoneStatus adds i to the "phone_status" field.
  35493. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  35494. if m.addphone_status != nil {
  35495. *m.addphone_status += i
  35496. } else {
  35497. m.addphone_status = &i
  35498. }
  35499. }
  35500. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  35501. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  35502. v := m.addphone_status
  35503. if v == nil {
  35504. return
  35505. }
  35506. return *v, true
  35507. }
  35508. // ResetPhoneStatus resets all changes to the "phone_status" field.
  35509. func (m *WhatsappMutation) ResetPhoneStatus() {
  35510. m.phone_status = nil
  35511. m.addphone_status = nil
  35512. }
  35513. // SetOrganizationID sets the "organization_id" field.
  35514. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  35515. m.organization_id = &u
  35516. m.addorganization_id = nil
  35517. }
  35518. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35519. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  35520. v := m.organization_id
  35521. if v == nil {
  35522. return
  35523. }
  35524. return *v, true
  35525. }
  35526. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  35527. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35529. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35530. if !m.op.Is(OpUpdateOne) {
  35531. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35532. }
  35533. if m.id == nil || m.oldValue == nil {
  35534. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35535. }
  35536. oldValue, err := m.oldValue(ctx)
  35537. if err != nil {
  35538. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35539. }
  35540. return oldValue.OrganizationID, nil
  35541. }
  35542. // AddOrganizationID adds u to the "organization_id" field.
  35543. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  35544. if m.addorganization_id != nil {
  35545. *m.addorganization_id += u
  35546. } else {
  35547. m.addorganization_id = &u
  35548. }
  35549. }
  35550. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35551. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  35552. v := m.addorganization_id
  35553. if v == nil {
  35554. return
  35555. }
  35556. return *v, true
  35557. }
  35558. // ClearOrganizationID clears the value of the "organization_id" field.
  35559. func (m *WhatsappMutation) ClearOrganizationID() {
  35560. m.organization_id = nil
  35561. m.addorganization_id = nil
  35562. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  35563. }
  35564. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35565. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  35566. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  35567. return ok
  35568. }
  35569. // ResetOrganizationID resets all changes to the "organization_id" field.
  35570. func (m *WhatsappMutation) ResetOrganizationID() {
  35571. m.organization_id = nil
  35572. m.addorganization_id = nil
  35573. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  35574. }
  35575. // SetAPIBase sets the "api_base" field.
  35576. func (m *WhatsappMutation) SetAPIBase(s string) {
  35577. m.api_base = &s
  35578. }
  35579. // APIBase returns the value of the "api_base" field in the mutation.
  35580. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  35581. v := m.api_base
  35582. if v == nil {
  35583. return
  35584. }
  35585. return *v, true
  35586. }
  35587. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  35588. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35590. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  35591. if !m.op.Is(OpUpdateOne) {
  35592. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  35593. }
  35594. if m.id == nil || m.oldValue == nil {
  35595. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  35596. }
  35597. oldValue, err := m.oldValue(ctx)
  35598. if err != nil {
  35599. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  35600. }
  35601. return oldValue.APIBase, nil
  35602. }
  35603. // ClearAPIBase clears the value of the "api_base" field.
  35604. func (m *WhatsappMutation) ClearAPIBase() {
  35605. m.api_base = nil
  35606. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  35607. }
  35608. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  35609. func (m *WhatsappMutation) APIBaseCleared() bool {
  35610. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  35611. return ok
  35612. }
  35613. // ResetAPIBase resets all changes to the "api_base" field.
  35614. func (m *WhatsappMutation) ResetAPIBase() {
  35615. m.api_base = nil
  35616. delete(m.clearedFields, whatsapp.FieldAPIBase)
  35617. }
  35618. // SetAPIKey sets the "api_key" field.
  35619. func (m *WhatsappMutation) SetAPIKey(s string) {
  35620. m.api_key = &s
  35621. }
  35622. // APIKey returns the value of the "api_key" field in the mutation.
  35623. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  35624. v := m.api_key
  35625. if v == nil {
  35626. return
  35627. }
  35628. return *v, true
  35629. }
  35630. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  35631. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35633. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  35634. if !m.op.Is(OpUpdateOne) {
  35635. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  35636. }
  35637. if m.id == nil || m.oldValue == nil {
  35638. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  35639. }
  35640. oldValue, err := m.oldValue(ctx)
  35641. if err != nil {
  35642. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  35643. }
  35644. return oldValue.APIKey, nil
  35645. }
  35646. // ClearAPIKey clears the value of the "api_key" field.
  35647. func (m *WhatsappMutation) ClearAPIKey() {
  35648. m.api_key = nil
  35649. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  35650. }
  35651. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  35652. func (m *WhatsappMutation) APIKeyCleared() bool {
  35653. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  35654. return ok
  35655. }
  35656. // ResetAPIKey resets all changes to the "api_key" field.
  35657. func (m *WhatsappMutation) ResetAPIKey() {
  35658. m.api_key = nil
  35659. delete(m.clearedFields, whatsapp.FieldAPIKey)
  35660. }
  35661. // SetAllowList sets the "allow_list" field.
  35662. func (m *WhatsappMutation) SetAllowList(s []string) {
  35663. m.allow_list = &s
  35664. m.appendallow_list = nil
  35665. }
  35666. // AllowList returns the value of the "allow_list" field in the mutation.
  35667. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  35668. v := m.allow_list
  35669. if v == nil {
  35670. return
  35671. }
  35672. return *v, true
  35673. }
  35674. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  35675. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35677. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  35678. if !m.op.Is(OpUpdateOne) {
  35679. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  35680. }
  35681. if m.id == nil || m.oldValue == nil {
  35682. return v, errors.New("OldAllowList requires an ID field in the mutation")
  35683. }
  35684. oldValue, err := m.oldValue(ctx)
  35685. if err != nil {
  35686. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  35687. }
  35688. return oldValue.AllowList, nil
  35689. }
  35690. // AppendAllowList adds s to the "allow_list" field.
  35691. func (m *WhatsappMutation) AppendAllowList(s []string) {
  35692. m.appendallow_list = append(m.appendallow_list, s...)
  35693. }
  35694. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  35695. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  35696. if len(m.appendallow_list) == 0 {
  35697. return nil, false
  35698. }
  35699. return m.appendallow_list, true
  35700. }
  35701. // ClearAllowList clears the value of the "allow_list" field.
  35702. func (m *WhatsappMutation) ClearAllowList() {
  35703. m.allow_list = nil
  35704. m.appendallow_list = nil
  35705. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  35706. }
  35707. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  35708. func (m *WhatsappMutation) AllowListCleared() bool {
  35709. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  35710. return ok
  35711. }
  35712. // ResetAllowList resets all changes to the "allow_list" field.
  35713. func (m *WhatsappMutation) ResetAllowList() {
  35714. m.allow_list = nil
  35715. m.appendallow_list = nil
  35716. delete(m.clearedFields, whatsapp.FieldAllowList)
  35717. }
  35718. // SetGroupAllowList sets the "group_allow_list" field.
  35719. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  35720. m.group_allow_list = &s
  35721. m.appendgroup_allow_list = nil
  35722. }
  35723. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  35724. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  35725. v := m.group_allow_list
  35726. if v == nil {
  35727. return
  35728. }
  35729. return *v, true
  35730. }
  35731. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  35732. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35734. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  35735. if !m.op.Is(OpUpdateOne) {
  35736. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  35737. }
  35738. if m.id == nil || m.oldValue == nil {
  35739. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  35740. }
  35741. oldValue, err := m.oldValue(ctx)
  35742. if err != nil {
  35743. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  35744. }
  35745. return oldValue.GroupAllowList, nil
  35746. }
  35747. // AppendGroupAllowList adds s to the "group_allow_list" field.
  35748. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  35749. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  35750. }
  35751. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  35752. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  35753. if len(m.appendgroup_allow_list) == 0 {
  35754. return nil, false
  35755. }
  35756. return m.appendgroup_allow_list, true
  35757. }
  35758. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  35759. func (m *WhatsappMutation) ClearGroupAllowList() {
  35760. m.group_allow_list = nil
  35761. m.appendgroup_allow_list = nil
  35762. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  35763. }
  35764. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  35765. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  35766. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  35767. return ok
  35768. }
  35769. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  35770. func (m *WhatsappMutation) ResetGroupAllowList() {
  35771. m.group_allow_list = nil
  35772. m.appendgroup_allow_list = nil
  35773. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  35774. }
  35775. // SetBlockList sets the "block_list" field.
  35776. func (m *WhatsappMutation) SetBlockList(s []string) {
  35777. m.block_list = &s
  35778. m.appendblock_list = nil
  35779. }
  35780. // BlockList returns the value of the "block_list" field in the mutation.
  35781. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  35782. v := m.block_list
  35783. if v == nil {
  35784. return
  35785. }
  35786. return *v, true
  35787. }
  35788. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  35789. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35791. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  35792. if !m.op.Is(OpUpdateOne) {
  35793. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  35794. }
  35795. if m.id == nil || m.oldValue == nil {
  35796. return v, errors.New("OldBlockList requires an ID field in the mutation")
  35797. }
  35798. oldValue, err := m.oldValue(ctx)
  35799. if err != nil {
  35800. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  35801. }
  35802. return oldValue.BlockList, nil
  35803. }
  35804. // AppendBlockList adds s to the "block_list" field.
  35805. func (m *WhatsappMutation) AppendBlockList(s []string) {
  35806. m.appendblock_list = append(m.appendblock_list, s...)
  35807. }
  35808. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  35809. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  35810. if len(m.appendblock_list) == 0 {
  35811. return nil, false
  35812. }
  35813. return m.appendblock_list, true
  35814. }
  35815. // ClearBlockList clears the value of the "block_list" field.
  35816. func (m *WhatsappMutation) ClearBlockList() {
  35817. m.block_list = nil
  35818. m.appendblock_list = nil
  35819. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  35820. }
  35821. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  35822. func (m *WhatsappMutation) BlockListCleared() bool {
  35823. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  35824. return ok
  35825. }
  35826. // ResetBlockList resets all changes to the "block_list" field.
  35827. func (m *WhatsappMutation) ResetBlockList() {
  35828. m.block_list = nil
  35829. m.appendblock_list = nil
  35830. delete(m.clearedFields, whatsapp.FieldBlockList)
  35831. }
  35832. // SetGroupBlockList sets the "group_block_list" field.
  35833. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  35834. m.group_block_list = &s
  35835. m.appendgroup_block_list = nil
  35836. }
  35837. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  35838. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  35839. v := m.group_block_list
  35840. if v == nil {
  35841. return
  35842. }
  35843. return *v, true
  35844. }
  35845. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  35846. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  35847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35848. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  35849. if !m.op.Is(OpUpdateOne) {
  35850. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  35851. }
  35852. if m.id == nil || m.oldValue == nil {
  35853. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  35854. }
  35855. oldValue, err := m.oldValue(ctx)
  35856. if err != nil {
  35857. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  35858. }
  35859. return oldValue.GroupBlockList, nil
  35860. }
  35861. // AppendGroupBlockList adds s to the "group_block_list" field.
  35862. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  35863. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  35864. }
  35865. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  35866. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  35867. if len(m.appendgroup_block_list) == 0 {
  35868. return nil, false
  35869. }
  35870. return m.appendgroup_block_list, true
  35871. }
  35872. // ClearGroupBlockList clears the value of the "group_block_list" field.
  35873. func (m *WhatsappMutation) ClearGroupBlockList() {
  35874. m.group_block_list = nil
  35875. m.appendgroup_block_list = nil
  35876. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  35877. }
  35878. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  35879. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  35880. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  35881. return ok
  35882. }
  35883. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  35884. func (m *WhatsappMutation) ResetGroupBlockList() {
  35885. m.group_block_list = nil
  35886. m.appendgroup_block_list = nil
  35887. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  35888. }
  35889. // ClearAgent clears the "agent" edge to the Agent entity.
  35890. func (m *WhatsappMutation) ClearAgent() {
  35891. m.clearedagent = true
  35892. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  35893. }
  35894. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  35895. func (m *WhatsappMutation) AgentCleared() bool {
  35896. return m.clearedagent
  35897. }
  35898. // AgentIDs returns the "agent" edge IDs in the mutation.
  35899. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  35900. // AgentID instead. It exists only for internal usage by the builders.
  35901. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  35902. if id := m.agent; id != nil {
  35903. ids = append(ids, *id)
  35904. }
  35905. return
  35906. }
  35907. // ResetAgent resets all changes to the "agent" edge.
  35908. func (m *WhatsappMutation) ResetAgent() {
  35909. m.agent = nil
  35910. m.clearedagent = false
  35911. }
  35912. // Where appends a list predicates to the WhatsappMutation builder.
  35913. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  35914. m.predicates = append(m.predicates, ps...)
  35915. }
  35916. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  35917. // users can use type-assertion to append predicates that do not depend on any generated package.
  35918. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  35919. p := make([]predicate.Whatsapp, len(ps))
  35920. for i := range ps {
  35921. p[i] = ps[i]
  35922. }
  35923. m.Where(p...)
  35924. }
  35925. // Op returns the operation name.
  35926. func (m *WhatsappMutation) Op() Op {
  35927. return m.op
  35928. }
  35929. // SetOp allows setting the mutation operation.
  35930. func (m *WhatsappMutation) SetOp(op Op) {
  35931. m.op = op
  35932. }
  35933. // Type returns the node type of this mutation (Whatsapp).
  35934. func (m *WhatsappMutation) Type() string {
  35935. return m.typ
  35936. }
  35937. // Fields returns all fields that were changed during this mutation. Note that in
  35938. // order to get all numeric fields that were incremented/decremented, call
  35939. // AddedFields().
  35940. func (m *WhatsappMutation) Fields() []string {
  35941. fields := make([]string, 0, 21)
  35942. if m.created_at != nil {
  35943. fields = append(fields, whatsapp.FieldCreatedAt)
  35944. }
  35945. if m.updated_at != nil {
  35946. fields = append(fields, whatsapp.FieldUpdatedAt)
  35947. }
  35948. if m.status != nil {
  35949. fields = append(fields, whatsapp.FieldStatus)
  35950. }
  35951. if m.deleted_at != nil {
  35952. fields = append(fields, whatsapp.FieldDeletedAt)
  35953. }
  35954. if m.wa_id != nil {
  35955. fields = append(fields, whatsapp.FieldWaID)
  35956. }
  35957. if m.wa_name != nil {
  35958. fields = append(fields, whatsapp.FieldWaName)
  35959. }
  35960. if m.callback != nil {
  35961. fields = append(fields, whatsapp.FieldCallback)
  35962. }
  35963. if m.agent != nil {
  35964. fields = append(fields, whatsapp.FieldAgentID)
  35965. }
  35966. if m.account != nil {
  35967. fields = append(fields, whatsapp.FieldAccount)
  35968. }
  35969. if m.cc != nil {
  35970. fields = append(fields, whatsapp.FieldCc)
  35971. }
  35972. if m.phone != nil {
  35973. fields = append(fields, whatsapp.FieldPhone)
  35974. }
  35975. if m.cc_phone != nil {
  35976. fields = append(fields, whatsapp.FieldCcPhone)
  35977. }
  35978. if m.phone_name != nil {
  35979. fields = append(fields, whatsapp.FieldPhoneName)
  35980. }
  35981. if m.phone_status != nil {
  35982. fields = append(fields, whatsapp.FieldPhoneStatus)
  35983. }
  35984. if m.organization_id != nil {
  35985. fields = append(fields, whatsapp.FieldOrganizationID)
  35986. }
  35987. if m.api_base != nil {
  35988. fields = append(fields, whatsapp.FieldAPIBase)
  35989. }
  35990. if m.api_key != nil {
  35991. fields = append(fields, whatsapp.FieldAPIKey)
  35992. }
  35993. if m.allow_list != nil {
  35994. fields = append(fields, whatsapp.FieldAllowList)
  35995. }
  35996. if m.group_allow_list != nil {
  35997. fields = append(fields, whatsapp.FieldGroupAllowList)
  35998. }
  35999. if m.block_list != nil {
  36000. fields = append(fields, whatsapp.FieldBlockList)
  36001. }
  36002. if m.group_block_list != nil {
  36003. fields = append(fields, whatsapp.FieldGroupBlockList)
  36004. }
  36005. return fields
  36006. }
  36007. // Field returns the value of a field with the given name. The second boolean
  36008. // return value indicates that this field was not set, or was not defined in the
  36009. // schema.
  36010. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  36011. switch name {
  36012. case whatsapp.FieldCreatedAt:
  36013. return m.CreatedAt()
  36014. case whatsapp.FieldUpdatedAt:
  36015. return m.UpdatedAt()
  36016. case whatsapp.FieldStatus:
  36017. return m.Status()
  36018. case whatsapp.FieldDeletedAt:
  36019. return m.DeletedAt()
  36020. case whatsapp.FieldWaID:
  36021. return m.WaID()
  36022. case whatsapp.FieldWaName:
  36023. return m.WaName()
  36024. case whatsapp.FieldCallback:
  36025. return m.Callback()
  36026. case whatsapp.FieldAgentID:
  36027. return m.AgentID()
  36028. case whatsapp.FieldAccount:
  36029. return m.Account()
  36030. case whatsapp.FieldCc:
  36031. return m.Cc()
  36032. case whatsapp.FieldPhone:
  36033. return m.Phone()
  36034. case whatsapp.FieldCcPhone:
  36035. return m.CcPhone()
  36036. case whatsapp.FieldPhoneName:
  36037. return m.PhoneName()
  36038. case whatsapp.FieldPhoneStatus:
  36039. return m.PhoneStatus()
  36040. case whatsapp.FieldOrganizationID:
  36041. return m.OrganizationID()
  36042. case whatsapp.FieldAPIBase:
  36043. return m.APIBase()
  36044. case whatsapp.FieldAPIKey:
  36045. return m.APIKey()
  36046. case whatsapp.FieldAllowList:
  36047. return m.AllowList()
  36048. case whatsapp.FieldGroupAllowList:
  36049. return m.GroupAllowList()
  36050. case whatsapp.FieldBlockList:
  36051. return m.BlockList()
  36052. case whatsapp.FieldGroupBlockList:
  36053. return m.GroupBlockList()
  36054. }
  36055. return nil, false
  36056. }
  36057. // OldField returns the old value of the field from the database. An error is
  36058. // returned if the mutation operation is not UpdateOne, or the query to the
  36059. // database failed.
  36060. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36061. switch name {
  36062. case whatsapp.FieldCreatedAt:
  36063. return m.OldCreatedAt(ctx)
  36064. case whatsapp.FieldUpdatedAt:
  36065. return m.OldUpdatedAt(ctx)
  36066. case whatsapp.FieldStatus:
  36067. return m.OldStatus(ctx)
  36068. case whatsapp.FieldDeletedAt:
  36069. return m.OldDeletedAt(ctx)
  36070. case whatsapp.FieldWaID:
  36071. return m.OldWaID(ctx)
  36072. case whatsapp.FieldWaName:
  36073. return m.OldWaName(ctx)
  36074. case whatsapp.FieldCallback:
  36075. return m.OldCallback(ctx)
  36076. case whatsapp.FieldAgentID:
  36077. return m.OldAgentID(ctx)
  36078. case whatsapp.FieldAccount:
  36079. return m.OldAccount(ctx)
  36080. case whatsapp.FieldCc:
  36081. return m.OldCc(ctx)
  36082. case whatsapp.FieldPhone:
  36083. return m.OldPhone(ctx)
  36084. case whatsapp.FieldCcPhone:
  36085. return m.OldCcPhone(ctx)
  36086. case whatsapp.FieldPhoneName:
  36087. return m.OldPhoneName(ctx)
  36088. case whatsapp.FieldPhoneStatus:
  36089. return m.OldPhoneStatus(ctx)
  36090. case whatsapp.FieldOrganizationID:
  36091. return m.OldOrganizationID(ctx)
  36092. case whatsapp.FieldAPIBase:
  36093. return m.OldAPIBase(ctx)
  36094. case whatsapp.FieldAPIKey:
  36095. return m.OldAPIKey(ctx)
  36096. case whatsapp.FieldAllowList:
  36097. return m.OldAllowList(ctx)
  36098. case whatsapp.FieldGroupAllowList:
  36099. return m.OldGroupAllowList(ctx)
  36100. case whatsapp.FieldBlockList:
  36101. return m.OldBlockList(ctx)
  36102. case whatsapp.FieldGroupBlockList:
  36103. return m.OldGroupBlockList(ctx)
  36104. }
  36105. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  36106. }
  36107. // SetField sets the value of a field with the given name. It returns an error if
  36108. // the field is not defined in the schema, or if the type mismatched the field
  36109. // type.
  36110. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  36111. switch name {
  36112. case whatsapp.FieldCreatedAt:
  36113. v, ok := value.(time.Time)
  36114. if !ok {
  36115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36116. }
  36117. m.SetCreatedAt(v)
  36118. return nil
  36119. case whatsapp.FieldUpdatedAt:
  36120. v, ok := value.(time.Time)
  36121. if !ok {
  36122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36123. }
  36124. m.SetUpdatedAt(v)
  36125. return nil
  36126. case whatsapp.FieldStatus:
  36127. v, ok := value.(uint8)
  36128. if !ok {
  36129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36130. }
  36131. m.SetStatus(v)
  36132. return nil
  36133. case whatsapp.FieldDeletedAt:
  36134. v, ok := value.(time.Time)
  36135. if !ok {
  36136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36137. }
  36138. m.SetDeletedAt(v)
  36139. return nil
  36140. case whatsapp.FieldWaID:
  36141. v, ok := value.(string)
  36142. if !ok {
  36143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36144. }
  36145. m.SetWaID(v)
  36146. return nil
  36147. case whatsapp.FieldWaName:
  36148. v, ok := value.(string)
  36149. if !ok {
  36150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36151. }
  36152. m.SetWaName(v)
  36153. return nil
  36154. case whatsapp.FieldCallback:
  36155. v, ok := value.(string)
  36156. if !ok {
  36157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36158. }
  36159. m.SetCallback(v)
  36160. return nil
  36161. case whatsapp.FieldAgentID:
  36162. v, ok := value.(uint64)
  36163. if !ok {
  36164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36165. }
  36166. m.SetAgentID(v)
  36167. return nil
  36168. case whatsapp.FieldAccount:
  36169. v, ok := value.(string)
  36170. if !ok {
  36171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36172. }
  36173. m.SetAccount(v)
  36174. return nil
  36175. case whatsapp.FieldCc:
  36176. v, ok := value.(string)
  36177. if !ok {
  36178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36179. }
  36180. m.SetCc(v)
  36181. return nil
  36182. case whatsapp.FieldPhone:
  36183. v, ok := value.(string)
  36184. if !ok {
  36185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36186. }
  36187. m.SetPhone(v)
  36188. return nil
  36189. case whatsapp.FieldCcPhone:
  36190. v, ok := value.(string)
  36191. if !ok {
  36192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36193. }
  36194. m.SetCcPhone(v)
  36195. return nil
  36196. case whatsapp.FieldPhoneName:
  36197. v, ok := value.(string)
  36198. if !ok {
  36199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36200. }
  36201. m.SetPhoneName(v)
  36202. return nil
  36203. case whatsapp.FieldPhoneStatus:
  36204. v, ok := value.(int8)
  36205. if !ok {
  36206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36207. }
  36208. m.SetPhoneStatus(v)
  36209. return nil
  36210. case whatsapp.FieldOrganizationID:
  36211. v, ok := value.(uint64)
  36212. if !ok {
  36213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36214. }
  36215. m.SetOrganizationID(v)
  36216. return nil
  36217. case whatsapp.FieldAPIBase:
  36218. v, ok := value.(string)
  36219. if !ok {
  36220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36221. }
  36222. m.SetAPIBase(v)
  36223. return nil
  36224. case whatsapp.FieldAPIKey:
  36225. v, ok := value.(string)
  36226. if !ok {
  36227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36228. }
  36229. m.SetAPIKey(v)
  36230. return nil
  36231. case whatsapp.FieldAllowList:
  36232. v, ok := value.([]string)
  36233. if !ok {
  36234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36235. }
  36236. m.SetAllowList(v)
  36237. return nil
  36238. case whatsapp.FieldGroupAllowList:
  36239. v, ok := value.([]string)
  36240. if !ok {
  36241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36242. }
  36243. m.SetGroupAllowList(v)
  36244. return nil
  36245. case whatsapp.FieldBlockList:
  36246. v, ok := value.([]string)
  36247. if !ok {
  36248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36249. }
  36250. m.SetBlockList(v)
  36251. return nil
  36252. case whatsapp.FieldGroupBlockList:
  36253. v, ok := value.([]string)
  36254. if !ok {
  36255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36256. }
  36257. m.SetGroupBlockList(v)
  36258. return nil
  36259. }
  36260. return fmt.Errorf("unknown Whatsapp field %s", name)
  36261. }
  36262. // AddedFields returns all numeric fields that were incremented/decremented during
  36263. // this mutation.
  36264. func (m *WhatsappMutation) AddedFields() []string {
  36265. var fields []string
  36266. if m.addstatus != nil {
  36267. fields = append(fields, whatsapp.FieldStatus)
  36268. }
  36269. if m.addphone_status != nil {
  36270. fields = append(fields, whatsapp.FieldPhoneStatus)
  36271. }
  36272. if m.addorganization_id != nil {
  36273. fields = append(fields, whatsapp.FieldOrganizationID)
  36274. }
  36275. return fields
  36276. }
  36277. // AddedField returns the numeric value that was incremented/decremented on a field
  36278. // with the given name. The second boolean return value indicates that this field
  36279. // was not set, or was not defined in the schema.
  36280. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  36281. switch name {
  36282. case whatsapp.FieldStatus:
  36283. return m.AddedStatus()
  36284. case whatsapp.FieldPhoneStatus:
  36285. return m.AddedPhoneStatus()
  36286. case whatsapp.FieldOrganizationID:
  36287. return m.AddedOrganizationID()
  36288. }
  36289. return nil, false
  36290. }
  36291. // AddField adds the value to the field with the given name. It returns an error if
  36292. // the field is not defined in the schema, or if the type mismatched the field
  36293. // type.
  36294. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  36295. switch name {
  36296. case whatsapp.FieldStatus:
  36297. v, ok := value.(int8)
  36298. if !ok {
  36299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36300. }
  36301. m.AddStatus(v)
  36302. return nil
  36303. case whatsapp.FieldPhoneStatus:
  36304. v, ok := value.(int8)
  36305. if !ok {
  36306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36307. }
  36308. m.AddPhoneStatus(v)
  36309. return nil
  36310. case whatsapp.FieldOrganizationID:
  36311. v, ok := value.(int64)
  36312. if !ok {
  36313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36314. }
  36315. m.AddOrganizationID(v)
  36316. return nil
  36317. }
  36318. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  36319. }
  36320. // ClearedFields returns all nullable fields that were cleared during this
  36321. // mutation.
  36322. func (m *WhatsappMutation) ClearedFields() []string {
  36323. var fields []string
  36324. if m.FieldCleared(whatsapp.FieldStatus) {
  36325. fields = append(fields, whatsapp.FieldStatus)
  36326. }
  36327. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  36328. fields = append(fields, whatsapp.FieldDeletedAt)
  36329. }
  36330. if m.FieldCleared(whatsapp.FieldWaID) {
  36331. fields = append(fields, whatsapp.FieldWaID)
  36332. }
  36333. if m.FieldCleared(whatsapp.FieldWaName) {
  36334. fields = append(fields, whatsapp.FieldWaName)
  36335. }
  36336. if m.FieldCleared(whatsapp.FieldCallback) {
  36337. fields = append(fields, whatsapp.FieldCallback)
  36338. }
  36339. if m.FieldCleared(whatsapp.FieldAccount) {
  36340. fields = append(fields, whatsapp.FieldAccount)
  36341. }
  36342. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  36343. fields = append(fields, whatsapp.FieldOrganizationID)
  36344. }
  36345. if m.FieldCleared(whatsapp.FieldAPIBase) {
  36346. fields = append(fields, whatsapp.FieldAPIBase)
  36347. }
  36348. if m.FieldCleared(whatsapp.FieldAPIKey) {
  36349. fields = append(fields, whatsapp.FieldAPIKey)
  36350. }
  36351. if m.FieldCleared(whatsapp.FieldAllowList) {
  36352. fields = append(fields, whatsapp.FieldAllowList)
  36353. }
  36354. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  36355. fields = append(fields, whatsapp.FieldGroupAllowList)
  36356. }
  36357. if m.FieldCleared(whatsapp.FieldBlockList) {
  36358. fields = append(fields, whatsapp.FieldBlockList)
  36359. }
  36360. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  36361. fields = append(fields, whatsapp.FieldGroupBlockList)
  36362. }
  36363. return fields
  36364. }
  36365. // FieldCleared returns a boolean indicating if a field with the given name was
  36366. // cleared in this mutation.
  36367. func (m *WhatsappMutation) FieldCleared(name string) bool {
  36368. _, ok := m.clearedFields[name]
  36369. return ok
  36370. }
  36371. // ClearField clears the value of the field with the given name. It returns an
  36372. // error if the field is not defined in the schema.
  36373. func (m *WhatsappMutation) ClearField(name string) error {
  36374. switch name {
  36375. case whatsapp.FieldStatus:
  36376. m.ClearStatus()
  36377. return nil
  36378. case whatsapp.FieldDeletedAt:
  36379. m.ClearDeletedAt()
  36380. return nil
  36381. case whatsapp.FieldWaID:
  36382. m.ClearWaID()
  36383. return nil
  36384. case whatsapp.FieldWaName:
  36385. m.ClearWaName()
  36386. return nil
  36387. case whatsapp.FieldCallback:
  36388. m.ClearCallback()
  36389. return nil
  36390. case whatsapp.FieldAccount:
  36391. m.ClearAccount()
  36392. return nil
  36393. case whatsapp.FieldOrganizationID:
  36394. m.ClearOrganizationID()
  36395. return nil
  36396. case whatsapp.FieldAPIBase:
  36397. m.ClearAPIBase()
  36398. return nil
  36399. case whatsapp.FieldAPIKey:
  36400. m.ClearAPIKey()
  36401. return nil
  36402. case whatsapp.FieldAllowList:
  36403. m.ClearAllowList()
  36404. return nil
  36405. case whatsapp.FieldGroupAllowList:
  36406. m.ClearGroupAllowList()
  36407. return nil
  36408. case whatsapp.FieldBlockList:
  36409. m.ClearBlockList()
  36410. return nil
  36411. case whatsapp.FieldGroupBlockList:
  36412. m.ClearGroupBlockList()
  36413. return nil
  36414. }
  36415. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  36416. }
  36417. // ResetField resets all changes in the mutation for the field with the given name.
  36418. // It returns an error if the field is not defined in the schema.
  36419. func (m *WhatsappMutation) ResetField(name string) error {
  36420. switch name {
  36421. case whatsapp.FieldCreatedAt:
  36422. m.ResetCreatedAt()
  36423. return nil
  36424. case whatsapp.FieldUpdatedAt:
  36425. m.ResetUpdatedAt()
  36426. return nil
  36427. case whatsapp.FieldStatus:
  36428. m.ResetStatus()
  36429. return nil
  36430. case whatsapp.FieldDeletedAt:
  36431. m.ResetDeletedAt()
  36432. return nil
  36433. case whatsapp.FieldWaID:
  36434. m.ResetWaID()
  36435. return nil
  36436. case whatsapp.FieldWaName:
  36437. m.ResetWaName()
  36438. return nil
  36439. case whatsapp.FieldCallback:
  36440. m.ResetCallback()
  36441. return nil
  36442. case whatsapp.FieldAgentID:
  36443. m.ResetAgentID()
  36444. return nil
  36445. case whatsapp.FieldAccount:
  36446. m.ResetAccount()
  36447. return nil
  36448. case whatsapp.FieldCc:
  36449. m.ResetCc()
  36450. return nil
  36451. case whatsapp.FieldPhone:
  36452. m.ResetPhone()
  36453. return nil
  36454. case whatsapp.FieldCcPhone:
  36455. m.ResetCcPhone()
  36456. return nil
  36457. case whatsapp.FieldPhoneName:
  36458. m.ResetPhoneName()
  36459. return nil
  36460. case whatsapp.FieldPhoneStatus:
  36461. m.ResetPhoneStatus()
  36462. return nil
  36463. case whatsapp.FieldOrganizationID:
  36464. m.ResetOrganizationID()
  36465. return nil
  36466. case whatsapp.FieldAPIBase:
  36467. m.ResetAPIBase()
  36468. return nil
  36469. case whatsapp.FieldAPIKey:
  36470. m.ResetAPIKey()
  36471. return nil
  36472. case whatsapp.FieldAllowList:
  36473. m.ResetAllowList()
  36474. return nil
  36475. case whatsapp.FieldGroupAllowList:
  36476. m.ResetGroupAllowList()
  36477. return nil
  36478. case whatsapp.FieldBlockList:
  36479. m.ResetBlockList()
  36480. return nil
  36481. case whatsapp.FieldGroupBlockList:
  36482. m.ResetGroupBlockList()
  36483. return nil
  36484. }
  36485. return fmt.Errorf("unknown Whatsapp field %s", name)
  36486. }
  36487. // AddedEdges returns all edge names that were set/added in this mutation.
  36488. func (m *WhatsappMutation) AddedEdges() []string {
  36489. edges := make([]string, 0, 1)
  36490. if m.agent != nil {
  36491. edges = append(edges, whatsapp.EdgeAgent)
  36492. }
  36493. return edges
  36494. }
  36495. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36496. // name in this mutation.
  36497. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  36498. switch name {
  36499. case whatsapp.EdgeAgent:
  36500. if id := m.agent; id != nil {
  36501. return []ent.Value{*id}
  36502. }
  36503. }
  36504. return nil
  36505. }
  36506. // RemovedEdges returns all edge names that were removed in this mutation.
  36507. func (m *WhatsappMutation) RemovedEdges() []string {
  36508. edges := make([]string, 0, 1)
  36509. return edges
  36510. }
  36511. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36512. // the given name in this mutation.
  36513. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  36514. return nil
  36515. }
  36516. // ClearedEdges returns all edge names that were cleared in this mutation.
  36517. func (m *WhatsappMutation) ClearedEdges() []string {
  36518. edges := make([]string, 0, 1)
  36519. if m.clearedagent {
  36520. edges = append(edges, whatsapp.EdgeAgent)
  36521. }
  36522. return edges
  36523. }
  36524. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36525. // was cleared in this mutation.
  36526. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  36527. switch name {
  36528. case whatsapp.EdgeAgent:
  36529. return m.clearedagent
  36530. }
  36531. return false
  36532. }
  36533. // ClearEdge clears the value of the edge with the given name. It returns an error
  36534. // if that edge is not defined in the schema.
  36535. func (m *WhatsappMutation) ClearEdge(name string) error {
  36536. switch name {
  36537. case whatsapp.EdgeAgent:
  36538. m.ClearAgent()
  36539. return nil
  36540. }
  36541. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  36542. }
  36543. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36544. // It returns an error if the edge is not defined in the schema.
  36545. func (m *WhatsappMutation) ResetEdge(name string) error {
  36546. switch name {
  36547. case whatsapp.EdgeAgent:
  36548. m.ResetAgent()
  36549. return nil
  36550. }
  36551. return fmt.Errorf("unknown Whatsapp edge %s", name)
  36552. }
  36553. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  36554. type WhatsappChannelMutation struct {
  36555. config
  36556. op Op
  36557. typ string
  36558. id *uint64
  36559. created_at *time.Time
  36560. updated_at *time.Time
  36561. status *uint8
  36562. addstatus *int8
  36563. deleted_at *time.Time
  36564. ak *string
  36565. sk *string
  36566. wa_id *string
  36567. wa_name *string
  36568. waba_id *uint64
  36569. addwaba_id *int64
  36570. business_id *uint64
  36571. addbusiness_id *int64
  36572. organization_id *uint64
  36573. addorganization_id *int64
  36574. verify_account *string
  36575. clearedFields map[string]struct{}
  36576. done bool
  36577. oldValue func(context.Context) (*WhatsappChannel, error)
  36578. predicates []predicate.WhatsappChannel
  36579. }
  36580. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  36581. // whatsappchannelOption allows management of the mutation configuration using functional options.
  36582. type whatsappchannelOption func(*WhatsappChannelMutation)
  36583. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  36584. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  36585. m := &WhatsappChannelMutation{
  36586. config: c,
  36587. op: op,
  36588. typ: TypeWhatsappChannel,
  36589. clearedFields: make(map[string]struct{}),
  36590. }
  36591. for _, opt := range opts {
  36592. opt(m)
  36593. }
  36594. return m
  36595. }
  36596. // withWhatsappChannelID sets the ID field of the mutation.
  36597. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  36598. return func(m *WhatsappChannelMutation) {
  36599. var (
  36600. err error
  36601. once sync.Once
  36602. value *WhatsappChannel
  36603. )
  36604. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  36605. once.Do(func() {
  36606. if m.done {
  36607. err = errors.New("querying old values post mutation is not allowed")
  36608. } else {
  36609. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  36610. }
  36611. })
  36612. return value, err
  36613. }
  36614. m.id = &id
  36615. }
  36616. }
  36617. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  36618. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  36619. return func(m *WhatsappChannelMutation) {
  36620. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  36621. return node, nil
  36622. }
  36623. m.id = &node.ID
  36624. }
  36625. }
  36626. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36627. // executed in a transaction (ent.Tx), a transactional client is returned.
  36628. func (m WhatsappChannelMutation) Client() *Client {
  36629. client := &Client{config: m.config}
  36630. client.init()
  36631. return client
  36632. }
  36633. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36634. // it returns an error otherwise.
  36635. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  36636. if _, ok := m.driver.(*txDriver); !ok {
  36637. return nil, errors.New("ent: mutation is not running in a transaction")
  36638. }
  36639. tx := &Tx{config: m.config}
  36640. tx.init()
  36641. return tx, nil
  36642. }
  36643. // SetID sets the value of the id field. Note that this
  36644. // operation is only accepted on creation of WhatsappChannel entities.
  36645. func (m *WhatsappChannelMutation) SetID(id uint64) {
  36646. m.id = &id
  36647. }
  36648. // ID returns the ID value in the mutation. Note that the ID is only available
  36649. // if it was provided to the builder or after it was returned from the database.
  36650. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  36651. if m.id == nil {
  36652. return
  36653. }
  36654. return *m.id, true
  36655. }
  36656. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36657. // That means, if the mutation is applied within a transaction with an isolation level such
  36658. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36659. // or updated by the mutation.
  36660. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  36661. switch {
  36662. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36663. id, exists := m.ID()
  36664. if exists {
  36665. return []uint64{id}, nil
  36666. }
  36667. fallthrough
  36668. case m.op.Is(OpUpdate | OpDelete):
  36669. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  36670. default:
  36671. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36672. }
  36673. }
  36674. // SetCreatedAt sets the "created_at" field.
  36675. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  36676. m.created_at = &t
  36677. }
  36678. // CreatedAt returns the value of the "created_at" field in the mutation.
  36679. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  36680. v := m.created_at
  36681. if v == nil {
  36682. return
  36683. }
  36684. return *v, true
  36685. }
  36686. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  36687. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36689. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36690. if !m.op.Is(OpUpdateOne) {
  36691. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36692. }
  36693. if m.id == nil || m.oldValue == nil {
  36694. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36695. }
  36696. oldValue, err := m.oldValue(ctx)
  36697. if err != nil {
  36698. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36699. }
  36700. return oldValue.CreatedAt, nil
  36701. }
  36702. // ResetCreatedAt resets all changes to the "created_at" field.
  36703. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  36704. m.created_at = nil
  36705. }
  36706. // SetUpdatedAt sets the "updated_at" field.
  36707. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  36708. m.updated_at = &t
  36709. }
  36710. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36711. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  36712. v := m.updated_at
  36713. if v == nil {
  36714. return
  36715. }
  36716. return *v, true
  36717. }
  36718. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  36719. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36721. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36722. if !m.op.Is(OpUpdateOne) {
  36723. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36724. }
  36725. if m.id == nil || m.oldValue == nil {
  36726. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36727. }
  36728. oldValue, err := m.oldValue(ctx)
  36729. if err != nil {
  36730. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36731. }
  36732. return oldValue.UpdatedAt, nil
  36733. }
  36734. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36735. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  36736. m.updated_at = nil
  36737. }
  36738. // SetStatus sets the "status" field.
  36739. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  36740. m.status = &u
  36741. m.addstatus = nil
  36742. }
  36743. // Status returns the value of the "status" field in the mutation.
  36744. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  36745. v := m.status
  36746. if v == nil {
  36747. return
  36748. }
  36749. return *v, true
  36750. }
  36751. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  36752. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36754. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36755. if !m.op.Is(OpUpdateOne) {
  36756. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36757. }
  36758. if m.id == nil || m.oldValue == nil {
  36759. return v, errors.New("OldStatus requires an ID field in the mutation")
  36760. }
  36761. oldValue, err := m.oldValue(ctx)
  36762. if err != nil {
  36763. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36764. }
  36765. return oldValue.Status, nil
  36766. }
  36767. // AddStatus adds u to the "status" field.
  36768. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  36769. if m.addstatus != nil {
  36770. *m.addstatus += u
  36771. } else {
  36772. m.addstatus = &u
  36773. }
  36774. }
  36775. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36776. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  36777. v := m.addstatus
  36778. if v == nil {
  36779. return
  36780. }
  36781. return *v, true
  36782. }
  36783. // ClearStatus clears the value of the "status" field.
  36784. func (m *WhatsappChannelMutation) ClearStatus() {
  36785. m.status = nil
  36786. m.addstatus = nil
  36787. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  36788. }
  36789. // StatusCleared returns if the "status" field was cleared in this mutation.
  36790. func (m *WhatsappChannelMutation) StatusCleared() bool {
  36791. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  36792. return ok
  36793. }
  36794. // ResetStatus resets all changes to the "status" field.
  36795. func (m *WhatsappChannelMutation) ResetStatus() {
  36796. m.status = nil
  36797. m.addstatus = nil
  36798. delete(m.clearedFields, whatsappchannel.FieldStatus)
  36799. }
  36800. // SetDeletedAt sets the "deleted_at" field.
  36801. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  36802. m.deleted_at = &t
  36803. }
  36804. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36805. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  36806. v := m.deleted_at
  36807. if v == nil {
  36808. return
  36809. }
  36810. return *v, true
  36811. }
  36812. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  36813. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36815. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36816. if !m.op.Is(OpUpdateOne) {
  36817. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36818. }
  36819. if m.id == nil || m.oldValue == nil {
  36820. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36821. }
  36822. oldValue, err := m.oldValue(ctx)
  36823. if err != nil {
  36824. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36825. }
  36826. return oldValue.DeletedAt, nil
  36827. }
  36828. // ClearDeletedAt clears the value of the "deleted_at" field.
  36829. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  36830. m.deleted_at = nil
  36831. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  36832. }
  36833. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36834. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  36835. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  36836. return ok
  36837. }
  36838. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36839. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  36840. m.deleted_at = nil
  36841. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  36842. }
  36843. // SetAk sets the "ak" field.
  36844. func (m *WhatsappChannelMutation) SetAk(s string) {
  36845. m.ak = &s
  36846. }
  36847. // Ak returns the value of the "ak" field in the mutation.
  36848. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  36849. v := m.ak
  36850. if v == nil {
  36851. return
  36852. }
  36853. return *v, true
  36854. }
  36855. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  36856. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36858. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  36859. if !m.op.Is(OpUpdateOne) {
  36860. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  36861. }
  36862. if m.id == nil || m.oldValue == nil {
  36863. return v, errors.New("OldAk requires an ID field in the mutation")
  36864. }
  36865. oldValue, err := m.oldValue(ctx)
  36866. if err != nil {
  36867. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  36868. }
  36869. return oldValue.Ak, nil
  36870. }
  36871. // ClearAk clears the value of the "ak" field.
  36872. func (m *WhatsappChannelMutation) ClearAk() {
  36873. m.ak = nil
  36874. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  36875. }
  36876. // AkCleared returns if the "ak" field was cleared in this mutation.
  36877. func (m *WhatsappChannelMutation) AkCleared() bool {
  36878. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  36879. return ok
  36880. }
  36881. // ResetAk resets all changes to the "ak" field.
  36882. func (m *WhatsappChannelMutation) ResetAk() {
  36883. m.ak = nil
  36884. delete(m.clearedFields, whatsappchannel.FieldAk)
  36885. }
  36886. // SetSk sets the "sk" field.
  36887. func (m *WhatsappChannelMutation) SetSk(s string) {
  36888. m.sk = &s
  36889. }
  36890. // Sk returns the value of the "sk" field in the mutation.
  36891. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  36892. v := m.sk
  36893. if v == nil {
  36894. return
  36895. }
  36896. return *v, true
  36897. }
  36898. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  36899. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36901. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  36902. if !m.op.Is(OpUpdateOne) {
  36903. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  36904. }
  36905. if m.id == nil || m.oldValue == nil {
  36906. return v, errors.New("OldSk requires an ID field in the mutation")
  36907. }
  36908. oldValue, err := m.oldValue(ctx)
  36909. if err != nil {
  36910. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  36911. }
  36912. return oldValue.Sk, nil
  36913. }
  36914. // ResetSk resets all changes to the "sk" field.
  36915. func (m *WhatsappChannelMutation) ResetSk() {
  36916. m.sk = nil
  36917. }
  36918. // SetWaID sets the "wa_id" field.
  36919. func (m *WhatsappChannelMutation) SetWaID(s string) {
  36920. m.wa_id = &s
  36921. }
  36922. // WaID returns the value of the "wa_id" field in the mutation.
  36923. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  36924. v := m.wa_id
  36925. if v == nil {
  36926. return
  36927. }
  36928. return *v, true
  36929. }
  36930. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  36931. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36933. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  36934. if !m.op.Is(OpUpdateOne) {
  36935. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  36936. }
  36937. if m.id == nil || m.oldValue == nil {
  36938. return v, errors.New("OldWaID requires an ID field in the mutation")
  36939. }
  36940. oldValue, err := m.oldValue(ctx)
  36941. if err != nil {
  36942. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  36943. }
  36944. return oldValue.WaID, nil
  36945. }
  36946. // ClearWaID clears the value of the "wa_id" field.
  36947. func (m *WhatsappChannelMutation) ClearWaID() {
  36948. m.wa_id = nil
  36949. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  36950. }
  36951. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  36952. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  36953. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  36954. return ok
  36955. }
  36956. // ResetWaID resets all changes to the "wa_id" field.
  36957. func (m *WhatsappChannelMutation) ResetWaID() {
  36958. m.wa_id = nil
  36959. delete(m.clearedFields, whatsappchannel.FieldWaID)
  36960. }
  36961. // SetWaName sets the "wa_name" field.
  36962. func (m *WhatsappChannelMutation) SetWaName(s string) {
  36963. m.wa_name = &s
  36964. }
  36965. // WaName returns the value of the "wa_name" field in the mutation.
  36966. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  36967. v := m.wa_name
  36968. if v == nil {
  36969. return
  36970. }
  36971. return *v, true
  36972. }
  36973. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  36974. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36976. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  36977. if !m.op.Is(OpUpdateOne) {
  36978. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  36979. }
  36980. if m.id == nil || m.oldValue == nil {
  36981. return v, errors.New("OldWaName requires an ID field in the mutation")
  36982. }
  36983. oldValue, err := m.oldValue(ctx)
  36984. if err != nil {
  36985. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  36986. }
  36987. return oldValue.WaName, nil
  36988. }
  36989. // ClearWaName clears the value of the "wa_name" field.
  36990. func (m *WhatsappChannelMutation) ClearWaName() {
  36991. m.wa_name = nil
  36992. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  36993. }
  36994. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  36995. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  36996. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  36997. return ok
  36998. }
  36999. // ResetWaName resets all changes to the "wa_name" field.
  37000. func (m *WhatsappChannelMutation) ResetWaName() {
  37001. m.wa_name = nil
  37002. delete(m.clearedFields, whatsappchannel.FieldWaName)
  37003. }
  37004. // SetWabaID sets the "waba_id" field.
  37005. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  37006. m.waba_id = &u
  37007. m.addwaba_id = nil
  37008. }
  37009. // WabaID returns the value of the "waba_id" field in the mutation.
  37010. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  37011. v := m.waba_id
  37012. if v == nil {
  37013. return
  37014. }
  37015. return *v, true
  37016. }
  37017. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  37018. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37020. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  37021. if !m.op.Is(OpUpdateOne) {
  37022. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  37023. }
  37024. if m.id == nil || m.oldValue == nil {
  37025. return v, errors.New("OldWabaID requires an ID field in the mutation")
  37026. }
  37027. oldValue, err := m.oldValue(ctx)
  37028. if err != nil {
  37029. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  37030. }
  37031. return oldValue.WabaID, nil
  37032. }
  37033. // AddWabaID adds u to the "waba_id" field.
  37034. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  37035. if m.addwaba_id != nil {
  37036. *m.addwaba_id += u
  37037. } else {
  37038. m.addwaba_id = &u
  37039. }
  37040. }
  37041. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  37042. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  37043. v := m.addwaba_id
  37044. if v == nil {
  37045. return
  37046. }
  37047. return *v, true
  37048. }
  37049. // ResetWabaID resets all changes to the "waba_id" field.
  37050. func (m *WhatsappChannelMutation) ResetWabaID() {
  37051. m.waba_id = nil
  37052. m.addwaba_id = nil
  37053. }
  37054. // SetBusinessID sets the "business_id" field.
  37055. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  37056. m.business_id = &u
  37057. m.addbusiness_id = nil
  37058. }
  37059. // BusinessID returns the value of the "business_id" field in the mutation.
  37060. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  37061. v := m.business_id
  37062. if v == nil {
  37063. return
  37064. }
  37065. return *v, true
  37066. }
  37067. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  37068. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37070. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  37071. if !m.op.Is(OpUpdateOne) {
  37072. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  37073. }
  37074. if m.id == nil || m.oldValue == nil {
  37075. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  37076. }
  37077. oldValue, err := m.oldValue(ctx)
  37078. if err != nil {
  37079. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  37080. }
  37081. return oldValue.BusinessID, nil
  37082. }
  37083. // AddBusinessID adds u to the "business_id" field.
  37084. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  37085. if m.addbusiness_id != nil {
  37086. *m.addbusiness_id += u
  37087. } else {
  37088. m.addbusiness_id = &u
  37089. }
  37090. }
  37091. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  37092. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  37093. v := m.addbusiness_id
  37094. if v == nil {
  37095. return
  37096. }
  37097. return *v, true
  37098. }
  37099. // ResetBusinessID resets all changes to the "business_id" field.
  37100. func (m *WhatsappChannelMutation) ResetBusinessID() {
  37101. m.business_id = nil
  37102. m.addbusiness_id = nil
  37103. }
  37104. // SetOrganizationID sets the "organization_id" field.
  37105. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  37106. m.organization_id = &u
  37107. m.addorganization_id = nil
  37108. }
  37109. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37110. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  37111. v := m.organization_id
  37112. if v == nil {
  37113. return
  37114. }
  37115. return *v, true
  37116. }
  37117. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  37118. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37120. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37121. if !m.op.Is(OpUpdateOne) {
  37122. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37123. }
  37124. if m.id == nil || m.oldValue == nil {
  37125. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37126. }
  37127. oldValue, err := m.oldValue(ctx)
  37128. if err != nil {
  37129. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37130. }
  37131. return oldValue.OrganizationID, nil
  37132. }
  37133. // AddOrganizationID adds u to the "organization_id" field.
  37134. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  37135. if m.addorganization_id != nil {
  37136. *m.addorganization_id += u
  37137. } else {
  37138. m.addorganization_id = &u
  37139. }
  37140. }
  37141. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37142. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  37143. v := m.addorganization_id
  37144. if v == nil {
  37145. return
  37146. }
  37147. return *v, true
  37148. }
  37149. // ClearOrganizationID clears the value of the "organization_id" field.
  37150. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  37151. m.organization_id = nil
  37152. m.addorganization_id = nil
  37153. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  37154. }
  37155. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37156. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  37157. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  37158. return ok
  37159. }
  37160. // ResetOrganizationID resets all changes to the "organization_id" field.
  37161. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  37162. m.organization_id = nil
  37163. m.addorganization_id = nil
  37164. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  37165. }
  37166. // SetVerifyAccount sets the "verify_account" field.
  37167. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  37168. m.verify_account = &s
  37169. }
  37170. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  37171. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  37172. v := m.verify_account
  37173. if v == nil {
  37174. return
  37175. }
  37176. return *v, true
  37177. }
  37178. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  37179. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  37180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37181. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  37182. if !m.op.Is(OpUpdateOne) {
  37183. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  37184. }
  37185. if m.id == nil || m.oldValue == nil {
  37186. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  37187. }
  37188. oldValue, err := m.oldValue(ctx)
  37189. if err != nil {
  37190. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  37191. }
  37192. return oldValue.VerifyAccount, nil
  37193. }
  37194. // ResetVerifyAccount resets all changes to the "verify_account" field.
  37195. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  37196. m.verify_account = nil
  37197. }
  37198. // Where appends a list predicates to the WhatsappChannelMutation builder.
  37199. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  37200. m.predicates = append(m.predicates, ps...)
  37201. }
  37202. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  37203. // users can use type-assertion to append predicates that do not depend on any generated package.
  37204. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  37205. p := make([]predicate.WhatsappChannel, len(ps))
  37206. for i := range ps {
  37207. p[i] = ps[i]
  37208. }
  37209. m.Where(p...)
  37210. }
  37211. // Op returns the operation name.
  37212. func (m *WhatsappChannelMutation) Op() Op {
  37213. return m.op
  37214. }
  37215. // SetOp allows setting the mutation operation.
  37216. func (m *WhatsappChannelMutation) SetOp(op Op) {
  37217. m.op = op
  37218. }
  37219. // Type returns the node type of this mutation (WhatsappChannel).
  37220. func (m *WhatsappChannelMutation) Type() string {
  37221. return m.typ
  37222. }
  37223. // Fields returns all fields that were changed during this mutation. Note that in
  37224. // order to get all numeric fields that were incremented/decremented, call
  37225. // AddedFields().
  37226. func (m *WhatsappChannelMutation) Fields() []string {
  37227. fields := make([]string, 0, 12)
  37228. if m.created_at != nil {
  37229. fields = append(fields, whatsappchannel.FieldCreatedAt)
  37230. }
  37231. if m.updated_at != nil {
  37232. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  37233. }
  37234. if m.status != nil {
  37235. fields = append(fields, whatsappchannel.FieldStatus)
  37236. }
  37237. if m.deleted_at != nil {
  37238. fields = append(fields, whatsappchannel.FieldDeletedAt)
  37239. }
  37240. if m.ak != nil {
  37241. fields = append(fields, whatsappchannel.FieldAk)
  37242. }
  37243. if m.sk != nil {
  37244. fields = append(fields, whatsappchannel.FieldSk)
  37245. }
  37246. if m.wa_id != nil {
  37247. fields = append(fields, whatsappchannel.FieldWaID)
  37248. }
  37249. if m.wa_name != nil {
  37250. fields = append(fields, whatsappchannel.FieldWaName)
  37251. }
  37252. if m.waba_id != nil {
  37253. fields = append(fields, whatsappchannel.FieldWabaID)
  37254. }
  37255. if m.business_id != nil {
  37256. fields = append(fields, whatsappchannel.FieldBusinessID)
  37257. }
  37258. if m.organization_id != nil {
  37259. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37260. }
  37261. if m.verify_account != nil {
  37262. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  37263. }
  37264. return fields
  37265. }
  37266. // Field returns the value of a field with the given name. The second boolean
  37267. // return value indicates that this field was not set, or was not defined in the
  37268. // schema.
  37269. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  37270. switch name {
  37271. case whatsappchannel.FieldCreatedAt:
  37272. return m.CreatedAt()
  37273. case whatsappchannel.FieldUpdatedAt:
  37274. return m.UpdatedAt()
  37275. case whatsappchannel.FieldStatus:
  37276. return m.Status()
  37277. case whatsappchannel.FieldDeletedAt:
  37278. return m.DeletedAt()
  37279. case whatsappchannel.FieldAk:
  37280. return m.Ak()
  37281. case whatsappchannel.FieldSk:
  37282. return m.Sk()
  37283. case whatsappchannel.FieldWaID:
  37284. return m.WaID()
  37285. case whatsappchannel.FieldWaName:
  37286. return m.WaName()
  37287. case whatsappchannel.FieldWabaID:
  37288. return m.WabaID()
  37289. case whatsappchannel.FieldBusinessID:
  37290. return m.BusinessID()
  37291. case whatsappchannel.FieldOrganizationID:
  37292. return m.OrganizationID()
  37293. case whatsappchannel.FieldVerifyAccount:
  37294. return m.VerifyAccount()
  37295. }
  37296. return nil, false
  37297. }
  37298. // OldField returns the old value of the field from the database. An error is
  37299. // returned if the mutation operation is not UpdateOne, or the query to the
  37300. // database failed.
  37301. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37302. switch name {
  37303. case whatsappchannel.FieldCreatedAt:
  37304. return m.OldCreatedAt(ctx)
  37305. case whatsappchannel.FieldUpdatedAt:
  37306. return m.OldUpdatedAt(ctx)
  37307. case whatsappchannel.FieldStatus:
  37308. return m.OldStatus(ctx)
  37309. case whatsappchannel.FieldDeletedAt:
  37310. return m.OldDeletedAt(ctx)
  37311. case whatsappchannel.FieldAk:
  37312. return m.OldAk(ctx)
  37313. case whatsappchannel.FieldSk:
  37314. return m.OldSk(ctx)
  37315. case whatsappchannel.FieldWaID:
  37316. return m.OldWaID(ctx)
  37317. case whatsappchannel.FieldWaName:
  37318. return m.OldWaName(ctx)
  37319. case whatsappchannel.FieldWabaID:
  37320. return m.OldWabaID(ctx)
  37321. case whatsappchannel.FieldBusinessID:
  37322. return m.OldBusinessID(ctx)
  37323. case whatsappchannel.FieldOrganizationID:
  37324. return m.OldOrganizationID(ctx)
  37325. case whatsappchannel.FieldVerifyAccount:
  37326. return m.OldVerifyAccount(ctx)
  37327. }
  37328. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  37329. }
  37330. // SetField sets the value of a field with the given name. It returns an error if
  37331. // the field is not defined in the schema, or if the type mismatched the field
  37332. // type.
  37333. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  37334. switch name {
  37335. case whatsappchannel.FieldCreatedAt:
  37336. v, ok := value.(time.Time)
  37337. if !ok {
  37338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37339. }
  37340. m.SetCreatedAt(v)
  37341. return nil
  37342. case whatsappchannel.FieldUpdatedAt:
  37343. v, ok := value.(time.Time)
  37344. if !ok {
  37345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37346. }
  37347. m.SetUpdatedAt(v)
  37348. return nil
  37349. case whatsappchannel.FieldStatus:
  37350. v, ok := value.(uint8)
  37351. if !ok {
  37352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37353. }
  37354. m.SetStatus(v)
  37355. return nil
  37356. case whatsappchannel.FieldDeletedAt:
  37357. v, ok := value.(time.Time)
  37358. if !ok {
  37359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37360. }
  37361. m.SetDeletedAt(v)
  37362. return nil
  37363. case whatsappchannel.FieldAk:
  37364. v, ok := value.(string)
  37365. if !ok {
  37366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37367. }
  37368. m.SetAk(v)
  37369. return nil
  37370. case whatsappchannel.FieldSk:
  37371. v, ok := value.(string)
  37372. if !ok {
  37373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37374. }
  37375. m.SetSk(v)
  37376. return nil
  37377. case whatsappchannel.FieldWaID:
  37378. v, ok := value.(string)
  37379. if !ok {
  37380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37381. }
  37382. m.SetWaID(v)
  37383. return nil
  37384. case whatsappchannel.FieldWaName:
  37385. v, ok := value.(string)
  37386. if !ok {
  37387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37388. }
  37389. m.SetWaName(v)
  37390. return nil
  37391. case whatsappchannel.FieldWabaID:
  37392. v, ok := value.(uint64)
  37393. if !ok {
  37394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37395. }
  37396. m.SetWabaID(v)
  37397. return nil
  37398. case whatsappchannel.FieldBusinessID:
  37399. v, ok := value.(uint64)
  37400. if !ok {
  37401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37402. }
  37403. m.SetBusinessID(v)
  37404. return nil
  37405. case whatsappchannel.FieldOrganizationID:
  37406. v, ok := value.(uint64)
  37407. if !ok {
  37408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37409. }
  37410. m.SetOrganizationID(v)
  37411. return nil
  37412. case whatsappchannel.FieldVerifyAccount:
  37413. v, ok := value.(string)
  37414. if !ok {
  37415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37416. }
  37417. m.SetVerifyAccount(v)
  37418. return nil
  37419. }
  37420. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  37421. }
  37422. // AddedFields returns all numeric fields that were incremented/decremented during
  37423. // this mutation.
  37424. func (m *WhatsappChannelMutation) AddedFields() []string {
  37425. var fields []string
  37426. if m.addstatus != nil {
  37427. fields = append(fields, whatsappchannel.FieldStatus)
  37428. }
  37429. if m.addwaba_id != nil {
  37430. fields = append(fields, whatsappchannel.FieldWabaID)
  37431. }
  37432. if m.addbusiness_id != nil {
  37433. fields = append(fields, whatsappchannel.FieldBusinessID)
  37434. }
  37435. if m.addorganization_id != nil {
  37436. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37437. }
  37438. return fields
  37439. }
  37440. // AddedField returns the numeric value that was incremented/decremented on a field
  37441. // with the given name. The second boolean return value indicates that this field
  37442. // was not set, or was not defined in the schema.
  37443. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  37444. switch name {
  37445. case whatsappchannel.FieldStatus:
  37446. return m.AddedStatus()
  37447. case whatsappchannel.FieldWabaID:
  37448. return m.AddedWabaID()
  37449. case whatsappchannel.FieldBusinessID:
  37450. return m.AddedBusinessID()
  37451. case whatsappchannel.FieldOrganizationID:
  37452. return m.AddedOrganizationID()
  37453. }
  37454. return nil, false
  37455. }
  37456. // AddField adds the value to the field with the given name. It returns an error if
  37457. // the field is not defined in the schema, or if the type mismatched the field
  37458. // type.
  37459. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  37460. switch name {
  37461. case whatsappchannel.FieldStatus:
  37462. v, ok := value.(int8)
  37463. if !ok {
  37464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37465. }
  37466. m.AddStatus(v)
  37467. return nil
  37468. case whatsappchannel.FieldWabaID:
  37469. v, ok := value.(int64)
  37470. if !ok {
  37471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37472. }
  37473. m.AddWabaID(v)
  37474. return nil
  37475. case whatsappchannel.FieldBusinessID:
  37476. v, ok := value.(int64)
  37477. if !ok {
  37478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37479. }
  37480. m.AddBusinessID(v)
  37481. return nil
  37482. case whatsappchannel.FieldOrganizationID:
  37483. v, ok := value.(int64)
  37484. if !ok {
  37485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37486. }
  37487. m.AddOrganizationID(v)
  37488. return nil
  37489. }
  37490. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  37491. }
  37492. // ClearedFields returns all nullable fields that were cleared during this
  37493. // mutation.
  37494. func (m *WhatsappChannelMutation) ClearedFields() []string {
  37495. var fields []string
  37496. if m.FieldCleared(whatsappchannel.FieldStatus) {
  37497. fields = append(fields, whatsappchannel.FieldStatus)
  37498. }
  37499. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  37500. fields = append(fields, whatsappchannel.FieldDeletedAt)
  37501. }
  37502. if m.FieldCleared(whatsappchannel.FieldAk) {
  37503. fields = append(fields, whatsappchannel.FieldAk)
  37504. }
  37505. if m.FieldCleared(whatsappchannel.FieldWaID) {
  37506. fields = append(fields, whatsappchannel.FieldWaID)
  37507. }
  37508. if m.FieldCleared(whatsappchannel.FieldWaName) {
  37509. fields = append(fields, whatsappchannel.FieldWaName)
  37510. }
  37511. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  37512. fields = append(fields, whatsappchannel.FieldOrganizationID)
  37513. }
  37514. return fields
  37515. }
  37516. // FieldCleared returns a boolean indicating if a field with the given name was
  37517. // cleared in this mutation.
  37518. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  37519. _, ok := m.clearedFields[name]
  37520. return ok
  37521. }
  37522. // ClearField clears the value of the field with the given name. It returns an
  37523. // error if the field is not defined in the schema.
  37524. func (m *WhatsappChannelMutation) ClearField(name string) error {
  37525. switch name {
  37526. case whatsappchannel.FieldStatus:
  37527. m.ClearStatus()
  37528. return nil
  37529. case whatsappchannel.FieldDeletedAt:
  37530. m.ClearDeletedAt()
  37531. return nil
  37532. case whatsappchannel.FieldAk:
  37533. m.ClearAk()
  37534. return nil
  37535. case whatsappchannel.FieldWaID:
  37536. m.ClearWaID()
  37537. return nil
  37538. case whatsappchannel.FieldWaName:
  37539. m.ClearWaName()
  37540. return nil
  37541. case whatsappchannel.FieldOrganizationID:
  37542. m.ClearOrganizationID()
  37543. return nil
  37544. }
  37545. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  37546. }
  37547. // ResetField resets all changes in the mutation for the field with the given name.
  37548. // It returns an error if the field is not defined in the schema.
  37549. func (m *WhatsappChannelMutation) ResetField(name string) error {
  37550. switch name {
  37551. case whatsappchannel.FieldCreatedAt:
  37552. m.ResetCreatedAt()
  37553. return nil
  37554. case whatsappchannel.FieldUpdatedAt:
  37555. m.ResetUpdatedAt()
  37556. return nil
  37557. case whatsappchannel.FieldStatus:
  37558. m.ResetStatus()
  37559. return nil
  37560. case whatsappchannel.FieldDeletedAt:
  37561. m.ResetDeletedAt()
  37562. return nil
  37563. case whatsappchannel.FieldAk:
  37564. m.ResetAk()
  37565. return nil
  37566. case whatsappchannel.FieldSk:
  37567. m.ResetSk()
  37568. return nil
  37569. case whatsappchannel.FieldWaID:
  37570. m.ResetWaID()
  37571. return nil
  37572. case whatsappchannel.FieldWaName:
  37573. m.ResetWaName()
  37574. return nil
  37575. case whatsappchannel.FieldWabaID:
  37576. m.ResetWabaID()
  37577. return nil
  37578. case whatsappchannel.FieldBusinessID:
  37579. m.ResetBusinessID()
  37580. return nil
  37581. case whatsappchannel.FieldOrganizationID:
  37582. m.ResetOrganizationID()
  37583. return nil
  37584. case whatsappchannel.FieldVerifyAccount:
  37585. m.ResetVerifyAccount()
  37586. return nil
  37587. }
  37588. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  37589. }
  37590. // AddedEdges returns all edge names that were set/added in this mutation.
  37591. func (m *WhatsappChannelMutation) AddedEdges() []string {
  37592. edges := make([]string, 0, 0)
  37593. return edges
  37594. }
  37595. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37596. // name in this mutation.
  37597. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  37598. return nil
  37599. }
  37600. // RemovedEdges returns all edge names that were removed in this mutation.
  37601. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  37602. edges := make([]string, 0, 0)
  37603. return edges
  37604. }
  37605. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37606. // the given name in this mutation.
  37607. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  37608. return nil
  37609. }
  37610. // ClearedEdges returns all edge names that were cleared in this mutation.
  37611. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  37612. edges := make([]string, 0, 0)
  37613. return edges
  37614. }
  37615. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37616. // was cleared in this mutation.
  37617. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  37618. return false
  37619. }
  37620. // ClearEdge clears the value of the edge with the given name. It returns an error
  37621. // if that edge is not defined in the schema.
  37622. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  37623. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  37624. }
  37625. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37626. // It returns an error if the edge is not defined in the schema.
  37627. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  37628. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  37629. }
  37630. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  37631. type WorkExperienceMutation struct {
  37632. config
  37633. op Op
  37634. typ string
  37635. id *uint64
  37636. created_at *time.Time
  37637. updated_at *time.Time
  37638. deleted_at *time.Time
  37639. start_date *time.Time
  37640. end_date *time.Time
  37641. company *string
  37642. experience *string
  37643. organization_id *uint64
  37644. addorganization_id *int64
  37645. clearedFields map[string]struct{}
  37646. employee *uint64
  37647. clearedemployee bool
  37648. done bool
  37649. oldValue func(context.Context) (*WorkExperience, error)
  37650. predicates []predicate.WorkExperience
  37651. }
  37652. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  37653. // workexperienceOption allows management of the mutation configuration using functional options.
  37654. type workexperienceOption func(*WorkExperienceMutation)
  37655. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  37656. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  37657. m := &WorkExperienceMutation{
  37658. config: c,
  37659. op: op,
  37660. typ: TypeWorkExperience,
  37661. clearedFields: make(map[string]struct{}),
  37662. }
  37663. for _, opt := range opts {
  37664. opt(m)
  37665. }
  37666. return m
  37667. }
  37668. // withWorkExperienceID sets the ID field of the mutation.
  37669. func withWorkExperienceID(id uint64) workexperienceOption {
  37670. return func(m *WorkExperienceMutation) {
  37671. var (
  37672. err error
  37673. once sync.Once
  37674. value *WorkExperience
  37675. )
  37676. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  37677. once.Do(func() {
  37678. if m.done {
  37679. err = errors.New("querying old values post mutation is not allowed")
  37680. } else {
  37681. value, err = m.Client().WorkExperience.Get(ctx, id)
  37682. }
  37683. })
  37684. return value, err
  37685. }
  37686. m.id = &id
  37687. }
  37688. }
  37689. // withWorkExperience sets the old WorkExperience of the mutation.
  37690. func withWorkExperience(node *WorkExperience) workexperienceOption {
  37691. return func(m *WorkExperienceMutation) {
  37692. m.oldValue = func(context.Context) (*WorkExperience, error) {
  37693. return node, nil
  37694. }
  37695. m.id = &node.ID
  37696. }
  37697. }
  37698. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37699. // executed in a transaction (ent.Tx), a transactional client is returned.
  37700. func (m WorkExperienceMutation) Client() *Client {
  37701. client := &Client{config: m.config}
  37702. client.init()
  37703. return client
  37704. }
  37705. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37706. // it returns an error otherwise.
  37707. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  37708. if _, ok := m.driver.(*txDriver); !ok {
  37709. return nil, errors.New("ent: mutation is not running in a transaction")
  37710. }
  37711. tx := &Tx{config: m.config}
  37712. tx.init()
  37713. return tx, nil
  37714. }
  37715. // SetID sets the value of the id field. Note that this
  37716. // operation is only accepted on creation of WorkExperience entities.
  37717. func (m *WorkExperienceMutation) SetID(id uint64) {
  37718. m.id = &id
  37719. }
  37720. // ID returns the ID value in the mutation. Note that the ID is only available
  37721. // if it was provided to the builder or after it was returned from the database.
  37722. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  37723. if m.id == nil {
  37724. return
  37725. }
  37726. return *m.id, true
  37727. }
  37728. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37729. // That means, if the mutation is applied within a transaction with an isolation level such
  37730. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37731. // or updated by the mutation.
  37732. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  37733. switch {
  37734. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37735. id, exists := m.ID()
  37736. if exists {
  37737. return []uint64{id}, nil
  37738. }
  37739. fallthrough
  37740. case m.op.Is(OpUpdate | OpDelete):
  37741. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  37742. default:
  37743. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37744. }
  37745. }
  37746. // SetCreatedAt sets the "created_at" field.
  37747. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  37748. m.created_at = &t
  37749. }
  37750. // CreatedAt returns the value of the "created_at" field in the mutation.
  37751. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  37752. v := m.created_at
  37753. if v == nil {
  37754. return
  37755. }
  37756. return *v, true
  37757. }
  37758. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  37759. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37761. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37762. if !m.op.Is(OpUpdateOne) {
  37763. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37764. }
  37765. if m.id == nil || m.oldValue == nil {
  37766. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37767. }
  37768. oldValue, err := m.oldValue(ctx)
  37769. if err != nil {
  37770. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37771. }
  37772. return oldValue.CreatedAt, nil
  37773. }
  37774. // ResetCreatedAt resets all changes to the "created_at" field.
  37775. func (m *WorkExperienceMutation) ResetCreatedAt() {
  37776. m.created_at = nil
  37777. }
  37778. // SetUpdatedAt sets the "updated_at" field.
  37779. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  37780. m.updated_at = &t
  37781. }
  37782. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37783. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  37784. v := m.updated_at
  37785. if v == nil {
  37786. return
  37787. }
  37788. return *v, true
  37789. }
  37790. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  37791. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37793. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37794. if !m.op.Is(OpUpdateOne) {
  37795. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37796. }
  37797. if m.id == nil || m.oldValue == nil {
  37798. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37799. }
  37800. oldValue, err := m.oldValue(ctx)
  37801. if err != nil {
  37802. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37803. }
  37804. return oldValue.UpdatedAt, nil
  37805. }
  37806. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37807. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  37808. m.updated_at = nil
  37809. }
  37810. // SetDeletedAt sets the "deleted_at" field.
  37811. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  37812. m.deleted_at = &t
  37813. }
  37814. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37815. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  37816. v := m.deleted_at
  37817. if v == nil {
  37818. return
  37819. }
  37820. return *v, true
  37821. }
  37822. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  37823. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37825. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37826. if !m.op.Is(OpUpdateOne) {
  37827. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37828. }
  37829. if m.id == nil || m.oldValue == nil {
  37830. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37831. }
  37832. oldValue, err := m.oldValue(ctx)
  37833. if err != nil {
  37834. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37835. }
  37836. return oldValue.DeletedAt, nil
  37837. }
  37838. // ClearDeletedAt clears the value of the "deleted_at" field.
  37839. func (m *WorkExperienceMutation) ClearDeletedAt() {
  37840. m.deleted_at = nil
  37841. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  37842. }
  37843. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37844. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  37845. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  37846. return ok
  37847. }
  37848. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37849. func (m *WorkExperienceMutation) ResetDeletedAt() {
  37850. m.deleted_at = nil
  37851. delete(m.clearedFields, workexperience.FieldDeletedAt)
  37852. }
  37853. // SetEmployeeID sets the "employee_id" field.
  37854. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  37855. m.employee = &u
  37856. }
  37857. // EmployeeID returns the value of the "employee_id" field in the mutation.
  37858. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  37859. v := m.employee
  37860. if v == nil {
  37861. return
  37862. }
  37863. return *v, true
  37864. }
  37865. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  37866. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37868. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  37869. if !m.op.Is(OpUpdateOne) {
  37870. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  37871. }
  37872. if m.id == nil || m.oldValue == nil {
  37873. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  37874. }
  37875. oldValue, err := m.oldValue(ctx)
  37876. if err != nil {
  37877. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  37878. }
  37879. return oldValue.EmployeeID, nil
  37880. }
  37881. // ResetEmployeeID resets all changes to the "employee_id" field.
  37882. func (m *WorkExperienceMutation) ResetEmployeeID() {
  37883. m.employee = nil
  37884. }
  37885. // SetStartDate sets the "start_date" field.
  37886. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  37887. m.start_date = &t
  37888. }
  37889. // StartDate returns the value of the "start_date" field in the mutation.
  37890. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  37891. v := m.start_date
  37892. if v == nil {
  37893. return
  37894. }
  37895. return *v, true
  37896. }
  37897. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  37898. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37900. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  37901. if !m.op.Is(OpUpdateOne) {
  37902. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  37903. }
  37904. if m.id == nil || m.oldValue == nil {
  37905. return v, errors.New("OldStartDate requires an ID field in the mutation")
  37906. }
  37907. oldValue, err := m.oldValue(ctx)
  37908. if err != nil {
  37909. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  37910. }
  37911. return oldValue.StartDate, nil
  37912. }
  37913. // ResetStartDate resets all changes to the "start_date" field.
  37914. func (m *WorkExperienceMutation) ResetStartDate() {
  37915. m.start_date = nil
  37916. }
  37917. // SetEndDate sets the "end_date" field.
  37918. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  37919. m.end_date = &t
  37920. }
  37921. // EndDate returns the value of the "end_date" field in the mutation.
  37922. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  37923. v := m.end_date
  37924. if v == nil {
  37925. return
  37926. }
  37927. return *v, true
  37928. }
  37929. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  37930. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37932. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  37933. if !m.op.Is(OpUpdateOne) {
  37934. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  37935. }
  37936. if m.id == nil || m.oldValue == nil {
  37937. return v, errors.New("OldEndDate requires an ID field in the mutation")
  37938. }
  37939. oldValue, err := m.oldValue(ctx)
  37940. if err != nil {
  37941. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  37942. }
  37943. return oldValue.EndDate, nil
  37944. }
  37945. // ResetEndDate resets all changes to the "end_date" field.
  37946. func (m *WorkExperienceMutation) ResetEndDate() {
  37947. m.end_date = nil
  37948. }
  37949. // SetCompany sets the "company" field.
  37950. func (m *WorkExperienceMutation) SetCompany(s string) {
  37951. m.company = &s
  37952. }
  37953. // Company returns the value of the "company" field in the mutation.
  37954. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  37955. v := m.company
  37956. if v == nil {
  37957. return
  37958. }
  37959. return *v, true
  37960. }
  37961. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  37962. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37964. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  37965. if !m.op.Is(OpUpdateOne) {
  37966. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  37967. }
  37968. if m.id == nil || m.oldValue == nil {
  37969. return v, errors.New("OldCompany requires an ID field in the mutation")
  37970. }
  37971. oldValue, err := m.oldValue(ctx)
  37972. if err != nil {
  37973. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  37974. }
  37975. return oldValue.Company, nil
  37976. }
  37977. // ResetCompany resets all changes to the "company" field.
  37978. func (m *WorkExperienceMutation) ResetCompany() {
  37979. m.company = nil
  37980. }
  37981. // SetExperience sets the "experience" field.
  37982. func (m *WorkExperienceMutation) SetExperience(s string) {
  37983. m.experience = &s
  37984. }
  37985. // Experience returns the value of the "experience" field in the mutation.
  37986. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  37987. v := m.experience
  37988. if v == nil {
  37989. return
  37990. }
  37991. return *v, true
  37992. }
  37993. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  37994. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  37995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37996. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  37997. if !m.op.Is(OpUpdateOne) {
  37998. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  37999. }
  38000. if m.id == nil || m.oldValue == nil {
  38001. return v, errors.New("OldExperience requires an ID field in the mutation")
  38002. }
  38003. oldValue, err := m.oldValue(ctx)
  38004. if err != nil {
  38005. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  38006. }
  38007. return oldValue.Experience, nil
  38008. }
  38009. // ResetExperience resets all changes to the "experience" field.
  38010. func (m *WorkExperienceMutation) ResetExperience() {
  38011. m.experience = nil
  38012. }
  38013. // SetOrganizationID sets the "organization_id" field.
  38014. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  38015. m.organization_id = &u
  38016. m.addorganization_id = nil
  38017. }
  38018. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38019. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  38020. v := m.organization_id
  38021. if v == nil {
  38022. return
  38023. }
  38024. return *v, true
  38025. }
  38026. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  38027. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  38028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38029. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38030. if !m.op.Is(OpUpdateOne) {
  38031. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38032. }
  38033. if m.id == nil || m.oldValue == nil {
  38034. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38035. }
  38036. oldValue, err := m.oldValue(ctx)
  38037. if err != nil {
  38038. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38039. }
  38040. return oldValue.OrganizationID, nil
  38041. }
  38042. // AddOrganizationID adds u to the "organization_id" field.
  38043. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  38044. if m.addorganization_id != nil {
  38045. *m.addorganization_id += u
  38046. } else {
  38047. m.addorganization_id = &u
  38048. }
  38049. }
  38050. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38051. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  38052. v := m.addorganization_id
  38053. if v == nil {
  38054. return
  38055. }
  38056. return *v, true
  38057. }
  38058. // ResetOrganizationID resets all changes to the "organization_id" field.
  38059. func (m *WorkExperienceMutation) ResetOrganizationID() {
  38060. m.organization_id = nil
  38061. m.addorganization_id = nil
  38062. }
  38063. // ClearEmployee clears the "employee" edge to the Employee entity.
  38064. func (m *WorkExperienceMutation) ClearEmployee() {
  38065. m.clearedemployee = true
  38066. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  38067. }
  38068. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  38069. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  38070. return m.clearedemployee
  38071. }
  38072. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  38073. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38074. // EmployeeID instead. It exists only for internal usage by the builders.
  38075. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  38076. if id := m.employee; id != nil {
  38077. ids = append(ids, *id)
  38078. }
  38079. return
  38080. }
  38081. // ResetEmployee resets all changes to the "employee" edge.
  38082. func (m *WorkExperienceMutation) ResetEmployee() {
  38083. m.employee = nil
  38084. m.clearedemployee = false
  38085. }
  38086. // Where appends a list predicates to the WorkExperienceMutation builder.
  38087. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  38088. m.predicates = append(m.predicates, ps...)
  38089. }
  38090. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  38091. // users can use type-assertion to append predicates that do not depend on any generated package.
  38092. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  38093. p := make([]predicate.WorkExperience, len(ps))
  38094. for i := range ps {
  38095. p[i] = ps[i]
  38096. }
  38097. m.Where(p...)
  38098. }
  38099. // Op returns the operation name.
  38100. func (m *WorkExperienceMutation) Op() Op {
  38101. return m.op
  38102. }
  38103. // SetOp allows setting the mutation operation.
  38104. func (m *WorkExperienceMutation) SetOp(op Op) {
  38105. m.op = op
  38106. }
  38107. // Type returns the node type of this mutation (WorkExperience).
  38108. func (m *WorkExperienceMutation) Type() string {
  38109. return m.typ
  38110. }
  38111. // Fields returns all fields that were changed during this mutation. Note that in
  38112. // order to get all numeric fields that were incremented/decremented, call
  38113. // AddedFields().
  38114. func (m *WorkExperienceMutation) Fields() []string {
  38115. fields := make([]string, 0, 9)
  38116. if m.created_at != nil {
  38117. fields = append(fields, workexperience.FieldCreatedAt)
  38118. }
  38119. if m.updated_at != nil {
  38120. fields = append(fields, workexperience.FieldUpdatedAt)
  38121. }
  38122. if m.deleted_at != nil {
  38123. fields = append(fields, workexperience.FieldDeletedAt)
  38124. }
  38125. if m.employee != nil {
  38126. fields = append(fields, workexperience.FieldEmployeeID)
  38127. }
  38128. if m.start_date != nil {
  38129. fields = append(fields, workexperience.FieldStartDate)
  38130. }
  38131. if m.end_date != nil {
  38132. fields = append(fields, workexperience.FieldEndDate)
  38133. }
  38134. if m.company != nil {
  38135. fields = append(fields, workexperience.FieldCompany)
  38136. }
  38137. if m.experience != nil {
  38138. fields = append(fields, workexperience.FieldExperience)
  38139. }
  38140. if m.organization_id != nil {
  38141. fields = append(fields, workexperience.FieldOrganizationID)
  38142. }
  38143. return fields
  38144. }
  38145. // Field returns the value of a field with the given name. The second boolean
  38146. // return value indicates that this field was not set, or was not defined in the
  38147. // schema.
  38148. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  38149. switch name {
  38150. case workexperience.FieldCreatedAt:
  38151. return m.CreatedAt()
  38152. case workexperience.FieldUpdatedAt:
  38153. return m.UpdatedAt()
  38154. case workexperience.FieldDeletedAt:
  38155. return m.DeletedAt()
  38156. case workexperience.FieldEmployeeID:
  38157. return m.EmployeeID()
  38158. case workexperience.FieldStartDate:
  38159. return m.StartDate()
  38160. case workexperience.FieldEndDate:
  38161. return m.EndDate()
  38162. case workexperience.FieldCompany:
  38163. return m.Company()
  38164. case workexperience.FieldExperience:
  38165. return m.Experience()
  38166. case workexperience.FieldOrganizationID:
  38167. return m.OrganizationID()
  38168. }
  38169. return nil, false
  38170. }
  38171. // OldField returns the old value of the field from the database. An error is
  38172. // returned if the mutation operation is not UpdateOne, or the query to the
  38173. // database failed.
  38174. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38175. switch name {
  38176. case workexperience.FieldCreatedAt:
  38177. return m.OldCreatedAt(ctx)
  38178. case workexperience.FieldUpdatedAt:
  38179. return m.OldUpdatedAt(ctx)
  38180. case workexperience.FieldDeletedAt:
  38181. return m.OldDeletedAt(ctx)
  38182. case workexperience.FieldEmployeeID:
  38183. return m.OldEmployeeID(ctx)
  38184. case workexperience.FieldStartDate:
  38185. return m.OldStartDate(ctx)
  38186. case workexperience.FieldEndDate:
  38187. return m.OldEndDate(ctx)
  38188. case workexperience.FieldCompany:
  38189. return m.OldCompany(ctx)
  38190. case workexperience.FieldExperience:
  38191. return m.OldExperience(ctx)
  38192. case workexperience.FieldOrganizationID:
  38193. return m.OldOrganizationID(ctx)
  38194. }
  38195. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  38196. }
  38197. // SetField sets the value of a field with the given name. It returns an error if
  38198. // the field is not defined in the schema, or if the type mismatched the field
  38199. // type.
  38200. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  38201. switch name {
  38202. case workexperience.FieldCreatedAt:
  38203. v, ok := value.(time.Time)
  38204. if !ok {
  38205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38206. }
  38207. m.SetCreatedAt(v)
  38208. return nil
  38209. case workexperience.FieldUpdatedAt:
  38210. v, ok := value.(time.Time)
  38211. if !ok {
  38212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38213. }
  38214. m.SetUpdatedAt(v)
  38215. return nil
  38216. case workexperience.FieldDeletedAt:
  38217. v, ok := value.(time.Time)
  38218. if !ok {
  38219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38220. }
  38221. m.SetDeletedAt(v)
  38222. return nil
  38223. case workexperience.FieldEmployeeID:
  38224. v, ok := value.(uint64)
  38225. if !ok {
  38226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38227. }
  38228. m.SetEmployeeID(v)
  38229. return nil
  38230. case workexperience.FieldStartDate:
  38231. v, ok := value.(time.Time)
  38232. if !ok {
  38233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38234. }
  38235. m.SetStartDate(v)
  38236. return nil
  38237. case workexperience.FieldEndDate:
  38238. v, ok := value.(time.Time)
  38239. if !ok {
  38240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38241. }
  38242. m.SetEndDate(v)
  38243. return nil
  38244. case workexperience.FieldCompany:
  38245. v, ok := value.(string)
  38246. if !ok {
  38247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38248. }
  38249. m.SetCompany(v)
  38250. return nil
  38251. case workexperience.FieldExperience:
  38252. v, ok := value.(string)
  38253. if !ok {
  38254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38255. }
  38256. m.SetExperience(v)
  38257. return nil
  38258. case workexperience.FieldOrganizationID:
  38259. v, ok := value.(uint64)
  38260. if !ok {
  38261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38262. }
  38263. m.SetOrganizationID(v)
  38264. return nil
  38265. }
  38266. return fmt.Errorf("unknown WorkExperience field %s", name)
  38267. }
  38268. // AddedFields returns all numeric fields that were incremented/decremented during
  38269. // this mutation.
  38270. func (m *WorkExperienceMutation) AddedFields() []string {
  38271. var fields []string
  38272. if m.addorganization_id != nil {
  38273. fields = append(fields, workexperience.FieldOrganizationID)
  38274. }
  38275. return fields
  38276. }
  38277. // AddedField returns the numeric value that was incremented/decremented on a field
  38278. // with the given name. The second boolean return value indicates that this field
  38279. // was not set, or was not defined in the schema.
  38280. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  38281. switch name {
  38282. case workexperience.FieldOrganizationID:
  38283. return m.AddedOrganizationID()
  38284. }
  38285. return nil, false
  38286. }
  38287. // AddField adds the value to the field with the given name. It returns an error if
  38288. // the field is not defined in the schema, or if the type mismatched the field
  38289. // type.
  38290. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  38291. switch name {
  38292. case workexperience.FieldOrganizationID:
  38293. v, ok := value.(int64)
  38294. if !ok {
  38295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38296. }
  38297. m.AddOrganizationID(v)
  38298. return nil
  38299. }
  38300. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  38301. }
  38302. // ClearedFields returns all nullable fields that were cleared during this
  38303. // mutation.
  38304. func (m *WorkExperienceMutation) ClearedFields() []string {
  38305. var fields []string
  38306. if m.FieldCleared(workexperience.FieldDeletedAt) {
  38307. fields = append(fields, workexperience.FieldDeletedAt)
  38308. }
  38309. return fields
  38310. }
  38311. // FieldCleared returns a boolean indicating if a field with the given name was
  38312. // cleared in this mutation.
  38313. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  38314. _, ok := m.clearedFields[name]
  38315. return ok
  38316. }
  38317. // ClearField clears the value of the field with the given name. It returns an
  38318. // error if the field is not defined in the schema.
  38319. func (m *WorkExperienceMutation) ClearField(name string) error {
  38320. switch name {
  38321. case workexperience.FieldDeletedAt:
  38322. m.ClearDeletedAt()
  38323. return nil
  38324. }
  38325. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  38326. }
  38327. // ResetField resets all changes in the mutation for the field with the given name.
  38328. // It returns an error if the field is not defined in the schema.
  38329. func (m *WorkExperienceMutation) ResetField(name string) error {
  38330. switch name {
  38331. case workexperience.FieldCreatedAt:
  38332. m.ResetCreatedAt()
  38333. return nil
  38334. case workexperience.FieldUpdatedAt:
  38335. m.ResetUpdatedAt()
  38336. return nil
  38337. case workexperience.FieldDeletedAt:
  38338. m.ResetDeletedAt()
  38339. return nil
  38340. case workexperience.FieldEmployeeID:
  38341. m.ResetEmployeeID()
  38342. return nil
  38343. case workexperience.FieldStartDate:
  38344. m.ResetStartDate()
  38345. return nil
  38346. case workexperience.FieldEndDate:
  38347. m.ResetEndDate()
  38348. return nil
  38349. case workexperience.FieldCompany:
  38350. m.ResetCompany()
  38351. return nil
  38352. case workexperience.FieldExperience:
  38353. m.ResetExperience()
  38354. return nil
  38355. case workexperience.FieldOrganizationID:
  38356. m.ResetOrganizationID()
  38357. return nil
  38358. }
  38359. return fmt.Errorf("unknown WorkExperience field %s", name)
  38360. }
  38361. // AddedEdges returns all edge names that were set/added in this mutation.
  38362. func (m *WorkExperienceMutation) AddedEdges() []string {
  38363. edges := make([]string, 0, 1)
  38364. if m.employee != nil {
  38365. edges = append(edges, workexperience.EdgeEmployee)
  38366. }
  38367. return edges
  38368. }
  38369. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38370. // name in this mutation.
  38371. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  38372. switch name {
  38373. case workexperience.EdgeEmployee:
  38374. if id := m.employee; id != nil {
  38375. return []ent.Value{*id}
  38376. }
  38377. }
  38378. return nil
  38379. }
  38380. // RemovedEdges returns all edge names that were removed in this mutation.
  38381. func (m *WorkExperienceMutation) RemovedEdges() []string {
  38382. edges := make([]string, 0, 1)
  38383. return edges
  38384. }
  38385. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38386. // the given name in this mutation.
  38387. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  38388. return nil
  38389. }
  38390. // ClearedEdges returns all edge names that were cleared in this mutation.
  38391. func (m *WorkExperienceMutation) ClearedEdges() []string {
  38392. edges := make([]string, 0, 1)
  38393. if m.clearedemployee {
  38394. edges = append(edges, workexperience.EdgeEmployee)
  38395. }
  38396. return edges
  38397. }
  38398. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38399. // was cleared in this mutation.
  38400. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  38401. switch name {
  38402. case workexperience.EdgeEmployee:
  38403. return m.clearedemployee
  38404. }
  38405. return false
  38406. }
  38407. // ClearEdge clears the value of the edge with the given name. It returns an error
  38408. // if that edge is not defined in the schema.
  38409. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  38410. switch name {
  38411. case workexperience.EdgeEmployee:
  38412. m.ClearEmployee()
  38413. return nil
  38414. }
  38415. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  38416. }
  38417. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38418. // It returns an error if the edge is not defined in the schema.
  38419. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  38420. switch name {
  38421. case workexperience.EdgeEmployee:
  38422. m.ResetEmployee()
  38423. return nil
  38424. }
  38425. return fmt.Errorf("unknown WorkExperience edge %s", name)
  38426. }
  38427. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  38428. type WpChatroomMutation struct {
  38429. config
  38430. op Op
  38431. typ string
  38432. id *uint64
  38433. created_at *time.Time
  38434. updated_at *time.Time
  38435. status *uint8
  38436. addstatus *int8
  38437. wx_wxid *string
  38438. chatroom_id *string
  38439. nickname *string
  38440. owner *string
  38441. avatar *string
  38442. member_list *[]string
  38443. appendmember_list []string
  38444. clearedFields map[string]struct{}
  38445. done bool
  38446. oldValue func(context.Context) (*WpChatroom, error)
  38447. predicates []predicate.WpChatroom
  38448. }
  38449. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  38450. // wpchatroomOption allows management of the mutation configuration using functional options.
  38451. type wpchatroomOption func(*WpChatroomMutation)
  38452. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  38453. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  38454. m := &WpChatroomMutation{
  38455. config: c,
  38456. op: op,
  38457. typ: TypeWpChatroom,
  38458. clearedFields: make(map[string]struct{}),
  38459. }
  38460. for _, opt := range opts {
  38461. opt(m)
  38462. }
  38463. return m
  38464. }
  38465. // withWpChatroomID sets the ID field of the mutation.
  38466. func withWpChatroomID(id uint64) wpchatroomOption {
  38467. return func(m *WpChatroomMutation) {
  38468. var (
  38469. err error
  38470. once sync.Once
  38471. value *WpChatroom
  38472. )
  38473. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  38474. once.Do(func() {
  38475. if m.done {
  38476. err = errors.New("querying old values post mutation is not allowed")
  38477. } else {
  38478. value, err = m.Client().WpChatroom.Get(ctx, id)
  38479. }
  38480. })
  38481. return value, err
  38482. }
  38483. m.id = &id
  38484. }
  38485. }
  38486. // withWpChatroom sets the old WpChatroom of the mutation.
  38487. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  38488. return func(m *WpChatroomMutation) {
  38489. m.oldValue = func(context.Context) (*WpChatroom, error) {
  38490. return node, nil
  38491. }
  38492. m.id = &node.ID
  38493. }
  38494. }
  38495. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38496. // executed in a transaction (ent.Tx), a transactional client is returned.
  38497. func (m WpChatroomMutation) Client() *Client {
  38498. client := &Client{config: m.config}
  38499. client.init()
  38500. return client
  38501. }
  38502. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38503. // it returns an error otherwise.
  38504. func (m WpChatroomMutation) Tx() (*Tx, error) {
  38505. if _, ok := m.driver.(*txDriver); !ok {
  38506. return nil, errors.New("ent: mutation is not running in a transaction")
  38507. }
  38508. tx := &Tx{config: m.config}
  38509. tx.init()
  38510. return tx, nil
  38511. }
  38512. // SetID sets the value of the id field. Note that this
  38513. // operation is only accepted on creation of WpChatroom entities.
  38514. func (m *WpChatroomMutation) SetID(id uint64) {
  38515. m.id = &id
  38516. }
  38517. // ID returns the ID value in the mutation. Note that the ID is only available
  38518. // if it was provided to the builder or after it was returned from the database.
  38519. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  38520. if m.id == nil {
  38521. return
  38522. }
  38523. return *m.id, true
  38524. }
  38525. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38526. // That means, if the mutation is applied within a transaction with an isolation level such
  38527. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38528. // or updated by the mutation.
  38529. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  38530. switch {
  38531. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38532. id, exists := m.ID()
  38533. if exists {
  38534. return []uint64{id}, nil
  38535. }
  38536. fallthrough
  38537. case m.op.Is(OpUpdate | OpDelete):
  38538. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  38539. default:
  38540. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38541. }
  38542. }
  38543. // SetCreatedAt sets the "created_at" field.
  38544. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  38545. m.created_at = &t
  38546. }
  38547. // CreatedAt returns the value of the "created_at" field in the mutation.
  38548. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  38549. v := m.created_at
  38550. if v == nil {
  38551. return
  38552. }
  38553. return *v, true
  38554. }
  38555. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  38556. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38558. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38559. if !m.op.Is(OpUpdateOne) {
  38560. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38561. }
  38562. if m.id == nil || m.oldValue == nil {
  38563. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38564. }
  38565. oldValue, err := m.oldValue(ctx)
  38566. if err != nil {
  38567. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38568. }
  38569. return oldValue.CreatedAt, nil
  38570. }
  38571. // ResetCreatedAt resets all changes to the "created_at" field.
  38572. func (m *WpChatroomMutation) ResetCreatedAt() {
  38573. m.created_at = nil
  38574. }
  38575. // SetUpdatedAt sets the "updated_at" field.
  38576. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  38577. m.updated_at = &t
  38578. }
  38579. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38580. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  38581. v := m.updated_at
  38582. if v == nil {
  38583. return
  38584. }
  38585. return *v, true
  38586. }
  38587. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  38588. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38590. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38591. if !m.op.Is(OpUpdateOne) {
  38592. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38593. }
  38594. if m.id == nil || m.oldValue == nil {
  38595. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38596. }
  38597. oldValue, err := m.oldValue(ctx)
  38598. if err != nil {
  38599. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38600. }
  38601. return oldValue.UpdatedAt, nil
  38602. }
  38603. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38604. func (m *WpChatroomMutation) ResetUpdatedAt() {
  38605. m.updated_at = nil
  38606. }
  38607. // SetStatus sets the "status" field.
  38608. func (m *WpChatroomMutation) SetStatus(u uint8) {
  38609. m.status = &u
  38610. m.addstatus = nil
  38611. }
  38612. // Status returns the value of the "status" field in the mutation.
  38613. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  38614. v := m.status
  38615. if v == nil {
  38616. return
  38617. }
  38618. return *v, true
  38619. }
  38620. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  38621. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38623. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38624. if !m.op.Is(OpUpdateOne) {
  38625. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38626. }
  38627. if m.id == nil || m.oldValue == nil {
  38628. return v, errors.New("OldStatus requires an ID field in the mutation")
  38629. }
  38630. oldValue, err := m.oldValue(ctx)
  38631. if err != nil {
  38632. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38633. }
  38634. return oldValue.Status, nil
  38635. }
  38636. // AddStatus adds u to the "status" field.
  38637. func (m *WpChatroomMutation) AddStatus(u int8) {
  38638. if m.addstatus != nil {
  38639. *m.addstatus += u
  38640. } else {
  38641. m.addstatus = &u
  38642. }
  38643. }
  38644. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38645. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  38646. v := m.addstatus
  38647. if v == nil {
  38648. return
  38649. }
  38650. return *v, true
  38651. }
  38652. // ClearStatus clears the value of the "status" field.
  38653. func (m *WpChatroomMutation) ClearStatus() {
  38654. m.status = nil
  38655. m.addstatus = nil
  38656. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  38657. }
  38658. // StatusCleared returns if the "status" field was cleared in this mutation.
  38659. func (m *WpChatroomMutation) StatusCleared() bool {
  38660. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  38661. return ok
  38662. }
  38663. // ResetStatus resets all changes to the "status" field.
  38664. func (m *WpChatroomMutation) ResetStatus() {
  38665. m.status = nil
  38666. m.addstatus = nil
  38667. delete(m.clearedFields, wpchatroom.FieldStatus)
  38668. }
  38669. // SetWxWxid sets the "wx_wxid" field.
  38670. func (m *WpChatroomMutation) SetWxWxid(s string) {
  38671. m.wx_wxid = &s
  38672. }
  38673. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  38674. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  38675. v := m.wx_wxid
  38676. if v == nil {
  38677. return
  38678. }
  38679. return *v, true
  38680. }
  38681. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  38682. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38684. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  38685. if !m.op.Is(OpUpdateOne) {
  38686. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  38687. }
  38688. if m.id == nil || m.oldValue == nil {
  38689. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  38690. }
  38691. oldValue, err := m.oldValue(ctx)
  38692. if err != nil {
  38693. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  38694. }
  38695. return oldValue.WxWxid, nil
  38696. }
  38697. // ResetWxWxid resets all changes to the "wx_wxid" field.
  38698. func (m *WpChatroomMutation) ResetWxWxid() {
  38699. m.wx_wxid = nil
  38700. }
  38701. // SetChatroomID sets the "chatroom_id" field.
  38702. func (m *WpChatroomMutation) SetChatroomID(s string) {
  38703. m.chatroom_id = &s
  38704. }
  38705. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  38706. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  38707. v := m.chatroom_id
  38708. if v == nil {
  38709. return
  38710. }
  38711. return *v, true
  38712. }
  38713. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  38714. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38716. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  38717. if !m.op.Is(OpUpdateOne) {
  38718. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  38719. }
  38720. if m.id == nil || m.oldValue == nil {
  38721. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  38722. }
  38723. oldValue, err := m.oldValue(ctx)
  38724. if err != nil {
  38725. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  38726. }
  38727. return oldValue.ChatroomID, nil
  38728. }
  38729. // ResetChatroomID resets all changes to the "chatroom_id" field.
  38730. func (m *WpChatroomMutation) ResetChatroomID() {
  38731. m.chatroom_id = nil
  38732. }
  38733. // SetNickname sets the "nickname" field.
  38734. func (m *WpChatroomMutation) SetNickname(s string) {
  38735. m.nickname = &s
  38736. }
  38737. // Nickname returns the value of the "nickname" field in the mutation.
  38738. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  38739. v := m.nickname
  38740. if v == nil {
  38741. return
  38742. }
  38743. return *v, true
  38744. }
  38745. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  38746. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38748. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  38749. if !m.op.Is(OpUpdateOne) {
  38750. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  38751. }
  38752. if m.id == nil || m.oldValue == nil {
  38753. return v, errors.New("OldNickname requires an ID field in the mutation")
  38754. }
  38755. oldValue, err := m.oldValue(ctx)
  38756. if err != nil {
  38757. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  38758. }
  38759. return oldValue.Nickname, nil
  38760. }
  38761. // ResetNickname resets all changes to the "nickname" field.
  38762. func (m *WpChatroomMutation) ResetNickname() {
  38763. m.nickname = nil
  38764. }
  38765. // SetOwner sets the "owner" field.
  38766. func (m *WpChatroomMutation) SetOwner(s string) {
  38767. m.owner = &s
  38768. }
  38769. // Owner returns the value of the "owner" field in the mutation.
  38770. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  38771. v := m.owner
  38772. if v == nil {
  38773. return
  38774. }
  38775. return *v, true
  38776. }
  38777. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  38778. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38780. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  38781. if !m.op.Is(OpUpdateOne) {
  38782. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  38783. }
  38784. if m.id == nil || m.oldValue == nil {
  38785. return v, errors.New("OldOwner requires an ID field in the mutation")
  38786. }
  38787. oldValue, err := m.oldValue(ctx)
  38788. if err != nil {
  38789. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  38790. }
  38791. return oldValue.Owner, nil
  38792. }
  38793. // ResetOwner resets all changes to the "owner" field.
  38794. func (m *WpChatroomMutation) ResetOwner() {
  38795. m.owner = nil
  38796. }
  38797. // SetAvatar sets the "avatar" field.
  38798. func (m *WpChatroomMutation) SetAvatar(s string) {
  38799. m.avatar = &s
  38800. }
  38801. // Avatar returns the value of the "avatar" field in the mutation.
  38802. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  38803. v := m.avatar
  38804. if v == nil {
  38805. return
  38806. }
  38807. return *v, true
  38808. }
  38809. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  38810. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38812. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  38813. if !m.op.Is(OpUpdateOne) {
  38814. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  38815. }
  38816. if m.id == nil || m.oldValue == nil {
  38817. return v, errors.New("OldAvatar requires an ID field in the mutation")
  38818. }
  38819. oldValue, err := m.oldValue(ctx)
  38820. if err != nil {
  38821. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  38822. }
  38823. return oldValue.Avatar, nil
  38824. }
  38825. // ResetAvatar resets all changes to the "avatar" field.
  38826. func (m *WpChatroomMutation) ResetAvatar() {
  38827. m.avatar = nil
  38828. }
  38829. // SetMemberList sets the "member_list" field.
  38830. func (m *WpChatroomMutation) SetMemberList(s []string) {
  38831. m.member_list = &s
  38832. m.appendmember_list = nil
  38833. }
  38834. // MemberList returns the value of the "member_list" field in the mutation.
  38835. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  38836. v := m.member_list
  38837. if v == nil {
  38838. return
  38839. }
  38840. return *v, true
  38841. }
  38842. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  38843. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  38844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38845. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  38846. if !m.op.Is(OpUpdateOne) {
  38847. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  38848. }
  38849. if m.id == nil || m.oldValue == nil {
  38850. return v, errors.New("OldMemberList requires an ID field in the mutation")
  38851. }
  38852. oldValue, err := m.oldValue(ctx)
  38853. if err != nil {
  38854. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  38855. }
  38856. return oldValue.MemberList, nil
  38857. }
  38858. // AppendMemberList adds s to the "member_list" field.
  38859. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  38860. m.appendmember_list = append(m.appendmember_list, s...)
  38861. }
  38862. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  38863. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  38864. if len(m.appendmember_list) == 0 {
  38865. return nil, false
  38866. }
  38867. return m.appendmember_list, true
  38868. }
  38869. // ResetMemberList resets all changes to the "member_list" field.
  38870. func (m *WpChatroomMutation) ResetMemberList() {
  38871. m.member_list = nil
  38872. m.appendmember_list = nil
  38873. }
  38874. // Where appends a list predicates to the WpChatroomMutation builder.
  38875. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  38876. m.predicates = append(m.predicates, ps...)
  38877. }
  38878. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  38879. // users can use type-assertion to append predicates that do not depend on any generated package.
  38880. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  38881. p := make([]predicate.WpChatroom, len(ps))
  38882. for i := range ps {
  38883. p[i] = ps[i]
  38884. }
  38885. m.Where(p...)
  38886. }
  38887. // Op returns the operation name.
  38888. func (m *WpChatroomMutation) Op() Op {
  38889. return m.op
  38890. }
  38891. // SetOp allows setting the mutation operation.
  38892. func (m *WpChatroomMutation) SetOp(op Op) {
  38893. m.op = op
  38894. }
  38895. // Type returns the node type of this mutation (WpChatroom).
  38896. func (m *WpChatroomMutation) Type() string {
  38897. return m.typ
  38898. }
  38899. // Fields returns all fields that were changed during this mutation. Note that in
  38900. // order to get all numeric fields that were incremented/decremented, call
  38901. // AddedFields().
  38902. func (m *WpChatroomMutation) Fields() []string {
  38903. fields := make([]string, 0, 9)
  38904. if m.created_at != nil {
  38905. fields = append(fields, wpchatroom.FieldCreatedAt)
  38906. }
  38907. if m.updated_at != nil {
  38908. fields = append(fields, wpchatroom.FieldUpdatedAt)
  38909. }
  38910. if m.status != nil {
  38911. fields = append(fields, wpchatroom.FieldStatus)
  38912. }
  38913. if m.wx_wxid != nil {
  38914. fields = append(fields, wpchatroom.FieldWxWxid)
  38915. }
  38916. if m.chatroom_id != nil {
  38917. fields = append(fields, wpchatroom.FieldChatroomID)
  38918. }
  38919. if m.nickname != nil {
  38920. fields = append(fields, wpchatroom.FieldNickname)
  38921. }
  38922. if m.owner != nil {
  38923. fields = append(fields, wpchatroom.FieldOwner)
  38924. }
  38925. if m.avatar != nil {
  38926. fields = append(fields, wpchatroom.FieldAvatar)
  38927. }
  38928. if m.member_list != nil {
  38929. fields = append(fields, wpchatroom.FieldMemberList)
  38930. }
  38931. return fields
  38932. }
  38933. // Field returns the value of a field with the given name. The second boolean
  38934. // return value indicates that this field was not set, or was not defined in the
  38935. // schema.
  38936. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  38937. switch name {
  38938. case wpchatroom.FieldCreatedAt:
  38939. return m.CreatedAt()
  38940. case wpchatroom.FieldUpdatedAt:
  38941. return m.UpdatedAt()
  38942. case wpchatroom.FieldStatus:
  38943. return m.Status()
  38944. case wpchatroom.FieldWxWxid:
  38945. return m.WxWxid()
  38946. case wpchatroom.FieldChatroomID:
  38947. return m.ChatroomID()
  38948. case wpchatroom.FieldNickname:
  38949. return m.Nickname()
  38950. case wpchatroom.FieldOwner:
  38951. return m.Owner()
  38952. case wpchatroom.FieldAvatar:
  38953. return m.Avatar()
  38954. case wpchatroom.FieldMemberList:
  38955. return m.MemberList()
  38956. }
  38957. return nil, false
  38958. }
  38959. // OldField returns the old value of the field from the database. An error is
  38960. // returned if the mutation operation is not UpdateOne, or the query to the
  38961. // database failed.
  38962. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38963. switch name {
  38964. case wpchatroom.FieldCreatedAt:
  38965. return m.OldCreatedAt(ctx)
  38966. case wpchatroom.FieldUpdatedAt:
  38967. return m.OldUpdatedAt(ctx)
  38968. case wpchatroom.FieldStatus:
  38969. return m.OldStatus(ctx)
  38970. case wpchatroom.FieldWxWxid:
  38971. return m.OldWxWxid(ctx)
  38972. case wpchatroom.FieldChatroomID:
  38973. return m.OldChatroomID(ctx)
  38974. case wpchatroom.FieldNickname:
  38975. return m.OldNickname(ctx)
  38976. case wpchatroom.FieldOwner:
  38977. return m.OldOwner(ctx)
  38978. case wpchatroom.FieldAvatar:
  38979. return m.OldAvatar(ctx)
  38980. case wpchatroom.FieldMemberList:
  38981. return m.OldMemberList(ctx)
  38982. }
  38983. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  38984. }
  38985. // SetField sets the value of a field with the given name. It returns an error if
  38986. // the field is not defined in the schema, or if the type mismatched the field
  38987. // type.
  38988. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  38989. switch name {
  38990. case wpchatroom.FieldCreatedAt:
  38991. v, ok := value.(time.Time)
  38992. if !ok {
  38993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38994. }
  38995. m.SetCreatedAt(v)
  38996. return nil
  38997. case wpchatroom.FieldUpdatedAt:
  38998. v, ok := value.(time.Time)
  38999. if !ok {
  39000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39001. }
  39002. m.SetUpdatedAt(v)
  39003. return nil
  39004. case wpchatroom.FieldStatus:
  39005. v, ok := value.(uint8)
  39006. if !ok {
  39007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39008. }
  39009. m.SetStatus(v)
  39010. return nil
  39011. case wpchatroom.FieldWxWxid:
  39012. v, ok := value.(string)
  39013. if !ok {
  39014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39015. }
  39016. m.SetWxWxid(v)
  39017. return nil
  39018. case wpchatroom.FieldChatroomID:
  39019. v, ok := value.(string)
  39020. if !ok {
  39021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39022. }
  39023. m.SetChatroomID(v)
  39024. return nil
  39025. case wpchatroom.FieldNickname:
  39026. v, ok := value.(string)
  39027. if !ok {
  39028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39029. }
  39030. m.SetNickname(v)
  39031. return nil
  39032. case wpchatroom.FieldOwner:
  39033. v, ok := value.(string)
  39034. if !ok {
  39035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39036. }
  39037. m.SetOwner(v)
  39038. return nil
  39039. case wpchatroom.FieldAvatar:
  39040. v, ok := value.(string)
  39041. if !ok {
  39042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39043. }
  39044. m.SetAvatar(v)
  39045. return nil
  39046. case wpchatroom.FieldMemberList:
  39047. v, ok := value.([]string)
  39048. if !ok {
  39049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39050. }
  39051. m.SetMemberList(v)
  39052. return nil
  39053. }
  39054. return fmt.Errorf("unknown WpChatroom field %s", name)
  39055. }
  39056. // AddedFields returns all numeric fields that were incremented/decremented during
  39057. // this mutation.
  39058. func (m *WpChatroomMutation) AddedFields() []string {
  39059. var fields []string
  39060. if m.addstatus != nil {
  39061. fields = append(fields, wpchatroom.FieldStatus)
  39062. }
  39063. return fields
  39064. }
  39065. // AddedField returns the numeric value that was incremented/decremented on a field
  39066. // with the given name. The second boolean return value indicates that this field
  39067. // was not set, or was not defined in the schema.
  39068. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  39069. switch name {
  39070. case wpchatroom.FieldStatus:
  39071. return m.AddedStatus()
  39072. }
  39073. return nil, false
  39074. }
  39075. // AddField adds the value to the field with the given name. It returns an error if
  39076. // the field is not defined in the schema, or if the type mismatched the field
  39077. // type.
  39078. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  39079. switch name {
  39080. case wpchatroom.FieldStatus:
  39081. v, ok := value.(int8)
  39082. if !ok {
  39083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39084. }
  39085. m.AddStatus(v)
  39086. return nil
  39087. }
  39088. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  39089. }
  39090. // ClearedFields returns all nullable fields that were cleared during this
  39091. // mutation.
  39092. func (m *WpChatroomMutation) ClearedFields() []string {
  39093. var fields []string
  39094. if m.FieldCleared(wpchatroom.FieldStatus) {
  39095. fields = append(fields, wpchatroom.FieldStatus)
  39096. }
  39097. return fields
  39098. }
  39099. // FieldCleared returns a boolean indicating if a field with the given name was
  39100. // cleared in this mutation.
  39101. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  39102. _, ok := m.clearedFields[name]
  39103. return ok
  39104. }
  39105. // ClearField clears the value of the field with the given name. It returns an
  39106. // error if the field is not defined in the schema.
  39107. func (m *WpChatroomMutation) ClearField(name string) error {
  39108. switch name {
  39109. case wpchatroom.FieldStatus:
  39110. m.ClearStatus()
  39111. return nil
  39112. }
  39113. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  39114. }
  39115. // ResetField resets all changes in the mutation for the field with the given name.
  39116. // It returns an error if the field is not defined in the schema.
  39117. func (m *WpChatroomMutation) ResetField(name string) error {
  39118. switch name {
  39119. case wpchatroom.FieldCreatedAt:
  39120. m.ResetCreatedAt()
  39121. return nil
  39122. case wpchatroom.FieldUpdatedAt:
  39123. m.ResetUpdatedAt()
  39124. return nil
  39125. case wpchatroom.FieldStatus:
  39126. m.ResetStatus()
  39127. return nil
  39128. case wpchatroom.FieldWxWxid:
  39129. m.ResetWxWxid()
  39130. return nil
  39131. case wpchatroom.FieldChatroomID:
  39132. m.ResetChatroomID()
  39133. return nil
  39134. case wpchatroom.FieldNickname:
  39135. m.ResetNickname()
  39136. return nil
  39137. case wpchatroom.FieldOwner:
  39138. m.ResetOwner()
  39139. return nil
  39140. case wpchatroom.FieldAvatar:
  39141. m.ResetAvatar()
  39142. return nil
  39143. case wpchatroom.FieldMemberList:
  39144. m.ResetMemberList()
  39145. return nil
  39146. }
  39147. return fmt.Errorf("unknown WpChatroom field %s", name)
  39148. }
  39149. // AddedEdges returns all edge names that were set/added in this mutation.
  39150. func (m *WpChatroomMutation) AddedEdges() []string {
  39151. edges := make([]string, 0, 0)
  39152. return edges
  39153. }
  39154. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39155. // name in this mutation.
  39156. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  39157. return nil
  39158. }
  39159. // RemovedEdges returns all edge names that were removed in this mutation.
  39160. func (m *WpChatroomMutation) RemovedEdges() []string {
  39161. edges := make([]string, 0, 0)
  39162. return edges
  39163. }
  39164. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39165. // the given name in this mutation.
  39166. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  39167. return nil
  39168. }
  39169. // ClearedEdges returns all edge names that were cleared in this mutation.
  39170. func (m *WpChatroomMutation) ClearedEdges() []string {
  39171. edges := make([]string, 0, 0)
  39172. return edges
  39173. }
  39174. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39175. // was cleared in this mutation.
  39176. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  39177. return false
  39178. }
  39179. // ClearEdge clears the value of the edge with the given name. It returns an error
  39180. // if that edge is not defined in the schema.
  39181. func (m *WpChatroomMutation) ClearEdge(name string) error {
  39182. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  39183. }
  39184. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39185. // It returns an error if the edge is not defined in the schema.
  39186. func (m *WpChatroomMutation) ResetEdge(name string) error {
  39187. return fmt.Errorf("unknown WpChatroom edge %s", name)
  39188. }
  39189. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  39190. type WpChatroomMemberMutation struct {
  39191. config
  39192. op Op
  39193. typ string
  39194. id *uint64
  39195. created_at *time.Time
  39196. updated_at *time.Time
  39197. status *uint8
  39198. addstatus *int8
  39199. wx_wxid *string
  39200. wxid *string
  39201. nickname *string
  39202. avatar *string
  39203. clearedFields map[string]struct{}
  39204. done bool
  39205. oldValue func(context.Context) (*WpChatroomMember, error)
  39206. predicates []predicate.WpChatroomMember
  39207. }
  39208. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  39209. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  39210. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  39211. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  39212. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  39213. m := &WpChatroomMemberMutation{
  39214. config: c,
  39215. op: op,
  39216. typ: TypeWpChatroomMember,
  39217. clearedFields: make(map[string]struct{}),
  39218. }
  39219. for _, opt := range opts {
  39220. opt(m)
  39221. }
  39222. return m
  39223. }
  39224. // withWpChatroomMemberID sets the ID field of the mutation.
  39225. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  39226. return func(m *WpChatroomMemberMutation) {
  39227. var (
  39228. err error
  39229. once sync.Once
  39230. value *WpChatroomMember
  39231. )
  39232. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  39233. once.Do(func() {
  39234. if m.done {
  39235. err = errors.New("querying old values post mutation is not allowed")
  39236. } else {
  39237. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  39238. }
  39239. })
  39240. return value, err
  39241. }
  39242. m.id = &id
  39243. }
  39244. }
  39245. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  39246. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  39247. return func(m *WpChatroomMemberMutation) {
  39248. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  39249. return node, nil
  39250. }
  39251. m.id = &node.ID
  39252. }
  39253. }
  39254. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39255. // executed in a transaction (ent.Tx), a transactional client is returned.
  39256. func (m WpChatroomMemberMutation) Client() *Client {
  39257. client := &Client{config: m.config}
  39258. client.init()
  39259. return client
  39260. }
  39261. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39262. // it returns an error otherwise.
  39263. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  39264. if _, ok := m.driver.(*txDriver); !ok {
  39265. return nil, errors.New("ent: mutation is not running in a transaction")
  39266. }
  39267. tx := &Tx{config: m.config}
  39268. tx.init()
  39269. return tx, nil
  39270. }
  39271. // SetID sets the value of the id field. Note that this
  39272. // operation is only accepted on creation of WpChatroomMember entities.
  39273. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  39274. m.id = &id
  39275. }
  39276. // ID returns the ID value in the mutation. Note that the ID is only available
  39277. // if it was provided to the builder or after it was returned from the database.
  39278. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  39279. if m.id == nil {
  39280. return
  39281. }
  39282. return *m.id, true
  39283. }
  39284. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39285. // That means, if the mutation is applied within a transaction with an isolation level such
  39286. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39287. // or updated by the mutation.
  39288. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  39289. switch {
  39290. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39291. id, exists := m.ID()
  39292. if exists {
  39293. return []uint64{id}, nil
  39294. }
  39295. fallthrough
  39296. case m.op.Is(OpUpdate | OpDelete):
  39297. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  39298. default:
  39299. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39300. }
  39301. }
  39302. // SetCreatedAt sets the "created_at" field.
  39303. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  39304. m.created_at = &t
  39305. }
  39306. // CreatedAt returns the value of the "created_at" field in the mutation.
  39307. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  39308. v := m.created_at
  39309. if v == nil {
  39310. return
  39311. }
  39312. return *v, true
  39313. }
  39314. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  39315. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39317. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39318. if !m.op.Is(OpUpdateOne) {
  39319. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39320. }
  39321. if m.id == nil || m.oldValue == nil {
  39322. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39323. }
  39324. oldValue, err := m.oldValue(ctx)
  39325. if err != nil {
  39326. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39327. }
  39328. return oldValue.CreatedAt, nil
  39329. }
  39330. // ResetCreatedAt resets all changes to the "created_at" field.
  39331. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  39332. m.created_at = nil
  39333. }
  39334. // SetUpdatedAt sets the "updated_at" field.
  39335. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  39336. m.updated_at = &t
  39337. }
  39338. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39339. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  39340. v := m.updated_at
  39341. if v == nil {
  39342. return
  39343. }
  39344. return *v, true
  39345. }
  39346. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  39347. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39349. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39350. if !m.op.Is(OpUpdateOne) {
  39351. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39352. }
  39353. if m.id == nil || m.oldValue == nil {
  39354. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39355. }
  39356. oldValue, err := m.oldValue(ctx)
  39357. if err != nil {
  39358. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39359. }
  39360. return oldValue.UpdatedAt, nil
  39361. }
  39362. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39363. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  39364. m.updated_at = nil
  39365. }
  39366. // SetStatus sets the "status" field.
  39367. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  39368. m.status = &u
  39369. m.addstatus = nil
  39370. }
  39371. // Status returns the value of the "status" field in the mutation.
  39372. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  39373. v := m.status
  39374. if v == nil {
  39375. return
  39376. }
  39377. return *v, true
  39378. }
  39379. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  39380. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39382. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39383. if !m.op.Is(OpUpdateOne) {
  39384. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39385. }
  39386. if m.id == nil || m.oldValue == nil {
  39387. return v, errors.New("OldStatus requires an ID field in the mutation")
  39388. }
  39389. oldValue, err := m.oldValue(ctx)
  39390. if err != nil {
  39391. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39392. }
  39393. return oldValue.Status, nil
  39394. }
  39395. // AddStatus adds u to the "status" field.
  39396. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  39397. if m.addstatus != nil {
  39398. *m.addstatus += u
  39399. } else {
  39400. m.addstatus = &u
  39401. }
  39402. }
  39403. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39404. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  39405. v := m.addstatus
  39406. if v == nil {
  39407. return
  39408. }
  39409. return *v, true
  39410. }
  39411. // ClearStatus clears the value of the "status" field.
  39412. func (m *WpChatroomMemberMutation) ClearStatus() {
  39413. m.status = nil
  39414. m.addstatus = nil
  39415. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  39416. }
  39417. // StatusCleared returns if the "status" field was cleared in this mutation.
  39418. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  39419. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  39420. return ok
  39421. }
  39422. // ResetStatus resets all changes to the "status" field.
  39423. func (m *WpChatroomMemberMutation) ResetStatus() {
  39424. m.status = nil
  39425. m.addstatus = nil
  39426. delete(m.clearedFields, wpchatroommember.FieldStatus)
  39427. }
  39428. // SetWxWxid sets the "wx_wxid" field.
  39429. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  39430. m.wx_wxid = &s
  39431. }
  39432. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  39433. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  39434. v := m.wx_wxid
  39435. if v == nil {
  39436. return
  39437. }
  39438. return *v, true
  39439. }
  39440. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  39441. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39443. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  39444. if !m.op.Is(OpUpdateOne) {
  39445. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  39446. }
  39447. if m.id == nil || m.oldValue == nil {
  39448. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  39449. }
  39450. oldValue, err := m.oldValue(ctx)
  39451. if err != nil {
  39452. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  39453. }
  39454. return oldValue.WxWxid, nil
  39455. }
  39456. // ResetWxWxid resets all changes to the "wx_wxid" field.
  39457. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  39458. m.wx_wxid = nil
  39459. }
  39460. // SetWxid sets the "wxid" field.
  39461. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  39462. m.wxid = &s
  39463. }
  39464. // Wxid returns the value of the "wxid" field in the mutation.
  39465. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  39466. v := m.wxid
  39467. if v == nil {
  39468. return
  39469. }
  39470. return *v, true
  39471. }
  39472. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  39473. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39475. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  39476. if !m.op.Is(OpUpdateOne) {
  39477. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  39478. }
  39479. if m.id == nil || m.oldValue == nil {
  39480. return v, errors.New("OldWxid requires an ID field in the mutation")
  39481. }
  39482. oldValue, err := m.oldValue(ctx)
  39483. if err != nil {
  39484. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  39485. }
  39486. return oldValue.Wxid, nil
  39487. }
  39488. // ResetWxid resets all changes to the "wxid" field.
  39489. func (m *WpChatroomMemberMutation) ResetWxid() {
  39490. m.wxid = nil
  39491. }
  39492. // SetNickname sets the "nickname" field.
  39493. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  39494. m.nickname = &s
  39495. }
  39496. // Nickname returns the value of the "nickname" field in the mutation.
  39497. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  39498. v := m.nickname
  39499. if v == nil {
  39500. return
  39501. }
  39502. return *v, true
  39503. }
  39504. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  39505. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39507. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  39508. if !m.op.Is(OpUpdateOne) {
  39509. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39510. }
  39511. if m.id == nil || m.oldValue == nil {
  39512. return v, errors.New("OldNickname requires an ID field in the mutation")
  39513. }
  39514. oldValue, err := m.oldValue(ctx)
  39515. if err != nil {
  39516. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39517. }
  39518. return oldValue.Nickname, nil
  39519. }
  39520. // ResetNickname resets all changes to the "nickname" field.
  39521. func (m *WpChatroomMemberMutation) ResetNickname() {
  39522. m.nickname = nil
  39523. }
  39524. // SetAvatar sets the "avatar" field.
  39525. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  39526. m.avatar = &s
  39527. }
  39528. // Avatar returns the value of the "avatar" field in the mutation.
  39529. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  39530. v := m.avatar
  39531. if v == nil {
  39532. return
  39533. }
  39534. return *v, true
  39535. }
  39536. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  39537. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  39538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39539. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39540. if !m.op.Is(OpUpdateOne) {
  39541. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39542. }
  39543. if m.id == nil || m.oldValue == nil {
  39544. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39545. }
  39546. oldValue, err := m.oldValue(ctx)
  39547. if err != nil {
  39548. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39549. }
  39550. return oldValue.Avatar, nil
  39551. }
  39552. // ResetAvatar resets all changes to the "avatar" field.
  39553. func (m *WpChatroomMemberMutation) ResetAvatar() {
  39554. m.avatar = nil
  39555. }
  39556. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  39557. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  39558. m.predicates = append(m.predicates, ps...)
  39559. }
  39560. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  39561. // users can use type-assertion to append predicates that do not depend on any generated package.
  39562. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  39563. p := make([]predicate.WpChatroomMember, len(ps))
  39564. for i := range ps {
  39565. p[i] = ps[i]
  39566. }
  39567. m.Where(p...)
  39568. }
  39569. // Op returns the operation name.
  39570. func (m *WpChatroomMemberMutation) Op() Op {
  39571. return m.op
  39572. }
  39573. // SetOp allows setting the mutation operation.
  39574. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  39575. m.op = op
  39576. }
  39577. // Type returns the node type of this mutation (WpChatroomMember).
  39578. func (m *WpChatroomMemberMutation) Type() string {
  39579. return m.typ
  39580. }
  39581. // Fields returns all fields that were changed during this mutation. Note that in
  39582. // order to get all numeric fields that were incremented/decremented, call
  39583. // AddedFields().
  39584. func (m *WpChatroomMemberMutation) Fields() []string {
  39585. fields := make([]string, 0, 7)
  39586. if m.created_at != nil {
  39587. fields = append(fields, wpchatroommember.FieldCreatedAt)
  39588. }
  39589. if m.updated_at != nil {
  39590. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  39591. }
  39592. if m.status != nil {
  39593. fields = append(fields, wpchatroommember.FieldStatus)
  39594. }
  39595. if m.wx_wxid != nil {
  39596. fields = append(fields, wpchatroommember.FieldWxWxid)
  39597. }
  39598. if m.wxid != nil {
  39599. fields = append(fields, wpchatroommember.FieldWxid)
  39600. }
  39601. if m.nickname != nil {
  39602. fields = append(fields, wpchatroommember.FieldNickname)
  39603. }
  39604. if m.avatar != nil {
  39605. fields = append(fields, wpchatroommember.FieldAvatar)
  39606. }
  39607. return fields
  39608. }
  39609. // Field returns the value of a field with the given name. The second boolean
  39610. // return value indicates that this field was not set, or was not defined in the
  39611. // schema.
  39612. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  39613. switch name {
  39614. case wpchatroommember.FieldCreatedAt:
  39615. return m.CreatedAt()
  39616. case wpchatroommember.FieldUpdatedAt:
  39617. return m.UpdatedAt()
  39618. case wpchatroommember.FieldStatus:
  39619. return m.Status()
  39620. case wpchatroommember.FieldWxWxid:
  39621. return m.WxWxid()
  39622. case wpchatroommember.FieldWxid:
  39623. return m.Wxid()
  39624. case wpchatroommember.FieldNickname:
  39625. return m.Nickname()
  39626. case wpchatroommember.FieldAvatar:
  39627. return m.Avatar()
  39628. }
  39629. return nil, false
  39630. }
  39631. // OldField returns the old value of the field from the database. An error is
  39632. // returned if the mutation operation is not UpdateOne, or the query to the
  39633. // database failed.
  39634. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39635. switch name {
  39636. case wpchatroommember.FieldCreatedAt:
  39637. return m.OldCreatedAt(ctx)
  39638. case wpchatroommember.FieldUpdatedAt:
  39639. return m.OldUpdatedAt(ctx)
  39640. case wpchatroommember.FieldStatus:
  39641. return m.OldStatus(ctx)
  39642. case wpchatroommember.FieldWxWxid:
  39643. return m.OldWxWxid(ctx)
  39644. case wpchatroommember.FieldWxid:
  39645. return m.OldWxid(ctx)
  39646. case wpchatroommember.FieldNickname:
  39647. return m.OldNickname(ctx)
  39648. case wpchatroommember.FieldAvatar:
  39649. return m.OldAvatar(ctx)
  39650. }
  39651. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  39652. }
  39653. // SetField sets the value of a field with the given name. It returns an error if
  39654. // the field is not defined in the schema, or if the type mismatched the field
  39655. // type.
  39656. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  39657. switch name {
  39658. case wpchatroommember.FieldCreatedAt:
  39659. v, ok := value.(time.Time)
  39660. if !ok {
  39661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39662. }
  39663. m.SetCreatedAt(v)
  39664. return nil
  39665. case wpchatroommember.FieldUpdatedAt:
  39666. v, ok := value.(time.Time)
  39667. if !ok {
  39668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39669. }
  39670. m.SetUpdatedAt(v)
  39671. return nil
  39672. case wpchatroommember.FieldStatus:
  39673. v, ok := value.(uint8)
  39674. if !ok {
  39675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39676. }
  39677. m.SetStatus(v)
  39678. return nil
  39679. case wpchatroommember.FieldWxWxid:
  39680. v, ok := value.(string)
  39681. if !ok {
  39682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39683. }
  39684. m.SetWxWxid(v)
  39685. return nil
  39686. case wpchatroommember.FieldWxid:
  39687. v, ok := value.(string)
  39688. if !ok {
  39689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39690. }
  39691. m.SetWxid(v)
  39692. return nil
  39693. case wpchatroommember.FieldNickname:
  39694. v, ok := value.(string)
  39695. if !ok {
  39696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39697. }
  39698. m.SetNickname(v)
  39699. return nil
  39700. case wpchatroommember.FieldAvatar:
  39701. v, ok := value.(string)
  39702. if !ok {
  39703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39704. }
  39705. m.SetAvatar(v)
  39706. return nil
  39707. }
  39708. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  39709. }
  39710. // AddedFields returns all numeric fields that were incremented/decremented during
  39711. // this mutation.
  39712. func (m *WpChatroomMemberMutation) AddedFields() []string {
  39713. var fields []string
  39714. if m.addstatus != nil {
  39715. fields = append(fields, wpchatroommember.FieldStatus)
  39716. }
  39717. return fields
  39718. }
  39719. // AddedField returns the numeric value that was incremented/decremented on a field
  39720. // with the given name. The second boolean return value indicates that this field
  39721. // was not set, or was not defined in the schema.
  39722. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  39723. switch name {
  39724. case wpchatroommember.FieldStatus:
  39725. return m.AddedStatus()
  39726. }
  39727. return nil, false
  39728. }
  39729. // AddField adds the value to the field with the given name. It returns an error if
  39730. // the field is not defined in the schema, or if the type mismatched the field
  39731. // type.
  39732. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  39733. switch name {
  39734. case wpchatroommember.FieldStatus:
  39735. v, ok := value.(int8)
  39736. if !ok {
  39737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39738. }
  39739. m.AddStatus(v)
  39740. return nil
  39741. }
  39742. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  39743. }
  39744. // ClearedFields returns all nullable fields that were cleared during this
  39745. // mutation.
  39746. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  39747. var fields []string
  39748. if m.FieldCleared(wpchatroommember.FieldStatus) {
  39749. fields = append(fields, wpchatroommember.FieldStatus)
  39750. }
  39751. return fields
  39752. }
  39753. // FieldCleared returns a boolean indicating if a field with the given name was
  39754. // cleared in this mutation.
  39755. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  39756. _, ok := m.clearedFields[name]
  39757. return ok
  39758. }
  39759. // ClearField clears the value of the field with the given name. It returns an
  39760. // error if the field is not defined in the schema.
  39761. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  39762. switch name {
  39763. case wpchatroommember.FieldStatus:
  39764. m.ClearStatus()
  39765. return nil
  39766. }
  39767. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  39768. }
  39769. // ResetField resets all changes in the mutation for the field with the given name.
  39770. // It returns an error if the field is not defined in the schema.
  39771. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  39772. switch name {
  39773. case wpchatroommember.FieldCreatedAt:
  39774. m.ResetCreatedAt()
  39775. return nil
  39776. case wpchatroommember.FieldUpdatedAt:
  39777. m.ResetUpdatedAt()
  39778. return nil
  39779. case wpchatroommember.FieldStatus:
  39780. m.ResetStatus()
  39781. return nil
  39782. case wpchatroommember.FieldWxWxid:
  39783. m.ResetWxWxid()
  39784. return nil
  39785. case wpchatroommember.FieldWxid:
  39786. m.ResetWxid()
  39787. return nil
  39788. case wpchatroommember.FieldNickname:
  39789. m.ResetNickname()
  39790. return nil
  39791. case wpchatroommember.FieldAvatar:
  39792. m.ResetAvatar()
  39793. return nil
  39794. }
  39795. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  39796. }
  39797. // AddedEdges returns all edge names that were set/added in this mutation.
  39798. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  39799. edges := make([]string, 0, 0)
  39800. return edges
  39801. }
  39802. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39803. // name in this mutation.
  39804. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  39805. return nil
  39806. }
  39807. // RemovedEdges returns all edge names that were removed in this mutation.
  39808. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  39809. edges := make([]string, 0, 0)
  39810. return edges
  39811. }
  39812. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39813. // the given name in this mutation.
  39814. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  39815. return nil
  39816. }
  39817. // ClearedEdges returns all edge names that were cleared in this mutation.
  39818. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  39819. edges := make([]string, 0, 0)
  39820. return edges
  39821. }
  39822. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39823. // was cleared in this mutation.
  39824. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  39825. return false
  39826. }
  39827. // ClearEdge clears the value of the edge with the given name. It returns an error
  39828. // if that edge is not defined in the schema.
  39829. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  39830. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  39831. }
  39832. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39833. // It returns an error if the edge is not defined in the schema.
  39834. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  39835. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  39836. }
  39837. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  39838. type WxMutation struct {
  39839. config
  39840. op Op
  39841. typ string
  39842. id *uint64
  39843. created_at *time.Time
  39844. updated_at *time.Time
  39845. status *uint8
  39846. addstatus *int8
  39847. deleted_at *time.Time
  39848. port *string
  39849. process_id *string
  39850. callback *string
  39851. wxid *string
  39852. account *string
  39853. nickname *string
  39854. tel *string
  39855. head_big *string
  39856. organization_id *uint64
  39857. addorganization_id *int64
  39858. api_base *string
  39859. api_key *string
  39860. allow_list *[]string
  39861. appendallow_list []string
  39862. group_allow_list *[]string
  39863. appendgroup_allow_list []string
  39864. block_list *[]string
  39865. appendblock_list []string
  39866. group_block_list *[]string
  39867. appendgroup_block_list []string
  39868. ctype *uint64
  39869. addctype *int64
  39870. clearedFields map[string]struct{}
  39871. server *uint64
  39872. clearedserver bool
  39873. agent *uint64
  39874. clearedagent bool
  39875. done bool
  39876. oldValue func(context.Context) (*Wx, error)
  39877. predicates []predicate.Wx
  39878. }
  39879. var _ ent.Mutation = (*WxMutation)(nil)
  39880. // wxOption allows management of the mutation configuration using functional options.
  39881. type wxOption func(*WxMutation)
  39882. // newWxMutation creates new mutation for the Wx entity.
  39883. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  39884. m := &WxMutation{
  39885. config: c,
  39886. op: op,
  39887. typ: TypeWx,
  39888. clearedFields: make(map[string]struct{}),
  39889. }
  39890. for _, opt := range opts {
  39891. opt(m)
  39892. }
  39893. return m
  39894. }
  39895. // withWxID sets the ID field of the mutation.
  39896. func withWxID(id uint64) wxOption {
  39897. return func(m *WxMutation) {
  39898. var (
  39899. err error
  39900. once sync.Once
  39901. value *Wx
  39902. )
  39903. m.oldValue = func(ctx context.Context) (*Wx, error) {
  39904. once.Do(func() {
  39905. if m.done {
  39906. err = errors.New("querying old values post mutation is not allowed")
  39907. } else {
  39908. value, err = m.Client().Wx.Get(ctx, id)
  39909. }
  39910. })
  39911. return value, err
  39912. }
  39913. m.id = &id
  39914. }
  39915. }
  39916. // withWx sets the old Wx of the mutation.
  39917. func withWx(node *Wx) wxOption {
  39918. return func(m *WxMutation) {
  39919. m.oldValue = func(context.Context) (*Wx, error) {
  39920. return node, nil
  39921. }
  39922. m.id = &node.ID
  39923. }
  39924. }
  39925. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39926. // executed in a transaction (ent.Tx), a transactional client is returned.
  39927. func (m WxMutation) Client() *Client {
  39928. client := &Client{config: m.config}
  39929. client.init()
  39930. return client
  39931. }
  39932. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39933. // it returns an error otherwise.
  39934. func (m WxMutation) Tx() (*Tx, error) {
  39935. if _, ok := m.driver.(*txDriver); !ok {
  39936. return nil, errors.New("ent: mutation is not running in a transaction")
  39937. }
  39938. tx := &Tx{config: m.config}
  39939. tx.init()
  39940. return tx, nil
  39941. }
  39942. // SetID sets the value of the id field. Note that this
  39943. // operation is only accepted on creation of Wx entities.
  39944. func (m *WxMutation) SetID(id uint64) {
  39945. m.id = &id
  39946. }
  39947. // ID returns the ID value in the mutation. Note that the ID is only available
  39948. // if it was provided to the builder or after it was returned from the database.
  39949. func (m *WxMutation) ID() (id uint64, exists bool) {
  39950. if m.id == nil {
  39951. return
  39952. }
  39953. return *m.id, true
  39954. }
  39955. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39956. // That means, if the mutation is applied within a transaction with an isolation level such
  39957. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39958. // or updated by the mutation.
  39959. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  39960. switch {
  39961. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39962. id, exists := m.ID()
  39963. if exists {
  39964. return []uint64{id}, nil
  39965. }
  39966. fallthrough
  39967. case m.op.Is(OpUpdate | OpDelete):
  39968. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  39969. default:
  39970. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39971. }
  39972. }
  39973. // SetCreatedAt sets the "created_at" field.
  39974. func (m *WxMutation) SetCreatedAt(t time.Time) {
  39975. m.created_at = &t
  39976. }
  39977. // CreatedAt returns the value of the "created_at" field in the mutation.
  39978. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  39979. v := m.created_at
  39980. if v == nil {
  39981. return
  39982. }
  39983. return *v, true
  39984. }
  39985. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  39986. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39988. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39989. if !m.op.Is(OpUpdateOne) {
  39990. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39991. }
  39992. if m.id == nil || m.oldValue == nil {
  39993. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39994. }
  39995. oldValue, err := m.oldValue(ctx)
  39996. if err != nil {
  39997. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39998. }
  39999. return oldValue.CreatedAt, nil
  40000. }
  40001. // ResetCreatedAt resets all changes to the "created_at" field.
  40002. func (m *WxMutation) ResetCreatedAt() {
  40003. m.created_at = nil
  40004. }
  40005. // SetUpdatedAt sets the "updated_at" field.
  40006. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  40007. m.updated_at = &t
  40008. }
  40009. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40010. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  40011. v := m.updated_at
  40012. if v == nil {
  40013. return
  40014. }
  40015. return *v, true
  40016. }
  40017. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  40018. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40020. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40021. if !m.op.Is(OpUpdateOne) {
  40022. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40023. }
  40024. if m.id == nil || m.oldValue == nil {
  40025. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40026. }
  40027. oldValue, err := m.oldValue(ctx)
  40028. if err != nil {
  40029. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40030. }
  40031. return oldValue.UpdatedAt, nil
  40032. }
  40033. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40034. func (m *WxMutation) ResetUpdatedAt() {
  40035. m.updated_at = nil
  40036. }
  40037. // SetStatus sets the "status" field.
  40038. func (m *WxMutation) SetStatus(u uint8) {
  40039. m.status = &u
  40040. m.addstatus = nil
  40041. }
  40042. // Status returns the value of the "status" field in the mutation.
  40043. func (m *WxMutation) Status() (r uint8, exists bool) {
  40044. v := m.status
  40045. if v == nil {
  40046. return
  40047. }
  40048. return *v, true
  40049. }
  40050. // OldStatus returns the old "status" field's value of the Wx entity.
  40051. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40053. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40054. if !m.op.Is(OpUpdateOne) {
  40055. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40056. }
  40057. if m.id == nil || m.oldValue == nil {
  40058. return v, errors.New("OldStatus requires an ID field in the mutation")
  40059. }
  40060. oldValue, err := m.oldValue(ctx)
  40061. if err != nil {
  40062. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40063. }
  40064. return oldValue.Status, nil
  40065. }
  40066. // AddStatus adds u to the "status" field.
  40067. func (m *WxMutation) AddStatus(u int8) {
  40068. if m.addstatus != nil {
  40069. *m.addstatus += u
  40070. } else {
  40071. m.addstatus = &u
  40072. }
  40073. }
  40074. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40075. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  40076. v := m.addstatus
  40077. if v == nil {
  40078. return
  40079. }
  40080. return *v, true
  40081. }
  40082. // ClearStatus clears the value of the "status" field.
  40083. func (m *WxMutation) ClearStatus() {
  40084. m.status = nil
  40085. m.addstatus = nil
  40086. m.clearedFields[wx.FieldStatus] = struct{}{}
  40087. }
  40088. // StatusCleared returns if the "status" field was cleared in this mutation.
  40089. func (m *WxMutation) StatusCleared() bool {
  40090. _, ok := m.clearedFields[wx.FieldStatus]
  40091. return ok
  40092. }
  40093. // ResetStatus resets all changes to the "status" field.
  40094. func (m *WxMutation) ResetStatus() {
  40095. m.status = nil
  40096. m.addstatus = nil
  40097. delete(m.clearedFields, wx.FieldStatus)
  40098. }
  40099. // SetDeletedAt sets the "deleted_at" field.
  40100. func (m *WxMutation) SetDeletedAt(t time.Time) {
  40101. m.deleted_at = &t
  40102. }
  40103. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40104. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  40105. v := m.deleted_at
  40106. if v == nil {
  40107. return
  40108. }
  40109. return *v, true
  40110. }
  40111. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  40112. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40114. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40115. if !m.op.Is(OpUpdateOne) {
  40116. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40117. }
  40118. if m.id == nil || m.oldValue == nil {
  40119. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40120. }
  40121. oldValue, err := m.oldValue(ctx)
  40122. if err != nil {
  40123. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40124. }
  40125. return oldValue.DeletedAt, nil
  40126. }
  40127. // ClearDeletedAt clears the value of the "deleted_at" field.
  40128. func (m *WxMutation) ClearDeletedAt() {
  40129. m.deleted_at = nil
  40130. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  40131. }
  40132. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40133. func (m *WxMutation) DeletedAtCleared() bool {
  40134. _, ok := m.clearedFields[wx.FieldDeletedAt]
  40135. return ok
  40136. }
  40137. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40138. func (m *WxMutation) ResetDeletedAt() {
  40139. m.deleted_at = nil
  40140. delete(m.clearedFields, wx.FieldDeletedAt)
  40141. }
  40142. // SetServerID sets the "server_id" field.
  40143. func (m *WxMutation) SetServerID(u uint64) {
  40144. m.server = &u
  40145. }
  40146. // ServerID returns the value of the "server_id" field in the mutation.
  40147. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  40148. v := m.server
  40149. if v == nil {
  40150. return
  40151. }
  40152. return *v, true
  40153. }
  40154. // OldServerID returns the old "server_id" field's value of the Wx entity.
  40155. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40157. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  40158. if !m.op.Is(OpUpdateOne) {
  40159. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  40160. }
  40161. if m.id == nil || m.oldValue == nil {
  40162. return v, errors.New("OldServerID requires an ID field in the mutation")
  40163. }
  40164. oldValue, err := m.oldValue(ctx)
  40165. if err != nil {
  40166. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  40167. }
  40168. return oldValue.ServerID, nil
  40169. }
  40170. // ClearServerID clears the value of the "server_id" field.
  40171. func (m *WxMutation) ClearServerID() {
  40172. m.server = nil
  40173. m.clearedFields[wx.FieldServerID] = struct{}{}
  40174. }
  40175. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  40176. func (m *WxMutation) ServerIDCleared() bool {
  40177. _, ok := m.clearedFields[wx.FieldServerID]
  40178. return ok
  40179. }
  40180. // ResetServerID resets all changes to the "server_id" field.
  40181. func (m *WxMutation) ResetServerID() {
  40182. m.server = nil
  40183. delete(m.clearedFields, wx.FieldServerID)
  40184. }
  40185. // SetPort sets the "port" field.
  40186. func (m *WxMutation) SetPort(s string) {
  40187. m.port = &s
  40188. }
  40189. // Port returns the value of the "port" field in the mutation.
  40190. func (m *WxMutation) Port() (r string, exists bool) {
  40191. v := m.port
  40192. if v == nil {
  40193. return
  40194. }
  40195. return *v, true
  40196. }
  40197. // OldPort returns the old "port" field's value of the Wx entity.
  40198. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40200. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  40201. if !m.op.Is(OpUpdateOne) {
  40202. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  40203. }
  40204. if m.id == nil || m.oldValue == nil {
  40205. return v, errors.New("OldPort requires an ID field in the mutation")
  40206. }
  40207. oldValue, err := m.oldValue(ctx)
  40208. if err != nil {
  40209. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  40210. }
  40211. return oldValue.Port, nil
  40212. }
  40213. // ResetPort resets all changes to the "port" field.
  40214. func (m *WxMutation) ResetPort() {
  40215. m.port = nil
  40216. }
  40217. // SetProcessID sets the "process_id" field.
  40218. func (m *WxMutation) SetProcessID(s string) {
  40219. m.process_id = &s
  40220. }
  40221. // ProcessID returns the value of the "process_id" field in the mutation.
  40222. func (m *WxMutation) ProcessID() (r string, exists bool) {
  40223. v := m.process_id
  40224. if v == nil {
  40225. return
  40226. }
  40227. return *v, true
  40228. }
  40229. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  40230. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40232. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  40233. if !m.op.Is(OpUpdateOne) {
  40234. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  40235. }
  40236. if m.id == nil || m.oldValue == nil {
  40237. return v, errors.New("OldProcessID requires an ID field in the mutation")
  40238. }
  40239. oldValue, err := m.oldValue(ctx)
  40240. if err != nil {
  40241. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  40242. }
  40243. return oldValue.ProcessID, nil
  40244. }
  40245. // ResetProcessID resets all changes to the "process_id" field.
  40246. func (m *WxMutation) ResetProcessID() {
  40247. m.process_id = nil
  40248. }
  40249. // SetCallback sets the "callback" field.
  40250. func (m *WxMutation) SetCallback(s string) {
  40251. m.callback = &s
  40252. }
  40253. // Callback returns the value of the "callback" field in the mutation.
  40254. func (m *WxMutation) Callback() (r string, exists bool) {
  40255. v := m.callback
  40256. if v == nil {
  40257. return
  40258. }
  40259. return *v, true
  40260. }
  40261. // OldCallback returns the old "callback" field's value of the Wx entity.
  40262. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40264. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  40265. if !m.op.Is(OpUpdateOne) {
  40266. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  40267. }
  40268. if m.id == nil || m.oldValue == nil {
  40269. return v, errors.New("OldCallback requires an ID field in the mutation")
  40270. }
  40271. oldValue, err := m.oldValue(ctx)
  40272. if err != nil {
  40273. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  40274. }
  40275. return oldValue.Callback, nil
  40276. }
  40277. // ResetCallback resets all changes to the "callback" field.
  40278. func (m *WxMutation) ResetCallback() {
  40279. m.callback = nil
  40280. }
  40281. // SetWxid sets the "wxid" field.
  40282. func (m *WxMutation) SetWxid(s string) {
  40283. m.wxid = &s
  40284. }
  40285. // Wxid returns the value of the "wxid" field in the mutation.
  40286. func (m *WxMutation) Wxid() (r string, exists bool) {
  40287. v := m.wxid
  40288. if v == nil {
  40289. return
  40290. }
  40291. return *v, true
  40292. }
  40293. // OldWxid returns the old "wxid" field's value of the Wx entity.
  40294. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40296. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  40297. if !m.op.Is(OpUpdateOne) {
  40298. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40299. }
  40300. if m.id == nil || m.oldValue == nil {
  40301. return v, errors.New("OldWxid requires an ID field in the mutation")
  40302. }
  40303. oldValue, err := m.oldValue(ctx)
  40304. if err != nil {
  40305. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40306. }
  40307. return oldValue.Wxid, nil
  40308. }
  40309. // ResetWxid resets all changes to the "wxid" field.
  40310. func (m *WxMutation) ResetWxid() {
  40311. m.wxid = nil
  40312. }
  40313. // SetAccount sets the "account" field.
  40314. func (m *WxMutation) SetAccount(s string) {
  40315. m.account = &s
  40316. }
  40317. // Account returns the value of the "account" field in the mutation.
  40318. func (m *WxMutation) Account() (r string, exists bool) {
  40319. v := m.account
  40320. if v == nil {
  40321. return
  40322. }
  40323. return *v, true
  40324. }
  40325. // OldAccount returns the old "account" 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) OldAccount(ctx context.Context) (v string, err error) {
  40329. if !m.op.Is(OpUpdateOne) {
  40330. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  40331. }
  40332. if m.id == nil || m.oldValue == nil {
  40333. return v, errors.New("OldAccount 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 OldAccount: %w", err)
  40338. }
  40339. return oldValue.Account, nil
  40340. }
  40341. // ResetAccount resets all changes to the "account" field.
  40342. func (m *WxMutation) ResetAccount() {
  40343. m.account = nil
  40344. }
  40345. // SetNickname sets the "nickname" field.
  40346. func (m *WxMutation) SetNickname(s string) {
  40347. m.nickname = &s
  40348. }
  40349. // Nickname returns the value of the "nickname" field in the mutation.
  40350. func (m *WxMutation) Nickname() (r string, exists bool) {
  40351. v := m.nickname
  40352. if v == nil {
  40353. return
  40354. }
  40355. return *v, true
  40356. }
  40357. // OldNickname returns the old "nickname" field's value of the Wx entity.
  40358. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40360. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  40361. if !m.op.Is(OpUpdateOne) {
  40362. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40363. }
  40364. if m.id == nil || m.oldValue == nil {
  40365. return v, errors.New("OldNickname requires an ID field in the mutation")
  40366. }
  40367. oldValue, err := m.oldValue(ctx)
  40368. if err != nil {
  40369. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40370. }
  40371. return oldValue.Nickname, nil
  40372. }
  40373. // ResetNickname resets all changes to the "nickname" field.
  40374. func (m *WxMutation) ResetNickname() {
  40375. m.nickname = nil
  40376. }
  40377. // SetTel sets the "tel" field.
  40378. func (m *WxMutation) SetTel(s string) {
  40379. m.tel = &s
  40380. }
  40381. // Tel returns the value of the "tel" field in the mutation.
  40382. func (m *WxMutation) Tel() (r string, exists bool) {
  40383. v := m.tel
  40384. if v == nil {
  40385. return
  40386. }
  40387. return *v, true
  40388. }
  40389. // OldTel returns the old "tel" field's value of the Wx entity.
  40390. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40392. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  40393. if !m.op.Is(OpUpdateOne) {
  40394. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  40395. }
  40396. if m.id == nil || m.oldValue == nil {
  40397. return v, errors.New("OldTel requires an ID field in the mutation")
  40398. }
  40399. oldValue, err := m.oldValue(ctx)
  40400. if err != nil {
  40401. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  40402. }
  40403. return oldValue.Tel, nil
  40404. }
  40405. // ResetTel resets all changes to the "tel" field.
  40406. func (m *WxMutation) ResetTel() {
  40407. m.tel = nil
  40408. }
  40409. // SetHeadBig sets the "head_big" field.
  40410. func (m *WxMutation) SetHeadBig(s string) {
  40411. m.head_big = &s
  40412. }
  40413. // HeadBig returns the value of the "head_big" field in the mutation.
  40414. func (m *WxMutation) HeadBig() (r string, exists bool) {
  40415. v := m.head_big
  40416. if v == nil {
  40417. return
  40418. }
  40419. return *v, true
  40420. }
  40421. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  40422. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40424. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  40425. if !m.op.Is(OpUpdateOne) {
  40426. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  40427. }
  40428. if m.id == nil || m.oldValue == nil {
  40429. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  40430. }
  40431. oldValue, err := m.oldValue(ctx)
  40432. if err != nil {
  40433. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  40434. }
  40435. return oldValue.HeadBig, nil
  40436. }
  40437. // ResetHeadBig resets all changes to the "head_big" field.
  40438. func (m *WxMutation) ResetHeadBig() {
  40439. m.head_big = nil
  40440. }
  40441. // SetOrganizationID sets the "organization_id" field.
  40442. func (m *WxMutation) SetOrganizationID(u uint64) {
  40443. m.organization_id = &u
  40444. m.addorganization_id = nil
  40445. }
  40446. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40447. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  40448. v := m.organization_id
  40449. if v == nil {
  40450. return
  40451. }
  40452. return *v, true
  40453. }
  40454. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  40455. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40457. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40458. if !m.op.Is(OpUpdateOne) {
  40459. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40460. }
  40461. if m.id == nil || m.oldValue == nil {
  40462. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40463. }
  40464. oldValue, err := m.oldValue(ctx)
  40465. if err != nil {
  40466. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40467. }
  40468. return oldValue.OrganizationID, nil
  40469. }
  40470. // AddOrganizationID adds u to the "organization_id" field.
  40471. func (m *WxMutation) AddOrganizationID(u int64) {
  40472. if m.addorganization_id != nil {
  40473. *m.addorganization_id += u
  40474. } else {
  40475. m.addorganization_id = &u
  40476. }
  40477. }
  40478. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40479. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  40480. v := m.addorganization_id
  40481. if v == nil {
  40482. return
  40483. }
  40484. return *v, true
  40485. }
  40486. // ClearOrganizationID clears the value of the "organization_id" field.
  40487. func (m *WxMutation) ClearOrganizationID() {
  40488. m.organization_id = nil
  40489. m.addorganization_id = nil
  40490. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  40491. }
  40492. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40493. func (m *WxMutation) OrganizationIDCleared() bool {
  40494. _, ok := m.clearedFields[wx.FieldOrganizationID]
  40495. return ok
  40496. }
  40497. // ResetOrganizationID resets all changes to the "organization_id" field.
  40498. func (m *WxMutation) ResetOrganizationID() {
  40499. m.organization_id = nil
  40500. m.addorganization_id = nil
  40501. delete(m.clearedFields, wx.FieldOrganizationID)
  40502. }
  40503. // SetAgentID sets the "agent_id" field.
  40504. func (m *WxMutation) SetAgentID(u uint64) {
  40505. m.agent = &u
  40506. }
  40507. // AgentID returns the value of the "agent_id" field in the mutation.
  40508. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  40509. v := m.agent
  40510. if v == nil {
  40511. return
  40512. }
  40513. return *v, true
  40514. }
  40515. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  40516. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40518. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  40519. if !m.op.Is(OpUpdateOne) {
  40520. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  40521. }
  40522. if m.id == nil || m.oldValue == nil {
  40523. return v, errors.New("OldAgentID requires an ID field in the mutation")
  40524. }
  40525. oldValue, err := m.oldValue(ctx)
  40526. if err != nil {
  40527. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  40528. }
  40529. return oldValue.AgentID, nil
  40530. }
  40531. // ResetAgentID resets all changes to the "agent_id" field.
  40532. func (m *WxMutation) ResetAgentID() {
  40533. m.agent = nil
  40534. }
  40535. // SetAPIBase sets the "api_base" field.
  40536. func (m *WxMutation) SetAPIBase(s string) {
  40537. m.api_base = &s
  40538. }
  40539. // APIBase returns the value of the "api_base" field in the mutation.
  40540. func (m *WxMutation) APIBase() (r string, exists bool) {
  40541. v := m.api_base
  40542. if v == nil {
  40543. return
  40544. }
  40545. return *v, true
  40546. }
  40547. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  40548. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40550. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  40551. if !m.op.Is(OpUpdateOne) {
  40552. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  40553. }
  40554. if m.id == nil || m.oldValue == nil {
  40555. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  40556. }
  40557. oldValue, err := m.oldValue(ctx)
  40558. if err != nil {
  40559. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  40560. }
  40561. return oldValue.APIBase, nil
  40562. }
  40563. // ClearAPIBase clears the value of the "api_base" field.
  40564. func (m *WxMutation) ClearAPIBase() {
  40565. m.api_base = nil
  40566. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  40567. }
  40568. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  40569. func (m *WxMutation) APIBaseCleared() bool {
  40570. _, ok := m.clearedFields[wx.FieldAPIBase]
  40571. return ok
  40572. }
  40573. // ResetAPIBase resets all changes to the "api_base" field.
  40574. func (m *WxMutation) ResetAPIBase() {
  40575. m.api_base = nil
  40576. delete(m.clearedFields, wx.FieldAPIBase)
  40577. }
  40578. // SetAPIKey sets the "api_key" field.
  40579. func (m *WxMutation) SetAPIKey(s string) {
  40580. m.api_key = &s
  40581. }
  40582. // APIKey returns the value of the "api_key" field in the mutation.
  40583. func (m *WxMutation) APIKey() (r string, exists bool) {
  40584. v := m.api_key
  40585. if v == nil {
  40586. return
  40587. }
  40588. return *v, true
  40589. }
  40590. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  40591. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40593. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  40594. if !m.op.Is(OpUpdateOne) {
  40595. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  40596. }
  40597. if m.id == nil || m.oldValue == nil {
  40598. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  40599. }
  40600. oldValue, err := m.oldValue(ctx)
  40601. if err != nil {
  40602. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  40603. }
  40604. return oldValue.APIKey, nil
  40605. }
  40606. // ClearAPIKey clears the value of the "api_key" field.
  40607. func (m *WxMutation) ClearAPIKey() {
  40608. m.api_key = nil
  40609. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  40610. }
  40611. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  40612. func (m *WxMutation) APIKeyCleared() bool {
  40613. _, ok := m.clearedFields[wx.FieldAPIKey]
  40614. return ok
  40615. }
  40616. // ResetAPIKey resets all changes to the "api_key" field.
  40617. func (m *WxMutation) ResetAPIKey() {
  40618. m.api_key = nil
  40619. delete(m.clearedFields, wx.FieldAPIKey)
  40620. }
  40621. // SetAllowList sets the "allow_list" field.
  40622. func (m *WxMutation) SetAllowList(s []string) {
  40623. m.allow_list = &s
  40624. m.appendallow_list = nil
  40625. }
  40626. // AllowList returns the value of the "allow_list" field in the mutation.
  40627. func (m *WxMutation) AllowList() (r []string, exists bool) {
  40628. v := m.allow_list
  40629. if v == nil {
  40630. return
  40631. }
  40632. return *v, true
  40633. }
  40634. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  40635. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40637. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  40638. if !m.op.Is(OpUpdateOne) {
  40639. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  40640. }
  40641. if m.id == nil || m.oldValue == nil {
  40642. return v, errors.New("OldAllowList requires an ID field in the mutation")
  40643. }
  40644. oldValue, err := m.oldValue(ctx)
  40645. if err != nil {
  40646. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  40647. }
  40648. return oldValue.AllowList, nil
  40649. }
  40650. // AppendAllowList adds s to the "allow_list" field.
  40651. func (m *WxMutation) AppendAllowList(s []string) {
  40652. m.appendallow_list = append(m.appendallow_list, s...)
  40653. }
  40654. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  40655. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  40656. if len(m.appendallow_list) == 0 {
  40657. return nil, false
  40658. }
  40659. return m.appendallow_list, true
  40660. }
  40661. // ResetAllowList resets all changes to the "allow_list" field.
  40662. func (m *WxMutation) ResetAllowList() {
  40663. m.allow_list = nil
  40664. m.appendallow_list = nil
  40665. }
  40666. // SetGroupAllowList sets the "group_allow_list" field.
  40667. func (m *WxMutation) SetGroupAllowList(s []string) {
  40668. m.group_allow_list = &s
  40669. m.appendgroup_allow_list = nil
  40670. }
  40671. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  40672. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  40673. v := m.group_allow_list
  40674. if v == nil {
  40675. return
  40676. }
  40677. return *v, true
  40678. }
  40679. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  40680. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40682. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  40683. if !m.op.Is(OpUpdateOne) {
  40684. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  40685. }
  40686. if m.id == nil || m.oldValue == nil {
  40687. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  40688. }
  40689. oldValue, err := m.oldValue(ctx)
  40690. if err != nil {
  40691. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  40692. }
  40693. return oldValue.GroupAllowList, nil
  40694. }
  40695. // AppendGroupAllowList adds s to the "group_allow_list" field.
  40696. func (m *WxMutation) AppendGroupAllowList(s []string) {
  40697. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  40698. }
  40699. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  40700. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  40701. if len(m.appendgroup_allow_list) == 0 {
  40702. return nil, false
  40703. }
  40704. return m.appendgroup_allow_list, true
  40705. }
  40706. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  40707. func (m *WxMutation) ResetGroupAllowList() {
  40708. m.group_allow_list = nil
  40709. m.appendgroup_allow_list = nil
  40710. }
  40711. // SetBlockList sets the "block_list" field.
  40712. func (m *WxMutation) SetBlockList(s []string) {
  40713. m.block_list = &s
  40714. m.appendblock_list = nil
  40715. }
  40716. // BlockList returns the value of the "block_list" field in the mutation.
  40717. func (m *WxMutation) BlockList() (r []string, exists bool) {
  40718. v := m.block_list
  40719. if v == nil {
  40720. return
  40721. }
  40722. return *v, true
  40723. }
  40724. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  40725. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40727. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  40728. if !m.op.Is(OpUpdateOne) {
  40729. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  40730. }
  40731. if m.id == nil || m.oldValue == nil {
  40732. return v, errors.New("OldBlockList requires an ID field in the mutation")
  40733. }
  40734. oldValue, err := m.oldValue(ctx)
  40735. if err != nil {
  40736. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  40737. }
  40738. return oldValue.BlockList, nil
  40739. }
  40740. // AppendBlockList adds s to the "block_list" field.
  40741. func (m *WxMutation) AppendBlockList(s []string) {
  40742. m.appendblock_list = append(m.appendblock_list, s...)
  40743. }
  40744. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  40745. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  40746. if len(m.appendblock_list) == 0 {
  40747. return nil, false
  40748. }
  40749. return m.appendblock_list, true
  40750. }
  40751. // ResetBlockList resets all changes to the "block_list" field.
  40752. func (m *WxMutation) ResetBlockList() {
  40753. m.block_list = nil
  40754. m.appendblock_list = nil
  40755. }
  40756. // SetGroupBlockList sets the "group_block_list" field.
  40757. func (m *WxMutation) SetGroupBlockList(s []string) {
  40758. m.group_block_list = &s
  40759. m.appendgroup_block_list = nil
  40760. }
  40761. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  40762. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  40763. v := m.group_block_list
  40764. if v == nil {
  40765. return
  40766. }
  40767. return *v, true
  40768. }
  40769. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  40770. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40772. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  40773. if !m.op.Is(OpUpdateOne) {
  40774. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  40775. }
  40776. if m.id == nil || m.oldValue == nil {
  40777. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  40778. }
  40779. oldValue, err := m.oldValue(ctx)
  40780. if err != nil {
  40781. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  40782. }
  40783. return oldValue.GroupBlockList, nil
  40784. }
  40785. // AppendGroupBlockList adds s to the "group_block_list" field.
  40786. func (m *WxMutation) AppendGroupBlockList(s []string) {
  40787. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  40788. }
  40789. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  40790. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  40791. if len(m.appendgroup_block_list) == 0 {
  40792. return nil, false
  40793. }
  40794. return m.appendgroup_block_list, true
  40795. }
  40796. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  40797. func (m *WxMutation) ResetGroupBlockList() {
  40798. m.group_block_list = nil
  40799. m.appendgroup_block_list = nil
  40800. }
  40801. // SetCtype sets the "ctype" field.
  40802. func (m *WxMutation) SetCtype(u uint64) {
  40803. m.ctype = &u
  40804. m.addctype = nil
  40805. }
  40806. // Ctype returns the value of the "ctype" field in the mutation.
  40807. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  40808. v := m.ctype
  40809. if v == nil {
  40810. return
  40811. }
  40812. return *v, true
  40813. }
  40814. // OldCtype returns the old "ctype" field's value of the Wx entity.
  40815. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  40816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40817. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  40818. if !m.op.Is(OpUpdateOne) {
  40819. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  40820. }
  40821. if m.id == nil || m.oldValue == nil {
  40822. return v, errors.New("OldCtype requires an ID field in the mutation")
  40823. }
  40824. oldValue, err := m.oldValue(ctx)
  40825. if err != nil {
  40826. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  40827. }
  40828. return oldValue.Ctype, nil
  40829. }
  40830. // AddCtype adds u to the "ctype" field.
  40831. func (m *WxMutation) AddCtype(u int64) {
  40832. if m.addctype != nil {
  40833. *m.addctype += u
  40834. } else {
  40835. m.addctype = &u
  40836. }
  40837. }
  40838. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  40839. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  40840. v := m.addctype
  40841. if v == nil {
  40842. return
  40843. }
  40844. return *v, true
  40845. }
  40846. // ClearCtype clears the value of the "ctype" field.
  40847. func (m *WxMutation) ClearCtype() {
  40848. m.ctype = nil
  40849. m.addctype = nil
  40850. m.clearedFields[wx.FieldCtype] = struct{}{}
  40851. }
  40852. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  40853. func (m *WxMutation) CtypeCleared() bool {
  40854. _, ok := m.clearedFields[wx.FieldCtype]
  40855. return ok
  40856. }
  40857. // ResetCtype resets all changes to the "ctype" field.
  40858. func (m *WxMutation) ResetCtype() {
  40859. m.ctype = nil
  40860. m.addctype = nil
  40861. delete(m.clearedFields, wx.FieldCtype)
  40862. }
  40863. // ClearServer clears the "server" edge to the Server entity.
  40864. func (m *WxMutation) ClearServer() {
  40865. m.clearedserver = true
  40866. m.clearedFields[wx.FieldServerID] = struct{}{}
  40867. }
  40868. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  40869. func (m *WxMutation) ServerCleared() bool {
  40870. return m.ServerIDCleared() || m.clearedserver
  40871. }
  40872. // ServerIDs returns the "server" edge IDs in the mutation.
  40873. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40874. // ServerID instead. It exists only for internal usage by the builders.
  40875. func (m *WxMutation) ServerIDs() (ids []uint64) {
  40876. if id := m.server; id != nil {
  40877. ids = append(ids, *id)
  40878. }
  40879. return
  40880. }
  40881. // ResetServer resets all changes to the "server" edge.
  40882. func (m *WxMutation) ResetServer() {
  40883. m.server = nil
  40884. m.clearedserver = false
  40885. }
  40886. // ClearAgent clears the "agent" edge to the Agent entity.
  40887. func (m *WxMutation) ClearAgent() {
  40888. m.clearedagent = true
  40889. m.clearedFields[wx.FieldAgentID] = struct{}{}
  40890. }
  40891. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  40892. func (m *WxMutation) AgentCleared() bool {
  40893. return m.clearedagent
  40894. }
  40895. // AgentIDs returns the "agent" edge IDs in the mutation.
  40896. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40897. // AgentID instead. It exists only for internal usage by the builders.
  40898. func (m *WxMutation) AgentIDs() (ids []uint64) {
  40899. if id := m.agent; id != nil {
  40900. ids = append(ids, *id)
  40901. }
  40902. return
  40903. }
  40904. // ResetAgent resets all changes to the "agent" edge.
  40905. func (m *WxMutation) ResetAgent() {
  40906. m.agent = nil
  40907. m.clearedagent = false
  40908. }
  40909. // Where appends a list predicates to the WxMutation builder.
  40910. func (m *WxMutation) Where(ps ...predicate.Wx) {
  40911. m.predicates = append(m.predicates, ps...)
  40912. }
  40913. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  40914. // users can use type-assertion to append predicates that do not depend on any generated package.
  40915. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  40916. p := make([]predicate.Wx, len(ps))
  40917. for i := range ps {
  40918. p[i] = ps[i]
  40919. }
  40920. m.Where(p...)
  40921. }
  40922. // Op returns the operation name.
  40923. func (m *WxMutation) Op() Op {
  40924. return m.op
  40925. }
  40926. // SetOp allows setting the mutation operation.
  40927. func (m *WxMutation) SetOp(op Op) {
  40928. m.op = op
  40929. }
  40930. // Type returns the node type of this mutation (Wx).
  40931. func (m *WxMutation) Type() string {
  40932. return m.typ
  40933. }
  40934. // Fields returns all fields that were changed during this mutation. Note that in
  40935. // order to get all numeric fields that were incremented/decremented, call
  40936. // AddedFields().
  40937. func (m *WxMutation) Fields() []string {
  40938. fields := make([]string, 0, 22)
  40939. if m.created_at != nil {
  40940. fields = append(fields, wx.FieldCreatedAt)
  40941. }
  40942. if m.updated_at != nil {
  40943. fields = append(fields, wx.FieldUpdatedAt)
  40944. }
  40945. if m.status != nil {
  40946. fields = append(fields, wx.FieldStatus)
  40947. }
  40948. if m.deleted_at != nil {
  40949. fields = append(fields, wx.FieldDeletedAt)
  40950. }
  40951. if m.server != nil {
  40952. fields = append(fields, wx.FieldServerID)
  40953. }
  40954. if m.port != nil {
  40955. fields = append(fields, wx.FieldPort)
  40956. }
  40957. if m.process_id != nil {
  40958. fields = append(fields, wx.FieldProcessID)
  40959. }
  40960. if m.callback != nil {
  40961. fields = append(fields, wx.FieldCallback)
  40962. }
  40963. if m.wxid != nil {
  40964. fields = append(fields, wx.FieldWxid)
  40965. }
  40966. if m.account != nil {
  40967. fields = append(fields, wx.FieldAccount)
  40968. }
  40969. if m.nickname != nil {
  40970. fields = append(fields, wx.FieldNickname)
  40971. }
  40972. if m.tel != nil {
  40973. fields = append(fields, wx.FieldTel)
  40974. }
  40975. if m.head_big != nil {
  40976. fields = append(fields, wx.FieldHeadBig)
  40977. }
  40978. if m.organization_id != nil {
  40979. fields = append(fields, wx.FieldOrganizationID)
  40980. }
  40981. if m.agent != nil {
  40982. fields = append(fields, wx.FieldAgentID)
  40983. }
  40984. if m.api_base != nil {
  40985. fields = append(fields, wx.FieldAPIBase)
  40986. }
  40987. if m.api_key != nil {
  40988. fields = append(fields, wx.FieldAPIKey)
  40989. }
  40990. if m.allow_list != nil {
  40991. fields = append(fields, wx.FieldAllowList)
  40992. }
  40993. if m.group_allow_list != nil {
  40994. fields = append(fields, wx.FieldGroupAllowList)
  40995. }
  40996. if m.block_list != nil {
  40997. fields = append(fields, wx.FieldBlockList)
  40998. }
  40999. if m.group_block_list != nil {
  41000. fields = append(fields, wx.FieldGroupBlockList)
  41001. }
  41002. if m.ctype != nil {
  41003. fields = append(fields, wx.FieldCtype)
  41004. }
  41005. return fields
  41006. }
  41007. // Field returns the value of a field with the given name. The second boolean
  41008. // return value indicates that this field was not set, or was not defined in the
  41009. // schema.
  41010. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  41011. switch name {
  41012. case wx.FieldCreatedAt:
  41013. return m.CreatedAt()
  41014. case wx.FieldUpdatedAt:
  41015. return m.UpdatedAt()
  41016. case wx.FieldStatus:
  41017. return m.Status()
  41018. case wx.FieldDeletedAt:
  41019. return m.DeletedAt()
  41020. case wx.FieldServerID:
  41021. return m.ServerID()
  41022. case wx.FieldPort:
  41023. return m.Port()
  41024. case wx.FieldProcessID:
  41025. return m.ProcessID()
  41026. case wx.FieldCallback:
  41027. return m.Callback()
  41028. case wx.FieldWxid:
  41029. return m.Wxid()
  41030. case wx.FieldAccount:
  41031. return m.Account()
  41032. case wx.FieldNickname:
  41033. return m.Nickname()
  41034. case wx.FieldTel:
  41035. return m.Tel()
  41036. case wx.FieldHeadBig:
  41037. return m.HeadBig()
  41038. case wx.FieldOrganizationID:
  41039. return m.OrganizationID()
  41040. case wx.FieldAgentID:
  41041. return m.AgentID()
  41042. case wx.FieldAPIBase:
  41043. return m.APIBase()
  41044. case wx.FieldAPIKey:
  41045. return m.APIKey()
  41046. case wx.FieldAllowList:
  41047. return m.AllowList()
  41048. case wx.FieldGroupAllowList:
  41049. return m.GroupAllowList()
  41050. case wx.FieldBlockList:
  41051. return m.BlockList()
  41052. case wx.FieldGroupBlockList:
  41053. return m.GroupBlockList()
  41054. case wx.FieldCtype:
  41055. return m.Ctype()
  41056. }
  41057. return nil, false
  41058. }
  41059. // OldField returns the old value of the field from the database. An error is
  41060. // returned if the mutation operation is not UpdateOne, or the query to the
  41061. // database failed.
  41062. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41063. switch name {
  41064. case wx.FieldCreatedAt:
  41065. return m.OldCreatedAt(ctx)
  41066. case wx.FieldUpdatedAt:
  41067. return m.OldUpdatedAt(ctx)
  41068. case wx.FieldStatus:
  41069. return m.OldStatus(ctx)
  41070. case wx.FieldDeletedAt:
  41071. return m.OldDeletedAt(ctx)
  41072. case wx.FieldServerID:
  41073. return m.OldServerID(ctx)
  41074. case wx.FieldPort:
  41075. return m.OldPort(ctx)
  41076. case wx.FieldProcessID:
  41077. return m.OldProcessID(ctx)
  41078. case wx.FieldCallback:
  41079. return m.OldCallback(ctx)
  41080. case wx.FieldWxid:
  41081. return m.OldWxid(ctx)
  41082. case wx.FieldAccount:
  41083. return m.OldAccount(ctx)
  41084. case wx.FieldNickname:
  41085. return m.OldNickname(ctx)
  41086. case wx.FieldTel:
  41087. return m.OldTel(ctx)
  41088. case wx.FieldHeadBig:
  41089. return m.OldHeadBig(ctx)
  41090. case wx.FieldOrganizationID:
  41091. return m.OldOrganizationID(ctx)
  41092. case wx.FieldAgentID:
  41093. return m.OldAgentID(ctx)
  41094. case wx.FieldAPIBase:
  41095. return m.OldAPIBase(ctx)
  41096. case wx.FieldAPIKey:
  41097. return m.OldAPIKey(ctx)
  41098. case wx.FieldAllowList:
  41099. return m.OldAllowList(ctx)
  41100. case wx.FieldGroupAllowList:
  41101. return m.OldGroupAllowList(ctx)
  41102. case wx.FieldBlockList:
  41103. return m.OldBlockList(ctx)
  41104. case wx.FieldGroupBlockList:
  41105. return m.OldGroupBlockList(ctx)
  41106. case wx.FieldCtype:
  41107. return m.OldCtype(ctx)
  41108. }
  41109. return nil, fmt.Errorf("unknown Wx field %s", name)
  41110. }
  41111. // SetField sets the value of a field with the given name. It returns an error if
  41112. // the field is not defined in the schema, or if the type mismatched the field
  41113. // type.
  41114. func (m *WxMutation) SetField(name string, value ent.Value) error {
  41115. switch name {
  41116. case wx.FieldCreatedAt:
  41117. v, ok := value.(time.Time)
  41118. if !ok {
  41119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41120. }
  41121. m.SetCreatedAt(v)
  41122. return nil
  41123. case wx.FieldUpdatedAt:
  41124. v, ok := value.(time.Time)
  41125. if !ok {
  41126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41127. }
  41128. m.SetUpdatedAt(v)
  41129. return nil
  41130. case wx.FieldStatus:
  41131. v, ok := value.(uint8)
  41132. if !ok {
  41133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41134. }
  41135. m.SetStatus(v)
  41136. return nil
  41137. case wx.FieldDeletedAt:
  41138. v, ok := value.(time.Time)
  41139. if !ok {
  41140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41141. }
  41142. m.SetDeletedAt(v)
  41143. return nil
  41144. case wx.FieldServerID:
  41145. v, ok := value.(uint64)
  41146. if !ok {
  41147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41148. }
  41149. m.SetServerID(v)
  41150. return nil
  41151. case wx.FieldPort:
  41152. v, ok := value.(string)
  41153. if !ok {
  41154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41155. }
  41156. m.SetPort(v)
  41157. return nil
  41158. case wx.FieldProcessID:
  41159. v, ok := value.(string)
  41160. if !ok {
  41161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41162. }
  41163. m.SetProcessID(v)
  41164. return nil
  41165. case wx.FieldCallback:
  41166. v, ok := value.(string)
  41167. if !ok {
  41168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41169. }
  41170. m.SetCallback(v)
  41171. return nil
  41172. case wx.FieldWxid:
  41173. v, ok := value.(string)
  41174. if !ok {
  41175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41176. }
  41177. m.SetWxid(v)
  41178. return nil
  41179. case wx.FieldAccount:
  41180. v, ok := value.(string)
  41181. if !ok {
  41182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41183. }
  41184. m.SetAccount(v)
  41185. return nil
  41186. case wx.FieldNickname:
  41187. v, ok := value.(string)
  41188. if !ok {
  41189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41190. }
  41191. m.SetNickname(v)
  41192. return nil
  41193. case wx.FieldTel:
  41194. v, ok := value.(string)
  41195. if !ok {
  41196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41197. }
  41198. m.SetTel(v)
  41199. return nil
  41200. case wx.FieldHeadBig:
  41201. v, ok := value.(string)
  41202. if !ok {
  41203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41204. }
  41205. m.SetHeadBig(v)
  41206. return nil
  41207. case wx.FieldOrganizationID:
  41208. v, ok := value.(uint64)
  41209. if !ok {
  41210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41211. }
  41212. m.SetOrganizationID(v)
  41213. return nil
  41214. case wx.FieldAgentID:
  41215. v, ok := value.(uint64)
  41216. if !ok {
  41217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41218. }
  41219. m.SetAgentID(v)
  41220. return nil
  41221. case wx.FieldAPIBase:
  41222. v, ok := value.(string)
  41223. if !ok {
  41224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41225. }
  41226. m.SetAPIBase(v)
  41227. return nil
  41228. case wx.FieldAPIKey:
  41229. v, ok := value.(string)
  41230. if !ok {
  41231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41232. }
  41233. m.SetAPIKey(v)
  41234. return nil
  41235. case wx.FieldAllowList:
  41236. v, ok := value.([]string)
  41237. if !ok {
  41238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41239. }
  41240. m.SetAllowList(v)
  41241. return nil
  41242. case wx.FieldGroupAllowList:
  41243. v, ok := value.([]string)
  41244. if !ok {
  41245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41246. }
  41247. m.SetGroupAllowList(v)
  41248. return nil
  41249. case wx.FieldBlockList:
  41250. v, ok := value.([]string)
  41251. if !ok {
  41252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41253. }
  41254. m.SetBlockList(v)
  41255. return nil
  41256. case wx.FieldGroupBlockList:
  41257. v, ok := value.([]string)
  41258. if !ok {
  41259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41260. }
  41261. m.SetGroupBlockList(v)
  41262. return nil
  41263. case wx.FieldCtype:
  41264. v, ok := value.(uint64)
  41265. if !ok {
  41266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41267. }
  41268. m.SetCtype(v)
  41269. return nil
  41270. }
  41271. return fmt.Errorf("unknown Wx field %s", name)
  41272. }
  41273. // AddedFields returns all numeric fields that were incremented/decremented during
  41274. // this mutation.
  41275. func (m *WxMutation) AddedFields() []string {
  41276. var fields []string
  41277. if m.addstatus != nil {
  41278. fields = append(fields, wx.FieldStatus)
  41279. }
  41280. if m.addorganization_id != nil {
  41281. fields = append(fields, wx.FieldOrganizationID)
  41282. }
  41283. if m.addctype != nil {
  41284. fields = append(fields, wx.FieldCtype)
  41285. }
  41286. return fields
  41287. }
  41288. // AddedField returns the numeric value that was incremented/decremented on a field
  41289. // with the given name. The second boolean return value indicates that this field
  41290. // was not set, or was not defined in the schema.
  41291. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  41292. switch name {
  41293. case wx.FieldStatus:
  41294. return m.AddedStatus()
  41295. case wx.FieldOrganizationID:
  41296. return m.AddedOrganizationID()
  41297. case wx.FieldCtype:
  41298. return m.AddedCtype()
  41299. }
  41300. return nil, false
  41301. }
  41302. // AddField adds the value to the field with the given name. It returns an error if
  41303. // the field is not defined in the schema, or if the type mismatched the field
  41304. // type.
  41305. func (m *WxMutation) AddField(name string, value ent.Value) error {
  41306. switch name {
  41307. case wx.FieldStatus:
  41308. v, ok := value.(int8)
  41309. if !ok {
  41310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41311. }
  41312. m.AddStatus(v)
  41313. return nil
  41314. case wx.FieldOrganizationID:
  41315. v, ok := value.(int64)
  41316. if !ok {
  41317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41318. }
  41319. m.AddOrganizationID(v)
  41320. return nil
  41321. case wx.FieldCtype:
  41322. v, ok := value.(int64)
  41323. if !ok {
  41324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41325. }
  41326. m.AddCtype(v)
  41327. return nil
  41328. }
  41329. return fmt.Errorf("unknown Wx numeric field %s", name)
  41330. }
  41331. // ClearedFields returns all nullable fields that were cleared during this
  41332. // mutation.
  41333. func (m *WxMutation) ClearedFields() []string {
  41334. var fields []string
  41335. if m.FieldCleared(wx.FieldStatus) {
  41336. fields = append(fields, wx.FieldStatus)
  41337. }
  41338. if m.FieldCleared(wx.FieldDeletedAt) {
  41339. fields = append(fields, wx.FieldDeletedAt)
  41340. }
  41341. if m.FieldCleared(wx.FieldServerID) {
  41342. fields = append(fields, wx.FieldServerID)
  41343. }
  41344. if m.FieldCleared(wx.FieldOrganizationID) {
  41345. fields = append(fields, wx.FieldOrganizationID)
  41346. }
  41347. if m.FieldCleared(wx.FieldAPIBase) {
  41348. fields = append(fields, wx.FieldAPIBase)
  41349. }
  41350. if m.FieldCleared(wx.FieldAPIKey) {
  41351. fields = append(fields, wx.FieldAPIKey)
  41352. }
  41353. if m.FieldCleared(wx.FieldCtype) {
  41354. fields = append(fields, wx.FieldCtype)
  41355. }
  41356. return fields
  41357. }
  41358. // FieldCleared returns a boolean indicating if a field with the given name was
  41359. // cleared in this mutation.
  41360. func (m *WxMutation) FieldCleared(name string) bool {
  41361. _, ok := m.clearedFields[name]
  41362. return ok
  41363. }
  41364. // ClearField clears the value of the field with the given name. It returns an
  41365. // error if the field is not defined in the schema.
  41366. func (m *WxMutation) ClearField(name string) error {
  41367. switch name {
  41368. case wx.FieldStatus:
  41369. m.ClearStatus()
  41370. return nil
  41371. case wx.FieldDeletedAt:
  41372. m.ClearDeletedAt()
  41373. return nil
  41374. case wx.FieldServerID:
  41375. m.ClearServerID()
  41376. return nil
  41377. case wx.FieldOrganizationID:
  41378. m.ClearOrganizationID()
  41379. return nil
  41380. case wx.FieldAPIBase:
  41381. m.ClearAPIBase()
  41382. return nil
  41383. case wx.FieldAPIKey:
  41384. m.ClearAPIKey()
  41385. return nil
  41386. case wx.FieldCtype:
  41387. m.ClearCtype()
  41388. return nil
  41389. }
  41390. return fmt.Errorf("unknown Wx nullable field %s", name)
  41391. }
  41392. // ResetField resets all changes in the mutation for the field with the given name.
  41393. // It returns an error if the field is not defined in the schema.
  41394. func (m *WxMutation) ResetField(name string) error {
  41395. switch name {
  41396. case wx.FieldCreatedAt:
  41397. m.ResetCreatedAt()
  41398. return nil
  41399. case wx.FieldUpdatedAt:
  41400. m.ResetUpdatedAt()
  41401. return nil
  41402. case wx.FieldStatus:
  41403. m.ResetStatus()
  41404. return nil
  41405. case wx.FieldDeletedAt:
  41406. m.ResetDeletedAt()
  41407. return nil
  41408. case wx.FieldServerID:
  41409. m.ResetServerID()
  41410. return nil
  41411. case wx.FieldPort:
  41412. m.ResetPort()
  41413. return nil
  41414. case wx.FieldProcessID:
  41415. m.ResetProcessID()
  41416. return nil
  41417. case wx.FieldCallback:
  41418. m.ResetCallback()
  41419. return nil
  41420. case wx.FieldWxid:
  41421. m.ResetWxid()
  41422. return nil
  41423. case wx.FieldAccount:
  41424. m.ResetAccount()
  41425. return nil
  41426. case wx.FieldNickname:
  41427. m.ResetNickname()
  41428. return nil
  41429. case wx.FieldTel:
  41430. m.ResetTel()
  41431. return nil
  41432. case wx.FieldHeadBig:
  41433. m.ResetHeadBig()
  41434. return nil
  41435. case wx.FieldOrganizationID:
  41436. m.ResetOrganizationID()
  41437. return nil
  41438. case wx.FieldAgentID:
  41439. m.ResetAgentID()
  41440. return nil
  41441. case wx.FieldAPIBase:
  41442. m.ResetAPIBase()
  41443. return nil
  41444. case wx.FieldAPIKey:
  41445. m.ResetAPIKey()
  41446. return nil
  41447. case wx.FieldAllowList:
  41448. m.ResetAllowList()
  41449. return nil
  41450. case wx.FieldGroupAllowList:
  41451. m.ResetGroupAllowList()
  41452. return nil
  41453. case wx.FieldBlockList:
  41454. m.ResetBlockList()
  41455. return nil
  41456. case wx.FieldGroupBlockList:
  41457. m.ResetGroupBlockList()
  41458. return nil
  41459. case wx.FieldCtype:
  41460. m.ResetCtype()
  41461. return nil
  41462. }
  41463. return fmt.Errorf("unknown Wx field %s", name)
  41464. }
  41465. // AddedEdges returns all edge names that were set/added in this mutation.
  41466. func (m *WxMutation) AddedEdges() []string {
  41467. edges := make([]string, 0, 2)
  41468. if m.server != nil {
  41469. edges = append(edges, wx.EdgeServer)
  41470. }
  41471. if m.agent != nil {
  41472. edges = append(edges, wx.EdgeAgent)
  41473. }
  41474. return edges
  41475. }
  41476. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41477. // name in this mutation.
  41478. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  41479. switch name {
  41480. case wx.EdgeServer:
  41481. if id := m.server; id != nil {
  41482. return []ent.Value{*id}
  41483. }
  41484. case wx.EdgeAgent:
  41485. if id := m.agent; id != nil {
  41486. return []ent.Value{*id}
  41487. }
  41488. }
  41489. return nil
  41490. }
  41491. // RemovedEdges returns all edge names that were removed in this mutation.
  41492. func (m *WxMutation) RemovedEdges() []string {
  41493. edges := make([]string, 0, 2)
  41494. return edges
  41495. }
  41496. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41497. // the given name in this mutation.
  41498. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  41499. return nil
  41500. }
  41501. // ClearedEdges returns all edge names that were cleared in this mutation.
  41502. func (m *WxMutation) ClearedEdges() []string {
  41503. edges := make([]string, 0, 2)
  41504. if m.clearedserver {
  41505. edges = append(edges, wx.EdgeServer)
  41506. }
  41507. if m.clearedagent {
  41508. edges = append(edges, wx.EdgeAgent)
  41509. }
  41510. return edges
  41511. }
  41512. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41513. // was cleared in this mutation.
  41514. func (m *WxMutation) EdgeCleared(name string) bool {
  41515. switch name {
  41516. case wx.EdgeServer:
  41517. return m.clearedserver
  41518. case wx.EdgeAgent:
  41519. return m.clearedagent
  41520. }
  41521. return false
  41522. }
  41523. // ClearEdge clears the value of the edge with the given name. It returns an error
  41524. // if that edge is not defined in the schema.
  41525. func (m *WxMutation) ClearEdge(name string) error {
  41526. switch name {
  41527. case wx.EdgeServer:
  41528. m.ClearServer()
  41529. return nil
  41530. case wx.EdgeAgent:
  41531. m.ClearAgent()
  41532. return nil
  41533. }
  41534. return fmt.Errorf("unknown Wx unique edge %s", name)
  41535. }
  41536. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41537. // It returns an error if the edge is not defined in the schema.
  41538. func (m *WxMutation) ResetEdge(name string) error {
  41539. switch name {
  41540. case wx.EdgeServer:
  41541. m.ResetServer()
  41542. return nil
  41543. case wx.EdgeAgent:
  41544. m.ResetAgent()
  41545. return nil
  41546. }
  41547. return fmt.Errorf("unknown Wx edge %s", name)
  41548. }
  41549. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  41550. type WxCardMutation struct {
  41551. config
  41552. op Op
  41553. typ string
  41554. id *uint64
  41555. created_at *time.Time
  41556. updated_at *time.Time
  41557. deleted_at *time.Time
  41558. user_id *uint64
  41559. adduser_id *int64
  41560. wx_user_id *uint64
  41561. addwx_user_id *int64
  41562. avatar *string
  41563. logo *string
  41564. name *string
  41565. company *string
  41566. address *string
  41567. phone *string
  41568. official_account *string
  41569. wechat_account *string
  41570. email *string
  41571. api_base *string
  41572. api_key *string
  41573. ai_info *string
  41574. intro *string
  41575. clearedFields map[string]struct{}
  41576. done bool
  41577. oldValue func(context.Context) (*WxCard, error)
  41578. predicates []predicate.WxCard
  41579. }
  41580. var _ ent.Mutation = (*WxCardMutation)(nil)
  41581. // wxcardOption allows management of the mutation configuration using functional options.
  41582. type wxcardOption func(*WxCardMutation)
  41583. // newWxCardMutation creates new mutation for the WxCard entity.
  41584. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  41585. m := &WxCardMutation{
  41586. config: c,
  41587. op: op,
  41588. typ: TypeWxCard,
  41589. clearedFields: make(map[string]struct{}),
  41590. }
  41591. for _, opt := range opts {
  41592. opt(m)
  41593. }
  41594. return m
  41595. }
  41596. // withWxCardID sets the ID field of the mutation.
  41597. func withWxCardID(id uint64) wxcardOption {
  41598. return func(m *WxCardMutation) {
  41599. var (
  41600. err error
  41601. once sync.Once
  41602. value *WxCard
  41603. )
  41604. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  41605. once.Do(func() {
  41606. if m.done {
  41607. err = errors.New("querying old values post mutation is not allowed")
  41608. } else {
  41609. value, err = m.Client().WxCard.Get(ctx, id)
  41610. }
  41611. })
  41612. return value, err
  41613. }
  41614. m.id = &id
  41615. }
  41616. }
  41617. // withWxCard sets the old WxCard of the mutation.
  41618. func withWxCard(node *WxCard) wxcardOption {
  41619. return func(m *WxCardMutation) {
  41620. m.oldValue = func(context.Context) (*WxCard, error) {
  41621. return node, nil
  41622. }
  41623. m.id = &node.ID
  41624. }
  41625. }
  41626. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41627. // executed in a transaction (ent.Tx), a transactional client is returned.
  41628. func (m WxCardMutation) Client() *Client {
  41629. client := &Client{config: m.config}
  41630. client.init()
  41631. return client
  41632. }
  41633. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41634. // it returns an error otherwise.
  41635. func (m WxCardMutation) Tx() (*Tx, error) {
  41636. if _, ok := m.driver.(*txDriver); !ok {
  41637. return nil, errors.New("ent: mutation is not running in a transaction")
  41638. }
  41639. tx := &Tx{config: m.config}
  41640. tx.init()
  41641. return tx, nil
  41642. }
  41643. // SetID sets the value of the id field. Note that this
  41644. // operation is only accepted on creation of WxCard entities.
  41645. func (m *WxCardMutation) SetID(id uint64) {
  41646. m.id = &id
  41647. }
  41648. // ID returns the ID value in the mutation. Note that the ID is only available
  41649. // if it was provided to the builder or after it was returned from the database.
  41650. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  41651. if m.id == nil {
  41652. return
  41653. }
  41654. return *m.id, true
  41655. }
  41656. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41657. // That means, if the mutation is applied within a transaction with an isolation level such
  41658. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41659. // or updated by the mutation.
  41660. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  41661. switch {
  41662. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41663. id, exists := m.ID()
  41664. if exists {
  41665. return []uint64{id}, nil
  41666. }
  41667. fallthrough
  41668. case m.op.Is(OpUpdate | OpDelete):
  41669. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  41670. default:
  41671. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41672. }
  41673. }
  41674. // SetCreatedAt sets the "created_at" field.
  41675. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  41676. m.created_at = &t
  41677. }
  41678. // CreatedAt returns the value of the "created_at" field in the mutation.
  41679. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  41680. v := m.created_at
  41681. if v == nil {
  41682. return
  41683. }
  41684. return *v, true
  41685. }
  41686. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  41687. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41689. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41690. if !m.op.Is(OpUpdateOne) {
  41691. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41692. }
  41693. if m.id == nil || m.oldValue == nil {
  41694. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41695. }
  41696. oldValue, err := m.oldValue(ctx)
  41697. if err != nil {
  41698. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41699. }
  41700. return oldValue.CreatedAt, nil
  41701. }
  41702. // ResetCreatedAt resets all changes to the "created_at" field.
  41703. func (m *WxCardMutation) ResetCreatedAt() {
  41704. m.created_at = nil
  41705. }
  41706. // SetUpdatedAt sets the "updated_at" field.
  41707. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  41708. m.updated_at = &t
  41709. }
  41710. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41711. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  41712. v := m.updated_at
  41713. if v == nil {
  41714. return
  41715. }
  41716. return *v, true
  41717. }
  41718. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  41719. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41721. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41722. if !m.op.Is(OpUpdateOne) {
  41723. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41724. }
  41725. if m.id == nil || m.oldValue == nil {
  41726. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41727. }
  41728. oldValue, err := m.oldValue(ctx)
  41729. if err != nil {
  41730. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41731. }
  41732. return oldValue.UpdatedAt, nil
  41733. }
  41734. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41735. func (m *WxCardMutation) ResetUpdatedAt() {
  41736. m.updated_at = nil
  41737. }
  41738. // SetDeletedAt sets the "deleted_at" field.
  41739. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  41740. m.deleted_at = &t
  41741. }
  41742. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41743. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  41744. v := m.deleted_at
  41745. if v == nil {
  41746. return
  41747. }
  41748. return *v, true
  41749. }
  41750. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  41751. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41753. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41754. if !m.op.Is(OpUpdateOne) {
  41755. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41756. }
  41757. if m.id == nil || m.oldValue == nil {
  41758. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41759. }
  41760. oldValue, err := m.oldValue(ctx)
  41761. if err != nil {
  41762. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41763. }
  41764. return oldValue.DeletedAt, nil
  41765. }
  41766. // ClearDeletedAt clears the value of the "deleted_at" field.
  41767. func (m *WxCardMutation) ClearDeletedAt() {
  41768. m.deleted_at = nil
  41769. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  41770. }
  41771. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41772. func (m *WxCardMutation) DeletedAtCleared() bool {
  41773. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  41774. return ok
  41775. }
  41776. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41777. func (m *WxCardMutation) ResetDeletedAt() {
  41778. m.deleted_at = nil
  41779. delete(m.clearedFields, wxcard.FieldDeletedAt)
  41780. }
  41781. // SetUserID sets the "user_id" field.
  41782. func (m *WxCardMutation) SetUserID(u uint64) {
  41783. m.user_id = &u
  41784. m.adduser_id = nil
  41785. }
  41786. // UserID returns the value of the "user_id" field in the mutation.
  41787. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  41788. v := m.user_id
  41789. if v == nil {
  41790. return
  41791. }
  41792. return *v, true
  41793. }
  41794. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  41795. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41797. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  41798. if !m.op.Is(OpUpdateOne) {
  41799. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  41800. }
  41801. if m.id == nil || m.oldValue == nil {
  41802. return v, errors.New("OldUserID requires an ID field in the mutation")
  41803. }
  41804. oldValue, err := m.oldValue(ctx)
  41805. if err != nil {
  41806. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  41807. }
  41808. return oldValue.UserID, nil
  41809. }
  41810. // AddUserID adds u to the "user_id" field.
  41811. func (m *WxCardMutation) AddUserID(u int64) {
  41812. if m.adduser_id != nil {
  41813. *m.adduser_id += u
  41814. } else {
  41815. m.adduser_id = &u
  41816. }
  41817. }
  41818. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  41819. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  41820. v := m.adduser_id
  41821. if v == nil {
  41822. return
  41823. }
  41824. return *v, true
  41825. }
  41826. // ClearUserID clears the value of the "user_id" field.
  41827. func (m *WxCardMutation) ClearUserID() {
  41828. m.user_id = nil
  41829. m.adduser_id = nil
  41830. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  41831. }
  41832. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  41833. func (m *WxCardMutation) UserIDCleared() bool {
  41834. _, ok := m.clearedFields[wxcard.FieldUserID]
  41835. return ok
  41836. }
  41837. // ResetUserID resets all changes to the "user_id" field.
  41838. func (m *WxCardMutation) ResetUserID() {
  41839. m.user_id = nil
  41840. m.adduser_id = nil
  41841. delete(m.clearedFields, wxcard.FieldUserID)
  41842. }
  41843. // SetWxUserID sets the "wx_user_id" field.
  41844. func (m *WxCardMutation) SetWxUserID(u uint64) {
  41845. m.wx_user_id = &u
  41846. m.addwx_user_id = nil
  41847. }
  41848. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  41849. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  41850. v := m.wx_user_id
  41851. if v == nil {
  41852. return
  41853. }
  41854. return *v, true
  41855. }
  41856. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  41857. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41859. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  41860. if !m.op.Is(OpUpdateOne) {
  41861. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  41862. }
  41863. if m.id == nil || m.oldValue == nil {
  41864. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  41865. }
  41866. oldValue, err := m.oldValue(ctx)
  41867. if err != nil {
  41868. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  41869. }
  41870. return oldValue.WxUserID, nil
  41871. }
  41872. // AddWxUserID adds u to the "wx_user_id" field.
  41873. func (m *WxCardMutation) AddWxUserID(u int64) {
  41874. if m.addwx_user_id != nil {
  41875. *m.addwx_user_id += u
  41876. } else {
  41877. m.addwx_user_id = &u
  41878. }
  41879. }
  41880. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  41881. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  41882. v := m.addwx_user_id
  41883. if v == nil {
  41884. return
  41885. }
  41886. return *v, true
  41887. }
  41888. // ClearWxUserID clears the value of the "wx_user_id" field.
  41889. func (m *WxCardMutation) ClearWxUserID() {
  41890. m.wx_user_id = nil
  41891. m.addwx_user_id = nil
  41892. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  41893. }
  41894. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  41895. func (m *WxCardMutation) WxUserIDCleared() bool {
  41896. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  41897. return ok
  41898. }
  41899. // ResetWxUserID resets all changes to the "wx_user_id" field.
  41900. func (m *WxCardMutation) ResetWxUserID() {
  41901. m.wx_user_id = nil
  41902. m.addwx_user_id = nil
  41903. delete(m.clearedFields, wxcard.FieldWxUserID)
  41904. }
  41905. // SetAvatar sets the "avatar" field.
  41906. func (m *WxCardMutation) SetAvatar(s string) {
  41907. m.avatar = &s
  41908. }
  41909. // Avatar returns the value of the "avatar" field in the mutation.
  41910. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  41911. v := m.avatar
  41912. if v == nil {
  41913. return
  41914. }
  41915. return *v, true
  41916. }
  41917. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  41918. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41920. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41921. if !m.op.Is(OpUpdateOne) {
  41922. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41923. }
  41924. if m.id == nil || m.oldValue == nil {
  41925. return v, errors.New("OldAvatar requires an ID field in the mutation")
  41926. }
  41927. oldValue, err := m.oldValue(ctx)
  41928. if err != nil {
  41929. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  41930. }
  41931. return oldValue.Avatar, nil
  41932. }
  41933. // ResetAvatar resets all changes to the "avatar" field.
  41934. func (m *WxCardMutation) ResetAvatar() {
  41935. m.avatar = nil
  41936. }
  41937. // SetLogo sets the "logo" field.
  41938. func (m *WxCardMutation) SetLogo(s string) {
  41939. m.logo = &s
  41940. }
  41941. // Logo returns the value of the "logo" field in the mutation.
  41942. func (m *WxCardMutation) Logo() (r string, exists bool) {
  41943. v := m.logo
  41944. if v == nil {
  41945. return
  41946. }
  41947. return *v, true
  41948. }
  41949. // OldLogo returns the old "logo" field's value of the WxCard entity.
  41950. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41952. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  41953. if !m.op.Is(OpUpdateOne) {
  41954. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  41955. }
  41956. if m.id == nil || m.oldValue == nil {
  41957. return v, errors.New("OldLogo requires an ID field in the mutation")
  41958. }
  41959. oldValue, err := m.oldValue(ctx)
  41960. if err != nil {
  41961. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  41962. }
  41963. return oldValue.Logo, nil
  41964. }
  41965. // ResetLogo resets all changes to the "logo" field.
  41966. func (m *WxCardMutation) ResetLogo() {
  41967. m.logo = nil
  41968. }
  41969. // SetName sets the "name" field.
  41970. func (m *WxCardMutation) SetName(s string) {
  41971. m.name = &s
  41972. }
  41973. // Name returns the value of the "name" field in the mutation.
  41974. func (m *WxCardMutation) Name() (r string, exists bool) {
  41975. v := m.name
  41976. if v == nil {
  41977. return
  41978. }
  41979. return *v, true
  41980. }
  41981. // OldName returns the old "name" field's value of the WxCard entity.
  41982. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41984. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  41985. if !m.op.Is(OpUpdateOne) {
  41986. return v, errors.New("OldName is only allowed on UpdateOne operations")
  41987. }
  41988. if m.id == nil || m.oldValue == nil {
  41989. return v, errors.New("OldName requires an ID field in the mutation")
  41990. }
  41991. oldValue, err := m.oldValue(ctx)
  41992. if err != nil {
  41993. return v, fmt.Errorf("querying old value for OldName: %w", err)
  41994. }
  41995. return oldValue.Name, nil
  41996. }
  41997. // ResetName resets all changes to the "name" field.
  41998. func (m *WxCardMutation) ResetName() {
  41999. m.name = nil
  42000. }
  42001. // SetCompany sets the "company" field.
  42002. func (m *WxCardMutation) SetCompany(s string) {
  42003. m.company = &s
  42004. }
  42005. // Company returns the value of the "company" field in the mutation.
  42006. func (m *WxCardMutation) Company() (r string, exists bool) {
  42007. v := m.company
  42008. if v == nil {
  42009. return
  42010. }
  42011. return *v, true
  42012. }
  42013. // OldCompany returns the old "company" field's value of the WxCard entity.
  42014. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42016. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  42017. if !m.op.Is(OpUpdateOne) {
  42018. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  42019. }
  42020. if m.id == nil || m.oldValue == nil {
  42021. return v, errors.New("OldCompany requires an ID field in the mutation")
  42022. }
  42023. oldValue, err := m.oldValue(ctx)
  42024. if err != nil {
  42025. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  42026. }
  42027. return oldValue.Company, nil
  42028. }
  42029. // ResetCompany resets all changes to the "company" field.
  42030. func (m *WxCardMutation) ResetCompany() {
  42031. m.company = nil
  42032. }
  42033. // SetAddress sets the "address" field.
  42034. func (m *WxCardMutation) SetAddress(s string) {
  42035. m.address = &s
  42036. }
  42037. // Address returns the value of the "address" field in the mutation.
  42038. func (m *WxCardMutation) Address() (r string, exists bool) {
  42039. v := m.address
  42040. if v == nil {
  42041. return
  42042. }
  42043. return *v, true
  42044. }
  42045. // OldAddress returns the old "address" field's value of the WxCard entity.
  42046. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42048. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  42049. if !m.op.Is(OpUpdateOne) {
  42050. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  42051. }
  42052. if m.id == nil || m.oldValue == nil {
  42053. return v, errors.New("OldAddress requires an ID field in the mutation")
  42054. }
  42055. oldValue, err := m.oldValue(ctx)
  42056. if err != nil {
  42057. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  42058. }
  42059. return oldValue.Address, nil
  42060. }
  42061. // ResetAddress resets all changes to the "address" field.
  42062. func (m *WxCardMutation) ResetAddress() {
  42063. m.address = nil
  42064. }
  42065. // SetPhone sets the "phone" field.
  42066. func (m *WxCardMutation) SetPhone(s string) {
  42067. m.phone = &s
  42068. }
  42069. // Phone returns the value of the "phone" field in the mutation.
  42070. func (m *WxCardMutation) Phone() (r string, exists bool) {
  42071. v := m.phone
  42072. if v == nil {
  42073. return
  42074. }
  42075. return *v, true
  42076. }
  42077. // OldPhone returns the old "phone" field's value of the WxCard entity.
  42078. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42080. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  42081. if !m.op.Is(OpUpdateOne) {
  42082. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  42083. }
  42084. if m.id == nil || m.oldValue == nil {
  42085. return v, errors.New("OldPhone requires an ID field in the mutation")
  42086. }
  42087. oldValue, err := m.oldValue(ctx)
  42088. if err != nil {
  42089. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  42090. }
  42091. return oldValue.Phone, nil
  42092. }
  42093. // ResetPhone resets all changes to the "phone" field.
  42094. func (m *WxCardMutation) ResetPhone() {
  42095. m.phone = nil
  42096. }
  42097. // SetOfficialAccount sets the "official_account" field.
  42098. func (m *WxCardMutation) SetOfficialAccount(s string) {
  42099. m.official_account = &s
  42100. }
  42101. // OfficialAccount returns the value of the "official_account" field in the mutation.
  42102. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  42103. v := m.official_account
  42104. if v == nil {
  42105. return
  42106. }
  42107. return *v, true
  42108. }
  42109. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  42110. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42112. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  42113. if !m.op.Is(OpUpdateOne) {
  42114. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  42115. }
  42116. if m.id == nil || m.oldValue == nil {
  42117. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  42118. }
  42119. oldValue, err := m.oldValue(ctx)
  42120. if err != nil {
  42121. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  42122. }
  42123. return oldValue.OfficialAccount, nil
  42124. }
  42125. // ResetOfficialAccount resets all changes to the "official_account" field.
  42126. func (m *WxCardMutation) ResetOfficialAccount() {
  42127. m.official_account = nil
  42128. }
  42129. // SetWechatAccount sets the "wechat_account" field.
  42130. func (m *WxCardMutation) SetWechatAccount(s string) {
  42131. m.wechat_account = &s
  42132. }
  42133. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  42134. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  42135. v := m.wechat_account
  42136. if v == nil {
  42137. return
  42138. }
  42139. return *v, true
  42140. }
  42141. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  42142. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42144. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  42145. if !m.op.Is(OpUpdateOne) {
  42146. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  42147. }
  42148. if m.id == nil || m.oldValue == nil {
  42149. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  42150. }
  42151. oldValue, err := m.oldValue(ctx)
  42152. if err != nil {
  42153. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  42154. }
  42155. return oldValue.WechatAccount, nil
  42156. }
  42157. // ResetWechatAccount resets all changes to the "wechat_account" field.
  42158. func (m *WxCardMutation) ResetWechatAccount() {
  42159. m.wechat_account = nil
  42160. }
  42161. // SetEmail sets the "email" field.
  42162. func (m *WxCardMutation) SetEmail(s string) {
  42163. m.email = &s
  42164. }
  42165. // Email returns the value of the "email" field in the mutation.
  42166. func (m *WxCardMutation) Email() (r string, exists bool) {
  42167. v := m.email
  42168. if v == nil {
  42169. return
  42170. }
  42171. return *v, true
  42172. }
  42173. // OldEmail returns the old "email" field's value of the WxCard entity.
  42174. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42176. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  42177. if !m.op.Is(OpUpdateOne) {
  42178. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  42179. }
  42180. if m.id == nil || m.oldValue == nil {
  42181. return v, errors.New("OldEmail requires an ID field in the mutation")
  42182. }
  42183. oldValue, err := m.oldValue(ctx)
  42184. if err != nil {
  42185. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  42186. }
  42187. return oldValue.Email, nil
  42188. }
  42189. // ClearEmail clears the value of the "email" field.
  42190. func (m *WxCardMutation) ClearEmail() {
  42191. m.email = nil
  42192. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  42193. }
  42194. // EmailCleared returns if the "email" field was cleared in this mutation.
  42195. func (m *WxCardMutation) EmailCleared() bool {
  42196. _, ok := m.clearedFields[wxcard.FieldEmail]
  42197. return ok
  42198. }
  42199. // ResetEmail resets all changes to the "email" field.
  42200. func (m *WxCardMutation) ResetEmail() {
  42201. m.email = nil
  42202. delete(m.clearedFields, wxcard.FieldEmail)
  42203. }
  42204. // SetAPIBase sets the "api_base" field.
  42205. func (m *WxCardMutation) SetAPIBase(s string) {
  42206. m.api_base = &s
  42207. }
  42208. // APIBase returns the value of the "api_base" field in the mutation.
  42209. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  42210. v := m.api_base
  42211. if v == nil {
  42212. return
  42213. }
  42214. return *v, true
  42215. }
  42216. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  42217. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42219. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42220. if !m.op.Is(OpUpdateOne) {
  42221. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42222. }
  42223. if m.id == nil || m.oldValue == nil {
  42224. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42225. }
  42226. oldValue, err := m.oldValue(ctx)
  42227. if err != nil {
  42228. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42229. }
  42230. return oldValue.APIBase, nil
  42231. }
  42232. // ClearAPIBase clears the value of the "api_base" field.
  42233. func (m *WxCardMutation) ClearAPIBase() {
  42234. m.api_base = nil
  42235. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  42236. }
  42237. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42238. func (m *WxCardMutation) APIBaseCleared() bool {
  42239. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  42240. return ok
  42241. }
  42242. // ResetAPIBase resets all changes to the "api_base" field.
  42243. func (m *WxCardMutation) ResetAPIBase() {
  42244. m.api_base = nil
  42245. delete(m.clearedFields, wxcard.FieldAPIBase)
  42246. }
  42247. // SetAPIKey sets the "api_key" field.
  42248. func (m *WxCardMutation) SetAPIKey(s string) {
  42249. m.api_key = &s
  42250. }
  42251. // APIKey returns the value of the "api_key" field in the mutation.
  42252. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  42253. v := m.api_key
  42254. if v == nil {
  42255. return
  42256. }
  42257. return *v, true
  42258. }
  42259. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  42260. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42262. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42263. if !m.op.Is(OpUpdateOne) {
  42264. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42265. }
  42266. if m.id == nil || m.oldValue == nil {
  42267. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42268. }
  42269. oldValue, err := m.oldValue(ctx)
  42270. if err != nil {
  42271. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42272. }
  42273. return oldValue.APIKey, nil
  42274. }
  42275. // ClearAPIKey clears the value of the "api_key" field.
  42276. func (m *WxCardMutation) ClearAPIKey() {
  42277. m.api_key = nil
  42278. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  42279. }
  42280. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42281. func (m *WxCardMutation) APIKeyCleared() bool {
  42282. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  42283. return ok
  42284. }
  42285. // ResetAPIKey resets all changes to the "api_key" field.
  42286. func (m *WxCardMutation) ResetAPIKey() {
  42287. m.api_key = nil
  42288. delete(m.clearedFields, wxcard.FieldAPIKey)
  42289. }
  42290. // SetAiInfo sets the "ai_info" field.
  42291. func (m *WxCardMutation) SetAiInfo(s string) {
  42292. m.ai_info = &s
  42293. }
  42294. // AiInfo returns the value of the "ai_info" field in the mutation.
  42295. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  42296. v := m.ai_info
  42297. if v == nil {
  42298. return
  42299. }
  42300. return *v, true
  42301. }
  42302. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  42303. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42305. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  42306. if !m.op.Is(OpUpdateOne) {
  42307. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  42308. }
  42309. if m.id == nil || m.oldValue == nil {
  42310. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  42311. }
  42312. oldValue, err := m.oldValue(ctx)
  42313. if err != nil {
  42314. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  42315. }
  42316. return oldValue.AiInfo, nil
  42317. }
  42318. // ClearAiInfo clears the value of the "ai_info" field.
  42319. func (m *WxCardMutation) ClearAiInfo() {
  42320. m.ai_info = nil
  42321. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  42322. }
  42323. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  42324. func (m *WxCardMutation) AiInfoCleared() bool {
  42325. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  42326. return ok
  42327. }
  42328. // ResetAiInfo resets all changes to the "ai_info" field.
  42329. func (m *WxCardMutation) ResetAiInfo() {
  42330. m.ai_info = nil
  42331. delete(m.clearedFields, wxcard.FieldAiInfo)
  42332. }
  42333. // SetIntro sets the "intro" field.
  42334. func (m *WxCardMutation) SetIntro(s string) {
  42335. m.intro = &s
  42336. }
  42337. // Intro returns the value of the "intro" field in the mutation.
  42338. func (m *WxCardMutation) Intro() (r string, exists bool) {
  42339. v := m.intro
  42340. if v == nil {
  42341. return
  42342. }
  42343. return *v, true
  42344. }
  42345. // OldIntro returns the old "intro" field's value of the WxCard entity.
  42346. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  42347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42348. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  42349. if !m.op.Is(OpUpdateOne) {
  42350. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  42351. }
  42352. if m.id == nil || m.oldValue == nil {
  42353. return v, errors.New("OldIntro requires an ID field in the mutation")
  42354. }
  42355. oldValue, err := m.oldValue(ctx)
  42356. if err != nil {
  42357. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  42358. }
  42359. return oldValue.Intro, nil
  42360. }
  42361. // ClearIntro clears the value of the "intro" field.
  42362. func (m *WxCardMutation) ClearIntro() {
  42363. m.intro = nil
  42364. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  42365. }
  42366. // IntroCleared returns if the "intro" field was cleared in this mutation.
  42367. func (m *WxCardMutation) IntroCleared() bool {
  42368. _, ok := m.clearedFields[wxcard.FieldIntro]
  42369. return ok
  42370. }
  42371. // ResetIntro resets all changes to the "intro" field.
  42372. func (m *WxCardMutation) ResetIntro() {
  42373. m.intro = nil
  42374. delete(m.clearedFields, wxcard.FieldIntro)
  42375. }
  42376. // Where appends a list predicates to the WxCardMutation builder.
  42377. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  42378. m.predicates = append(m.predicates, ps...)
  42379. }
  42380. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  42381. // users can use type-assertion to append predicates that do not depend on any generated package.
  42382. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  42383. p := make([]predicate.WxCard, len(ps))
  42384. for i := range ps {
  42385. p[i] = ps[i]
  42386. }
  42387. m.Where(p...)
  42388. }
  42389. // Op returns the operation name.
  42390. func (m *WxCardMutation) Op() Op {
  42391. return m.op
  42392. }
  42393. // SetOp allows setting the mutation operation.
  42394. func (m *WxCardMutation) SetOp(op Op) {
  42395. m.op = op
  42396. }
  42397. // Type returns the node type of this mutation (WxCard).
  42398. func (m *WxCardMutation) Type() string {
  42399. return m.typ
  42400. }
  42401. // Fields returns all fields that were changed during this mutation. Note that in
  42402. // order to get all numeric fields that were incremented/decremented, call
  42403. // AddedFields().
  42404. func (m *WxCardMutation) Fields() []string {
  42405. fields := make([]string, 0, 18)
  42406. if m.created_at != nil {
  42407. fields = append(fields, wxcard.FieldCreatedAt)
  42408. }
  42409. if m.updated_at != nil {
  42410. fields = append(fields, wxcard.FieldUpdatedAt)
  42411. }
  42412. if m.deleted_at != nil {
  42413. fields = append(fields, wxcard.FieldDeletedAt)
  42414. }
  42415. if m.user_id != nil {
  42416. fields = append(fields, wxcard.FieldUserID)
  42417. }
  42418. if m.wx_user_id != nil {
  42419. fields = append(fields, wxcard.FieldWxUserID)
  42420. }
  42421. if m.avatar != nil {
  42422. fields = append(fields, wxcard.FieldAvatar)
  42423. }
  42424. if m.logo != nil {
  42425. fields = append(fields, wxcard.FieldLogo)
  42426. }
  42427. if m.name != nil {
  42428. fields = append(fields, wxcard.FieldName)
  42429. }
  42430. if m.company != nil {
  42431. fields = append(fields, wxcard.FieldCompany)
  42432. }
  42433. if m.address != nil {
  42434. fields = append(fields, wxcard.FieldAddress)
  42435. }
  42436. if m.phone != nil {
  42437. fields = append(fields, wxcard.FieldPhone)
  42438. }
  42439. if m.official_account != nil {
  42440. fields = append(fields, wxcard.FieldOfficialAccount)
  42441. }
  42442. if m.wechat_account != nil {
  42443. fields = append(fields, wxcard.FieldWechatAccount)
  42444. }
  42445. if m.email != nil {
  42446. fields = append(fields, wxcard.FieldEmail)
  42447. }
  42448. if m.api_base != nil {
  42449. fields = append(fields, wxcard.FieldAPIBase)
  42450. }
  42451. if m.api_key != nil {
  42452. fields = append(fields, wxcard.FieldAPIKey)
  42453. }
  42454. if m.ai_info != nil {
  42455. fields = append(fields, wxcard.FieldAiInfo)
  42456. }
  42457. if m.intro != nil {
  42458. fields = append(fields, wxcard.FieldIntro)
  42459. }
  42460. return fields
  42461. }
  42462. // Field returns the value of a field with the given name. The second boolean
  42463. // return value indicates that this field was not set, or was not defined in the
  42464. // schema.
  42465. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  42466. switch name {
  42467. case wxcard.FieldCreatedAt:
  42468. return m.CreatedAt()
  42469. case wxcard.FieldUpdatedAt:
  42470. return m.UpdatedAt()
  42471. case wxcard.FieldDeletedAt:
  42472. return m.DeletedAt()
  42473. case wxcard.FieldUserID:
  42474. return m.UserID()
  42475. case wxcard.FieldWxUserID:
  42476. return m.WxUserID()
  42477. case wxcard.FieldAvatar:
  42478. return m.Avatar()
  42479. case wxcard.FieldLogo:
  42480. return m.Logo()
  42481. case wxcard.FieldName:
  42482. return m.Name()
  42483. case wxcard.FieldCompany:
  42484. return m.Company()
  42485. case wxcard.FieldAddress:
  42486. return m.Address()
  42487. case wxcard.FieldPhone:
  42488. return m.Phone()
  42489. case wxcard.FieldOfficialAccount:
  42490. return m.OfficialAccount()
  42491. case wxcard.FieldWechatAccount:
  42492. return m.WechatAccount()
  42493. case wxcard.FieldEmail:
  42494. return m.Email()
  42495. case wxcard.FieldAPIBase:
  42496. return m.APIBase()
  42497. case wxcard.FieldAPIKey:
  42498. return m.APIKey()
  42499. case wxcard.FieldAiInfo:
  42500. return m.AiInfo()
  42501. case wxcard.FieldIntro:
  42502. return m.Intro()
  42503. }
  42504. return nil, false
  42505. }
  42506. // OldField returns the old value of the field from the database. An error is
  42507. // returned if the mutation operation is not UpdateOne, or the query to the
  42508. // database failed.
  42509. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42510. switch name {
  42511. case wxcard.FieldCreatedAt:
  42512. return m.OldCreatedAt(ctx)
  42513. case wxcard.FieldUpdatedAt:
  42514. return m.OldUpdatedAt(ctx)
  42515. case wxcard.FieldDeletedAt:
  42516. return m.OldDeletedAt(ctx)
  42517. case wxcard.FieldUserID:
  42518. return m.OldUserID(ctx)
  42519. case wxcard.FieldWxUserID:
  42520. return m.OldWxUserID(ctx)
  42521. case wxcard.FieldAvatar:
  42522. return m.OldAvatar(ctx)
  42523. case wxcard.FieldLogo:
  42524. return m.OldLogo(ctx)
  42525. case wxcard.FieldName:
  42526. return m.OldName(ctx)
  42527. case wxcard.FieldCompany:
  42528. return m.OldCompany(ctx)
  42529. case wxcard.FieldAddress:
  42530. return m.OldAddress(ctx)
  42531. case wxcard.FieldPhone:
  42532. return m.OldPhone(ctx)
  42533. case wxcard.FieldOfficialAccount:
  42534. return m.OldOfficialAccount(ctx)
  42535. case wxcard.FieldWechatAccount:
  42536. return m.OldWechatAccount(ctx)
  42537. case wxcard.FieldEmail:
  42538. return m.OldEmail(ctx)
  42539. case wxcard.FieldAPIBase:
  42540. return m.OldAPIBase(ctx)
  42541. case wxcard.FieldAPIKey:
  42542. return m.OldAPIKey(ctx)
  42543. case wxcard.FieldAiInfo:
  42544. return m.OldAiInfo(ctx)
  42545. case wxcard.FieldIntro:
  42546. return m.OldIntro(ctx)
  42547. }
  42548. return nil, fmt.Errorf("unknown WxCard field %s", name)
  42549. }
  42550. // SetField sets the value of a field with the given name. It returns an error if
  42551. // the field is not defined in the schema, or if the type mismatched the field
  42552. // type.
  42553. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  42554. switch name {
  42555. case wxcard.FieldCreatedAt:
  42556. v, ok := value.(time.Time)
  42557. if !ok {
  42558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42559. }
  42560. m.SetCreatedAt(v)
  42561. return nil
  42562. case wxcard.FieldUpdatedAt:
  42563. v, ok := value.(time.Time)
  42564. if !ok {
  42565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42566. }
  42567. m.SetUpdatedAt(v)
  42568. return nil
  42569. case wxcard.FieldDeletedAt:
  42570. v, ok := value.(time.Time)
  42571. if !ok {
  42572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42573. }
  42574. m.SetDeletedAt(v)
  42575. return nil
  42576. case wxcard.FieldUserID:
  42577. v, ok := value.(uint64)
  42578. if !ok {
  42579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42580. }
  42581. m.SetUserID(v)
  42582. return nil
  42583. case wxcard.FieldWxUserID:
  42584. v, ok := value.(uint64)
  42585. if !ok {
  42586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42587. }
  42588. m.SetWxUserID(v)
  42589. return nil
  42590. case wxcard.FieldAvatar:
  42591. v, ok := value.(string)
  42592. if !ok {
  42593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42594. }
  42595. m.SetAvatar(v)
  42596. return nil
  42597. case wxcard.FieldLogo:
  42598. v, ok := value.(string)
  42599. if !ok {
  42600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42601. }
  42602. m.SetLogo(v)
  42603. return nil
  42604. case wxcard.FieldName:
  42605. v, ok := value.(string)
  42606. if !ok {
  42607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42608. }
  42609. m.SetName(v)
  42610. return nil
  42611. case wxcard.FieldCompany:
  42612. v, ok := value.(string)
  42613. if !ok {
  42614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42615. }
  42616. m.SetCompany(v)
  42617. return nil
  42618. case wxcard.FieldAddress:
  42619. v, ok := value.(string)
  42620. if !ok {
  42621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42622. }
  42623. m.SetAddress(v)
  42624. return nil
  42625. case wxcard.FieldPhone:
  42626. v, ok := value.(string)
  42627. if !ok {
  42628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42629. }
  42630. m.SetPhone(v)
  42631. return nil
  42632. case wxcard.FieldOfficialAccount:
  42633. v, ok := value.(string)
  42634. if !ok {
  42635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42636. }
  42637. m.SetOfficialAccount(v)
  42638. return nil
  42639. case wxcard.FieldWechatAccount:
  42640. v, ok := value.(string)
  42641. if !ok {
  42642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42643. }
  42644. m.SetWechatAccount(v)
  42645. return nil
  42646. case wxcard.FieldEmail:
  42647. v, ok := value.(string)
  42648. if !ok {
  42649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42650. }
  42651. m.SetEmail(v)
  42652. return nil
  42653. case wxcard.FieldAPIBase:
  42654. v, ok := value.(string)
  42655. if !ok {
  42656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42657. }
  42658. m.SetAPIBase(v)
  42659. return nil
  42660. case wxcard.FieldAPIKey:
  42661. v, ok := value.(string)
  42662. if !ok {
  42663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42664. }
  42665. m.SetAPIKey(v)
  42666. return nil
  42667. case wxcard.FieldAiInfo:
  42668. v, ok := value.(string)
  42669. if !ok {
  42670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42671. }
  42672. m.SetAiInfo(v)
  42673. return nil
  42674. case wxcard.FieldIntro:
  42675. v, ok := value.(string)
  42676. if !ok {
  42677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42678. }
  42679. m.SetIntro(v)
  42680. return nil
  42681. }
  42682. return fmt.Errorf("unknown WxCard field %s", name)
  42683. }
  42684. // AddedFields returns all numeric fields that were incremented/decremented during
  42685. // this mutation.
  42686. func (m *WxCardMutation) AddedFields() []string {
  42687. var fields []string
  42688. if m.adduser_id != nil {
  42689. fields = append(fields, wxcard.FieldUserID)
  42690. }
  42691. if m.addwx_user_id != nil {
  42692. fields = append(fields, wxcard.FieldWxUserID)
  42693. }
  42694. return fields
  42695. }
  42696. // AddedField returns the numeric value that was incremented/decremented on a field
  42697. // with the given name. The second boolean return value indicates that this field
  42698. // was not set, or was not defined in the schema.
  42699. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  42700. switch name {
  42701. case wxcard.FieldUserID:
  42702. return m.AddedUserID()
  42703. case wxcard.FieldWxUserID:
  42704. return m.AddedWxUserID()
  42705. }
  42706. return nil, false
  42707. }
  42708. // AddField adds the value to the field with the given name. It returns an error if
  42709. // the field is not defined in the schema, or if the type mismatched the field
  42710. // type.
  42711. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  42712. switch name {
  42713. case wxcard.FieldUserID:
  42714. v, ok := value.(int64)
  42715. if !ok {
  42716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42717. }
  42718. m.AddUserID(v)
  42719. return nil
  42720. case wxcard.FieldWxUserID:
  42721. v, ok := value.(int64)
  42722. if !ok {
  42723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42724. }
  42725. m.AddWxUserID(v)
  42726. return nil
  42727. }
  42728. return fmt.Errorf("unknown WxCard numeric field %s", name)
  42729. }
  42730. // ClearedFields returns all nullable fields that were cleared during this
  42731. // mutation.
  42732. func (m *WxCardMutation) ClearedFields() []string {
  42733. var fields []string
  42734. if m.FieldCleared(wxcard.FieldDeletedAt) {
  42735. fields = append(fields, wxcard.FieldDeletedAt)
  42736. }
  42737. if m.FieldCleared(wxcard.FieldUserID) {
  42738. fields = append(fields, wxcard.FieldUserID)
  42739. }
  42740. if m.FieldCleared(wxcard.FieldWxUserID) {
  42741. fields = append(fields, wxcard.FieldWxUserID)
  42742. }
  42743. if m.FieldCleared(wxcard.FieldEmail) {
  42744. fields = append(fields, wxcard.FieldEmail)
  42745. }
  42746. if m.FieldCleared(wxcard.FieldAPIBase) {
  42747. fields = append(fields, wxcard.FieldAPIBase)
  42748. }
  42749. if m.FieldCleared(wxcard.FieldAPIKey) {
  42750. fields = append(fields, wxcard.FieldAPIKey)
  42751. }
  42752. if m.FieldCleared(wxcard.FieldAiInfo) {
  42753. fields = append(fields, wxcard.FieldAiInfo)
  42754. }
  42755. if m.FieldCleared(wxcard.FieldIntro) {
  42756. fields = append(fields, wxcard.FieldIntro)
  42757. }
  42758. return fields
  42759. }
  42760. // FieldCleared returns a boolean indicating if a field with the given name was
  42761. // cleared in this mutation.
  42762. func (m *WxCardMutation) FieldCleared(name string) bool {
  42763. _, ok := m.clearedFields[name]
  42764. return ok
  42765. }
  42766. // ClearField clears the value of the field with the given name. It returns an
  42767. // error if the field is not defined in the schema.
  42768. func (m *WxCardMutation) ClearField(name string) error {
  42769. switch name {
  42770. case wxcard.FieldDeletedAt:
  42771. m.ClearDeletedAt()
  42772. return nil
  42773. case wxcard.FieldUserID:
  42774. m.ClearUserID()
  42775. return nil
  42776. case wxcard.FieldWxUserID:
  42777. m.ClearWxUserID()
  42778. return nil
  42779. case wxcard.FieldEmail:
  42780. m.ClearEmail()
  42781. return nil
  42782. case wxcard.FieldAPIBase:
  42783. m.ClearAPIBase()
  42784. return nil
  42785. case wxcard.FieldAPIKey:
  42786. m.ClearAPIKey()
  42787. return nil
  42788. case wxcard.FieldAiInfo:
  42789. m.ClearAiInfo()
  42790. return nil
  42791. case wxcard.FieldIntro:
  42792. m.ClearIntro()
  42793. return nil
  42794. }
  42795. return fmt.Errorf("unknown WxCard nullable field %s", name)
  42796. }
  42797. // ResetField resets all changes in the mutation for the field with the given name.
  42798. // It returns an error if the field is not defined in the schema.
  42799. func (m *WxCardMutation) ResetField(name string) error {
  42800. switch name {
  42801. case wxcard.FieldCreatedAt:
  42802. m.ResetCreatedAt()
  42803. return nil
  42804. case wxcard.FieldUpdatedAt:
  42805. m.ResetUpdatedAt()
  42806. return nil
  42807. case wxcard.FieldDeletedAt:
  42808. m.ResetDeletedAt()
  42809. return nil
  42810. case wxcard.FieldUserID:
  42811. m.ResetUserID()
  42812. return nil
  42813. case wxcard.FieldWxUserID:
  42814. m.ResetWxUserID()
  42815. return nil
  42816. case wxcard.FieldAvatar:
  42817. m.ResetAvatar()
  42818. return nil
  42819. case wxcard.FieldLogo:
  42820. m.ResetLogo()
  42821. return nil
  42822. case wxcard.FieldName:
  42823. m.ResetName()
  42824. return nil
  42825. case wxcard.FieldCompany:
  42826. m.ResetCompany()
  42827. return nil
  42828. case wxcard.FieldAddress:
  42829. m.ResetAddress()
  42830. return nil
  42831. case wxcard.FieldPhone:
  42832. m.ResetPhone()
  42833. return nil
  42834. case wxcard.FieldOfficialAccount:
  42835. m.ResetOfficialAccount()
  42836. return nil
  42837. case wxcard.FieldWechatAccount:
  42838. m.ResetWechatAccount()
  42839. return nil
  42840. case wxcard.FieldEmail:
  42841. m.ResetEmail()
  42842. return nil
  42843. case wxcard.FieldAPIBase:
  42844. m.ResetAPIBase()
  42845. return nil
  42846. case wxcard.FieldAPIKey:
  42847. m.ResetAPIKey()
  42848. return nil
  42849. case wxcard.FieldAiInfo:
  42850. m.ResetAiInfo()
  42851. return nil
  42852. case wxcard.FieldIntro:
  42853. m.ResetIntro()
  42854. return nil
  42855. }
  42856. return fmt.Errorf("unknown WxCard field %s", name)
  42857. }
  42858. // AddedEdges returns all edge names that were set/added in this mutation.
  42859. func (m *WxCardMutation) AddedEdges() []string {
  42860. edges := make([]string, 0, 0)
  42861. return edges
  42862. }
  42863. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42864. // name in this mutation.
  42865. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  42866. return nil
  42867. }
  42868. // RemovedEdges returns all edge names that were removed in this mutation.
  42869. func (m *WxCardMutation) RemovedEdges() []string {
  42870. edges := make([]string, 0, 0)
  42871. return edges
  42872. }
  42873. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42874. // the given name in this mutation.
  42875. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  42876. return nil
  42877. }
  42878. // ClearedEdges returns all edge names that were cleared in this mutation.
  42879. func (m *WxCardMutation) ClearedEdges() []string {
  42880. edges := make([]string, 0, 0)
  42881. return edges
  42882. }
  42883. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42884. // was cleared in this mutation.
  42885. func (m *WxCardMutation) EdgeCleared(name string) bool {
  42886. return false
  42887. }
  42888. // ClearEdge clears the value of the edge with the given name. It returns an error
  42889. // if that edge is not defined in the schema.
  42890. func (m *WxCardMutation) ClearEdge(name string) error {
  42891. return fmt.Errorf("unknown WxCard unique edge %s", name)
  42892. }
  42893. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42894. // It returns an error if the edge is not defined in the schema.
  42895. func (m *WxCardMutation) ResetEdge(name string) error {
  42896. return fmt.Errorf("unknown WxCard edge %s", name)
  42897. }
  42898. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  42899. type WxCardUserMutation struct {
  42900. config
  42901. op Op
  42902. typ string
  42903. id *uint64
  42904. created_at *time.Time
  42905. updated_at *time.Time
  42906. deleted_at *time.Time
  42907. wxid *string
  42908. account *string
  42909. avatar *string
  42910. nickname *string
  42911. remark *string
  42912. phone *string
  42913. open_id *string
  42914. union_id *string
  42915. session_key *string
  42916. is_vip *int
  42917. addis_vip *int
  42918. clearedFields map[string]struct{}
  42919. done bool
  42920. oldValue func(context.Context) (*WxCardUser, error)
  42921. predicates []predicate.WxCardUser
  42922. }
  42923. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  42924. // wxcarduserOption allows management of the mutation configuration using functional options.
  42925. type wxcarduserOption func(*WxCardUserMutation)
  42926. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  42927. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  42928. m := &WxCardUserMutation{
  42929. config: c,
  42930. op: op,
  42931. typ: TypeWxCardUser,
  42932. clearedFields: make(map[string]struct{}),
  42933. }
  42934. for _, opt := range opts {
  42935. opt(m)
  42936. }
  42937. return m
  42938. }
  42939. // withWxCardUserID sets the ID field of the mutation.
  42940. func withWxCardUserID(id uint64) wxcarduserOption {
  42941. return func(m *WxCardUserMutation) {
  42942. var (
  42943. err error
  42944. once sync.Once
  42945. value *WxCardUser
  42946. )
  42947. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  42948. once.Do(func() {
  42949. if m.done {
  42950. err = errors.New("querying old values post mutation is not allowed")
  42951. } else {
  42952. value, err = m.Client().WxCardUser.Get(ctx, id)
  42953. }
  42954. })
  42955. return value, err
  42956. }
  42957. m.id = &id
  42958. }
  42959. }
  42960. // withWxCardUser sets the old WxCardUser of the mutation.
  42961. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  42962. return func(m *WxCardUserMutation) {
  42963. m.oldValue = func(context.Context) (*WxCardUser, error) {
  42964. return node, nil
  42965. }
  42966. m.id = &node.ID
  42967. }
  42968. }
  42969. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42970. // executed in a transaction (ent.Tx), a transactional client is returned.
  42971. func (m WxCardUserMutation) Client() *Client {
  42972. client := &Client{config: m.config}
  42973. client.init()
  42974. return client
  42975. }
  42976. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42977. // it returns an error otherwise.
  42978. func (m WxCardUserMutation) Tx() (*Tx, error) {
  42979. if _, ok := m.driver.(*txDriver); !ok {
  42980. return nil, errors.New("ent: mutation is not running in a transaction")
  42981. }
  42982. tx := &Tx{config: m.config}
  42983. tx.init()
  42984. return tx, nil
  42985. }
  42986. // SetID sets the value of the id field. Note that this
  42987. // operation is only accepted on creation of WxCardUser entities.
  42988. func (m *WxCardUserMutation) SetID(id uint64) {
  42989. m.id = &id
  42990. }
  42991. // ID returns the ID value in the mutation. Note that the ID is only available
  42992. // if it was provided to the builder or after it was returned from the database.
  42993. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  42994. if m.id == nil {
  42995. return
  42996. }
  42997. return *m.id, true
  42998. }
  42999. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43000. // That means, if the mutation is applied within a transaction with an isolation level such
  43001. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43002. // or updated by the mutation.
  43003. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  43004. switch {
  43005. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43006. id, exists := m.ID()
  43007. if exists {
  43008. return []uint64{id}, nil
  43009. }
  43010. fallthrough
  43011. case m.op.Is(OpUpdate | OpDelete):
  43012. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  43013. default:
  43014. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43015. }
  43016. }
  43017. // SetCreatedAt sets the "created_at" field.
  43018. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  43019. m.created_at = &t
  43020. }
  43021. // CreatedAt returns the value of the "created_at" field in the mutation.
  43022. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  43023. v := m.created_at
  43024. if v == nil {
  43025. return
  43026. }
  43027. return *v, true
  43028. }
  43029. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  43030. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43032. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43033. if !m.op.Is(OpUpdateOne) {
  43034. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43035. }
  43036. if m.id == nil || m.oldValue == nil {
  43037. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43038. }
  43039. oldValue, err := m.oldValue(ctx)
  43040. if err != nil {
  43041. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43042. }
  43043. return oldValue.CreatedAt, nil
  43044. }
  43045. // ResetCreatedAt resets all changes to the "created_at" field.
  43046. func (m *WxCardUserMutation) ResetCreatedAt() {
  43047. m.created_at = nil
  43048. }
  43049. // SetUpdatedAt sets the "updated_at" field.
  43050. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  43051. m.updated_at = &t
  43052. }
  43053. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43054. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  43055. v := m.updated_at
  43056. if v == nil {
  43057. return
  43058. }
  43059. return *v, true
  43060. }
  43061. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  43062. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43064. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43065. if !m.op.Is(OpUpdateOne) {
  43066. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43067. }
  43068. if m.id == nil || m.oldValue == nil {
  43069. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43070. }
  43071. oldValue, err := m.oldValue(ctx)
  43072. if err != nil {
  43073. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43074. }
  43075. return oldValue.UpdatedAt, nil
  43076. }
  43077. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43078. func (m *WxCardUserMutation) ResetUpdatedAt() {
  43079. m.updated_at = nil
  43080. }
  43081. // SetDeletedAt sets the "deleted_at" field.
  43082. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  43083. m.deleted_at = &t
  43084. }
  43085. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43086. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  43087. v := m.deleted_at
  43088. if v == nil {
  43089. return
  43090. }
  43091. return *v, true
  43092. }
  43093. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  43094. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43096. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43097. if !m.op.Is(OpUpdateOne) {
  43098. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43099. }
  43100. if m.id == nil || m.oldValue == nil {
  43101. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43102. }
  43103. oldValue, err := m.oldValue(ctx)
  43104. if err != nil {
  43105. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43106. }
  43107. return oldValue.DeletedAt, nil
  43108. }
  43109. // ClearDeletedAt clears the value of the "deleted_at" field.
  43110. func (m *WxCardUserMutation) ClearDeletedAt() {
  43111. m.deleted_at = nil
  43112. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  43113. }
  43114. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43115. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  43116. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  43117. return ok
  43118. }
  43119. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43120. func (m *WxCardUserMutation) ResetDeletedAt() {
  43121. m.deleted_at = nil
  43122. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  43123. }
  43124. // SetWxid sets the "wxid" field.
  43125. func (m *WxCardUserMutation) SetWxid(s string) {
  43126. m.wxid = &s
  43127. }
  43128. // Wxid returns the value of the "wxid" field in the mutation.
  43129. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  43130. v := m.wxid
  43131. if v == nil {
  43132. return
  43133. }
  43134. return *v, true
  43135. }
  43136. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  43137. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43139. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  43140. if !m.op.Is(OpUpdateOne) {
  43141. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  43142. }
  43143. if m.id == nil || m.oldValue == nil {
  43144. return v, errors.New("OldWxid requires an ID field in the mutation")
  43145. }
  43146. oldValue, err := m.oldValue(ctx)
  43147. if err != nil {
  43148. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  43149. }
  43150. return oldValue.Wxid, nil
  43151. }
  43152. // ResetWxid resets all changes to the "wxid" field.
  43153. func (m *WxCardUserMutation) ResetWxid() {
  43154. m.wxid = nil
  43155. }
  43156. // SetAccount sets the "account" field.
  43157. func (m *WxCardUserMutation) SetAccount(s string) {
  43158. m.account = &s
  43159. }
  43160. // Account returns the value of the "account" field in the mutation.
  43161. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  43162. v := m.account
  43163. if v == nil {
  43164. return
  43165. }
  43166. return *v, true
  43167. }
  43168. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  43169. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43171. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  43172. if !m.op.Is(OpUpdateOne) {
  43173. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  43174. }
  43175. if m.id == nil || m.oldValue == nil {
  43176. return v, errors.New("OldAccount requires an ID field in the mutation")
  43177. }
  43178. oldValue, err := m.oldValue(ctx)
  43179. if err != nil {
  43180. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  43181. }
  43182. return oldValue.Account, nil
  43183. }
  43184. // ResetAccount resets all changes to the "account" field.
  43185. func (m *WxCardUserMutation) ResetAccount() {
  43186. m.account = nil
  43187. }
  43188. // SetAvatar sets the "avatar" field.
  43189. func (m *WxCardUserMutation) SetAvatar(s string) {
  43190. m.avatar = &s
  43191. }
  43192. // Avatar returns the value of the "avatar" field in the mutation.
  43193. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  43194. v := m.avatar
  43195. if v == nil {
  43196. return
  43197. }
  43198. return *v, true
  43199. }
  43200. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  43201. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43203. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43204. if !m.op.Is(OpUpdateOne) {
  43205. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43206. }
  43207. if m.id == nil || m.oldValue == nil {
  43208. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43209. }
  43210. oldValue, err := m.oldValue(ctx)
  43211. if err != nil {
  43212. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43213. }
  43214. return oldValue.Avatar, nil
  43215. }
  43216. // ResetAvatar resets all changes to the "avatar" field.
  43217. func (m *WxCardUserMutation) ResetAvatar() {
  43218. m.avatar = nil
  43219. }
  43220. // SetNickname sets the "nickname" field.
  43221. func (m *WxCardUserMutation) SetNickname(s string) {
  43222. m.nickname = &s
  43223. }
  43224. // Nickname returns the value of the "nickname" field in the mutation.
  43225. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  43226. v := m.nickname
  43227. if v == nil {
  43228. return
  43229. }
  43230. return *v, true
  43231. }
  43232. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  43233. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43235. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  43236. if !m.op.Is(OpUpdateOne) {
  43237. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  43238. }
  43239. if m.id == nil || m.oldValue == nil {
  43240. return v, errors.New("OldNickname requires an ID field in the mutation")
  43241. }
  43242. oldValue, err := m.oldValue(ctx)
  43243. if err != nil {
  43244. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  43245. }
  43246. return oldValue.Nickname, nil
  43247. }
  43248. // ResetNickname resets all changes to the "nickname" field.
  43249. func (m *WxCardUserMutation) ResetNickname() {
  43250. m.nickname = nil
  43251. }
  43252. // SetRemark sets the "remark" field.
  43253. func (m *WxCardUserMutation) SetRemark(s string) {
  43254. m.remark = &s
  43255. }
  43256. // Remark returns the value of the "remark" field in the mutation.
  43257. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  43258. v := m.remark
  43259. if v == nil {
  43260. return
  43261. }
  43262. return *v, true
  43263. }
  43264. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  43265. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43267. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  43268. if !m.op.Is(OpUpdateOne) {
  43269. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  43270. }
  43271. if m.id == nil || m.oldValue == nil {
  43272. return v, errors.New("OldRemark requires an ID field in the mutation")
  43273. }
  43274. oldValue, err := m.oldValue(ctx)
  43275. if err != nil {
  43276. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  43277. }
  43278. return oldValue.Remark, nil
  43279. }
  43280. // ResetRemark resets all changes to the "remark" field.
  43281. func (m *WxCardUserMutation) ResetRemark() {
  43282. m.remark = nil
  43283. }
  43284. // SetPhone sets the "phone" field.
  43285. func (m *WxCardUserMutation) SetPhone(s string) {
  43286. m.phone = &s
  43287. }
  43288. // Phone returns the value of the "phone" field in the mutation.
  43289. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  43290. v := m.phone
  43291. if v == nil {
  43292. return
  43293. }
  43294. return *v, true
  43295. }
  43296. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  43297. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43299. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  43300. if !m.op.Is(OpUpdateOne) {
  43301. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43302. }
  43303. if m.id == nil || m.oldValue == nil {
  43304. return v, errors.New("OldPhone requires an ID field in the mutation")
  43305. }
  43306. oldValue, err := m.oldValue(ctx)
  43307. if err != nil {
  43308. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43309. }
  43310. return oldValue.Phone, nil
  43311. }
  43312. // ResetPhone resets all changes to the "phone" field.
  43313. func (m *WxCardUserMutation) ResetPhone() {
  43314. m.phone = nil
  43315. }
  43316. // SetOpenID sets the "open_id" field.
  43317. func (m *WxCardUserMutation) SetOpenID(s string) {
  43318. m.open_id = &s
  43319. }
  43320. // OpenID returns the value of the "open_id" field in the mutation.
  43321. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  43322. v := m.open_id
  43323. if v == nil {
  43324. return
  43325. }
  43326. return *v, true
  43327. }
  43328. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  43329. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43331. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  43332. if !m.op.Is(OpUpdateOne) {
  43333. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  43334. }
  43335. if m.id == nil || m.oldValue == nil {
  43336. return v, errors.New("OldOpenID requires an ID field in the mutation")
  43337. }
  43338. oldValue, err := m.oldValue(ctx)
  43339. if err != nil {
  43340. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  43341. }
  43342. return oldValue.OpenID, nil
  43343. }
  43344. // ResetOpenID resets all changes to the "open_id" field.
  43345. func (m *WxCardUserMutation) ResetOpenID() {
  43346. m.open_id = nil
  43347. }
  43348. // SetUnionID sets the "union_id" field.
  43349. func (m *WxCardUserMutation) SetUnionID(s string) {
  43350. m.union_id = &s
  43351. }
  43352. // UnionID returns the value of the "union_id" field in the mutation.
  43353. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  43354. v := m.union_id
  43355. if v == nil {
  43356. return
  43357. }
  43358. return *v, true
  43359. }
  43360. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  43361. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43363. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  43364. if !m.op.Is(OpUpdateOne) {
  43365. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  43366. }
  43367. if m.id == nil || m.oldValue == nil {
  43368. return v, errors.New("OldUnionID requires an ID field in the mutation")
  43369. }
  43370. oldValue, err := m.oldValue(ctx)
  43371. if err != nil {
  43372. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  43373. }
  43374. return oldValue.UnionID, nil
  43375. }
  43376. // ResetUnionID resets all changes to the "union_id" field.
  43377. func (m *WxCardUserMutation) ResetUnionID() {
  43378. m.union_id = nil
  43379. }
  43380. // SetSessionKey sets the "session_key" field.
  43381. func (m *WxCardUserMutation) SetSessionKey(s string) {
  43382. m.session_key = &s
  43383. }
  43384. // SessionKey returns the value of the "session_key" field in the mutation.
  43385. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  43386. v := m.session_key
  43387. if v == nil {
  43388. return
  43389. }
  43390. return *v, true
  43391. }
  43392. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  43393. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43395. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  43396. if !m.op.Is(OpUpdateOne) {
  43397. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  43398. }
  43399. if m.id == nil || m.oldValue == nil {
  43400. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  43401. }
  43402. oldValue, err := m.oldValue(ctx)
  43403. if err != nil {
  43404. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  43405. }
  43406. return oldValue.SessionKey, nil
  43407. }
  43408. // ResetSessionKey resets all changes to the "session_key" field.
  43409. func (m *WxCardUserMutation) ResetSessionKey() {
  43410. m.session_key = nil
  43411. }
  43412. // SetIsVip sets the "is_vip" field.
  43413. func (m *WxCardUserMutation) SetIsVip(i int) {
  43414. m.is_vip = &i
  43415. m.addis_vip = nil
  43416. }
  43417. // IsVip returns the value of the "is_vip" field in the mutation.
  43418. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  43419. v := m.is_vip
  43420. if v == nil {
  43421. return
  43422. }
  43423. return *v, true
  43424. }
  43425. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  43426. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  43427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43428. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  43429. if !m.op.Is(OpUpdateOne) {
  43430. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  43431. }
  43432. if m.id == nil || m.oldValue == nil {
  43433. return v, errors.New("OldIsVip requires an ID field in the mutation")
  43434. }
  43435. oldValue, err := m.oldValue(ctx)
  43436. if err != nil {
  43437. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  43438. }
  43439. return oldValue.IsVip, nil
  43440. }
  43441. // AddIsVip adds i to the "is_vip" field.
  43442. func (m *WxCardUserMutation) AddIsVip(i int) {
  43443. if m.addis_vip != nil {
  43444. *m.addis_vip += i
  43445. } else {
  43446. m.addis_vip = &i
  43447. }
  43448. }
  43449. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  43450. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  43451. v := m.addis_vip
  43452. if v == nil {
  43453. return
  43454. }
  43455. return *v, true
  43456. }
  43457. // ResetIsVip resets all changes to the "is_vip" field.
  43458. func (m *WxCardUserMutation) ResetIsVip() {
  43459. m.is_vip = nil
  43460. m.addis_vip = nil
  43461. }
  43462. // Where appends a list predicates to the WxCardUserMutation builder.
  43463. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  43464. m.predicates = append(m.predicates, ps...)
  43465. }
  43466. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  43467. // users can use type-assertion to append predicates that do not depend on any generated package.
  43468. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  43469. p := make([]predicate.WxCardUser, len(ps))
  43470. for i := range ps {
  43471. p[i] = ps[i]
  43472. }
  43473. m.Where(p...)
  43474. }
  43475. // Op returns the operation name.
  43476. func (m *WxCardUserMutation) Op() Op {
  43477. return m.op
  43478. }
  43479. // SetOp allows setting the mutation operation.
  43480. func (m *WxCardUserMutation) SetOp(op Op) {
  43481. m.op = op
  43482. }
  43483. // Type returns the node type of this mutation (WxCardUser).
  43484. func (m *WxCardUserMutation) Type() string {
  43485. return m.typ
  43486. }
  43487. // Fields returns all fields that were changed during this mutation. Note that in
  43488. // order to get all numeric fields that were incremented/decremented, call
  43489. // AddedFields().
  43490. func (m *WxCardUserMutation) Fields() []string {
  43491. fields := make([]string, 0, 13)
  43492. if m.created_at != nil {
  43493. fields = append(fields, wxcarduser.FieldCreatedAt)
  43494. }
  43495. if m.updated_at != nil {
  43496. fields = append(fields, wxcarduser.FieldUpdatedAt)
  43497. }
  43498. if m.deleted_at != nil {
  43499. fields = append(fields, wxcarduser.FieldDeletedAt)
  43500. }
  43501. if m.wxid != nil {
  43502. fields = append(fields, wxcarduser.FieldWxid)
  43503. }
  43504. if m.account != nil {
  43505. fields = append(fields, wxcarduser.FieldAccount)
  43506. }
  43507. if m.avatar != nil {
  43508. fields = append(fields, wxcarduser.FieldAvatar)
  43509. }
  43510. if m.nickname != nil {
  43511. fields = append(fields, wxcarduser.FieldNickname)
  43512. }
  43513. if m.remark != nil {
  43514. fields = append(fields, wxcarduser.FieldRemark)
  43515. }
  43516. if m.phone != nil {
  43517. fields = append(fields, wxcarduser.FieldPhone)
  43518. }
  43519. if m.open_id != nil {
  43520. fields = append(fields, wxcarduser.FieldOpenID)
  43521. }
  43522. if m.union_id != nil {
  43523. fields = append(fields, wxcarduser.FieldUnionID)
  43524. }
  43525. if m.session_key != nil {
  43526. fields = append(fields, wxcarduser.FieldSessionKey)
  43527. }
  43528. if m.is_vip != nil {
  43529. fields = append(fields, wxcarduser.FieldIsVip)
  43530. }
  43531. return fields
  43532. }
  43533. // Field returns the value of a field with the given name. The second boolean
  43534. // return value indicates that this field was not set, or was not defined in the
  43535. // schema.
  43536. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  43537. switch name {
  43538. case wxcarduser.FieldCreatedAt:
  43539. return m.CreatedAt()
  43540. case wxcarduser.FieldUpdatedAt:
  43541. return m.UpdatedAt()
  43542. case wxcarduser.FieldDeletedAt:
  43543. return m.DeletedAt()
  43544. case wxcarduser.FieldWxid:
  43545. return m.Wxid()
  43546. case wxcarduser.FieldAccount:
  43547. return m.Account()
  43548. case wxcarduser.FieldAvatar:
  43549. return m.Avatar()
  43550. case wxcarduser.FieldNickname:
  43551. return m.Nickname()
  43552. case wxcarduser.FieldRemark:
  43553. return m.Remark()
  43554. case wxcarduser.FieldPhone:
  43555. return m.Phone()
  43556. case wxcarduser.FieldOpenID:
  43557. return m.OpenID()
  43558. case wxcarduser.FieldUnionID:
  43559. return m.UnionID()
  43560. case wxcarduser.FieldSessionKey:
  43561. return m.SessionKey()
  43562. case wxcarduser.FieldIsVip:
  43563. return m.IsVip()
  43564. }
  43565. return nil, false
  43566. }
  43567. // OldField returns the old value of the field from the database. An error is
  43568. // returned if the mutation operation is not UpdateOne, or the query to the
  43569. // database failed.
  43570. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43571. switch name {
  43572. case wxcarduser.FieldCreatedAt:
  43573. return m.OldCreatedAt(ctx)
  43574. case wxcarduser.FieldUpdatedAt:
  43575. return m.OldUpdatedAt(ctx)
  43576. case wxcarduser.FieldDeletedAt:
  43577. return m.OldDeletedAt(ctx)
  43578. case wxcarduser.FieldWxid:
  43579. return m.OldWxid(ctx)
  43580. case wxcarduser.FieldAccount:
  43581. return m.OldAccount(ctx)
  43582. case wxcarduser.FieldAvatar:
  43583. return m.OldAvatar(ctx)
  43584. case wxcarduser.FieldNickname:
  43585. return m.OldNickname(ctx)
  43586. case wxcarduser.FieldRemark:
  43587. return m.OldRemark(ctx)
  43588. case wxcarduser.FieldPhone:
  43589. return m.OldPhone(ctx)
  43590. case wxcarduser.FieldOpenID:
  43591. return m.OldOpenID(ctx)
  43592. case wxcarduser.FieldUnionID:
  43593. return m.OldUnionID(ctx)
  43594. case wxcarduser.FieldSessionKey:
  43595. return m.OldSessionKey(ctx)
  43596. case wxcarduser.FieldIsVip:
  43597. return m.OldIsVip(ctx)
  43598. }
  43599. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  43600. }
  43601. // SetField sets the value of a field with the given name. It returns an error if
  43602. // the field is not defined in the schema, or if the type mismatched the field
  43603. // type.
  43604. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  43605. switch name {
  43606. case wxcarduser.FieldCreatedAt:
  43607. v, ok := value.(time.Time)
  43608. if !ok {
  43609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43610. }
  43611. m.SetCreatedAt(v)
  43612. return nil
  43613. case wxcarduser.FieldUpdatedAt:
  43614. v, ok := value.(time.Time)
  43615. if !ok {
  43616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43617. }
  43618. m.SetUpdatedAt(v)
  43619. return nil
  43620. case wxcarduser.FieldDeletedAt:
  43621. v, ok := value.(time.Time)
  43622. if !ok {
  43623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43624. }
  43625. m.SetDeletedAt(v)
  43626. return nil
  43627. case wxcarduser.FieldWxid:
  43628. v, ok := value.(string)
  43629. if !ok {
  43630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43631. }
  43632. m.SetWxid(v)
  43633. return nil
  43634. case wxcarduser.FieldAccount:
  43635. v, ok := value.(string)
  43636. if !ok {
  43637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43638. }
  43639. m.SetAccount(v)
  43640. return nil
  43641. case wxcarduser.FieldAvatar:
  43642. v, ok := value.(string)
  43643. if !ok {
  43644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43645. }
  43646. m.SetAvatar(v)
  43647. return nil
  43648. case wxcarduser.FieldNickname:
  43649. v, ok := value.(string)
  43650. if !ok {
  43651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43652. }
  43653. m.SetNickname(v)
  43654. return nil
  43655. case wxcarduser.FieldRemark:
  43656. v, ok := value.(string)
  43657. if !ok {
  43658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43659. }
  43660. m.SetRemark(v)
  43661. return nil
  43662. case wxcarduser.FieldPhone:
  43663. v, ok := value.(string)
  43664. if !ok {
  43665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43666. }
  43667. m.SetPhone(v)
  43668. return nil
  43669. case wxcarduser.FieldOpenID:
  43670. v, ok := value.(string)
  43671. if !ok {
  43672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43673. }
  43674. m.SetOpenID(v)
  43675. return nil
  43676. case wxcarduser.FieldUnionID:
  43677. v, ok := value.(string)
  43678. if !ok {
  43679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43680. }
  43681. m.SetUnionID(v)
  43682. return nil
  43683. case wxcarduser.FieldSessionKey:
  43684. v, ok := value.(string)
  43685. if !ok {
  43686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43687. }
  43688. m.SetSessionKey(v)
  43689. return nil
  43690. case wxcarduser.FieldIsVip:
  43691. v, ok := value.(int)
  43692. if !ok {
  43693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43694. }
  43695. m.SetIsVip(v)
  43696. return nil
  43697. }
  43698. return fmt.Errorf("unknown WxCardUser field %s", name)
  43699. }
  43700. // AddedFields returns all numeric fields that were incremented/decremented during
  43701. // this mutation.
  43702. func (m *WxCardUserMutation) AddedFields() []string {
  43703. var fields []string
  43704. if m.addis_vip != nil {
  43705. fields = append(fields, wxcarduser.FieldIsVip)
  43706. }
  43707. return fields
  43708. }
  43709. // AddedField returns the numeric value that was incremented/decremented on a field
  43710. // with the given name. The second boolean return value indicates that this field
  43711. // was not set, or was not defined in the schema.
  43712. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  43713. switch name {
  43714. case wxcarduser.FieldIsVip:
  43715. return m.AddedIsVip()
  43716. }
  43717. return nil, false
  43718. }
  43719. // AddField adds the value to the field with the given name. It returns an error if
  43720. // the field is not defined in the schema, or if the type mismatched the field
  43721. // type.
  43722. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  43723. switch name {
  43724. case wxcarduser.FieldIsVip:
  43725. v, ok := value.(int)
  43726. if !ok {
  43727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43728. }
  43729. m.AddIsVip(v)
  43730. return nil
  43731. }
  43732. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  43733. }
  43734. // ClearedFields returns all nullable fields that were cleared during this
  43735. // mutation.
  43736. func (m *WxCardUserMutation) ClearedFields() []string {
  43737. var fields []string
  43738. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  43739. fields = append(fields, wxcarduser.FieldDeletedAt)
  43740. }
  43741. return fields
  43742. }
  43743. // FieldCleared returns a boolean indicating if a field with the given name was
  43744. // cleared in this mutation.
  43745. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  43746. _, ok := m.clearedFields[name]
  43747. return ok
  43748. }
  43749. // ClearField clears the value of the field with the given name. It returns an
  43750. // error if the field is not defined in the schema.
  43751. func (m *WxCardUserMutation) ClearField(name string) error {
  43752. switch name {
  43753. case wxcarduser.FieldDeletedAt:
  43754. m.ClearDeletedAt()
  43755. return nil
  43756. }
  43757. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  43758. }
  43759. // ResetField resets all changes in the mutation for the field with the given name.
  43760. // It returns an error if the field is not defined in the schema.
  43761. func (m *WxCardUserMutation) ResetField(name string) error {
  43762. switch name {
  43763. case wxcarduser.FieldCreatedAt:
  43764. m.ResetCreatedAt()
  43765. return nil
  43766. case wxcarduser.FieldUpdatedAt:
  43767. m.ResetUpdatedAt()
  43768. return nil
  43769. case wxcarduser.FieldDeletedAt:
  43770. m.ResetDeletedAt()
  43771. return nil
  43772. case wxcarduser.FieldWxid:
  43773. m.ResetWxid()
  43774. return nil
  43775. case wxcarduser.FieldAccount:
  43776. m.ResetAccount()
  43777. return nil
  43778. case wxcarduser.FieldAvatar:
  43779. m.ResetAvatar()
  43780. return nil
  43781. case wxcarduser.FieldNickname:
  43782. m.ResetNickname()
  43783. return nil
  43784. case wxcarduser.FieldRemark:
  43785. m.ResetRemark()
  43786. return nil
  43787. case wxcarduser.FieldPhone:
  43788. m.ResetPhone()
  43789. return nil
  43790. case wxcarduser.FieldOpenID:
  43791. m.ResetOpenID()
  43792. return nil
  43793. case wxcarduser.FieldUnionID:
  43794. m.ResetUnionID()
  43795. return nil
  43796. case wxcarduser.FieldSessionKey:
  43797. m.ResetSessionKey()
  43798. return nil
  43799. case wxcarduser.FieldIsVip:
  43800. m.ResetIsVip()
  43801. return nil
  43802. }
  43803. return fmt.Errorf("unknown WxCardUser field %s", name)
  43804. }
  43805. // AddedEdges returns all edge names that were set/added in this mutation.
  43806. func (m *WxCardUserMutation) AddedEdges() []string {
  43807. edges := make([]string, 0, 0)
  43808. return edges
  43809. }
  43810. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43811. // name in this mutation.
  43812. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  43813. return nil
  43814. }
  43815. // RemovedEdges returns all edge names that were removed in this mutation.
  43816. func (m *WxCardUserMutation) RemovedEdges() []string {
  43817. edges := make([]string, 0, 0)
  43818. return edges
  43819. }
  43820. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43821. // the given name in this mutation.
  43822. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  43823. return nil
  43824. }
  43825. // ClearedEdges returns all edge names that were cleared in this mutation.
  43826. func (m *WxCardUserMutation) ClearedEdges() []string {
  43827. edges := make([]string, 0, 0)
  43828. return edges
  43829. }
  43830. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43831. // was cleared in this mutation.
  43832. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  43833. return false
  43834. }
  43835. // ClearEdge clears the value of the edge with the given name. It returns an error
  43836. // if that edge is not defined in the schema.
  43837. func (m *WxCardUserMutation) ClearEdge(name string) error {
  43838. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  43839. }
  43840. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43841. // It returns an error if the edge is not defined in the schema.
  43842. func (m *WxCardUserMutation) ResetEdge(name string) error {
  43843. return fmt.Errorf("unknown WxCardUser edge %s", name)
  43844. }
  43845. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  43846. type WxCardVisitMutation struct {
  43847. config
  43848. op Op
  43849. typ string
  43850. id *uint64
  43851. created_at *time.Time
  43852. updated_at *time.Time
  43853. deleted_at *time.Time
  43854. user_id *uint64
  43855. adduser_id *int64
  43856. bot_id *uint64
  43857. addbot_id *int64
  43858. bot_type *uint8
  43859. addbot_type *int8
  43860. clearedFields map[string]struct{}
  43861. done bool
  43862. oldValue func(context.Context) (*WxCardVisit, error)
  43863. predicates []predicate.WxCardVisit
  43864. }
  43865. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  43866. // wxcardvisitOption allows management of the mutation configuration using functional options.
  43867. type wxcardvisitOption func(*WxCardVisitMutation)
  43868. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  43869. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  43870. m := &WxCardVisitMutation{
  43871. config: c,
  43872. op: op,
  43873. typ: TypeWxCardVisit,
  43874. clearedFields: make(map[string]struct{}),
  43875. }
  43876. for _, opt := range opts {
  43877. opt(m)
  43878. }
  43879. return m
  43880. }
  43881. // withWxCardVisitID sets the ID field of the mutation.
  43882. func withWxCardVisitID(id uint64) wxcardvisitOption {
  43883. return func(m *WxCardVisitMutation) {
  43884. var (
  43885. err error
  43886. once sync.Once
  43887. value *WxCardVisit
  43888. )
  43889. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  43890. once.Do(func() {
  43891. if m.done {
  43892. err = errors.New("querying old values post mutation is not allowed")
  43893. } else {
  43894. value, err = m.Client().WxCardVisit.Get(ctx, id)
  43895. }
  43896. })
  43897. return value, err
  43898. }
  43899. m.id = &id
  43900. }
  43901. }
  43902. // withWxCardVisit sets the old WxCardVisit of the mutation.
  43903. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  43904. return func(m *WxCardVisitMutation) {
  43905. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  43906. return node, nil
  43907. }
  43908. m.id = &node.ID
  43909. }
  43910. }
  43911. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43912. // executed in a transaction (ent.Tx), a transactional client is returned.
  43913. func (m WxCardVisitMutation) Client() *Client {
  43914. client := &Client{config: m.config}
  43915. client.init()
  43916. return client
  43917. }
  43918. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43919. // it returns an error otherwise.
  43920. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  43921. if _, ok := m.driver.(*txDriver); !ok {
  43922. return nil, errors.New("ent: mutation is not running in a transaction")
  43923. }
  43924. tx := &Tx{config: m.config}
  43925. tx.init()
  43926. return tx, nil
  43927. }
  43928. // SetID sets the value of the id field. Note that this
  43929. // operation is only accepted on creation of WxCardVisit entities.
  43930. func (m *WxCardVisitMutation) SetID(id uint64) {
  43931. m.id = &id
  43932. }
  43933. // ID returns the ID value in the mutation. Note that the ID is only available
  43934. // if it was provided to the builder or after it was returned from the database.
  43935. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  43936. if m.id == nil {
  43937. return
  43938. }
  43939. return *m.id, true
  43940. }
  43941. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43942. // That means, if the mutation is applied within a transaction with an isolation level such
  43943. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43944. // or updated by the mutation.
  43945. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  43946. switch {
  43947. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43948. id, exists := m.ID()
  43949. if exists {
  43950. return []uint64{id}, nil
  43951. }
  43952. fallthrough
  43953. case m.op.Is(OpUpdate | OpDelete):
  43954. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  43955. default:
  43956. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43957. }
  43958. }
  43959. // SetCreatedAt sets the "created_at" field.
  43960. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  43961. m.created_at = &t
  43962. }
  43963. // CreatedAt returns the value of the "created_at" field in the mutation.
  43964. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  43965. v := m.created_at
  43966. if v == nil {
  43967. return
  43968. }
  43969. return *v, true
  43970. }
  43971. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  43972. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  43973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43974. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43975. if !m.op.Is(OpUpdateOne) {
  43976. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43977. }
  43978. if m.id == nil || m.oldValue == nil {
  43979. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43980. }
  43981. oldValue, err := m.oldValue(ctx)
  43982. if err != nil {
  43983. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43984. }
  43985. return oldValue.CreatedAt, nil
  43986. }
  43987. // ResetCreatedAt resets all changes to the "created_at" field.
  43988. func (m *WxCardVisitMutation) ResetCreatedAt() {
  43989. m.created_at = nil
  43990. }
  43991. // SetUpdatedAt sets the "updated_at" field.
  43992. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  43993. m.updated_at = &t
  43994. }
  43995. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43996. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  43997. v := m.updated_at
  43998. if v == nil {
  43999. return
  44000. }
  44001. return *v, true
  44002. }
  44003. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  44004. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44006. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44007. if !m.op.Is(OpUpdateOne) {
  44008. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44009. }
  44010. if m.id == nil || m.oldValue == nil {
  44011. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44012. }
  44013. oldValue, err := m.oldValue(ctx)
  44014. if err != nil {
  44015. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44016. }
  44017. return oldValue.UpdatedAt, nil
  44018. }
  44019. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44020. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  44021. m.updated_at = nil
  44022. }
  44023. // SetDeletedAt sets the "deleted_at" field.
  44024. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  44025. m.deleted_at = &t
  44026. }
  44027. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44028. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  44029. v := m.deleted_at
  44030. if v == nil {
  44031. return
  44032. }
  44033. return *v, true
  44034. }
  44035. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  44036. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44038. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44039. if !m.op.Is(OpUpdateOne) {
  44040. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44041. }
  44042. if m.id == nil || m.oldValue == nil {
  44043. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44044. }
  44045. oldValue, err := m.oldValue(ctx)
  44046. if err != nil {
  44047. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44048. }
  44049. return oldValue.DeletedAt, nil
  44050. }
  44051. // ClearDeletedAt clears the value of the "deleted_at" field.
  44052. func (m *WxCardVisitMutation) ClearDeletedAt() {
  44053. m.deleted_at = nil
  44054. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  44055. }
  44056. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44057. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  44058. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  44059. return ok
  44060. }
  44061. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44062. func (m *WxCardVisitMutation) ResetDeletedAt() {
  44063. m.deleted_at = nil
  44064. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  44065. }
  44066. // SetUserID sets the "user_id" field.
  44067. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  44068. m.user_id = &u
  44069. m.adduser_id = nil
  44070. }
  44071. // UserID returns the value of the "user_id" field in the mutation.
  44072. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  44073. v := m.user_id
  44074. if v == nil {
  44075. return
  44076. }
  44077. return *v, true
  44078. }
  44079. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  44080. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44082. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  44083. if !m.op.Is(OpUpdateOne) {
  44084. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  44085. }
  44086. if m.id == nil || m.oldValue == nil {
  44087. return v, errors.New("OldUserID requires an ID field in the mutation")
  44088. }
  44089. oldValue, err := m.oldValue(ctx)
  44090. if err != nil {
  44091. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  44092. }
  44093. return oldValue.UserID, nil
  44094. }
  44095. // AddUserID adds u to the "user_id" field.
  44096. func (m *WxCardVisitMutation) AddUserID(u int64) {
  44097. if m.adduser_id != nil {
  44098. *m.adduser_id += u
  44099. } else {
  44100. m.adduser_id = &u
  44101. }
  44102. }
  44103. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  44104. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  44105. v := m.adduser_id
  44106. if v == nil {
  44107. return
  44108. }
  44109. return *v, true
  44110. }
  44111. // ClearUserID clears the value of the "user_id" field.
  44112. func (m *WxCardVisitMutation) ClearUserID() {
  44113. m.user_id = nil
  44114. m.adduser_id = nil
  44115. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  44116. }
  44117. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  44118. func (m *WxCardVisitMutation) UserIDCleared() bool {
  44119. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  44120. return ok
  44121. }
  44122. // ResetUserID resets all changes to the "user_id" field.
  44123. func (m *WxCardVisitMutation) ResetUserID() {
  44124. m.user_id = nil
  44125. m.adduser_id = nil
  44126. delete(m.clearedFields, wxcardvisit.FieldUserID)
  44127. }
  44128. // SetBotID sets the "bot_id" field.
  44129. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  44130. m.bot_id = &u
  44131. m.addbot_id = nil
  44132. }
  44133. // BotID returns the value of the "bot_id" field in the mutation.
  44134. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  44135. v := m.bot_id
  44136. if v == nil {
  44137. return
  44138. }
  44139. return *v, true
  44140. }
  44141. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  44142. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44144. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  44145. if !m.op.Is(OpUpdateOne) {
  44146. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  44147. }
  44148. if m.id == nil || m.oldValue == nil {
  44149. return v, errors.New("OldBotID requires an ID field in the mutation")
  44150. }
  44151. oldValue, err := m.oldValue(ctx)
  44152. if err != nil {
  44153. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  44154. }
  44155. return oldValue.BotID, nil
  44156. }
  44157. // AddBotID adds u to the "bot_id" field.
  44158. func (m *WxCardVisitMutation) AddBotID(u int64) {
  44159. if m.addbot_id != nil {
  44160. *m.addbot_id += u
  44161. } else {
  44162. m.addbot_id = &u
  44163. }
  44164. }
  44165. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  44166. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  44167. v := m.addbot_id
  44168. if v == nil {
  44169. return
  44170. }
  44171. return *v, true
  44172. }
  44173. // ResetBotID resets all changes to the "bot_id" field.
  44174. func (m *WxCardVisitMutation) ResetBotID() {
  44175. m.bot_id = nil
  44176. m.addbot_id = nil
  44177. }
  44178. // SetBotType sets the "bot_type" field.
  44179. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  44180. m.bot_type = &u
  44181. m.addbot_type = nil
  44182. }
  44183. // BotType returns the value of the "bot_type" field in the mutation.
  44184. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  44185. v := m.bot_type
  44186. if v == nil {
  44187. return
  44188. }
  44189. return *v, true
  44190. }
  44191. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  44192. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  44193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44194. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  44195. if !m.op.Is(OpUpdateOne) {
  44196. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  44197. }
  44198. if m.id == nil || m.oldValue == nil {
  44199. return v, errors.New("OldBotType requires an ID field in the mutation")
  44200. }
  44201. oldValue, err := m.oldValue(ctx)
  44202. if err != nil {
  44203. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  44204. }
  44205. return oldValue.BotType, nil
  44206. }
  44207. // AddBotType adds u to the "bot_type" field.
  44208. func (m *WxCardVisitMutation) AddBotType(u int8) {
  44209. if m.addbot_type != nil {
  44210. *m.addbot_type += u
  44211. } else {
  44212. m.addbot_type = &u
  44213. }
  44214. }
  44215. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  44216. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  44217. v := m.addbot_type
  44218. if v == nil {
  44219. return
  44220. }
  44221. return *v, true
  44222. }
  44223. // ResetBotType resets all changes to the "bot_type" field.
  44224. func (m *WxCardVisitMutation) ResetBotType() {
  44225. m.bot_type = nil
  44226. m.addbot_type = nil
  44227. }
  44228. // Where appends a list predicates to the WxCardVisitMutation builder.
  44229. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  44230. m.predicates = append(m.predicates, ps...)
  44231. }
  44232. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  44233. // users can use type-assertion to append predicates that do not depend on any generated package.
  44234. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  44235. p := make([]predicate.WxCardVisit, len(ps))
  44236. for i := range ps {
  44237. p[i] = ps[i]
  44238. }
  44239. m.Where(p...)
  44240. }
  44241. // Op returns the operation name.
  44242. func (m *WxCardVisitMutation) Op() Op {
  44243. return m.op
  44244. }
  44245. // SetOp allows setting the mutation operation.
  44246. func (m *WxCardVisitMutation) SetOp(op Op) {
  44247. m.op = op
  44248. }
  44249. // Type returns the node type of this mutation (WxCardVisit).
  44250. func (m *WxCardVisitMutation) Type() string {
  44251. return m.typ
  44252. }
  44253. // Fields returns all fields that were changed during this mutation. Note that in
  44254. // order to get all numeric fields that were incremented/decremented, call
  44255. // AddedFields().
  44256. func (m *WxCardVisitMutation) Fields() []string {
  44257. fields := make([]string, 0, 6)
  44258. if m.created_at != nil {
  44259. fields = append(fields, wxcardvisit.FieldCreatedAt)
  44260. }
  44261. if m.updated_at != nil {
  44262. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  44263. }
  44264. if m.deleted_at != nil {
  44265. fields = append(fields, wxcardvisit.FieldDeletedAt)
  44266. }
  44267. if m.user_id != nil {
  44268. fields = append(fields, wxcardvisit.FieldUserID)
  44269. }
  44270. if m.bot_id != nil {
  44271. fields = append(fields, wxcardvisit.FieldBotID)
  44272. }
  44273. if m.bot_type != nil {
  44274. fields = append(fields, wxcardvisit.FieldBotType)
  44275. }
  44276. return fields
  44277. }
  44278. // Field returns the value of a field with the given name. The second boolean
  44279. // return value indicates that this field was not set, or was not defined in the
  44280. // schema.
  44281. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  44282. switch name {
  44283. case wxcardvisit.FieldCreatedAt:
  44284. return m.CreatedAt()
  44285. case wxcardvisit.FieldUpdatedAt:
  44286. return m.UpdatedAt()
  44287. case wxcardvisit.FieldDeletedAt:
  44288. return m.DeletedAt()
  44289. case wxcardvisit.FieldUserID:
  44290. return m.UserID()
  44291. case wxcardvisit.FieldBotID:
  44292. return m.BotID()
  44293. case wxcardvisit.FieldBotType:
  44294. return m.BotType()
  44295. }
  44296. return nil, false
  44297. }
  44298. // OldField returns the old value of the field from the database. An error is
  44299. // returned if the mutation operation is not UpdateOne, or the query to the
  44300. // database failed.
  44301. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44302. switch name {
  44303. case wxcardvisit.FieldCreatedAt:
  44304. return m.OldCreatedAt(ctx)
  44305. case wxcardvisit.FieldUpdatedAt:
  44306. return m.OldUpdatedAt(ctx)
  44307. case wxcardvisit.FieldDeletedAt:
  44308. return m.OldDeletedAt(ctx)
  44309. case wxcardvisit.FieldUserID:
  44310. return m.OldUserID(ctx)
  44311. case wxcardvisit.FieldBotID:
  44312. return m.OldBotID(ctx)
  44313. case wxcardvisit.FieldBotType:
  44314. return m.OldBotType(ctx)
  44315. }
  44316. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  44317. }
  44318. // SetField sets the value of a field with the given name. It returns an error if
  44319. // the field is not defined in the schema, or if the type mismatched the field
  44320. // type.
  44321. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  44322. switch name {
  44323. case wxcardvisit.FieldCreatedAt:
  44324. v, ok := value.(time.Time)
  44325. if !ok {
  44326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44327. }
  44328. m.SetCreatedAt(v)
  44329. return nil
  44330. case wxcardvisit.FieldUpdatedAt:
  44331. v, ok := value.(time.Time)
  44332. if !ok {
  44333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44334. }
  44335. m.SetUpdatedAt(v)
  44336. return nil
  44337. case wxcardvisit.FieldDeletedAt:
  44338. v, ok := value.(time.Time)
  44339. if !ok {
  44340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44341. }
  44342. m.SetDeletedAt(v)
  44343. return nil
  44344. case wxcardvisit.FieldUserID:
  44345. v, ok := value.(uint64)
  44346. if !ok {
  44347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44348. }
  44349. m.SetUserID(v)
  44350. return nil
  44351. case wxcardvisit.FieldBotID:
  44352. v, ok := value.(uint64)
  44353. if !ok {
  44354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44355. }
  44356. m.SetBotID(v)
  44357. return nil
  44358. case wxcardvisit.FieldBotType:
  44359. v, ok := value.(uint8)
  44360. if !ok {
  44361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44362. }
  44363. m.SetBotType(v)
  44364. return nil
  44365. }
  44366. return fmt.Errorf("unknown WxCardVisit field %s", name)
  44367. }
  44368. // AddedFields returns all numeric fields that were incremented/decremented during
  44369. // this mutation.
  44370. func (m *WxCardVisitMutation) AddedFields() []string {
  44371. var fields []string
  44372. if m.adduser_id != nil {
  44373. fields = append(fields, wxcardvisit.FieldUserID)
  44374. }
  44375. if m.addbot_id != nil {
  44376. fields = append(fields, wxcardvisit.FieldBotID)
  44377. }
  44378. if m.addbot_type != nil {
  44379. fields = append(fields, wxcardvisit.FieldBotType)
  44380. }
  44381. return fields
  44382. }
  44383. // AddedField returns the numeric value that was incremented/decremented on a field
  44384. // with the given name. The second boolean return value indicates that this field
  44385. // was not set, or was not defined in the schema.
  44386. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  44387. switch name {
  44388. case wxcardvisit.FieldUserID:
  44389. return m.AddedUserID()
  44390. case wxcardvisit.FieldBotID:
  44391. return m.AddedBotID()
  44392. case wxcardvisit.FieldBotType:
  44393. return m.AddedBotType()
  44394. }
  44395. return nil, false
  44396. }
  44397. // AddField adds the value to the field with the given name. It returns an error if
  44398. // the field is not defined in the schema, or if the type mismatched the field
  44399. // type.
  44400. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  44401. switch name {
  44402. case wxcardvisit.FieldUserID:
  44403. v, ok := value.(int64)
  44404. if !ok {
  44405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44406. }
  44407. m.AddUserID(v)
  44408. return nil
  44409. case wxcardvisit.FieldBotID:
  44410. v, ok := value.(int64)
  44411. if !ok {
  44412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44413. }
  44414. m.AddBotID(v)
  44415. return nil
  44416. case wxcardvisit.FieldBotType:
  44417. v, ok := value.(int8)
  44418. if !ok {
  44419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44420. }
  44421. m.AddBotType(v)
  44422. return nil
  44423. }
  44424. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  44425. }
  44426. // ClearedFields returns all nullable fields that were cleared during this
  44427. // mutation.
  44428. func (m *WxCardVisitMutation) ClearedFields() []string {
  44429. var fields []string
  44430. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  44431. fields = append(fields, wxcardvisit.FieldDeletedAt)
  44432. }
  44433. if m.FieldCleared(wxcardvisit.FieldUserID) {
  44434. fields = append(fields, wxcardvisit.FieldUserID)
  44435. }
  44436. return fields
  44437. }
  44438. // FieldCleared returns a boolean indicating if a field with the given name was
  44439. // cleared in this mutation.
  44440. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  44441. _, ok := m.clearedFields[name]
  44442. return ok
  44443. }
  44444. // ClearField clears the value of the field with the given name. It returns an
  44445. // error if the field is not defined in the schema.
  44446. func (m *WxCardVisitMutation) ClearField(name string) error {
  44447. switch name {
  44448. case wxcardvisit.FieldDeletedAt:
  44449. m.ClearDeletedAt()
  44450. return nil
  44451. case wxcardvisit.FieldUserID:
  44452. m.ClearUserID()
  44453. return nil
  44454. }
  44455. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  44456. }
  44457. // ResetField resets all changes in the mutation for the field with the given name.
  44458. // It returns an error if the field is not defined in the schema.
  44459. func (m *WxCardVisitMutation) ResetField(name string) error {
  44460. switch name {
  44461. case wxcardvisit.FieldCreatedAt:
  44462. m.ResetCreatedAt()
  44463. return nil
  44464. case wxcardvisit.FieldUpdatedAt:
  44465. m.ResetUpdatedAt()
  44466. return nil
  44467. case wxcardvisit.FieldDeletedAt:
  44468. m.ResetDeletedAt()
  44469. return nil
  44470. case wxcardvisit.FieldUserID:
  44471. m.ResetUserID()
  44472. return nil
  44473. case wxcardvisit.FieldBotID:
  44474. m.ResetBotID()
  44475. return nil
  44476. case wxcardvisit.FieldBotType:
  44477. m.ResetBotType()
  44478. return nil
  44479. }
  44480. return fmt.Errorf("unknown WxCardVisit field %s", name)
  44481. }
  44482. // AddedEdges returns all edge names that were set/added in this mutation.
  44483. func (m *WxCardVisitMutation) AddedEdges() []string {
  44484. edges := make([]string, 0, 0)
  44485. return edges
  44486. }
  44487. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44488. // name in this mutation.
  44489. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  44490. return nil
  44491. }
  44492. // RemovedEdges returns all edge names that were removed in this mutation.
  44493. func (m *WxCardVisitMutation) RemovedEdges() []string {
  44494. edges := make([]string, 0, 0)
  44495. return edges
  44496. }
  44497. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44498. // the given name in this mutation.
  44499. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  44500. return nil
  44501. }
  44502. // ClearedEdges returns all edge names that were cleared in this mutation.
  44503. func (m *WxCardVisitMutation) ClearedEdges() []string {
  44504. edges := make([]string, 0, 0)
  44505. return edges
  44506. }
  44507. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44508. // was cleared in this mutation.
  44509. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  44510. return false
  44511. }
  44512. // ClearEdge clears the value of the edge with the given name. It returns an error
  44513. // if that edge is not defined in the schema.
  44514. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  44515. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  44516. }
  44517. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44518. // It returns an error if the edge is not defined in the schema.
  44519. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  44520. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  44521. }