mutation.go 1.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/batchmsg"
  14. "wechat-api/ent/category"
  15. "wechat-api/ent/chatrecords"
  16. "wechat-api/ent/chatsession"
  17. "wechat-api/ent/contact"
  18. "wechat-api/ent/creditbalance"
  19. "wechat-api/ent/creditusage"
  20. "wechat-api/ent/custom_types"
  21. "wechat-api/ent/employee"
  22. "wechat-api/ent/employeeconfig"
  23. "wechat-api/ent/label"
  24. "wechat-api/ent/labelrelationship"
  25. "wechat-api/ent/labeltagging"
  26. "wechat-api/ent/message"
  27. "wechat-api/ent/messagerecords"
  28. "wechat-api/ent/msg"
  29. "wechat-api/ent/payrecharge"
  30. "wechat-api/ent/predicate"
  31. "wechat-api/ent/server"
  32. "wechat-api/ent/sopnode"
  33. "wechat-api/ent/sopstage"
  34. "wechat-api/ent/soptask"
  35. "wechat-api/ent/token"
  36. "wechat-api/ent/tutorial"
  37. "wechat-api/ent/usagedetail"
  38. "wechat-api/ent/usagestatisticday"
  39. "wechat-api/ent/usagestatistichour"
  40. "wechat-api/ent/usagestatisticmonth"
  41. "wechat-api/ent/usagetotal"
  42. "wechat-api/ent/whatsapp"
  43. "wechat-api/ent/whatsappchannel"
  44. "wechat-api/ent/workexperience"
  45. "wechat-api/ent/wpchatroom"
  46. "wechat-api/ent/wpchatroommember"
  47. "wechat-api/ent/wx"
  48. "wechat-api/ent/wxcard"
  49. "wechat-api/ent/wxcarduser"
  50. "wechat-api/ent/wxcardvisit"
  51. "entgo.io/ent"
  52. "entgo.io/ent/dialect/sql"
  53. )
  54. const (
  55. // Operation types.
  56. OpCreate = ent.OpCreate
  57. OpDelete = ent.OpDelete
  58. OpDeleteOne = ent.OpDeleteOne
  59. OpUpdate = ent.OpUpdate
  60. OpUpdateOne = ent.OpUpdateOne
  61. // Node types.
  62. TypeAgent = "Agent"
  63. TypeAgentBase = "AgentBase"
  64. TypeAliyunAvatar = "AliyunAvatar"
  65. TypeAllocAgent = "AllocAgent"
  66. TypeBatchMsg = "BatchMsg"
  67. TypeCategory = "Category"
  68. TypeChatRecords = "ChatRecords"
  69. TypeChatSession = "ChatSession"
  70. TypeContact = "Contact"
  71. TypeCreditBalance = "CreditBalance"
  72. TypeCreditUsage = "CreditUsage"
  73. TypeEmployee = "Employee"
  74. TypeEmployeeConfig = "EmployeeConfig"
  75. TypeLabel = "Label"
  76. TypeLabelRelationship = "LabelRelationship"
  77. TypeLabelTagging = "LabelTagging"
  78. TypeMessage = "Message"
  79. TypeMessageRecords = "MessageRecords"
  80. TypeMsg = "Msg"
  81. TypePayRecharge = "PayRecharge"
  82. TypeServer = "Server"
  83. TypeSopNode = "SopNode"
  84. TypeSopStage = "SopStage"
  85. TypeSopTask = "SopTask"
  86. TypeToken = "Token"
  87. TypeTutorial = "Tutorial"
  88. TypeUsageDetail = "UsageDetail"
  89. TypeUsageStatisticDay = "UsageStatisticDay"
  90. TypeUsageStatisticHour = "UsageStatisticHour"
  91. TypeUsageStatisticMonth = "UsageStatisticMonth"
  92. TypeUsageTotal = "UsageTotal"
  93. TypeWhatsapp = "Whatsapp"
  94. TypeWhatsappChannel = "WhatsappChannel"
  95. TypeWorkExperience = "WorkExperience"
  96. TypeWpChatroom = "WpChatroom"
  97. TypeWpChatroomMember = "WpChatroomMember"
  98. TypeWx = "Wx"
  99. TypeWxCard = "WxCard"
  100. TypeWxCardUser = "WxCardUser"
  101. TypeWxCardVisit = "WxCardVisit"
  102. )
  103. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  104. type AgentMutation struct {
  105. config
  106. op Op
  107. typ string
  108. id *uint64
  109. created_at *time.Time
  110. updated_at *time.Time
  111. deleted_at *time.Time
  112. name *string
  113. role *string
  114. status *int
  115. addstatus *int
  116. background *string
  117. examples *string
  118. organization_id *uint64
  119. addorganization_id *int64
  120. dataset_id *string
  121. collection_id *string
  122. clearedFields map[string]struct{}
  123. wx_agent map[uint64]struct{}
  124. removedwx_agent map[uint64]struct{}
  125. clearedwx_agent bool
  126. token_agent map[uint64]struct{}
  127. removedtoken_agent map[uint64]struct{}
  128. clearedtoken_agent bool
  129. wa_agent map[uint64]struct{}
  130. removedwa_agent map[uint64]struct{}
  131. clearedwa_agent bool
  132. done bool
  133. oldValue func(context.Context) (*Agent, error)
  134. predicates []predicate.Agent
  135. }
  136. var _ ent.Mutation = (*AgentMutation)(nil)
  137. // agentOption allows management of the mutation configuration using functional options.
  138. type agentOption func(*AgentMutation)
  139. // newAgentMutation creates new mutation for the Agent entity.
  140. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  141. m := &AgentMutation{
  142. config: c,
  143. op: op,
  144. typ: TypeAgent,
  145. clearedFields: make(map[string]struct{}),
  146. }
  147. for _, opt := range opts {
  148. opt(m)
  149. }
  150. return m
  151. }
  152. // withAgentID sets the ID field of the mutation.
  153. func withAgentID(id uint64) agentOption {
  154. return func(m *AgentMutation) {
  155. var (
  156. err error
  157. once sync.Once
  158. value *Agent
  159. )
  160. m.oldValue = func(ctx context.Context) (*Agent, error) {
  161. once.Do(func() {
  162. if m.done {
  163. err = errors.New("querying old values post mutation is not allowed")
  164. } else {
  165. value, err = m.Client().Agent.Get(ctx, id)
  166. }
  167. })
  168. return value, err
  169. }
  170. m.id = &id
  171. }
  172. }
  173. // withAgent sets the old Agent of the mutation.
  174. func withAgent(node *Agent) agentOption {
  175. return func(m *AgentMutation) {
  176. m.oldValue = func(context.Context) (*Agent, error) {
  177. return node, nil
  178. }
  179. m.id = &node.ID
  180. }
  181. }
  182. // Client returns a new `ent.Client` from the mutation. If the mutation was
  183. // executed in a transaction (ent.Tx), a transactional client is returned.
  184. func (m AgentMutation) Client() *Client {
  185. client := &Client{config: m.config}
  186. client.init()
  187. return client
  188. }
  189. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  190. // it returns an error otherwise.
  191. func (m AgentMutation) Tx() (*Tx, error) {
  192. if _, ok := m.driver.(*txDriver); !ok {
  193. return nil, errors.New("ent: mutation is not running in a transaction")
  194. }
  195. tx := &Tx{config: m.config}
  196. tx.init()
  197. return tx, nil
  198. }
  199. // SetID sets the value of the id field. Note that this
  200. // operation is only accepted on creation of Agent entities.
  201. func (m *AgentMutation) SetID(id uint64) {
  202. m.id = &id
  203. }
  204. // ID returns the ID value in the mutation. Note that the ID is only available
  205. // if it was provided to the builder or after it was returned from the database.
  206. func (m *AgentMutation) ID() (id uint64, exists bool) {
  207. if m.id == nil {
  208. return
  209. }
  210. return *m.id, true
  211. }
  212. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  213. // That means, if the mutation is applied within a transaction with an isolation level such
  214. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  215. // or updated by the mutation.
  216. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  217. switch {
  218. case m.op.Is(OpUpdateOne | OpDeleteOne):
  219. id, exists := m.ID()
  220. if exists {
  221. return []uint64{id}, nil
  222. }
  223. fallthrough
  224. case m.op.Is(OpUpdate | OpDelete):
  225. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  226. default:
  227. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  228. }
  229. }
  230. // SetCreatedAt sets the "created_at" field.
  231. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  232. m.created_at = &t
  233. }
  234. // CreatedAt returns the value of the "created_at" field in the mutation.
  235. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  236. v := m.created_at
  237. if v == nil {
  238. return
  239. }
  240. return *v, true
  241. }
  242. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  243. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  245. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  246. if !m.op.Is(OpUpdateOne) {
  247. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  248. }
  249. if m.id == nil || m.oldValue == nil {
  250. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  251. }
  252. oldValue, err := m.oldValue(ctx)
  253. if err != nil {
  254. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  255. }
  256. return oldValue.CreatedAt, nil
  257. }
  258. // ResetCreatedAt resets all changes to the "created_at" field.
  259. func (m *AgentMutation) ResetCreatedAt() {
  260. m.created_at = nil
  261. }
  262. // SetUpdatedAt sets the "updated_at" field.
  263. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  264. m.updated_at = &t
  265. }
  266. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  267. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  268. v := m.updated_at
  269. if v == nil {
  270. return
  271. }
  272. return *v, true
  273. }
  274. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  275. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  277. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  278. if !m.op.Is(OpUpdateOne) {
  279. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  280. }
  281. if m.id == nil || m.oldValue == nil {
  282. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  283. }
  284. oldValue, err := m.oldValue(ctx)
  285. if err != nil {
  286. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  287. }
  288. return oldValue.UpdatedAt, nil
  289. }
  290. // ResetUpdatedAt resets all changes to the "updated_at" field.
  291. func (m *AgentMutation) ResetUpdatedAt() {
  292. m.updated_at = nil
  293. }
  294. // SetDeletedAt sets the "deleted_at" field.
  295. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  296. m.deleted_at = &t
  297. }
  298. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  299. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  300. v := m.deleted_at
  301. if v == nil {
  302. return
  303. }
  304. return *v, true
  305. }
  306. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  307. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  309. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  310. if !m.op.Is(OpUpdateOne) {
  311. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  312. }
  313. if m.id == nil || m.oldValue == nil {
  314. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  315. }
  316. oldValue, err := m.oldValue(ctx)
  317. if err != nil {
  318. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  319. }
  320. return oldValue.DeletedAt, nil
  321. }
  322. // ClearDeletedAt clears the value of the "deleted_at" field.
  323. func (m *AgentMutation) ClearDeletedAt() {
  324. m.deleted_at = nil
  325. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  326. }
  327. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  328. func (m *AgentMutation) DeletedAtCleared() bool {
  329. _, ok := m.clearedFields[agent.FieldDeletedAt]
  330. return ok
  331. }
  332. // ResetDeletedAt resets all changes to the "deleted_at" field.
  333. func (m *AgentMutation) ResetDeletedAt() {
  334. m.deleted_at = nil
  335. delete(m.clearedFields, agent.FieldDeletedAt)
  336. }
  337. // SetName sets the "name" field.
  338. func (m *AgentMutation) SetName(s string) {
  339. m.name = &s
  340. }
  341. // Name returns the value of the "name" field in the mutation.
  342. func (m *AgentMutation) Name() (r string, exists bool) {
  343. v := m.name
  344. if v == nil {
  345. return
  346. }
  347. return *v, true
  348. }
  349. // OldName returns the old "name" field's value of the Agent entity.
  350. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  352. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  353. if !m.op.Is(OpUpdateOne) {
  354. return v, errors.New("OldName is only allowed on UpdateOne operations")
  355. }
  356. if m.id == nil || m.oldValue == nil {
  357. return v, errors.New("OldName requires an ID field in the mutation")
  358. }
  359. oldValue, err := m.oldValue(ctx)
  360. if err != nil {
  361. return v, fmt.Errorf("querying old value for OldName: %w", err)
  362. }
  363. return oldValue.Name, nil
  364. }
  365. // ResetName resets all changes to the "name" field.
  366. func (m *AgentMutation) ResetName() {
  367. m.name = nil
  368. }
  369. // SetRole sets the "role" field.
  370. func (m *AgentMutation) SetRole(s string) {
  371. m.role = &s
  372. }
  373. // Role returns the value of the "role" field in the mutation.
  374. func (m *AgentMutation) Role() (r string, exists bool) {
  375. v := m.role
  376. if v == nil {
  377. return
  378. }
  379. return *v, true
  380. }
  381. // OldRole returns the old "role" field's value of the Agent entity.
  382. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  384. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  385. if !m.op.Is(OpUpdateOne) {
  386. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  387. }
  388. if m.id == nil || m.oldValue == nil {
  389. return v, errors.New("OldRole requires an ID field in the mutation")
  390. }
  391. oldValue, err := m.oldValue(ctx)
  392. if err != nil {
  393. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  394. }
  395. return oldValue.Role, nil
  396. }
  397. // ResetRole resets all changes to the "role" field.
  398. func (m *AgentMutation) ResetRole() {
  399. m.role = nil
  400. }
  401. // SetStatus sets the "status" field.
  402. func (m *AgentMutation) SetStatus(i int) {
  403. m.status = &i
  404. m.addstatus = nil
  405. }
  406. // Status returns the value of the "status" field in the mutation.
  407. func (m *AgentMutation) Status() (r int, exists bool) {
  408. v := m.status
  409. if v == nil {
  410. return
  411. }
  412. return *v, true
  413. }
  414. // OldStatus returns the old "status" field's value of the Agent entity.
  415. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  417. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  418. if !m.op.Is(OpUpdateOne) {
  419. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  420. }
  421. if m.id == nil || m.oldValue == nil {
  422. return v, errors.New("OldStatus requires an ID field in the mutation")
  423. }
  424. oldValue, err := m.oldValue(ctx)
  425. if err != nil {
  426. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  427. }
  428. return oldValue.Status, nil
  429. }
  430. // AddStatus adds i to the "status" field.
  431. func (m *AgentMutation) AddStatus(i int) {
  432. if m.addstatus != nil {
  433. *m.addstatus += i
  434. } else {
  435. m.addstatus = &i
  436. }
  437. }
  438. // AddedStatus returns the value that was added to the "status" field in this mutation.
  439. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  440. v := m.addstatus
  441. if v == nil {
  442. return
  443. }
  444. return *v, true
  445. }
  446. // ClearStatus clears the value of the "status" field.
  447. func (m *AgentMutation) ClearStatus() {
  448. m.status = nil
  449. m.addstatus = nil
  450. m.clearedFields[agent.FieldStatus] = struct{}{}
  451. }
  452. // StatusCleared returns if the "status" field was cleared in this mutation.
  453. func (m *AgentMutation) StatusCleared() bool {
  454. _, ok := m.clearedFields[agent.FieldStatus]
  455. return ok
  456. }
  457. // ResetStatus resets all changes to the "status" field.
  458. func (m *AgentMutation) ResetStatus() {
  459. m.status = nil
  460. m.addstatus = nil
  461. delete(m.clearedFields, agent.FieldStatus)
  462. }
  463. // SetBackground sets the "background" field.
  464. func (m *AgentMutation) SetBackground(s string) {
  465. m.background = &s
  466. }
  467. // Background returns the value of the "background" field in the mutation.
  468. func (m *AgentMutation) Background() (r string, exists bool) {
  469. v := m.background
  470. if v == nil {
  471. return
  472. }
  473. return *v, true
  474. }
  475. // OldBackground returns the old "background" field's value of the Agent entity.
  476. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  478. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  479. if !m.op.Is(OpUpdateOne) {
  480. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  481. }
  482. if m.id == nil || m.oldValue == nil {
  483. return v, errors.New("OldBackground requires an ID field in the mutation")
  484. }
  485. oldValue, err := m.oldValue(ctx)
  486. if err != nil {
  487. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  488. }
  489. return oldValue.Background, nil
  490. }
  491. // ClearBackground clears the value of the "background" field.
  492. func (m *AgentMutation) ClearBackground() {
  493. m.background = nil
  494. m.clearedFields[agent.FieldBackground] = struct{}{}
  495. }
  496. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  497. func (m *AgentMutation) BackgroundCleared() bool {
  498. _, ok := m.clearedFields[agent.FieldBackground]
  499. return ok
  500. }
  501. // ResetBackground resets all changes to the "background" field.
  502. func (m *AgentMutation) ResetBackground() {
  503. m.background = nil
  504. delete(m.clearedFields, agent.FieldBackground)
  505. }
  506. // SetExamples sets the "examples" field.
  507. func (m *AgentMutation) SetExamples(s string) {
  508. m.examples = &s
  509. }
  510. // Examples returns the value of the "examples" field in the mutation.
  511. func (m *AgentMutation) Examples() (r string, exists bool) {
  512. v := m.examples
  513. if v == nil {
  514. return
  515. }
  516. return *v, true
  517. }
  518. // OldExamples returns the old "examples" field's value of the Agent entity.
  519. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  521. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  522. if !m.op.Is(OpUpdateOne) {
  523. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  524. }
  525. if m.id == nil || m.oldValue == nil {
  526. return v, errors.New("OldExamples requires an ID field in the mutation")
  527. }
  528. oldValue, err := m.oldValue(ctx)
  529. if err != nil {
  530. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  531. }
  532. return oldValue.Examples, nil
  533. }
  534. // ClearExamples clears the value of the "examples" field.
  535. func (m *AgentMutation) ClearExamples() {
  536. m.examples = nil
  537. m.clearedFields[agent.FieldExamples] = struct{}{}
  538. }
  539. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  540. func (m *AgentMutation) ExamplesCleared() bool {
  541. _, ok := m.clearedFields[agent.FieldExamples]
  542. return ok
  543. }
  544. // ResetExamples resets all changes to the "examples" field.
  545. func (m *AgentMutation) ResetExamples() {
  546. m.examples = nil
  547. delete(m.clearedFields, agent.FieldExamples)
  548. }
  549. // SetOrganizationID sets the "organization_id" field.
  550. func (m *AgentMutation) SetOrganizationID(u uint64) {
  551. m.organization_id = &u
  552. m.addorganization_id = nil
  553. }
  554. // OrganizationID returns the value of the "organization_id" field in the mutation.
  555. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  556. v := m.organization_id
  557. if v == nil {
  558. return
  559. }
  560. return *v, true
  561. }
  562. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  563. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  565. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  566. if !m.op.Is(OpUpdateOne) {
  567. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  568. }
  569. if m.id == nil || m.oldValue == nil {
  570. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  571. }
  572. oldValue, err := m.oldValue(ctx)
  573. if err != nil {
  574. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  575. }
  576. return oldValue.OrganizationID, nil
  577. }
  578. // AddOrganizationID adds u to the "organization_id" field.
  579. func (m *AgentMutation) AddOrganizationID(u int64) {
  580. if m.addorganization_id != nil {
  581. *m.addorganization_id += u
  582. } else {
  583. m.addorganization_id = &u
  584. }
  585. }
  586. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  587. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  588. v := m.addorganization_id
  589. if v == nil {
  590. return
  591. }
  592. return *v, true
  593. }
  594. // ResetOrganizationID resets all changes to the "organization_id" field.
  595. func (m *AgentMutation) ResetOrganizationID() {
  596. m.organization_id = nil
  597. m.addorganization_id = nil
  598. }
  599. // SetDatasetID sets the "dataset_id" field.
  600. func (m *AgentMutation) SetDatasetID(s string) {
  601. m.dataset_id = &s
  602. }
  603. // DatasetID returns the value of the "dataset_id" field in the mutation.
  604. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  605. v := m.dataset_id
  606. if v == nil {
  607. return
  608. }
  609. return *v, true
  610. }
  611. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  612. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  614. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  615. if !m.op.Is(OpUpdateOne) {
  616. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  617. }
  618. if m.id == nil || m.oldValue == nil {
  619. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  620. }
  621. oldValue, err := m.oldValue(ctx)
  622. if err != nil {
  623. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  624. }
  625. return oldValue.DatasetID, nil
  626. }
  627. // ResetDatasetID resets all changes to the "dataset_id" field.
  628. func (m *AgentMutation) ResetDatasetID() {
  629. m.dataset_id = nil
  630. }
  631. // SetCollectionID sets the "collection_id" field.
  632. func (m *AgentMutation) SetCollectionID(s string) {
  633. m.collection_id = &s
  634. }
  635. // CollectionID returns the value of the "collection_id" field in the mutation.
  636. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  637. v := m.collection_id
  638. if v == nil {
  639. return
  640. }
  641. return *v, true
  642. }
  643. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  644. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  646. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  647. if !m.op.Is(OpUpdateOne) {
  648. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  649. }
  650. if m.id == nil || m.oldValue == nil {
  651. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  652. }
  653. oldValue, err := m.oldValue(ctx)
  654. if err != nil {
  655. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  656. }
  657. return oldValue.CollectionID, nil
  658. }
  659. // ResetCollectionID resets all changes to the "collection_id" field.
  660. func (m *AgentMutation) ResetCollectionID() {
  661. m.collection_id = nil
  662. }
  663. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  664. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  665. if m.wx_agent == nil {
  666. m.wx_agent = make(map[uint64]struct{})
  667. }
  668. for i := range ids {
  669. m.wx_agent[ids[i]] = struct{}{}
  670. }
  671. }
  672. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  673. func (m *AgentMutation) ClearWxAgent() {
  674. m.clearedwx_agent = true
  675. }
  676. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  677. func (m *AgentMutation) WxAgentCleared() bool {
  678. return m.clearedwx_agent
  679. }
  680. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  681. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  682. if m.removedwx_agent == nil {
  683. m.removedwx_agent = make(map[uint64]struct{})
  684. }
  685. for i := range ids {
  686. delete(m.wx_agent, ids[i])
  687. m.removedwx_agent[ids[i]] = struct{}{}
  688. }
  689. }
  690. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  691. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  692. for id := range m.removedwx_agent {
  693. ids = append(ids, id)
  694. }
  695. return
  696. }
  697. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  698. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  699. for id := range m.wx_agent {
  700. ids = append(ids, id)
  701. }
  702. return
  703. }
  704. // ResetWxAgent resets all changes to the "wx_agent" edge.
  705. func (m *AgentMutation) ResetWxAgent() {
  706. m.wx_agent = nil
  707. m.clearedwx_agent = false
  708. m.removedwx_agent = nil
  709. }
  710. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  711. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  712. if m.token_agent == nil {
  713. m.token_agent = make(map[uint64]struct{})
  714. }
  715. for i := range ids {
  716. m.token_agent[ids[i]] = struct{}{}
  717. }
  718. }
  719. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  720. func (m *AgentMutation) ClearTokenAgent() {
  721. m.clearedtoken_agent = true
  722. }
  723. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  724. func (m *AgentMutation) TokenAgentCleared() bool {
  725. return m.clearedtoken_agent
  726. }
  727. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  728. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  729. if m.removedtoken_agent == nil {
  730. m.removedtoken_agent = make(map[uint64]struct{})
  731. }
  732. for i := range ids {
  733. delete(m.token_agent, ids[i])
  734. m.removedtoken_agent[ids[i]] = struct{}{}
  735. }
  736. }
  737. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  738. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  739. for id := range m.removedtoken_agent {
  740. ids = append(ids, id)
  741. }
  742. return
  743. }
  744. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  745. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  746. for id := range m.token_agent {
  747. ids = append(ids, id)
  748. }
  749. return
  750. }
  751. // ResetTokenAgent resets all changes to the "token_agent" edge.
  752. func (m *AgentMutation) ResetTokenAgent() {
  753. m.token_agent = nil
  754. m.clearedtoken_agent = false
  755. m.removedtoken_agent = nil
  756. }
  757. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  758. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  759. if m.wa_agent == nil {
  760. m.wa_agent = make(map[uint64]struct{})
  761. }
  762. for i := range ids {
  763. m.wa_agent[ids[i]] = struct{}{}
  764. }
  765. }
  766. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  767. func (m *AgentMutation) ClearWaAgent() {
  768. m.clearedwa_agent = true
  769. }
  770. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  771. func (m *AgentMutation) WaAgentCleared() bool {
  772. return m.clearedwa_agent
  773. }
  774. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  775. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  776. if m.removedwa_agent == nil {
  777. m.removedwa_agent = make(map[uint64]struct{})
  778. }
  779. for i := range ids {
  780. delete(m.wa_agent, ids[i])
  781. m.removedwa_agent[ids[i]] = struct{}{}
  782. }
  783. }
  784. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  785. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  786. for id := range m.removedwa_agent {
  787. ids = append(ids, id)
  788. }
  789. return
  790. }
  791. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  792. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  793. for id := range m.wa_agent {
  794. ids = append(ids, id)
  795. }
  796. return
  797. }
  798. // ResetWaAgent resets all changes to the "wa_agent" edge.
  799. func (m *AgentMutation) ResetWaAgent() {
  800. m.wa_agent = nil
  801. m.clearedwa_agent = false
  802. m.removedwa_agent = nil
  803. }
  804. // Where appends a list predicates to the AgentMutation builder.
  805. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  806. m.predicates = append(m.predicates, ps...)
  807. }
  808. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  809. // users can use type-assertion to append predicates that do not depend on any generated package.
  810. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  811. p := make([]predicate.Agent, len(ps))
  812. for i := range ps {
  813. p[i] = ps[i]
  814. }
  815. m.Where(p...)
  816. }
  817. // Op returns the operation name.
  818. func (m *AgentMutation) Op() Op {
  819. return m.op
  820. }
  821. // SetOp allows setting the mutation operation.
  822. func (m *AgentMutation) SetOp(op Op) {
  823. m.op = op
  824. }
  825. // Type returns the node type of this mutation (Agent).
  826. func (m *AgentMutation) Type() string {
  827. return m.typ
  828. }
  829. // Fields returns all fields that were changed during this mutation. Note that in
  830. // order to get all numeric fields that were incremented/decremented, call
  831. // AddedFields().
  832. func (m *AgentMutation) Fields() []string {
  833. fields := make([]string, 0, 11)
  834. if m.created_at != nil {
  835. fields = append(fields, agent.FieldCreatedAt)
  836. }
  837. if m.updated_at != nil {
  838. fields = append(fields, agent.FieldUpdatedAt)
  839. }
  840. if m.deleted_at != nil {
  841. fields = append(fields, agent.FieldDeletedAt)
  842. }
  843. if m.name != nil {
  844. fields = append(fields, agent.FieldName)
  845. }
  846. if m.role != nil {
  847. fields = append(fields, agent.FieldRole)
  848. }
  849. if m.status != nil {
  850. fields = append(fields, agent.FieldStatus)
  851. }
  852. if m.background != nil {
  853. fields = append(fields, agent.FieldBackground)
  854. }
  855. if m.examples != nil {
  856. fields = append(fields, agent.FieldExamples)
  857. }
  858. if m.organization_id != nil {
  859. fields = append(fields, agent.FieldOrganizationID)
  860. }
  861. if m.dataset_id != nil {
  862. fields = append(fields, agent.FieldDatasetID)
  863. }
  864. if m.collection_id != nil {
  865. fields = append(fields, agent.FieldCollectionID)
  866. }
  867. return fields
  868. }
  869. // Field returns the value of a field with the given name. The second boolean
  870. // return value indicates that this field was not set, or was not defined in the
  871. // schema.
  872. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  873. switch name {
  874. case agent.FieldCreatedAt:
  875. return m.CreatedAt()
  876. case agent.FieldUpdatedAt:
  877. return m.UpdatedAt()
  878. case agent.FieldDeletedAt:
  879. return m.DeletedAt()
  880. case agent.FieldName:
  881. return m.Name()
  882. case agent.FieldRole:
  883. return m.Role()
  884. case agent.FieldStatus:
  885. return m.Status()
  886. case agent.FieldBackground:
  887. return m.Background()
  888. case agent.FieldExamples:
  889. return m.Examples()
  890. case agent.FieldOrganizationID:
  891. return m.OrganizationID()
  892. case agent.FieldDatasetID:
  893. return m.DatasetID()
  894. case agent.FieldCollectionID:
  895. return m.CollectionID()
  896. }
  897. return nil, false
  898. }
  899. // OldField returns the old value of the field from the database. An error is
  900. // returned if the mutation operation is not UpdateOne, or the query to the
  901. // database failed.
  902. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  903. switch name {
  904. case agent.FieldCreatedAt:
  905. return m.OldCreatedAt(ctx)
  906. case agent.FieldUpdatedAt:
  907. return m.OldUpdatedAt(ctx)
  908. case agent.FieldDeletedAt:
  909. return m.OldDeletedAt(ctx)
  910. case agent.FieldName:
  911. return m.OldName(ctx)
  912. case agent.FieldRole:
  913. return m.OldRole(ctx)
  914. case agent.FieldStatus:
  915. return m.OldStatus(ctx)
  916. case agent.FieldBackground:
  917. return m.OldBackground(ctx)
  918. case agent.FieldExamples:
  919. return m.OldExamples(ctx)
  920. case agent.FieldOrganizationID:
  921. return m.OldOrganizationID(ctx)
  922. case agent.FieldDatasetID:
  923. return m.OldDatasetID(ctx)
  924. case agent.FieldCollectionID:
  925. return m.OldCollectionID(ctx)
  926. }
  927. return nil, fmt.Errorf("unknown Agent field %s", name)
  928. }
  929. // SetField sets the value of a field with the given name. It returns an error if
  930. // the field is not defined in the schema, or if the type mismatched the field
  931. // type.
  932. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  933. switch name {
  934. case agent.FieldCreatedAt:
  935. v, ok := value.(time.Time)
  936. if !ok {
  937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  938. }
  939. m.SetCreatedAt(v)
  940. return nil
  941. case agent.FieldUpdatedAt:
  942. v, ok := value.(time.Time)
  943. if !ok {
  944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  945. }
  946. m.SetUpdatedAt(v)
  947. return nil
  948. case agent.FieldDeletedAt:
  949. v, ok := value.(time.Time)
  950. if !ok {
  951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  952. }
  953. m.SetDeletedAt(v)
  954. return nil
  955. case agent.FieldName:
  956. v, ok := value.(string)
  957. if !ok {
  958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  959. }
  960. m.SetName(v)
  961. return nil
  962. case agent.FieldRole:
  963. v, ok := value.(string)
  964. if !ok {
  965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  966. }
  967. m.SetRole(v)
  968. return nil
  969. case agent.FieldStatus:
  970. v, ok := value.(int)
  971. if !ok {
  972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  973. }
  974. m.SetStatus(v)
  975. return nil
  976. case agent.FieldBackground:
  977. v, ok := value.(string)
  978. if !ok {
  979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  980. }
  981. m.SetBackground(v)
  982. return nil
  983. case agent.FieldExamples:
  984. v, ok := value.(string)
  985. if !ok {
  986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  987. }
  988. m.SetExamples(v)
  989. return nil
  990. case agent.FieldOrganizationID:
  991. v, ok := value.(uint64)
  992. if !ok {
  993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  994. }
  995. m.SetOrganizationID(v)
  996. return nil
  997. case agent.FieldDatasetID:
  998. v, ok := value.(string)
  999. if !ok {
  1000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1001. }
  1002. m.SetDatasetID(v)
  1003. return nil
  1004. case agent.FieldCollectionID:
  1005. v, ok := value.(string)
  1006. if !ok {
  1007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1008. }
  1009. m.SetCollectionID(v)
  1010. return nil
  1011. }
  1012. return fmt.Errorf("unknown Agent field %s", name)
  1013. }
  1014. // AddedFields returns all numeric fields that were incremented/decremented during
  1015. // this mutation.
  1016. func (m *AgentMutation) AddedFields() []string {
  1017. var fields []string
  1018. if m.addstatus != nil {
  1019. fields = append(fields, agent.FieldStatus)
  1020. }
  1021. if m.addorganization_id != nil {
  1022. fields = append(fields, agent.FieldOrganizationID)
  1023. }
  1024. return fields
  1025. }
  1026. // AddedField returns the numeric value that was incremented/decremented on a field
  1027. // with the given name. The second boolean return value indicates that this field
  1028. // was not set, or was not defined in the schema.
  1029. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1030. switch name {
  1031. case agent.FieldStatus:
  1032. return m.AddedStatus()
  1033. case agent.FieldOrganizationID:
  1034. return m.AddedOrganizationID()
  1035. }
  1036. return nil, false
  1037. }
  1038. // AddField adds the value to the field with the given name. It returns an error if
  1039. // the field is not defined in the schema, or if the type mismatched the field
  1040. // type.
  1041. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1042. switch name {
  1043. case agent.FieldStatus:
  1044. v, ok := value.(int)
  1045. if !ok {
  1046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1047. }
  1048. m.AddStatus(v)
  1049. return nil
  1050. case agent.FieldOrganizationID:
  1051. v, ok := value.(int64)
  1052. if !ok {
  1053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1054. }
  1055. m.AddOrganizationID(v)
  1056. return nil
  1057. }
  1058. return fmt.Errorf("unknown Agent numeric field %s", name)
  1059. }
  1060. // ClearedFields returns all nullable fields that were cleared during this
  1061. // mutation.
  1062. func (m *AgentMutation) ClearedFields() []string {
  1063. var fields []string
  1064. if m.FieldCleared(agent.FieldDeletedAt) {
  1065. fields = append(fields, agent.FieldDeletedAt)
  1066. }
  1067. if m.FieldCleared(agent.FieldStatus) {
  1068. fields = append(fields, agent.FieldStatus)
  1069. }
  1070. if m.FieldCleared(agent.FieldBackground) {
  1071. fields = append(fields, agent.FieldBackground)
  1072. }
  1073. if m.FieldCleared(agent.FieldExamples) {
  1074. fields = append(fields, agent.FieldExamples)
  1075. }
  1076. return fields
  1077. }
  1078. // FieldCleared returns a boolean indicating if a field with the given name was
  1079. // cleared in this mutation.
  1080. func (m *AgentMutation) FieldCleared(name string) bool {
  1081. _, ok := m.clearedFields[name]
  1082. return ok
  1083. }
  1084. // ClearField clears the value of the field with the given name. It returns an
  1085. // error if the field is not defined in the schema.
  1086. func (m *AgentMutation) ClearField(name string) error {
  1087. switch name {
  1088. case agent.FieldDeletedAt:
  1089. m.ClearDeletedAt()
  1090. return nil
  1091. case agent.FieldStatus:
  1092. m.ClearStatus()
  1093. return nil
  1094. case agent.FieldBackground:
  1095. m.ClearBackground()
  1096. return nil
  1097. case agent.FieldExamples:
  1098. m.ClearExamples()
  1099. return nil
  1100. }
  1101. return fmt.Errorf("unknown Agent nullable field %s", name)
  1102. }
  1103. // ResetField resets all changes in the mutation for the field with the given name.
  1104. // It returns an error if the field is not defined in the schema.
  1105. func (m *AgentMutation) ResetField(name string) error {
  1106. switch name {
  1107. case agent.FieldCreatedAt:
  1108. m.ResetCreatedAt()
  1109. return nil
  1110. case agent.FieldUpdatedAt:
  1111. m.ResetUpdatedAt()
  1112. return nil
  1113. case agent.FieldDeletedAt:
  1114. m.ResetDeletedAt()
  1115. return nil
  1116. case agent.FieldName:
  1117. m.ResetName()
  1118. return nil
  1119. case agent.FieldRole:
  1120. m.ResetRole()
  1121. return nil
  1122. case agent.FieldStatus:
  1123. m.ResetStatus()
  1124. return nil
  1125. case agent.FieldBackground:
  1126. m.ResetBackground()
  1127. return nil
  1128. case agent.FieldExamples:
  1129. m.ResetExamples()
  1130. return nil
  1131. case agent.FieldOrganizationID:
  1132. m.ResetOrganizationID()
  1133. return nil
  1134. case agent.FieldDatasetID:
  1135. m.ResetDatasetID()
  1136. return nil
  1137. case agent.FieldCollectionID:
  1138. m.ResetCollectionID()
  1139. return nil
  1140. }
  1141. return fmt.Errorf("unknown Agent field %s", name)
  1142. }
  1143. // AddedEdges returns all edge names that were set/added in this mutation.
  1144. func (m *AgentMutation) AddedEdges() []string {
  1145. edges := make([]string, 0, 3)
  1146. if m.wx_agent != nil {
  1147. edges = append(edges, agent.EdgeWxAgent)
  1148. }
  1149. if m.token_agent != nil {
  1150. edges = append(edges, agent.EdgeTokenAgent)
  1151. }
  1152. if m.wa_agent != nil {
  1153. edges = append(edges, agent.EdgeWaAgent)
  1154. }
  1155. return edges
  1156. }
  1157. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1158. // name in this mutation.
  1159. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1160. switch name {
  1161. case agent.EdgeWxAgent:
  1162. ids := make([]ent.Value, 0, len(m.wx_agent))
  1163. for id := range m.wx_agent {
  1164. ids = append(ids, id)
  1165. }
  1166. return ids
  1167. case agent.EdgeTokenAgent:
  1168. ids := make([]ent.Value, 0, len(m.token_agent))
  1169. for id := range m.token_agent {
  1170. ids = append(ids, id)
  1171. }
  1172. return ids
  1173. case agent.EdgeWaAgent:
  1174. ids := make([]ent.Value, 0, len(m.wa_agent))
  1175. for id := range m.wa_agent {
  1176. ids = append(ids, id)
  1177. }
  1178. return ids
  1179. }
  1180. return nil
  1181. }
  1182. // RemovedEdges returns all edge names that were removed in this mutation.
  1183. func (m *AgentMutation) RemovedEdges() []string {
  1184. edges := make([]string, 0, 3)
  1185. if m.removedwx_agent != nil {
  1186. edges = append(edges, agent.EdgeWxAgent)
  1187. }
  1188. if m.removedtoken_agent != nil {
  1189. edges = append(edges, agent.EdgeTokenAgent)
  1190. }
  1191. if m.removedwa_agent != nil {
  1192. edges = append(edges, agent.EdgeWaAgent)
  1193. }
  1194. return edges
  1195. }
  1196. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1197. // the given name in this mutation.
  1198. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1199. switch name {
  1200. case agent.EdgeWxAgent:
  1201. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1202. for id := range m.removedwx_agent {
  1203. ids = append(ids, id)
  1204. }
  1205. return ids
  1206. case agent.EdgeTokenAgent:
  1207. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1208. for id := range m.removedtoken_agent {
  1209. ids = append(ids, id)
  1210. }
  1211. return ids
  1212. case agent.EdgeWaAgent:
  1213. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1214. for id := range m.removedwa_agent {
  1215. ids = append(ids, id)
  1216. }
  1217. return ids
  1218. }
  1219. return nil
  1220. }
  1221. // ClearedEdges returns all edge names that were cleared in this mutation.
  1222. func (m *AgentMutation) ClearedEdges() []string {
  1223. edges := make([]string, 0, 3)
  1224. if m.clearedwx_agent {
  1225. edges = append(edges, agent.EdgeWxAgent)
  1226. }
  1227. if m.clearedtoken_agent {
  1228. edges = append(edges, agent.EdgeTokenAgent)
  1229. }
  1230. if m.clearedwa_agent {
  1231. edges = append(edges, agent.EdgeWaAgent)
  1232. }
  1233. return edges
  1234. }
  1235. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1236. // was cleared in this mutation.
  1237. func (m *AgentMutation) EdgeCleared(name string) bool {
  1238. switch name {
  1239. case agent.EdgeWxAgent:
  1240. return m.clearedwx_agent
  1241. case agent.EdgeTokenAgent:
  1242. return m.clearedtoken_agent
  1243. case agent.EdgeWaAgent:
  1244. return m.clearedwa_agent
  1245. }
  1246. return false
  1247. }
  1248. // ClearEdge clears the value of the edge with the given name. It returns an error
  1249. // if that edge is not defined in the schema.
  1250. func (m *AgentMutation) ClearEdge(name string) error {
  1251. switch name {
  1252. }
  1253. return fmt.Errorf("unknown Agent unique edge %s", name)
  1254. }
  1255. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1256. // It returns an error if the edge is not defined in the schema.
  1257. func (m *AgentMutation) ResetEdge(name string) error {
  1258. switch name {
  1259. case agent.EdgeWxAgent:
  1260. m.ResetWxAgent()
  1261. return nil
  1262. case agent.EdgeTokenAgent:
  1263. m.ResetTokenAgent()
  1264. return nil
  1265. case agent.EdgeWaAgent:
  1266. m.ResetWaAgent()
  1267. return nil
  1268. }
  1269. return fmt.Errorf("unknown Agent edge %s", name)
  1270. }
  1271. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1272. type AgentBaseMutation struct {
  1273. config
  1274. op Op
  1275. typ string
  1276. id *string
  1277. q *string
  1278. a *string
  1279. chunk_index *uint64
  1280. addchunk_index *int64
  1281. indexes *[]string
  1282. appendindexes []string
  1283. dataset_id *string
  1284. collection_id *string
  1285. source_name *string
  1286. can_write *[]bool
  1287. appendcan_write []bool
  1288. is_owner *[]bool
  1289. appendis_owner []bool
  1290. clearedFields map[string]struct{}
  1291. wx_agent map[uint64]struct{}
  1292. removedwx_agent map[uint64]struct{}
  1293. clearedwx_agent bool
  1294. done bool
  1295. oldValue func(context.Context) (*AgentBase, error)
  1296. predicates []predicate.AgentBase
  1297. }
  1298. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1299. // agentbaseOption allows management of the mutation configuration using functional options.
  1300. type agentbaseOption func(*AgentBaseMutation)
  1301. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1302. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1303. m := &AgentBaseMutation{
  1304. config: c,
  1305. op: op,
  1306. typ: TypeAgentBase,
  1307. clearedFields: make(map[string]struct{}),
  1308. }
  1309. for _, opt := range opts {
  1310. opt(m)
  1311. }
  1312. return m
  1313. }
  1314. // withAgentBaseID sets the ID field of the mutation.
  1315. func withAgentBaseID(id string) agentbaseOption {
  1316. return func(m *AgentBaseMutation) {
  1317. var (
  1318. err error
  1319. once sync.Once
  1320. value *AgentBase
  1321. )
  1322. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1323. once.Do(func() {
  1324. if m.done {
  1325. err = errors.New("querying old values post mutation is not allowed")
  1326. } else {
  1327. value, err = m.Client().AgentBase.Get(ctx, id)
  1328. }
  1329. })
  1330. return value, err
  1331. }
  1332. m.id = &id
  1333. }
  1334. }
  1335. // withAgentBase sets the old AgentBase of the mutation.
  1336. func withAgentBase(node *AgentBase) agentbaseOption {
  1337. return func(m *AgentBaseMutation) {
  1338. m.oldValue = func(context.Context) (*AgentBase, error) {
  1339. return node, nil
  1340. }
  1341. m.id = &node.ID
  1342. }
  1343. }
  1344. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1345. // executed in a transaction (ent.Tx), a transactional client is returned.
  1346. func (m AgentBaseMutation) Client() *Client {
  1347. client := &Client{config: m.config}
  1348. client.init()
  1349. return client
  1350. }
  1351. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1352. // it returns an error otherwise.
  1353. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1354. if _, ok := m.driver.(*txDriver); !ok {
  1355. return nil, errors.New("ent: mutation is not running in a transaction")
  1356. }
  1357. tx := &Tx{config: m.config}
  1358. tx.init()
  1359. return tx, nil
  1360. }
  1361. // SetID sets the value of the id field. Note that this
  1362. // operation is only accepted on creation of AgentBase entities.
  1363. func (m *AgentBaseMutation) SetID(id string) {
  1364. m.id = &id
  1365. }
  1366. // ID returns the ID value in the mutation. Note that the ID is only available
  1367. // if it was provided to the builder or after it was returned from the database.
  1368. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1369. if m.id == nil {
  1370. return
  1371. }
  1372. return *m.id, true
  1373. }
  1374. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1375. // That means, if the mutation is applied within a transaction with an isolation level such
  1376. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1377. // or updated by the mutation.
  1378. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1379. switch {
  1380. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1381. id, exists := m.ID()
  1382. if exists {
  1383. return []string{id}, nil
  1384. }
  1385. fallthrough
  1386. case m.op.Is(OpUpdate | OpDelete):
  1387. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1388. default:
  1389. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1390. }
  1391. }
  1392. // SetQ sets the "q" field.
  1393. func (m *AgentBaseMutation) SetQ(s string) {
  1394. m.q = &s
  1395. }
  1396. // Q returns the value of the "q" field in the mutation.
  1397. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1398. v := m.q
  1399. if v == nil {
  1400. return
  1401. }
  1402. return *v, true
  1403. }
  1404. // OldQ returns the old "q" field's value of the AgentBase entity.
  1405. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1407. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1408. if !m.op.Is(OpUpdateOne) {
  1409. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1410. }
  1411. if m.id == nil || m.oldValue == nil {
  1412. return v, errors.New("OldQ requires an ID field in the mutation")
  1413. }
  1414. oldValue, err := m.oldValue(ctx)
  1415. if err != nil {
  1416. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1417. }
  1418. return oldValue.Q, nil
  1419. }
  1420. // ClearQ clears the value of the "q" field.
  1421. func (m *AgentBaseMutation) ClearQ() {
  1422. m.q = nil
  1423. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1424. }
  1425. // QCleared returns if the "q" field was cleared in this mutation.
  1426. func (m *AgentBaseMutation) QCleared() bool {
  1427. _, ok := m.clearedFields[agentbase.FieldQ]
  1428. return ok
  1429. }
  1430. // ResetQ resets all changes to the "q" field.
  1431. func (m *AgentBaseMutation) ResetQ() {
  1432. m.q = nil
  1433. delete(m.clearedFields, agentbase.FieldQ)
  1434. }
  1435. // SetA sets the "a" field.
  1436. func (m *AgentBaseMutation) SetA(s string) {
  1437. m.a = &s
  1438. }
  1439. // A returns the value of the "a" field in the mutation.
  1440. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1441. v := m.a
  1442. if v == nil {
  1443. return
  1444. }
  1445. return *v, true
  1446. }
  1447. // OldA returns the old "a" field's value of the AgentBase entity.
  1448. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1450. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1451. if !m.op.Is(OpUpdateOne) {
  1452. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1453. }
  1454. if m.id == nil || m.oldValue == nil {
  1455. return v, errors.New("OldA requires an ID field in the mutation")
  1456. }
  1457. oldValue, err := m.oldValue(ctx)
  1458. if err != nil {
  1459. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1460. }
  1461. return oldValue.A, nil
  1462. }
  1463. // ClearA clears the value of the "a" field.
  1464. func (m *AgentBaseMutation) ClearA() {
  1465. m.a = nil
  1466. m.clearedFields[agentbase.FieldA] = struct{}{}
  1467. }
  1468. // ACleared returns if the "a" field was cleared in this mutation.
  1469. func (m *AgentBaseMutation) ACleared() bool {
  1470. _, ok := m.clearedFields[agentbase.FieldA]
  1471. return ok
  1472. }
  1473. // ResetA resets all changes to the "a" field.
  1474. func (m *AgentBaseMutation) ResetA() {
  1475. m.a = nil
  1476. delete(m.clearedFields, agentbase.FieldA)
  1477. }
  1478. // SetChunkIndex sets the "chunk_index" field.
  1479. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1480. m.chunk_index = &u
  1481. m.addchunk_index = nil
  1482. }
  1483. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1484. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1485. v := m.chunk_index
  1486. if v == nil {
  1487. return
  1488. }
  1489. return *v, true
  1490. }
  1491. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1492. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1494. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1495. if !m.op.Is(OpUpdateOne) {
  1496. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1497. }
  1498. if m.id == nil || m.oldValue == nil {
  1499. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1500. }
  1501. oldValue, err := m.oldValue(ctx)
  1502. if err != nil {
  1503. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1504. }
  1505. return oldValue.ChunkIndex, nil
  1506. }
  1507. // AddChunkIndex adds u to the "chunk_index" field.
  1508. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1509. if m.addchunk_index != nil {
  1510. *m.addchunk_index += u
  1511. } else {
  1512. m.addchunk_index = &u
  1513. }
  1514. }
  1515. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1516. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1517. v := m.addchunk_index
  1518. if v == nil {
  1519. return
  1520. }
  1521. return *v, true
  1522. }
  1523. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1524. func (m *AgentBaseMutation) ResetChunkIndex() {
  1525. m.chunk_index = nil
  1526. m.addchunk_index = nil
  1527. }
  1528. // SetIndexes sets the "indexes" field.
  1529. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1530. m.indexes = &s
  1531. m.appendindexes = nil
  1532. }
  1533. // Indexes returns the value of the "indexes" field in the mutation.
  1534. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1535. v := m.indexes
  1536. if v == nil {
  1537. return
  1538. }
  1539. return *v, true
  1540. }
  1541. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1542. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1544. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1545. if !m.op.Is(OpUpdateOne) {
  1546. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1547. }
  1548. if m.id == nil || m.oldValue == nil {
  1549. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1550. }
  1551. oldValue, err := m.oldValue(ctx)
  1552. if err != nil {
  1553. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1554. }
  1555. return oldValue.Indexes, nil
  1556. }
  1557. // AppendIndexes adds s to the "indexes" field.
  1558. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1559. m.appendindexes = append(m.appendindexes, s...)
  1560. }
  1561. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1562. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1563. if len(m.appendindexes) == 0 {
  1564. return nil, false
  1565. }
  1566. return m.appendindexes, true
  1567. }
  1568. // ClearIndexes clears the value of the "indexes" field.
  1569. func (m *AgentBaseMutation) ClearIndexes() {
  1570. m.indexes = nil
  1571. m.appendindexes = nil
  1572. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1573. }
  1574. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1575. func (m *AgentBaseMutation) IndexesCleared() bool {
  1576. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1577. return ok
  1578. }
  1579. // ResetIndexes resets all changes to the "indexes" field.
  1580. func (m *AgentBaseMutation) ResetIndexes() {
  1581. m.indexes = nil
  1582. m.appendindexes = nil
  1583. delete(m.clearedFields, agentbase.FieldIndexes)
  1584. }
  1585. // SetDatasetID sets the "dataset_id" field.
  1586. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1587. m.dataset_id = &s
  1588. }
  1589. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1590. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1591. v := m.dataset_id
  1592. if v == nil {
  1593. return
  1594. }
  1595. return *v, true
  1596. }
  1597. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1598. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1600. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1601. if !m.op.Is(OpUpdateOne) {
  1602. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1603. }
  1604. if m.id == nil || m.oldValue == nil {
  1605. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1606. }
  1607. oldValue, err := m.oldValue(ctx)
  1608. if err != nil {
  1609. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1610. }
  1611. return oldValue.DatasetID, nil
  1612. }
  1613. // ClearDatasetID clears the value of the "dataset_id" field.
  1614. func (m *AgentBaseMutation) ClearDatasetID() {
  1615. m.dataset_id = nil
  1616. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1617. }
  1618. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1619. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1620. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1621. return ok
  1622. }
  1623. // ResetDatasetID resets all changes to the "dataset_id" field.
  1624. func (m *AgentBaseMutation) ResetDatasetID() {
  1625. m.dataset_id = nil
  1626. delete(m.clearedFields, agentbase.FieldDatasetID)
  1627. }
  1628. // SetCollectionID sets the "collection_id" field.
  1629. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1630. m.collection_id = &s
  1631. }
  1632. // CollectionID returns the value of the "collection_id" field in the mutation.
  1633. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1634. v := m.collection_id
  1635. if v == nil {
  1636. return
  1637. }
  1638. return *v, true
  1639. }
  1640. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1641. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1643. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1644. if !m.op.Is(OpUpdateOne) {
  1645. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1646. }
  1647. if m.id == nil || m.oldValue == nil {
  1648. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1649. }
  1650. oldValue, err := m.oldValue(ctx)
  1651. if err != nil {
  1652. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1653. }
  1654. return oldValue.CollectionID, nil
  1655. }
  1656. // ClearCollectionID clears the value of the "collection_id" field.
  1657. func (m *AgentBaseMutation) ClearCollectionID() {
  1658. m.collection_id = nil
  1659. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1660. }
  1661. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1662. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1663. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1664. return ok
  1665. }
  1666. // ResetCollectionID resets all changes to the "collection_id" field.
  1667. func (m *AgentBaseMutation) ResetCollectionID() {
  1668. m.collection_id = nil
  1669. delete(m.clearedFields, agentbase.FieldCollectionID)
  1670. }
  1671. // SetSourceName sets the "source_name" field.
  1672. func (m *AgentBaseMutation) SetSourceName(s string) {
  1673. m.source_name = &s
  1674. }
  1675. // SourceName returns the value of the "source_name" field in the mutation.
  1676. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1677. v := m.source_name
  1678. if v == nil {
  1679. return
  1680. }
  1681. return *v, true
  1682. }
  1683. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1684. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1686. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1687. if !m.op.Is(OpUpdateOne) {
  1688. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1689. }
  1690. if m.id == nil || m.oldValue == nil {
  1691. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1692. }
  1693. oldValue, err := m.oldValue(ctx)
  1694. if err != nil {
  1695. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1696. }
  1697. return oldValue.SourceName, nil
  1698. }
  1699. // ClearSourceName clears the value of the "source_name" field.
  1700. func (m *AgentBaseMutation) ClearSourceName() {
  1701. m.source_name = nil
  1702. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1703. }
  1704. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1705. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1706. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1707. return ok
  1708. }
  1709. // ResetSourceName resets all changes to the "source_name" field.
  1710. func (m *AgentBaseMutation) ResetSourceName() {
  1711. m.source_name = nil
  1712. delete(m.clearedFields, agentbase.FieldSourceName)
  1713. }
  1714. // SetCanWrite sets the "can_write" field.
  1715. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1716. m.can_write = &b
  1717. m.appendcan_write = nil
  1718. }
  1719. // CanWrite returns the value of the "can_write" field in the mutation.
  1720. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1721. v := m.can_write
  1722. if v == nil {
  1723. return
  1724. }
  1725. return *v, true
  1726. }
  1727. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1728. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1730. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1731. if !m.op.Is(OpUpdateOne) {
  1732. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1733. }
  1734. if m.id == nil || m.oldValue == nil {
  1735. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1736. }
  1737. oldValue, err := m.oldValue(ctx)
  1738. if err != nil {
  1739. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1740. }
  1741. return oldValue.CanWrite, nil
  1742. }
  1743. // AppendCanWrite adds b to the "can_write" field.
  1744. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1745. m.appendcan_write = append(m.appendcan_write, b...)
  1746. }
  1747. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1748. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1749. if len(m.appendcan_write) == 0 {
  1750. return nil, false
  1751. }
  1752. return m.appendcan_write, true
  1753. }
  1754. // ClearCanWrite clears the value of the "can_write" field.
  1755. func (m *AgentBaseMutation) ClearCanWrite() {
  1756. m.can_write = nil
  1757. m.appendcan_write = nil
  1758. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1759. }
  1760. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1761. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1762. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1763. return ok
  1764. }
  1765. // ResetCanWrite resets all changes to the "can_write" field.
  1766. func (m *AgentBaseMutation) ResetCanWrite() {
  1767. m.can_write = nil
  1768. m.appendcan_write = nil
  1769. delete(m.clearedFields, agentbase.FieldCanWrite)
  1770. }
  1771. // SetIsOwner sets the "is_owner" field.
  1772. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1773. m.is_owner = &b
  1774. m.appendis_owner = nil
  1775. }
  1776. // IsOwner returns the value of the "is_owner" field in the mutation.
  1777. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1778. v := m.is_owner
  1779. if v == nil {
  1780. return
  1781. }
  1782. return *v, true
  1783. }
  1784. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1785. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1787. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1788. if !m.op.Is(OpUpdateOne) {
  1789. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1790. }
  1791. if m.id == nil || m.oldValue == nil {
  1792. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1793. }
  1794. oldValue, err := m.oldValue(ctx)
  1795. if err != nil {
  1796. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1797. }
  1798. return oldValue.IsOwner, nil
  1799. }
  1800. // AppendIsOwner adds b to the "is_owner" field.
  1801. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1802. m.appendis_owner = append(m.appendis_owner, b...)
  1803. }
  1804. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1805. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1806. if len(m.appendis_owner) == 0 {
  1807. return nil, false
  1808. }
  1809. return m.appendis_owner, true
  1810. }
  1811. // ClearIsOwner clears the value of the "is_owner" field.
  1812. func (m *AgentBaseMutation) ClearIsOwner() {
  1813. m.is_owner = nil
  1814. m.appendis_owner = nil
  1815. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1816. }
  1817. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1818. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1819. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1820. return ok
  1821. }
  1822. // ResetIsOwner resets all changes to the "is_owner" field.
  1823. func (m *AgentBaseMutation) ResetIsOwner() {
  1824. m.is_owner = nil
  1825. m.appendis_owner = nil
  1826. delete(m.clearedFields, agentbase.FieldIsOwner)
  1827. }
  1828. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1829. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1830. if m.wx_agent == nil {
  1831. m.wx_agent = make(map[uint64]struct{})
  1832. }
  1833. for i := range ids {
  1834. m.wx_agent[ids[i]] = struct{}{}
  1835. }
  1836. }
  1837. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1838. func (m *AgentBaseMutation) ClearWxAgent() {
  1839. m.clearedwx_agent = true
  1840. }
  1841. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1842. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1843. return m.clearedwx_agent
  1844. }
  1845. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1846. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1847. if m.removedwx_agent == nil {
  1848. m.removedwx_agent = make(map[uint64]struct{})
  1849. }
  1850. for i := range ids {
  1851. delete(m.wx_agent, ids[i])
  1852. m.removedwx_agent[ids[i]] = struct{}{}
  1853. }
  1854. }
  1855. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1856. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1857. for id := range m.removedwx_agent {
  1858. ids = append(ids, id)
  1859. }
  1860. return
  1861. }
  1862. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1863. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1864. for id := range m.wx_agent {
  1865. ids = append(ids, id)
  1866. }
  1867. return
  1868. }
  1869. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1870. func (m *AgentBaseMutation) ResetWxAgent() {
  1871. m.wx_agent = nil
  1872. m.clearedwx_agent = false
  1873. m.removedwx_agent = nil
  1874. }
  1875. // Where appends a list predicates to the AgentBaseMutation builder.
  1876. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1877. m.predicates = append(m.predicates, ps...)
  1878. }
  1879. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1880. // users can use type-assertion to append predicates that do not depend on any generated package.
  1881. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1882. p := make([]predicate.AgentBase, len(ps))
  1883. for i := range ps {
  1884. p[i] = ps[i]
  1885. }
  1886. m.Where(p...)
  1887. }
  1888. // Op returns the operation name.
  1889. func (m *AgentBaseMutation) Op() Op {
  1890. return m.op
  1891. }
  1892. // SetOp allows setting the mutation operation.
  1893. func (m *AgentBaseMutation) SetOp(op Op) {
  1894. m.op = op
  1895. }
  1896. // Type returns the node type of this mutation (AgentBase).
  1897. func (m *AgentBaseMutation) Type() string {
  1898. return m.typ
  1899. }
  1900. // Fields returns all fields that were changed during this mutation. Note that in
  1901. // order to get all numeric fields that were incremented/decremented, call
  1902. // AddedFields().
  1903. func (m *AgentBaseMutation) Fields() []string {
  1904. fields := make([]string, 0, 9)
  1905. if m.q != nil {
  1906. fields = append(fields, agentbase.FieldQ)
  1907. }
  1908. if m.a != nil {
  1909. fields = append(fields, agentbase.FieldA)
  1910. }
  1911. if m.chunk_index != nil {
  1912. fields = append(fields, agentbase.FieldChunkIndex)
  1913. }
  1914. if m.indexes != nil {
  1915. fields = append(fields, agentbase.FieldIndexes)
  1916. }
  1917. if m.dataset_id != nil {
  1918. fields = append(fields, agentbase.FieldDatasetID)
  1919. }
  1920. if m.collection_id != nil {
  1921. fields = append(fields, agentbase.FieldCollectionID)
  1922. }
  1923. if m.source_name != nil {
  1924. fields = append(fields, agentbase.FieldSourceName)
  1925. }
  1926. if m.can_write != nil {
  1927. fields = append(fields, agentbase.FieldCanWrite)
  1928. }
  1929. if m.is_owner != nil {
  1930. fields = append(fields, agentbase.FieldIsOwner)
  1931. }
  1932. return fields
  1933. }
  1934. // Field returns the value of a field with the given name. The second boolean
  1935. // return value indicates that this field was not set, or was not defined in the
  1936. // schema.
  1937. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1938. switch name {
  1939. case agentbase.FieldQ:
  1940. return m.Q()
  1941. case agentbase.FieldA:
  1942. return m.A()
  1943. case agentbase.FieldChunkIndex:
  1944. return m.ChunkIndex()
  1945. case agentbase.FieldIndexes:
  1946. return m.Indexes()
  1947. case agentbase.FieldDatasetID:
  1948. return m.DatasetID()
  1949. case agentbase.FieldCollectionID:
  1950. return m.CollectionID()
  1951. case agentbase.FieldSourceName:
  1952. return m.SourceName()
  1953. case agentbase.FieldCanWrite:
  1954. return m.CanWrite()
  1955. case agentbase.FieldIsOwner:
  1956. return m.IsOwner()
  1957. }
  1958. return nil, false
  1959. }
  1960. // OldField returns the old value of the field from the database. An error is
  1961. // returned if the mutation operation is not UpdateOne, or the query to the
  1962. // database failed.
  1963. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1964. switch name {
  1965. case agentbase.FieldQ:
  1966. return m.OldQ(ctx)
  1967. case agentbase.FieldA:
  1968. return m.OldA(ctx)
  1969. case agentbase.FieldChunkIndex:
  1970. return m.OldChunkIndex(ctx)
  1971. case agentbase.FieldIndexes:
  1972. return m.OldIndexes(ctx)
  1973. case agentbase.FieldDatasetID:
  1974. return m.OldDatasetID(ctx)
  1975. case agentbase.FieldCollectionID:
  1976. return m.OldCollectionID(ctx)
  1977. case agentbase.FieldSourceName:
  1978. return m.OldSourceName(ctx)
  1979. case agentbase.FieldCanWrite:
  1980. return m.OldCanWrite(ctx)
  1981. case agentbase.FieldIsOwner:
  1982. return m.OldIsOwner(ctx)
  1983. }
  1984. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1985. }
  1986. // SetField sets the value of a field with the given name. It returns an error if
  1987. // the field is not defined in the schema, or if the type mismatched the field
  1988. // type.
  1989. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1990. switch name {
  1991. case agentbase.FieldQ:
  1992. v, ok := value.(string)
  1993. if !ok {
  1994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1995. }
  1996. m.SetQ(v)
  1997. return nil
  1998. case agentbase.FieldA:
  1999. v, ok := value.(string)
  2000. if !ok {
  2001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2002. }
  2003. m.SetA(v)
  2004. return nil
  2005. case agentbase.FieldChunkIndex:
  2006. v, ok := value.(uint64)
  2007. if !ok {
  2008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2009. }
  2010. m.SetChunkIndex(v)
  2011. return nil
  2012. case agentbase.FieldIndexes:
  2013. v, ok := value.([]string)
  2014. if !ok {
  2015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2016. }
  2017. m.SetIndexes(v)
  2018. return nil
  2019. case agentbase.FieldDatasetID:
  2020. v, ok := value.(string)
  2021. if !ok {
  2022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2023. }
  2024. m.SetDatasetID(v)
  2025. return nil
  2026. case agentbase.FieldCollectionID:
  2027. v, ok := value.(string)
  2028. if !ok {
  2029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2030. }
  2031. m.SetCollectionID(v)
  2032. return nil
  2033. case agentbase.FieldSourceName:
  2034. v, ok := value.(string)
  2035. if !ok {
  2036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2037. }
  2038. m.SetSourceName(v)
  2039. return nil
  2040. case agentbase.FieldCanWrite:
  2041. v, ok := value.([]bool)
  2042. if !ok {
  2043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2044. }
  2045. m.SetCanWrite(v)
  2046. return nil
  2047. case agentbase.FieldIsOwner:
  2048. v, ok := value.([]bool)
  2049. if !ok {
  2050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2051. }
  2052. m.SetIsOwner(v)
  2053. return nil
  2054. }
  2055. return fmt.Errorf("unknown AgentBase field %s", name)
  2056. }
  2057. // AddedFields returns all numeric fields that were incremented/decremented during
  2058. // this mutation.
  2059. func (m *AgentBaseMutation) AddedFields() []string {
  2060. var fields []string
  2061. if m.addchunk_index != nil {
  2062. fields = append(fields, agentbase.FieldChunkIndex)
  2063. }
  2064. return fields
  2065. }
  2066. // AddedField returns the numeric value that was incremented/decremented on a field
  2067. // with the given name. The second boolean return value indicates that this field
  2068. // was not set, or was not defined in the schema.
  2069. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2070. switch name {
  2071. case agentbase.FieldChunkIndex:
  2072. return m.AddedChunkIndex()
  2073. }
  2074. return nil, false
  2075. }
  2076. // AddField adds the value to the field with the given name. It returns an error if
  2077. // the field is not defined in the schema, or if the type mismatched the field
  2078. // type.
  2079. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2080. switch name {
  2081. case agentbase.FieldChunkIndex:
  2082. v, ok := value.(int64)
  2083. if !ok {
  2084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2085. }
  2086. m.AddChunkIndex(v)
  2087. return nil
  2088. }
  2089. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2090. }
  2091. // ClearedFields returns all nullable fields that were cleared during this
  2092. // mutation.
  2093. func (m *AgentBaseMutation) ClearedFields() []string {
  2094. var fields []string
  2095. if m.FieldCleared(agentbase.FieldQ) {
  2096. fields = append(fields, agentbase.FieldQ)
  2097. }
  2098. if m.FieldCleared(agentbase.FieldA) {
  2099. fields = append(fields, agentbase.FieldA)
  2100. }
  2101. if m.FieldCleared(agentbase.FieldIndexes) {
  2102. fields = append(fields, agentbase.FieldIndexes)
  2103. }
  2104. if m.FieldCleared(agentbase.FieldDatasetID) {
  2105. fields = append(fields, agentbase.FieldDatasetID)
  2106. }
  2107. if m.FieldCleared(agentbase.FieldCollectionID) {
  2108. fields = append(fields, agentbase.FieldCollectionID)
  2109. }
  2110. if m.FieldCleared(agentbase.FieldSourceName) {
  2111. fields = append(fields, agentbase.FieldSourceName)
  2112. }
  2113. if m.FieldCleared(agentbase.FieldCanWrite) {
  2114. fields = append(fields, agentbase.FieldCanWrite)
  2115. }
  2116. if m.FieldCleared(agentbase.FieldIsOwner) {
  2117. fields = append(fields, agentbase.FieldIsOwner)
  2118. }
  2119. return fields
  2120. }
  2121. // FieldCleared returns a boolean indicating if a field with the given name was
  2122. // cleared in this mutation.
  2123. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2124. _, ok := m.clearedFields[name]
  2125. return ok
  2126. }
  2127. // ClearField clears the value of the field with the given name. It returns an
  2128. // error if the field is not defined in the schema.
  2129. func (m *AgentBaseMutation) ClearField(name string) error {
  2130. switch name {
  2131. case agentbase.FieldQ:
  2132. m.ClearQ()
  2133. return nil
  2134. case agentbase.FieldA:
  2135. m.ClearA()
  2136. return nil
  2137. case agentbase.FieldIndexes:
  2138. m.ClearIndexes()
  2139. return nil
  2140. case agentbase.FieldDatasetID:
  2141. m.ClearDatasetID()
  2142. return nil
  2143. case agentbase.FieldCollectionID:
  2144. m.ClearCollectionID()
  2145. return nil
  2146. case agentbase.FieldSourceName:
  2147. m.ClearSourceName()
  2148. return nil
  2149. case agentbase.FieldCanWrite:
  2150. m.ClearCanWrite()
  2151. return nil
  2152. case agentbase.FieldIsOwner:
  2153. m.ClearIsOwner()
  2154. return nil
  2155. }
  2156. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2157. }
  2158. // ResetField resets all changes in the mutation for the field with the given name.
  2159. // It returns an error if the field is not defined in the schema.
  2160. func (m *AgentBaseMutation) ResetField(name string) error {
  2161. switch name {
  2162. case agentbase.FieldQ:
  2163. m.ResetQ()
  2164. return nil
  2165. case agentbase.FieldA:
  2166. m.ResetA()
  2167. return nil
  2168. case agentbase.FieldChunkIndex:
  2169. m.ResetChunkIndex()
  2170. return nil
  2171. case agentbase.FieldIndexes:
  2172. m.ResetIndexes()
  2173. return nil
  2174. case agentbase.FieldDatasetID:
  2175. m.ResetDatasetID()
  2176. return nil
  2177. case agentbase.FieldCollectionID:
  2178. m.ResetCollectionID()
  2179. return nil
  2180. case agentbase.FieldSourceName:
  2181. m.ResetSourceName()
  2182. return nil
  2183. case agentbase.FieldCanWrite:
  2184. m.ResetCanWrite()
  2185. return nil
  2186. case agentbase.FieldIsOwner:
  2187. m.ResetIsOwner()
  2188. return nil
  2189. }
  2190. return fmt.Errorf("unknown AgentBase field %s", name)
  2191. }
  2192. // AddedEdges returns all edge names that were set/added in this mutation.
  2193. func (m *AgentBaseMutation) AddedEdges() []string {
  2194. edges := make([]string, 0, 1)
  2195. if m.wx_agent != nil {
  2196. edges = append(edges, agentbase.EdgeWxAgent)
  2197. }
  2198. return edges
  2199. }
  2200. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2201. // name in this mutation.
  2202. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2203. switch name {
  2204. case agentbase.EdgeWxAgent:
  2205. ids := make([]ent.Value, 0, len(m.wx_agent))
  2206. for id := range m.wx_agent {
  2207. ids = append(ids, id)
  2208. }
  2209. return ids
  2210. }
  2211. return nil
  2212. }
  2213. // RemovedEdges returns all edge names that were removed in this mutation.
  2214. func (m *AgentBaseMutation) RemovedEdges() []string {
  2215. edges := make([]string, 0, 1)
  2216. if m.removedwx_agent != nil {
  2217. edges = append(edges, agentbase.EdgeWxAgent)
  2218. }
  2219. return edges
  2220. }
  2221. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2222. // the given name in this mutation.
  2223. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2224. switch name {
  2225. case agentbase.EdgeWxAgent:
  2226. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2227. for id := range m.removedwx_agent {
  2228. ids = append(ids, id)
  2229. }
  2230. return ids
  2231. }
  2232. return nil
  2233. }
  2234. // ClearedEdges returns all edge names that were cleared in this mutation.
  2235. func (m *AgentBaseMutation) ClearedEdges() []string {
  2236. edges := make([]string, 0, 1)
  2237. if m.clearedwx_agent {
  2238. edges = append(edges, agentbase.EdgeWxAgent)
  2239. }
  2240. return edges
  2241. }
  2242. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2243. // was cleared in this mutation.
  2244. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2245. switch name {
  2246. case agentbase.EdgeWxAgent:
  2247. return m.clearedwx_agent
  2248. }
  2249. return false
  2250. }
  2251. // ClearEdge clears the value of the edge with the given name. It returns an error
  2252. // if that edge is not defined in the schema.
  2253. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2254. switch name {
  2255. }
  2256. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2257. }
  2258. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2259. // It returns an error if the edge is not defined in the schema.
  2260. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2261. switch name {
  2262. case agentbase.EdgeWxAgent:
  2263. m.ResetWxAgent()
  2264. return nil
  2265. }
  2266. return fmt.Errorf("unknown AgentBase edge %s", name)
  2267. }
  2268. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2269. type AliyunAvatarMutation struct {
  2270. config
  2271. op Op
  2272. typ string
  2273. id *uint64
  2274. created_at *time.Time
  2275. updated_at *time.Time
  2276. deleted_at *time.Time
  2277. user_id *uint64
  2278. adduser_id *int64
  2279. biz_id *string
  2280. access_key_id *string
  2281. access_key_secret *string
  2282. app_id *string
  2283. tenant_id *uint64
  2284. addtenant_id *int64
  2285. response *string
  2286. token *string
  2287. session_id *string
  2288. clearedFields map[string]struct{}
  2289. done bool
  2290. oldValue func(context.Context) (*AliyunAvatar, error)
  2291. predicates []predicate.AliyunAvatar
  2292. }
  2293. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2294. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2295. type aliyunavatarOption func(*AliyunAvatarMutation)
  2296. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2297. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2298. m := &AliyunAvatarMutation{
  2299. config: c,
  2300. op: op,
  2301. typ: TypeAliyunAvatar,
  2302. clearedFields: make(map[string]struct{}),
  2303. }
  2304. for _, opt := range opts {
  2305. opt(m)
  2306. }
  2307. return m
  2308. }
  2309. // withAliyunAvatarID sets the ID field of the mutation.
  2310. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2311. return func(m *AliyunAvatarMutation) {
  2312. var (
  2313. err error
  2314. once sync.Once
  2315. value *AliyunAvatar
  2316. )
  2317. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2318. once.Do(func() {
  2319. if m.done {
  2320. err = errors.New("querying old values post mutation is not allowed")
  2321. } else {
  2322. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2323. }
  2324. })
  2325. return value, err
  2326. }
  2327. m.id = &id
  2328. }
  2329. }
  2330. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2331. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2332. return func(m *AliyunAvatarMutation) {
  2333. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2334. return node, nil
  2335. }
  2336. m.id = &node.ID
  2337. }
  2338. }
  2339. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2340. // executed in a transaction (ent.Tx), a transactional client is returned.
  2341. func (m AliyunAvatarMutation) Client() *Client {
  2342. client := &Client{config: m.config}
  2343. client.init()
  2344. return client
  2345. }
  2346. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2347. // it returns an error otherwise.
  2348. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2349. if _, ok := m.driver.(*txDriver); !ok {
  2350. return nil, errors.New("ent: mutation is not running in a transaction")
  2351. }
  2352. tx := &Tx{config: m.config}
  2353. tx.init()
  2354. return tx, nil
  2355. }
  2356. // SetID sets the value of the id field. Note that this
  2357. // operation is only accepted on creation of AliyunAvatar entities.
  2358. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2359. m.id = &id
  2360. }
  2361. // ID returns the ID value in the mutation. Note that the ID is only available
  2362. // if it was provided to the builder or after it was returned from the database.
  2363. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2364. if m.id == nil {
  2365. return
  2366. }
  2367. return *m.id, true
  2368. }
  2369. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2370. // That means, if the mutation is applied within a transaction with an isolation level such
  2371. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2372. // or updated by the mutation.
  2373. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2374. switch {
  2375. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2376. id, exists := m.ID()
  2377. if exists {
  2378. return []uint64{id}, nil
  2379. }
  2380. fallthrough
  2381. case m.op.Is(OpUpdate | OpDelete):
  2382. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2383. default:
  2384. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2385. }
  2386. }
  2387. // SetCreatedAt sets the "created_at" field.
  2388. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2389. m.created_at = &t
  2390. }
  2391. // CreatedAt returns the value of the "created_at" field in the mutation.
  2392. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2393. v := m.created_at
  2394. if v == nil {
  2395. return
  2396. }
  2397. return *v, true
  2398. }
  2399. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2400. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2402. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2403. if !m.op.Is(OpUpdateOne) {
  2404. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2405. }
  2406. if m.id == nil || m.oldValue == nil {
  2407. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2408. }
  2409. oldValue, err := m.oldValue(ctx)
  2410. if err != nil {
  2411. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2412. }
  2413. return oldValue.CreatedAt, nil
  2414. }
  2415. // ResetCreatedAt resets all changes to the "created_at" field.
  2416. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2417. m.created_at = nil
  2418. }
  2419. // SetUpdatedAt sets the "updated_at" field.
  2420. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2421. m.updated_at = &t
  2422. }
  2423. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2424. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2425. v := m.updated_at
  2426. if v == nil {
  2427. return
  2428. }
  2429. return *v, true
  2430. }
  2431. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2432. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2434. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2435. if !m.op.Is(OpUpdateOne) {
  2436. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2437. }
  2438. if m.id == nil || m.oldValue == nil {
  2439. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2440. }
  2441. oldValue, err := m.oldValue(ctx)
  2442. if err != nil {
  2443. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2444. }
  2445. return oldValue.UpdatedAt, nil
  2446. }
  2447. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2448. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2449. m.updated_at = nil
  2450. }
  2451. // SetDeletedAt sets the "deleted_at" field.
  2452. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2453. m.deleted_at = &t
  2454. }
  2455. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2456. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2457. v := m.deleted_at
  2458. if v == nil {
  2459. return
  2460. }
  2461. return *v, true
  2462. }
  2463. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2464. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2466. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2467. if !m.op.Is(OpUpdateOne) {
  2468. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2469. }
  2470. if m.id == nil || m.oldValue == nil {
  2471. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2472. }
  2473. oldValue, err := m.oldValue(ctx)
  2474. if err != nil {
  2475. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2476. }
  2477. return oldValue.DeletedAt, nil
  2478. }
  2479. // ClearDeletedAt clears the value of the "deleted_at" field.
  2480. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2481. m.deleted_at = nil
  2482. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2483. }
  2484. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2485. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2486. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2487. return ok
  2488. }
  2489. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2490. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2491. m.deleted_at = nil
  2492. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2493. }
  2494. // SetUserID sets the "user_id" field.
  2495. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2496. m.user_id = &u
  2497. m.adduser_id = nil
  2498. }
  2499. // UserID returns the value of the "user_id" field in the mutation.
  2500. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2501. v := m.user_id
  2502. if v == nil {
  2503. return
  2504. }
  2505. return *v, true
  2506. }
  2507. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2508. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2510. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2511. if !m.op.Is(OpUpdateOne) {
  2512. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2513. }
  2514. if m.id == nil || m.oldValue == nil {
  2515. return v, errors.New("OldUserID requires an ID field in the mutation")
  2516. }
  2517. oldValue, err := m.oldValue(ctx)
  2518. if err != nil {
  2519. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2520. }
  2521. return oldValue.UserID, nil
  2522. }
  2523. // AddUserID adds u to the "user_id" field.
  2524. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2525. if m.adduser_id != nil {
  2526. *m.adduser_id += u
  2527. } else {
  2528. m.adduser_id = &u
  2529. }
  2530. }
  2531. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2532. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2533. v := m.adduser_id
  2534. if v == nil {
  2535. return
  2536. }
  2537. return *v, true
  2538. }
  2539. // ResetUserID resets all changes to the "user_id" field.
  2540. func (m *AliyunAvatarMutation) ResetUserID() {
  2541. m.user_id = nil
  2542. m.adduser_id = nil
  2543. }
  2544. // SetBizID sets the "biz_id" field.
  2545. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2546. m.biz_id = &s
  2547. }
  2548. // BizID returns the value of the "biz_id" field in the mutation.
  2549. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2550. v := m.biz_id
  2551. if v == nil {
  2552. return
  2553. }
  2554. return *v, true
  2555. }
  2556. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2557. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2559. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2560. if !m.op.Is(OpUpdateOne) {
  2561. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2562. }
  2563. if m.id == nil || m.oldValue == nil {
  2564. return v, errors.New("OldBizID requires an ID field in the mutation")
  2565. }
  2566. oldValue, err := m.oldValue(ctx)
  2567. if err != nil {
  2568. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2569. }
  2570. return oldValue.BizID, nil
  2571. }
  2572. // ResetBizID resets all changes to the "biz_id" field.
  2573. func (m *AliyunAvatarMutation) ResetBizID() {
  2574. m.biz_id = nil
  2575. }
  2576. // SetAccessKeyID sets the "access_key_id" field.
  2577. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2578. m.access_key_id = &s
  2579. }
  2580. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2581. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2582. v := m.access_key_id
  2583. if v == nil {
  2584. return
  2585. }
  2586. return *v, true
  2587. }
  2588. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2589. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2591. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2592. if !m.op.Is(OpUpdateOne) {
  2593. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2594. }
  2595. if m.id == nil || m.oldValue == nil {
  2596. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2597. }
  2598. oldValue, err := m.oldValue(ctx)
  2599. if err != nil {
  2600. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2601. }
  2602. return oldValue.AccessKeyID, nil
  2603. }
  2604. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2605. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2606. m.access_key_id = nil
  2607. }
  2608. // SetAccessKeySecret sets the "access_key_secret" field.
  2609. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2610. m.access_key_secret = &s
  2611. }
  2612. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2613. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2614. v := m.access_key_secret
  2615. if v == nil {
  2616. return
  2617. }
  2618. return *v, true
  2619. }
  2620. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2621. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2623. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2624. if !m.op.Is(OpUpdateOne) {
  2625. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2626. }
  2627. if m.id == nil || m.oldValue == nil {
  2628. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2629. }
  2630. oldValue, err := m.oldValue(ctx)
  2631. if err != nil {
  2632. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2633. }
  2634. return oldValue.AccessKeySecret, nil
  2635. }
  2636. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2637. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2638. m.access_key_secret = nil
  2639. }
  2640. // SetAppID sets the "app_id" field.
  2641. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2642. m.app_id = &s
  2643. }
  2644. // AppID returns the value of the "app_id" field in the mutation.
  2645. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2646. v := m.app_id
  2647. if v == nil {
  2648. return
  2649. }
  2650. return *v, true
  2651. }
  2652. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2653. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2655. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2656. if !m.op.Is(OpUpdateOne) {
  2657. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2658. }
  2659. if m.id == nil || m.oldValue == nil {
  2660. return v, errors.New("OldAppID requires an ID field in the mutation")
  2661. }
  2662. oldValue, err := m.oldValue(ctx)
  2663. if err != nil {
  2664. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2665. }
  2666. return oldValue.AppID, nil
  2667. }
  2668. // ClearAppID clears the value of the "app_id" field.
  2669. func (m *AliyunAvatarMutation) ClearAppID() {
  2670. m.app_id = nil
  2671. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2672. }
  2673. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2674. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2675. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2676. return ok
  2677. }
  2678. // ResetAppID resets all changes to the "app_id" field.
  2679. func (m *AliyunAvatarMutation) ResetAppID() {
  2680. m.app_id = nil
  2681. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2682. }
  2683. // SetTenantID sets the "tenant_id" field.
  2684. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2685. m.tenant_id = &u
  2686. m.addtenant_id = nil
  2687. }
  2688. // TenantID returns the value of the "tenant_id" field in the mutation.
  2689. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2690. v := m.tenant_id
  2691. if v == nil {
  2692. return
  2693. }
  2694. return *v, true
  2695. }
  2696. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2697. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2699. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2700. if !m.op.Is(OpUpdateOne) {
  2701. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2702. }
  2703. if m.id == nil || m.oldValue == nil {
  2704. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2705. }
  2706. oldValue, err := m.oldValue(ctx)
  2707. if err != nil {
  2708. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2709. }
  2710. return oldValue.TenantID, nil
  2711. }
  2712. // AddTenantID adds u to the "tenant_id" field.
  2713. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2714. if m.addtenant_id != nil {
  2715. *m.addtenant_id += u
  2716. } else {
  2717. m.addtenant_id = &u
  2718. }
  2719. }
  2720. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2721. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2722. v := m.addtenant_id
  2723. if v == nil {
  2724. return
  2725. }
  2726. return *v, true
  2727. }
  2728. // ResetTenantID resets all changes to the "tenant_id" field.
  2729. func (m *AliyunAvatarMutation) ResetTenantID() {
  2730. m.tenant_id = nil
  2731. m.addtenant_id = nil
  2732. }
  2733. // SetResponse sets the "response" field.
  2734. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2735. m.response = &s
  2736. }
  2737. // Response returns the value of the "response" field in the mutation.
  2738. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2739. v := m.response
  2740. if v == nil {
  2741. return
  2742. }
  2743. return *v, true
  2744. }
  2745. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2746. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2748. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2749. if !m.op.Is(OpUpdateOne) {
  2750. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2751. }
  2752. if m.id == nil || m.oldValue == nil {
  2753. return v, errors.New("OldResponse requires an ID field in the mutation")
  2754. }
  2755. oldValue, err := m.oldValue(ctx)
  2756. if err != nil {
  2757. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2758. }
  2759. return oldValue.Response, nil
  2760. }
  2761. // ResetResponse resets all changes to the "response" field.
  2762. func (m *AliyunAvatarMutation) ResetResponse() {
  2763. m.response = nil
  2764. }
  2765. // SetToken sets the "token" field.
  2766. func (m *AliyunAvatarMutation) SetToken(s string) {
  2767. m.token = &s
  2768. }
  2769. // Token returns the value of the "token" field in the mutation.
  2770. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2771. v := m.token
  2772. if v == nil {
  2773. return
  2774. }
  2775. return *v, true
  2776. }
  2777. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2778. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2780. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2781. if !m.op.Is(OpUpdateOne) {
  2782. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2783. }
  2784. if m.id == nil || m.oldValue == nil {
  2785. return v, errors.New("OldToken requires an ID field in the mutation")
  2786. }
  2787. oldValue, err := m.oldValue(ctx)
  2788. if err != nil {
  2789. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2790. }
  2791. return oldValue.Token, nil
  2792. }
  2793. // ResetToken resets all changes to the "token" field.
  2794. func (m *AliyunAvatarMutation) ResetToken() {
  2795. m.token = nil
  2796. }
  2797. // SetSessionID sets the "session_id" field.
  2798. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2799. m.session_id = &s
  2800. }
  2801. // SessionID returns the value of the "session_id" field in the mutation.
  2802. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2803. v := m.session_id
  2804. if v == nil {
  2805. return
  2806. }
  2807. return *v, true
  2808. }
  2809. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2810. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2812. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2813. if !m.op.Is(OpUpdateOne) {
  2814. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2815. }
  2816. if m.id == nil || m.oldValue == nil {
  2817. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2818. }
  2819. oldValue, err := m.oldValue(ctx)
  2820. if err != nil {
  2821. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2822. }
  2823. return oldValue.SessionID, nil
  2824. }
  2825. // ResetSessionID resets all changes to the "session_id" field.
  2826. func (m *AliyunAvatarMutation) ResetSessionID() {
  2827. m.session_id = nil
  2828. }
  2829. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2830. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2831. m.predicates = append(m.predicates, ps...)
  2832. }
  2833. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2834. // users can use type-assertion to append predicates that do not depend on any generated package.
  2835. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2836. p := make([]predicate.AliyunAvatar, len(ps))
  2837. for i := range ps {
  2838. p[i] = ps[i]
  2839. }
  2840. m.Where(p...)
  2841. }
  2842. // Op returns the operation name.
  2843. func (m *AliyunAvatarMutation) Op() Op {
  2844. return m.op
  2845. }
  2846. // SetOp allows setting the mutation operation.
  2847. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2848. m.op = op
  2849. }
  2850. // Type returns the node type of this mutation (AliyunAvatar).
  2851. func (m *AliyunAvatarMutation) Type() string {
  2852. return m.typ
  2853. }
  2854. // Fields returns all fields that were changed during this mutation. Note that in
  2855. // order to get all numeric fields that were incremented/decremented, call
  2856. // AddedFields().
  2857. func (m *AliyunAvatarMutation) Fields() []string {
  2858. fields := make([]string, 0, 12)
  2859. if m.created_at != nil {
  2860. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2861. }
  2862. if m.updated_at != nil {
  2863. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2864. }
  2865. if m.deleted_at != nil {
  2866. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2867. }
  2868. if m.user_id != nil {
  2869. fields = append(fields, aliyunavatar.FieldUserID)
  2870. }
  2871. if m.biz_id != nil {
  2872. fields = append(fields, aliyunavatar.FieldBizID)
  2873. }
  2874. if m.access_key_id != nil {
  2875. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2876. }
  2877. if m.access_key_secret != nil {
  2878. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2879. }
  2880. if m.app_id != nil {
  2881. fields = append(fields, aliyunavatar.FieldAppID)
  2882. }
  2883. if m.tenant_id != nil {
  2884. fields = append(fields, aliyunavatar.FieldTenantID)
  2885. }
  2886. if m.response != nil {
  2887. fields = append(fields, aliyunavatar.FieldResponse)
  2888. }
  2889. if m.token != nil {
  2890. fields = append(fields, aliyunavatar.FieldToken)
  2891. }
  2892. if m.session_id != nil {
  2893. fields = append(fields, aliyunavatar.FieldSessionID)
  2894. }
  2895. return fields
  2896. }
  2897. // Field returns the value of a field with the given name. The second boolean
  2898. // return value indicates that this field was not set, or was not defined in the
  2899. // schema.
  2900. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2901. switch name {
  2902. case aliyunavatar.FieldCreatedAt:
  2903. return m.CreatedAt()
  2904. case aliyunavatar.FieldUpdatedAt:
  2905. return m.UpdatedAt()
  2906. case aliyunavatar.FieldDeletedAt:
  2907. return m.DeletedAt()
  2908. case aliyunavatar.FieldUserID:
  2909. return m.UserID()
  2910. case aliyunavatar.FieldBizID:
  2911. return m.BizID()
  2912. case aliyunavatar.FieldAccessKeyID:
  2913. return m.AccessKeyID()
  2914. case aliyunavatar.FieldAccessKeySecret:
  2915. return m.AccessKeySecret()
  2916. case aliyunavatar.FieldAppID:
  2917. return m.AppID()
  2918. case aliyunavatar.FieldTenantID:
  2919. return m.TenantID()
  2920. case aliyunavatar.FieldResponse:
  2921. return m.Response()
  2922. case aliyunavatar.FieldToken:
  2923. return m.Token()
  2924. case aliyunavatar.FieldSessionID:
  2925. return m.SessionID()
  2926. }
  2927. return nil, false
  2928. }
  2929. // OldField returns the old value of the field from the database. An error is
  2930. // returned if the mutation operation is not UpdateOne, or the query to the
  2931. // database failed.
  2932. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2933. switch name {
  2934. case aliyunavatar.FieldCreatedAt:
  2935. return m.OldCreatedAt(ctx)
  2936. case aliyunavatar.FieldUpdatedAt:
  2937. return m.OldUpdatedAt(ctx)
  2938. case aliyunavatar.FieldDeletedAt:
  2939. return m.OldDeletedAt(ctx)
  2940. case aliyunavatar.FieldUserID:
  2941. return m.OldUserID(ctx)
  2942. case aliyunavatar.FieldBizID:
  2943. return m.OldBizID(ctx)
  2944. case aliyunavatar.FieldAccessKeyID:
  2945. return m.OldAccessKeyID(ctx)
  2946. case aliyunavatar.FieldAccessKeySecret:
  2947. return m.OldAccessKeySecret(ctx)
  2948. case aliyunavatar.FieldAppID:
  2949. return m.OldAppID(ctx)
  2950. case aliyunavatar.FieldTenantID:
  2951. return m.OldTenantID(ctx)
  2952. case aliyunavatar.FieldResponse:
  2953. return m.OldResponse(ctx)
  2954. case aliyunavatar.FieldToken:
  2955. return m.OldToken(ctx)
  2956. case aliyunavatar.FieldSessionID:
  2957. return m.OldSessionID(ctx)
  2958. }
  2959. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2960. }
  2961. // SetField sets the value of a field with the given name. It returns an error if
  2962. // the field is not defined in the schema, or if the type mismatched the field
  2963. // type.
  2964. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2965. switch name {
  2966. case aliyunavatar.FieldCreatedAt:
  2967. v, ok := value.(time.Time)
  2968. if !ok {
  2969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2970. }
  2971. m.SetCreatedAt(v)
  2972. return nil
  2973. case aliyunavatar.FieldUpdatedAt:
  2974. v, ok := value.(time.Time)
  2975. if !ok {
  2976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2977. }
  2978. m.SetUpdatedAt(v)
  2979. return nil
  2980. case aliyunavatar.FieldDeletedAt:
  2981. v, ok := value.(time.Time)
  2982. if !ok {
  2983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2984. }
  2985. m.SetDeletedAt(v)
  2986. return nil
  2987. case aliyunavatar.FieldUserID:
  2988. v, ok := value.(uint64)
  2989. if !ok {
  2990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2991. }
  2992. m.SetUserID(v)
  2993. return nil
  2994. case aliyunavatar.FieldBizID:
  2995. v, ok := value.(string)
  2996. if !ok {
  2997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2998. }
  2999. m.SetBizID(v)
  3000. return nil
  3001. case aliyunavatar.FieldAccessKeyID:
  3002. v, ok := value.(string)
  3003. if !ok {
  3004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3005. }
  3006. m.SetAccessKeyID(v)
  3007. return nil
  3008. case aliyunavatar.FieldAccessKeySecret:
  3009. v, ok := value.(string)
  3010. if !ok {
  3011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3012. }
  3013. m.SetAccessKeySecret(v)
  3014. return nil
  3015. case aliyunavatar.FieldAppID:
  3016. v, ok := value.(string)
  3017. if !ok {
  3018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3019. }
  3020. m.SetAppID(v)
  3021. return nil
  3022. case aliyunavatar.FieldTenantID:
  3023. v, ok := value.(uint64)
  3024. if !ok {
  3025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3026. }
  3027. m.SetTenantID(v)
  3028. return nil
  3029. case aliyunavatar.FieldResponse:
  3030. v, ok := value.(string)
  3031. if !ok {
  3032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3033. }
  3034. m.SetResponse(v)
  3035. return nil
  3036. case aliyunavatar.FieldToken:
  3037. v, ok := value.(string)
  3038. if !ok {
  3039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3040. }
  3041. m.SetToken(v)
  3042. return nil
  3043. case aliyunavatar.FieldSessionID:
  3044. v, ok := value.(string)
  3045. if !ok {
  3046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3047. }
  3048. m.SetSessionID(v)
  3049. return nil
  3050. }
  3051. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3052. }
  3053. // AddedFields returns all numeric fields that were incremented/decremented during
  3054. // this mutation.
  3055. func (m *AliyunAvatarMutation) AddedFields() []string {
  3056. var fields []string
  3057. if m.adduser_id != nil {
  3058. fields = append(fields, aliyunavatar.FieldUserID)
  3059. }
  3060. if m.addtenant_id != nil {
  3061. fields = append(fields, aliyunavatar.FieldTenantID)
  3062. }
  3063. return fields
  3064. }
  3065. // AddedField returns the numeric value that was incremented/decremented on a field
  3066. // with the given name. The second boolean return value indicates that this field
  3067. // was not set, or was not defined in the schema.
  3068. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3069. switch name {
  3070. case aliyunavatar.FieldUserID:
  3071. return m.AddedUserID()
  3072. case aliyunavatar.FieldTenantID:
  3073. return m.AddedTenantID()
  3074. }
  3075. return nil, false
  3076. }
  3077. // AddField adds the value to the field with the given name. It returns an error if
  3078. // the field is not defined in the schema, or if the type mismatched the field
  3079. // type.
  3080. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3081. switch name {
  3082. case aliyunavatar.FieldUserID:
  3083. v, ok := value.(int64)
  3084. if !ok {
  3085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3086. }
  3087. m.AddUserID(v)
  3088. return nil
  3089. case aliyunavatar.FieldTenantID:
  3090. v, ok := value.(int64)
  3091. if !ok {
  3092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3093. }
  3094. m.AddTenantID(v)
  3095. return nil
  3096. }
  3097. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3098. }
  3099. // ClearedFields returns all nullable fields that were cleared during this
  3100. // mutation.
  3101. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3102. var fields []string
  3103. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3104. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3105. }
  3106. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3107. fields = append(fields, aliyunavatar.FieldAppID)
  3108. }
  3109. return fields
  3110. }
  3111. // FieldCleared returns a boolean indicating if a field with the given name was
  3112. // cleared in this mutation.
  3113. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3114. _, ok := m.clearedFields[name]
  3115. return ok
  3116. }
  3117. // ClearField clears the value of the field with the given name. It returns an
  3118. // error if the field is not defined in the schema.
  3119. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3120. switch name {
  3121. case aliyunavatar.FieldDeletedAt:
  3122. m.ClearDeletedAt()
  3123. return nil
  3124. case aliyunavatar.FieldAppID:
  3125. m.ClearAppID()
  3126. return nil
  3127. }
  3128. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3129. }
  3130. // ResetField resets all changes in the mutation for the field with the given name.
  3131. // It returns an error if the field is not defined in the schema.
  3132. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3133. switch name {
  3134. case aliyunavatar.FieldCreatedAt:
  3135. m.ResetCreatedAt()
  3136. return nil
  3137. case aliyunavatar.FieldUpdatedAt:
  3138. m.ResetUpdatedAt()
  3139. return nil
  3140. case aliyunavatar.FieldDeletedAt:
  3141. m.ResetDeletedAt()
  3142. return nil
  3143. case aliyunavatar.FieldUserID:
  3144. m.ResetUserID()
  3145. return nil
  3146. case aliyunavatar.FieldBizID:
  3147. m.ResetBizID()
  3148. return nil
  3149. case aliyunavatar.FieldAccessKeyID:
  3150. m.ResetAccessKeyID()
  3151. return nil
  3152. case aliyunavatar.FieldAccessKeySecret:
  3153. m.ResetAccessKeySecret()
  3154. return nil
  3155. case aliyunavatar.FieldAppID:
  3156. m.ResetAppID()
  3157. return nil
  3158. case aliyunavatar.FieldTenantID:
  3159. m.ResetTenantID()
  3160. return nil
  3161. case aliyunavatar.FieldResponse:
  3162. m.ResetResponse()
  3163. return nil
  3164. case aliyunavatar.FieldToken:
  3165. m.ResetToken()
  3166. return nil
  3167. case aliyunavatar.FieldSessionID:
  3168. m.ResetSessionID()
  3169. return nil
  3170. }
  3171. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3172. }
  3173. // AddedEdges returns all edge names that were set/added in this mutation.
  3174. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3175. edges := make([]string, 0, 0)
  3176. return edges
  3177. }
  3178. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3179. // name in this mutation.
  3180. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3181. return nil
  3182. }
  3183. // RemovedEdges returns all edge names that were removed in this mutation.
  3184. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3185. edges := make([]string, 0, 0)
  3186. return edges
  3187. }
  3188. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3189. // the given name in this mutation.
  3190. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3191. return nil
  3192. }
  3193. // ClearedEdges returns all edge names that were cleared in this mutation.
  3194. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3195. edges := make([]string, 0, 0)
  3196. return edges
  3197. }
  3198. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3199. // was cleared in this mutation.
  3200. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3201. return false
  3202. }
  3203. // ClearEdge clears the value of the edge with the given name. It returns an error
  3204. // if that edge is not defined in the schema.
  3205. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3206. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3207. }
  3208. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3209. // It returns an error if the edge is not defined in the schema.
  3210. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3211. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3212. }
  3213. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3214. type AllocAgentMutation struct {
  3215. config
  3216. op Op
  3217. typ string
  3218. id *uint64
  3219. created_at *time.Time
  3220. updated_at *time.Time
  3221. deleted_at *time.Time
  3222. user_id *string
  3223. organization_id *uint64
  3224. addorganization_id *int64
  3225. agents *[]uint64
  3226. appendagents []uint64
  3227. status *int
  3228. addstatus *int
  3229. clearedFields map[string]struct{}
  3230. done bool
  3231. oldValue func(context.Context) (*AllocAgent, error)
  3232. predicates []predicate.AllocAgent
  3233. }
  3234. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3235. // allocagentOption allows management of the mutation configuration using functional options.
  3236. type allocagentOption func(*AllocAgentMutation)
  3237. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3238. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3239. m := &AllocAgentMutation{
  3240. config: c,
  3241. op: op,
  3242. typ: TypeAllocAgent,
  3243. clearedFields: make(map[string]struct{}),
  3244. }
  3245. for _, opt := range opts {
  3246. opt(m)
  3247. }
  3248. return m
  3249. }
  3250. // withAllocAgentID sets the ID field of the mutation.
  3251. func withAllocAgentID(id uint64) allocagentOption {
  3252. return func(m *AllocAgentMutation) {
  3253. var (
  3254. err error
  3255. once sync.Once
  3256. value *AllocAgent
  3257. )
  3258. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3259. once.Do(func() {
  3260. if m.done {
  3261. err = errors.New("querying old values post mutation is not allowed")
  3262. } else {
  3263. value, err = m.Client().AllocAgent.Get(ctx, id)
  3264. }
  3265. })
  3266. return value, err
  3267. }
  3268. m.id = &id
  3269. }
  3270. }
  3271. // withAllocAgent sets the old AllocAgent of the mutation.
  3272. func withAllocAgent(node *AllocAgent) allocagentOption {
  3273. return func(m *AllocAgentMutation) {
  3274. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3275. return node, nil
  3276. }
  3277. m.id = &node.ID
  3278. }
  3279. }
  3280. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3281. // executed in a transaction (ent.Tx), a transactional client is returned.
  3282. func (m AllocAgentMutation) Client() *Client {
  3283. client := &Client{config: m.config}
  3284. client.init()
  3285. return client
  3286. }
  3287. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3288. // it returns an error otherwise.
  3289. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3290. if _, ok := m.driver.(*txDriver); !ok {
  3291. return nil, errors.New("ent: mutation is not running in a transaction")
  3292. }
  3293. tx := &Tx{config: m.config}
  3294. tx.init()
  3295. return tx, nil
  3296. }
  3297. // SetID sets the value of the id field. Note that this
  3298. // operation is only accepted on creation of AllocAgent entities.
  3299. func (m *AllocAgentMutation) SetID(id uint64) {
  3300. m.id = &id
  3301. }
  3302. // ID returns the ID value in the mutation. Note that the ID is only available
  3303. // if it was provided to the builder or after it was returned from the database.
  3304. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3305. if m.id == nil {
  3306. return
  3307. }
  3308. return *m.id, true
  3309. }
  3310. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3311. // That means, if the mutation is applied within a transaction with an isolation level such
  3312. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3313. // or updated by the mutation.
  3314. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3315. switch {
  3316. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3317. id, exists := m.ID()
  3318. if exists {
  3319. return []uint64{id}, nil
  3320. }
  3321. fallthrough
  3322. case m.op.Is(OpUpdate | OpDelete):
  3323. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3324. default:
  3325. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3326. }
  3327. }
  3328. // SetCreatedAt sets the "created_at" field.
  3329. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3330. m.created_at = &t
  3331. }
  3332. // CreatedAt returns the value of the "created_at" field in the mutation.
  3333. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3334. v := m.created_at
  3335. if v == nil {
  3336. return
  3337. }
  3338. return *v, true
  3339. }
  3340. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3341. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3343. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3344. if !m.op.Is(OpUpdateOne) {
  3345. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3346. }
  3347. if m.id == nil || m.oldValue == nil {
  3348. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3349. }
  3350. oldValue, err := m.oldValue(ctx)
  3351. if err != nil {
  3352. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3353. }
  3354. return oldValue.CreatedAt, nil
  3355. }
  3356. // ResetCreatedAt resets all changes to the "created_at" field.
  3357. func (m *AllocAgentMutation) ResetCreatedAt() {
  3358. m.created_at = nil
  3359. }
  3360. // SetUpdatedAt sets the "updated_at" field.
  3361. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3362. m.updated_at = &t
  3363. }
  3364. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3365. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3366. v := m.updated_at
  3367. if v == nil {
  3368. return
  3369. }
  3370. return *v, true
  3371. }
  3372. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3373. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3375. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3376. if !m.op.Is(OpUpdateOne) {
  3377. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3378. }
  3379. if m.id == nil || m.oldValue == nil {
  3380. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3381. }
  3382. oldValue, err := m.oldValue(ctx)
  3383. if err != nil {
  3384. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3385. }
  3386. return oldValue.UpdatedAt, nil
  3387. }
  3388. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3389. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3390. m.updated_at = nil
  3391. }
  3392. // SetDeletedAt sets the "deleted_at" field.
  3393. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3394. m.deleted_at = &t
  3395. }
  3396. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3397. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3398. v := m.deleted_at
  3399. if v == nil {
  3400. return
  3401. }
  3402. return *v, true
  3403. }
  3404. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3405. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3407. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3408. if !m.op.Is(OpUpdateOne) {
  3409. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3410. }
  3411. if m.id == nil || m.oldValue == nil {
  3412. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3413. }
  3414. oldValue, err := m.oldValue(ctx)
  3415. if err != nil {
  3416. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3417. }
  3418. return oldValue.DeletedAt, nil
  3419. }
  3420. // ClearDeletedAt clears the value of the "deleted_at" field.
  3421. func (m *AllocAgentMutation) ClearDeletedAt() {
  3422. m.deleted_at = nil
  3423. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3424. }
  3425. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3426. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3427. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3428. return ok
  3429. }
  3430. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3431. func (m *AllocAgentMutation) ResetDeletedAt() {
  3432. m.deleted_at = nil
  3433. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3434. }
  3435. // SetUserID sets the "user_id" field.
  3436. func (m *AllocAgentMutation) SetUserID(s string) {
  3437. m.user_id = &s
  3438. }
  3439. // UserID returns the value of the "user_id" field in the mutation.
  3440. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3441. v := m.user_id
  3442. if v == nil {
  3443. return
  3444. }
  3445. return *v, true
  3446. }
  3447. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3448. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3450. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3451. if !m.op.Is(OpUpdateOne) {
  3452. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3453. }
  3454. if m.id == nil || m.oldValue == nil {
  3455. return v, errors.New("OldUserID requires an ID field in the mutation")
  3456. }
  3457. oldValue, err := m.oldValue(ctx)
  3458. if err != nil {
  3459. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3460. }
  3461. return oldValue.UserID, nil
  3462. }
  3463. // ClearUserID clears the value of the "user_id" field.
  3464. func (m *AllocAgentMutation) ClearUserID() {
  3465. m.user_id = nil
  3466. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3467. }
  3468. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3469. func (m *AllocAgentMutation) UserIDCleared() bool {
  3470. _, ok := m.clearedFields[allocagent.FieldUserID]
  3471. return ok
  3472. }
  3473. // ResetUserID resets all changes to the "user_id" field.
  3474. func (m *AllocAgentMutation) ResetUserID() {
  3475. m.user_id = nil
  3476. delete(m.clearedFields, allocagent.FieldUserID)
  3477. }
  3478. // SetOrganizationID sets the "organization_id" field.
  3479. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3480. m.organization_id = &u
  3481. m.addorganization_id = nil
  3482. }
  3483. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3484. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3485. v := m.organization_id
  3486. if v == nil {
  3487. return
  3488. }
  3489. return *v, true
  3490. }
  3491. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3492. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3494. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3495. if !m.op.Is(OpUpdateOne) {
  3496. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3497. }
  3498. if m.id == nil || m.oldValue == nil {
  3499. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3500. }
  3501. oldValue, err := m.oldValue(ctx)
  3502. if err != nil {
  3503. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3504. }
  3505. return oldValue.OrganizationID, nil
  3506. }
  3507. // AddOrganizationID adds u to the "organization_id" field.
  3508. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3509. if m.addorganization_id != nil {
  3510. *m.addorganization_id += u
  3511. } else {
  3512. m.addorganization_id = &u
  3513. }
  3514. }
  3515. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3516. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3517. v := m.addorganization_id
  3518. if v == nil {
  3519. return
  3520. }
  3521. return *v, true
  3522. }
  3523. // ClearOrganizationID clears the value of the "organization_id" field.
  3524. func (m *AllocAgentMutation) ClearOrganizationID() {
  3525. m.organization_id = nil
  3526. m.addorganization_id = nil
  3527. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3528. }
  3529. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3530. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3531. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3532. return ok
  3533. }
  3534. // ResetOrganizationID resets all changes to the "organization_id" field.
  3535. func (m *AllocAgentMutation) ResetOrganizationID() {
  3536. m.organization_id = nil
  3537. m.addorganization_id = nil
  3538. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3539. }
  3540. // SetAgents sets the "agents" field.
  3541. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3542. m.agents = &u
  3543. m.appendagents = nil
  3544. }
  3545. // Agents returns the value of the "agents" field in the mutation.
  3546. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3547. v := m.agents
  3548. if v == nil {
  3549. return
  3550. }
  3551. return *v, true
  3552. }
  3553. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3554. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3556. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3557. if !m.op.Is(OpUpdateOne) {
  3558. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3559. }
  3560. if m.id == nil || m.oldValue == nil {
  3561. return v, errors.New("OldAgents requires an ID field in the mutation")
  3562. }
  3563. oldValue, err := m.oldValue(ctx)
  3564. if err != nil {
  3565. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3566. }
  3567. return oldValue.Agents, nil
  3568. }
  3569. // AppendAgents adds u to the "agents" field.
  3570. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3571. m.appendagents = append(m.appendagents, u...)
  3572. }
  3573. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3574. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3575. if len(m.appendagents) == 0 {
  3576. return nil, false
  3577. }
  3578. return m.appendagents, true
  3579. }
  3580. // ResetAgents resets all changes to the "agents" field.
  3581. func (m *AllocAgentMutation) ResetAgents() {
  3582. m.agents = nil
  3583. m.appendagents = nil
  3584. }
  3585. // SetStatus sets the "status" field.
  3586. func (m *AllocAgentMutation) SetStatus(i int) {
  3587. m.status = &i
  3588. m.addstatus = nil
  3589. }
  3590. // Status returns the value of the "status" field in the mutation.
  3591. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3592. v := m.status
  3593. if v == nil {
  3594. return
  3595. }
  3596. return *v, true
  3597. }
  3598. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3599. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3601. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3602. if !m.op.Is(OpUpdateOne) {
  3603. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3604. }
  3605. if m.id == nil || m.oldValue == nil {
  3606. return v, errors.New("OldStatus requires an ID field in the mutation")
  3607. }
  3608. oldValue, err := m.oldValue(ctx)
  3609. if err != nil {
  3610. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3611. }
  3612. return oldValue.Status, nil
  3613. }
  3614. // AddStatus adds i to the "status" field.
  3615. func (m *AllocAgentMutation) AddStatus(i int) {
  3616. if m.addstatus != nil {
  3617. *m.addstatus += i
  3618. } else {
  3619. m.addstatus = &i
  3620. }
  3621. }
  3622. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3623. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3624. v := m.addstatus
  3625. if v == nil {
  3626. return
  3627. }
  3628. return *v, true
  3629. }
  3630. // ClearStatus clears the value of the "status" field.
  3631. func (m *AllocAgentMutation) ClearStatus() {
  3632. m.status = nil
  3633. m.addstatus = nil
  3634. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3635. }
  3636. // StatusCleared returns if the "status" field was cleared in this mutation.
  3637. func (m *AllocAgentMutation) StatusCleared() bool {
  3638. _, ok := m.clearedFields[allocagent.FieldStatus]
  3639. return ok
  3640. }
  3641. // ResetStatus resets all changes to the "status" field.
  3642. func (m *AllocAgentMutation) ResetStatus() {
  3643. m.status = nil
  3644. m.addstatus = nil
  3645. delete(m.clearedFields, allocagent.FieldStatus)
  3646. }
  3647. // Where appends a list predicates to the AllocAgentMutation builder.
  3648. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3649. m.predicates = append(m.predicates, ps...)
  3650. }
  3651. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3652. // users can use type-assertion to append predicates that do not depend on any generated package.
  3653. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3654. p := make([]predicate.AllocAgent, len(ps))
  3655. for i := range ps {
  3656. p[i] = ps[i]
  3657. }
  3658. m.Where(p...)
  3659. }
  3660. // Op returns the operation name.
  3661. func (m *AllocAgentMutation) Op() Op {
  3662. return m.op
  3663. }
  3664. // SetOp allows setting the mutation operation.
  3665. func (m *AllocAgentMutation) SetOp(op Op) {
  3666. m.op = op
  3667. }
  3668. // Type returns the node type of this mutation (AllocAgent).
  3669. func (m *AllocAgentMutation) Type() string {
  3670. return m.typ
  3671. }
  3672. // Fields returns all fields that were changed during this mutation. Note that in
  3673. // order to get all numeric fields that were incremented/decremented, call
  3674. // AddedFields().
  3675. func (m *AllocAgentMutation) Fields() []string {
  3676. fields := make([]string, 0, 7)
  3677. if m.created_at != nil {
  3678. fields = append(fields, allocagent.FieldCreatedAt)
  3679. }
  3680. if m.updated_at != nil {
  3681. fields = append(fields, allocagent.FieldUpdatedAt)
  3682. }
  3683. if m.deleted_at != nil {
  3684. fields = append(fields, allocagent.FieldDeletedAt)
  3685. }
  3686. if m.user_id != nil {
  3687. fields = append(fields, allocagent.FieldUserID)
  3688. }
  3689. if m.organization_id != nil {
  3690. fields = append(fields, allocagent.FieldOrganizationID)
  3691. }
  3692. if m.agents != nil {
  3693. fields = append(fields, allocagent.FieldAgents)
  3694. }
  3695. if m.status != nil {
  3696. fields = append(fields, allocagent.FieldStatus)
  3697. }
  3698. return fields
  3699. }
  3700. // Field returns the value of a field with the given name. The second boolean
  3701. // return value indicates that this field was not set, or was not defined in the
  3702. // schema.
  3703. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3704. switch name {
  3705. case allocagent.FieldCreatedAt:
  3706. return m.CreatedAt()
  3707. case allocagent.FieldUpdatedAt:
  3708. return m.UpdatedAt()
  3709. case allocagent.FieldDeletedAt:
  3710. return m.DeletedAt()
  3711. case allocagent.FieldUserID:
  3712. return m.UserID()
  3713. case allocagent.FieldOrganizationID:
  3714. return m.OrganizationID()
  3715. case allocagent.FieldAgents:
  3716. return m.Agents()
  3717. case allocagent.FieldStatus:
  3718. return m.Status()
  3719. }
  3720. return nil, false
  3721. }
  3722. // OldField returns the old value of the field from the database. An error is
  3723. // returned if the mutation operation is not UpdateOne, or the query to the
  3724. // database failed.
  3725. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3726. switch name {
  3727. case allocagent.FieldCreatedAt:
  3728. return m.OldCreatedAt(ctx)
  3729. case allocagent.FieldUpdatedAt:
  3730. return m.OldUpdatedAt(ctx)
  3731. case allocagent.FieldDeletedAt:
  3732. return m.OldDeletedAt(ctx)
  3733. case allocagent.FieldUserID:
  3734. return m.OldUserID(ctx)
  3735. case allocagent.FieldOrganizationID:
  3736. return m.OldOrganizationID(ctx)
  3737. case allocagent.FieldAgents:
  3738. return m.OldAgents(ctx)
  3739. case allocagent.FieldStatus:
  3740. return m.OldStatus(ctx)
  3741. }
  3742. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3743. }
  3744. // SetField sets the value of a field with the given name. It returns an error if
  3745. // the field is not defined in the schema, or if the type mismatched the field
  3746. // type.
  3747. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3748. switch name {
  3749. case allocagent.FieldCreatedAt:
  3750. v, ok := value.(time.Time)
  3751. if !ok {
  3752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3753. }
  3754. m.SetCreatedAt(v)
  3755. return nil
  3756. case allocagent.FieldUpdatedAt:
  3757. v, ok := value.(time.Time)
  3758. if !ok {
  3759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3760. }
  3761. m.SetUpdatedAt(v)
  3762. return nil
  3763. case allocagent.FieldDeletedAt:
  3764. v, ok := value.(time.Time)
  3765. if !ok {
  3766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3767. }
  3768. m.SetDeletedAt(v)
  3769. return nil
  3770. case allocagent.FieldUserID:
  3771. v, ok := value.(string)
  3772. if !ok {
  3773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3774. }
  3775. m.SetUserID(v)
  3776. return nil
  3777. case allocagent.FieldOrganizationID:
  3778. v, ok := value.(uint64)
  3779. if !ok {
  3780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3781. }
  3782. m.SetOrganizationID(v)
  3783. return nil
  3784. case allocagent.FieldAgents:
  3785. v, ok := value.([]uint64)
  3786. if !ok {
  3787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3788. }
  3789. m.SetAgents(v)
  3790. return nil
  3791. case allocagent.FieldStatus:
  3792. v, ok := value.(int)
  3793. if !ok {
  3794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3795. }
  3796. m.SetStatus(v)
  3797. return nil
  3798. }
  3799. return fmt.Errorf("unknown AllocAgent field %s", name)
  3800. }
  3801. // AddedFields returns all numeric fields that were incremented/decremented during
  3802. // this mutation.
  3803. func (m *AllocAgentMutation) AddedFields() []string {
  3804. var fields []string
  3805. if m.addorganization_id != nil {
  3806. fields = append(fields, allocagent.FieldOrganizationID)
  3807. }
  3808. if m.addstatus != nil {
  3809. fields = append(fields, allocagent.FieldStatus)
  3810. }
  3811. return fields
  3812. }
  3813. // AddedField returns the numeric value that was incremented/decremented on a field
  3814. // with the given name. The second boolean return value indicates that this field
  3815. // was not set, or was not defined in the schema.
  3816. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3817. switch name {
  3818. case allocagent.FieldOrganizationID:
  3819. return m.AddedOrganizationID()
  3820. case allocagent.FieldStatus:
  3821. return m.AddedStatus()
  3822. }
  3823. return nil, false
  3824. }
  3825. // AddField adds the value to the field with the given name. It returns an error if
  3826. // the field is not defined in the schema, or if the type mismatched the field
  3827. // type.
  3828. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3829. switch name {
  3830. case allocagent.FieldOrganizationID:
  3831. v, ok := value.(int64)
  3832. if !ok {
  3833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3834. }
  3835. m.AddOrganizationID(v)
  3836. return nil
  3837. case allocagent.FieldStatus:
  3838. v, ok := value.(int)
  3839. if !ok {
  3840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3841. }
  3842. m.AddStatus(v)
  3843. return nil
  3844. }
  3845. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3846. }
  3847. // ClearedFields returns all nullable fields that were cleared during this
  3848. // mutation.
  3849. func (m *AllocAgentMutation) ClearedFields() []string {
  3850. var fields []string
  3851. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3852. fields = append(fields, allocagent.FieldDeletedAt)
  3853. }
  3854. if m.FieldCleared(allocagent.FieldUserID) {
  3855. fields = append(fields, allocagent.FieldUserID)
  3856. }
  3857. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3858. fields = append(fields, allocagent.FieldOrganizationID)
  3859. }
  3860. if m.FieldCleared(allocagent.FieldStatus) {
  3861. fields = append(fields, allocagent.FieldStatus)
  3862. }
  3863. return fields
  3864. }
  3865. // FieldCleared returns a boolean indicating if a field with the given name was
  3866. // cleared in this mutation.
  3867. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3868. _, ok := m.clearedFields[name]
  3869. return ok
  3870. }
  3871. // ClearField clears the value of the field with the given name. It returns an
  3872. // error if the field is not defined in the schema.
  3873. func (m *AllocAgentMutation) ClearField(name string) error {
  3874. switch name {
  3875. case allocagent.FieldDeletedAt:
  3876. m.ClearDeletedAt()
  3877. return nil
  3878. case allocagent.FieldUserID:
  3879. m.ClearUserID()
  3880. return nil
  3881. case allocagent.FieldOrganizationID:
  3882. m.ClearOrganizationID()
  3883. return nil
  3884. case allocagent.FieldStatus:
  3885. m.ClearStatus()
  3886. return nil
  3887. }
  3888. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3889. }
  3890. // ResetField resets all changes in the mutation for the field with the given name.
  3891. // It returns an error if the field is not defined in the schema.
  3892. func (m *AllocAgentMutation) ResetField(name string) error {
  3893. switch name {
  3894. case allocagent.FieldCreatedAt:
  3895. m.ResetCreatedAt()
  3896. return nil
  3897. case allocagent.FieldUpdatedAt:
  3898. m.ResetUpdatedAt()
  3899. return nil
  3900. case allocagent.FieldDeletedAt:
  3901. m.ResetDeletedAt()
  3902. return nil
  3903. case allocagent.FieldUserID:
  3904. m.ResetUserID()
  3905. return nil
  3906. case allocagent.FieldOrganizationID:
  3907. m.ResetOrganizationID()
  3908. return nil
  3909. case allocagent.FieldAgents:
  3910. m.ResetAgents()
  3911. return nil
  3912. case allocagent.FieldStatus:
  3913. m.ResetStatus()
  3914. return nil
  3915. }
  3916. return fmt.Errorf("unknown AllocAgent field %s", name)
  3917. }
  3918. // AddedEdges returns all edge names that were set/added in this mutation.
  3919. func (m *AllocAgentMutation) AddedEdges() []string {
  3920. edges := make([]string, 0, 0)
  3921. return edges
  3922. }
  3923. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3924. // name in this mutation.
  3925. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3926. return nil
  3927. }
  3928. // RemovedEdges returns all edge names that were removed in this mutation.
  3929. func (m *AllocAgentMutation) RemovedEdges() []string {
  3930. edges := make([]string, 0, 0)
  3931. return edges
  3932. }
  3933. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3934. // the given name in this mutation.
  3935. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3936. return nil
  3937. }
  3938. // ClearedEdges returns all edge names that were cleared in this mutation.
  3939. func (m *AllocAgentMutation) ClearedEdges() []string {
  3940. edges := make([]string, 0, 0)
  3941. return edges
  3942. }
  3943. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3944. // was cleared in this mutation.
  3945. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3946. return false
  3947. }
  3948. // ClearEdge clears the value of the edge with the given name. It returns an error
  3949. // if that edge is not defined in the schema.
  3950. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3951. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3952. }
  3953. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3954. // It returns an error if the edge is not defined in the schema.
  3955. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3956. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3957. }
  3958. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3959. type BatchMsgMutation struct {
  3960. config
  3961. op Op
  3962. typ string
  3963. id *uint64
  3964. created_at *time.Time
  3965. updated_at *time.Time
  3966. deleted_at *time.Time
  3967. status *uint8
  3968. addstatus *int8
  3969. batch_no *string
  3970. task_name *string
  3971. fromwxid *string
  3972. msg *string
  3973. tag *string
  3974. tagids *string
  3975. total *int32
  3976. addtotal *int32
  3977. success *int32
  3978. addsuccess *int32
  3979. fail *int32
  3980. addfail *int32
  3981. start_time *time.Time
  3982. stop_time *time.Time
  3983. send_time *time.Time
  3984. _type *int32
  3985. add_type *int32
  3986. organization_id *uint64
  3987. addorganization_id *int64
  3988. clearedFields map[string]struct{}
  3989. done bool
  3990. oldValue func(context.Context) (*BatchMsg, error)
  3991. predicates []predicate.BatchMsg
  3992. }
  3993. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3994. // batchmsgOption allows management of the mutation configuration using functional options.
  3995. type batchmsgOption func(*BatchMsgMutation)
  3996. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3997. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3998. m := &BatchMsgMutation{
  3999. config: c,
  4000. op: op,
  4001. typ: TypeBatchMsg,
  4002. clearedFields: make(map[string]struct{}),
  4003. }
  4004. for _, opt := range opts {
  4005. opt(m)
  4006. }
  4007. return m
  4008. }
  4009. // withBatchMsgID sets the ID field of the mutation.
  4010. func withBatchMsgID(id uint64) batchmsgOption {
  4011. return func(m *BatchMsgMutation) {
  4012. var (
  4013. err error
  4014. once sync.Once
  4015. value *BatchMsg
  4016. )
  4017. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  4018. once.Do(func() {
  4019. if m.done {
  4020. err = errors.New("querying old values post mutation is not allowed")
  4021. } else {
  4022. value, err = m.Client().BatchMsg.Get(ctx, id)
  4023. }
  4024. })
  4025. return value, err
  4026. }
  4027. m.id = &id
  4028. }
  4029. }
  4030. // withBatchMsg sets the old BatchMsg of the mutation.
  4031. func withBatchMsg(node *BatchMsg) batchmsgOption {
  4032. return func(m *BatchMsgMutation) {
  4033. m.oldValue = func(context.Context) (*BatchMsg, error) {
  4034. return node, nil
  4035. }
  4036. m.id = &node.ID
  4037. }
  4038. }
  4039. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4040. // executed in a transaction (ent.Tx), a transactional client is returned.
  4041. func (m BatchMsgMutation) Client() *Client {
  4042. client := &Client{config: m.config}
  4043. client.init()
  4044. return client
  4045. }
  4046. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4047. // it returns an error otherwise.
  4048. func (m BatchMsgMutation) Tx() (*Tx, error) {
  4049. if _, ok := m.driver.(*txDriver); !ok {
  4050. return nil, errors.New("ent: mutation is not running in a transaction")
  4051. }
  4052. tx := &Tx{config: m.config}
  4053. tx.init()
  4054. return tx, nil
  4055. }
  4056. // SetID sets the value of the id field. Note that this
  4057. // operation is only accepted on creation of BatchMsg entities.
  4058. func (m *BatchMsgMutation) SetID(id uint64) {
  4059. m.id = &id
  4060. }
  4061. // ID returns the ID value in the mutation. Note that the ID is only available
  4062. // if it was provided to the builder or after it was returned from the database.
  4063. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  4064. if m.id == nil {
  4065. return
  4066. }
  4067. return *m.id, true
  4068. }
  4069. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4070. // That means, if the mutation is applied within a transaction with an isolation level such
  4071. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4072. // or updated by the mutation.
  4073. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  4074. switch {
  4075. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4076. id, exists := m.ID()
  4077. if exists {
  4078. return []uint64{id}, nil
  4079. }
  4080. fallthrough
  4081. case m.op.Is(OpUpdate | OpDelete):
  4082. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4083. default:
  4084. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4085. }
  4086. }
  4087. // SetCreatedAt sets the "created_at" field.
  4088. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4089. m.created_at = &t
  4090. }
  4091. // CreatedAt returns the value of the "created_at" field in the mutation.
  4092. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4093. v := m.created_at
  4094. if v == nil {
  4095. return
  4096. }
  4097. return *v, true
  4098. }
  4099. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4100. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4102. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4103. if !m.op.Is(OpUpdateOne) {
  4104. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4105. }
  4106. if m.id == nil || m.oldValue == nil {
  4107. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4108. }
  4109. oldValue, err := m.oldValue(ctx)
  4110. if err != nil {
  4111. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4112. }
  4113. return oldValue.CreatedAt, nil
  4114. }
  4115. // ResetCreatedAt resets all changes to the "created_at" field.
  4116. func (m *BatchMsgMutation) ResetCreatedAt() {
  4117. m.created_at = nil
  4118. }
  4119. // SetUpdatedAt sets the "updated_at" field.
  4120. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4121. m.updated_at = &t
  4122. }
  4123. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4124. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4125. v := m.updated_at
  4126. if v == nil {
  4127. return
  4128. }
  4129. return *v, true
  4130. }
  4131. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4132. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4134. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4135. if !m.op.Is(OpUpdateOne) {
  4136. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4137. }
  4138. if m.id == nil || m.oldValue == nil {
  4139. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4140. }
  4141. oldValue, err := m.oldValue(ctx)
  4142. if err != nil {
  4143. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4144. }
  4145. return oldValue.UpdatedAt, nil
  4146. }
  4147. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4148. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4149. m.updated_at = nil
  4150. }
  4151. // SetDeletedAt sets the "deleted_at" field.
  4152. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4153. m.deleted_at = &t
  4154. }
  4155. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4156. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4157. v := m.deleted_at
  4158. if v == nil {
  4159. return
  4160. }
  4161. return *v, true
  4162. }
  4163. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4164. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4166. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4167. if !m.op.Is(OpUpdateOne) {
  4168. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4169. }
  4170. if m.id == nil || m.oldValue == nil {
  4171. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4172. }
  4173. oldValue, err := m.oldValue(ctx)
  4174. if err != nil {
  4175. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4176. }
  4177. return oldValue.DeletedAt, nil
  4178. }
  4179. // ClearDeletedAt clears the value of the "deleted_at" field.
  4180. func (m *BatchMsgMutation) ClearDeletedAt() {
  4181. m.deleted_at = nil
  4182. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4183. }
  4184. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4185. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4186. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4187. return ok
  4188. }
  4189. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4190. func (m *BatchMsgMutation) ResetDeletedAt() {
  4191. m.deleted_at = nil
  4192. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4193. }
  4194. // SetStatus sets the "status" field.
  4195. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4196. m.status = &u
  4197. m.addstatus = nil
  4198. }
  4199. // Status returns the value of the "status" field in the mutation.
  4200. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4201. v := m.status
  4202. if v == nil {
  4203. return
  4204. }
  4205. return *v, true
  4206. }
  4207. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4208. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4210. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4211. if !m.op.Is(OpUpdateOne) {
  4212. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4213. }
  4214. if m.id == nil || m.oldValue == nil {
  4215. return v, errors.New("OldStatus requires an ID field in the mutation")
  4216. }
  4217. oldValue, err := m.oldValue(ctx)
  4218. if err != nil {
  4219. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4220. }
  4221. return oldValue.Status, nil
  4222. }
  4223. // AddStatus adds u to the "status" field.
  4224. func (m *BatchMsgMutation) AddStatus(u int8) {
  4225. if m.addstatus != nil {
  4226. *m.addstatus += u
  4227. } else {
  4228. m.addstatus = &u
  4229. }
  4230. }
  4231. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4232. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4233. v := m.addstatus
  4234. if v == nil {
  4235. return
  4236. }
  4237. return *v, true
  4238. }
  4239. // ClearStatus clears the value of the "status" field.
  4240. func (m *BatchMsgMutation) ClearStatus() {
  4241. m.status = nil
  4242. m.addstatus = nil
  4243. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4244. }
  4245. // StatusCleared returns if the "status" field was cleared in this mutation.
  4246. func (m *BatchMsgMutation) StatusCleared() bool {
  4247. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4248. return ok
  4249. }
  4250. // ResetStatus resets all changes to the "status" field.
  4251. func (m *BatchMsgMutation) ResetStatus() {
  4252. m.status = nil
  4253. m.addstatus = nil
  4254. delete(m.clearedFields, batchmsg.FieldStatus)
  4255. }
  4256. // SetBatchNo sets the "batch_no" field.
  4257. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4258. m.batch_no = &s
  4259. }
  4260. // BatchNo returns the value of the "batch_no" field in the mutation.
  4261. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4262. v := m.batch_no
  4263. if v == nil {
  4264. return
  4265. }
  4266. return *v, true
  4267. }
  4268. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4269. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4271. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4272. if !m.op.Is(OpUpdateOne) {
  4273. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4274. }
  4275. if m.id == nil || m.oldValue == nil {
  4276. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4277. }
  4278. oldValue, err := m.oldValue(ctx)
  4279. if err != nil {
  4280. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4281. }
  4282. return oldValue.BatchNo, nil
  4283. }
  4284. // ClearBatchNo clears the value of the "batch_no" field.
  4285. func (m *BatchMsgMutation) ClearBatchNo() {
  4286. m.batch_no = nil
  4287. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4288. }
  4289. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4290. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4291. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4292. return ok
  4293. }
  4294. // ResetBatchNo resets all changes to the "batch_no" field.
  4295. func (m *BatchMsgMutation) ResetBatchNo() {
  4296. m.batch_no = nil
  4297. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4298. }
  4299. // SetTaskName sets the "task_name" field.
  4300. func (m *BatchMsgMutation) SetTaskName(s string) {
  4301. m.task_name = &s
  4302. }
  4303. // TaskName returns the value of the "task_name" field in the mutation.
  4304. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4305. v := m.task_name
  4306. if v == nil {
  4307. return
  4308. }
  4309. return *v, true
  4310. }
  4311. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4312. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4314. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4315. if !m.op.Is(OpUpdateOne) {
  4316. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4317. }
  4318. if m.id == nil || m.oldValue == nil {
  4319. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4320. }
  4321. oldValue, err := m.oldValue(ctx)
  4322. if err != nil {
  4323. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4324. }
  4325. return oldValue.TaskName, nil
  4326. }
  4327. // ClearTaskName clears the value of the "task_name" field.
  4328. func (m *BatchMsgMutation) ClearTaskName() {
  4329. m.task_name = nil
  4330. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4331. }
  4332. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4333. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4334. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4335. return ok
  4336. }
  4337. // ResetTaskName resets all changes to the "task_name" field.
  4338. func (m *BatchMsgMutation) ResetTaskName() {
  4339. m.task_name = nil
  4340. delete(m.clearedFields, batchmsg.FieldTaskName)
  4341. }
  4342. // SetFromwxid sets the "fromwxid" field.
  4343. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4344. m.fromwxid = &s
  4345. }
  4346. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4347. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4348. v := m.fromwxid
  4349. if v == nil {
  4350. return
  4351. }
  4352. return *v, true
  4353. }
  4354. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4355. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4357. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4358. if !m.op.Is(OpUpdateOne) {
  4359. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4360. }
  4361. if m.id == nil || m.oldValue == nil {
  4362. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4363. }
  4364. oldValue, err := m.oldValue(ctx)
  4365. if err != nil {
  4366. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4367. }
  4368. return oldValue.Fromwxid, nil
  4369. }
  4370. // ClearFromwxid clears the value of the "fromwxid" field.
  4371. func (m *BatchMsgMutation) ClearFromwxid() {
  4372. m.fromwxid = nil
  4373. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4374. }
  4375. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4376. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4377. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4378. return ok
  4379. }
  4380. // ResetFromwxid resets all changes to the "fromwxid" field.
  4381. func (m *BatchMsgMutation) ResetFromwxid() {
  4382. m.fromwxid = nil
  4383. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4384. }
  4385. // SetMsg sets the "msg" field.
  4386. func (m *BatchMsgMutation) SetMsg(s string) {
  4387. m.msg = &s
  4388. }
  4389. // Msg returns the value of the "msg" field in the mutation.
  4390. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4391. v := m.msg
  4392. if v == nil {
  4393. return
  4394. }
  4395. return *v, true
  4396. }
  4397. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4398. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4400. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4401. if !m.op.Is(OpUpdateOne) {
  4402. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4403. }
  4404. if m.id == nil || m.oldValue == nil {
  4405. return v, errors.New("OldMsg requires an ID field in the mutation")
  4406. }
  4407. oldValue, err := m.oldValue(ctx)
  4408. if err != nil {
  4409. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4410. }
  4411. return oldValue.Msg, nil
  4412. }
  4413. // ClearMsg clears the value of the "msg" field.
  4414. func (m *BatchMsgMutation) ClearMsg() {
  4415. m.msg = nil
  4416. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4417. }
  4418. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4419. func (m *BatchMsgMutation) MsgCleared() bool {
  4420. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4421. return ok
  4422. }
  4423. // ResetMsg resets all changes to the "msg" field.
  4424. func (m *BatchMsgMutation) ResetMsg() {
  4425. m.msg = nil
  4426. delete(m.clearedFields, batchmsg.FieldMsg)
  4427. }
  4428. // SetTag sets the "tag" field.
  4429. func (m *BatchMsgMutation) SetTag(s string) {
  4430. m.tag = &s
  4431. }
  4432. // Tag returns the value of the "tag" field in the mutation.
  4433. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4434. v := m.tag
  4435. if v == nil {
  4436. return
  4437. }
  4438. return *v, true
  4439. }
  4440. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4441. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4443. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4444. if !m.op.Is(OpUpdateOne) {
  4445. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4446. }
  4447. if m.id == nil || m.oldValue == nil {
  4448. return v, errors.New("OldTag requires an ID field in the mutation")
  4449. }
  4450. oldValue, err := m.oldValue(ctx)
  4451. if err != nil {
  4452. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4453. }
  4454. return oldValue.Tag, nil
  4455. }
  4456. // ClearTag clears the value of the "tag" field.
  4457. func (m *BatchMsgMutation) ClearTag() {
  4458. m.tag = nil
  4459. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4460. }
  4461. // TagCleared returns if the "tag" field was cleared in this mutation.
  4462. func (m *BatchMsgMutation) TagCleared() bool {
  4463. _, ok := m.clearedFields[batchmsg.FieldTag]
  4464. return ok
  4465. }
  4466. // ResetTag resets all changes to the "tag" field.
  4467. func (m *BatchMsgMutation) ResetTag() {
  4468. m.tag = nil
  4469. delete(m.clearedFields, batchmsg.FieldTag)
  4470. }
  4471. // SetTagids sets the "tagids" field.
  4472. func (m *BatchMsgMutation) SetTagids(s string) {
  4473. m.tagids = &s
  4474. }
  4475. // Tagids returns the value of the "tagids" field in the mutation.
  4476. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4477. v := m.tagids
  4478. if v == nil {
  4479. return
  4480. }
  4481. return *v, true
  4482. }
  4483. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4484. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4486. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4487. if !m.op.Is(OpUpdateOne) {
  4488. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4489. }
  4490. if m.id == nil || m.oldValue == nil {
  4491. return v, errors.New("OldTagids requires an ID field in the mutation")
  4492. }
  4493. oldValue, err := m.oldValue(ctx)
  4494. if err != nil {
  4495. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4496. }
  4497. return oldValue.Tagids, nil
  4498. }
  4499. // ClearTagids clears the value of the "tagids" field.
  4500. func (m *BatchMsgMutation) ClearTagids() {
  4501. m.tagids = nil
  4502. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4503. }
  4504. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4505. func (m *BatchMsgMutation) TagidsCleared() bool {
  4506. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4507. return ok
  4508. }
  4509. // ResetTagids resets all changes to the "tagids" field.
  4510. func (m *BatchMsgMutation) ResetTagids() {
  4511. m.tagids = nil
  4512. delete(m.clearedFields, batchmsg.FieldTagids)
  4513. }
  4514. // SetTotal sets the "total" field.
  4515. func (m *BatchMsgMutation) SetTotal(i int32) {
  4516. m.total = &i
  4517. m.addtotal = nil
  4518. }
  4519. // Total returns the value of the "total" field in the mutation.
  4520. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4521. v := m.total
  4522. if v == nil {
  4523. return
  4524. }
  4525. return *v, true
  4526. }
  4527. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4528. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4530. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4531. if !m.op.Is(OpUpdateOne) {
  4532. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4533. }
  4534. if m.id == nil || m.oldValue == nil {
  4535. return v, errors.New("OldTotal requires an ID field in the mutation")
  4536. }
  4537. oldValue, err := m.oldValue(ctx)
  4538. if err != nil {
  4539. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4540. }
  4541. return oldValue.Total, nil
  4542. }
  4543. // AddTotal adds i to the "total" field.
  4544. func (m *BatchMsgMutation) AddTotal(i int32) {
  4545. if m.addtotal != nil {
  4546. *m.addtotal += i
  4547. } else {
  4548. m.addtotal = &i
  4549. }
  4550. }
  4551. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4552. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4553. v := m.addtotal
  4554. if v == nil {
  4555. return
  4556. }
  4557. return *v, true
  4558. }
  4559. // ClearTotal clears the value of the "total" field.
  4560. func (m *BatchMsgMutation) ClearTotal() {
  4561. m.total = nil
  4562. m.addtotal = nil
  4563. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4564. }
  4565. // TotalCleared returns if the "total" field was cleared in this mutation.
  4566. func (m *BatchMsgMutation) TotalCleared() bool {
  4567. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4568. return ok
  4569. }
  4570. // ResetTotal resets all changes to the "total" field.
  4571. func (m *BatchMsgMutation) ResetTotal() {
  4572. m.total = nil
  4573. m.addtotal = nil
  4574. delete(m.clearedFields, batchmsg.FieldTotal)
  4575. }
  4576. // SetSuccess sets the "success" field.
  4577. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4578. m.success = &i
  4579. m.addsuccess = nil
  4580. }
  4581. // Success returns the value of the "success" field in the mutation.
  4582. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4583. v := m.success
  4584. if v == nil {
  4585. return
  4586. }
  4587. return *v, true
  4588. }
  4589. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4590. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4592. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4593. if !m.op.Is(OpUpdateOne) {
  4594. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4595. }
  4596. if m.id == nil || m.oldValue == nil {
  4597. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4598. }
  4599. oldValue, err := m.oldValue(ctx)
  4600. if err != nil {
  4601. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4602. }
  4603. return oldValue.Success, nil
  4604. }
  4605. // AddSuccess adds i to the "success" field.
  4606. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4607. if m.addsuccess != nil {
  4608. *m.addsuccess += i
  4609. } else {
  4610. m.addsuccess = &i
  4611. }
  4612. }
  4613. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4614. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4615. v := m.addsuccess
  4616. if v == nil {
  4617. return
  4618. }
  4619. return *v, true
  4620. }
  4621. // ClearSuccess clears the value of the "success" field.
  4622. func (m *BatchMsgMutation) ClearSuccess() {
  4623. m.success = nil
  4624. m.addsuccess = nil
  4625. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4626. }
  4627. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4628. func (m *BatchMsgMutation) SuccessCleared() bool {
  4629. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4630. return ok
  4631. }
  4632. // ResetSuccess resets all changes to the "success" field.
  4633. func (m *BatchMsgMutation) ResetSuccess() {
  4634. m.success = nil
  4635. m.addsuccess = nil
  4636. delete(m.clearedFields, batchmsg.FieldSuccess)
  4637. }
  4638. // SetFail sets the "fail" field.
  4639. func (m *BatchMsgMutation) SetFail(i int32) {
  4640. m.fail = &i
  4641. m.addfail = nil
  4642. }
  4643. // Fail returns the value of the "fail" field in the mutation.
  4644. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4645. v := m.fail
  4646. if v == nil {
  4647. return
  4648. }
  4649. return *v, true
  4650. }
  4651. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4652. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4654. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4655. if !m.op.Is(OpUpdateOne) {
  4656. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4657. }
  4658. if m.id == nil || m.oldValue == nil {
  4659. return v, errors.New("OldFail requires an ID field in the mutation")
  4660. }
  4661. oldValue, err := m.oldValue(ctx)
  4662. if err != nil {
  4663. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4664. }
  4665. return oldValue.Fail, nil
  4666. }
  4667. // AddFail adds i to the "fail" field.
  4668. func (m *BatchMsgMutation) AddFail(i int32) {
  4669. if m.addfail != nil {
  4670. *m.addfail += i
  4671. } else {
  4672. m.addfail = &i
  4673. }
  4674. }
  4675. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4676. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4677. v := m.addfail
  4678. if v == nil {
  4679. return
  4680. }
  4681. return *v, true
  4682. }
  4683. // ClearFail clears the value of the "fail" field.
  4684. func (m *BatchMsgMutation) ClearFail() {
  4685. m.fail = nil
  4686. m.addfail = nil
  4687. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4688. }
  4689. // FailCleared returns if the "fail" field was cleared in this mutation.
  4690. func (m *BatchMsgMutation) FailCleared() bool {
  4691. _, ok := m.clearedFields[batchmsg.FieldFail]
  4692. return ok
  4693. }
  4694. // ResetFail resets all changes to the "fail" field.
  4695. func (m *BatchMsgMutation) ResetFail() {
  4696. m.fail = nil
  4697. m.addfail = nil
  4698. delete(m.clearedFields, batchmsg.FieldFail)
  4699. }
  4700. // SetStartTime sets the "start_time" field.
  4701. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4702. m.start_time = &t
  4703. }
  4704. // StartTime returns the value of the "start_time" field in the mutation.
  4705. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4706. v := m.start_time
  4707. if v == nil {
  4708. return
  4709. }
  4710. return *v, true
  4711. }
  4712. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4713. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4715. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4716. if !m.op.Is(OpUpdateOne) {
  4717. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4718. }
  4719. if m.id == nil || m.oldValue == nil {
  4720. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4721. }
  4722. oldValue, err := m.oldValue(ctx)
  4723. if err != nil {
  4724. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4725. }
  4726. return oldValue.StartTime, nil
  4727. }
  4728. // ClearStartTime clears the value of the "start_time" field.
  4729. func (m *BatchMsgMutation) ClearStartTime() {
  4730. m.start_time = nil
  4731. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4732. }
  4733. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4734. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4735. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4736. return ok
  4737. }
  4738. // ResetStartTime resets all changes to the "start_time" field.
  4739. func (m *BatchMsgMutation) ResetStartTime() {
  4740. m.start_time = nil
  4741. delete(m.clearedFields, batchmsg.FieldStartTime)
  4742. }
  4743. // SetStopTime sets the "stop_time" field.
  4744. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4745. m.stop_time = &t
  4746. }
  4747. // StopTime returns the value of the "stop_time" field in the mutation.
  4748. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4749. v := m.stop_time
  4750. if v == nil {
  4751. return
  4752. }
  4753. return *v, true
  4754. }
  4755. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4756. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4758. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4759. if !m.op.Is(OpUpdateOne) {
  4760. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4761. }
  4762. if m.id == nil || m.oldValue == nil {
  4763. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4764. }
  4765. oldValue, err := m.oldValue(ctx)
  4766. if err != nil {
  4767. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4768. }
  4769. return oldValue.StopTime, nil
  4770. }
  4771. // ClearStopTime clears the value of the "stop_time" field.
  4772. func (m *BatchMsgMutation) ClearStopTime() {
  4773. m.stop_time = nil
  4774. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4775. }
  4776. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4777. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4778. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4779. return ok
  4780. }
  4781. // ResetStopTime resets all changes to the "stop_time" field.
  4782. func (m *BatchMsgMutation) ResetStopTime() {
  4783. m.stop_time = nil
  4784. delete(m.clearedFields, batchmsg.FieldStopTime)
  4785. }
  4786. // SetSendTime sets the "send_time" field.
  4787. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4788. m.send_time = &t
  4789. }
  4790. // SendTime returns the value of the "send_time" field in the mutation.
  4791. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4792. v := m.send_time
  4793. if v == nil {
  4794. return
  4795. }
  4796. return *v, true
  4797. }
  4798. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4799. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4801. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4802. if !m.op.Is(OpUpdateOne) {
  4803. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4804. }
  4805. if m.id == nil || m.oldValue == nil {
  4806. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4807. }
  4808. oldValue, err := m.oldValue(ctx)
  4809. if err != nil {
  4810. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4811. }
  4812. return oldValue.SendTime, nil
  4813. }
  4814. // ClearSendTime clears the value of the "send_time" field.
  4815. func (m *BatchMsgMutation) ClearSendTime() {
  4816. m.send_time = nil
  4817. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4818. }
  4819. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4820. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4821. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4822. return ok
  4823. }
  4824. // ResetSendTime resets all changes to the "send_time" field.
  4825. func (m *BatchMsgMutation) ResetSendTime() {
  4826. m.send_time = nil
  4827. delete(m.clearedFields, batchmsg.FieldSendTime)
  4828. }
  4829. // SetType sets the "type" field.
  4830. func (m *BatchMsgMutation) SetType(i int32) {
  4831. m._type = &i
  4832. m.add_type = nil
  4833. }
  4834. // GetType returns the value of the "type" field in the mutation.
  4835. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4836. v := m._type
  4837. if v == nil {
  4838. return
  4839. }
  4840. return *v, true
  4841. }
  4842. // OldType returns the old "type" field's value of the BatchMsg entity.
  4843. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4845. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4846. if !m.op.Is(OpUpdateOne) {
  4847. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4848. }
  4849. if m.id == nil || m.oldValue == nil {
  4850. return v, errors.New("OldType requires an ID field in the mutation")
  4851. }
  4852. oldValue, err := m.oldValue(ctx)
  4853. if err != nil {
  4854. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4855. }
  4856. return oldValue.Type, nil
  4857. }
  4858. // AddType adds i to the "type" field.
  4859. func (m *BatchMsgMutation) AddType(i int32) {
  4860. if m.add_type != nil {
  4861. *m.add_type += i
  4862. } else {
  4863. m.add_type = &i
  4864. }
  4865. }
  4866. // AddedType returns the value that was added to the "type" field in this mutation.
  4867. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4868. v := m.add_type
  4869. if v == nil {
  4870. return
  4871. }
  4872. return *v, true
  4873. }
  4874. // ClearType clears the value of the "type" field.
  4875. func (m *BatchMsgMutation) ClearType() {
  4876. m._type = nil
  4877. m.add_type = nil
  4878. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4879. }
  4880. // TypeCleared returns if the "type" field was cleared in this mutation.
  4881. func (m *BatchMsgMutation) TypeCleared() bool {
  4882. _, ok := m.clearedFields[batchmsg.FieldType]
  4883. return ok
  4884. }
  4885. // ResetType resets all changes to the "type" field.
  4886. func (m *BatchMsgMutation) ResetType() {
  4887. m._type = nil
  4888. m.add_type = nil
  4889. delete(m.clearedFields, batchmsg.FieldType)
  4890. }
  4891. // SetOrganizationID sets the "organization_id" field.
  4892. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4893. m.organization_id = &u
  4894. m.addorganization_id = nil
  4895. }
  4896. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4897. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4898. v := m.organization_id
  4899. if v == nil {
  4900. return
  4901. }
  4902. return *v, true
  4903. }
  4904. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4905. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4907. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4908. if !m.op.Is(OpUpdateOne) {
  4909. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4910. }
  4911. if m.id == nil || m.oldValue == nil {
  4912. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4913. }
  4914. oldValue, err := m.oldValue(ctx)
  4915. if err != nil {
  4916. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4917. }
  4918. return oldValue.OrganizationID, nil
  4919. }
  4920. // AddOrganizationID adds u to the "organization_id" field.
  4921. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4922. if m.addorganization_id != nil {
  4923. *m.addorganization_id += u
  4924. } else {
  4925. m.addorganization_id = &u
  4926. }
  4927. }
  4928. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4929. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4930. v := m.addorganization_id
  4931. if v == nil {
  4932. return
  4933. }
  4934. return *v, true
  4935. }
  4936. // ResetOrganizationID resets all changes to the "organization_id" field.
  4937. func (m *BatchMsgMutation) ResetOrganizationID() {
  4938. m.organization_id = nil
  4939. m.addorganization_id = nil
  4940. }
  4941. // Where appends a list predicates to the BatchMsgMutation builder.
  4942. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4943. m.predicates = append(m.predicates, ps...)
  4944. }
  4945. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4946. // users can use type-assertion to append predicates that do not depend on any generated package.
  4947. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4948. p := make([]predicate.BatchMsg, len(ps))
  4949. for i := range ps {
  4950. p[i] = ps[i]
  4951. }
  4952. m.Where(p...)
  4953. }
  4954. // Op returns the operation name.
  4955. func (m *BatchMsgMutation) Op() Op {
  4956. return m.op
  4957. }
  4958. // SetOp allows setting the mutation operation.
  4959. func (m *BatchMsgMutation) SetOp(op Op) {
  4960. m.op = op
  4961. }
  4962. // Type returns the node type of this mutation (BatchMsg).
  4963. func (m *BatchMsgMutation) Type() string {
  4964. return m.typ
  4965. }
  4966. // Fields returns all fields that were changed during this mutation. Note that in
  4967. // order to get all numeric fields that were incremented/decremented, call
  4968. // AddedFields().
  4969. func (m *BatchMsgMutation) Fields() []string {
  4970. fields := make([]string, 0, 18)
  4971. if m.created_at != nil {
  4972. fields = append(fields, batchmsg.FieldCreatedAt)
  4973. }
  4974. if m.updated_at != nil {
  4975. fields = append(fields, batchmsg.FieldUpdatedAt)
  4976. }
  4977. if m.deleted_at != nil {
  4978. fields = append(fields, batchmsg.FieldDeletedAt)
  4979. }
  4980. if m.status != nil {
  4981. fields = append(fields, batchmsg.FieldStatus)
  4982. }
  4983. if m.batch_no != nil {
  4984. fields = append(fields, batchmsg.FieldBatchNo)
  4985. }
  4986. if m.task_name != nil {
  4987. fields = append(fields, batchmsg.FieldTaskName)
  4988. }
  4989. if m.fromwxid != nil {
  4990. fields = append(fields, batchmsg.FieldFromwxid)
  4991. }
  4992. if m.msg != nil {
  4993. fields = append(fields, batchmsg.FieldMsg)
  4994. }
  4995. if m.tag != nil {
  4996. fields = append(fields, batchmsg.FieldTag)
  4997. }
  4998. if m.tagids != nil {
  4999. fields = append(fields, batchmsg.FieldTagids)
  5000. }
  5001. if m.total != nil {
  5002. fields = append(fields, batchmsg.FieldTotal)
  5003. }
  5004. if m.success != nil {
  5005. fields = append(fields, batchmsg.FieldSuccess)
  5006. }
  5007. if m.fail != nil {
  5008. fields = append(fields, batchmsg.FieldFail)
  5009. }
  5010. if m.start_time != nil {
  5011. fields = append(fields, batchmsg.FieldStartTime)
  5012. }
  5013. if m.stop_time != nil {
  5014. fields = append(fields, batchmsg.FieldStopTime)
  5015. }
  5016. if m.send_time != nil {
  5017. fields = append(fields, batchmsg.FieldSendTime)
  5018. }
  5019. if m._type != nil {
  5020. fields = append(fields, batchmsg.FieldType)
  5021. }
  5022. if m.organization_id != nil {
  5023. fields = append(fields, batchmsg.FieldOrganizationID)
  5024. }
  5025. return fields
  5026. }
  5027. // Field returns the value of a field with the given name. The second boolean
  5028. // return value indicates that this field was not set, or was not defined in the
  5029. // schema.
  5030. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  5031. switch name {
  5032. case batchmsg.FieldCreatedAt:
  5033. return m.CreatedAt()
  5034. case batchmsg.FieldUpdatedAt:
  5035. return m.UpdatedAt()
  5036. case batchmsg.FieldDeletedAt:
  5037. return m.DeletedAt()
  5038. case batchmsg.FieldStatus:
  5039. return m.Status()
  5040. case batchmsg.FieldBatchNo:
  5041. return m.BatchNo()
  5042. case batchmsg.FieldTaskName:
  5043. return m.TaskName()
  5044. case batchmsg.FieldFromwxid:
  5045. return m.Fromwxid()
  5046. case batchmsg.FieldMsg:
  5047. return m.Msg()
  5048. case batchmsg.FieldTag:
  5049. return m.Tag()
  5050. case batchmsg.FieldTagids:
  5051. return m.Tagids()
  5052. case batchmsg.FieldTotal:
  5053. return m.Total()
  5054. case batchmsg.FieldSuccess:
  5055. return m.Success()
  5056. case batchmsg.FieldFail:
  5057. return m.Fail()
  5058. case batchmsg.FieldStartTime:
  5059. return m.StartTime()
  5060. case batchmsg.FieldStopTime:
  5061. return m.StopTime()
  5062. case batchmsg.FieldSendTime:
  5063. return m.SendTime()
  5064. case batchmsg.FieldType:
  5065. return m.GetType()
  5066. case batchmsg.FieldOrganizationID:
  5067. return m.OrganizationID()
  5068. }
  5069. return nil, false
  5070. }
  5071. // OldField returns the old value of the field from the database. An error is
  5072. // returned if the mutation operation is not UpdateOne, or the query to the
  5073. // database failed.
  5074. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5075. switch name {
  5076. case batchmsg.FieldCreatedAt:
  5077. return m.OldCreatedAt(ctx)
  5078. case batchmsg.FieldUpdatedAt:
  5079. return m.OldUpdatedAt(ctx)
  5080. case batchmsg.FieldDeletedAt:
  5081. return m.OldDeletedAt(ctx)
  5082. case batchmsg.FieldStatus:
  5083. return m.OldStatus(ctx)
  5084. case batchmsg.FieldBatchNo:
  5085. return m.OldBatchNo(ctx)
  5086. case batchmsg.FieldTaskName:
  5087. return m.OldTaskName(ctx)
  5088. case batchmsg.FieldFromwxid:
  5089. return m.OldFromwxid(ctx)
  5090. case batchmsg.FieldMsg:
  5091. return m.OldMsg(ctx)
  5092. case batchmsg.FieldTag:
  5093. return m.OldTag(ctx)
  5094. case batchmsg.FieldTagids:
  5095. return m.OldTagids(ctx)
  5096. case batchmsg.FieldTotal:
  5097. return m.OldTotal(ctx)
  5098. case batchmsg.FieldSuccess:
  5099. return m.OldSuccess(ctx)
  5100. case batchmsg.FieldFail:
  5101. return m.OldFail(ctx)
  5102. case batchmsg.FieldStartTime:
  5103. return m.OldStartTime(ctx)
  5104. case batchmsg.FieldStopTime:
  5105. return m.OldStopTime(ctx)
  5106. case batchmsg.FieldSendTime:
  5107. return m.OldSendTime(ctx)
  5108. case batchmsg.FieldType:
  5109. return m.OldType(ctx)
  5110. case batchmsg.FieldOrganizationID:
  5111. return m.OldOrganizationID(ctx)
  5112. }
  5113. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5114. }
  5115. // SetField sets the value of a field with the given name. It returns an error if
  5116. // the field is not defined in the schema, or if the type mismatched the field
  5117. // type.
  5118. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5119. switch name {
  5120. case batchmsg.FieldCreatedAt:
  5121. v, ok := value.(time.Time)
  5122. if !ok {
  5123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5124. }
  5125. m.SetCreatedAt(v)
  5126. return nil
  5127. case batchmsg.FieldUpdatedAt:
  5128. v, ok := value.(time.Time)
  5129. if !ok {
  5130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5131. }
  5132. m.SetUpdatedAt(v)
  5133. return nil
  5134. case batchmsg.FieldDeletedAt:
  5135. v, ok := value.(time.Time)
  5136. if !ok {
  5137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5138. }
  5139. m.SetDeletedAt(v)
  5140. return nil
  5141. case batchmsg.FieldStatus:
  5142. v, ok := value.(uint8)
  5143. if !ok {
  5144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5145. }
  5146. m.SetStatus(v)
  5147. return nil
  5148. case batchmsg.FieldBatchNo:
  5149. v, ok := value.(string)
  5150. if !ok {
  5151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5152. }
  5153. m.SetBatchNo(v)
  5154. return nil
  5155. case batchmsg.FieldTaskName:
  5156. v, ok := value.(string)
  5157. if !ok {
  5158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5159. }
  5160. m.SetTaskName(v)
  5161. return nil
  5162. case batchmsg.FieldFromwxid:
  5163. v, ok := value.(string)
  5164. if !ok {
  5165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5166. }
  5167. m.SetFromwxid(v)
  5168. return nil
  5169. case batchmsg.FieldMsg:
  5170. v, ok := value.(string)
  5171. if !ok {
  5172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5173. }
  5174. m.SetMsg(v)
  5175. return nil
  5176. case batchmsg.FieldTag:
  5177. v, ok := value.(string)
  5178. if !ok {
  5179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5180. }
  5181. m.SetTag(v)
  5182. return nil
  5183. case batchmsg.FieldTagids:
  5184. v, ok := value.(string)
  5185. if !ok {
  5186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5187. }
  5188. m.SetTagids(v)
  5189. return nil
  5190. case batchmsg.FieldTotal:
  5191. v, ok := value.(int32)
  5192. if !ok {
  5193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5194. }
  5195. m.SetTotal(v)
  5196. return nil
  5197. case batchmsg.FieldSuccess:
  5198. v, ok := value.(int32)
  5199. if !ok {
  5200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5201. }
  5202. m.SetSuccess(v)
  5203. return nil
  5204. case batchmsg.FieldFail:
  5205. v, ok := value.(int32)
  5206. if !ok {
  5207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5208. }
  5209. m.SetFail(v)
  5210. return nil
  5211. case batchmsg.FieldStartTime:
  5212. v, ok := value.(time.Time)
  5213. if !ok {
  5214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5215. }
  5216. m.SetStartTime(v)
  5217. return nil
  5218. case batchmsg.FieldStopTime:
  5219. v, ok := value.(time.Time)
  5220. if !ok {
  5221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5222. }
  5223. m.SetStopTime(v)
  5224. return nil
  5225. case batchmsg.FieldSendTime:
  5226. v, ok := value.(time.Time)
  5227. if !ok {
  5228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5229. }
  5230. m.SetSendTime(v)
  5231. return nil
  5232. case batchmsg.FieldType:
  5233. v, ok := value.(int32)
  5234. if !ok {
  5235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5236. }
  5237. m.SetType(v)
  5238. return nil
  5239. case batchmsg.FieldOrganizationID:
  5240. v, ok := value.(uint64)
  5241. if !ok {
  5242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5243. }
  5244. m.SetOrganizationID(v)
  5245. return nil
  5246. }
  5247. return fmt.Errorf("unknown BatchMsg field %s", name)
  5248. }
  5249. // AddedFields returns all numeric fields that were incremented/decremented during
  5250. // this mutation.
  5251. func (m *BatchMsgMutation) AddedFields() []string {
  5252. var fields []string
  5253. if m.addstatus != nil {
  5254. fields = append(fields, batchmsg.FieldStatus)
  5255. }
  5256. if m.addtotal != nil {
  5257. fields = append(fields, batchmsg.FieldTotal)
  5258. }
  5259. if m.addsuccess != nil {
  5260. fields = append(fields, batchmsg.FieldSuccess)
  5261. }
  5262. if m.addfail != nil {
  5263. fields = append(fields, batchmsg.FieldFail)
  5264. }
  5265. if m.add_type != nil {
  5266. fields = append(fields, batchmsg.FieldType)
  5267. }
  5268. if m.addorganization_id != nil {
  5269. fields = append(fields, batchmsg.FieldOrganizationID)
  5270. }
  5271. return fields
  5272. }
  5273. // AddedField returns the numeric value that was incremented/decremented on a field
  5274. // with the given name. The second boolean return value indicates that this field
  5275. // was not set, or was not defined in the schema.
  5276. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5277. switch name {
  5278. case batchmsg.FieldStatus:
  5279. return m.AddedStatus()
  5280. case batchmsg.FieldTotal:
  5281. return m.AddedTotal()
  5282. case batchmsg.FieldSuccess:
  5283. return m.AddedSuccess()
  5284. case batchmsg.FieldFail:
  5285. return m.AddedFail()
  5286. case batchmsg.FieldType:
  5287. return m.AddedType()
  5288. case batchmsg.FieldOrganizationID:
  5289. return m.AddedOrganizationID()
  5290. }
  5291. return nil, false
  5292. }
  5293. // AddField adds the value to the field with the given name. It returns an error if
  5294. // the field is not defined in the schema, or if the type mismatched the field
  5295. // type.
  5296. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5297. switch name {
  5298. case batchmsg.FieldStatus:
  5299. v, ok := value.(int8)
  5300. if !ok {
  5301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5302. }
  5303. m.AddStatus(v)
  5304. return nil
  5305. case batchmsg.FieldTotal:
  5306. v, ok := value.(int32)
  5307. if !ok {
  5308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5309. }
  5310. m.AddTotal(v)
  5311. return nil
  5312. case batchmsg.FieldSuccess:
  5313. v, ok := value.(int32)
  5314. if !ok {
  5315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5316. }
  5317. m.AddSuccess(v)
  5318. return nil
  5319. case batchmsg.FieldFail:
  5320. v, ok := value.(int32)
  5321. if !ok {
  5322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5323. }
  5324. m.AddFail(v)
  5325. return nil
  5326. case batchmsg.FieldType:
  5327. v, ok := value.(int32)
  5328. if !ok {
  5329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5330. }
  5331. m.AddType(v)
  5332. return nil
  5333. case batchmsg.FieldOrganizationID:
  5334. v, ok := value.(int64)
  5335. if !ok {
  5336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5337. }
  5338. m.AddOrganizationID(v)
  5339. return nil
  5340. }
  5341. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5342. }
  5343. // ClearedFields returns all nullable fields that were cleared during this
  5344. // mutation.
  5345. func (m *BatchMsgMutation) ClearedFields() []string {
  5346. var fields []string
  5347. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5348. fields = append(fields, batchmsg.FieldDeletedAt)
  5349. }
  5350. if m.FieldCleared(batchmsg.FieldStatus) {
  5351. fields = append(fields, batchmsg.FieldStatus)
  5352. }
  5353. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5354. fields = append(fields, batchmsg.FieldBatchNo)
  5355. }
  5356. if m.FieldCleared(batchmsg.FieldTaskName) {
  5357. fields = append(fields, batchmsg.FieldTaskName)
  5358. }
  5359. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5360. fields = append(fields, batchmsg.FieldFromwxid)
  5361. }
  5362. if m.FieldCleared(batchmsg.FieldMsg) {
  5363. fields = append(fields, batchmsg.FieldMsg)
  5364. }
  5365. if m.FieldCleared(batchmsg.FieldTag) {
  5366. fields = append(fields, batchmsg.FieldTag)
  5367. }
  5368. if m.FieldCleared(batchmsg.FieldTagids) {
  5369. fields = append(fields, batchmsg.FieldTagids)
  5370. }
  5371. if m.FieldCleared(batchmsg.FieldTotal) {
  5372. fields = append(fields, batchmsg.FieldTotal)
  5373. }
  5374. if m.FieldCleared(batchmsg.FieldSuccess) {
  5375. fields = append(fields, batchmsg.FieldSuccess)
  5376. }
  5377. if m.FieldCleared(batchmsg.FieldFail) {
  5378. fields = append(fields, batchmsg.FieldFail)
  5379. }
  5380. if m.FieldCleared(batchmsg.FieldStartTime) {
  5381. fields = append(fields, batchmsg.FieldStartTime)
  5382. }
  5383. if m.FieldCleared(batchmsg.FieldStopTime) {
  5384. fields = append(fields, batchmsg.FieldStopTime)
  5385. }
  5386. if m.FieldCleared(batchmsg.FieldSendTime) {
  5387. fields = append(fields, batchmsg.FieldSendTime)
  5388. }
  5389. if m.FieldCleared(batchmsg.FieldType) {
  5390. fields = append(fields, batchmsg.FieldType)
  5391. }
  5392. return fields
  5393. }
  5394. // FieldCleared returns a boolean indicating if a field with the given name was
  5395. // cleared in this mutation.
  5396. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5397. _, ok := m.clearedFields[name]
  5398. return ok
  5399. }
  5400. // ClearField clears the value of the field with the given name. It returns an
  5401. // error if the field is not defined in the schema.
  5402. func (m *BatchMsgMutation) ClearField(name string) error {
  5403. switch name {
  5404. case batchmsg.FieldDeletedAt:
  5405. m.ClearDeletedAt()
  5406. return nil
  5407. case batchmsg.FieldStatus:
  5408. m.ClearStatus()
  5409. return nil
  5410. case batchmsg.FieldBatchNo:
  5411. m.ClearBatchNo()
  5412. return nil
  5413. case batchmsg.FieldTaskName:
  5414. m.ClearTaskName()
  5415. return nil
  5416. case batchmsg.FieldFromwxid:
  5417. m.ClearFromwxid()
  5418. return nil
  5419. case batchmsg.FieldMsg:
  5420. m.ClearMsg()
  5421. return nil
  5422. case batchmsg.FieldTag:
  5423. m.ClearTag()
  5424. return nil
  5425. case batchmsg.FieldTagids:
  5426. m.ClearTagids()
  5427. return nil
  5428. case batchmsg.FieldTotal:
  5429. m.ClearTotal()
  5430. return nil
  5431. case batchmsg.FieldSuccess:
  5432. m.ClearSuccess()
  5433. return nil
  5434. case batchmsg.FieldFail:
  5435. m.ClearFail()
  5436. return nil
  5437. case batchmsg.FieldStartTime:
  5438. m.ClearStartTime()
  5439. return nil
  5440. case batchmsg.FieldStopTime:
  5441. m.ClearStopTime()
  5442. return nil
  5443. case batchmsg.FieldSendTime:
  5444. m.ClearSendTime()
  5445. return nil
  5446. case batchmsg.FieldType:
  5447. m.ClearType()
  5448. return nil
  5449. }
  5450. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5451. }
  5452. // ResetField resets all changes in the mutation for the field with the given name.
  5453. // It returns an error if the field is not defined in the schema.
  5454. func (m *BatchMsgMutation) ResetField(name string) error {
  5455. switch name {
  5456. case batchmsg.FieldCreatedAt:
  5457. m.ResetCreatedAt()
  5458. return nil
  5459. case batchmsg.FieldUpdatedAt:
  5460. m.ResetUpdatedAt()
  5461. return nil
  5462. case batchmsg.FieldDeletedAt:
  5463. m.ResetDeletedAt()
  5464. return nil
  5465. case batchmsg.FieldStatus:
  5466. m.ResetStatus()
  5467. return nil
  5468. case batchmsg.FieldBatchNo:
  5469. m.ResetBatchNo()
  5470. return nil
  5471. case batchmsg.FieldTaskName:
  5472. m.ResetTaskName()
  5473. return nil
  5474. case batchmsg.FieldFromwxid:
  5475. m.ResetFromwxid()
  5476. return nil
  5477. case batchmsg.FieldMsg:
  5478. m.ResetMsg()
  5479. return nil
  5480. case batchmsg.FieldTag:
  5481. m.ResetTag()
  5482. return nil
  5483. case batchmsg.FieldTagids:
  5484. m.ResetTagids()
  5485. return nil
  5486. case batchmsg.FieldTotal:
  5487. m.ResetTotal()
  5488. return nil
  5489. case batchmsg.FieldSuccess:
  5490. m.ResetSuccess()
  5491. return nil
  5492. case batchmsg.FieldFail:
  5493. m.ResetFail()
  5494. return nil
  5495. case batchmsg.FieldStartTime:
  5496. m.ResetStartTime()
  5497. return nil
  5498. case batchmsg.FieldStopTime:
  5499. m.ResetStopTime()
  5500. return nil
  5501. case batchmsg.FieldSendTime:
  5502. m.ResetSendTime()
  5503. return nil
  5504. case batchmsg.FieldType:
  5505. m.ResetType()
  5506. return nil
  5507. case batchmsg.FieldOrganizationID:
  5508. m.ResetOrganizationID()
  5509. return nil
  5510. }
  5511. return fmt.Errorf("unknown BatchMsg field %s", name)
  5512. }
  5513. // AddedEdges returns all edge names that were set/added in this mutation.
  5514. func (m *BatchMsgMutation) AddedEdges() []string {
  5515. edges := make([]string, 0, 0)
  5516. return edges
  5517. }
  5518. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5519. // name in this mutation.
  5520. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5521. return nil
  5522. }
  5523. // RemovedEdges returns all edge names that were removed in this mutation.
  5524. func (m *BatchMsgMutation) RemovedEdges() []string {
  5525. edges := make([]string, 0, 0)
  5526. return edges
  5527. }
  5528. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5529. // the given name in this mutation.
  5530. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5531. return nil
  5532. }
  5533. // ClearedEdges returns all edge names that were cleared in this mutation.
  5534. func (m *BatchMsgMutation) ClearedEdges() []string {
  5535. edges := make([]string, 0, 0)
  5536. return edges
  5537. }
  5538. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5539. // was cleared in this mutation.
  5540. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5541. return false
  5542. }
  5543. // ClearEdge clears the value of the edge with the given name. It returns an error
  5544. // if that edge is not defined in the schema.
  5545. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5546. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5547. }
  5548. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5549. // It returns an error if the edge is not defined in the schema.
  5550. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5551. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5552. }
  5553. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5554. type CategoryMutation struct {
  5555. config
  5556. op Op
  5557. typ string
  5558. id *uint64
  5559. created_at *time.Time
  5560. updated_at *time.Time
  5561. deleted_at *time.Time
  5562. name *string
  5563. organization_id *uint64
  5564. addorganization_id *int64
  5565. clearedFields map[string]struct{}
  5566. done bool
  5567. oldValue func(context.Context) (*Category, error)
  5568. predicates []predicate.Category
  5569. }
  5570. var _ ent.Mutation = (*CategoryMutation)(nil)
  5571. // categoryOption allows management of the mutation configuration using functional options.
  5572. type categoryOption func(*CategoryMutation)
  5573. // newCategoryMutation creates new mutation for the Category entity.
  5574. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5575. m := &CategoryMutation{
  5576. config: c,
  5577. op: op,
  5578. typ: TypeCategory,
  5579. clearedFields: make(map[string]struct{}),
  5580. }
  5581. for _, opt := range opts {
  5582. opt(m)
  5583. }
  5584. return m
  5585. }
  5586. // withCategoryID sets the ID field of the mutation.
  5587. func withCategoryID(id uint64) categoryOption {
  5588. return func(m *CategoryMutation) {
  5589. var (
  5590. err error
  5591. once sync.Once
  5592. value *Category
  5593. )
  5594. m.oldValue = func(ctx context.Context) (*Category, error) {
  5595. once.Do(func() {
  5596. if m.done {
  5597. err = errors.New("querying old values post mutation is not allowed")
  5598. } else {
  5599. value, err = m.Client().Category.Get(ctx, id)
  5600. }
  5601. })
  5602. return value, err
  5603. }
  5604. m.id = &id
  5605. }
  5606. }
  5607. // withCategory sets the old Category of the mutation.
  5608. func withCategory(node *Category) categoryOption {
  5609. return func(m *CategoryMutation) {
  5610. m.oldValue = func(context.Context) (*Category, error) {
  5611. return node, nil
  5612. }
  5613. m.id = &node.ID
  5614. }
  5615. }
  5616. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5617. // executed in a transaction (ent.Tx), a transactional client is returned.
  5618. func (m CategoryMutation) Client() *Client {
  5619. client := &Client{config: m.config}
  5620. client.init()
  5621. return client
  5622. }
  5623. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5624. // it returns an error otherwise.
  5625. func (m CategoryMutation) Tx() (*Tx, error) {
  5626. if _, ok := m.driver.(*txDriver); !ok {
  5627. return nil, errors.New("ent: mutation is not running in a transaction")
  5628. }
  5629. tx := &Tx{config: m.config}
  5630. tx.init()
  5631. return tx, nil
  5632. }
  5633. // SetID sets the value of the id field. Note that this
  5634. // operation is only accepted on creation of Category entities.
  5635. func (m *CategoryMutation) SetID(id uint64) {
  5636. m.id = &id
  5637. }
  5638. // ID returns the ID value in the mutation. Note that the ID is only available
  5639. // if it was provided to the builder or after it was returned from the database.
  5640. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5641. if m.id == nil {
  5642. return
  5643. }
  5644. return *m.id, true
  5645. }
  5646. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5647. // That means, if the mutation is applied within a transaction with an isolation level such
  5648. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5649. // or updated by the mutation.
  5650. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5651. switch {
  5652. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5653. id, exists := m.ID()
  5654. if exists {
  5655. return []uint64{id}, nil
  5656. }
  5657. fallthrough
  5658. case m.op.Is(OpUpdate | OpDelete):
  5659. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5660. default:
  5661. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5662. }
  5663. }
  5664. // SetCreatedAt sets the "created_at" field.
  5665. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5666. m.created_at = &t
  5667. }
  5668. // CreatedAt returns the value of the "created_at" field in the mutation.
  5669. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5670. v := m.created_at
  5671. if v == nil {
  5672. return
  5673. }
  5674. return *v, true
  5675. }
  5676. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5677. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5679. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5680. if !m.op.Is(OpUpdateOne) {
  5681. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5682. }
  5683. if m.id == nil || m.oldValue == nil {
  5684. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5685. }
  5686. oldValue, err := m.oldValue(ctx)
  5687. if err != nil {
  5688. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5689. }
  5690. return oldValue.CreatedAt, nil
  5691. }
  5692. // ResetCreatedAt resets all changes to the "created_at" field.
  5693. func (m *CategoryMutation) ResetCreatedAt() {
  5694. m.created_at = nil
  5695. }
  5696. // SetUpdatedAt sets the "updated_at" field.
  5697. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5698. m.updated_at = &t
  5699. }
  5700. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5701. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5702. v := m.updated_at
  5703. if v == nil {
  5704. return
  5705. }
  5706. return *v, true
  5707. }
  5708. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5709. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5711. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5712. if !m.op.Is(OpUpdateOne) {
  5713. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5714. }
  5715. if m.id == nil || m.oldValue == nil {
  5716. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5717. }
  5718. oldValue, err := m.oldValue(ctx)
  5719. if err != nil {
  5720. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5721. }
  5722. return oldValue.UpdatedAt, nil
  5723. }
  5724. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5725. func (m *CategoryMutation) ResetUpdatedAt() {
  5726. m.updated_at = nil
  5727. }
  5728. // SetDeletedAt sets the "deleted_at" field.
  5729. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5730. m.deleted_at = &t
  5731. }
  5732. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5733. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5734. v := m.deleted_at
  5735. if v == nil {
  5736. return
  5737. }
  5738. return *v, true
  5739. }
  5740. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5741. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5743. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5744. if !m.op.Is(OpUpdateOne) {
  5745. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5746. }
  5747. if m.id == nil || m.oldValue == nil {
  5748. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5749. }
  5750. oldValue, err := m.oldValue(ctx)
  5751. if err != nil {
  5752. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5753. }
  5754. return oldValue.DeletedAt, nil
  5755. }
  5756. // ClearDeletedAt clears the value of the "deleted_at" field.
  5757. func (m *CategoryMutation) ClearDeletedAt() {
  5758. m.deleted_at = nil
  5759. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5760. }
  5761. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5762. func (m *CategoryMutation) DeletedAtCleared() bool {
  5763. _, ok := m.clearedFields[category.FieldDeletedAt]
  5764. return ok
  5765. }
  5766. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5767. func (m *CategoryMutation) ResetDeletedAt() {
  5768. m.deleted_at = nil
  5769. delete(m.clearedFields, category.FieldDeletedAt)
  5770. }
  5771. // SetName sets the "name" field.
  5772. func (m *CategoryMutation) SetName(s string) {
  5773. m.name = &s
  5774. }
  5775. // Name returns the value of the "name" field in the mutation.
  5776. func (m *CategoryMutation) Name() (r string, exists bool) {
  5777. v := m.name
  5778. if v == nil {
  5779. return
  5780. }
  5781. return *v, true
  5782. }
  5783. // OldName returns the old "name" field's value of the Category entity.
  5784. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5786. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5787. if !m.op.Is(OpUpdateOne) {
  5788. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5789. }
  5790. if m.id == nil || m.oldValue == nil {
  5791. return v, errors.New("OldName requires an ID field in the mutation")
  5792. }
  5793. oldValue, err := m.oldValue(ctx)
  5794. if err != nil {
  5795. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5796. }
  5797. return oldValue.Name, nil
  5798. }
  5799. // ResetName resets all changes to the "name" field.
  5800. func (m *CategoryMutation) ResetName() {
  5801. m.name = nil
  5802. }
  5803. // SetOrganizationID sets the "organization_id" field.
  5804. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5805. m.organization_id = &u
  5806. m.addorganization_id = nil
  5807. }
  5808. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5809. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5810. v := m.organization_id
  5811. if v == nil {
  5812. return
  5813. }
  5814. return *v, true
  5815. }
  5816. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  5817. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5819. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5820. if !m.op.Is(OpUpdateOne) {
  5821. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5822. }
  5823. if m.id == nil || m.oldValue == nil {
  5824. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5825. }
  5826. oldValue, err := m.oldValue(ctx)
  5827. if err != nil {
  5828. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5829. }
  5830. return oldValue.OrganizationID, nil
  5831. }
  5832. // AddOrganizationID adds u to the "organization_id" field.
  5833. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5834. if m.addorganization_id != nil {
  5835. *m.addorganization_id += u
  5836. } else {
  5837. m.addorganization_id = &u
  5838. }
  5839. }
  5840. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5841. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5842. v := m.addorganization_id
  5843. if v == nil {
  5844. return
  5845. }
  5846. return *v, true
  5847. }
  5848. // ResetOrganizationID resets all changes to the "organization_id" field.
  5849. func (m *CategoryMutation) ResetOrganizationID() {
  5850. m.organization_id = nil
  5851. m.addorganization_id = nil
  5852. }
  5853. // Where appends a list predicates to the CategoryMutation builder.
  5854. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5855. m.predicates = append(m.predicates, ps...)
  5856. }
  5857. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5858. // users can use type-assertion to append predicates that do not depend on any generated package.
  5859. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5860. p := make([]predicate.Category, len(ps))
  5861. for i := range ps {
  5862. p[i] = ps[i]
  5863. }
  5864. m.Where(p...)
  5865. }
  5866. // Op returns the operation name.
  5867. func (m *CategoryMutation) Op() Op {
  5868. return m.op
  5869. }
  5870. // SetOp allows setting the mutation operation.
  5871. func (m *CategoryMutation) SetOp(op Op) {
  5872. m.op = op
  5873. }
  5874. // Type returns the node type of this mutation (Category).
  5875. func (m *CategoryMutation) Type() string {
  5876. return m.typ
  5877. }
  5878. // Fields returns all fields that were changed during this mutation. Note that in
  5879. // order to get all numeric fields that were incremented/decremented, call
  5880. // AddedFields().
  5881. func (m *CategoryMutation) Fields() []string {
  5882. fields := make([]string, 0, 5)
  5883. if m.created_at != nil {
  5884. fields = append(fields, category.FieldCreatedAt)
  5885. }
  5886. if m.updated_at != nil {
  5887. fields = append(fields, category.FieldUpdatedAt)
  5888. }
  5889. if m.deleted_at != nil {
  5890. fields = append(fields, category.FieldDeletedAt)
  5891. }
  5892. if m.name != nil {
  5893. fields = append(fields, category.FieldName)
  5894. }
  5895. if m.organization_id != nil {
  5896. fields = append(fields, category.FieldOrganizationID)
  5897. }
  5898. return fields
  5899. }
  5900. // Field returns the value of a field with the given name. The second boolean
  5901. // return value indicates that this field was not set, or was not defined in the
  5902. // schema.
  5903. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5904. switch name {
  5905. case category.FieldCreatedAt:
  5906. return m.CreatedAt()
  5907. case category.FieldUpdatedAt:
  5908. return m.UpdatedAt()
  5909. case category.FieldDeletedAt:
  5910. return m.DeletedAt()
  5911. case category.FieldName:
  5912. return m.Name()
  5913. case category.FieldOrganizationID:
  5914. return m.OrganizationID()
  5915. }
  5916. return nil, false
  5917. }
  5918. // OldField returns the old value of the field from the database. An error is
  5919. // returned if the mutation operation is not UpdateOne, or the query to the
  5920. // database failed.
  5921. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5922. switch name {
  5923. case category.FieldCreatedAt:
  5924. return m.OldCreatedAt(ctx)
  5925. case category.FieldUpdatedAt:
  5926. return m.OldUpdatedAt(ctx)
  5927. case category.FieldDeletedAt:
  5928. return m.OldDeletedAt(ctx)
  5929. case category.FieldName:
  5930. return m.OldName(ctx)
  5931. case category.FieldOrganizationID:
  5932. return m.OldOrganizationID(ctx)
  5933. }
  5934. return nil, fmt.Errorf("unknown Category field %s", name)
  5935. }
  5936. // SetField sets the value of a field with the given name. It returns an error if
  5937. // the field is not defined in the schema, or if the type mismatched the field
  5938. // type.
  5939. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5940. switch name {
  5941. case category.FieldCreatedAt:
  5942. v, ok := value.(time.Time)
  5943. if !ok {
  5944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5945. }
  5946. m.SetCreatedAt(v)
  5947. return nil
  5948. case category.FieldUpdatedAt:
  5949. v, ok := value.(time.Time)
  5950. if !ok {
  5951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5952. }
  5953. m.SetUpdatedAt(v)
  5954. return nil
  5955. case category.FieldDeletedAt:
  5956. v, ok := value.(time.Time)
  5957. if !ok {
  5958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5959. }
  5960. m.SetDeletedAt(v)
  5961. return nil
  5962. case category.FieldName:
  5963. v, ok := value.(string)
  5964. if !ok {
  5965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5966. }
  5967. m.SetName(v)
  5968. return nil
  5969. case category.FieldOrganizationID:
  5970. v, ok := value.(uint64)
  5971. if !ok {
  5972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5973. }
  5974. m.SetOrganizationID(v)
  5975. return nil
  5976. }
  5977. return fmt.Errorf("unknown Category field %s", name)
  5978. }
  5979. // AddedFields returns all numeric fields that were incremented/decremented during
  5980. // this mutation.
  5981. func (m *CategoryMutation) AddedFields() []string {
  5982. var fields []string
  5983. if m.addorganization_id != nil {
  5984. fields = append(fields, category.FieldOrganizationID)
  5985. }
  5986. return fields
  5987. }
  5988. // AddedField returns the numeric value that was incremented/decremented on a field
  5989. // with the given name. The second boolean return value indicates that this field
  5990. // was not set, or was not defined in the schema.
  5991. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5992. switch name {
  5993. case category.FieldOrganizationID:
  5994. return m.AddedOrganizationID()
  5995. }
  5996. return nil, false
  5997. }
  5998. // AddField adds the value to the field with the given name. It returns an error if
  5999. // the field is not defined in the schema, or if the type mismatched the field
  6000. // type.
  6001. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  6002. switch name {
  6003. case category.FieldOrganizationID:
  6004. v, ok := value.(int64)
  6005. if !ok {
  6006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6007. }
  6008. m.AddOrganizationID(v)
  6009. return nil
  6010. }
  6011. return fmt.Errorf("unknown Category numeric field %s", name)
  6012. }
  6013. // ClearedFields returns all nullable fields that were cleared during this
  6014. // mutation.
  6015. func (m *CategoryMutation) ClearedFields() []string {
  6016. var fields []string
  6017. if m.FieldCleared(category.FieldDeletedAt) {
  6018. fields = append(fields, category.FieldDeletedAt)
  6019. }
  6020. return fields
  6021. }
  6022. // FieldCleared returns a boolean indicating if a field with the given name was
  6023. // cleared in this mutation.
  6024. func (m *CategoryMutation) FieldCleared(name string) bool {
  6025. _, ok := m.clearedFields[name]
  6026. return ok
  6027. }
  6028. // ClearField clears the value of the field with the given name. It returns an
  6029. // error if the field is not defined in the schema.
  6030. func (m *CategoryMutation) ClearField(name string) error {
  6031. switch name {
  6032. case category.FieldDeletedAt:
  6033. m.ClearDeletedAt()
  6034. return nil
  6035. }
  6036. return fmt.Errorf("unknown Category nullable field %s", name)
  6037. }
  6038. // ResetField resets all changes in the mutation for the field with the given name.
  6039. // It returns an error if the field is not defined in the schema.
  6040. func (m *CategoryMutation) ResetField(name string) error {
  6041. switch name {
  6042. case category.FieldCreatedAt:
  6043. m.ResetCreatedAt()
  6044. return nil
  6045. case category.FieldUpdatedAt:
  6046. m.ResetUpdatedAt()
  6047. return nil
  6048. case category.FieldDeletedAt:
  6049. m.ResetDeletedAt()
  6050. return nil
  6051. case category.FieldName:
  6052. m.ResetName()
  6053. return nil
  6054. case category.FieldOrganizationID:
  6055. m.ResetOrganizationID()
  6056. return nil
  6057. }
  6058. return fmt.Errorf("unknown Category field %s", name)
  6059. }
  6060. // AddedEdges returns all edge names that were set/added in this mutation.
  6061. func (m *CategoryMutation) AddedEdges() []string {
  6062. edges := make([]string, 0, 0)
  6063. return edges
  6064. }
  6065. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6066. // name in this mutation.
  6067. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  6068. return nil
  6069. }
  6070. // RemovedEdges returns all edge names that were removed in this mutation.
  6071. func (m *CategoryMutation) RemovedEdges() []string {
  6072. edges := make([]string, 0, 0)
  6073. return edges
  6074. }
  6075. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6076. // the given name in this mutation.
  6077. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  6078. return nil
  6079. }
  6080. // ClearedEdges returns all edge names that were cleared in this mutation.
  6081. func (m *CategoryMutation) ClearedEdges() []string {
  6082. edges := make([]string, 0, 0)
  6083. return edges
  6084. }
  6085. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6086. // was cleared in this mutation.
  6087. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6088. return false
  6089. }
  6090. // ClearEdge clears the value of the edge with the given name. It returns an error
  6091. // if that edge is not defined in the schema.
  6092. func (m *CategoryMutation) ClearEdge(name string) error {
  6093. return fmt.Errorf("unknown Category unique edge %s", name)
  6094. }
  6095. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6096. // It returns an error if the edge is not defined in the schema.
  6097. func (m *CategoryMutation) ResetEdge(name string) error {
  6098. return fmt.Errorf("unknown Category edge %s", name)
  6099. }
  6100. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6101. type ChatRecordsMutation struct {
  6102. config
  6103. op Op
  6104. typ string
  6105. id *uint64
  6106. created_at *time.Time
  6107. updated_at *time.Time
  6108. deleted_at *time.Time
  6109. content *string
  6110. content_type *uint8
  6111. addcontent_type *int8
  6112. session_id *uint64
  6113. addsession_id *int64
  6114. user_id *uint64
  6115. adduser_id *int64
  6116. bot_id *uint64
  6117. addbot_id *int64
  6118. bot_type *uint8
  6119. addbot_type *int8
  6120. clearedFields map[string]struct{}
  6121. done bool
  6122. oldValue func(context.Context) (*ChatRecords, error)
  6123. predicates []predicate.ChatRecords
  6124. }
  6125. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6126. // chatrecordsOption allows management of the mutation configuration using functional options.
  6127. type chatrecordsOption func(*ChatRecordsMutation)
  6128. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6129. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6130. m := &ChatRecordsMutation{
  6131. config: c,
  6132. op: op,
  6133. typ: TypeChatRecords,
  6134. clearedFields: make(map[string]struct{}),
  6135. }
  6136. for _, opt := range opts {
  6137. opt(m)
  6138. }
  6139. return m
  6140. }
  6141. // withChatRecordsID sets the ID field of the mutation.
  6142. func withChatRecordsID(id uint64) chatrecordsOption {
  6143. return func(m *ChatRecordsMutation) {
  6144. var (
  6145. err error
  6146. once sync.Once
  6147. value *ChatRecords
  6148. )
  6149. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6150. once.Do(func() {
  6151. if m.done {
  6152. err = errors.New("querying old values post mutation is not allowed")
  6153. } else {
  6154. value, err = m.Client().ChatRecords.Get(ctx, id)
  6155. }
  6156. })
  6157. return value, err
  6158. }
  6159. m.id = &id
  6160. }
  6161. }
  6162. // withChatRecords sets the old ChatRecords of the mutation.
  6163. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6164. return func(m *ChatRecordsMutation) {
  6165. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6166. return node, nil
  6167. }
  6168. m.id = &node.ID
  6169. }
  6170. }
  6171. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6172. // executed in a transaction (ent.Tx), a transactional client is returned.
  6173. func (m ChatRecordsMutation) Client() *Client {
  6174. client := &Client{config: m.config}
  6175. client.init()
  6176. return client
  6177. }
  6178. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6179. // it returns an error otherwise.
  6180. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6181. if _, ok := m.driver.(*txDriver); !ok {
  6182. return nil, errors.New("ent: mutation is not running in a transaction")
  6183. }
  6184. tx := &Tx{config: m.config}
  6185. tx.init()
  6186. return tx, nil
  6187. }
  6188. // SetID sets the value of the id field. Note that this
  6189. // operation is only accepted on creation of ChatRecords entities.
  6190. func (m *ChatRecordsMutation) SetID(id uint64) {
  6191. m.id = &id
  6192. }
  6193. // ID returns the ID value in the mutation. Note that the ID is only available
  6194. // if it was provided to the builder or after it was returned from the database.
  6195. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6196. if m.id == nil {
  6197. return
  6198. }
  6199. return *m.id, true
  6200. }
  6201. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6202. // That means, if the mutation is applied within a transaction with an isolation level such
  6203. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6204. // or updated by the mutation.
  6205. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6206. switch {
  6207. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6208. id, exists := m.ID()
  6209. if exists {
  6210. return []uint64{id}, nil
  6211. }
  6212. fallthrough
  6213. case m.op.Is(OpUpdate | OpDelete):
  6214. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6215. default:
  6216. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6217. }
  6218. }
  6219. // SetCreatedAt sets the "created_at" field.
  6220. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6221. m.created_at = &t
  6222. }
  6223. // CreatedAt returns the value of the "created_at" field in the mutation.
  6224. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6225. v := m.created_at
  6226. if v == nil {
  6227. return
  6228. }
  6229. return *v, true
  6230. }
  6231. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6232. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6234. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6235. if !m.op.Is(OpUpdateOne) {
  6236. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6237. }
  6238. if m.id == nil || m.oldValue == nil {
  6239. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6240. }
  6241. oldValue, err := m.oldValue(ctx)
  6242. if err != nil {
  6243. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6244. }
  6245. return oldValue.CreatedAt, nil
  6246. }
  6247. // ResetCreatedAt resets all changes to the "created_at" field.
  6248. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6249. m.created_at = nil
  6250. }
  6251. // SetUpdatedAt sets the "updated_at" field.
  6252. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6253. m.updated_at = &t
  6254. }
  6255. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6256. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6257. v := m.updated_at
  6258. if v == nil {
  6259. return
  6260. }
  6261. return *v, true
  6262. }
  6263. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6264. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6266. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6267. if !m.op.Is(OpUpdateOne) {
  6268. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6269. }
  6270. if m.id == nil || m.oldValue == nil {
  6271. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6272. }
  6273. oldValue, err := m.oldValue(ctx)
  6274. if err != nil {
  6275. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6276. }
  6277. return oldValue.UpdatedAt, nil
  6278. }
  6279. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6280. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6281. m.updated_at = nil
  6282. }
  6283. // SetDeletedAt sets the "deleted_at" field.
  6284. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6285. m.deleted_at = &t
  6286. }
  6287. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6288. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6289. v := m.deleted_at
  6290. if v == nil {
  6291. return
  6292. }
  6293. return *v, true
  6294. }
  6295. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6296. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6298. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6299. if !m.op.Is(OpUpdateOne) {
  6300. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6301. }
  6302. if m.id == nil || m.oldValue == nil {
  6303. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6304. }
  6305. oldValue, err := m.oldValue(ctx)
  6306. if err != nil {
  6307. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6308. }
  6309. return oldValue.DeletedAt, nil
  6310. }
  6311. // ClearDeletedAt clears the value of the "deleted_at" field.
  6312. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6313. m.deleted_at = nil
  6314. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6315. }
  6316. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6317. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6318. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6319. return ok
  6320. }
  6321. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6322. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6323. m.deleted_at = nil
  6324. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6325. }
  6326. // SetContent sets the "content" field.
  6327. func (m *ChatRecordsMutation) SetContent(s string) {
  6328. m.content = &s
  6329. }
  6330. // Content returns the value of the "content" field in the mutation.
  6331. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6332. v := m.content
  6333. if v == nil {
  6334. return
  6335. }
  6336. return *v, true
  6337. }
  6338. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6339. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6341. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6342. if !m.op.Is(OpUpdateOne) {
  6343. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6344. }
  6345. if m.id == nil || m.oldValue == nil {
  6346. return v, errors.New("OldContent requires an ID field in the mutation")
  6347. }
  6348. oldValue, err := m.oldValue(ctx)
  6349. if err != nil {
  6350. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6351. }
  6352. return oldValue.Content, nil
  6353. }
  6354. // ResetContent resets all changes to the "content" field.
  6355. func (m *ChatRecordsMutation) ResetContent() {
  6356. m.content = nil
  6357. }
  6358. // SetContentType sets the "content_type" field.
  6359. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6360. m.content_type = &u
  6361. m.addcontent_type = nil
  6362. }
  6363. // ContentType returns the value of the "content_type" field in the mutation.
  6364. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6365. v := m.content_type
  6366. if v == nil {
  6367. return
  6368. }
  6369. return *v, true
  6370. }
  6371. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6372. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6374. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6375. if !m.op.Is(OpUpdateOne) {
  6376. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6377. }
  6378. if m.id == nil || m.oldValue == nil {
  6379. return v, errors.New("OldContentType requires an ID field in the mutation")
  6380. }
  6381. oldValue, err := m.oldValue(ctx)
  6382. if err != nil {
  6383. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6384. }
  6385. return oldValue.ContentType, nil
  6386. }
  6387. // AddContentType adds u to the "content_type" field.
  6388. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6389. if m.addcontent_type != nil {
  6390. *m.addcontent_type += u
  6391. } else {
  6392. m.addcontent_type = &u
  6393. }
  6394. }
  6395. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6396. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6397. v := m.addcontent_type
  6398. if v == nil {
  6399. return
  6400. }
  6401. return *v, true
  6402. }
  6403. // ResetContentType resets all changes to the "content_type" field.
  6404. func (m *ChatRecordsMutation) ResetContentType() {
  6405. m.content_type = nil
  6406. m.addcontent_type = nil
  6407. }
  6408. // SetSessionID sets the "session_id" field.
  6409. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6410. m.session_id = &u
  6411. m.addsession_id = nil
  6412. }
  6413. // SessionID returns the value of the "session_id" field in the mutation.
  6414. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6415. v := m.session_id
  6416. if v == nil {
  6417. return
  6418. }
  6419. return *v, true
  6420. }
  6421. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6422. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6424. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6425. if !m.op.Is(OpUpdateOne) {
  6426. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6427. }
  6428. if m.id == nil || m.oldValue == nil {
  6429. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6430. }
  6431. oldValue, err := m.oldValue(ctx)
  6432. if err != nil {
  6433. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6434. }
  6435. return oldValue.SessionID, nil
  6436. }
  6437. // AddSessionID adds u to the "session_id" field.
  6438. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6439. if m.addsession_id != nil {
  6440. *m.addsession_id += u
  6441. } else {
  6442. m.addsession_id = &u
  6443. }
  6444. }
  6445. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6446. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6447. v := m.addsession_id
  6448. if v == nil {
  6449. return
  6450. }
  6451. return *v, true
  6452. }
  6453. // ResetSessionID resets all changes to the "session_id" field.
  6454. func (m *ChatRecordsMutation) ResetSessionID() {
  6455. m.session_id = nil
  6456. m.addsession_id = nil
  6457. }
  6458. // SetUserID sets the "user_id" field.
  6459. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6460. m.user_id = &u
  6461. m.adduser_id = nil
  6462. }
  6463. // UserID returns the value of the "user_id" field in the mutation.
  6464. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6465. v := m.user_id
  6466. if v == nil {
  6467. return
  6468. }
  6469. return *v, true
  6470. }
  6471. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6472. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6474. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6475. if !m.op.Is(OpUpdateOne) {
  6476. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6477. }
  6478. if m.id == nil || m.oldValue == nil {
  6479. return v, errors.New("OldUserID requires an ID field in the mutation")
  6480. }
  6481. oldValue, err := m.oldValue(ctx)
  6482. if err != nil {
  6483. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6484. }
  6485. return oldValue.UserID, nil
  6486. }
  6487. // AddUserID adds u to the "user_id" field.
  6488. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6489. if m.adduser_id != nil {
  6490. *m.adduser_id += u
  6491. } else {
  6492. m.adduser_id = &u
  6493. }
  6494. }
  6495. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6496. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6497. v := m.adduser_id
  6498. if v == nil {
  6499. return
  6500. }
  6501. return *v, true
  6502. }
  6503. // ResetUserID resets all changes to the "user_id" field.
  6504. func (m *ChatRecordsMutation) ResetUserID() {
  6505. m.user_id = nil
  6506. m.adduser_id = nil
  6507. }
  6508. // SetBotID sets the "bot_id" field.
  6509. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6510. m.bot_id = &u
  6511. m.addbot_id = nil
  6512. }
  6513. // BotID returns the value of the "bot_id" field in the mutation.
  6514. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6515. v := m.bot_id
  6516. if v == nil {
  6517. return
  6518. }
  6519. return *v, true
  6520. }
  6521. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6522. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6524. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6525. if !m.op.Is(OpUpdateOne) {
  6526. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6527. }
  6528. if m.id == nil || m.oldValue == nil {
  6529. return v, errors.New("OldBotID requires an ID field in the mutation")
  6530. }
  6531. oldValue, err := m.oldValue(ctx)
  6532. if err != nil {
  6533. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6534. }
  6535. return oldValue.BotID, nil
  6536. }
  6537. // AddBotID adds u to the "bot_id" field.
  6538. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6539. if m.addbot_id != nil {
  6540. *m.addbot_id += u
  6541. } else {
  6542. m.addbot_id = &u
  6543. }
  6544. }
  6545. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6546. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6547. v := m.addbot_id
  6548. if v == nil {
  6549. return
  6550. }
  6551. return *v, true
  6552. }
  6553. // ResetBotID resets all changes to the "bot_id" field.
  6554. func (m *ChatRecordsMutation) ResetBotID() {
  6555. m.bot_id = nil
  6556. m.addbot_id = nil
  6557. }
  6558. // SetBotType sets the "bot_type" field.
  6559. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6560. m.bot_type = &u
  6561. m.addbot_type = nil
  6562. }
  6563. // BotType returns the value of the "bot_type" field in the mutation.
  6564. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6565. v := m.bot_type
  6566. if v == nil {
  6567. return
  6568. }
  6569. return *v, true
  6570. }
  6571. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6572. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6574. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6575. if !m.op.Is(OpUpdateOne) {
  6576. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6577. }
  6578. if m.id == nil || m.oldValue == nil {
  6579. return v, errors.New("OldBotType requires an ID field in the mutation")
  6580. }
  6581. oldValue, err := m.oldValue(ctx)
  6582. if err != nil {
  6583. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6584. }
  6585. return oldValue.BotType, nil
  6586. }
  6587. // AddBotType adds u to the "bot_type" field.
  6588. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6589. if m.addbot_type != nil {
  6590. *m.addbot_type += u
  6591. } else {
  6592. m.addbot_type = &u
  6593. }
  6594. }
  6595. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6596. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6597. v := m.addbot_type
  6598. if v == nil {
  6599. return
  6600. }
  6601. return *v, true
  6602. }
  6603. // ResetBotType resets all changes to the "bot_type" field.
  6604. func (m *ChatRecordsMutation) ResetBotType() {
  6605. m.bot_type = nil
  6606. m.addbot_type = nil
  6607. }
  6608. // Where appends a list predicates to the ChatRecordsMutation builder.
  6609. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6610. m.predicates = append(m.predicates, ps...)
  6611. }
  6612. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6613. // users can use type-assertion to append predicates that do not depend on any generated package.
  6614. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6615. p := make([]predicate.ChatRecords, len(ps))
  6616. for i := range ps {
  6617. p[i] = ps[i]
  6618. }
  6619. m.Where(p...)
  6620. }
  6621. // Op returns the operation name.
  6622. func (m *ChatRecordsMutation) Op() Op {
  6623. return m.op
  6624. }
  6625. // SetOp allows setting the mutation operation.
  6626. func (m *ChatRecordsMutation) SetOp(op Op) {
  6627. m.op = op
  6628. }
  6629. // Type returns the node type of this mutation (ChatRecords).
  6630. func (m *ChatRecordsMutation) Type() string {
  6631. return m.typ
  6632. }
  6633. // Fields returns all fields that were changed during this mutation. Note that in
  6634. // order to get all numeric fields that were incremented/decremented, call
  6635. // AddedFields().
  6636. func (m *ChatRecordsMutation) Fields() []string {
  6637. fields := make([]string, 0, 9)
  6638. if m.created_at != nil {
  6639. fields = append(fields, chatrecords.FieldCreatedAt)
  6640. }
  6641. if m.updated_at != nil {
  6642. fields = append(fields, chatrecords.FieldUpdatedAt)
  6643. }
  6644. if m.deleted_at != nil {
  6645. fields = append(fields, chatrecords.FieldDeletedAt)
  6646. }
  6647. if m.content != nil {
  6648. fields = append(fields, chatrecords.FieldContent)
  6649. }
  6650. if m.content_type != nil {
  6651. fields = append(fields, chatrecords.FieldContentType)
  6652. }
  6653. if m.session_id != nil {
  6654. fields = append(fields, chatrecords.FieldSessionID)
  6655. }
  6656. if m.user_id != nil {
  6657. fields = append(fields, chatrecords.FieldUserID)
  6658. }
  6659. if m.bot_id != nil {
  6660. fields = append(fields, chatrecords.FieldBotID)
  6661. }
  6662. if m.bot_type != nil {
  6663. fields = append(fields, chatrecords.FieldBotType)
  6664. }
  6665. return fields
  6666. }
  6667. // Field returns the value of a field with the given name. The second boolean
  6668. // return value indicates that this field was not set, or was not defined in the
  6669. // schema.
  6670. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6671. switch name {
  6672. case chatrecords.FieldCreatedAt:
  6673. return m.CreatedAt()
  6674. case chatrecords.FieldUpdatedAt:
  6675. return m.UpdatedAt()
  6676. case chatrecords.FieldDeletedAt:
  6677. return m.DeletedAt()
  6678. case chatrecords.FieldContent:
  6679. return m.Content()
  6680. case chatrecords.FieldContentType:
  6681. return m.ContentType()
  6682. case chatrecords.FieldSessionID:
  6683. return m.SessionID()
  6684. case chatrecords.FieldUserID:
  6685. return m.UserID()
  6686. case chatrecords.FieldBotID:
  6687. return m.BotID()
  6688. case chatrecords.FieldBotType:
  6689. return m.BotType()
  6690. }
  6691. return nil, false
  6692. }
  6693. // OldField returns the old value of the field from the database. An error is
  6694. // returned if the mutation operation is not UpdateOne, or the query to the
  6695. // database failed.
  6696. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6697. switch name {
  6698. case chatrecords.FieldCreatedAt:
  6699. return m.OldCreatedAt(ctx)
  6700. case chatrecords.FieldUpdatedAt:
  6701. return m.OldUpdatedAt(ctx)
  6702. case chatrecords.FieldDeletedAt:
  6703. return m.OldDeletedAt(ctx)
  6704. case chatrecords.FieldContent:
  6705. return m.OldContent(ctx)
  6706. case chatrecords.FieldContentType:
  6707. return m.OldContentType(ctx)
  6708. case chatrecords.FieldSessionID:
  6709. return m.OldSessionID(ctx)
  6710. case chatrecords.FieldUserID:
  6711. return m.OldUserID(ctx)
  6712. case chatrecords.FieldBotID:
  6713. return m.OldBotID(ctx)
  6714. case chatrecords.FieldBotType:
  6715. return m.OldBotType(ctx)
  6716. }
  6717. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6718. }
  6719. // SetField sets the value of a field with the given name. It returns an error if
  6720. // the field is not defined in the schema, or if the type mismatched the field
  6721. // type.
  6722. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6723. switch name {
  6724. case chatrecords.FieldCreatedAt:
  6725. v, ok := value.(time.Time)
  6726. if !ok {
  6727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6728. }
  6729. m.SetCreatedAt(v)
  6730. return nil
  6731. case chatrecords.FieldUpdatedAt:
  6732. v, ok := value.(time.Time)
  6733. if !ok {
  6734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6735. }
  6736. m.SetUpdatedAt(v)
  6737. return nil
  6738. case chatrecords.FieldDeletedAt:
  6739. v, ok := value.(time.Time)
  6740. if !ok {
  6741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6742. }
  6743. m.SetDeletedAt(v)
  6744. return nil
  6745. case chatrecords.FieldContent:
  6746. v, ok := value.(string)
  6747. if !ok {
  6748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6749. }
  6750. m.SetContent(v)
  6751. return nil
  6752. case chatrecords.FieldContentType:
  6753. v, ok := value.(uint8)
  6754. if !ok {
  6755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6756. }
  6757. m.SetContentType(v)
  6758. return nil
  6759. case chatrecords.FieldSessionID:
  6760. v, ok := value.(uint64)
  6761. if !ok {
  6762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6763. }
  6764. m.SetSessionID(v)
  6765. return nil
  6766. case chatrecords.FieldUserID:
  6767. v, ok := value.(uint64)
  6768. if !ok {
  6769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6770. }
  6771. m.SetUserID(v)
  6772. return nil
  6773. case chatrecords.FieldBotID:
  6774. v, ok := value.(uint64)
  6775. if !ok {
  6776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6777. }
  6778. m.SetBotID(v)
  6779. return nil
  6780. case chatrecords.FieldBotType:
  6781. v, ok := value.(uint8)
  6782. if !ok {
  6783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6784. }
  6785. m.SetBotType(v)
  6786. return nil
  6787. }
  6788. return fmt.Errorf("unknown ChatRecords field %s", name)
  6789. }
  6790. // AddedFields returns all numeric fields that were incremented/decremented during
  6791. // this mutation.
  6792. func (m *ChatRecordsMutation) AddedFields() []string {
  6793. var fields []string
  6794. if m.addcontent_type != nil {
  6795. fields = append(fields, chatrecords.FieldContentType)
  6796. }
  6797. if m.addsession_id != nil {
  6798. fields = append(fields, chatrecords.FieldSessionID)
  6799. }
  6800. if m.adduser_id != nil {
  6801. fields = append(fields, chatrecords.FieldUserID)
  6802. }
  6803. if m.addbot_id != nil {
  6804. fields = append(fields, chatrecords.FieldBotID)
  6805. }
  6806. if m.addbot_type != nil {
  6807. fields = append(fields, chatrecords.FieldBotType)
  6808. }
  6809. return fields
  6810. }
  6811. // AddedField returns the numeric value that was incremented/decremented on a field
  6812. // with the given name. The second boolean return value indicates that this field
  6813. // was not set, or was not defined in the schema.
  6814. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6815. switch name {
  6816. case chatrecords.FieldContentType:
  6817. return m.AddedContentType()
  6818. case chatrecords.FieldSessionID:
  6819. return m.AddedSessionID()
  6820. case chatrecords.FieldUserID:
  6821. return m.AddedUserID()
  6822. case chatrecords.FieldBotID:
  6823. return m.AddedBotID()
  6824. case chatrecords.FieldBotType:
  6825. return m.AddedBotType()
  6826. }
  6827. return nil, false
  6828. }
  6829. // AddField adds the value to the field with the given name. It returns an error if
  6830. // the field is not defined in the schema, or if the type mismatched the field
  6831. // type.
  6832. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6833. switch name {
  6834. case chatrecords.FieldContentType:
  6835. v, ok := value.(int8)
  6836. if !ok {
  6837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6838. }
  6839. m.AddContentType(v)
  6840. return nil
  6841. case chatrecords.FieldSessionID:
  6842. v, ok := value.(int64)
  6843. if !ok {
  6844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6845. }
  6846. m.AddSessionID(v)
  6847. return nil
  6848. case chatrecords.FieldUserID:
  6849. v, ok := value.(int64)
  6850. if !ok {
  6851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6852. }
  6853. m.AddUserID(v)
  6854. return nil
  6855. case chatrecords.FieldBotID:
  6856. v, ok := value.(int64)
  6857. if !ok {
  6858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6859. }
  6860. m.AddBotID(v)
  6861. return nil
  6862. case chatrecords.FieldBotType:
  6863. v, ok := value.(int8)
  6864. if !ok {
  6865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6866. }
  6867. m.AddBotType(v)
  6868. return nil
  6869. }
  6870. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6871. }
  6872. // ClearedFields returns all nullable fields that were cleared during this
  6873. // mutation.
  6874. func (m *ChatRecordsMutation) ClearedFields() []string {
  6875. var fields []string
  6876. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6877. fields = append(fields, chatrecords.FieldDeletedAt)
  6878. }
  6879. return fields
  6880. }
  6881. // FieldCleared returns a boolean indicating if a field with the given name was
  6882. // cleared in this mutation.
  6883. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6884. _, ok := m.clearedFields[name]
  6885. return ok
  6886. }
  6887. // ClearField clears the value of the field with the given name. It returns an
  6888. // error if the field is not defined in the schema.
  6889. func (m *ChatRecordsMutation) ClearField(name string) error {
  6890. switch name {
  6891. case chatrecords.FieldDeletedAt:
  6892. m.ClearDeletedAt()
  6893. return nil
  6894. }
  6895. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6896. }
  6897. // ResetField resets all changes in the mutation for the field with the given name.
  6898. // It returns an error if the field is not defined in the schema.
  6899. func (m *ChatRecordsMutation) ResetField(name string) error {
  6900. switch name {
  6901. case chatrecords.FieldCreatedAt:
  6902. m.ResetCreatedAt()
  6903. return nil
  6904. case chatrecords.FieldUpdatedAt:
  6905. m.ResetUpdatedAt()
  6906. return nil
  6907. case chatrecords.FieldDeletedAt:
  6908. m.ResetDeletedAt()
  6909. return nil
  6910. case chatrecords.FieldContent:
  6911. m.ResetContent()
  6912. return nil
  6913. case chatrecords.FieldContentType:
  6914. m.ResetContentType()
  6915. return nil
  6916. case chatrecords.FieldSessionID:
  6917. m.ResetSessionID()
  6918. return nil
  6919. case chatrecords.FieldUserID:
  6920. m.ResetUserID()
  6921. return nil
  6922. case chatrecords.FieldBotID:
  6923. m.ResetBotID()
  6924. return nil
  6925. case chatrecords.FieldBotType:
  6926. m.ResetBotType()
  6927. return nil
  6928. }
  6929. return fmt.Errorf("unknown ChatRecords field %s", name)
  6930. }
  6931. // AddedEdges returns all edge names that were set/added in this mutation.
  6932. func (m *ChatRecordsMutation) AddedEdges() []string {
  6933. edges := make([]string, 0, 0)
  6934. return edges
  6935. }
  6936. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6937. // name in this mutation.
  6938. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6939. return nil
  6940. }
  6941. // RemovedEdges returns all edge names that were removed in this mutation.
  6942. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6943. edges := make([]string, 0, 0)
  6944. return edges
  6945. }
  6946. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6947. // the given name in this mutation.
  6948. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6949. return nil
  6950. }
  6951. // ClearedEdges returns all edge names that were cleared in this mutation.
  6952. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6953. edges := make([]string, 0, 0)
  6954. return edges
  6955. }
  6956. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6957. // was cleared in this mutation.
  6958. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6959. return false
  6960. }
  6961. // ClearEdge clears the value of the edge with the given name. It returns an error
  6962. // if that edge is not defined in the schema.
  6963. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6964. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6965. }
  6966. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6967. // It returns an error if the edge is not defined in the schema.
  6968. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6969. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6970. }
  6971. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6972. type ChatSessionMutation struct {
  6973. config
  6974. op Op
  6975. typ string
  6976. id *uint64
  6977. created_at *time.Time
  6978. updated_at *time.Time
  6979. deleted_at *time.Time
  6980. name *string
  6981. user_id *uint64
  6982. adduser_id *int64
  6983. bot_id *uint64
  6984. addbot_id *int64
  6985. bot_type *uint8
  6986. addbot_type *int8
  6987. clearedFields map[string]struct{}
  6988. done bool
  6989. oldValue func(context.Context) (*ChatSession, error)
  6990. predicates []predicate.ChatSession
  6991. }
  6992. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6993. // chatsessionOption allows management of the mutation configuration using functional options.
  6994. type chatsessionOption func(*ChatSessionMutation)
  6995. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6996. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6997. m := &ChatSessionMutation{
  6998. config: c,
  6999. op: op,
  7000. typ: TypeChatSession,
  7001. clearedFields: make(map[string]struct{}),
  7002. }
  7003. for _, opt := range opts {
  7004. opt(m)
  7005. }
  7006. return m
  7007. }
  7008. // withChatSessionID sets the ID field of the mutation.
  7009. func withChatSessionID(id uint64) chatsessionOption {
  7010. return func(m *ChatSessionMutation) {
  7011. var (
  7012. err error
  7013. once sync.Once
  7014. value *ChatSession
  7015. )
  7016. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  7017. once.Do(func() {
  7018. if m.done {
  7019. err = errors.New("querying old values post mutation is not allowed")
  7020. } else {
  7021. value, err = m.Client().ChatSession.Get(ctx, id)
  7022. }
  7023. })
  7024. return value, err
  7025. }
  7026. m.id = &id
  7027. }
  7028. }
  7029. // withChatSession sets the old ChatSession of the mutation.
  7030. func withChatSession(node *ChatSession) chatsessionOption {
  7031. return func(m *ChatSessionMutation) {
  7032. m.oldValue = func(context.Context) (*ChatSession, error) {
  7033. return node, nil
  7034. }
  7035. m.id = &node.ID
  7036. }
  7037. }
  7038. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7039. // executed in a transaction (ent.Tx), a transactional client is returned.
  7040. func (m ChatSessionMutation) Client() *Client {
  7041. client := &Client{config: m.config}
  7042. client.init()
  7043. return client
  7044. }
  7045. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7046. // it returns an error otherwise.
  7047. func (m ChatSessionMutation) Tx() (*Tx, error) {
  7048. if _, ok := m.driver.(*txDriver); !ok {
  7049. return nil, errors.New("ent: mutation is not running in a transaction")
  7050. }
  7051. tx := &Tx{config: m.config}
  7052. tx.init()
  7053. return tx, nil
  7054. }
  7055. // SetID sets the value of the id field. Note that this
  7056. // operation is only accepted on creation of ChatSession entities.
  7057. func (m *ChatSessionMutation) SetID(id uint64) {
  7058. m.id = &id
  7059. }
  7060. // ID returns the ID value in the mutation. Note that the ID is only available
  7061. // if it was provided to the builder or after it was returned from the database.
  7062. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  7063. if m.id == nil {
  7064. return
  7065. }
  7066. return *m.id, true
  7067. }
  7068. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7069. // That means, if the mutation is applied within a transaction with an isolation level such
  7070. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7071. // or updated by the mutation.
  7072. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  7073. switch {
  7074. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7075. id, exists := m.ID()
  7076. if exists {
  7077. return []uint64{id}, nil
  7078. }
  7079. fallthrough
  7080. case m.op.Is(OpUpdate | OpDelete):
  7081. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7082. default:
  7083. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7084. }
  7085. }
  7086. // SetCreatedAt sets the "created_at" field.
  7087. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7088. m.created_at = &t
  7089. }
  7090. // CreatedAt returns the value of the "created_at" field in the mutation.
  7091. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7092. v := m.created_at
  7093. if v == nil {
  7094. return
  7095. }
  7096. return *v, true
  7097. }
  7098. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7099. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7101. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7102. if !m.op.Is(OpUpdateOne) {
  7103. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7104. }
  7105. if m.id == nil || m.oldValue == nil {
  7106. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7107. }
  7108. oldValue, err := m.oldValue(ctx)
  7109. if err != nil {
  7110. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7111. }
  7112. return oldValue.CreatedAt, nil
  7113. }
  7114. // ResetCreatedAt resets all changes to the "created_at" field.
  7115. func (m *ChatSessionMutation) ResetCreatedAt() {
  7116. m.created_at = nil
  7117. }
  7118. // SetUpdatedAt sets the "updated_at" field.
  7119. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7120. m.updated_at = &t
  7121. }
  7122. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7123. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7124. v := m.updated_at
  7125. if v == nil {
  7126. return
  7127. }
  7128. return *v, true
  7129. }
  7130. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7131. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7133. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7134. if !m.op.Is(OpUpdateOne) {
  7135. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7136. }
  7137. if m.id == nil || m.oldValue == nil {
  7138. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7139. }
  7140. oldValue, err := m.oldValue(ctx)
  7141. if err != nil {
  7142. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7143. }
  7144. return oldValue.UpdatedAt, nil
  7145. }
  7146. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7147. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7148. m.updated_at = nil
  7149. }
  7150. // SetDeletedAt sets the "deleted_at" field.
  7151. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7152. m.deleted_at = &t
  7153. }
  7154. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7155. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7156. v := m.deleted_at
  7157. if v == nil {
  7158. return
  7159. }
  7160. return *v, true
  7161. }
  7162. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7163. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7165. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7166. if !m.op.Is(OpUpdateOne) {
  7167. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7168. }
  7169. if m.id == nil || m.oldValue == nil {
  7170. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7171. }
  7172. oldValue, err := m.oldValue(ctx)
  7173. if err != nil {
  7174. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7175. }
  7176. return oldValue.DeletedAt, nil
  7177. }
  7178. // ClearDeletedAt clears the value of the "deleted_at" field.
  7179. func (m *ChatSessionMutation) ClearDeletedAt() {
  7180. m.deleted_at = nil
  7181. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7182. }
  7183. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7184. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7185. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7186. return ok
  7187. }
  7188. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7189. func (m *ChatSessionMutation) ResetDeletedAt() {
  7190. m.deleted_at = nil
  7191. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7192. }
  7193. // SetName sets the "name" field.
  7194. func (m *ChatSessionMutation) SetName(s string) {
  7195. m.name = &s
  7196. }
  7197. // Name returns the value of the "name" field in the mutation.
  7198. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7199. v := m.name
  7200. if v == nil {
  7201. return
  7202. }
  7203. return *v, true
  7204. }
  7205. // OldName returns the old "name" field's value of the ChatSession entity.
  7206. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7208. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7209. if !m.op.Is(OpUpdateOne) {
  7210. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7211. }
  7212. if m.id == nil || m.oldValue == nil {
  7213. return v, errors.New("OldName requires an ID field in the mutation")
  7214. }
  7215. oldValue, err := m.oldValue(ctx)
  7216. if err != nil {
  7217. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7218. }
  7219. return oldValue.Name, nil
  7220. }
  7221. // ResetName resets all changes to the "name" field.
  7222. func (m *ChatSessionMutation) ResetName() {
  7223. m.name = nil
  7224. }
  7225. // SetUserID sets the "user_id" field.
  7226. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7227. m.user_id = &u
  7228. m.adduser_id = nil
  7229. }
  7230. // UserID returns the value of the "user_id" field in the mutation.
  7231. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7232. v := m.user_id
  7233. if v == nil {
  7234. return
  7235. }
  7236. return *v, true
  7237. }
  7238. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7239. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7241. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7242. if !m.op.Is(OpUpdateOne) {
  7243. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7244. }
  7245. if m.id == nil || m.oldValue == nil {
  7246. return v, errors.New("OldUserID requires an ID field in the mutation")
  7247. }
  7248. oldValue, err := m.oldValue(ctx)
  7249. if err != nil {
  7250. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7251. }
  7252. return oldValue.UserID, nil
  7253. }
  7254. // AddUserID adds u to the "user_id" field.
  7255. func (m *ChatSessionMutation) AddUserID(u int64) {
  7256. if m.adduser_id != nil {
  7257. *m.adduser_id += u
  7258. } else {
  7259. m.adduser_id = &u
  7260. }
  7261. }
  7262. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7263. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7264. v := m.adduser_id
  7265. if v == nil {
  7266. return
  7267. }
  7268. return *v, true
  7269. }
  7270. // ResetUserID resets all changes to the "user_id" field.
  7271. func (m *ChatSessionMutation) ResetUserID() {
  7272. m.user_id = nil
  7273. m.adduser_id = nil
  7274. }
  7275. // SetBotID sets the "bot_id" field.
  7276. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7277. m.bot_id = &u
  7278. m.addbot_id = nil
  7279. }
  7280. // BotID returns the value of the "bot_id" field in the mutation.
  7281. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7282. v := m.bot_id
  7283. if v == nil {
  7284. return
  7285. }
  7286. return *v, true
  7287. }
  7288. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7289. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7291. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7292. if !m.op.Is(OpUpdateOne) {
  7293. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7294. }
  7295. if m.id == nil || m.oldValue == nil {
  7296. return v, errors.New("OldBotID requires an ID field in the mutation")
  7297. }
  7298. oldValue, err := m.oldValue(ctx)
  7299. if err != nil {
  7300. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7301. }
  7302. return oldValue.BotID, nil
  7303. }
  7304. // AddBotID adds u to the "bot_id" field.
  7305. func (m *ChatSessionMutation) AddBotID(u int64) {
  7306. if m.addbot_id != nil {
  7307. *m.addbot_id += u
  7308. } else {
  7309. m.addbot_id = &u
  7310. }
  7311. }
  7312. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7313. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7314. v := m.addbot_id
  7315. if v == nil {
  7316. return
  7317. }
  7318. return *v, true
  7319. }
  7320. // ResetBotID resets all changes to the "bot_id" field.
  7321. func (m *ChatSessionMutation) ResetBotID() {
  7322. m.bot_id = nil
  7323. m.addbot_id = nil
  7324. }
  7325. // SetBotType sets the "bot_type" field.
  7326. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7327. m.bot_type = &u
  7328. m.addbot_type = nil
  7329. }
  7330. // BotType returns the value of the "bot_type" field in the mutation.
  7331. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7332. v := m.bot_type
  7333. if v == nil {
  7334. return
  7335. }
  7336. return *v, true
  7337. }
  7338. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7339. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7341. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7342. if !m.op.Is(OpUpdateOne) {
  7343. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7344. }
  7345. if m.id == nil || m.oldValue == nil {
  7346. return v, errors.New("OldBotType requires an ID field in the mutation")
  7347. }
  7348. oldValue, err := m.oldValue(ctx)
  7349. if err != nil {
  7350. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7351. }
  7352. return oldValue.BotType, nil
  7353. }
  7354. // AddBotType adds u to the "bot_type" field.
  7355. func (m *ChatSessionMutation) AddBotType(u int8) {
  7356. if m.addbot_type != nil {
  7357. *m.addbot_type += u
  7358. } else {
  7359. m.addbot_type = &u
  7360. }
  7361. }
  7362. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7363. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7364. v := m.addbot_type
  7365. if v == nil {
  7366. return
  7367. }
  7368. return *v, true
  7369. }
  7370. // ResetBotType resets all changes to the "bot_type" field.
  7371. func (m *ChatSessionMutation) ResetBotType() {
  7372. m.bot_type = nil
  7373. m.addbot_type = nil
  7374. }
  7375. // Where appends a list predicates to the ChatSessionMutation builder.
  7376. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7377. m.predicates = append(m.predicates, ps...)
  7378. }
  7379. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7380. // users can use type-assertion to append predicates that do not depend on any generated package.
  7381. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7382. p := make([]predicate.ChatSession, len(ps))
  7383. for i := range ps {
  7384. p[i] = ps[i]
  7385. }
  7386. m.Where(p...)
  7387. }
  7388. // Op returns the operation name.
  7389. func (m *ChatSessionMutation) Op() Op {
  7390. return m.op
  7391. }
  7392. // SetOp allows setting the mutation operation.
  7393. func (m *ChatSessionMutation) SetOp(op Op) {
  7394. m.op = op
  7395. }
  7396. // Type returns the node type of this mutation (ChatSession).
  7397. func (m *ChatSessionMutation) Type() string {
  7398. return m.typ
  7399. }
  7400. // Fields returns all fields that were changed during this mutation. Note that in
  7401. // order to get all numeric fields that were incremented/decremented, call
  7402. // AddedFields().
  7403. func (m *ChatSessionMutation) Fields() []string {
  7404. fields := make([]string, 0, 7)
  7405. if m.created_at != nil {
  7406. fields = append(fields, chatsession.FieldCreatedAt)
  7407. }
  7408. if m.updated_at != nil {
  7409. fields = append(fields, chatsession.FieldUpdatedAt)
  7410. }
  7411. if m.deleted_at != nil {
  7412. fields = append(fields, chatsession.FieldDeletedAt)
  7413. }
  7414. if m.name != nil {
  7415. fields = append(fields, chatsession.FieldName)
  7416. }
  7417. if m.user_id != nil {
  7418. fields = append(fields, chatsession.FieldUserID)
  7419. }
  7420. if m.bot_id != nil {
  7421. fields = append(fields, chatsession.FieldBotID)
  7422. }
  7423. if m.bot_type != nil {
  7424. fields = append(fields, chatsession.FieldBotType)
  7425. }
  7426. return fields
  7427. }
  7428. // Field returns the value of a field with the given name. The second boolean
  7429. // return value indicates that this field was not set, or was not defined in the
  7430. // schema.
  7431. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7432. switch name {
  7433. case chatsession.FieldCreatedAt:
  7434. return m.CreatedAt()
  7435. case chatsession.FieldUpdatedAt:
  7436. return m.UpdatedAt()
  7437. case chatsession.FieldDeletedAt:
  7438. return m.DeletedAt()
  7439. case chatsession.FieldName:
  7440. return m.Name()
  7441. case chatsession.FieldUserID:
  7442. return m.UserID()
  7443. case chatsession.FieldBotID:
  7444. return m.BotID()
  7445. case chatsession.FieldBotType:
  7446. return m.BotType()
  7447. }
  7448. return nil, false
  7449. }
  7450. // OldField returns the old value of the field from the database. An error is
  7451. // returned if the mutation operation is not UpdateOne, or the query to the
  7452. // database failed.
  7453. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7454. switch name {
  7455. case chatsession.FieldCreatedAt:
  7456. return m.OldCreatedAt(ctx)
  7457. case chatsession.FieldUpdatedAt:
  7458. return m.OldUpdatedAt(ctx)
  7459. case chatsession.FieldDeletedAt:
  7460. return m.OldDeletedAt(ctx)
  7461. case chatsession.FieldName:
  7462. return m.OldName(ctx)
  7463. case chatsession.FieldUserID:
  7464. return m.OldUserID(ctx)
  7465. case chatsession.FieldBotID:
  7466. return m.OldBotID(ctx)
  7467. case chatsession.FieldBotType:
  7468. return m.OldBotType(ctx)
  7469. }
  7470. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7471. }
  7472. // SetField sets the value of a field with the given name. It returns an error if
  7473. // the field is not defined in the schema, or if the type mismatched the field
  7474. // type.
  7475. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7476. switch name {
  7477. case chatsession.FieldCreatedAt:
  7478. v, ok := value.(time.Time)
  7479. if !ok {
  7480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7481. }
  7482. m.SetCreatedAt(v)
  7483. return nil
  7484. case chatsession.FieldUpdatedAt:
  7485. v, ok := value.(time.Time)
  7486. if !ok {
  7487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7488. }
  7489. m.SetUpdatedAt(v)
  7490. return nil
  7491. case chatsession.FieldDeletedAt:
  7492. v, ok := value.(time.Time)
  7493. if !ok {
  7494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7495. }
  7496. m.SetDeletedAt(v)
  7497. return nil
  7498. case chatsession.FieldName:
  7499. v, ok := value.(string)
  7500. if !ok {
  7501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7502. }
  7503. m.SetName(v)
  7504. return nil
  7505. case chatsession.FieldUserID:
  7506. v, ok := value.(uint64)
  7507. if !ok {
  7508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7509. }
  7510. m.SetUserID(v)
  7511. return nil
  7512. case chatsession.FieldBotID:
  7513. v, ok := value.(uint64)
  7514. if !ok {
  7515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7516. }
  7517. m.SetBotID(v)
  7518. return nil
  7519. case chatsession.FieldBotType:
  7520. v, ok := value.(uint8)
  7521. if !ok {
  7522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7523. }
  7524. m.SetBotType(v)
  7525. return nil
  7526. }
  7527. return fmt.Errorf("unknown ChatSession field %s", name)
  7528. }
  7529. // AddedFields returns all numeric fields that were incremented/decremented during
  7530. // this mutation.
  7531. func (m *ChatSessionMutation) AddedFields() []string {
  7532. var fields []string
  7533. if m.adduser_id != nil {
  7534. fields = append(fields, chatsession.FieldUserID)
  7535. }
  7536. if m.addbot_id != nil {
  7537. fields = append(fields, chatsession.FieldBotID)
  7538. }
  7539. if m.addbot_type != nil {
  7540. fields = append(fields, chatsession.FieldBotType)
  7541. }
  7542. return fields
  7543. }
  7544. // AddedField returns the numeric value that was incremented/decremented on a field
  7545. // with the given name. The second boolean return value indicates that this field
  7546. // was not set, or was not defined in the schema.
  7547. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7548. switch name {
  7549. case chatsession.FieldUserID:
  7550. return m.AddedUserID()
  7551. case chatsession.FieldBotID:
  7552. return m.AddedBotID()
  7553. case chatsession.FieldBotType:
  7554. return m.AddedBotType()
  7555. }
  7556. return nil, false
  7557. }
  7558. // AddField adds the value to the field with the given name. It returns an error if
  7559. // the field is not defined in the schema, or if the type mismatched the field
  7560. // type.
  7561. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7562. switch name {
  7563. case chatsession.FieldUserID:
  7564. v, ok := value.(int64)
  7565. if !ok {
  7566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7567. }
  7568. m.AddUserID(v)
  7569. return nil
  7570. case chatsession.FieldBotID:
  7571. v, ok := value.(int64)
  7572. if !ok {
  7573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7574. }
  7575. m.AddBotID(v)
  7576. return nil
  7577. case chatsession.FieldBotType:
  7578. v, ok := value.(int8)
  7579. if !ok {
  7580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7581. }
  7582. m.AddBotType(v)
  7583. return nil
  7584. }
  7585. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7586. }
  7587. // ClearedFields returns all nullable fields that were cleared during this
  7588. // mutation.
  7589. func (m *ChatSessionMutation) ClearedFields() []string {
  7590. var fields []string
  7591. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7592. fields = append(fields, chatsession.FieldDeletedAt)
  7593. }
  7594. return fields
  7595. }
  7596. // FieldCleared returns a boolean indicating if a field with the given name was
  7597. // cleared in this mutation.
  7598. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7599. _, ok := m.clearedFields[name]
  7600. return ok
  7601. }
  7602. // ClearField clears the value of the field with the given name. It returns an
  7603. // error if the field is not defined in the schema.
  7604. func (m *ChatSessionMutation) ClearField(name string) error {
  7605. switch name {
  7606. case chatsession.FieldDeletedAt:
  7607. m.ClearDeletedAt()
  7608. return nil
  7609. }
  7610. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7611. }
  7612. // ResetField resets all changes in the mutation for the field with the given name.
  7613. // It returns an error if the field is not defined in the schema.
  7614. func (m *ChatSessionMutation) ResetField(name string) error {
  7615. switch name {
  7616. case chatsession.FieldCreatedAt:
  7617. m.ResetCreatedAt()
  7618. return nil
  7619. case chatsession.FieldUpdatedAt:
  7620. m.ResetUpdatedAt()
  7621. return nil
  7622. case chatsession.FieldDeletedAt:
  7623. m.ResetDeletedAt()
  7624. return nil
  7625. case chatsession.FieldName:
  7626. m.ResetName()
  7627. return nil
  7628. case chatsession.FieldUserID:
  7629. m.ResetUserID()
  7630. return nil
  7631. case chatsession.FieldBotID:
  7632. m.ResetBotID()
  7633. return nil
  7634. case chatsession.FieldBotType:
  7635. m.ResetBotType()
  7636. return nil
  7637. }
  7638. return fmt.Errorf("unknown ChatSession field %s", name)
  7639. }
  7640. // AddedEdges returns all edge names that were set/added in this mutation.
  7641. func (m *ChatSessionMutation) AddedEdges() []string {
  7642. edges := make([]string, 0, 0)
  7643. return edges
  7644. }
  7645. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7646. // name in this mutation.
  7647. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7648. return nil
  7649. }
  7650. // RemovedEdges returns all edge names that were removed in this mutation.
  7651. func (m *ChatSessionMutation) RemovedEdges() []string {
  7652. edges := make([]string, 0, 0)
  7653. return edges
  7654. }
  7655. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7656. // the given name in this mutation.
  7657. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7658. return nil
  7659. }
  7660. // ClearedEdges returns all edge names that were cleared in this mutation.
  7661. func (m *ChatSessionMutation) ClearedEdges() []string {
  7662. edges := make([]string, 0, 0)
  7663. return edges
  7664. }
  7665. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7666. // was cleared in this mutation.
  7667. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7668. return false
  7669. }
  7670. // ClearEdge clears the value of the edge with the given name. It returns an error
  7671. // if that edge is not defined in the schema.
  7672. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7673. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7674. }
  7675. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7676. // It returns an error if the edge is not defined in the schema.
  7677. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7678. return fmt.Errorf("unknown ChatSession edge %s", name)
  7679. }
  7680. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7681. type ContactMutation struct {
  7682. config
  7683. op Op
  7684. typ string
  7685. id *uint64
  7686. created_at *time.Time
  7687. updated_at *time.Time
  7688. status *uint8
  7689. addstatus *int8
  7690. deleted_at *time.Time
  7691. wx_wxid *string
  7692. _type *int
  7693. add_type *int
  7694. wxid *string
  7695. account *string
  7696. nickname *string
  7697. markname *string
  7698. headimg *string
  7699. sex *int
  7700. addsex *int
  7701. starrole *string
  7702. dontseeit *int
  7703. adddontseeit *int
  7704. dontseeme *int
  7705. adddontseeme *int
  7706. lag *string
  7707. gid *string
  7708. gname *string
  7709. v3 *string
  7710. organization_id *uint64
  7711. addorganization_id *int64
  7712. clearedFields map[string]struct{}
  7713. contact_relationships map[uint64]struct{}
  7714. removedcontact_relationships map[uint64]struct{}
  7715. clearedcontact_relationships bool
  7716. contact_messages map[uint64]struct{}
  7717. removedcontact_messages map[uint64]struct{}
  7718. clearedcontact_messages bool
  7719. done bool
  7720. oldValue func(context.Context) (*Contact, error)
  7721. predicates []predicate.Contact
  7722. }
  7723. var _ ent.Mutation = (*ContactMutation)(nil)
  7724. // contactOption allows management of the mutation configuration using functional options.
  7725. type contactOption func(*ContactMutation)
  7726. // newContactMutation creates new mutation for the Contact entity.
  7727. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7728. m := &ContactMutation{
  7729. config: c,
  7730. op: op,
  7731. typ: TypeContact,
  7732. clearedFields: make(map[string]struct{}),
  7733. }
  7734. for _, opt := range opts {
  7735. opt(m)
  7736. }
  7737. return m
  7738. }
  7739. // withContactID sets the ID field of the mutation.
  7740. func withContactID(id uint64) contactOption {
  7741. return func(m *ContactMutation) {
  7742. var (
  7743. err error
  7744. once sync.Once
  7745. value *Contact
  7746. )
  7747. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7748. once.Do(func() {
  7749. if m.done {
  7750. err = errors.New("querying old values post mutation is not allowed")
  7751. } else {
  7752. value, err = m.Client().Contact.Get(ctx, id)
  7753. }
  7754. })
  7755. return value, err
  7756. }
  7757. m.id = &id
  7758. }
  7759. }
  7760. // withContact sets the old Contact of the mutation.
  7761. func withContact(node *Contact) contactOption {
  7762. return func(m *ContactMutation) {
  7763. m.oldValue = func(context.Context) (*Contact, error) {
  7764. return node, nil
  7765. }
  7766. m.id = &node.ID
  7767. }
  7768. }
  7769. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7770. // executed in a transaction (ent.Tx), a transactional client is returned.
  7771. func (m ContactMutation) Client() *Client {
  7772. client := &Client{config: m.config}
  7773. client.init()
  7774. return client
  7775. }
  7776. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7777. // it returns an error otherwise.
  7778. func (m ContactMutation) Tx() (*Tx, error) {
  7779. if _, ok := m.driver.(*txDriver); !ok {
  7780. return nil, errors.New("ent: mutation is not running in a transaction")
  7781. }
  7782. tx := &Tx{config: m.config}
  7783. tx.init()
  7784. return tx, nil
  7785. }
  7786. // SetID sets the value of the id field. Note that this
  7787. // operation is only accepted on creation of Contact entities.
  7788. func (m *ContactMutation) SetID(id uint64) {
  7789. m.id = &id
  7790. }
  7791. // ID returns the ID value in the mutation. Note that the ID is only available
  7792. // if it was provided to the builder or after it was returned from the database.
  7793. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7794. if m.id == nil {
  7795. return
  7796. }
  7797. return *m.id, true
  7798. }
  7799. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7800. // That means, if the mutation is applied within a transaction with an isolation level such
  7801. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7802. // or updated by the mutation.
  7803. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7804. switch {
  7805. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7806. id, exists := m.ID()
  7807. if exists {
  7808. return []uint64{id}, nil
  7809. }
  7810. fallthrough
  7811. case m.op.Is(OpUpdate | OpDelete):
  7812. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7813. default:
  7814. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7815. }
  7816. }
  7817. // SetCreatedAt sets the "created_at" field.
  7818. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7819. m.created_at = &t
  7820. }
  7821. // CreatedAt returns the value of the "created_at" field in the mutation.
  7822. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7823. v := m.created_at
  7824. if v == nil {
  7825. return
  7826. }
  7827. return *v, true
  7828. }
  7829. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7830. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7832. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7833. if !m.op.Is(OpUpdateOne) {
  7834. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7835. }
  7836. if m.id == nil || m.oldValue == nil {
  7837. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7838. }
  7839. oldValue, err := m.oldValue(ctx)
  7840. if err != nil {
  7841. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7842. }
  7843. return oldValue.CreatedAt, nil
  7844. }
  7845. // ResetCreatedAt resets all changes to the "created_at" field.
  7846. func (m *ContactMutation) ResetCreatedAt() {
  7847. m.created_at = nil
  7848. }
  7849. // SetUpdatedAt sets the "updated_at" field.
  7850. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7851. m.updated_at = &t
  7852. }
  7853. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7854. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7855. v := m.updated_at
  7856. if v == nil {
  7857. return
  7858. }
  7859. return *v, true
  7860. }
  7861. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7862. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7864. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7865. if !m.op.Is(OpUpdateOne) {
  7866. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7867. }
  7868. if m.id == nil || m.oldValue == nil {
  7869. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7870. }
  7871. oldValue, err := m.oldValue(ctx)
  7872. if err != nil {
  7873. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7874. }
  7875. return oldValue.UpdatedAt, nil
  7876. }
  7877. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7878. func (m *ContactMutation) ResetUpdatedAt() {
  7879. m.updated_at = nil
  7880. }
  7881. // SetStatus sets the "status" field.
  7882. func (m *ContactMutation) SetStatus(u uint8) {
  7883. m.status = &u
  7884. m.addstatus = nil
  7885. }
  7886. // Status returns the value of the "status" field in the mutation.
  7887. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7888. v := m.status
  7889. if v == nil {
  7890. return
  7891. }
  7892. return *v, true
  7893. }
  7894. // OldStatus returns the old "status" field's value of the Contact entity.
  7895. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7897. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7898. if !m.op.Is(OpUpdateOne) {
  7899. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7900. }
  7901. if m.id == nil || m.oldValue == nil {
  7902. return v, errors.New("OldStatus requires an ID field in the mutation")
  7903. }
  7904. oldValue, err := m.oldValue(ctx)
  7905. if err != nil {
  7906. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7907. }
  7908. return oldValue.Status, nil
  7909. }
  7910. // AddStatus adds u to the "status" field.
  7911. func (m *ContactMutation) AddStatus(u int8) {
  7912. if m.addstatus != nil {
  7913. *m.addstatus += u
  7914. } else {
  7915. m.addstatus = &u
  7916. }
  7917. }
  7918. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7919. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7920. v := m.addstatus
  7921. if v == nil {
  7922. return
  7923. }
  7924. return *v, true
  7925. }
  7926. // ClearStatus clears the value of the "status" field.
  7927. func (m *ContactMutation) ClearStatus() {
  7928. m.status = nil
  7929. m.addstatus = nil
  7930. m.clearedFields[contact.FieldStatus] = struct{}{}
  7931. }
  7932. // StatusCleared returns if the "status" field was cleared in this mutation.
  7933. func (m *ContactMutation) StatusCleared() bool {
  7934. _, ok := m.clearedFields[contact.FieldStatus]
  7935. return ok
  7936. }
  7937. // ResetStatus resets all changes to the "status" field.
  7938. func (m *ContactMutation) ResetStatus() {
  7939. m.status = nil
  7940. m.addstatus = nil
  7941. delete(m.clearedFields, contact.FieldStatus)
  7942. }
  7943. // SetDeletedAt sets the "deleted_at" field.
  7944. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7945. m.deleted_at = &t
  7946. }
  7947. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7948. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7949. v := m.deleted_at
  7950. if v == nil {
  7951. return
  7952. }
  7953. return *v, true
  7954. }
  7955. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7956. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7958. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7959. if !m.op.Is(OpUpdateOne) {
  7960. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7961. }
  7962. if m.id == nil || m.oldValue == nil {
  7963. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7964. }
  7965. oldValue, err := m.oldValue(ctx)
  7966. if err != nil {
  7967. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7968. }
  7969. return oldValue.DeletedAt, nil
  7970. }
  7971. // ClearDeletedAt clears the value of the "deleted_at" field.
  7972. func (m *ContactMutation) ClearDeletedAt() {
  7973. m.deleted_at = nil
  7974. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7975. }
  7976. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7977. func (m *ContactMutation) DeletedAtCleared() bool {
  7978. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7979. return ok
  7980. }
  7981. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7982. func (m *ContactMutation) ResetDeletedAt() {
  7983. m.deleted_at = nil
  7984. delete(m.clearedFields, contact.FieldDeletedAt)
  7985. }
  7986. // SetWxWxid sets the "wx_wxid" field.
  7987. func (m *ContactMutation) SetWxWxid(s string) {
  7988. m.wx_wxid = &s
  7989. }
  7990. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7991. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7992. v := m.wx_wxid
  7993. if v == nil {
  7994. return
  7995. }
  7996. return *v, true
  7997. }
  7998. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7999. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8001. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8002. if !m.op.Is(OpUpdateOne) {
  8003. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8004. }
  8005. if m.id == nil || m.oldValue == nil {
  8006. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8007. }
  8008. oldValue, err := m.oldValue(ctx)
  8009. if err != nil {
  8010. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8011. }
  8012. return oldValue.WxWxid, nil
  8013. }
  8014. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8015. func (m *ContactMutation) ResetWxWxid() {
  8016. m.wx_wxid = nil
  8017. }
  8018. // SetType sets the "type" field.
  8019. func (m *ContactMutation) SetType(i int) {
  8020. m._type = &i
  8021. m.add_type = nil
  8022. }
  8023. // GetType returns the value of the "type" field in the mutation.
  8024. func (m *ContactMutation) GetType() (r int, exists bool) {
  8025. v := m._type
  8026. if v == nil {
  8027. return
  8028. }
  8029. return *v, true
  8030. }
  8031. // OldType returns the old "type" field's value of the Contact entity.
  8032. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8034. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  8035. if !m.op.Is(OpUpdateOne) {
  8036. return v, errors.New("OldType is only allowed on UpdateOne operations")
  8037. }
  8038. if m.id == nil || m.oldValue == nil {
  8039. return v, errors.New("OldType requires an ID field in the mutation")
  8040. }
  8041. oldValue, err := m.oldValue(ctx)
  8042. if err != nil {
  8043. return v, fmt.Errorf("querying old value for OldType: %w", err)
  8044. }
  8045. return oldValue.Type, nil
  8046. }
  8047. // AddType adds i to the "type" field.
  8048. func (m *ContactMutation) AddType(i int) {
  8049. if m.add_type != nil {
  8050. *m.add_type += i
  8051. } else {
  8052. m.add_type = &i
  8053. }
  8054. }
  8055. // AddedType returns the value that was added to the "type" field in this mutation.
  8056. func (m *ContactMutation) AddedType() (r int, exists bool) {
  8057. v := m.add_type
  8058. if v == nil {
  8059. return
  8060. }
  8061. return *v, true
  8062. }
  8063. // ClearType clears the value of the "type" field.
  8064. func (m *ContactMutation) ClearType() {
  8065. m._type = nil
  8066. m.add_type = nil
  8067. m.clearedFields[contact.FieldType] = struct{}{}
  8068. }
  8069. // TypeCleared returns if the "type" field was cleared in this mutation.
  8070. func (m *ContactMutation) TypeCleared() bool {
  8071. _, ok := m.clearedFields[contact.FieldType]
  8072. return ok
  8073. }
  8074. // ResetType resets all changes to the "type" field.
  8075. func (m *ContactMutation) ResetType() {
  8076. m._type = nil
  8077. m.add_type = nil
  8078. delete(m.clearedFields, contact.FieldType)
  8079. }
  8080. // SetWxid sets the "wxid" field.
  8081. func (m *ContactMutation) SetWxid(s string) {
  8082. m.wxid = &s
  8083. }
  8084. // Wxid returns the value of the "wxid" field in the mutation.
  8085. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8086. v := m.wxid
  8087. if v == nil {
  8088. return
  8089. }
  8090. return *v, true
  8091. }
  8092. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8093. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8095. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8096. if !m.op.Is(OpUpdateOne) {
  8097. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8098. }
  8099. if m.id == nil || m.oldValue == nil {
  8100. return v, errors.New("OldWxid requires an ID field in the mutation")
  8101. }
  8102. oldValue, err := m.oldValue(ctx)
  8103. if err != nil {
  8104. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8105. }
  8106. return oldValue.Wxid, nil
  8107. }
  8108. // ResetWxid resets all changes to the "wxid" field.
  8109. func (m *ContactMutation) ResetWxid() {
  8110. m.wxid = nil
  8111. }
  8112. // SetAccount sets the "account" field.
  8113. func (m *ContactMutation) SetAccount(s string) {
  8114. m.account = &s
  8115. }
  8116. // Account returns the value of the "account" field in the mutation.
  8117. func (m *ContactMutation) Account() (r string, exists bool) {
  8118. v := m.account
  8119. if v == nil {
  8120. return
  8121. }
  8122. return *v, true
  8123. }
  8124. // OldAccount returns the old "account" field's value of the Contact entity.
  8125. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8127. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8128. if !m.op.Is(OpUpdateOne) {
  8129. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8130. }
  8131. if m.id == nil || m.oldValue == nil {
  8132. return v, errors.New("OldAccount requires an ID field in the mutation")
  8133. }
  8134. oldValue, err := m.oldValue(ctx)
  8135. if err != nil {
  8136. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8137. }
  8138. return oldValue.Account, nil
  8139. }
  8140. // ResetAccount resets all changes to the "account" field.
  8141. func (m *ContactMutation) ResetAccount() {
  8142. m.account = nil
  8143. }
  8144. // SetNickname sets the "nickname" field.
  8145. func (m *ContactMutation) SetNickname(s string) {
  8146. m.nickname = &s
  8147. }
  8148. // Nickname returns the value of the "nickname" field in the mutation.
  8149. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8150. v := m.nickname
  8151. if v == nil {
  8152. return
  8153. }
  8154. return *v, true
  8155. }
  8156. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8157. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8159. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8160. if !m.op.Is(OpUpdateOne) {
  8161. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8162. }
  8163. if m.id == nil || m.oldValue == nil {
  8164. return v, errors.New("OldNickname requires an ID field in the mutation")
  8165. }
  8166. oldValue, err := m.oldValue(ctx)
  8167. if err != nil {
  8168. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8169. }
  8170. return oldValue.Nickname, nil
  8171. }
  8172. // ResetNickname resets all changes to the "nickname" field.
  8173. func (m *ContactMutation) ResetNickname() {
  8174. m.nickname = nil
  8175. }
  8176. // SetMarkname sets the "markname" field.
  8177. func (m *ContactMutation) SetMarkname(s string) {
  8178. m.markname = &s
  8179. }
  8180. // Markname returns the value of the "markname" field in the mutation.
  8181. func (m *ContactMutation) Markname() (r string, exists bool) {
  8182. v := m.markname
  8183. if v == nil {
  8184. return
  8185. }
  8186. return *v, true
  8187. }
  8188. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8189. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8191. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8192. if !m.op.Is(OpUpdateOne) {
  8193. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8194. }
  8195. if m.id == nil || m.oldValue == nil {
  8196. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8197. }
  8198. oldValue, err := m.oldValue(ctx)
  8199. if err != nil {
  8200. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8201. }
  8202. return oldValue.Markname, nil
  8203. }
  8204. // ResetMarkname resets all changes to the "markname" field.
  8205. func (m *ContactMutation) ResetMarkname() {
  8206. m.markname = nil
  8207. }
  8208. // SetHeadimg sets the "headimg" field.
  8209. func (m *ContactMutation) SetHeadimg(s string) {
  8210. m.headimg = &s
  8211. }
  8212. // Headimg returns the value of the "headimg" field in the mutation.
  8213. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8214. v := m.headimg
  8215. if v == nil {
  8216. return
  8217. }
  8218. return *v, true
  8219. }
  8220. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8221. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8223. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8224. if !m.op.Is(OpUpdateOne) {
  8225. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8226. }
  8227. if m.id == nil || m.oldValue == nil {
  8228. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8229. }
  8230. oldValue, err := m.oldValue(ctx)
  8231. if err != nil {
  8232. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8233. }
  8234. return oldValue.Headimg, nil
  8235. }
  8236. // ResetHeadimg resets all changes to the "headimg" field.
  8237. func (m *ContactMutation) ResetHeadimg() {
  8238. m.headimg = nil
  8239. }
  8240. // SetSex sets the "sex" field.
  8241. func (m *ContactMutation) SetSex(i int) {
  8242. m.sex = &i
  8243. m.addsex = nil
  8244. }
  8245. // Sex returns the value of the "sex" field in the mutation.
  8246. func (m *ContactMutation) Sex() (r int, exists bool) {
  8247. v := m.sex
  8248. if v == nil {
  8249. return
  8250. }
  8251. return *v, true
  8252. }
  8253. // OldSex returns the old "sex" field's value of the Contact entity.
  8254. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8256. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8257. if !m.op.Is(OpUpdateOne) {
  8258. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8259. }
  8260. if m.id == nil || m.oldValue == nil {
  8261. return v, errors.New("OldSex requires an ID field in the mutation")
  8262. }
  8263. oldValue, err := m.oldValue(ctx)
  8264. if err != nil {
  8265. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8266. }
  8267. return oldValue.Sex, nil
  8268. }
  8269. // AddSex adds i to the "sex" field.
  8270. func (m *ContactMutation) AddSex(i int) {
  8271. if m.addsex != nil {
  8272. *m.addsex += i
  8273. } else {
  8274. m.addsex = &i
  8275. }
  8276. }
  8277. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8278. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8279. v := m.addsex
  8280. if v == nil {
  8281. return
  8282. }
  8283. return *v, true
  8284. }
  8285. // ResetSex resets all changes to the "sex" field.
  8286. func (m *ContactMutation) ResetSex() {
  8287. m.sex = nil
  8288. m.addsex = nil
  8289. }
  8290. // SetStarrole sets the "starrole" field.
  8291. func (m *ContactMutation) SetStarrole(s string) {
  8292. m.starrole = &s
  8293. }
  8294. // Starrole returns the value of the "starrole" field in the mutation.
  8295. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8296. v := m.starrole
  8297. if v == nil {
  8298. return
  8299. }
  8300. return *v, true
  8301. }
  8302. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8303. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8305. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8306. if !m.op.Is(OpUpdateOne) {
  8307. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8308. }
  8309. if m.id == nil || m.oldValue == nil {
  8310. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8311. }
  8312. oldValue, err := m.oldValue(ctx)
  8313. if err != nil {
  8314. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8315. }
  8316. return oldValue.Starrole, nil
  8317. }
  8318. // ResetStarrole resets all changes to the "starrole" field.
  8319. func (m *ContactMutation) ResetStarrole() {
  8320. m.starrole = nil
  8321. }
  8322. // SetDontseeit sets the "dontseeit" field.
  8323. func (m *ContactMutation) SetDontseeit(i int) {
  8324. m.dontseeit = &i
  8325. m.adddontseeit = nil
  8326. }
  8327. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8328. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8329. v := m.dontseeit
  8330. if v == nil {
  8331. return
  8332. }
  8333. return *v, true
  8334. }
  8335. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8336. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8338. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8339. if !m.op.Is(OpUpdateOne) {
  8340. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8341. }
  8342. if m.id == nil || m.oldValue == nil {
  8343. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8344. }
  8345. oldValue, err := m.oldValue(ctx)
  8346. if err != nil {
  8347. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8348. }
  8349. return oldValue.Dontseeit, nil
  8350. }
  8351. // AddDontseeit adds i to the "dontseeit" field.
  8352. func (m *ContactMutation) AddDontseeit(i int) {
  8353. if m.adddontseeit != nil {
  8354. *m.adddontseeit += i
  8355. } else {
  8356. m.adddontseeit = &i
  8357. }
  8358. }
  8359. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8360. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8361. v := m.adddontseeit
  8362. if v == nil {
  8363. return
  8364. }
  8365. return *v, true
  8366. }
  8367. // ResetDontseeit resets all changes to the "dontseeit" field.
  8368. func (m *ContactMutation) ResetDontseeit() {
  8369. m.dontseeit = nil
  8370. m.adddontseeit = nil
  8371. }
  8372. // SetDontseeme sets the "dontseeme" field.
  8373. func (m *ContactMutation) SetDontseeme(i int) {
  8374. m.dontseeme = &i
  8375. m.adddontseeme = nil
  8376. }
  8377. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8378. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8379. v := m.dontseeme
  8380. if v == nil {
  8381. return
  8382. }
  8383. return *v, true
  8384. }
  8385. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8386. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8388. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8389. if !m.op.Is(OpUpdateOne) {
  8390. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8391. }
  8392. if m.id == nil || m.oldValue == nil {
  8393. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8394. }
  8395. oldValue, err := m.oldValue(ctx)
  8396. if err != nil {
  8397. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8398. }
  8399. return oldValue.Dontseeme, nil
  8400. }
  8401. // AddDontseeme adds i to the "dontseeme" field.
  8402. func (m *ContactMutation) AddDontseeme(i int) {
  8403. if m.adddontseeme != nil {
  8404. *m.adddontseeme += i
  8405. } else {
  8406. m.adddontseeme = &i
  8407. }
  8408. }
  8409. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8410. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8411. v := m.adddontseeme
  8412. if v == nil {
  8413. return
  8414. }
  8415. return *v, true
  8416. }
  8417. // ResetDontseeme resets all changes to the "dontseeme" field.
  8418. func (m *ContactMutation) ResetDontseeme() {
  8419. m.dontseeme = nil
  8420. m.adddontseeme = nil
  8421. }
  8422. // SetLag sets the "lag" field.
  8423. func (m *ContactMutation) SetLag(s string) {
  8424. m.lag = &s
  8425. }
  8426. // Lag returns the value of the "lag" field in the mutation.
  8427. func (m *ContactMutation) Lag() (r string, exists bool) {
  8428. v := m.lag
  8429. if v == nil {
  8430. return
  8431. }
  8432. return *v, true
  8433. }
  8434. // OldLag returns the old "lag" field's value of the Contact entity.
  8435. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8437. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8438. if !m.op.Is(OpUpdateOne) {
  8439. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8440. }
  8441. if m.id == nil || m.oldValue == nil {
  8442. return v, errors.New("OldLag requires an ID field in the mutation")
  8443. }
  8444. oldValue, err := m.oldValue(ctx)
  8445. if err != nil {
  8446. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8447. }
  8448. return oldValue.Lag, nil
  8449. }
  8450. // ResetLag resets all changes to the "lag" field.
  8451. func (m *ContactMutation) ResetLag() {
  8452. m.lag = nil
  8453. }
  8454. // SetGid sets the "gid" field.
  8455. func (m *ContactMutation) SetGid(s string) {
  8456. m.gid = &s
  8457. }
  8458. // Gid returns the value of the "gid" field in the mutation.
  8459. func (m *ContactMutation) Gid() (r string, exists bool) {
  8460. v := m.gid
  8461. if v == nil {
  8462. return
  8463. }
  8464. return *v, true
  8465. }
  8466. // OldGid returns the old "gid" field's value of the Contact entity.
  8467. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8469. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8470. if !m.op.Is(OpUpdateOne) {
  8471. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8472. }
  8473. if m.id == nil || m.oldValue == nil {
  8474. return v, errors.New("OldGid requires an ID field in the mutation")
  8475. }
  8476. oldValue, err := m.oldValue(ctx)
  8477. if err != nil {
  8478. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8479. }
  8480. return oldValue.Gid, nil
  8481. }
  8482. // ResetGid resets all changes to the "gid" field.
  8483. func (m *ContactMutation) ResetGid() {
  8484. m.gid = nil
  8485. }
  8486. // SetGname sets the "gname" field.
  8487. func (m *ContactMutation) SetGname(s string) {
  8488. m.gname = &s
  8489. }
  8490. // Gname returns the value of the "gname" field in the mutation.
  8491. func (m *ContactMutation) Gname() (r string, exists bool) {
  8492. v := m.gname
  8493. if v == nil {
  8494. return
  8495. }
  8496. return *v, true
  8497. }
  8498. // OldGname returns the old "gname" field's value of the Contact entity.
  8499. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8501. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8502. if !m.op.Is(OpUpdateOne) {
  8503. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8504. }
  8505. if m.id == nil || m.oldValue == nil {
  8506. return v, errors.New("OldGname requires an ID field in the mutation")
  8507. }
  8508. oldValue, err := m.oldValue(ctx)
  8509. if err != nil {
  8510. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8511. }
  8512. return oldValue.Gname, nil
  8513. }
  8514. // ResetGname resets all changes to the "gname" field.
  8515. func (m *ContactMutation) ResetGname() {
  8516. m.gname = nil
  8517. }
  8518. // SetV3 sets the "v3" field.
  8519. func (m *ContactMutation) SetV3(s string) {
  8520. m.v3 = &s
  8521. }
  8522. // V3 returns the value of the "v3" field in the mutation.
  8523. func (m *ContactMutation) V3() (r string, exists bool) {
  8524. v := m.v3
  8525. if v == nil {
  8526. return
  8527. }
  8528. return *v, true
  8529. }
  8530. // OldV3 returns the old "v3" field's value of the Contact entity.
  8531. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8533. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8534. if !m.op.Is(OpUpdateOne) {
  8535. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8536. }
  8537. if m.id == nil || m.oldValue == nil {
  8538. return v, errors.New("OldV3 requires an ID field in the mutation")
  8539. }
  8540. oldValue, err := m.oldValue(ctx)
  8541. if err != nil {
  8542. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8543. }
  8544. return oldValue.V3, nil
  8545. }
  8546. // ResetV3 resets all changes to the "v3" field.
  8547. func (m *ContactMutation) ResetV3() {
  8548. m.v3 = nil
  8549. }
  8550. // SetOrganizationID sets the "organization_id" field.
  8551. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8552. m.organization_id = &u
  8553. m.addorganization_id = nil
  8554. }
  8555. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8556. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8557. v := m.organization_id
  8558. if v == nil {
  8559. return
  8560. }
  8561. return *v, true
  8562. }
  8563. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8564. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8566. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8567. if !m.op.Is(OpUpdateOne) {
  8568. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8569. }
  8570. if m.id == nil || m.oldValue == nil {
  8571. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8572. }
  8573. oldValue, err := m.oldValue(ctx)
  8574. if err != nil {
  8575. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8576. }
  8577. return oldValue.OrganizationID, nil
  8578. }
  8579. // AddOrganizationID adds u to the "organization_id" field.
  8580. func (m *ContactMutation) AddOrganizationID(u int64) {
  8581. if m.addorganization_id != nil {
  8582. *m.addorganization_id += u
  8583. } else {
  8584. m.addorganization_id = &u
  8585. }
  8586. }
  8587. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8588. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8589. v := m.addorganization_id
  8590. if v == nil {
  8591. return
  8592. }
  8593. return *v, true
  8594. }
  8595. // ClearOrganizationID clears the value of the "organization_id" field.
  8596. func (m *ContactMutation) ClearOrganizationID() {
  8597. m.organization_id = nil
  8598. m.addorganization_id = nil
  8599. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8600. }
  8601. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8602. func (m *ContactMutation) OrganizationIDCleared() bool {
  8603. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8604. return ok
  8605. }
  8606. // ResetOrganizationID resets all changes to the "organization_id" field.
  8607. func (m *ContactMutation) ResetOrganizationID() {
  8608. m.organization_id = nil
  8609. m.addorganization_id = nil
  8610. delete(m.clearedFields, contact.FieldOrganizationID)
  8611. }
  8612. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8613. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8614. if m.contact_relationships == nil {
  8615. m.contact_relationships = make(map[uint64]struct{})
  8616. }
  8617. for i := range ids {
  8618. m.contact_relationships[ids[i]] = struct{}{}
  8619. }
  8620. }
  8621. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8622. func (m *ContactMutation) ClearContactRelationships() {
  8623. m.clearedcontact_relationships = true
  8624. }
  8625. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8626. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8627. return m.clearedcontact_relationships
  8628. }
  8629. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8630. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8631. if m.removedcontact_relationships == nil {
  8632. m.removedcontact_relationships = make(map[uint64]struct{})
  8633. }
  8634. for i := range ids {
  8635. delete(m.contact_relationships, ids[i])
  8636. m.removedcontact_relationships[ids[i]] = struct{}{}
  8637. }
  8638. }
  8639. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8640. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8641. for id := range m.removedcontact_relationships {
  8642. ids = append(ids, id)
  8643. }
  8644. return
  8645. }
  8646. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8647. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8648. for id := range m.contact_relationships {
  8649. ids = append(ids, id)
  8650. }
  8651. return
  8652. }
  8653. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8654. func (m *ContactMutation) ResetContactRelationships() {
  8655. m.contact_relationships = nil
  8656. m.clearedcontact_relationships = false
  8657. m.removedcontact_relationships = nil
  8658. }
  8659. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8660. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8661. if m.contact_messages == nil {
  8662. m.contact_messages = make(map[uint64]struct{})
  8663. }
  8664. for i := range ids {
  8665. m.contact_messages[ids[i]] = struct{}{}
  8666. }
  8667. }
  8668. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8669. func (m *ContactMutation) ClearContactMessages() {
  8670. m.clearedcontact_messages = true
  8671. }
  8672. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8673. func (m *ContactMutation) ContactMessagesCleared() bool {
  8674. return m.clearedcontact_messages
  8675. }
  8676. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8677. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8678. if m.removedcontact_messages == nil {
  8679. m.removedcontact_messages = make(map[uint64]struct{})
  8680. }
  8681. for i := range ids {
  8682. delete(m.contact_messages, ids[i])
  8683. m.removedcontact_messages[ids[i]] = struct{}{}
  8684. }
  8685. }
  8686. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8687. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8688. for id := range m.removedcontact_messages {
  8689. ids = append(ids, id)
  8690. }
  8691. return
  8692. }
  8693. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8694. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8695. for id := range m.contact_messages {
  8696. ids = append(ids, id)
  8697. }
  8698. return
  8699. }
  8700. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8701. func (m *ContactMutation) ResetContactMessages() {
  8702. m.contact_messages = nil
  8703. m.clearedcontact_messages = false
  8704. m.removedcontact_messages = nil
  8705. }
  8706. // Where appends a list predicates to the ContactMutation builder.
  8707. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8708. m.predicates = append(m.predicates, ps...)
  8709. }
  8710. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8711. // users can use type-assertion to append predicates that do not depend on any generated package.
  8712. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8713. p := make([]predicate.Contact, len(ps))
  8714. for i := range ps {
  8715. p[i] = ps[i]
  8716. }
  8717. m.Where(p...)
  8718. }
  8719. // Op returns the operation name.
  8720. func (m *ContactMutation) Op() Op {
  8721. return m.op
  8722. }
  8723. // SetOp allows setting the mutation operation.
  8724. func (m *ContactMutation) SetOp(op Op) {
  8725. m.op = op
  8726. }
  8727. // Type returns the node type of this mutation (Contact).
  8728. func (m *ContactMutation) Type() string {
  8729. return m.typ
  8730. }
  8731. // Fields returns all fields that were changed during this mutation. Note that in
  8732. // order to get all numeric fields that were incremented/decremented, call
  8733. // AddedFields().
  8734. func (m *ContactMutation) Fields() []string {
  8735. fields := make([]string, 0, 20)
  8736. if m.created_at != nil {
  8737. fields = append(fields, contact.FieldCreatedAt)
  8738. }
  8739. if m.updated_at != nil {
  8740. fields = append(fields, contact.FieldUpdatedAt)
  8741. }
  8742. if m.status != nil {
  8743. fields = append(fields, contact.FieldStatus)
  8744. }
  8745. if m.deleted_at != nil {
  8746. fields = append(fields, contact.FieldDeletedAt)
  8747. }
  8748. if m.wx_wxid != nil {
  8749. fields = append(fields, contact.FieldWxWxid)
  8750. }
  8751. if m._type != nil {
  8752. fields = append(fields, contact.FieldType)
  8753. }
  8754. if m.wxid != nil {
  8755. fields = append(fields, contact.FieldWxid)
  8756. }
  8757. if m.account != nil {
  8758. fields = append(fields, contact.FieldAccount)
  8759. }
  8760. if m.nickname != nil {
  8761. fields = append(fields, contact.FieldNickname)
  8762. }
  8763. if m.markname != nil {
  8764. fields = append(fields, contact.FieldMarkname)
  8765. }
  8766. if m.headimg != nil {
  8767. fields = append(fields, contact.FieldHeadimg)
  8768. }
  8769. if m.sex != nil {
  8770. fields = append(fields, contact.FieldSex)
  8771. }
  8772. if m.starrole != nil {
  8773. fields = append(fields, contact.FieldStarrole)
  8774. }
  8775. if m.dontseeit != nil {
  8776. fields = append(fields, contact.FieldDontseeit)
  8777. }
  8778. if m.dontseeme != nil {
  8779. fields = append(fields, contact.FieldDontseeme)
  8780. }
  8781. if m.lag != nil {
  8782. fields = append(fields, contact.FieldLag)
  8783. }
  8784. if m.gid != nil {
  8785. fields = append(fields, contact.FieldGid)
  8786. }
  8787. if m.gname != nil {
  8788. fields = append(fields, contact.FieldGname)
  8789. }
  8790. if m.v3 != nil {
  8791. fields = append(fields, contact.FieldV3)
  8792. }
  8793. if m.organization_id != nil {
  8794. fields = append(fields, contact.FieldOrganizationID)
  8795. }
  8796. return fields
  8797. }
  8798. // Field returns the value of a field with the given name. The second boolean
  8799. // return value indicates that this field was not set, or was not defined in the
  8800. // schema.
  8801. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8802. switch name {
  8803. case contact.FieldCreatedAt:
  8804. return m.CreatedAt()
  8805. case contact.FieldUpdatedAt:
  8806. return m.UpdatedAt()
  8807. case contact.FieldStatus:
  8808. return m.Status()
  8809. case contact.FieldDeletedAt:
  8810. return m.DeletedAt()
  8811. case contact.FieldWxWxid:
  8812. return m.WxWxid()
  8813. case contact.FieldType:
  8814. return m.GetType()
  8815. case contact.FieldWxid:
  8816. return m.Wxid()
  8817. case contact.FieldAccount:
  8818. return m.Account()
  8819. case contact.FieldNickname:
  8820. return m.Nickname()
  8821. case contact.FieldMarkname:
  8822. return m.Markname()
  8823. case contact.FieldHeadimg:
  8824. return m.Headimg()
  8825. case contact.FieldSex:
  8826. return m.Sex()
  8827. case contact.FieldStarrole:
  8828. return m.Starrole()
  8829. case contact.FieldDontseeit:
  8830. return m.Dontseeit()
  8831. case contact.FieldDontseeme:
  8832. return m.Dontseeme()
  8833. case contact.FieldLag:
  8834. return m.Lag()
  8835. case contact.FieldGid:
  8836. return m.Gid()
  8837. case contact.FieldGname:
  8838. return m.Gname()
  8839. case contact.FieldV3:
  8840. return m.V3()
  8841. case contact.FieldOrganizationID:
  8842. return m.OrganizationID()
  8843. }
  8844. return nil, false
  8845. }
  8846. // OldField returns the old value of the field from the database. An error is
  8847. // returned if the mutation operation is not UpdateOne, or the query to the
  8848. // database failed.
  8849. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8850. switch name {
  8851. case contact.FieldCreatedAt:
  8852. return m.OldCreatedAt(ctx)
  8853. case contact.FieldUpdatedAt:
  8854. return m.OldUpdatedAt(ctx)
  8855. case contact.FieldStatus:
  8856. return m.OldStatus(ctx)
  8857. case contact.FieldDeletedAt:
  8858. return m.OldDeletedAt(ctx)
  8859. case contact.FieldWxWxid:
  8860. return m.OldWxWxid(ctx)
  8861. case contact.FieldType:
  8862. return m.OldType(ctx)
  8863. case contact.FieldWxid:
  8864. return m.OldWxid(ctx)
  8865. case contact.FieldAccount:
  8866. return m.OldAccount(ctx)
  8867. case contact.FieldNickname:
  8868. return m.OldNickname(ctx)
  8869. case contact.FieldMarkname:
  8870. return m.OldMarkname(ctx)
  8871. case contact.FieldHeadimg:
  8872. return m.OldHeadimg(ctx)
  8873. case contact.FieldSex:
  8874. return m.OldSex(ctx)
  8875. case contact.FieldStarrole:
  8876. return m.OldStarrole(ctx)
  8877. case contact.FieldDontseeit:
  8878. return m.OldDontseeit(ctx)
  8879. case contact.FieldDontseeme:
  8880. return m.OldDontseeme(ctx)
  8881. case contact.FieldLag:
  8882. return m.OldLag(ctx)
  8883. case contact.FieldGid:
  8884. return m.OldGid(ctx)
  8885. case contact.FieldGname:
  8886. return m.OldGname(ctx)
  8887. case contact.FieldV3:
  8888. return m.OldV3(ctx)
  8889. case contact.FieldOrganizationID:
  8890. return m.OldOrganizationID(ctx)
  8891. }
  8892. return nil, fmt.Errorf("unknown Contact field %s", name)
  8893. }
  8894. // SetField sets the value of a field with the given name. It returns an error if
  8895. // the field is not defined in the schema, or if the type mismatched the field
  8896. // type.
  8897. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8898. switch name {
  8899. case contact.FieldCreatedAt:
  8900. v, ok := value.(time.Time)
  8901. if !ok {
  8902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8903. }
  8904. m.SetCreatedAt(v)
  8905. return nil
  8906. case contact.FieldUpdatedAt:
  8907. v, ok := value.(time.Time)
  8908. if !ok {
  8909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8910. }
  8911. m.SetUpdatedAt(v)
  8912. return nil
  8913. case contact.FieldStatus:
  8914. v, ok := value.(uint8)
  8915. if !ok {
  8916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8917. }
  8918. m.SetStatus(v)
  8919. return nil
  8920. case contact.FieldDeletedAt:
  8921. v, ok := value.(time.Time)
  8922. if !ok {
  8923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8924. }
  8925. m.SetDeletedAt(v)
  8926. return nil
  8927. case contact.FieldWxWxid:
  8928. v, ok := value.(string)
  8929. if !ok {
  8930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8931. }
  8932. m.SetWxWxid(v)
  8933. return nil
  8934. case contact.FieldType:
  8935. v, ok := value.(int)
  8936. if !ok {
  8937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8938. }
  8939. m.SetType(v)
  8940. return nil
  8941. case contact.FieldWxid:
  8942. v, ok := value.(string)
  8943. if !ok {
  8944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8945. }
  8946. m.SetWxid(v)
  8947. return nil
  8948. case contact.FieldAccount:
  8949. v, ok := value.(string)
  8950. if !ok {
  8951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8952. }
  8953. m.SetAccount(v)
  8954. return nil
  8955. case contact.FieldNickname:
  8956. v, ok := value.(string)
  8957. if !ok {
  8958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8959. }
  8960. m.SetNickname(v)
  8961. return nil
  8962. case contact.FieldMarkname:
  8963. v, ok := value.(string)
  8964. if !ok {
  8965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8966. }
  8967. m.SetMarkname(v)
  8968. return nil
  8969. case contact.FieldHeadimg:
  8970. v, ok := value.(string)
  8971. if !ok {
  8972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8973. }
  8974. m.SetHeadimg(v)
  8975. return nil
  8976. case contact.FieldSex:
  8977. v, ok := value.(int)
  8978. if !ok {
  8979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8980. }
  8981. m.SetSex(v)
  8982. return nil
  8983. case contact.FieldStarrole:
  8984. v, ok := value.(string)
  8985. if !ok {
  8986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8987. }
  8988. m.SetStarrole(v)
  8989. return nil
  8990. case contact.FieldDontseeit:
  8991. v, ok := value.(int)
  8992. if !ok {
  8993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8994. }
  8995. m.SetDontseeit(v)
  8996. return nil
  8997. case contact.FieldDontseeme:
  8998. v, ok := value.(int)
  8999. if !ok {
  9000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9001. }
  9002. m.SetDontseeme(v)
  9003. return nil
  9004. case contact.FieldLag:
  9005. v, ok := value.(string)
  9006. if !ok {
  9007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9008. }
  9009. m.SetLag(v)
  9010. return nil
  9011. case contact.FieldGid:
  9012. v, ok := value.(string)
  9013. if !ok {
  9014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9015. }
  9016. m.SetGid(v)
  9017. return nil
  9018. case contact.FieldGname:
  9019. v, ok := value.(string)
  9020. if !ok {
  9021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9022. }
  9023. m.SetGname(v)
  9024. return nil
  9025. case contact.FieldV3:
  9026. v, ok := value.(string)
  9027. if !ok {
  9028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9029. }
  9030. m.SetV3(v)
  9031. return nil
  9032. case contact.FieldOrganizationID:
  9033. v, ok := value.(uint64)
  9034. if !ok {
  9035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9036. }
  9037. m.SetOrganizationID(v)
  9038. return nil
  9039. }
  9040. return fmt.Errorf("unknown Contact field %s", name)
  9041. }
  9042. // AddedFields returns all numeric fields that were incremented/decremented during
  9043. // this mutation.
  9044. func (m *ContactMutation) AddedFields() []string {
  9045. var fields []string
  9046. if m.addstatus != nil {
  9047. fields = append(fields, contact.FieldStatus)
  9048. }
  9049. if m.add_type != nil {
  9050. fields = append(fields, contact.FieldType)
  9051. }
  9052. if m.addsex != nil {
  9053. fields = append(fields, contact.FieldSex)
  9054. }
  9055. if m.adddontseeit != nil {
  9056. fields = append(fields, contact.FieldDontseeit)
  9057. }
  9058. if m.adddontseeme != nil {
  9059. fields = append(fields, contact.FieldDontseeme)
  9060. }
  9061. if m.addorganization_id != nil {
  9062. fields = append(fields, contact.FieldOrganizationID)
  9063. }
  9064. return fields
  9065. }
  9066. // AddedField returns the numeric value that was incremented/decremented on a field
  9067. // with the given name. The second boolean return value indicates that this field
  9068. // was not set, or was not defined in the schema.
  9069. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  9070. switch name {
  9071. case contact.FieldStatus:
  9072. return m.AddedStatus()
  9073. case contact.FieldType:
  9074. return m.AddedType()
  9075. case contact.FieldSex:
  9076. return m.AddedSex()
  9077. case contact.FieldDontseeit:
  9078. return m.AddedDontseeit()
  9079. case contact.FieldDontseeme:
  9080. return m.AddedDontseeme()
  9081. case contact.FieldOrganizationID:
  9082. return m.AddedOrganizationID()
  9083. }
  9084. return nil, false
  9085. }
  9086. // AddField adds the value to the field with the given name. It returns an error if
  9087. // the field is not defined in the schema, or if the type mismatched the field
  9088. // type.
  9089. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9090. switch name {
  9091. case contact.FieldStatus:
  9092. v, ok := value.(int8)
  9093. if !ok {
  9094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9095. }
  9096. m.AddStatus(v)
  9097. return nil
  9098. case contact.FieldType:
  9099. v, ok := value.(int)
  9100. if !ok {
  9101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9102. }
  9103. m.AddType(v)
  9104. return nil
  9105. case contact.FieldSex:
  9106. v, ok := value.(int)
  9107. if !ok {
  9108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9109. }
  9110. m.AddSex(v)
  9111. return nil
  9112. case contact.FieldDontseeit:
  9113. v, ok := value.(int)
  9114. if !ok {
  9115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9116. }
  9117. m.AddDontseeit(v)
  9118. return nil
  9119. case contact.FieldDontseeme:
  9120. v, ok := value.(int)
  9121. if !ok {
  9122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9123. }
  9124. m.AddDontseeme(v)
  9125. return nil
  9126. case contact.FieldOrganizationID:
  9127. v, ok := value.(int64)
  9128. if !ok {
  9129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9130. }
  9131. m.AddOrganizationID(v)
  9132. return nil
  9133. }
  9134. return fmt.Errorf("unknown Contact numeric field %s", name)
  9135. }
  9136. // ClearedFields returns all nullable fields that were cleared during this
  9137. // mutation.
  9138. func (m *ContactMutation) ClearedFields() []string {
  9139. var fields []string
  9140. if m.FieldCleared(contact.FieldStatus) {
  9141. fields = append(fields, contact.FieldStatus)
  9142. }
  9143. if m.FieldCleared(contact.FieldDeletedAt) {
  9144. fields = append(fields, contact.FieldDeletedAt)
  9145. }
  9146. if m.FieldCleared(contact.FieldType) {
  9147. fields = append(fields, contact.FieldType)
  9148. }
  9149. if m.FieldCleared(contact.FieldOrganizationID) {
  9150. fields = append(fields, contact.FieldOrganizationID)
  9151. }
  9152. return fields
  9153. }
  9154. // FieldCleared returns a boolean indicating if a field with the given name was
  9155. // cleared in this mutation.
  9156. func (m *ContactMutation) FieldCleared(name string) bool {
  9157. _, ok := m.clearedFields[name]
  9158. return ok
  9159. }
  9160. // ClearField clears the value of the field with the given name. It returns an
  9161. // error if the field is not defined in the schema.
  9162. func (m *ContactMutation) ClearField(name string) error {
  9163. switch name {
  9164. case contact.FieldStatus:
  9165. m.ClearStatus()
  9166. return nil
  9167. case contact.FieldDeletedAt:
  9168. m.ClearDeletedAt()
  9169. return nil
  9170. case contact.FieldType:
  9171. m.ClearType()
  9172. return nil
  9173. case contact.FieldOrganizationID:
  9174. m.ClearOrganizationID()
  9175. return nil
  9176. }
  9177. return fmt.Errorf("unknown Contact nullable field %s", name)
  9178. }
  9179. // ResetField resets all changes in the mutation for the field with the given name.
  9180. // It returns an error if the field is not defined in the schema.
  9181. func (m *ContactMutation) ResetField(name string) error {
  9182. switch name {
  9183. case contact.FieldCreatedAt:
  9184. m.ResetCreatedAt()
  9185. return nil
  9186. case contact.FieldUpdatedAt:
  9187. m.ResetUpdatedAt()
  9188. return nil
  9189. case contact.FieldStatus:
  9190. m.ResetStatus()
  9191. return nil
  9192. case contact.FieldDeletedAt:
  9193. m.ResetDeletedAt()
  9194. return nil
  9195. case contact.FieldWxWxid:
  9196. m.ResetWxWxid()
  9197. return nil
  9198. case contact.FieldType:
  9199. m.ResetType()
  9200. return nil
  9201. case contact.FieldWxid:
  9202. m.ResetWxid()
  9203. return nil
  9204. case contact.FieldAccount:
  9205. m.ResetAccount()
  9206. return nil
  9207. case contact.FieldNickname:
  9208. m.ResetNickname()
  9209. return nil
  9210. case contact.FieldMarkname:
  9211. m.ResetMarkname()
  9212. return nil
  9213. case contact.FieldHeadimg:
  9214. m.ResetHeadimg()
  9215. return nil
  9216. case contact.FieldSex:
  9217. m.ResetSex()
  9218. return nil
  9219. case contact.FieldStarrole:
  9220. m.ResetStarrole()
  9221. return nil
  9222. case contact.FieldDontseeit:
  9223. m.ResetDontseeit()
  9224. return nil
  9225. case contact.FieldDontseeme:
  9226. m.ResetDontseeme()
  9227. return nil
  9228. case contact.FieldLag:
  9229. m.ResetLag()
  9230. return nil
  9231. case contact.FieldGid:
  9232. m.ResetGid()
  9233. return nil
  9234. case contact.FieldGname:
  9235. m.ResetGname()
  9236. return nil
  9237. case contact.FieldV3:
  9238. m.ResetV3()
  9239. return nil
  9240. case contact.FieldOrganizationID:
  9241. m.ResetOrganizationID()
  9242. return nil
  9243. }
  9244. return fmt.Errorf("unknown Contact field %s", name)
  9245. }
  9246. // AddedEdges returns all edge names that were set/added in this mutation.
  9247. func (m *ContactMutation) AddedEdges() []string {
  9248. edges := make([]string, 0, 2)
  9249. if m.contact_relationships != nil {
  9250. edges = append(edges, contact.EdgeContactRelationships)
  9251. }
  9252. if m.contact_messages != nil {
  9253. edges = append(edges, contact.EdgeContactMessages)
  9254. }
  9255. return edges
  9256. }
  9257. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9258. // name in this mutation.
  9259. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9260. switch name {
  9261. case contact.EdgeContactRelationships:
  9262. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9263. for id := range m.contact_relationships {
  9264. ids = append(ids, id)
  9265. }
  9266. return ids
  9267. case contact.EdgeContactMessages:
  9268. ids := make([]ent.Value, 0, len(m.contact_messages))
  9269. for id := range m.contact_messages {
  9270. ids = append(ids, id)
  9271. }
  9272. return ids
  9273. }
  9274. return nil
  9275. }
  9276. // RemovedEdges returns all edge names that were removed in this mutation.
  9277. func (m *ContactMutation) RemovedEdges() []string {
  9278. edges := make([]string, 0, 2)
  9279. if m.removedcontact_relationships != nil {
  9280. edges = append(edges, contact.EdgeContactRelationships)
  9281. }
  9282. if m.removedcontact_messages != nil {
  9283. edges = append(edges, contact.EdgeContactMessages)
  9284. }
  9285. return edges
  9286. }
  9287. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9288. // the given name in this mutation.
  9289. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9290. switch name {
  9291. case contact.EdgeContactRelationships:
  9292. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9293. for id := range m.removedcontact_relationships {
  9294. ids = append(ids, id)
  9295. }
  9296. return ids
  9297. case contact.EdgeContactMessages:
  9298. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9299. for id := range m.removedcontact_messages {
  9300. ids = append(ids, id)
  9301. }
  9302. return ids
  9303. }
  9304. return nil
  9305. }
  9306. // ClearedEdges returns all edge names that were cleared in this mutation.
  9307. func (m *ContactMutation) ClearedEdges() []string {
  9308. edges := make([]string, 0, 2)
  9309. if m.clearedcontact_relationships {
  9310. edges = append(edges, contact.EdgeContactRelationships)
  9311. }
  9312. if m.clearedcontact_messages {
  9313. edges = append(edges, contact.EdgeContactMessages)
  9314. }
  9315. return edges
  9316. }
  9317. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9318. // was cleared in this mutation.
  9319. func (m *ContactMutation) EdgeCleared(name string) bool {
  9320. switch name {
  9321. case contact.EdgeContactRelationships:
  9322. return m.clearedcontact_relationships
  9323. case contact.EdgeContactMessages:
  9324. return m.clearedcontact_messages
  9325. }
  9326. return false
  9327. }
  9328. // ClearEdge clears the value of the edge with the given name. It returns an error
  9329. // if that edge is not defined in the schema.
  9330. func (m *ContactMutation) ClearEdge(name string) error {
  9331. switch name {
  9332. }
  9333. return fmt.Errorf("unknown Contact unique edge %s", name)
  9334. }
  9335. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9336. // It returns an error if the edge is not defined in the schema.
  9337. func (m *ContactMutation) ResetEdge(name string) error {
  9338. switch name {
  9339. case contact.EdgeContactRelationships:
  9340. m.ResetContactRelationships()
  9341. return nil
  9342. case contact.EdgeContactMessages:
  9343. m.ResetContactMessages()
  9344. return nil
  9345. }
  9346. return fmt.Errorf("unknown Contact edge %s", name)
  9347. }
  9348. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  9349. type CreditBalanceMutation struct {
  9350. config
  9351. op Op
  9352. typ string
  9353. id *uint64
  9354. created_at *time.Time
  9355. updated_at *time.Time
  9356. deleted_at *time.Time
  9357. user_id *string
  9358. balance *float32
  9359. addbalance *float32
  9360. status *int
  9361. addstatus *int
  9362. organization_id *uint64
  9363. addorganization_id *int64
  9364. clearedFields map[string]struct{}
  9365. done bool
  9366. oldValue func(context.Context) (*CreditBalance, error)
  9367. predicates []predicate.CreditBalance
  9368. }
  9369. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  9370. // creditbalanceOption allows management of the mutation configuration using functional options.
  9371. type creditbalanceOption func(*CreditBalanceMutation)
  9372. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  9373. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  9374. m := &CreditBalanceMutation{
  9375. config: c,
  9376. op: op,
  9377. typ: TypeCreditBalance,
  9378. clearedFields: make(map[string]struct{}),
  9379. }
  9380. for _, opt := range opts {
  9381. opt(m)
  9382. }
  9383. return m
  9384. }
  9385. // withCreditBalanceID sets the ID field of the mutation.
  9386. func withCreditBalanceID(id uint64) creditbalanceOption {
  9387. return func(m *CreditBalanceMutation) {
  9388. var (
  9389. err error
  9390. once sync.Once
  9391. value *CreditBalance
  9392. )
  9393. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  9394. once.Do(func() {
  9395. if m.done {
  9396. err = errors.New("querying old values post mutation is not allowed")
  9397. } else {
  9398. value, err = m.Client().CreditBalance.Get(ctx, id)
  9399. }
  9400. })
  9401. return value, err
  9402. }
  9403. m.id = &id
  9404. }
  9405. }
  9406. // withCreditBalance sets the old CreditBalance of the mutation.
  9407. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  9408. return func(m *CreditBalanceMutation) {
  9409. m.oldValue = func(context.Context) (*CreditBalance, error) {
  9410. return node, nil
  9411. }
  9412. m.id = &node.ID
  9413. }
  9414. }
  9415. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9416. // executed in a transaction (ent.Tx), a transactional client is returned.
  9417. func (m CreditBalanceMutation) Client() *Client {
  9418. client := &Client{config: m.config}
  9419. client.init()
  9420. return client
  9421. }
  9422. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9423. // it returns an error otherwise.
  9424. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  9425. if _, ok := m.driver.(*txDriver); !ok {
  9426. return nil, errors.New("ent: mutation is not running in a transaction")
  9427. }
  9428. tx := &Tx{config: m.config}
  9429. tx.init()
  9430. return tx, nil
  9431. }
  9432. // SetID sets the value of the id field. Note that this
  9433. // operation is only accepted on creation of CreditBalance entities.
  9434. func (m *CreditBalanceMutation) SetID(id uint64) {
  9435. m.id = &id
  9436. }
  9437. // ID returns the ID value in the mutation. Note that the ID is only available
  9438. // if it was provided to the builder or after it was returned from the database.
  9439. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  9440. if m.id == nil {
  9441. return
  9442. }
  9443. return *m.id, true
  9444. }
  9445. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9446. // That means, if the mutation is applied within a transaction with an isolation level such
  9447. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9448. // or updated by the mutation.
  9449. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  9450. switch {
  9451. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9452. id, exists := m.ID()
  9453. if exists {
  9454. return []uint64{id}, nil
  9455. }
  9456. fallthrough
  9457. case m.op.Is(OpUpdate | OpDelete):
  9458. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  9459. default:
  9460. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9461. }
  9462. }
  9463. // SetCreatedAt sets the "created_at" field.
  9464. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  9465. m.created_at = &t
  9466. }
  9467. // CreatedAt returns the value of the "created_at" field in the mutation.
  9468. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  9469. v := m.created_at
  9470. if v == nil {
  9471. return
  9472. }
  9473. return *v, true
  9474. }
  9475. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  9476. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9478. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9479. if !m.op.Is(OpUpdateOne) {
  9480. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9481. }
  9482. if m.id == nil || m.oldValue == nil {
  9483. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9484. }
  9485. oldValue, err := m.oldValue(ctx)
  9486. if err != nil {
  9487. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9488. }
  9489. return oldValue.CreatedAt, nil
  9490. }
  9491. // ResetCreatedAt resets all changes to the "created_at" field.
  9492. func (m *CreditBalanceMutation) ResetCreatedAt() {
  9493. m.created_at = nil
  9494. }
  9495. // SetUpdatedAt sets the "updated_at" field.
  9496. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  9497. m.updated_at = &t
  9498. }
  9499. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9500. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  9501. v := m.updated_at
  9502. if v == nil {
  9503. return
  9504. }
  9505. return *v, true
  9506. }
  9507. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  9508. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9510. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9511. if !m.op.Is(OpUpdateOne) {
  9512. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9513. }
  9514. if m.id == nil || m.oldValue == nil {
  9515. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9516. }
  9517. oldValue, err := m.oldValue(ctx)
  9518. if err != nil {
  9519. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9520. }
  9521. return oldValue.UpdatedAt, nil
  9522. }
  9523. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9524. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  9525. m.updated_at = nil
  9526. }
  9527. // SetDeletedAt sets the "deleted_at" field.
  9528. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  9529. m.deleted_at = &t
  9530. }
  9531. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9532. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  9533. v := m.deleted_at
  9534. if v == nil {
  9535. return
  9536. }
  9537. return *v, true
  9538. }
  9539. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  9540. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9542. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9543. if !m.op.Is(OpUpdateOne) {
  9544. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9545. }
  9546. if m.id == nil || m.oldValue == nil {
  9547. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9548. }
  9549. oldValue, err := m.oldValue(ctx)
  9550. if err != nil {
  9551. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9552. }
  9553. return oldValue.DeletedAt, nil
  9554. }
  9555. // ClearDeletedAt clears the value of the "deleted_at" field.
  9556. func (m *CreditBalanceMutation) ClearDeletedAt() {
  9557. m.deleted_at = nil
  9558. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  9559. }
  9560. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9561. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  9562. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  9563. return ok
  9564. }
  9565. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9566. func (m *CreditBalanceMutation) ResetDeletedAt() {
  9567. m.deleted_at = nil
  9568. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  9569. }
  9570. // SetUserID sets the "user_id" field.
  9571. func (m *CreditBalanceMutation) SetUserID(s string) {
  9572. m.user_id = &s
  9573. }
  9574. // UserID returns the value of the "user_id" field in the mutation.
  9575. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  9576. v := m.user_id
  9577. if v == nil {
  9578. return
  9579. }
  9580. return *v, true
  9581. }
  9582. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  9583. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9585. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  9586. if !m.op.Is(OpUpdateOne) {
  9587. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9588. }
  9589. if m.id == nil || m.oldValue == nil {
  9590. return v, errors.New("OldUserID requires an ID field in the mutation")
  9591. }
  9592. oldValue, err := m.oldValue(ctx)
  9593. if err != nil {
  9594. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9595. }
  9596. return oldValue.UserID, nil
  9597. }
  9598. // ClearUserID clears the value of the "user_id" field.
  9599. func (m *CreditBalanceMutation) ClearUserID() {
  9600. m.user_id = nil
  9601. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  9602. }
  9603. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  9604. func (m *CreditBalanceMutation) UserIDCleared() bool {
  9605. _, ok := m.clearedFields[creditbalance.FieldUserID]
  9606. return ok
  9607. }
  9608. // ResetUserID resets all changes to the "user_id" field.
  9609. func (m *CreditBalanceMutation) ResetUserID() {
  9610. m.user_id = nil
  9611. delete(m.clearedFields, creditbalance.FieldUserID)
  9612. }
  9613. // SetBalance sets the "balance" field.
  9614. func (m *CreditBalanceMutation) SetBalance(f float32) {
  9615. m.balance = &f
  9616. m.addbalance = nil
  9617. }
  9618. // Balance returns the value of the "balance" field in the mutation.
  9619. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  9620. v := m.balance
  9621. if v == nil {
  9622. return
  9623. }
  9624. return *v, true
  9625. }
  9626. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  9627. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9629. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  9630. if !m.op.Is(OpUpdateOne) {
  9631. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  9632. }
  9633. if m.id == nil || m.oldValue == nil {
  9634. return v, errors.New("OldBalance requires an ID field in the mutation")
  9635. }
  9636. oldValue, err := m.oldValue(ctx)
  9637. if err != nil {
  9638. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  9639. }
  9640. return oldValue.Balance, nil
  9641. }
  9642. // AddBalance adds f to the "balance" field.
  9643. func (m *CreditBalanceMutation) AddBalance(f float32) {
  9644. if m.addbalance != nil {
  9645. *m.addbalance += f
  9646. } else {
  9647. m.addbalance = &f
  9648. }
  9649. }
  9650. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  9651. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  9652. v := m.addbalance
  9653. if v == nil {
  9654. return
  9655. }
  9656. return *v, true
  9657. }
  9658. // ResetBalance resets all changes to the "balance" field.
  9659. func (m *CreditBalanceMutation) ResetBalance() {
  9660. m.balance = nil
  9661. m.addbalance = nil
  9662. }
  9663. // SetStatus sets the "status" field.
  9664. func (m *CreditBalanceMutation) SetStatus(i int) {
  9665. m.status = &i
  9666. m.addstatus = nil
  9667. }
  9668. // Status returns the value of the "status" field in the mutation.
  9669. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  9670. v := m.status
  9671. if v == nil {
  9672. return
  9673. }
  9674. return *v, true
  9675. }
  9676. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  9677. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9679. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  9680. if !m.op.Is(OpUpdateOne) {
  9681. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9682. }
  9683. if m.id == nil || m.oldValue == nil {
  9684. return v, errors.New("OldStatus requires an ID field in the mutation")
  9685. }
  9686. oldValue, err := m.oldValue(ctx)
  9687. if err != nil {
  9688. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9689. }
  9690. return oldValue.Status, nil
  9691. }
  9692. // AddStatus adds i to the "status" field.
  9693. func (m *CreditBalanceMutation) AddStatus(i int) {
  9694. if m.addstatus != nil {
  9695. *m.addstatus += i
  9696. } else {
  9697. m.addstatus = &i
  9698. }
  9699. }
  9700. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9701. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  9702. v := m.addstatus
  9703. if v == nil {
  9704. return
  9705. }
  9706. return *v, true
  9707. }
  9708. // ClearStatus clears the value of the "status" field.
  9709. func (m *CreditBalanceMutation) ClearStatus() {
  9710. m.status = nil
  9711. m.addstatus = nil
  9712. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  9713. }
  9714. // StatusCleared returns if the "status" field was cleared in this mutation.
  9715. func (m *CreditBalanceMutation) StatusCleared() bool {
  9716. _, ok := m.clearedFields[creditbalance.FieldStatus]
  9717. return ok
  9718. }
  9719. // ResetStatus resets all changes to the "status" field.
  9720. func (m *CreditBalanceMutation) ResetStatus() {
  9721. m.status = nil
  9722. m.addstatus = nil
  9723. delete(m.clearedFields, creditbalance.FieldStatus)
  9724. }
  9725. // SetOrganizationID sets the "organization_id" field.
  9726. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  9727. m.organization_id = &u
  9728. m.addorganization_id = nil
  9729. }
  9730. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9731. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  9732. v := m.organization_id
  9733. if v == nil {
  9734. return
  9735. }
  9736. return *v, true
  9737. }
  9738. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  9739. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9741. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9742. if !m.op.Is(OpUpdateOne) {
  9743. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9744. }
  9745. if m.id == nil || m.oldValue == nil {
  9746. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9747. }
  9748. oldValue, err := m.oldValue(ctx)
  9749. if err != nil {
  9750. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9751. }
  9752. return oldValue.OrganizationID, nil
  9753. }
  9754. // AddOrganizationID adds u to the "organization_id" field.
  9755. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  9756. if m.addorganization_id != nil {
  9757. *m.addorganization_id += u
  9758. } else {
  9759. m.addorganization_id = &u
  9760. }
  9761. }
  9762. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9763. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  9764. v := m.addorganization_id
  9765. if v == nil {
  9766. return
  9767. }
  9768. return *v, true
  9769. }
  9770. // ClearOrganizationID clears the value of the "organization_id" field.
  9771. func (m *CreditBalanceMutation) ClearOrganizationID() {
  9772. m.organization_id = nil
  9773. m.addorganization_id = nil
  9774. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  9775. }
  9776. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9777. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  9778. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  9779. return ok
  9780. }
  9781. // ResetOrganizationID resets all changes to the "organization_id" field.
  9782. func (m *CreditBalanceMutation) ResetOrganizationID() {
  9783. m.organization_id = nil
  9784. m.addorganization_id = nil
  9785. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  9786. }
  9787. // Where appends a list predicates to the CreditBalanceMutation builder.
  9788. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  9789. m.predicates = append(m.predicates, ps...)
  9790. }
  9791. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  9792. // users can use type-assertion to append predicates that do not depend on any generated package.
  9793. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  9794. p := make([]predicate.CreditBalance, len(ps))
  9795. for i := range ps {
  9796. p[i] = ps[i]
  9797. }
  9798. m.Where(p...)
  9799. }
  9800. // Op returns the operation name.
  9801. func (m *CreditBalanceMutation) Op() Op {
  9802. return m.op
  9803. }
  9804. // SetOp allows setting the mutation operation.
  9805. func (m *CreditBalanceMutation) SetOp(op Op) {
  9806. m.op = op
  9807. }
  9808. // Type returns the node type of this mutation (CreditBalance).
  9809. func (m *CreditBalanceMutation) Type() string {
  9810. return m.typ
  9811. }
  9812. // Fields returns all fields that were changed during this mutation. Note that in
  9813. // order to get all numeric fields that were incremented/decremented, call
  9814. // AddedFields().
  9815. func (m *CreditBalanceMutation) Fields() []string {
  9816. fields := make([]string, 0, 7)
  9817. if m.created_at != nil {
  9818. fields = append(fields, creditbalance.FieldCreatedAt)
  9819. }
  9820. if m.updated_at != nil {
  9821. fields = append(fields, creditbalance.FieldUpdatedAt)
  9822. }
  9823. if m.deleted_at != nil {
  9824. fields = append(fields, creditbalance.FieldDeletedAt)
  9825. }
  9826. if m.user_id != nil {
  9827. fields = append(fields, creditbalance.FieldUserID)
  9828. }
  9829. if m.balance != nil {
  9830. fields = append(fields, creditbalance.FieldBalance)
  9831. }
  9832. if m.status != nil {
  9833. fields = append(fields, creditbalance.FieldStatus)
  9834. }
  9835. if m.organization_id != nil {
  9836. fields = append(fields, creditbalance.FieldOrganizationID)
  9837. }
  9838. return fields
  9839. }
  9840. // Field returns the value of a field with the given name. The second boolean
  9841. // return value indicates that this field was not set, or was not defined in the
  9842. // schema.
  9843. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  9844. switch name {
  9845. case creditbalance.FieldCreatedAt:
  9846. return m.CreatedAt()
  9847. case creditbalance.FieldUpdatedAt:
  9848. return m.UpdatedAt()
  9849. case creditbalance.FieldDeletedAt:
  9850. return m.DeletedAt()
  9851. case creditbalance.FieldUserID:
  9852. return m.UserID()
  9853. case creditbalance.FieldBalance:
  9854. return m.Balance()
  9855. case creditbalance.FieldStatus:
  9856. return m.Status()
  9857. case creditbalance.FieldOrganizationID:
  9858. return m.OrganizationID()
  9859. }
  9860. return nil, false
  9861. }
  9862. // OldField returns the old value of the field from the database. An error is
  9863. // returned if the mutation operation is not UpdateOne, or the query to the
  9864. // database failed.
  9865. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9866. switch name {
  9867. case creditbalance.FieldCreatedAt:
  9868. return m.OldCreatedAt(ctx)
  9869. case creditbalance.FieldUpdatedAt:
  9870. return m.OldUpdatedAt(ctx)
  9871. case creditbalance.FieldDeletedAt:
  9872. return m.OldDeletedAt(ctx)
  9873. case creditbalance.FieldUserID:
  9874. return m.OldUserID(ctx)
  9875. case creditbalance.FieldBalance:
  9876. return m.OldBalance(ctx)
  9877. case creditbalance.FieldStatus:
  9878. return m.OldStatus(ctx)
  9879. case creditbalance.FieldOrganizationID:
  9880. return m.OldOrganizationID(ctx)
  9881. }
  9882. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  9883. }
  9884. // SetField sets the value of a field with the given name. It returns an error if
  9885. // the field is not defined in the schema, or if the type mismatched the field
  9886. // type.
  9887. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  9888. switch name {
  9889. case creditbalance.FieldCreatedAt:
  9890. v, ok := value.(time.Time)
  9891. if !ok {
  9892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9893. }
  9894. m.SetCreatedAt(v)
  9895. return nil
  9896. case creditbalance.FieldUpdatedAt:
  9897. v, ok := value.(time.Time)
  9898. if !ok {
  9899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9900. }
  9901. m.SetUpdatedAt(v)
  9902. return nil
  9903. case creditbalance.FieldDeletedAt:
  9904. v, ok := value.(time.Time)
  9905. if !ok {
  9906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9907. }
  9908. m.SetDeletedAt(v)
  9909. return nil
  9910. case creditbalance.FieldUserID:
  9911. v, ok := value.(string)
  9912. if !ok {
  9913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9914. }
  9915. m.SetUserID(v)
  9916. return nil
  9917. case creditbalance.FieldBalance:
  9918. v, ok := value.(float32)
  9919. if !ok {
  9920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9921. }
  9922. m.SetBalance(v)
  9923. return nil
  9924. case creditbalance.FieldStatus:
  9925. v, ok := value.(int)
  9926. if !ok {
  9927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9928. }
  9929. m.SetStatus(v)
  9930. return nil
  9931. case creditbalance.FieldOrganizationID:
  9932. v, ok := value.(uint64)
  9933. if !ok {
  9934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9935. }
  9936. m.SetOrganizationID(v)
  9937. return nil
  9938. }
  9939. return fmt.Errorf("unknown CreditBalance field %s", name)
  9940. }
  9941. // AddedFields returns all numeric fields that were incremented/decremented during
  9942. // this mutation.
  9943. func (m *CreditBalanceMutation) AddedFields() []string {
  9944. var fields []string
  9945. if m.addbalance != nil {
  9946. fields = append(fields, creditbalance.FieldBalance)
  9947. }
  9948. if m.addstatus != nil {
  9949. fields = append(fields, creditbalance.FieldStatus)
  9950. }
  9951. if m.addorganization_id != nil {
  9952. fields = append(fields, creditbalance.FieldOrganizationID)
  9953. }
  9954. return fields
  9955. }
  9956. // AddedField returns the numeric value that was incremented/decremented on a field
  9957. // with the given name. The second boolean return value indicates that this field
  9958. // was not set, or was not defined in the schema.
  9959. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  9960. switch name {
  9961. case creditbalance.FieldBalance:
  9962. return m.AddedBalance()
  9963. case creditbalance.FieldStatus:
  9964. return m.AddedStatus()
  9965. case creditbalance.FieldOrganizationID:
  9966. return m.AddedOrganizationID()
  9967. }
  9968. return nil, false
  9969. }
  9970. // AddField adds the value to the field with the given name. It returns an error if
  9971. // the field is not defined in the schema, or if the type mismatched the field
  9972. // type.
  9973. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  9974. switch name {
  9975. case creditbalance.FieldBalance:
  9976. v, ok := value.(float32)
  9977. if !ok {
  9978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9979. }
  9980. m.AddBalance(v)
  9981. return nil
  9982. case creditbalance.FieldStatus:
  9983. v, ok := value.(int)
  9984. if !ok {
  9985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9986. }
  9987. m.AddStatus(v)
  9988. return nil
  9989. case creditbalance.FieldOrganizationID:
  9990. v, ok := value.(int64)
  9991. if !ok {
  9992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9993. }
  9994. m.AddOrganizationID(v)
  9995. return nil
  9996. }
  9997. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  9998. }
  9999. // ClearedFields returns all nullable fields that were cleared during this
  10000. // mutation.
  10001. func (m *CreditBalanceMutation) ClearedFields() []string {
  10002. var fields []string
  10003. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  10004. fields = append(fields, creditbalance.FieldDeletedAt)
  10005. }
  10006. if m.FieldCleared(creditbalance.FieldUserID) {
  10007. fields = append(fields, creditbalance.FieldUserID)
  10008. }
  10009. if m.FieldCleared(creditbalance.FieldStatus) {
  10010. fields = append(fields, creditbalance.FieldStatus)
  10011. }
  10012. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  10013. fields = append(fields, creditbalance.FieldOrganizationID)
  10014. }
  10015. return fields
  10016. }
  10017. // FieldCleared returns a boolean indicating if a field with the given name was
  10018. // cleared in this mutation.
  10019. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  10020. _, ok := m.clearedFields[name]
  10021. return ok
  10022. }
  10023. // ClearField clears the value of the field with the given name. It returns an
  10024. // error if the field is not defined in the schema.
  10025. func (m *CreditBalanceMutation) ClearField(name string) error {
  10026. switch name {
  10027. case creditbalance.FieldDeletedAt:
  10028. m.ClearDeletedAt()
  10029. return nil
  10030. case creditbalance.FieldUserID:
  10031. m.ClearUserID()
  10032. return nil
  10033. case creditbalance.FieldStatus:
  10034. m.ClearStatus()
  10035. return nil
  10036. case creditbalance.FieldOrganizationID:
  10037. m.ClearOrganizationID()
  10038. return nil
  10039. }
  10040. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  10041. }
  10042. // ResetField resets all changes in the mutation for the field with the given name.
  10043. // It returns an error if the field is not defined in the schema.
  10044. func (m *CreditBalanceMutation) ResetField(name string) error {
  10045. switch name {
  10046. case creditbalance.FieldCreatedAt:
  10047. m.ResetCreatedAt()
  10048. return nil
  10049. case creditbalance.FieldUpdatedAt:
  10050. m.ResetUpdatedAt()
  10051. return nil
  10052. case creditbalance.FieldDeletedAt:
  10053. m.ResetDeletedAt()
  10054. return nil
  10055. case creditbalance.FieldUserID:
  10056. m.ResetUserID()
  10057. return nil
  10058. case creditbalance.FieldBalance:
  10059. m.ResetBalance()
  10060. return nil
  10061. case creditbalance.FieldStatus:
  10062. m.ResetStatus()
  10063. return nil
  10064. case creditbalance.FieldOrganizationID:
  10065. m.ResetOrganizationID()
  10066. return nil
  10067. }
  10068. return fmt.Errorf("unknown CreditBalance field %s", name)
  10069. }
  10070. // AddedEdges returns all edge names that were set/added in this mutation.
  10071. func (m *CreditBalanceMutation) AddedEdges() []string {
  10072. edges := make([]string, 0, 0)
  10073. return edges
  10074. }
  10075. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10076. // name in this mutation.
  10077. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  10078. return nil
  10079. }
  10080. // RemovedEdges returns all edge names that were removed in this mutation.
  10081. func (m *CreditBalanceMutation) RemovedEdges() []string {
  10082. edges := make([]string, 0, 0)
  10083. return edges
  10084. }
  10085. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10086. // the given name in this mutation.
  10087. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  10088. return nil
  10089. }
  10090. // ClearedEdges returns all edge names that were cleared in this mutation.
  10091. func (m *CreditBalanceMutation) ClearedEdges() []string {
  10092. edges := make([]string, 0, 0)
  10093. return edges
  10094. }
  10095. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10096. // was cleared in this mutation.
  10097. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  10098. return false
  10099. }
  10100. // ClearEdge clears the value of the edge with the given name. It returns an error
  10101. // if that edge is not defined in the schema.
  10102. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  10103. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  10104. }
  10105. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10106. // It returns an error if the edge is not defined in the schema.
  10107. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  10108. return fmt.Errorf("unknown CreditBalance edge %s", name)
  10109. }
  10110. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  10111. type CreditUsageMutation struct {
  10112. config
  10113. op Op
  10114. typ string
  10115. id *uint64
  10116. created_at *time.Time
  10117. updated_at *time.Time
  10118. deleted_at *time.Time
  10119. user_id *string
  10120. number *float32
  10121. addnumber *float32
  10122. status *int
  10123. addstatus *int
  10124. ntype *int
  10125. addntype *int
  10126. table *string
  10127. organization_id *uint64
  10128. addorganization_id *int64
  10129. nid *uint64
  10130. addnid *int64
  10131. reason *string
  10132. operator *string
  10133. clearedFields map[string]struct{}
  10134. done bool
  10135. oldValue func(context.Context) (*CreditUsage, error)
  10136. predicates []predicate.CreditUsage
  10137. }
  10138. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  10139. // creditusageOption allows management of the mutation configuration using functional options.
  10140. type creditusageOption func(*CreditUsageMutation)
  10141. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  10142. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  10143. m := &CreditUsageMutation{
  10144. config: c,
  10145. op: op,
  10146. typ: TypeCreditUsage,
  10147. clearedFields: make(map[string]struct{}),
  10148. }
  10149. for _, opt := range opts {
  10150. opt(m)
  10151. }
  10152. return m
  10153. }
  10154. // withCreditUsageID sets the ID field of the mutation.
  10155. func withCreditUsageID(id uint64) creditusageOption {
  10156. return func(m *CreditUsageMutation) {
  10157. var (
  10158. err error
  10159. once sync.Once
  10160. value *CreditUsage
  10161. )
  10162. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  10163. once.Do(func() {
  10164. if m.done {
  10165. err = errors.New("querying old values post mutation is not allowed")
  10166. } else {
  10167. value, err = m.Client().CreditUsage.Get(ctx, id)
  10168. }
  10169. })
  10170. return value, err
  10171. }
  10172. m.id = &id
  10173. }
  10174. }
  10175. // withCreditUsage sets the old CreditUsage of the mutation.
  10176. func withCreditUsage(node *CreditUsage) creditusageOption {
  10177. return func(m *CreditUsageMutation) {
  10178. m.oldValue = func(context.Context) (*CreditUsage, error) {
  10179. return node, nil
  10180. }
  10181. m.id = &node.ID
  10182. }
  10183. }
  10184. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10185. // executed in a transaction (ent.Tx), a transactional client is returned.
  10186. func (m CreditUsageMutation) Client() *Client {
  10187. client := &Client{config: m.config}
  10188. client.init()
  10189. return client
  10190. }
  10191. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10192. // it returns an error otherwise.
  10193. func (m CreditUsageMutation) Tx() (*Tx, error) {
  10194. if _, ok := m.driver.(*txDriver); !ok {
  10195. return nil, errors.New("ent: mutation is not running in a transaction")
  10196. }
  10197. tx := &Tx{config: m.config}
  10198. tx.init()
  10199. return tx, nil
  10200. }
  10201. // SetID sets the value of the id field. Note that this
  10202. // operation is only accepted on creation of CreditUsage entities.
  10203. func (m *CreditUsageMutation) SetID(id uint64) {
  10204. m.id = &id
  10205. }
  10206. // ID returns the ID value in the mutation. Note that the ID is only available
  10207. // if it was provided to the builder or after it was returned from the database.
  10208. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  10209. if m.id == nil {
  10210. return
  10211. }
  10212. return *m.id, true
  10213. }
  10214. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10215. // That means, if the mutation is applied within a transaction with an isolation level such
  10216. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10217. // or updated by the mutation.
  10218. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10219. switch {
  10220. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10221. id, exists := m.ID()
  10222. if exists {
  10223. return []uint64{id}, nil
  10224. }
  10225. fallthrough
  10226. case m.op.Is(OpUpdate | OpDelete):
  10227. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  10228. default:
  10229. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10230. }
  10231. }
  10232. // SetCreatedAt sets the "created_at" field.
  10233. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  10234. m.created_at = &t
  10235. }
  10236. // CreatedAt returns the value of the "created_at" field in the mutation.
  10237. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  10238. v := m.created_at
  10239. if v == nil {
  10240. return
  10241. }
  10242. return *v, true
  10243. }
  10244. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  10245. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10247. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10248. if !m.op.Is(OpUpdateOne) {
  10249. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10250. }
  10251. if m.id == nil || m.oldValue == nil {
  10252. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10253. }
  10254. oldValue, err := m.oldValue(ctx)
  10255. if err != nil {
  10256. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10257. }
  10258. return oldValue.CreatedAt, nil
  10259. }
  10260. // ResetCreatedAt resets all changes to the "created_at" field.
  10261. func (m *CreditUsageMutation) ResetCreatedAt() {
  10262. m.created_at = nil
  10263. }
  10264. // SetUpdatedAt sets the "updated_at" field.
  10265. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  10266. m.updated_at = &t
  10267. }
  10268. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10269. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  10270. v := m.updated_at
  10271. if v == nil {
  10272. return
  10273. }
  10274. return *v, true
  10275. }
  10276. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  10277. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10279. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10280. if !m.op.Is(OpUpdateOne) {
  10281. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10282. }
  10283. if m.id == nil || m.oldValue == nil {
  10284. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10285. }
  10286. oldValue, err := m.oldValue(ctx)
  10287. if err != nil {
  10288. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10289. }
  10290. return oldValue.UpdatedAt, nil
  10291. }
  10292. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10293. func (m *CreditUsageMutation) ResetUpdatedAt() {
  10294. m.updated_at = nil
  10295. }
  10296. // SetDeletedAt sets the "deleted_at" field.
  10297. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  10298. m.deleted_at = &t
  10299. }
  10300. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10301. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  10302. v := m.deleted_at
  10303. if v == nil {
  10304. return
  10305. }
  10306. return *v, true
  10307. }
  10308. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  10309. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10311. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10312. if !m.op.Is(OpUpdateOne) {
  10313. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10314. }
  10315. if m.id == nil || m.oldValue == nil {
  10316. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10317. }
  10318. oldValue, err := m.oldValue(ctx)
  10319. if err != nil {
  10320. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10321. }
  10322. return oldValue.DeletedAt, nil
  10323. }
  10324. // ClearDeletedAt clears the value of the "deleted_at" field.
  10325. func (m *CreditUsageMutation) ClearDeletedAt() {
  10326. m.deleted_at = nil
  10327. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  10328. }
  10329. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10330. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  10331. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  10332. return ok
  10333. }
  10334. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10335. func (m *CreditUsageMutation) ResetDeletedAt() {
  10336. m.deleted_at = nil
  10337. delete(m.clearedFields, creditusage.FieldDeletedAt)
  10338. }
  10339. // SetUserID sets the "user_id" field.
  10340. func (m *CreditUsageMutation) SetUserID(s string) {
  10341. m.user_id = &s
  10342. }
  10343. // UserID returns the value of the "user_id" field in the mutation.
  10344. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  10345. v := m.user_id
  10346. if v == nil {
  10347. return
  10348. }
  10349. return *v, true
  10350. }
  10351. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  10352. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10354. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  10355. if !m.op.Is(OpUpdateOne) {
  10356. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10357. }
  10358. if m.id == nil || m.oldValue == nil {
  10359. return v, errors.New("OldUserID requires an ID field in the mutation")
  10360. }
  10361. oldValue, err := m.oldValue(ctx)
  10362. if err != nil {
  10363. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10364. }
  10365. return oldValue.UserID, nil
  10366. }
  10367. // ResetUserID resets all changes to the "user_id" field.
  10368. func (m *CreditUsageMutation) ResetUserID() {
  10369. m.user_id = nil
  10370. }
  10371. // SetNumber sets the "number" field.
  10372. func (m *CreditUsageMutation) SetNumber(f float32) {
  10373. m.number = &f
  10374. m.addnumber = nil
  10375. }
  10376. // Number returns the value of the "number" field in the mutation.
  10377. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  10378. v := m.number
  10379. if v == nil {
  10380. return
  10381. }
  10382. return *v, true
  10383. }
  10384. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  10385. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10387. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  10388. if !m.op.Is(OpUpdateOne) {
  10389. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  10390. }
  10391. if m.id == nil || m.oldValue == nil {
  10392. return v, errors.New("OldNumber requires an ID field in the mutation")
  10393. }
  10394. oldValue, err := m.oldValue(ctx)
  10395. if err != nil {
  10396. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  10397. }
  10398. return oldValue.Number, nil
  10399. }
  10400. // AddNumber adds f to the "number" field.
  10401. func (m *CreditUsageMutation) AddNumber(f float32) {
  10402. if m.addnumber != nil {
  10403. *m.addnumber += f
  10404. } else {
  10405. m.addnumber = &f
  10406. }
  10407. }
  10408. // AddedNumber returns the value that was added to the "number" field in this mutation.
  10409. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  10410. v := m.addnumber
  10411. if v == nil {
  10412. return
  10413. }
  10414. return *v, true
  10415. }
  10416. // ResetNumber resets all changes to the "number" field.
  10417. func (m *CreditUsageMutation) ResetNumber() {
  10418. m.number = nil
  10419. m.addnumber = nil
  10420. }
  10421. // SetStatus sets the "status" field.
  10422. func (m *CreditUsageMutation) SetStatus(i int) {
  10423. m.status = &i
  10424. m.addstatus = nil
  10425. }
  10426. // Status returns the value of the "status" field in the mutation.
  10427. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  10428. v := m.status
  10429. if v == nil {
  10430. return
  10431. }
  10432. return *v, true
  10433. }
  10434. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  10435. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10437. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  10438. if !m.op.Is(OpUpdateOne) {
  10439. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10440. }
  10441. if m.id == nil || m.oldValue == nil {
  10442. return v, errors.New("OldStatus requires an ID field in the mutation")
  10443. }
  10444. oldValue, err := m.oldValue(ctx)
  10445. if err != nil {
  10446. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10447. }
  10448. return oldValue.Status, nil
  10449. }
  10450. // AddStatus adds i to the "status" field.
  10451. func (m *CreditUsageMutation) AddStatus(i int) {
  10452. if m.addstatus != nil {
  10453. *m.addstatus += i
  10454. } else {
  10455. m.addstatus = &i
  10456. }
  10457. }
  10458. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10459. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  10460. v := m.addstatus
  10461. if v == nil {
  10462. return
  10463. }
  10464. return *v, true
  10465. }
  10466. // ClearStatus clears the value of the "status" field.
  10467. func (m *CreditUsageMutation) ClearStatus() {
  10468. m.status = nil
  10469. m.addstatus = nil
  10470. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  10471. }
  10472. // StatusCleared returns if the "status" field was cleared in this mutation.
  10473. func (m *CreditUsageMutation) StatusCleared() bool {
  10474. _, ok := m.clearedFields[creditusage.FieldStatus]
  10475. return ok
  10476. }
  10477. // ResetStatus resets all changes to the "status" field.
  10478. func (m *CreditUsageMutation) ResetStatus() {
  10479. m.status = nil
  10480. m.addstatus = nil
  10481. delete(m.clearedFields, creditusage.FieldStatus)
  10482. }
  10483. // SetNtype sets the "ntype" field.
  10484. func (m *CreditUsageMutation) SetNtype(i int) {
  10485. m.ntype = &i
  10486. m.addntype = nil
  10487. }
  10488. // Ntype returns the value of the "ntype" field in the mutation.
  10489. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  10490. v := m.ntype
  10491. if v == nil {
  10492. return
  10493. }
  10494. return *v, true
  10495. }
  10496. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  10497. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10499. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  10500. if !m.op.Is(OpUpdateOne) {
  10501. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  10502. }
  10503. if m.id == nil || m.oldValue == nil {
  10504. return v, errors.New("OldNtype requires an ID field in the mutation")
  10505. }
  10506. oldValue, err := m.oldValue(ctx)
  10507. if err != nil {
  10508. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  10509. }
  10510. return oldValue.Ntype, nil
  10511. }
  10512. // AddNtype adds i to the "ntype" field.
  10513. func (m *CreditUsageMutation) AddNtype(i int) {
  10514. if m.addntype != nil {
  10515. *m.addntype += i
  10516. } else {
  10517. m.addntype = &i
  10518. }
  10519. }
  10520. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  10521. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  10522. v := m.addntype
  10523. if v == nil {
  10524. return
  10525. }
  10526. return *v, true
  10527. }
  10528. // ResetNtype resets all changes to the "ntype" field.
  10529. func (m *CreditUsageMutation) ResetNtype() {
  10530. m.ntype = nil
  10531. m.addntype = nil
  10532. }
  10533. // SetTable sets the "table" field.
  10534. func (m *CreditUsageMutation) SetTable(s string) {
  10535. m.table = &s
  10536. }
  10537. // Table returns the value of the "table" field in the mutation.
  10538. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  10539. v := m.table
  10540. if v == nil {
  10541. return
  10542. }
  10543. return *v, true
  10544. }
  10545. // OldTable returns the old "table" field's value of the CreditUsage entity.
  10546. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10548. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  10549. if !m.op.Is(OpUpdateOne) {
  10550. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  10551. }
  10552. if m.id == nil || m.oldValue == nil {
  10553. return v, errors.New("OldTable requires an ID field in the mutation")
  10554. }
  10555. oldValue, err := m.oldValue(ctx)
  10556. if err != nil {
  10557. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  10558. }
  10559. return oldValue.Table, nil
  10560. }
  10561. // ResetTable resets all changes to the "table" field.
  10562. func (m *CreditUsageMutation) ResetTable() {
  10563. m.table = nil
  10564. }
  10565. // SetOrganizationID sets the "organization_id" field.
  10566. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  10567. m.organization_id = &u
  10568. m.addorganization_id = nil
  10569. }
  10570. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10571. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  10572. v := m.organization_id
  10573. if v == nil {
  10574. return
  10575. }
  10576. return *v, true
  10577. }
  10578. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  10579. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10581. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10582. if !m.op.Is(OpUpdateOne) {
  10583. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10584. }
  10585. if m.id == nil || m.oldValue == nil {
  10586. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10587. }
  10588. oldValue, err := m.oldValue(ctx)
  10589. if err != nil {
  10590. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10591. }
  10592. return oldValue.OrganizationID, nil
  10593. }
  10594. // AddOrganizationID adds u to the "organization_id" field.
  10595. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  10596. if m.addorganization_id != nil {
  10597. *m.addorganization_id += u
  10598. } else {
  10599. m.addorganization_id = &u
  10600. }
  10601. }
  10602. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10603. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  10604. v := m.addorganization_id
  10605. if v == nil {
  10606. return
  10607. }
  10608. return *v, true
  10609. }
  10610. // ClearOrganizationID clears the value of the "organization_id" field.
  10611. func (m *CreditUsageMutation) ClearOrganizationID() {
  10612. m.organization_id = nil
  10613. m.addorganization_id = nil
  10614. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  10615. }
  10616. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10617. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  10618. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  10619. return ok
  10620. }
  10621. // ResetOrganizationID resets all changes to the "organization_id" field.
  10622. func (m *CreditUsageMutation) ResetOrganizationID() {
  10623. m.organization_id = nil
  10624. m.addorganization_id = nil
  10625. delete(m.clearedFields, creditusage.FieldOrganizationID)
  10626. }
  10627. // SetNid sets the "nid" field.
  10628. func (m *CreditUsageMutation) SetNid(u uint64) {
  10629. m.nid = &u
  10630. m.addnid = nil
  10631. }
  10632. // Nid returns the value of the "nid" field in the mutation.
  10633. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  10634. v := m.nid
  10635. if v == nil {
  10636. return
  10637. }
  10638. return *v, true
  10639. }
  10640. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  10641. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10643. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  10644. if !m.op.Is(OpUpdateOne) {
  10645. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  10646. }
  10647. if m.id == nil || m.oldValue == nil {
  10648. return v, errors.New("OldNid requires an ID field in the mutation")
  10649. }
  10650. oldValue, err := m.oldValue(ctx)
  10651. if err != nil {
  10652. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  10653. }
  10654. return oldValue.Nid, nil
  10655. }
  10656. // AddNid adds u to the "nid" field.
  10657. func (m *CreditUsageMutation) AddNid(u int64) {
  10658. if m.addnid != nil {
  10659. *m.addnid += u
  10660. } else {
  10661. m.addnid = &u
  10662. }
  10663. }
  10664. // AddedNid returns the value that was added to the "nid" field in this mutation.
  10665. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  10666. v := m.addnid
  10667. if v == nil {
  10668. return
  10669. }
  10670. return *v, true
  10671. }
  10672. // ResetNid resets all changes to the "nid" field.
  10673. func (m *CreditUsageMutation) ResetNid() {
  10674. m.nid = nil
  10675. m.addnid = nil
  10676. }
  10677. // SetReason sets the "reason" field.
  10678. func (m *CreditUsageMutation) SetReason(s string) {
  10679. m.reason = &s
  10680. }
  10681. // Reason returns the value of the "reason" field in the mutation.
  10682. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  10683. v := m.reason
  10684. if v == nil {
  10685. return
  10686. }
  10687. return *v, true
  10688. }
  10689. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  10690. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10692. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  10693. if !m.op.Is(OpUpdateOne) {
  10694. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  10695. }
  10696. if m.id == nil || m.oldValue == nil {
  10697. return v, errors.New("OldReason requires an ID field in the mutation")
  10698. }
  10699. oldValue, err := m.oldValue(ctx)
  10700. if err != nil {
  10701. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  10702. }
  10703. return oldValue.Reason, nil
  10704. }
  10705. // ResetReason resets all changes to the "reason" field.
  10706. func (m *CreditUsageMutation) ResetReason() {
  10707. m.reason = nil
  10708. }
  10709. // SetOperator sets the "operator" field.
  10710. func (m *CreditUsageMutation) SetOperator(s string) {
  10711. m.operator = &s
  10712. }
  10713. // Operator returns the value of the "operator" field in the mutation.
  10714. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  10715. v := m.operator
  10716. if v == nil {
  10717. return
  10718. }
  10719. return *v, true
  10720. }
  10721. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  10722. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10724. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  10725. if !m.op.Is(OpUpdateOne) {
  10726. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  10727. }
  10728. if m.id == nil || m.oldValue == nil {
  10729. return v, errors.New("OldOperator requires an ID field in the mutation")
  10730. }
  10731. oldValue, err := m.oldValue(ctx)
  10732. if err != nil {
  10733. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  10734. }
  10735. return oldValue.Operator, nil
  10736. }
  10737. // ResetOperator resets all changes to the "operator" field.
  10738. func (m *CreditUsageMutation) ResetOperator() {
  10739. m.operator = nil
  10740. }
  10741. // Where appends a list predicates to the CreditUsageMutation builder.
  10742. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  10743. m.predicates = append(m.predicates, ps...)
  10744. }
  10745. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  10746. // users can use type-assertion to append predicates that do not depend on any generated package.
  10747. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  10748. p := make([]predicate.CreditUsage, len(ps))
  10749. for i := range ps {
  10750. p[i] = ps[i]
  10751. }
  10752. m.Where(p...)
  10753. }
  10754. // Op returns the operation name.
  10755. func (m *CreditUsageMutation) Op() Op {
  10756. return m.op
  10757. }
  10758. // SetOp allows setting the mutation operation.
  10759. func (m *CreditUsageMutation) SetOp(op Op) {
  10760. m.op = op
  10761. }
  10762. // Type returns the node type of this mutation (CreditUsage).
  10763. func (m *CreditUsageMutation) Type() string {
  10764. return m.typ
  10765. }
  10766. // Fields returns all fields that were changed during this mutation. Note that in
  10767. // order to get all numeric fields that were incremented/decremented, call
  10768. // AddedFields().
  10769. func (m *CreditUsageMutation) Fields() []string {
  10770. fields := make([]string, 0, 12)
  10771. if m.created_at != nil {
  10772. fields = append(fields, creditusage.FieldCreatedAt)
  10773. }
  10774. if m.updated_at != nil {
  10775. fields = append(fields, creditusage.FieldUpdatedAt)
  10776. }
  10777. if m.deleted_at != nil {
  10778. fields = append(fields, creditusage.FieldDeletedAt)
  10779. }
  10780. if m.user_id != nil {
  10781. fields = append(fields, creditusage.FieldUserID)
  10782. }
  10783. if m.number != nil {
  10784. fields = append(fields, creditusage.FieldNumber)
  10785. }
  10786. if m.status != nil {
  10787. fields = append(fields, creditusage.FieldStatus)
  10788. }
  10789. if m.ntype != nil {
  10790. fields = append(fields, creditusage.FieldNtype)
  10791. }
  10792. if m.table != nil {
  10793. fields = append(fields, creditusage.FieldTable)
  10794. }
  10795. if m.organization_id != nil {
  10796. fields = append(fields, creditusage.FieldOrganizationID)
  10797. }
  10798. if m.nid != nil {
  10799. fields = append(fields, creditusage.FieldNid)
  10800. }
  10801. if m.reason != nil {
  10802. fields = append(fields, creditusage.FieldReason)
  10803. }
  10804. if m.operator != nil {
  10805. fields = append(fields, creditusage.FieldOperator)
  10806. }
  10807. return fields
  10808. }
  10809. // Field returns the value of a field with the given name. The second boolean
  10810. // return value indicates that this field was not set, or was not defined in the
  10811. // schema.
  10812. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  10813. switch name {
  10814. case creditusage.FieldCreatedAt:
  10815. return m.CreatedAt()
  10816. case creditusage.FieldUpdatedAt:
  10817. return m.UpdatedAt()
  10818. case creditusage.FieldDeletedAt:
  10819. return m.DeletedAt()
  10820. case creditusage.FieldUserID:
  10821. return m.UserID()
  10822. case creditusage.FieldNumber:
  10823. return m.Number()
  10824. case creditusage.FieldStatus:
  10825. return m.Status()
  10826. case creditusage.FieldNtype:
  10827. return m.Ntype()
  10828. case creditusage.FieldTable:
  10829. return m.Table()
  10830. case creditusage.FieldOrganizationID:
  10831. return m.OrganizationID()
  10832. case creditusage.FieldNid:
  10833. return m.Nid()
  10834. case creditusage.FieldReason:
  10835. return m.Reason()
  10836. case creditusage.FieldOperator:
  10837. return m.Operator()
  10838. }
  10839. return nil, false
  10840. }
  10841. // OldField returns the old value of the field from the database. An error is
  10842. // returned if the mutation operation is not UpdateOne, or the query to the
  10843. // database failed.
  10844. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10845. switch name {
  10846. case creditusage.FieldCreatedAt:
  10847. return m.OldCreatedAt(ctx)
  10848. case creditusage.FieldUpdatedAt:
  10849. return m.OldUpdatedAt(ctx)
  10850. case creditusage.FieldDeletedAt:
  10851. return m.OldDeletedAt(ctx)
  10852. case creditusage.FieldUserID:
  10853. return m.OldUserID(ctx)
  10854. case creditusage.FieldNumber:
  10855. return m.OldNumber(ctx)
  10856. case creditusage.FieldStatus:
  10857. return m.OldStatus(ctx)
  10858. case creditusage.FieldNtype:
  10859. return m.OldNtype(ctx)
  10860. case creditusage.FieldTable:
  10861. return m.OldTable(ctx)
  10862. case creditusage.FieldOrganizationID:
  10863. return m.OldOrganizationID(ctx)
  10864. case creditusage.FieldNid:
  10865. return m.OldNid(ctx)
  10866. case creditusage.FieldReason:
  10867. return m.OldReason(ctx)
  10868. case creditusage.FieldOperator:
  10869. return m.OldOperator(ctx)
  10870. }
  10871. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  10872. }
  10873. // SetField sets the value of a field with the given name. It returns an error if
  10874. // the field is not defined in the schema, or if the type mismatched the field
  10875. // type.
  10876. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  10877. switch name {
  10878. case creditusage.FieldCreatedAt:
  10879. v, ok := value.(time.Time)
  10880. if !ok {
  10881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10882. }
  10883. m.SetCreatedAt(v)
  10884. return nil
  10885. case creditusage.FieldUpdatedAt:
  10886. v, ok := value.(time.Time)
  10887. if !ok {
  10888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10889. }
  10890. m.SetUpdatedAt(v)
  10891. return nil
  10892. case creditusage.FieldDeletedAt:
  10893. v, ok := value.(time.Time)
  10894. if !ok {
  10895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10896. }
  10897. m.SetDeletedAt(v)
  10898. return nil
  10899. case creditusage.FieldUserID:
  10900. v, ok := value.(string)
  10901. if !ok {
  10902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10903. }
  10904. m.SetUserID(v)
  10905. return nil
  10906. case creditusage.FieldNumber:
  10907. v, ok := value.(float32)
  10908. if !ok {
  10909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10910. }
  10911. m.SetNumber(v)
  10912. return nil
  10913. case creditusage.FieldStatus:
  10914. v, ok := value.(int)
  10915. if !ok {
  10916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10917. }
  10918. m.SetStatus(v)
  10919. return nil
  10920. case creditusage.FieldNtype:
  10921. v, ok := value.(int)
  10922. if !ok {
  10923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10924. }
  10925. m.SetNtype(v)
  10926. return nil
  10927. case creditusage.FieldTable:
  10928. v, ok := value.(string)
  10929. if !ok {
  10930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10931. }
  10932. m.SetTable(v)
  10933. return nil
  10934. case creditusage.FieldOrganizationID:
  10935. v, ok := value.(uint64)
  10936. if !ok {
  10937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10938. }
  10939. m.SetOrganizationID(v)
  10940. return nil
  10941. case creditusage.FieldNid:
  10942. v, ok := value.(uint64)
  10943. if !ok {
  10944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10945. }
  10946. m.SetNid(v)
  10947. return nil
  10948. case creditusage.FieldReason:
  10949. v, ok := value.(string)
  10950. if !ok {
  10951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10952. }
  10953. m.SetReason(v)
  10954. return nil
  10955. case creditusage.FieldOperator:
  10956. v, ok := value.(string)
  10957. if !ok {
  10958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10959. }
  10960. m.SetOperator(v)
  10961. return nil
  10962. }
  10963. return fmt.Errorf("unknown CreditUsage field %s", name)
  10964. }
  10965. // AddedFields returns all numeric fields that were incremented/decremented during
  10966. // this mutation.
  10967. func (m *CreditUsageMutation) AddedFields() []string {
  10968. var fields []string
  10969. if m.addnumber != nil {
  10970. fields = append(fields, creditusage.FieldNumber)
  10971. }
  10972. if m.addstatus != nil {
  10973. fields = append(fields, creditusage.FieldStatus)
  10974. }
  10975. if m.addntype != nil {
  10976. fields = append(fields, creditusage.FieldNtype)
  10977. }
  10978. if m.addorganization_id != nil {
  10979. fields = append(fields, creditusage.FieldOrganizationID)
  10980. }
  10981. if m.addnid != nil {
  10982. fields = append(fields, creditusage.FieldNid)
  10983. }
  10984. return fields
  10985. }
  10986. // AddedField returns the numeric value that was incremented/decremented on a field
  10987. // with the given name. The second boolean return value indicates that this field
  10988. // was not set, or was not defined in the schema.
  10989. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  10990. switch name {
  10991. case creditusage.FieldNumber:
  10992. return m.AddedNumber()
  10993. case creditusage.FieldStatus:
  10994. return m.AddedStatus()
  10995. case creditusage.FieldNtype:
  10996. return m.AddedNtype()
  10997. case creditusage.FieldOrganizationID:
  10998. return m.AddedOrganizationID()
  10999. case creditusage.FieldNid:
  11000. return m.AddedNid()
  11001. }
  11002. return nil, false
  11003. }
  11004. // AddField adds the value to the field with the given name. It returns an error if
  11005. // the field is not defined in the schema, or if the type mismatched the field
  11006. // type.
  11007. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  11008. switch name {
  11009. case creditusage.FieldNumber:
  11010. v, ok := value.(float32)
  11011. if !ok {
  11012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11013. }
  11014. m.AddNumber(v)
  11015. return nil
  11016. case creditusage.FieldStatus:
  11017. v, ok := value.(int)
  11018. if !ok {
  11019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11020. }
  11021. m.AddStatus(v)
  11022. return nil
  11023. case creditusage.FieldNtype:
  11024. v, ok := value.(int)
  11025. if !ok {
  11026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11027. }
  11028. m.AddNtype(v)
  11029. return nil
  11030. case creditusage.FieldOrganizationID:
  11031. v, ok := value.(int64)
  11032. if !ok {
  11033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11034. }
  11035. m.AddOrganizationID(v)
  11036. return nil
  11037. case creditusage.FieldNid:
  11038. v, ok := value.(int64)
  11039. if !ok {
  11040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11041. }
  11042. m.AddNid(v)
  11043. return nil
  11044. }
  11045. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  11046. }
  11047. // ClearedFields returns all nullable fields that were cleared during this
  11048. // mutation.
  11049. func (m *CreditUsageMutation) ClearedFields() []string {
  11050. var fields []string
  11051. if m.FieldCleared(creditusage.FieldDeletedAt) {
  11052. fields = append(fields, creditusage.FieldDeletedAt)
  11053. }
  11054. if m.FieldCleared(creditusage.FieldStatus) {
  11055. fields = append(fields, creditusage.FieldStatus)
  11056. }
  11057. if m.FieldCleared(creditusage.FieldOrganizationID) {
  11058. fields = append(fields, creditusage.FieldOrganizationID)
  11059. }
  11060. return fields
  11061. }
  11062. // FieldCleared returns a boolean indicating if a field with the given name was
  11063. // cleared in this mutation.
  11064. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  11065. _, ok := m.clearedFields[name]
  11066. return ok
  11067. }
  11068. // ClearField clears the value of the field with the given name. It returns an
  11069. // error if the field is not defined in the schema.
  11070. func (m *CreditUsageMutation) ClearField(name string) error {
  11071. switch name {
  11072. case creditusage.FieldDeletedAt:
  11073. m.ClearDeletedAt()
  11074. return nil
  11075. case creditusage.FieldStatus:
  11076. m.ClearStatus()
  11077. return nil
  11078. case creditusage.FieldOrganizationID:
  11079. m.ClearOrganizationID()
  11080. return nil
  11081. }
  11082. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  11083. }
  11084. // ResetField resets all changes in the mutation for the field with the given name.
  11085. // It returns an error if the field is not defined in the schema.
  11086. func (m *CreditUsageMutation) ResetField(name string) error {
  11087. switch name {
  11088. case creditusage.FieldCreatedAt:
  11089. m.ResetCreatedAt()
  11090. return nil
  11091. case creditusage.FieldUpdatedAt:
  11092. m.ResetUpdatedAt()
  11093. return nil
  11094. case creditusage.FieldDeletedAt:
  11095. m.ResetDeletedAt()
  11096. return nil
  11097. case creditusage.FieldUserID:
  11098. m.ResetUserID()
  11099. return nil
  11100. case creditusage.FieldNumber:
  11101. m.ResetNumber()
  11102. return nil
  11103. case creditusage.FieldStatus:
  11104. m.ResetStatus()
  11105. return nil
  11106. case creditusage.FieldNtype:
  11107. m.ResetNtype()
  11108. return nil
  11109. case creditusage.FieldTable:
  11110. m.ResetTable()
  11111. return nil
  11112. case creditusage.FieldOrganizationID:
  11113. m.ResetOrganizationID()
  11114. return nil
  11115. case creditusage.FieldNid:
  11116. m.ResetNid()
  11117. return nil
  11118. case creditusage.FieldReason:
  11119. m.ResetReason()
  11120. return nil
  11121. case creditusage.FieldOperator:
  11122. m.ResetOperator()
  11123. return nil
  11124. }
  11125. return fmt.Errorf("unknown CreditUsage field %s", name)
  11126. }
  11127. // AddedEdges returns all edge names that were set/added in this mutation.
  11128. func (m *CreditUsageMutation) AddedEdges() []string {
  11129. edges := make([]string, 0, 0)
  11130. return edges
  11131. }
  11132. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11133. // name in this mutation.
  11134. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  11135. return nil
  11136. }
  11137. // RemovedEdges returns all edge names that were removed in this mutation.
  11138. func (m *CreditUsageMutation) RemovedEdges() []string {
  11139. edges := make([]string, 0, 0)
  11140. return edges
  11141. }
  11142. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11143. // the given name in this mutation.
  11144. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  11145. return nil
  11146. }
  11147. // ClearedEdges returns all edge names that were cleared in this mutation.
  11148. func (m *CreditUsageMutation) ClearedEdges() []string {
  11149. edges := make([]string, 0, 0)
  11150. return edges
  11151. }
  11152. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11153. // was cleared in this mutation.
  11154. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  11155. return false
  11156. }
  11157. // ClearEdge clears the value of the edge with the given name. It returns an error
  11158. // if that edge is not defined in the schema.
  11159. func (m *CreditUsageMutation) ClearEdge(name string) error {
  11160. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  11161. }
  11162. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11163. // It returns an error if the edge is not defined in the schema.
  11164. func (m *CreditUsageMutation) ResetEdge(name string) error {
  11165. return fmt.Errorf("unknown CreditUsage edge %s", name)
  11166. }
  11167. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  11168. type EmployeeMutation struct {
  11169. config
  11170. op Op
  11171. typ string
  11172. id *uint64
  11173. created_at *time.Time
  11174. updated_at *time.Time
  11175. deleted_at *time.Time
  11176. title *string
  11177. avatar *string
  11178. tags *string
  11179. hire_count *int
  11180. addhire_count *int
  11181. service_count *int
  11182. addservice_count *int
  11183. achievement_count *int
  11184. addachievement_count *int
  11185. intro *string
  11186. estimate *string
  11187. skill *string
  11188. ability_type *string
  11189. scene *string
  11190. switch_in *string
  11191. video_url *string
  11192. organization_id *uint64
  11193. addorganization_id *int64
  11194. category_id *uint64
  11195. addcategory_id *int64
  11196. api_base *string
  11197. api_key *string
  11198. ai_info *string
  11199. is_vip *int
  11200. addis_vip *int
  11201. chat_url *string
  11202. clearedFields map[string]struct{}
  11203. em_work_experiences map[uint64]struct{}
  11204. removedem_work_experiences map[uint64]struct{}
  11205. clearedem_work_experiences bool
  11206. em_tutorial map[uint64]struct{}
  11207. removedem_tutorial map[uint64]struct{}
  11208. clearedem_tutorial bool
  11209. done bool
  11210. oldValue func(context.Context) (*Employee, error)
  11211. predicates []predicate.Employee
  11212. }
  11213. var _ ent.Mutation = (*EmployeeMutation)(nil)
  11214. // employeeOption allows management of the mutation configuration using functional options.
  11215. type employeeOption func(*EmployeeMutation)
  11216. // newEmployeeMutation creates new mutation for the Employee entity.
  11217. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  11218. m := &EmployeeMutation{
  11219. config: c,
  11220. op: op,
  11221. typ: TypeEmployee,
  11222. clearedFields: make(map[string]struct{}),
  11223. }
  11224. for _, opt := range opts {
  11225. opt(m)
  11226. }
  11227. return m
  11228. }
  11229. // withEmployeeID sets the ID field of the mutation.
  11230. func withEmployeeID(id uint64) employeeOption {
  11231. return func(m *EmployeeMutation) {
  11232. var (
  11233. err error
  11234. once sync.Once
  11235. value *Employee
  11236. )
  11237. m.oldValue = func(ctx context.Context) (*Employee, error) {
  11238. once.Do(func() {
  11239. if m.done {
  11240. err = errors.New("querying old values post mutation is not allowed")
  11241. } else {
  11242. value, err = m.Client().Employee.Get(ctx, id)
  11243. }
  11244. })
  11245. return value, err
  11246. }
  11247. m.id = &id
  11248. }
  11249. }
  11250. // withEmployee sets the old Employee of the mutation.
  11251. func withEmployee(node *Employee) employeeOption {
  11252. return func(m *EmployeeMutation) {
  11253. m.oldValue = func(context.Context) (*Employee, error) {
  11254. return node, nil
  11255. }
  11256. m.id = &node.ID
  11257. }
  11258. }
  11259. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11260. // executed in a transaction (ent.Tx), a transactional client is returned.
  11261. func (m EmployeeMutation) Client() *Client {
  11262. client := &Client{config: m.config}
  11263. client.init()
  11264. return client
  11265. }
  11266. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11267. // it returns an error otherwise.
  11268. func (m EmployeeMutation) Tx() (*Tx, error) {
  11269. if _, ok := m.driver.(*txDriver); !ok {
  11270. return nil, errors.New("ent: mutation is not running in a transaction")
  11271. }
  11272. tx := &Tx{config: m.config}
  11273. tx.init()
  11274. return tx, nil
  11275. }
  11276. // SetID sets the value of the id field. Note that this
  11277. // operation is only accepted on creation of Employee entities.
  11278. func (m *EmployeeMutation) SetID(id uint64) {
  11279. m.id = &id
  11280. }
  11281. // ID returns the ID value in the mutation. Note that the ID is only available
  11282. // if it was provided to the builder or after it was returned from the database.
  11283. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  11284. if m.id == nil {
  11285. return
  11286. }
  11287. return *m.id, true
  11288. }
  11289. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11290. // That means, if the mutation is applied within a transaction with an isolation level such
  11291. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11292. // or updated by the mutation.
  11293. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11294. switch {
  11295. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11296. id, exists := m.ID()
  11297. if exists {
  11298. return []uint64{id}, nil
  11299. }
  11300. fallthrough
  11301. case m.op.Is(OpUpdate | OpDelete):
  11302. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  11303. default:
  11304. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11305. }
  11306. }
  11307. // SetCreatedAt sets the "created_at" field.
  11308. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  11309. m.created_at = &t
  11310. }
  11311. // CreatedAt returns the value of the "created_at" field in the mutation.
  11312. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  11313. v := m.created_at
  11314. if v == nil {
  11315. return
  11316. }
  11317. return *v, true
  11318. }
  11319. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  11320. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11322. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11323. if !m.op.Is(OpUpdateOne) {
  11324. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11325. }
  11326. if m.id == nil || m.oldValue == nil {
  11327. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11328. }
  11329. oldValue, err := m.oldValue(ctx)
  11330. if err != nil {
  11331. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11332. }
  11333. return oldValue.CreatedAt, nil
  11334. }
  11335. // ResetCreatedAt resets all changes to the "created_at" field.
  11336. func (m *EmployeeMutation) ResetCreatedAt() {
  11337. m.created_at = nil
  11338. }
  11339. // SetUpdatedAt sets the "updated_at" field.
  11340. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  11341. m.updated_at = &t
  11342. }
  11343. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11344. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  11345. v := m.updated_at
  11346. if v == nil {
  11347. return
  11348. }
  11349. return *v, true
  11350. }
  11351. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  11352. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11354. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11355. if !m.op.Is(OpUpdateOne) {
  11356. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11357. }
  11358. if m.id == nil || m.oldValue == nil {
  11359. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11360. }
  11361. oldValue, err := m.oldValue(ctx)
  11362. if err != nil {
  11363. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11364. }
  11365. return oldValue.UpdatedAt, nil
  11366. }
  11367. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11368. func (m *EmployeeMutation) ResetUpdatedAt() {
  11369. m.updated_at = nil
  11370. }
  11371. // SetDeletedAt sets the "deleted_at" field.
  11372. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  11373. m.deleted_at = &t
  11374. }
  11375. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11376. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  11377. v := m.deleted_at
  11378. if v == nil {
  11379. return
  11380. }
  11381. return *v, true
  11382. }
  11383. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  11384. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11386. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11387. if !m.op.Is(OpUpdateOne) {
  11388. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11389. }
  11390. if m.id == nil || m.oldValue == nil {
  11391. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11392. }
  11393. oldValue, err := m.oldValue(ctx)
  11394. if err != nil {
  11395. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11396. }
  11397. return oldValue.DeletedAt, nil
  11398. }
  11399. // ClearDeletedAt clears the value of the "deleted_at" field.
  11400. func (m *EmployeeMutation) ClearDeletedAt() {
  11401. m.deleted_at = nil
  11402. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  11403. }
  11404. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11405. func (m *EmployeeMutation) DeletedAtCleared() bool {
  11406. _, ok := m.clearedFields[employee.FieldDeletedAt]
  11407. return ok
  11408. }
  11409. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11410. func (m *EmployeeMutation) ResetDeletedAt() {
  11411. m.deleted_at = nil
  11412. delete(m.clearedFields, employee.FieldDeletedAt)
  11413. }
  11414. // SetTitle sets the "title" field.
  11415. func (m *EmployeeMutation) SetTitle(s string) {
  11416. m.title = &s
  11417. }
  11418. // Title returns the value of the "title" field in the mutation.
  11419. func (m *EmployeeMutation) Title() (r string, exists bool) {
  11420. v := m.title
  11421. if v == nil {
  11422. return
  11423. }
  11424. return *v, true
  11425. }
  11426. // OldTitle returns the old "title" field's value of the Employee entity.
  11427. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11429. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  11430. if !m.op.Is(OpUpdateOne) {
  11431. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11432. }
  11433. if m.id == nil || m.oldValue == nil {
  11434. return v, errors.New("OldTitle requires an ID field in the mutation")
  11435. }
  11436. oldValue, err := m.oldValue(ctx)
  11437. if err != nil {
  11438. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11439. }
  11440. return oldValue.Title, nil
  11441. }
  11442. // ResetTitle resets all changes to the "title" field.
  11443. func (m *EmployeeMutation) ResetTitle() {
  11444. m.title = nil
  11445. }
  11446. // SetAvatar sets the "avatar" field.
  11447. func (m *EmployeeMutation) SetAvatar(s string) {
  11448. m.avatar = &s
  11449. }
  11450. // Avatar returns the value of the "avatar" field in the mutation.
  11451. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  11452. v := m.avatar
  11453. if v == nil {
  11454. return
  11455. }
  11456. return *v, true
  11457. }
  11458. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  11459. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11461. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  11462. if !m.op.Is(OpUpdateOne) {
  11463. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  11464. }
  11465. if m.id == nil || m.oldValue == nil {
  11466. return v, errors.New("OldAvatar requires an ID field in the mutation")
  11467. }
  11468. oldValue, err := m.oldValue(ctx)
  11469. if err != nil {
  11470. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  11471. }
  11472. return oldValue.Avatar, nil
  11473. }
  11474. // ResetAvatar resets all changes to the "avatar" field.
  11475. func (m *EmployeeMutation) ResetAvatar() {
  11476. m.avatar = nil
  11477. }
  11478. // SetTags sets the "tags" field.
  11479. func (m *EmployeeMutation) SetTags(s string) {
  11480. m.tags = &s
  11481. }
  11482. // Tags returns the value of the "tags" field in the mutation.
  11483. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  11484. v := m.tags
  11485. if v == nil {
  11486. return
  11487. }
  11488. return *v, true
  11489. }
  11490. // OldTags returns the old "tags" field's value of the Employee entity.
  11491. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11493. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  11494. if !m.op.Is(OpUpdateOne) {
  11495. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  11496. }
  11497. if m.id == nil || m.oldValue == nil {
  11498. return v, errors.New("OldTags requires an ID field in the mutation")
  11499. }
  11500. oldValue, err := m.oldValue(ctx)
  11501. if err != nil {
  11502. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  11503. }
  11504. return oldValue.Tags, nil
  11505. }
  11506. // ResetTags resets all changes to the "tags" field.
  11507. func (m *EmployeeMutation) ResetTags() {
  11508. m.tags = nil
  11509. }
  11510. // SetHireCount sets the "hire_count" field.
  11511. func (m *EmployeeMutation) SetHireCount(i int) {
  11512. m.hire_count = &i
  11513. m.addhire_count = nil
  11514. }
  11515. // HireCount returns the value of the "hire_count" field in the mutation.
  11516. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  11517. v := m.hire_count
  11518. if v == nil {
  11519. return
  11520. }
  11521. return *v, true
  11522. }
  11523. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  11524. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11526. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  11527. if !m.op.Is(OpUpdateOne) {
  11528. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  11529. }
  11530. if m.id == nil || m.oldValue == nil {
  11531. return v, errors.New("OldHireCount requires an ID field in the mutation")
  11532. }
  11533. oldValue, err := m.oldValue(ctx)
  11534. if err != nil {
  11535. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  11536. }
  11537. return oldValue.HireCount, nil
  11538. }
  11539. // AddHireCount adds i to the "hire_count" field.
  11540. func (m *EmployeeMutation) AddHireCount(i int) {
  11541. if m.addhire_count != nil {
  11542. *m.addhire_count += i
  11543. } else {
  11544. m.addhire_count = &i
  11545. }
  11546. }
  11547. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  11548. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  11549. v := m.addhire_count
  11550. if v == nil {
  11551. return
  11552. }
  11553. return *v, true
  11554. }
  11555. // ResetHireCount resets all changes to the "hire_count" field.
  11556. func (m *EmployeeMutation) ResetHireCount() {
  11557. m.hire_count = nil
  11558. m.addhire_count = nil
  11559. }
  11560. // SetServiceCount sets the "service_count" field.
  11561. func (m *EmployeeMutation) SetServiceCount(i int) {
  11562. m.service_count = &i
  11563. m.addservice_count = nil
  11564. }
  11565. // ServiceCount returns the value of the "service_count" field in the mutation.
  11566. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  11567. v := m.service_count
  11568. if v == nil {
  11569. return
  11570. }
  11571. return *v, true
  11572. }
  11573. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  11574. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11576. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  11577. if !m.op.Is(OpUpdateOne) {
  11578. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  11579. }
  11580. if m.id == nil || m.oldValue == nil {
  11581. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  11582. }
  11583. oldValue, err := m.oldValue(ctx)
  11584. if err != nil {
  11585. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  11586. }
  11587. return oldValue.ServiceCount, nil
  11588. }
  11589. // AddServiceCount adds i to the "service_count" field.
  11590. func (m *EmployeeMutation) AddServiceCount(i int) {
  11591. if m.addservice_count != nil {
  11592. *m.addservice_count += i
  11593. } else {
  11594. m.addservice_count = &i
  11595. }
  11596. }
  11597. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  11598. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  11599. v := m.addservice_count
  11600. if v == nil {
  11601. return
  11602. }
  11603. return *v, true
  11604. }
  11605. // ResetServiceCount resets all changes to the "service_count" field.
  11606. func (m *EmployeeMutation) ResetServiceCount() {
  11607. m.service_count = nil
  11608. m.addservice_count = nil
  11609. }
  11610. // SetAchievementCount sets the "achievement_count" field.
  11611. func (m *EmployeeMutation) SetAchievementCount(i int) {
  11612. m.achievement_count = &i
  11613. m.addachievement_count = nil
  11614. }
  11615. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  11616. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  11617. v := m.achievement_count
  11618. if v == nil {
  11619. return
  11620. }
  11621. return *v, true
  11622. }
  11623. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  11624. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11626. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  11627. if !m.op.Is(OpUpdateOne) {
  11628. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  11629. }
  11630. if m.id == nil || m.oldValue == nil {
  11631. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  11632. }
  11633. oldValue, err := m.oldValue(ctx)
  11634. if err != nil {
  11635. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  11636. }
  11637. return oldValue.AchievementCount, nil
  11638. }
  11639. // AddAchievementCount adds i to the "achievement_count" field.
  11640. func (m *EmployeeMutation) AddAchievementCount(i int) {
  11641. if m.addachievement_count != nil {
  11642. *m.addachievement_count += i
  11643. } else {
  11644. m.addachievement_count = &i
  11645. }
  11646. }
  11647. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  11648. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  11649. v := m.addachievement_count
  11650. if v == nil {
  11651. return
  11652. }
  11653. return *v, true
  11654. }
  11655. // ResetAchievementCount resets all changes to the "achievement_count" field.
  11656. func (m *EmployeeMutation) ResetAchievementCount() {
  11657. m.achievement_count = nil
  11658. m.addachievement_count = nil
  11659. }
  11660. // SetIntro sets the "intro" field.
  11661. func (m *EmployeeMutation) SetIntro(s string) {
  11662. m.intro = &s
  11663. }
  11664. // Intro returns the value of the "intro" field in the mutation.
  11665. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  11666. v := m.intro
  11667. if v == nil {
  11668. return
  11669. }
  11670. return *v, true
  11671. }
  11672. // OldIntro returns the old "intro" field's value of the Employee entity.
  11673. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11675. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  11676. if !m.op.Is(OpUpdateOne) {
  11677. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  11678. }
  11679. if m.id == nil || m.oldValue == nil {
  11680. return v, errors.New("OldIntro requires an ID field in the mutation")
  11681. }
  11682. oldValue, err := m.oldValue(ctx)
  11683. if err != nil {
  11684. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  11685. }
  11686. return oldValue.Intro, nil
  11687. }
  11688. // ResetIntro resets all changes to the "intro" field.
  11689. func (m *EmployeeMutation) ResetIntro() {
  11690. m.intro = nil
  11691. }
  11692. // SetEstimate sets the "estimate" field.
  11693. func (m *EmployeeMutation) SetEstimate(s string) {
  11694. m.estimate = &s
  11695. }
  11696. // Estimate returns the value of the "estimate" field in the mutation.
  11697. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  11698. v := m.estimate
  11699. if v == nil {
  11700. return
  11701. }
  11702. return *v, true
  11703. }
  11704. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  11705. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11707. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  11708. if !m.op.Is(OpUpdateOne) {
  11709. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  11710. }
  11711. if m.id == nil || m.oldValue == nil {
  11712. return v, errors.New("OldEstimate requires an ID field in the mutation")
  11713. }
  11714. oldValue, err := m.oldValue(ctx)
  11715. if err != nil {
  11716. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  11717. }
  11718. return oldValue.Estimate, nil
  11719. }
  11720. // ResetEstimate resets all changes to the "estimate" field.
  11721. func (m *EmployeeMutation) ResetEstimate() {
  11722. m.estimate = nil
  11723. }
  11724. // SetSkill sets the "skill" field.
  11725. func (m *EmployeeMutation) SetSkill(s string) {
  11726. m.skill = &s
  11727. }
  11728. // Skill returns the value of the "skill" field in the mutation.
  11729. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  11730. v := m.skill
  11731. if v == nil {
  11732. return
  11733. }
  11734. return *v, true
  11735. }
  11736. // OldSkill returns the old "skill" field's value of the Employee entity.
  11737. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11739. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  11740. if !m.op.Is(OpUpdateOne) {
  11741. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  11742. }
  11743. if m.id == nil || m.oldValue == nil {
  11744. return v, errors.New("OldSkill requires an ID field in the mutation")
  11745. }
  11746. oldValue, err := m.oldValue(ctx)
  11747. if err != nil {
  11748. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  11749. }
  11750. return oldValue.Skill, nil
  11751. }
  11752. // ResetSkill resets all changes to the "skill" field.
  11753. func (m *EmployeeMutation) ResetSkill() {
  11754. m.skill = nil
  11755. }
  11756. // SetAbilityType sets the "ability_type" field.
  11757. func (m *EmployeeMutation) SetAbilityType(s string) {
  11758. m.ability_type = &s
  11759. }
  11760. // AbilityType returns the value of the "ability_type" field in the mutation.
  11761. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  11762. v := m.ability_type
  11763. if v == nil {
  11764. return
  11765. }
  11766. return *v, true
  11767. }
  11768. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  11769. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11771. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  11772. if !m.op.Is(OpUpdateOne) {
  11773. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  11774. }
  11775. if m.id == nil || m.oldValue == nil {
  11776. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  11777. }
  11778. oldValue, err := m.oldValue(ctx)
  11779. if err != nil {
  11780. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  11781. }
  11782. return oldValue.AbilityType, nil
  11783. }
  11784. // ResetAbilityType resets all changes to the "ability_type" field.
  11785. func (m *EmployeeMutation) ResetAbilityType() {
  11786. m.ability_type = nil
  11787. }
  11788. // SetScene sets the "scene" field.
  11789. func (m *EmployeeMutation) SetScene(s string) {
  11790. m.scene = &s
  11791. }
  11792. // Scene returns the value of the "scene" field in the mutation.
  11793. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  11794. v := m.scene
  11795. if v == nil {
  11796. return
  11797. }
  11798. return *v, true
  11799. }
  11800. // OldScene returns the old "scene" field's value of the Employee entity.
  11801. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11803. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  11804. if !m.op.Is(OpUpdateOne) {
  11805. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  11806. }
  11807. if m.id == nil || m.oldValue == nil {
  11808. return v, errors.New("OldScene requires an ID field in the mutation")
  11809. }
  11810. oldValue, err := m.oldValue(ctx)
  11811. if err != nil {
  11812. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  11813. }
  11814. return oldValue.Scene, nil
  11815. }
  11816. // ResetScene resets all changes to the "scene" field.
  11817. func (m *EmployeeMutation) ResetScene() {
  11818. m.scene = nil
  11819. }
  11820. // SetSwitchIn sets the "switch_in" field.
  11821. func (m *EmployeeMutation) SetSwitchIn(s string) {
  11822. m.switch_in = &s
  11823. }
  11824. // SwitchIn returns the value of the "switch_in" field in the mutation.
  11825. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  11826. v := m.switch_in
  11827. if v == nil {
  11828. return
  11829. }
  11830. return *v, true
  11831. }
  11832. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  11833. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11835. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  11836. if !m.op.Is(OpUpdateOne) {
  11837. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  11838. }
  11839. if m.id == nil || m.oldValue == nil {
  11840. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  11841. }
  11842. oldValue, err := m.oldValue(ctx)
  11843. if err != nil {
  11844. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  11845. }
  11846. return oldValue.SwitchIn, nil
  11847. }
  11848. // ResetSwitchIn resets all changes to the "switch_in" field.
  11849. func (m *EmployeeMutation) ResetSwitchIn() {
  11850. m.switch_in = nil
  11851. }
  11852. // SetVideoURL sets the "video_url" field.
  11853. func (m *EmployeeMutation) SetVideoURL(s string) {
  11854. m.video_url = &s
  11855. }
  11856. // VideoURL returns the value of the "video_url" field in the mutation.
  11857. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  11858. v := m.video_url
  11859. if v == nil {
  11860. return
  11861. }
  11862. return *v, true
  11863. }
  11864. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  11865. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11867. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  11868. if !m.op.Is(OpUpdateOne) {
  11869. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  11870. }
  11871. if m.id == nil || m.oldValue == nil {
  11872. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  11873. }
  11874. oldValue, err := m.oldValue(ctx)
  11875. if err != nil {
  11876. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  11877. }
  11878. return oldValue.VideoURL, nil
  11879. }
  11880. // ResetVideoURL resets all changes to the "video_url" field.
  11881. func (m *EmployeeMutation) ResetVideoURL() {
  11882. m.video_url = nil
  11883. }
  11884. // SetOrganizationID sets the "organization_id" field.
  11885. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  11886. m.organization_id = &u
  11887. m.addorganization_id = nil
  11888. }
  11889. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11890. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  11891. v := m.organization_id
  11892. if v == nil {
  11893. return
  11894. }
  11895. return *v, true
  11896. }
  11897. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  11898. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11900. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11901. if !m.op.Is(OpUpdateOne) {
  11902. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11903. }
  11904. if m.id == nil || m.oldValue == nil {
  11905. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11906. }
  11907. oldValue, err := m.oldValue(ctx)
  11908. if err != nil {
  11909. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11910. }
  11911. return oldValue.OrganizationID, nil
  11912. }
  11913. // AddOrganizationID adds u to the "organization_id" field.
  11914. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  11915. if m.addorganization_id != nil {
  11916. *m.addorganization_id += u
  11917. } else {
  11918. m.addorganization_id = &u
  11919. }
  11920. }
  11921. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11922. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  11923. v := m.addorganization_id
  11924. if v == nil {
  11925. return
  11926. }
  11927. return *v, true
  11928. }
  11929. // ResetOrganizationID resets all changes to the "organization_id" field.
  11930. func (m *EmployeeMutation) ResetOrganizationID() {
  11931. m.organization_id = nil
  11932. m.addorganization_id = nil
  11933. }
  11934. // SetCategoryID sets the "category_id" field.
  11935. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  11936. m.category_id = &u
  11937. m.addcategory_id = nil
  11938. }
  11939. // CategoryID returns the value of the "category_id" field in the mutation.
  11940. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  11941. v := m.category_id
  11942. if v == nil {
  11943. return
  11944. }
  11945. return *v, true
  11946. }
  11947. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  11948. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11950. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  11951. if !m.op.Is(OpUpdateOne) {
  11952. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  11953. }
  11954. if m.id == nil || m.oldValue == nil {
  11955. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  11956. }
  11957. oldValue, err := m.oldValue(ctx)
  11958. if err != nil {
  11959. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  11960. }
  11961. return oldValue.CategoryID, nil
  11962. }
  11963. // AddCategoryID adds u to the "category_id" field.
  11964. func (m *EmployeeMutation) AddCategoryID(u int64) {
  11965. if m.addcategory_id != nil {
  11966. *m.addcategory_id += u
  11967. } else {
  11968. m.addcategory_id = &u
  11969. }
  11970. }
  11971. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  11972. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  11973. v := m.addcategory_id
  11974. if v == nil {
  11975. return
  11976. }
  11977. return *v, true
  11978. }
  11979. // ResetCategoryID resets all changes to the "category_id" field.
  11980. func (m *EmployeeMutation) ResetCategoryID() {
  11981. m.category_id = nil
  11982. m.addcategory_id = nil
  11983. }
  11984. // SetAPIBase sets the "api_base" field.
  11985. func (m *EmployeeMutation) SetAPIBase(s string) {
  11986. m.api_base = &s
  11987. }
  11988. // APIBase returns the value of the "api_base" field in the mutation.
  11989. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  11990. v := m.api_base
  11991. if v == nil {
  11992. return
  11993. }
  11994. return *v, true
  11995. }
  11996. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  11997. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11999. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  12000. if !m.op.Is(OpUpdateOne) {
  12001. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  12002. }
  12003. if m.id == nil || m.oldValue == nil {
  12004. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  12005. }
  12006. oldValue, err := m.oldValue(ctx)
  12007. if err != nil {
  12008. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  12009. }
  12010. return oldValue.APIBase, nil
  12011. }
  12012. // ResetAPIBase resets all changes to the "api_base" field.
  12013. func (m *EmployeeMutation) ResetAPIBase() {
  12014. m.api_base = nil
  12015. }
  12016. // SetAPIKey sets the "api_key" field.
  12017. func (m *EmployeeMutation) SetAPIKey(s string) {
  12018. m.api_key = &s
  12019. }
  12020. // APIKey returns the value of the "api_key" field in the mutation.
  12021. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  12022. v := m.api_key
  12023. if v == nil {
  12024. return
  12025. }
  12026. return *v, true
  12027. }
  12028. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  12029. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12031. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  12032. if !m.op.Is(OpUpdateOne) {
  12033. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  12034. }
  12035. if m.id == nil || m.oldValue == nil {
  12036. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  12037. }
  12038. oldValue, err := m.oldValue(ctx)
  12039. if err != nil {
  12040. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  12041. }
  12042. return oldValue.APIKey, nil
  12043. }
  12044. // ResetAPIKey resets all changes to the "api_key" field.
  12045. func (m *EmployeeMutation) ResetAPIKey() {
  12046. m.api_key = nil
  12047. }
  12048. // SetAiInfo sets the "ai_info" field.
  12049. func (m *EmployeeMutation) SetAiInfo(s string) {
  12050. m.ai_info = &s
  12051. }
  12052. // AiInfo returns the value of the "ai_info" field in the mutation.
  12053. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  12054. v := m.ai_info
  12055. if v == nil {
  12056. return
  12057. }
  12058. return *v, true
  12059. }
  12060. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  12061. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12063. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  12064. if !m.op.Is(OpUpdateOne) {
  12065. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  12066. }
  12067. if m.id == nil || m.oldValue == nil {
  12068. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  12069. }
  12070. oldValue, err := m.oldValue(ctx)
  12071. if err != nil {
  12072. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  12073. }
  12074. return oldValue.AiInfo, nil
  12075. }
  12076. // ClearAiInfo clears the value of the "ai_info" field.
  12077. func (m *EmployeeMutation) ClearAiInfo() {
  12078. m.ai_info = nil
  12079. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  12080. }
  12081. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  12082. func (m *EmployeeMutation) AiInfoCleared() bool {
  12083. _, ok := m.clearedFields[employee.FieldAiInfo]
  12084. return ok
  12085. }
  12086. // ResetAiInfo resets all changes to the "ai_info" field.
  12087. func (m *EmployeeMutation) ResetAiInfo() {
  12088. m.ai_info = nil
  12089. delete(m.clearedFields, employee.FieldAiInfo)
  12090. }
  12091. // SetIsVip sets the "is_vip" field.
  12092. func (m *EmployeeMutation) SetIsVip(i int) {
  12093. m.is_vip = &i
  12094. m.addis_vip = nil
  12095. }
  12096. // IsVip returns the value of the "is_vip" field in the mutation.
  12097. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  12098. v := m.is_vip
  12099. if v == nil {
  12100. return
  12101. }
  12102. return *v, true
  12103. }
  12104. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  12105. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12107. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  12108. if !m.op.Is(OpUpdateOne) {
  12109. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  12110. }
  12111. if m.id == nil || m.oldValue == nil {
  12112. return v, errors.New("OldIsVip requires an ID field in the mutation")
  12113. }
  12114. oldValue, err := m.oldValue(ctx)
  12115. if err != nil {
  12116. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  12117. }
  12118. return oldValue.IsVip, nil
  12119. }
  12120. // AddIsVip adds i to the "is_vip" field.
  12121. func (m *EmployeeMutation) AddIsVip(i int) {
  12122. if m.addis_vip != nil {
  12123. *m.addis_vip += i
  12124. } else {
  12125. m.addis_vip = &i
  12126. }
  12127. }
  12128. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  12129. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  12130. v := m.addis_vip
  12131. if v == nil {
  12132. return
  12133. }
  12134. return *v, true
  12135. }
  12136. // ResetIsVip resets all changes to the "is_vip" field.
  12137. func (m *EmployeeMutation) ResetIsVip() {
  12138. m.is_vip = nil
  12139. m.addis_vip = nil
  12140. }
  12141. // SetChatURL sets the "chat_url" field.
  12142. func (m *EmployeeMutation) SetChatURL(s string) {
  12143. m.chat_url = &s
  12144. }
  12145. // ChatURL returns the value of the "chat_url" field in the mutation.
  12146. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  12147. v := m.chat_url
  12148. if v == nil {
  12149. return
  12150. }
  12151. return *v, true
  12152. }
  12153. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  12154. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12156. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  12157. if !m.op.Is(OpUpdateOne) {
  12158. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  12159. }
  12160. if m.id == nil || m.oldValue == nil {
  12161. return v, errors.New("OldChatURL requires an ID field in the mutation")
  12162. }
  12163. oldValue, err := m.oldValue(ctx)
  12164. if err != nil {
  12165. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  12166. }
  12167. return oldValue.ChatURL, nil
  12168. }
  12169. // ResetChatURL resets all changes to the "chat_url" field.
  12170. func (m *EmployeeMutation) ResetChatURL() {
  12171. m.chat_url = nil
  12172. }
  12173. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  12174. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  12175. if m.em_work_experiences == nil {
  12176. m.em_work_experiences = make(map[uint64]struct{})
  12177. }
  12178. for i := range ids {
  12179. m.em_work_experiences[ids[i]] = struct{}{}
  12180. }
  12181. }
  12182. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  12183. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  12184. m.clearedem_work_experiences = true
  12185. }
  12186. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  12187. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  12188. return m.clearedem_work_experiences
  12189. }
  12190. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  12191. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  12192. if m.removedem_work_experiences == nil {
  12193. m.removedem_work_experiences = make(map[uint64]struct{})
  12194. }
  12195. for i := range ids {
  12196. delete(m.em_work_experiences, ids[i])
  12197. m.removedem_work_experiences[ids[i]] = struct{}{}
  12198. }
  12199. }
  12200. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  12201. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  12202. for id := range m.removedem_work_experiences {
  12203. ids = append(ids, id)
  12204. }
  12205. return
  12206. }
  12207. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  12208. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  12209. for id := range m.em_work_experiences {
  12210. ids = append(ids, id)
  12211. }
  12212. return
  12213. }
  12214. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  12215. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  12216. m.em_work_experiences = nil
  12217. m.clearedem_work_experiences = false
  12218. m.removedem_work_experiences = nil
  12219. }
  12220. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  12221. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  12222. if m.em_tutorial == nil {
  12223. m.em_tutorial = make(map[uint64]struct{})
  12224. }
  12225. for i := range ids {
  12226. m.em_tutorial[ids[i]] = struct{}{}
  12227. }
  12228. }
  12229. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  12230. func (m *EmployeeMutation) ClearEmTutorial() {
  12231. m.clearedem_tutorial = true
  12232. }
  12233. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  12234. func (m *EmployeeMutation) EmTutorialCleared() bool {
  12235. return m.clearedem_tutorial
  12236. }
  12237. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  12238. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  12239. if m.removedem_tutorial == nil {
  12240. m.removedem_tutorial = make(map[uint64]struct{})
  12241. }
  12242. for i := range ids {
  12243. delete(m.em_tutorial, ids[i])
  12244. m.removedem_tutorial[ids[i]] = struct{}{}
  12245. }
  12246. }
  12247. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  12248. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  12249. for id := range m.removedem_tutorial {
  12250. ids = append(ids, id)
  12251. }
  12252. return
  12253. }
  12254. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  12255. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  12256. for id := range m.em_tutorial {
  12257. ids = append(ids, id)
  12258. }
  12259. return
  12260. }
  12261. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  12262. func (m *EmployeeMutation) ResetEmTutorial() {
  12263. m.em_tutorial = nil
  12264. m.clearedem_tutorial = false
  12265. m.removedem_tutorial = nil
  12266. }
  12267. // Where appends a list predicates to the EmployeeMutation builder.
  12268. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  12269. m.predicates = append(m.predicates, ps...)
  12270. }
  12271. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  12272. // users can use type-assertion to append predicates that do not depend on any generated package.
  12273. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  12274. p := make([]predicate.Employee, len(ps))
  12275. for i := range ps {
  12276. p[i] = ps[i]
  12277. }
  12278. m.Where(p...)
  12279. }
  12280. // Op returns the operation name.
  12281. func (m *EmployeeMutation) Op() Op {
  12282. return m.op
  12283. }
  12284. // SetOp allows setting the mutation operation.
  12285. func (m *EmployeeMutation) SetOp(op Op) {
  12286. m.op = op
  12287. }
  12288. // Type returns the node type of this mutation (Employee).
  12289. func (m *EmployeeMutation) Type() string {
  12290. return m.typ
  12291. }
  12292. // Fields returns all fields that were changed during this mutation. Note that in
  12293. // order to get all numeric fields that were incremented/decremented, call
  12294. // AddedFields().
  12295. func (m *EmployeeMutation) Fields() []string {
  12296. fields := make([]string, 0, 23)
  12297. if m.created_at != nil {
  12298. fields = append(fields, employee.FieldCreatedAt)
  12299. }
  12300. if m.updated_at != nil {
  12301. fields = append(fields, employee.FieldUpdatedAt)
  12302. }
  12303. if m.deleted_at != nil {
  12304. fields = append(fields, employee.FieldDeletedAt)
  12305. }
  12306. if m.title != nil {
  12307. fields = append(fields, employee.FieldTitle)
  12308. }
  12309. if m.avatar != nil {
  12310. fields = append(fields, employee.FieldAvatar)
  12311. }
  12312. if m.tags != nil {
  12313. fields = append(fields, employee.FieldTags)
  12314. }
  12315. if m.hire_count != nil {
  12316. fields = append(fields, employee.FieldHireCount)
  12317. }
  12318. if m.service_count != nil {
  12319. fields = append(fields, employee.FieldServiceCount)
  12320. }
  12321. if m.achievement_count != nil {
  12322. fields = append(fields, employee.FieldAchievementCount)
  12323. }
  12324. if m.intro != nil {
  12325. fields = append(fields, employee.FieldIntro)
  12326. }
  12327. if m.estimate != nil {
  12328. fields = append(fields, employee.FieldEstimate)
  12329. }
  12330. if m.skill != nil {
  12331. fields = append(fields, employee.FieldSkill)
  12332. }
  12333. if m.ability_type != nil {
  12334. fields = append(fields, employee.FieldAbilityType)
  12335. }
  12336. if m.scene != nil {
  12337. fields = append(fields, employee.FieldScene)
  12338. }
  12339. if m.switch_in != nil {
  12340. fields = append(fields, employee.FieldSwitchIn)
  12341. }
  12342. if m.video_url != nil {
  12343. fields = append(fields, employee.FieldVideoURL)
  12344. }
  12345. if m.organization_id != nil {
  12346. fields = append(fields, employee.FieldOrganizationID)
  12347. }
  12348. if m.category_id != nil {
  12349. fields = append(fields, employee.FieldCategoryID)
  12350. }
  12351. if m.api_base != nil {
  12352. fields = append(fields, employee.FieldAPIBase)
  12353. }
  12354. if m.api_key != nil {
  12355. fields = append(fields, employee.FieldAPIKey)
  12356. }
  12357. if m.ai_info != nil {
  12358. fields = append(fields, employee.FieldAiInfo)
  12359. }
  12360. if m.is_vip != nil {
  12361. fields = append(fields, employee.FieldIsVip)
  12362. }
  12363. if m.chat_url != nil {
  12364. fields = append(fields, employee.FieldChatURL)
  12365. }
  12366. return fields
  12367. }
  12368. // Field returns the value of a field with the given name. The second boolean
  12369. // return value indicates that this field was not set, or was not defined in the
  12370. // schema.
  12371. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  12372. switch name {
  12373. case employee.FieldCreatedAt:
  12374. return m.CreatedAt()
  12375. case employee.FieldUpdatedAt:
  12376. return m.UpdatedAt()
  12377. case employee.FieldDeletedAt:
  12378. return m.DeletedAt()
  12379. case employee.FieldTitle:
  12380. return m.Title()
  12381. case employee.FieldAvatar:
  12382. return m.Avatar()
  12383. case employee.FieldTags:
  12384. return m.Tags()
  12385. case employee.FieldHireCount:
  12386. return m.HireCount()
  12387. case employee.FieldServiceCount:
  12388. return m.ServiceCount()
  12389. case employee.FieldAchievementCount:
  12390. return m.AchievementCount()
  12391. case employee.FieldIntro:
  12392. return m.Intro()
  12393. case employee.FieldEstimate:
  12394. return m.Estimate()
  12395. case employee.FieldSkill:
  12396. return m.Skill()
  12397. case employee.FieldAbilityType:
  12398. return m.AbilityType()
  12399. case employee.FieldScene:
  12400. return m.Scene()
  12401. case employee.FieldSwitchIn:
  12402. return m.SwitchIn()
  12403. case employee.FieldVideoURL:
  12404. return m.VideoURL()
  12405. case employee.FieldOrganizationID:
  12406. return m.OrganizationID()
  12407. case employee.FieldCategoryID:
  12408. return m.CategoryID()
  12409. case employee.FieldAPIBase:
  12410. return m.APIBase()
  12411. case employee.FieldAPIKey:
  12412. return m.APIKey()
  12413. case employee.FieldAiInfo:
  12414. return m.AiInfo()
  12415. case employee.FieldIsVip:
  12416. return m.IsVip()
  12417. case employee.FieldChatURL:
  12418. return m.ChatURL()
  12419. }
  12420. return nil, false
  12421. }
  12422. // OldField returns the old value of the field from the database. An error is
  12423. // returned if the mutation operation is not UpdateOne, or the query to the
  12424. // database failed.
  12425. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12426. switch name {
  12427. case employee.FieldCreatedAt:
  12428. return m.OldCreatedAt(ctx)
  12429. case employee.FieldUpdatedAt:
  12430. return m.OldUpdatedAt(ctx)
  12431. case employee.FieldDeletedAt:
  12432. return m.OldDeletedAt(ctx)
  12433. case employee.FieldTitle:
  12434. return m.OldTitle(ctx)
  12435. case employee.FieldAvatar:
  12436. return m.OldAvatar(ctx)
  12437. case employee.FieldTags:
  12438. return m.OldTags(ctx)
  12439. case employee.FieldHireCount:
  12440. return m.OldHireCount(ctx)
  12441. case employee.FieldServiceCount:
  12442. return m.OldServiceCount(ctx)
  12443. case employee.FieldAchievementCount:
  12444. return m.OldAchievementCount(ctx)
  12445. case employee.FieldIntro:
  12446. return m.OldIntro(ctx)
  12447. case employee.FieldEstimate:
  12448. return m.OldEstimate(ctx)
  12449. case employee.FieldSkill:
  12450. return m.OldSkill(ctx)
  12451. case employee.FieldAbilityType:
  12452. return m.OldAbilityType(ctx)
  12453. case employee.FieldScene:
  12454. return m.OldScene(ctx)
  12455. case employee.FieldSwitchIn:
  12456. return m.OldSwitchIn(ctx)
  12457. case employee.FieldVideoURL:
  12458. return m.OldVideoURL(ctx)
  12459. case employee.FieldOrganizationID:
  12460. return m.OldOrganizationID(ctx)
  12461. case employee.FieldCategoryID:
  12462. return m.OldCategoryID(ctx)
  12463. case employee.FieldAPIBase:
  12464. return m.OldAPIBase(ctx)
  12465. case employee.FieldAPIKey:
  12466. return m.OldAPIKey(ctx)
  12467. case employee.FieldAiInfo:
  12468. return m.OldAiInfo(ctx)
  12469. case employee.FieldIsVip:
  12470. return m.OldIsVip(ctx)
  12471. case employee.FieldChatURL:
  12472. return m.OldChatURL(ctx)
  12473. }
  12474. return nil, fmt.Errorf("unknown Employee field %s", name)
  12475. }
  12476. // SetField sets the value of a field with the given name. It returns an error if
  12477. // the field is not defined in the schema, or if the type mismatched the field
  12478. // type.
  12479. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  12480. switch name {
  12481. case employee.FieldCreatedAt:
  12482. v, ok := value.(time.Time)
  12483. if !ok {
  12484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12485. }
  12486. m.SetCreatedAt(v)
  12487. return nil
  12488. case employee.FieldUpdatedAt:
  12489. v, ok := value.(time.Time)
  12490. if !ok {
  12491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12492. }
  12493. m.SetUpdatedAt(v)
  12494. return nil
  12495. case employee.FieldDeletedAt:
  12496. v, ok := value.(time.Time)
  12497. if !ok {
  12498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12499. }
  12500. m.SetDeletedAt(v)
  12501. return nil
  12502. case employee.FieldTitle:
  12503. v, ok := value.(string)
  12504. if !ok {
  12505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12506. }
  12507. m.SetTitle(v)
  12508. return nil
  12509. case employee.FieldAvatar:
  12510. v, ok := value.(string)
  12511. if !ok {
  12512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12513. }
  12514. m.SetAvatar(v)
  12515. return nil
  12516. case employee.FieldTags:
  12517. v, ok := value.(string)
  12518. if !ok {
  12519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12520. }
  12521. m.SetTags(v)
  12522. return nil
  12523. case employee.FieldHireCount:
  12524. v, ok := value.(int)
  12525. if !ok {
  12526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12527. }
  12528. m.SetHireCount(v)
  12529. return nil
  12530. case employee.FieldServiceCount:
  12531. v, ok := value.(int)
  12532. if !ok {
  12533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12534. }
  12535. m.SetServiceCount(v)
  12536. return nil
  12537. case employee.FieldAchievementCount:
  12538. v, ok := value.(int)
  12539. if !ok {
  12540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12541. }
  12542. m.SetAchievementCount(v)
  12543. return nil
  12544. case employee.FieldIntro:
  12545. v, ok := value.(string)
  12546. if !ok {
  12547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12548. }
  12549. m.SetIntro(v)
  12550. return nil
  12551. case employee.FieldEstimate:
  12552. v, ok := value.(string)
  12553. if !ok {
  12554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12555. }
  12556. m.SetEstimate(v)
  12557. return nil
  12558. case employee.FieldSkill:
  12559. v, ok := value.(string)
  12560. if !ok {
  12561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12562. }
  12563. m.SetSkill(v)
  12564. return nil
  12565. case employee.FieldAbilityType:
  12566. v, ok := value.(string)
  12567. if !ok {
  12568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12569. }
  12570. m.SetAbilityType(v)
  12571. return nil
  12572. case employee.FieldScene:
  12573. v, ok := value.(string)
  12574. if !ok {
  12575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12576. }
  12577. m.SetScene(v)
  12578. return nil
  12579. case employee.FieldSwitchIn:
  12580. v, ok := value.(string)
  12581. if !ok {
  12582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12583. }
  12584. m.SetSwitchIn(v)
  12585. return nil
  12586. case employee.FieldVideoURL:
  12587. v, ok := value.(string)
  12588. if !ok {
  12589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12590. }
  12591. m.SetVideoURL(v)
  12592. return nil
  12593. case employee.FieldOrganizationID:
  12594. v, ok := value.(uint64)
  12595. if !ok {
  12596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12597. }
  12598. m.SetOrganizationID(v)
  12599. return nil
  12600. case employee.FieldCategoryID:
  12601. v, ok := value.(uint64)
  12602. if !ok {
  12603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12604. }
  12605. m.SetCategoryID(v)
  12606. return nil
  12607. case employee.FieldAPIBase:
  12608. v, ok := value.(string)
  12609. if !ok {
  12610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12611. }
  12612. m.SetAPIBase(v)
  12613. return nil
  12614. case employee.FieldAPIKey:
  12615. v, ok := value.(string)
  12616. if !ok {
  12617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12618. }
  12619. m.SetAPIKey(v)
  12620. return nil
  12621. case employee.FieldAiInfo:
  12622. v, ok := value.(string)
  12623. if !ok {
  12624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12625. }
  12626. m.SetAiInfo(v)
  12627. return nil
  12628. case employee.FieldIsVip:
  12629. v, ok := value.(int)
  12630. if !ok {
  12631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12632. }
  12633. m.SetIsVip(v)
  12634. return nil
  12635. case employee.FieldChatURL:
  12636. v, ok := value.(string)
  12637. if !ok {
  12638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12639. }
  12640. m.SetChatURL(v)
  12641. return nil
  12642. }
  12643. return fmt.Errorf("unknown Employee field %s", name)
  12644. }
  12645. // AddedFields returns all numeric fields that were incremented/decremented during
  12646. // this mutation.
  12647. func (m *EmployeeMutation) AddedFields() []string {
  12648. var fields []string
  12649. if m.addhire_count != nil {
  12650. fields = append(fields, employee.FieldHireCount)
  12651. }
  12652. if m.addservice_count != nil {
  12653. fields = append(fields, employee.FieldServiceCount)
  12654. }
  12655. if m.addachievement_count != nil {
  12656. fields = append(fields, employee.FieldAchievementCount)
  12657. }
  12658. if m.addorganization_id != nil {
  12659. fields = append(fields, employee.FieldOrganizationID)
  12660. }
  12661. if m.addcategory_id != nil {
  12662. fields = append(fields, employee.FieldCategoryID)
  12663. }
  12664. if m.addis_vip != nil {
  12665. fields = append(fields, employee.FieldIsVip)
  12666. }
  12667. return fields
  12668. }
  12669. // AddedField returns the numeric value that was incremented/decremented on a field
  12670. // with the given name. The second boolean return value indicates that this field
  12671. // was not set, or was not defined in the schema.
  12672. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  12673. switch name {
  12674. case employee.FieldHireCount:
  12675. return m.AddedHireCount()
  12676. case employee.FieldServiceCount:
  12677. return m.AddedServiceCount()
  12678. case employee.FieldAchievementCount:
  12679. return m.AddedAchievementCount()
  12680. case employee.FieldOrganizationID:
  12681. return m.AddedOrganizationID()
  12682. case employee.FieldCategoryID:
  12683. return m.AddedCategoryID()
  12684. case employee.FieldIsVip:
  12685. return m.AddedIsVip()
  12686. }
  12687. return nil, false
  12688. }
  12689. // AddField adds the value to the field with the given name. It returns an error if
  12690. // the field is not defined in the schema, or if the type mismatched the field
  12691. // type.
  12692. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  12693. switch name {
  12694. case employee.FieldHireCount:
  12695. v, ok := value.(int)
  12696. if !ok {
  12697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12698. }
  12699. m.AddHireCount(v)
  12700. return nil
  12701. case employee.FieldServiceCount:
  12702. v, ok := value.(int)
  12703. if !ok {
  12704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12705. }
  12706. m.AddServiceCount(v)
  12707. return nil
  12708. case employee.FieldAchievementCount:
  12709. v, ok := value.(int)
  12710. if !ok {
  12711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12712. }
  12713. m.AddAchievementCount(v)
  12714. return nil
  12715. case employee.FieldOrganizationID:
  12716. v, ok := value.(int64)
  12717. if !ok {
  12718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12719. }
  12720. m.AddOrganizationID(v)
  12721. return nil
  12722. case employee.FieldCategoryID:
  12723. v, ok := value.(int64)
  12724. if !ok {
  12725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12726. }
  12727. m.AddCategoryID(v)
  12728. return nil
  12729. case employee.FieldIsVip:
  12730. v, ok := value.(int)
  12731. if !ok {
  12732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12733. }
  12734. m.AddIsVip(v)
  12735. return nil
  12736. }
  12737. return fmt.Errorf("unknown Employee numeric field %s", name)
  12738. }
  12739. // ClearedFields returns all nullable fields that were cleared during this
  12740. // mutation.
  12741. func (m *EmployeeMutation) ClearedFields() []string {
  12742. var fields []string
  12743. if m.FieldCleared(employee.FieldDeletedAt) {
  12744. fields = append(fields, employee.FieldDeletedAt)
  12745. }
  12746. if m.FieldCleared(employee.FieldAiInfo) {
  12747. fields = append(fields, employee.FieldAiInfo)
  12748. }
  12749. return fields
  12750. }
  12751. // FieldCleared returns a boolean indicating if a field with the given name was
  12752. // cleared in this mutation.
  12753. func (m *EmployeeMutation) FieldCleared(name string) bool {
  12754. _, ok := m.clearedFields[name]
  12755. return ok
  12756. }
  12757. // ClearField clears the value of the field with the given name. It returns an
  12758. // error if the field is not defined in the schema.
  12759. func (m *EmployeeMutation) ClearField(name string) error {
  12760. switch name {
  12761. case employee.FieldDeletedAt:
  12762. m.ClearDeletedAt()
  12763. return nil
  12764. case employee.FieldAiInfo:
  12765. m.ClearAiInfo()
  12766. return nil
  12767. }
  12768. return fmt.Errorf("unknown Employee nullable field %s", name)
  12769. }
  12770. // ResetField resets all changes in the mutation for the field with the given name.
  12771. // It returns an error if the field is not defined in the schema.
  12772. func (m *EmployeeMutation) ResetField(name string) error {
  12773. switch name {
  12774. case employee.FieldCreatedAt:
  12775. m.ResetCreatedAt()
  12776. return nil
  12777. case employee.FieldUpdatedAt:
  12778. m.ResetUpdatedAt()
  12779. return nil
  12780. case employee.FieldDeletedAt:
  12781. m.ResetDeletedAt()
  12782. return nil
  12783. case employee.FieldTitle:
  12784. m.ResetTitle()
  12785. return nil
  12786. case employee.FieldAvatar:
  12787. m.ResetAvatar()
  12788. return nil
  12789. case employee.FieldTags:
  12790. m.ResetTags()
  12791. return nil
  12792. case employee.FieldHireCount:
  12793. m.ResetHireCount()
  12794. return nil
  12795. case employee.FieldServiceCount:
  12796. m.ResetServiceCount()
  12797. return nil
  12798. case employee.FieldAchievementCount:
  12799. m.ResetAchievementCount()
  12800. return nil
  12801. case employee.FieldIntro:
  12802. m.ResetIntro()
  12803. return nil
  12804. case employee.FieldEstimate:
  12805. m.ResetEstimate()
  12806. return nil
  12807. case employee.FieldSkill:
  12808. m.ResetSkill()
  12809. return nil
  12810. case employee.FieldAbilityType:
  12811. m.ResetAbilityType()
  12812. return nil
  12813. case employee.FieldScene:
  12814. m.ResetScene()
  12815. return nil
  12816. case employee.FieldSwitchIn:
  12817. m.ResetSwitchIn()
  12818. return nil
  12819. case employee.FieldVideoURL:
  12820. m.ResetVideoURL()
  12821. return nil
  12822. case employee.FieldOrganizationID:
  12823. m.ResetOrganizationID()
  12824. return nil
  12825. case employee.FieldCategoryID:
  12826. m.ResetCategoryID()
  12827. return nil
  12828. case employee.FieldAPIBase:
  12829. m.ResetAPIBase()
  12830. return nil
  12831. case employee.FieldAPIKey:
  12832. m.ResetAPIKey()
  12833. return nil
  12834. case employee.FieldAiInfo:
  12835. m.ResetAiInfo()
  12836. return nil
  12837. case employee.FieldIsVip:
  12838. m.ResetIsVip()
  12839. return nil
  12840. case employee.FieldChatURL:
  12841. m.ResetChatURL()
  12842. return nil
  12843. }
  12844. return fmt.Errorf("unknown Employee field %s", name)
  12845. }
  12846. // AddedEdges returns all edge names that were set/added in this mutation.
  12847. func (m *EmployeeMutation) AddedEdges() []string {
  12848. edges := make([]string, 0, 2)
  12849. if m.em_work_experiences != nil {
  12850. edges = append(edges, employee.EdgeEmWorkExperiences)
  12851. }
  12852. if m.em_tutorial != nil {
  12853. edges = append(edges, employee.EdgeEmTutorial)
  12854. }
  12855. return edges
  12856. }
  12857. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12858. // name in this mutation.
  12859. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  12860. switch name {
  12861. case employee.EdgeEmWorkExperiences:
  12862. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  12863. for id := range m.em_work_experiences {
  12864. ids = append(ids, id)
  12865. }
  12866. return ids
  12867. case employee.EdgeEmTutorial:
  12868. ids := make([]ent.Value, 0, len(m.em_tutorial))
  12869. for id := range m.em_tutorial {
  12870. ids = append(ids, id)
  12871. }
  12872. return ids
  12873. }
  12874. return nil
  12875. }
  12876. // RemovedEdges returns all edge names that were removed in this mutation.
  12877. func (m *EmployeeMutation) RemovedEdges() []string {
  12878. edges := make([]string, 0, 2)
  12879. if m.removedem_work_experiences != nil {
  12880. edges = append(edges, employee.EdgeEmWorkExperiences)
  12881. }
  12882. if m.removedem_tutorial != nil {
  12883. edges = append(edges, employee.EdgeEmTutorial)
  12884. }
  12885. return edges
  12886. }
  12887. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12888. // the given name in this mutation.
  12889. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  12890. switch name {
  12891. case employee.EdgeEmWorkExperiences:
  12892. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  12893. for id := range m.removedem_work_experiences {
  12894. ids = append(ids, id)
  12895. }
  12896. return ids
  12897. case employee.EdgeEmTutorial:
  12898. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  12899. for id := range m.removedem_tutorial {
  12900. ids = append(ids, id)
  12901. }
  12902. return ids
  12903. }
  12904. return nil
  12905. }
  12906. // ClearedEdges returns all edge names that were cleared in this mutation.
  12907. func (m *EmployeeMutation) ClearedEdges() []string {
  12908. edges := make([]string, 0, 2)
  12909. if m.clearedem_work_experiences {
  12910. edges = append(edges, employee.EdgeEmWorkExperiences)
  12911. }
  12912. if m.clearedem_tutorial {
  12913. edges = append(edges, employee.EdgeEmTutorial)
  12914. }
  12915. return edges
  12916. }
  12917. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12918. // was cleared in this mutation.
  12919. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  12920. switch name {
  12921. case employee.EdgeEmWorkExperiences:
  12922. return m.clearedem_work_experiences
  12923. case employee.EdgeEmTutorial:
  12924. return m.clearedem_tutorial
  12925. }
  12926. return false
  12927. }
  12928. // ClearEdge clears the value of the edge with the given name. It returns an error
  12929. // if that edge is not defined in the schema.
  12930. func (m *EmployeeMutation) ClearEdge(name string) error {
  12931. switch name {
  12932. }
  12933. return fmt.Errorf("unknown Employee unique edge %s", name)
  12934. }
  12935. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12936. // It returns an error if the edge is not defined in the schema.
  12937. func (m *EmployeeMutation) ResetEdge(name string) error {
  12938. switch name {
  12939. case employee.EdgeEmWorkExperiences:
  12940. m.ResetEmWorkExperiences()
  12941. return nil
  12942. case employee.EdgeEmTutorial:
  12943. m.ResetEmTutorial()
  12944. return nil
  12945. }
  12946. return fmt.Errorf("unknown Employee edge %s", name)
  12947. }
  12948. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  12949. type EmployeeConfigMutation struct {
  12950. config
  12951. op Op
  12952. typ string
  12953. id *uint64
  12954. created_at *time.Time
  12955. updated_at *time.Time
  12956. deleted_at *time.Time
  12957. stype *string
  12958. title *string
  12959. photo *string
  12960. organization_id *uint64
  12961. addorganization_id *int64
  12962. clearedFields map[string]struct{}
  12963. done bool
  12964. oldValue func(context.Context) (*EmployeeConfig, error)
  12965. predicates []predicate.EmployeeConfig
  12966. }
  12967. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  12968. // employeeconfigOption allows management of the mutation configuration using functional options.
  12969. type employeeconfigOption func(*EmployeeConfigMutation)
  12970. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  12971. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  12972. m := &EmployeeConfigMutation{
  12973. config: c,
  12974. op: op,
  12975. typ: TypeEmployeeConfig,
  12976. clearedFields: make(map[string]struct{}),
  12977. }
  12978. for _, opt := range opts {
  12979. opt(m)
  12980. }
  12981. return m
  12982. }
  12983. // withEmployeeConfigID sets the ID field of the mutation.
  12984. func withEmployeeConfigID(id uint64) employeeconfigOption {
  12985. return func(m *EmployeeConfigMutation) {
  12986. var (
  12987. err error
  12988. once sync.Once
  12989. value *EmployeeConfig
  12990. )
  12991. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  12992. once.Do(func() {
  12993. if m.done {
  12994. err = errors.New("querying old values post mutation is not allowed")
  12995. } else {
  12996. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  12997. }
  12998. })
  12999. return value, err
  13000. }
  13001. m.id = &id
  13002. }
  13003. }
  13004. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  13005. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  13006. return func(m *EmployeeConfigMutation) {
  13007. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  13008. return node, nil
  13009. }
  13010. m.id = &node.ID
  13011. }
  13012. }
  13013. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13014. // executed in a transaction (ent.Tx), a transactional client is returned.
  13015. func (m EmployeeConfigMutation) Client() *Client {
  13016. client := &Client{config: m.config}
  13017. client.init()
  13018. return client
  13019. }
  13020. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13021. // it returns an error otherwise.
  13022. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  13023. if _, ok := m.driver.(*txDriver); !ok {
  13024. return nil, errors.New("ent: mutation is not running in a transaction")
  13025. }
  13026. tx := &Tx{config: m.config}
  13027. tx.init()
  13028. return tx, nil
  13029. }
  13030. // SetID sets the value of the id field. Note that this
  13031. // operation is only accepted on creation of EmployeeConfig entities.
  13032. func (m *EmployeeConfigMutation) SetID(id uint64) {
  13033. m.id = &id
  13034. }
  13035. // ID returns the ID value in the mutation. Note that the ID is only available
  13036. // if it was provided to the builder or after it was returned from the database.
  13037. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  13038. if m.id == nil {
  13039. return
  13040. }
  13041. return *m.id, true
  13042. }
  13043. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13044. // That means, if the mutation is applied within a transaction with an isolation level such
  13045. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13046. // or updated by the mutation.
  13047. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  13048. switch {
  13049. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13050. id, exists := m.ID()
  13051. if exists {
  13052. return []uint64{id}, nil
  13053. }
  13054. fallthrough
  13055. case m.op.Is(OpUpdate | OpDelete):
  13056. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  13057. default:
  13058. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13059. }
  13060. }
  13061. // SetCreatedAt sets the "created_at" field.
  13062. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  13063. m.created_at = &t
  13064. }
  13065. // CreatedAt returns the value of the "created_at" field in the mutation.
  13066. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  13067. v := m.created_at
  13068. if v == nil {
  13069. return
  13070. }
  13071. return *v, true
  13072. }
  13073. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  13074. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13076. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13077. if !m.op.Is(OpUpdateOne) {
  13078. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13079. }
  13080. if m.id == nil || m.oldValue == nil {
  13081. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13082. }
  13083. oldValue, err := m.oldValue(ctx)
  13084. if err != nil {
  13085. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13086. }
  13087. return oldValue.CreatedAt, nil
  13088. }
  13089. // ResetCreatedAt resets all changes to the "created_at" field.
  13090. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  13091. m.created_at = nil
  13092. }
  13093. // SetUpdatedAt sets the "updated_at" field.
  13094. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  13095. m.updated_at = &t
  13096. }
  13097. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13098. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  13099. v := m.updated_at
  13100. if v == nil {
  13101. return
  13102. }
  13103. return *v, true
  13104. }
  13105. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  13106. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13108. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13109. if !m.op.Is(OpUpdateOne) {
  13110. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13111. }
  13112. if m.id == nil || m.oldValue == nil {
  13113. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13114. }
  13115. oldValue, err := m.oldValue(ctx)
  13116. if err != nil {
  13117. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13118. }
  13119. return oldValue.UpdatedAt, nil
  13120. }
  13121. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13122. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  13123. m.updated_at = nil
  13124. }
  13125. // SetDeletedAt sets the "deleted_at" field.
  13126. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  13127. m.deleted_at = &t
  13128. }
  13129. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13130. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  13131. v := m.deleted_at
  13132. if v == nil {
  13133. return
  13134. }
  13135. return *v, true
  13136. }
  13137. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  13138. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13140. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13141. if !m.op.Is(OpUpdateOne) {
  13142. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13143. }
  13144. if m.id == nil || m.oldValue == nil {
  13145. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13146. }
  13147. oldValue, err := m.oldValue(ctx)
  13148. if err != nil {
  13149. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13150. }
  13151. return oldValue.DeletedAt, nil
  13152. }
  13153. // ClearDeletedAt clears the value of the "deleted_at" field.
  13154. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  13155. m.deleted_at = nil
  13156. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  13157. }
  13158. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13159. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  13160. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  13161. return ok
  13162. }
  13163. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13164. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  13165. m.deleted_at = nil
  13166. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  13167. }
  13168. // SetStype sets the "stype" field.
  13169. func (m *EmployeeConfigMutation) SetStype(s string) {
  13170. m.stype = &s
  13171. }
  13172. // Stype returns the value of the "stype" field in the mutation.
  13173. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  13174. v := m.stype
  13175. if v == nil {
  13176. return
  13177. }
  13178. return *v, true
  13179. }
  13180. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  13181. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13183. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  13184. if !m.op.Is(OpUpdateOne) {
  13185. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  13186. }
  13187. if m.id == nil || m.oldValue == nil {
  13188. return v, errors.New("OldStype requires an ID field in the mutation")
  13189. }
  13190. oldValue, err := m.oldValue(ctx)
  13191. if err != nil {
  13192. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  13193. }
  13194. return oldValue.Stype, nil
  13195. }
  13196. // ResetStype resets all changes to the "stype" field.
  13197. func (m *EmployeeConfigMutation) ResetStype() {
  13198. m.stype = nil
  13199. }
  13200. // SetTitle sets the "title" field.
  13201. func (m *EmployeeConfigMutation) SetTitle(s string) {
  13202. m.title = &s
  13203. }
  13204. // Title returns the value of the "title" field in the mutation.
  13205. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  13206. v := m.title
  13207. if v == nil {
  13208. return
  13209. }
  13210. return *v, true
  13211. }
  13212. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  13213. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13215. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  13216. if !m.op.Is(OpUpdateOne) {
  13217. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13218. }
  13219. if m.id == nil || m.oldValue == nil {
  13220. return v, errors.New("OldTitle requires an ID field in the mutation")
  13221. }
  13222. oldValue, err := m.oldValue(ctx)
  13223. if err != nil {
  13224. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13225. }
  13226. return oldValue.Title, nil
  13227. }
  13228. // ResetTitle resets all changes to the "title" field.
  13229. func (m *EmployeeConfigMutation) ResetTitle() {
  13230. m.title = nil
  13231. }
  13232. // SetPhoto sets the "photo" field.
  13233. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  13234. m.photo = &s
  13235. }
  13236. // Photo returns the value of the "photo" field in the mutation.
  13237. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  13238. v := m.photo
  13239. if v == nil {
  13240. return
  13241. }
  13242. return *v, true
  13243. }
  13244. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  13245. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13247. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  13248. if !m.op.Is(OpUpdateOne) {
  13249. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  13250. }
  13251. if m.id == nil || m.oldValue == nil {
  13252. return v, errors.New("OldPhoto requires an ID field in the mutation")
  13253. }
  13254. oldValue, err := m.oldValue(ctx)
  13255. if err != nil {
  13256. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  13257. }
  13258. return oldValue.Photo, nil
  13259. }
  13260. // ResetPhoto resets all changes to the "photo" field.
  13261. func (m *EmployeeConfigMutation) ResetPhoto() {
  13262. m.photo = nil
  13263. }
  13264. // SetOrganizationID sets the "organization_id" field.
  13265. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  13266. m.organization_id = &u
  13267. m.addorganization_id = nil
  13268. }
  13269. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13270. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  13271. v := m.organization_id
  13272. if v == nil {
  13273. return
  13274. }
  13275. return *v, true
  13276. }
  13277. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  13278. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13280. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13281. if !m.op.Is(OpUpdateOne) {
  13282. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13283. }
  13284. if m.id == nil || m.oldValue == nil {
  13285. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13286. }
  13287. oldValue, err := m.oldValue(ctx)
  13288. if err != nil {
  13289. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13290. }
  13291. return oldValue.OrganizationID, nil
  13292. }
  13293. // AddOrganizationID adds u to the "organization_id" field.
  13294. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  13295. if m.addorganization_id != nil {
  13296. *m.addorganization_id += u
  13297. } else {
  13298. m.addorganization_id = &u
  13299. }
  13300. }
  13301. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13302. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  13303. v := m.addorganization_id
  13304. if v == nil {
  13305. return
  13306. }
  13307. return *v, true
  13308. }
  13309. // ClearOrganizationID clears the value of the "organization_id" field.
  13310. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  13311. m.organization_id = nil
  13312. m.addorganization_id = nil
  13313. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  13314. }
  13315. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13316. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  13317. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  13318. return ok
  13319. }
  13320. // ResetOrganizationID resets all changes to the "organization_id" field.
  13321. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  13322. m.organization_id = nil
  13323. m.addorganization_id = nil
  13324. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  13325. }
  13326. // Where appends a list predicates to the EmployeeConfigMutation builder.
  13327. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  13328. m.predicates = append(m.predicates, ps...)
  13329. }
  13330. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  13331. // users can use type-assertion to append predicates that do not depend on any generated package.
  13332. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  13333. p := make([]predicate.EmployeeConfig, len(ps))
  13334. for i := range ps {
  13335. p[i] = ps[i]
  13336. }
  13337. m.Where(p...)
  13338. }
  13339. // Op returns the operation name.
  13340. func (m *EmployeeConfigMutation) Op() Op {
  13341. return m.op
  13342. }
  13343. // SetOp allows setting the mutation operation.
  13344. func (m *EmployeeConfigMutation) SetOp(op Op) {
  13345. m.op = op
  13346. }
  13347. // Type returns the node type of this mutation (EmployeeConfig).
  13348. func (m *EmployeeConfigMutation) Type() string {
  13349. return m.typ
  13350. }
  13351. // Fields returns all fields that were changed during this mutation. Note that in
  13352. // order to get all numeric fields that were incremented/decremented, call
  13353. // AddedFields().
  13354. func (m *EmployeeConfigMutation) Fields() []string {
  13355. fields := make([]string, 0, 7)
  13356. if m.created_at != nil {
  13357. fields = append(fields, employeeconfig.FieldCreatedAt)
  13358. }
  13359. if m.updated_at != nil {
  13360. fields = append(fields, employeeconfig.FieldUpdatedAt)
  13361. }
  13362. if m.deleted_at != nil {
  13363. fields = append(fields, employeeconfig.FieldDeletedAt)
  13364. }
  13365. if m.stype != nil {
  13366. fields = append(fields, employeeconfig.FieldStype)
  13367. }
  13368. if m.title != nil {
  13369. fields = append(fields, employeeconfig.FieldTitle)
  13370. }
  13371. if m.photo != nil {
  13372. fields = append(fields, employeeconfig.FieldPhoto)
  13373. }
  13374. if m.organization_id != nil {
  13375. fields = append(fields, employeeconfig.FieldOrganizationID)
  13376. }
  13377. return fields
  13378. }
  13379. // Field returns the value of a field with the given name. The second boolean
  13380. // return value indicates that this field was not set, or was not defined in the
  13381. // schema.
  13382. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  13383. switch name {
  13384. case employeeconfig.FieldCreatedAt:
  13385. return m.CreatedAt()
  13386. case employeeconfig.FieldUpdatedAt:
  13387. return m.UpdatedAt()
  13388. case employeeconfig.FieldDeletedAt:
  13389. return m.DeletedAt()
  13390. case employeeconfig.FieldStype:
  13391. return m.Stype()
  13392. case employeeconfig.FieldTitle:
  13393. return m.Title()
  13394. case employeeconfig.FieldPhoto:
  13395. return m.Photo()
  13396. case employeeconfig.FieldOrganizationID:
  13397. return m.OrganizationID()
  13398. }
  13399. return nil, false
  13400. }
  13401. // OldField returns the old value of the field from the database. An error is
  13402. // returned if the mutation operation is not UpdateOne, or the query to the
  13403. // database failed.
  13404. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13405. switch name {
  13406. case employeeconfig.FieldCreatedAt:
  13407. return m.OldCreatedAt(ctx)
  13408. case employeeconfig.FieldUpdatedAt:
  13409. return m.OldUpdatedAt(ctx)
  13410. case employeeconfig.FieldDeletedAt:
  13411. return m.OldDeletedAt(ctx)
  13412. case employeeconfig.FieldStype:
  13413. return m.OldStype(ctx)
  13414. case employeeconfig.FieldTitle:
  13415. return m.OldTitle(ctx)
  13416. case employeeconfig.FieldPhoto:
  13417. return m.OldPhoto(ctx)
  13418. case employeeconfig.FieldOrganizationID:
  13419. return m.OldOrganizationID(ctx)
  13420. }
  13421. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  13422. }
  13423. // SetField sets the value of a field with the given name. It returns an error if
  13424. // the field is not defined in the schema, or if the type mismatched the field
  13425. // type.
  13426. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  13427. switch name {
  13428. case employeeconfig.FieldCreatedAt:
  13429. v, ok := value.(time.Time)
  13430. if !ok {
  13431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13432. }
  13433. m.SetCreatedAt(v)
  13434. return nil
  13435. case employeeconfig.FieldUpdatedAt:
  13436. v, ok := value.(time.Time)
  13437. if !ok {
  13438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13439. }
  13440. m.SetUpdatedAt(v)
  13441. return nil
  13442. case employeeconfig.FieldDeletedAt:
  13443. v, ok := value.(time.Time)
  13444. if !ok {
  13445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13446. }
  13447. m.SetDeletedAt(v)
  13448. return nil
  13449. case employeeconfig.FieldStype:
  13450. v, ok := value.(string)
  13451. if !ok {
  13452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13453. }
  13454. m.SetStype(v)
  13455. return nil
  13456. case employeeconfig.FieldTitle:
  13457. v, ok := value.(string)
  13458. if !ok {
  13459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13460. }
  13461. m.SetTitle(v)
  13462. return nil
  13463. case employeeconfig.FieldPhoto:
  13464. v, ok := value.(string)
  13465. if !ok {
  13466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13467. }
  13468. m.SetPhoto(v)
  13469. return nil
  13470. case employeeconfig.FieldOrganizationID:
  13471. v, ok := value.(uint64)
  13472. if !ok {
  13473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13474. }
  13475. m.SetOrganizationID(v)
  13476. return nil
  13477. }
  13478. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13479. }
  13480. // AddedFields returns all numeric fields that were incremented/decremented during
  13481. // this mutation.
  13482. func (m *EmployeeConfigMutation) AddedFields() []string {
  13483. var fields []string
  13484. if m.addorganization_id != nil {
  13485. fields = append(fields, employeeconfig.FieldOrganizationID)
  13486. }
  13487. return fields
  13488. }
  13489. // AddedField returns the numeric value that was incremented/decremented on a field
  13490. // with the given name. The second boolean return value indicates that this field
  13491. // was not set, or was not defined in the schema.
  13492. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  13493. switch name {
  13494. case employeeconfig.FieldOrganizationID:
  13495. return m.AddedOrganizationID()
  13496. }
  13497. return nil, false
  13498. }
  13499. // AddField adds the value to the field with the given name. It returns an error if
  13500. // the field is not defined in the schema, or if the type mismatched the field
  13501. // type.
  13502. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  13503. switch name {
  13504. case employeeconfig.FieldOrganizationID:
  13505. v, ok := value.(int64)
  13506. if !ok {
  13507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13508. }
  13509. m.AddOrganizationID(v)
  13510. return nil
  13511. }
  13512. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  13513. }
  13514. // ClearedFields returns all nullable fields that were cleared during this
  13515. // mutation.
  13516. func (m *EmployeeConfigMutation) ClearedFields() []string {
  13517. var fields []string
  13518. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  13519. fields = append(fields, employeeconfig.FieldDeletedAt)
  13520. }
  13521. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  13522. fields = append(fields, employeeconfig.FieldOrganizationID)
  13523. }
  13524. return fields
  13525. }
  13526. // FieldCleared returns a boolean indicating if a field with the given name was
  13527. // cleared in this mutation.
  13528. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  13529. _, ok := m.clearedFields[name]
  13530. return ok
  13531. }
  13532. // ClearField clears the value of the field with the given name. It returns an
  13533. // error if the field is not defined in the schema.
  13534. func (m *EmployeeConfigMutation) ClearField(name string) error {
  13535. switch name {
  13536. case employeeconfig.FieldDeletedAt:
  13537. m.ClearDeletedAt()
  13538. return nil
  13539. case employeeconfig.FieldOrganizationID:
  13540. m.ClearOrganizationID()
  13541. return nil
  13542. }
  13543. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  13544. }
  13545. // ResetField resets all changes in the mutation for the field with the given name.
  13546. // It returns an error if the field is not defined in the schema.
  13547. func (m *EmployeeConfigMutation) ResetField(name string) error {
  13548. switch name {
  13549. case employeeconfig.FieldCreatedAt:
  13550. m.ResetCreatedAt()
  13551. return nil
  13552. case employeeconfig.FieldUpdatedAt:
  13553. m.ResetUpdatedAt()
  13554. return nil
  13555. case employeeconfig.FieldDeletedAt:
  13556. m.ResetDeletedAt()
  13557. return nil
  13558. case employeeconfig.FieldStype:
  13559. m.ResetStype()
  13560. return nil
  13561. case employeeconfig.FieldTitle:
  13562. m.ResetTitle()
  13563. return nil
  13564. case employeeconfig.FieldPhoto:
  13565. m.ResetPhoto()
  13566. return nil
  13567. case employeeconfig.FieldOrganizationID:
  13568. m.ResetOrganizationID()
  13569. return nil
  13570. }
  13571. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13572. }
  13573. // AddedEdges returns all edge names that were set/added in this mutation.
  13574. func (m *EmployeeConfigMutation) AddedEdges() []string {
  13575. edges := make([]string, 0, 0)
  13576. return edges
  13577. }
  13578. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13579. // name in this mutation.
  13580. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  13581. return nil
  13582. }
  13583. // RemovedEdges returns all edge names that were removed in this mutation.
  13584. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  13585. edges := make([]string, 0, 0)
  13586. return edges
  13587. }
  13588. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13589. // the given name in this mutation.
  13590. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  13591. return nil
  13592. }
  13593. // ClearedEdges returns all edge names that were cleared in this mutation.
  13594. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  13595. edges := make([]string, 0, 0)
  13596. return edges
  13597. }
  13598. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13599. // was cleared in this mutation.
  13600. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  13601. return false
  13602. }
  13603. // ClearEdge clears the value of the edge with the given name. It returns an error
  13604. // if that edge is not defined in the schema.
  13605. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  13606. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  13607. }
  13608. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13609. // It returns an error if the edge is not defined in the schema.
  13610. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  13611. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  13612. }
  13613. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  13614. type LabelMutation struct {
  13615. config
  13616. op Op
  13617. typ string
  13618. id *uint64
  13619. created_at *time.Time
  13620. updated_at *time.Time
  13621. status *uint8
  13622. addstatus *int8
  13623. _type *int
  13624. add_type *int
  13625. name *string
  13626. from *int
  13627. addfrom *int
  13628. mode *int
  13629. addmode *int
  13630. conditions *string
  13631. organization_id *uint64
  13632. addorganization_id *int64
  13633. clearedFields map[string]struct{}
  13634. label_relationships map[uint64]struct{}
  13635. removedlabel_relationships map[uint64]struct{}
  13636. clearedlabel_relationships bool
  13637. done bool
  13638. oldValue func(context.Context) (*Label, error)
  13639. predicates []predicate.Label
  13640. }
  13641. var _ ent.Mutation = (*LabelMutation)(nil)
  13642. // labelOption allows management of the mutation configuration using functional options.
  13643. type labelOption func(*LabelMutation)
  13644. // newLabelMutation creates new mutation for the Label entity.
  13645. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  13646. m := &LabelMutation{
  13647. config: c,
  13648. op: op,
  13649. typ: TypeLabel,
  13650. clearedFields: make(map[string]struct{}),
  13651. }
  13652. for _, opt := range opts {
  13653. opt(m)
  13654. }
  13655. return m
  13656. }
  13657. // withLabelID sets the ID field of the mutation.
  13658. func withLabelID(id uint64) labelOption {
  13659. return func(m *LabelMutation) {
  13660. var (
  13661. err error
  13662. once sync.Once
  13663. value *Label
  13664. )
  13665. m.oldValue = func(ctx context.Context) (*Label, error) {
  13666. once.Do(func() {
  13667. if m.done {
  13668. err = errors.New("querying old values post mutation is not allowed")
  13669. } else {
  13670. value, err = m.Client().Label.Get(ctx, id)
  13671. }
  13672. })
  13673. return value, err
  13674. }
  13675. m.id = &id
  13676. }
  13677. }
  13678. // withLabel sets the old Label of the mutation.
  13679. func withLabel(node *Label) labelOption {
  13680. return func(m *LabelMutation) {
  13681. m.oldValue = func(context.Context) (*Label, error) {
  13682. return node, nil
  13683. }
  13684. m.id = &node.ID
  13685. }
  13686. }
  13687. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13688. // executed in a transaction (ent.Tx), a transactional client is returned.
  13689. func (m LabelMutation) Client() *Client {
  13690. client := &Client{config: m.config}
  13691. client.init()
  13692. return client
  13693. }
  13694. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13695. // it returns an error otherwise.
  13696. func (m LabelMutation) Tx() (*Tx, error) {
  13697. if _, ok := m.driver.(*txDriver); !ok {
  13698. return nil, errors.New("ent: mutation is not running in a transaction")
  13699. }
  13700. tx := &Tx{config: m.config}
  13701. tx.init()
  13702. return tx, nil
  13703. }
  13704. // SetID sets the value of the id field. Note that this
  13705. // operation is only accepted on creation of Label entities.
  13706. func (m *LabelMutation) SetID(id uint64) {
  13707. m.id = &id
  13708. }
  13709. // ID returns the ID value in the mutation. Note that the ID is only available
  13710. // if it was provided to the builder or after it was returned from the database.
  13711. func (m *LabelMutation) ID() (id uint64, exists bool) {
  13712. if m.id == nil {
  13713. return
  13714. }
  13715. return *m.id, true
  13716. }
  13717. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13718. // That means, if the mutation is applied within a transaction with an isolation level such
  13719. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13720. // or updated by the mutation.
  13721. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  13722. switch {
  13723. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13724. id, exists := m.ID()
  13725. if exists {
  13726. return []uint64{id}, nil
  13727. }
  13728. fallthrough
  13729. case m.op.Is(OpUpdate | OpDelete):
  13730. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  13731. default:
  13732. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13733. }
  13734. }
  13735. // SetCreatedAt sets the "created_at" field.
  13736. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  13737. m.created_at = &t
  13738. }
  13739. // CreatedAt returns the value of the "created_at" field in the mutation.
  13740. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  13741. v := m.created_at
  13742. if v == nil {
  13743. return
  13744. }
  13745. return *v, true
  13746. }
  13747. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  13748. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13750. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13751. if !m.op.Is(OpUpdateOne) {
  13752. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13753. }
  13754. if m.id == nil || m.oldValue == nil {
  13755. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13756. }
  13757. oldValue, err := m.oldValue(ctx)
  13758. if err != nil {
  13759. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13760. }
  13761. return oldValue.CreatedAt, nil
  13762. }
  13763. // ResetCreatedAt resets all changes to the "created_at" field.
  13764. func (m *LabelMutation) ResetCreatedAt() {
  13765. m.created_at = nil
  13766. }
  13767. // SetUpdatedAt sets the "updated_at" field.
  13768. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  13769. m.updated_at = &t
  13770. }
  13771. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13772. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  13773. v := m.updated_at
  13774. if v == nil {
  13775. return
  13776. }
  13777. return *v, true
  13778. }
  13779. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  13780. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13782. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13783. if !m.op.Is(OpUpdateOne) {
  13784. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13785. }
  13786. if m.id == nil || m.oldValue == nil {
  13787. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13788. }
  13789. oldValue, err := m.oldValue(ctx)
  13790. if err != nil {
  13791. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13792. }
  13793. return oldValue.UpdatedAt, nil
  13794. }
  13795. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13796. func (m *LabelMutation) ResetUpdatedAt() {
  13797. m.updated_at = nil
  13798. }
  13799. // SetStatus sets the "status" field.
  13800. func (m *LabelMutation) SetStatus(u uint8) {
  13801. m.status = &u
  13802. m.addstatus = nil
  13803. }
  13804. // Status returns the value of the "status" field in the mutation.
  13805. func (m *LabelMutation) Status() (r uint8, exists bool) {
  13806. v := m.status
  13807. if v == nil {
  13808. return
  13809. }
  13810. return *v, true
  13811. }
  13812. // OldStatus returns the old "status" field's value of the Label entity.
  13813. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13815. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13816. if !m.op.Is(OpUpdateOne) {
  13817. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13818. }
  13819. if m.id == nil || m.oldValue == nil {
  13820. return v, errors.New("OldStatus requires an ID field in the mutation")
  13821. }
  13822. oldValue, err := m.oldValue(ctx)
  13823. if err != nil {
  13824. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13825. }
  13826. return oldValue.Status, nil
  13827. }
  13828. // AddStatus adds u to the "status" field.
  13829. func (m *LabelMutation) AddStatus(u int8) {
  13830. if m.addstatus != nil {
  13831. *m.addstatus += u
  13832. } else {
  13833. m.addstatus = &u
  13834. }
  13835. }
  13836. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13837. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  13838. v := m.addstatus
  13839. if v == nil {
  13840. return
  13841. }
  13842. return *v, true
  13843. }
  13844. // ClearStatus clears the value of the "status" field.
  13845. func (m *LabelMutation) ClearStatus() {
  13846. m.status = nil
  13847. m.addstatus = nil
  13848. m.clearedFields[label.FieldStatus] = struct{}{}
  13849. }
  13850. // StatusCleared returns if the "status" field was cleared in this mutation.
  13851. func (m *LabelMutation) StatusCleared() bool {
  13852. _, ok := m.clearedFields[label.FieldStatus]
  13853. return ok
  13854. }
  13855. // ResetStatus resets all changes to the "status" field.
  13856. func (m *LabelMutation) ResetStatus() {
  13857. m.status = nil
  13858. m.addstatus = nil
  13859. delete(m.clearedFields, label.FieldStatus)
  13860. }
  13861. // SetType sets the "type" field.
  13862. func (m *LabelMutation) SetType(i int) {
  13863. m._type = &i
  13864. m.add_type = nil
  13865. }
  13866. // GetType returns the value of the "type" field in the mutation.
  13867. func (m *LabelMutation) GetType() (r int, exists bool) {
  13868. v := m._type
  13869. if v == nil {
  13870. return
  13871. }
  13872. return *v, true
  13873. }
  13874. // OldType returns the old "type" field's value of the Label entity.
  13875. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13877. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  13878. if !m.op.Is(OpUpdateOne) {
  13879. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13880. }
  13881. if m.id == nil || m.oldValue == nil {
  13882. return v, errors.New("OldType requires an ID field in the mutation")
  13883. }
  13884. oldValue, err := m.oldValue(ctx)
  13885. if err != nil {
  13886. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13887. }
  13888. return oldValue.Type, nil
  13889. }
  13890. // AddType adds i to the "type" field.
  13891. func (m *LabelMutation) AddType(i int) {
  13892. if m.add_type != nil {
  13893. *m.add_type += i
  13894. } else {
  13895. m.add_type = &i
  13896. }
  13897. }
  13898. // AddedType returns the value that was added to the "type" field in this mutation.
  13899. func (m *LabelMutation) AddedType() (r int, exists bool) {
  13900. v := m.add_type
  13901. if v == nil {
  13902. return
  13903. }
  13904. return *v, true
  13905. }
  13906. // ResetType resets all changes to the "type" field.
  13907. func (m *LabelMutation) ResetType() {
  13908. m._type = nil
  13909. m.add_type = nil
  13910. }
  13911. // SetName sets the "name" field.
  13912. func (m *LabelMutation) SetName(s string) {
  13913. m.name = &s
  13914. }
  13915. // Name returns the value of the "name" field in the mutation.
  13916. func (m *LabelMutation) Name() (r string, exists bool) {
  13917. v := m.name
  13918. if v == nil {
  13919. return
  13920. }
  13921. return *v, true
  13922. }
  13923. // OldName returns the old "name" field's value of the Label entity.
  13924. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13926. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  13927. if !m.op.Is(OpUpdateOne) {
  13928. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13929. }
  13930. if m.id == nil || m.oldValue == nil {
  13931. return v, errors.New("OldName requires an ID field in the mutation")
  13932. }
  13933. oldValue, err := m.oldValue(ctx)
  13934. if err != nil {
  13935. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13936. }
  13937. return oldValue.Name, nil
  13938. }
  13939. // ResetName resets all changes to the "name" field.
  13940. func (m *LabelMutation) ResetName() {
  13941. m.name = nil
  13942. }
  13943. // SetFrom sets the "from" field.
  13944. func (m *LabelMutation) SetFrom(i int) {
  13945. m.from = &i
  13946. m.addfrom = nil
  13947. }
  13948. // From returns the value of the "from" field in the mutation.
  13949. func (m *LabelMutation) From() (r int, exists bool) {
  13950. v := m.from
  13951. if v == nil {
  13952. return
  13953. }
  13954. return *v, true
  13955. }
  13956. // OldFrom returns the old "from" field's value of the Label entity.
  13957. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13959. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  13960. if !m.op.Is(OpUpdateOne) {
  13961. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  13962. }
  13963. if m.id == nil || m.oldValue == nil {
  13964. return v, errors.New("OldFrom requires an ID field in the mutation")
  13965. }
  13966. oldValue, err := m.oldValue(ctx)
  13967. if err != nil {
  13968. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  13969. }
  13970. return oldValue.From, nil
  13971. }
  13972. // AddFrom adds i to the "from" field.
  13973. func (m *LabelMutation) AddFrom(i int) {
  13974. if m.addfrom != nil {
  13975. *m.addfrom += i
  13976. } else {
  13977. m.addfrom = &i
  13978. }
  13979. }
  13980. // AddedFrom returns the value that was added to the "from" field in this mutation.
  13981. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  13982. v := m.addfrom
  13983. if v == nil {
  13984. return
  13985. }
  13986. return *v, true
  13987. }
  13988. // ResetFrom resets all changes to the "from" field.
  13989. func (m *LabelMutation) ResetFrom() {
  13990. m.from = nil
  13991. m.addfrom = nil
  13992. }
  13993. // SetMode sets the "mode" field.
  13994. func (m *LabelMutation) SetMode(i int) {
  13995. m.mode = &i
  13996. m.addmode = nil
  13997. }
  13998. // Mode returns the value of the "mode" field in the mutation.
  13999. func (m *LabelMutation) Mode() (r int, exists bool) {
  14000. v := m.mode
  14001. if v == nil {
  14002. return
  14003. }
  14004. return *v, true
  14005. }
  14006. // OldMode returns the old "mode" field's value of the Label entity.
  14007. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14009. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  14010. if !m.op.Is(OpUpdateOne) {
  14011. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  14012. }
  14013. if m.id == nil || m.oldValue == nil {
  14014. return v, errors.New("OldMode requires an ID field in the mutation")
  14015. }
  14016. oldValue, err := m.oldValue(ctx)
  14017. if err != nil {
  14018. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  14019. }
  14020. return oldValue.Mode, nil
  14021. }
  14022. // AddMode adds i to the "mode" field.
  14023. func (m *LabelMutation) AddMode(i int) {
  14024. if m.addmode != nil {
  14025. *m.addmode += i
  14026. } else {
  14027. m.addmode = &i
  14028. }
  14029. }
  14030. // AddedMode returns the value that was added to the "mode" field in this mutation.
  14031. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  14032. v := m.addmode
  14033. if v == nil {
  14034. return
  14035. }
  14036. return *v, true
  14037. }
  14038. // ResetMode resets all changes to the "mode" field.
  14039. func (m *LabelMutation) ResetMode() {
  14040. m.mode = nil
  14041. m.addmode = nil
  14042. }
  14043. // SetConditions sets the "conditions" field.
  14044. func (m *LabelMutation) SetConditions(s string) {
  14045. m.conditions = &s
  14046. }
  14047. // Conditions returns the value of the "conditions" field in the mutation.
  14048. func (m *LabelMutation) Conditions() (r string, exists bool) {
  14049. v := m.conditions
  14050. if v == nil {
  14051. return
  14052. }
  14053. return *v, true
  14054. }
  14055. // OldConditions returns the old "conditions" field's value of the Label entity.
  14056. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14058. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  14059. if !m.op.Is(OpUpdateOne) {
  14060. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  14061. }
  14062. if m.id == nil || m.oldValue == nil {
  14063. return v, errors.New("OldConditions requires an ID field in the mutation")
  14064. }
  14065. oldValue, err := m.oldValue(ctx)
  14066. if err != nil {
  14067. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  14068. }
  14069. return oldValue.Conditions, nil
  14070. }
  14071. // ClearConditions clears the value of the "conditions" field.
  14072. func (m *LabelMutation) ClearConditions() {
  14073. m.conditions = nil
  14074. m.clearedFields[label.FieldConditions] = struct{}{}
  14075. }
  14076. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  14077. func (m *LabelMutation) ConditionsCleared() bool {
  14078. _, ok := m.clearedFields[label.FieldConditions]
  14079. return ok
  14080. }
  14081. // ResetConditions resets all changes to the "conditions" field.
  14082. func (m *LabelMutation) ResetConditions() {
  14083. m.conditions = nil
  14084. delete(m.clearedFields, label.FieldConditions)
  14085. }
  14086. // SetOrganizationID sets the "organization_id" field.
  14087. func (m *LabelMutation) SetOrganizationID(u uint64) {
  14088. m.organization_id = &u
  14089. m.addorganization_id = nil
  14090. }
  14091. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14092. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  14093. v := m.organization_id
  14094. if v == nil {
  14095. return
  14096. }
  14097. return *v, true
  14098. }
  14099. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  14100. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14102. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14103. if !m.op.Is(OpUpdateOne) {
  14104. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14105. }
  14106. if m.id == nil || m.oldValue == nil {
  14107. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14108. }
  14109. oldValue, err := m.oldValue(ctx)
  14110. if err != nil {
  14111. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14112. }
  14113. return oldValue.OrganizationID, nil
  14114. }
  14115. // AddOrganizationID adds u to the "organization_id" field.
  14116. func (m *LabelMutation) AddOrganizationID(u int64) {
  14117. if m.addorganization_id != nil {
  14118. *m.addorganization_id += u
  14119. } else {
  14120. m.addorganization_id = &u
  14121. }
  14122. }
  14123. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14124. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  14125. v := m.addorganization_id
  14126. if v == nil {
  14127. return
  14128. }
  14129. return *v, true
  14130. }
  14131. // ClearOrganizationID clears the value of the "organization_id" field.
  14132. func (m *LabelMutation) ClearOrganizationID() {
  14133. m.organization_id = nil
  14134. m.addorganization_id = nil
  14135. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  14136. }
  14137. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14138. func (m *LabelMutation) OrganizationIDCleared() bool {
  14139. _, ok := m.clearedFields[label.FieldOrganizationID]
  14140. return ok
  14141. }
  14142. // ResetOrganizationID resets all changes to the "organization_id" field.
  14143. func (m *LabelMutation) ResetOrganizationID() {
  14144. m.organization_id = nil
  14145. m.addorganization_id = nil
  14146. delete(m.clearedFields, label.FieldOrganizationID)
  14147. }
  14148. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  14149. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  14150. if m.label_relationships == nil {
  14151. m.label_relationships = make(map[uint64]struct{})
  14152. }
  14153. for i := range ids {
  14154. m.label_relationships[ids[i]] = struct{}{}
  14155. }
  14156. }
  14157. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  14158. func (m *LabelMutation) ClearLabelRelationships() {
  14159. m.clearedlabel_relationships = true
  14160. }
  14161. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  14162. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  14163. return m.clearedlabel_relationships
  14164. }
  14165. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  14166. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  14167. if m.removedlabel_relationships == nil {
  14168. m.removedlabel_relationships = make(map[uint64]struct{})
  14169. }
  14170. for i := range ids {
  14171. delete(m.label_relationships, ids[i])
  14172. m.removedlabel_relationships[ids[i]] = struct{}{}
  14173. }
  14174. }
  14175. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  14176. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  14177. for id := range m.removedlabel_relationships {
  14178. ids = append(ids, id)
  14179. }
  14180. return
  14181. }
  14182. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  14183. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  14184. for id := range m.label_relationships {
  14185. ids = append(ids, id)
  14186. }
  14187. return
  14188. }
  14189. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  14190. func (m *LabelMutation) ResetLabelRelationships() {
  14191. m.label_relationships = nil
  14192. m.clearedlabel_relationships = false
  14193. m.removedlabel_relationships = nil
  14194. }
  14195. // Where appends a list predicates to the LabelMutation builder.
  14196. func (m *LabelMutation) Where(ps ...predicate.Label) {
  14197. m.predicates = append(m.predicates, ps...)
  14198. }
  14199. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  14200. // users can use type-assertion to append predicates that do not depend on any generated package.
  14201. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  14202. p := make([]predicate.Label, len(ps))
  14203. for i := range ps {
  14204. p[i] = ps[i]
  14205. }
  14206. m.Where(p...)
  14207. }
  14208. // Op returns the operation name.
  14209. func (m *LabelMutation) Op() Op {
  14210. return m.op
  14211. }
  14212. // SetOp allows setting the mutation operation.
  14213. func (m *LabelMutation) SetOp(op Op) {
  14214. m.op = op
  14215. }
  14216. // Type returns the node type of this mutation (Label).
  14217. func (m *LabelMutation) Type() string {
  14218. return m.typ
  14219. }
  14220. // Fields returns all fields that were changed during this mutation. Note that in
  14221. // order to get all numeric fields that were incremented/decremented, call
  14222. // AddedFields().
  14223. func (m *LabelMutation) Fields() []string {
  14224. fields := make([]string, 0, 9)
  14225. if m.created_at != nil {
  14226. fields = append(fields, label.FieldCreatedAt)
  14227. }
  14228. if m.updated_at != nil {
  14229. fields = append(fields, label.FieldUpdatedAt)
  14230. }
  14231. if m.status != nil {
  14232. fields = append(fields, label.FieldStatus)
  14233. }
  14234. if m._type != nil {
  14235. fields = append(fields, label.FieldType)
  14236. }
  14237. if m.name != nil {
  14238. fields = append(fields, label.FieldName)
  14239. }
  14240. if m.from != nil {
  14241. fields = append(fields, label.FieldFrom)
  14242. }
  14243. if m.mode != nil {
  14244. fields = append(fields, label.FieldMode)
  14245. }
  14246. if m.conditions != nil {
  14247. fields = append(fields, label.FieldConditions)
  14248. }
  14249. if m.organization_id != nil {
  14250. fields = append(fields, label.FieldOrganizationID)
  14251. }
  14252. return fields
  14253. }
  14254. // Field returns the value of a field with the given name. The second boolean
  14255. // return value indicates that this field was not set, or was not defined in the
  14256. // schema.
  14257. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  14258. switch name {
  14259. case label.FieldCreatedAt:
  14260. return m.CreatedAt()
  14261. case label.FieldUpdatedAt:
  14262. return m.UpdatedAt()
  14263. case label.FieldStatus:
  14264. return m.Status()
  14265. case label.FieldType:
  14266. return m.GetType()
  14267. case label.FieldName:
  14268. return m.Name()
  14269. case label.FieldFrom:
  14270. return m.From()
  14271. case label.FieldMode:
  14272. return m.Mode()
  14273. case label.FieldConditions:
  14274. return m.Conditions()
  14275. case label.FieldOrganizationID:
  14276. return m.OrganizationID()
  14277. }
  14278. return nil, false
  14279. }
  14280. // OldField returns the old value of the field from the database. An error is
  14281. // returned if the mutation operation is not UpdateOne, or the query to the
  14282. // database failed.
  14283. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14284. switch name {
  14285. case label.FieldCreatedAt:
  14286. return m.OldCreatedAt(ctx)
  14287. case label.FieldUpdatedAt:
  14288. return m.OldUpdatedAt(ctx)
  14289. case label.FieldStatus:
  14290. return m.OldStatus(ctx)
  14291. case label.FieldType:
  14292. return m.OldType(ctx)
  14293. case label.FieldName:
  14294. return m.OldName(ctx)
  14295. case label.FieldFrom:
  14296. return m.OldFrom(ctx)
  14297. case label.FieldMode:
  14298. return m.OldMode(ctx)
  14299. case label.FieldConditions:
  14300. return m.OldConditions(ctx)
  14301. case label.FieldOrganizationID:
  14302. return m.OldOrganizationID(ctx)
  14303. }
  14304. return nil, fmt.Errorf("unknown Label field %s", name)
  14305. }
  14306. // SetField sets the value of a field with the given name. It returns an error if
  14307. // the field is not defined in the schema, or if the type mismatched the field
  14308. // type.
  14309. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  14310. switch name {
  14311. case label.FieldCreatedAt:
  14312. v, ok := value.(time.Time)
  14313. if !ok {
  14314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14315. }
  14316. m.SetCreatedAt(v)
  14317. return nil
  14318. case label.FieldUpdatedAt:
  14319. v, ok := value.(time.Time)
  14320. if !ok {
  14321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14322. }
  14323. m.SetUpdatedAt(v)
  14324. return nil
  14325. case label.FieldStatus:
  14326. v, ok := value.(uint8)
  14327. if !ok {
  14328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14329. }
  14330. m.SetStatus(v)
  14331. return nil
  14332. case label.FieldType:
  14333. v, ok := value.(int)
  14334. if !ok {
  14335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14336. }
  14337. m.SetType(v)
  14338. return nil
  14339. case label.FieldName:
  14340. v, ok := value.(string)
  14341. if !ok {
  14342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14343. }
  14344. m.SetName(v)
  14345. return nil
  14346. case label.FieldFrom:
  14347. v, ok := value.(int)
  14348. if !ok {
  14349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14350. }
  14351. m.SetFrom(v)
  14352. return nil
  14353. case label.FieldMode:
  14354. v, ok := value.(int)
  14355. if !ok {
  14356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14357. }
  14358. m.SetMode(v)
  14359. return nil
  14360. case label.FieldConditions:
  14361. v, ok := value.(string)
  14362. if !ok {
  14363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14364. }
  14365. m.SetConditions(v)
  14366. return nil
  14367. case label.FieldOrganizationID:
  14368. v, ok := value.(uint64)
  14369. if !ok {
  14370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14371. }
  14372. m.SetOrganizationID(v)
  14373. return nil
  14374. }
  14375. return fmt.Errorf("unknown Label field %s", name)
  14376. }
  14377. // AddedFields returns all numeric fields that were incremented/decremented during
  14378. // this mutation.
  14379. func (m *LabelMutation) AddedFields() []string {
  14380. var fields []string
  14381. if m.addstatus != nil {
  14382. fields = append(fields, label.FieldStatus)
  14383. }
  14384. if m.add_type != nil {
  14385. fields = append(fields, label.FieldType)
  14386. }
  14387. if m.addfrom != nil {
  14388. fields = append(fields, label.FieldFrom)
  14389. }
  14390. if m.addmode != nil {
  14391. fields = append(fields, label.FieldMode)
  14392. }
  14393. if m.addorganization_id != nil {
  14394. fields = append(fields, label.FieldOrganizationID)
  14395. }
  14396. return fields
  14397. }
  14398. // AddedField returns the numeric value that was incremented/decremented on a field
  14399. // with the given name. The second boolean return value indicates that this field
  14400. // was not set, or was not defined in the schema.
  14401. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  14402. switch name {
  14403. case label.FieldStatus:
  14404. return m.AddedStatus()
  14405. case label.FieldType:
  14406. return m.AddedType()
  14407. case label.FieldFrom:
  14408. return m.AddedFrom()
  14409. case label.FieldMode:
  14410. return m.AddedMode()
  14411. case label.FieldOrganizationID:
  14412. return m.AddedOrganizationID()
  14413. }
  14414. return nil, false
  14415. }
  14416. // AddField adds the value to the field with the given name. It returns an error if
  14417. // the field is not defined in the schema, or if the type mismatched the field
  14418. // type.
  14419. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  14420. switch name {
  14421. case label.FieldStatus:
  14422. v, ok := value.(int8)
  14423. if !ok {
  14424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14425. }
  14426. m.AddStatus(v)
  14427. return nil
  14428. case label.FieldType:
  14429. v, ok := value.(int)
  14430. if !ok {
  14431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14432. }
  14433. m.AddType(v)
  14434. return nil
  14435. case label.FieldFrom:
  14436. v, ok := value.(int)
  14437. if !ok {
  14438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14439. }
  14440. m.AddFrom(v)
  14441. return nil
  14442. case label.FieldMode:
  14443. v, ok := value.(int)
  14444. if !ok {
  14445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14446. }
  14447. m.AddMode(v)
  14448. return nil
  14449. case label.FieldOrganizationID:
  14450. v, ok := value.(int64)
  14451. if !ok {
  14452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14453. }
  14454. m.AddOrganizationID(v)
  14455. return nil
  14456. }
  14457. return fmt.Errorf("unknown Label numeric field %s", name)
  14458. }
  14459. // ClearedFields returns all nullable fields that were cleared during this
  14460. // mutation.
  14461. func (m *LabelMutation) ClearedFields() []string {
  14462. var fields []string
  14463. if m.FieldCleared(label.FieldStatus) {
  14464. fields = append(fields, label.FieldStatus)
  14465. }
  14466. if m.FieldCleared(label.FieldConditions) {
  14467. fields = append(fields, label.FieldConditions)
  14468. }
  14469. if m.FieldCleared(label.FieldOrganizationID) {
  14470. fields = append(fields, label.FieldOrganizationID)
  14471. }
  14472. return fields
  14473. }
  14474. // FieldCleared returns a boolean indicating if a field with the given name was
  14475. // cleared in this mutation.
  14476. func (m *LabelMutation) FieldCleared(name string) bool {
  14477. _, ok := m.clearedFields[name]
  14478. return ok
  14479. }
  14480. // ClearField clears the value of the field with the given name. It returns an
  14481. // error if the field is not defined in the schema.
  14482. func (m *LabelMutation) ClearField(name string) error {
  14483. switch name {
  14484. case label.FieldStatus:
  14485. m.ClearStatus()
  14486. return nil
  14487. case label.FieldConditions:
  14488. m.ClearConditions()
  14489. return nil
  14490. case label.FieldOrganizationID:
  14491. m.ClearOrganizationID()
  14492. return nil
  14493. }
  14494. return fmt.Errorf("unknown Label nullable field %s", name)
  14495. }
  14496. // ResetField resets all changes in the mutation for the field with the given name.
  14497. // It returns an error if the field is not defined in the schema.
  14498. func (m *LabelMutation) ResetField(name string) error {
  14499. switch name {
  14500. case label.FieldCreatedAt:
  14501. m.ResetCreatedAt()
  14502. return nil
  14503. case label.FieldUpdatedAt:
  14504. m.ResetUpdatedAt()
  14505. return nil
  14506. case label.FieldStatus:
  14507. m.ResetStatus()
  14508. return nil
  14509. case label.FieldType:
  14510. m.ResetType()
  14511. return nil
  14512. case label.FieldName:
  14513. m.ResetName()
  14514. return nil
  14515. case label.FieldFrom:
  14516. m.ResetFrom()
  14517. return nil
  14518. case label.FieldMode:
  14519. m.ResetMode()
  14520. return nil
  14521. case label.FieldConditions:
  14522. m.ResetConditions()
  14523. return nil
  14524. case label.FieldOrganizationID:
  14525. m.ResetOrganizationID()
  14526. return nil
  14527. }
  14528. return fmt.Errorf("unknown Label field %s", name)
  14529. }
  14530. // AddedEdges returns all edge names that were set/added in this mutation.
  14531. func (m *LabelMutation) AddedEdges() []string {
  14532. edges := make([]string, 0, 1)
  14533. if m.label_relationships != nil {
  14534. edges = append(edges, label.EdgeLabelRelationships)
  14535. }
  14536. return edges
  14537. }
  14538. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14539. // name in this mutation.
  14540. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  14541. switch name {
  14542. case label.EdgeLabelRelationships:
  14543. ids := make([]ent.Value, 0, len(m.label_relationships))
  14544. for id := range m.label_relationships {
  14545. ids = append(ids, id)
  14546. }
  14547. return ids
  14548. }
  14549. return nil
  14550. }
  14551. // RemovedEdges returns all edge names that were removed in this mutation.
  14552. func (m *LabelMutation) RemovedEdges() []string {
  14553. edges := make([]string, 0, 1)
  14554. if m.removedlabel_relationships != nil {
  14555. edges = append(edges, label.EdgeLabelRelationships)
  14556. }
  14557. return edges
  14558. }
  14559. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14560. // the given name in this mutation.
  14561. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  14562. switch name {
  14563. case label.EdgeLabelRelationships:
  14564. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  14565. for id := range m.removedlabel_relationships {
  14566. ids = append(ids, id)
  14567. }
  14568. return ids
  14569. }
  14570. return nil
  14571. }
  14572. // ClearedEdges returns all edge names that were cleared in this mutation.
  14573. func (m *LabelMutation) ClearedEdges() []string {
  14574. edges := make([]string, 0, 1)
  14575. if m.clearedlabel_relationships {
  14576. edges = append(edges, label.EdgeLabelRelationships)
  14577. }
  14578. return edges
  14579. }
  14580. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14581. // was cleared in this mutation.
  14582. func (m *LabelMutation) EdgeCleared(name string) bool {
  14583. switch name {
  14584. case label.EdgeLabelRelationships:
  14585. return m.clearedlabel_relationships
  14586. }
  14587. return false
  14588. }
  14589. // ClearEdge clears the value of the edge with the given name. It returns an error
  14590. // if that edge is not defined in the schema.
  14591. func (m *LabelMutation) ClearEdge(name string) error {
  14592. switch name {
  14593. }
  14594. return fmt.Errorf("unknown Label unique edge %s", name)
  14595. }
  14596. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14597. // It returns an error if the edge is not defined in the schema.
  14598. func (m *LabelMutation) ResetEdge(name string) error {
  14599. switch name {
  14600. case label.EdgeLabelRelationships:
  14601. m.ResetLabelRelationships()
  14602. return nil
  14603. }
  14604. return fmt.Errorf("unknown Label edge %s", name)
  14605. }
  14606. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  14607. type LabelRelationshipMutation struct {
  14608. config
  14609. op Op
  14610. typ string
  14611. id *uint64
  14612. created_at *time.Time
  14613. updated_at *time.Time
  14614. status *uint8
  14615. addstatus *int8
  14616. organization_id *uint64
  14617. addorganization_id *int64
  14618. clearedFields map[string]struct{}
  14619. contacts *uint64
  14620. clearedcontacts bool
  14621. labels *uint64
  14622. clearedlabels bool
  14623. done bool
  14624. oldValue func(context.Context) (*LabelRelationship, error)
  14625. predicates []predicate.LabelRelationship
  14626. }
  14627. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  14628. // labelrelationshipOption allows management of the mutation configuration using functional options.
  14629. type labelrelationshipOption func(*LabelRelationshipMutation)
  14630. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  14631. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  14632. m := &LabelRelationshipMutation{
  14633. config: c,
  14634. op: op,
  14635. typ: TypeLabelRelationship,
  14636. clearedFields: make(map[string]struct{}),
  14637. }
  14638. for _, opt := range opts {
  14639. opt(m)
  14640. }
  14641. return m
  14642. }
  14643. // withLabelRelationshipID sets the ID field of the mutation.
  14644. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  14645. return func(m *LabelRelationshipMutation) {
  14646. var (
  14647. err error
  14648. once sync.Once
  14649. value *LabelRelationship
  14650. )
  14651. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  14652. once.Do(func() {
  14653. if m.done {
  14654. err = errors.New("querying old values post mutation is not allowed")
  14655. } else {
  14656. value, err = m.Client().LabelRelationship.Get(ctx, id)
  14657. }
  14658. })
  14659. return value, err
  14660. }
  14661. m.id = &id
  14662. }
  14663. }
  14664. // withLabelRelationship sets the old LabelRelationship of the mutation.
  14665. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  14666. return func(m *LabelRelationshipMutation) {
  14667. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  14668. return node, nil
  14669. }
  14670. m.id = &node.ID
  14671. }
  14672. }
  14673. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14674. // executed in a transaction (ent.Tx), a transactional client is returned.
  14675. func (m LabelRelationshipMutation) Client() *Client {
  14676. client := &Client{config: m.config}
  14677. client.init()
  14678. return client
  14679. }
  14680. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14681. // it returns an error otherwise.
  14682. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  14683. if _, ok := m.driver.(*txDriver); !ok {
  14684. return nil, errors.New("ent: mutation is not running in a transaction")
  14685. }
  14686. tx := &Tx{config: m.config}
  14687. tx.init()
  14688. return tx, nil
  14689. }
  14690. // SetID sets the value of the id field. Note that this
  14691. // operation is only accepted on creation of LabelRelationship entities.
  14692. func (m *LabelRelationshipMutation) SetID(id uint64) {
  14693. m.id = &id
  14694. }
  14695. // ID returns the ID value in the mutation. Note that the ID is only available
  14696. // if it was provided to the builder or after it was returned from the database.
  14697. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  14698. if m.id == nil {
  14699. return
  14700. }
  14701. return *m.id, true
  14702. }
  14703. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14704. // That means, if the mutation is applied within a transaction with an isolation level such
  14705. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14706. // or updated by the mutation.
  14707. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  14708. switch {
  14709. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14710. id, exists := m.ID()
  14711. if exists {
  14712. return []uint64{id}, nil
  14713. }
  14714. fallthrough
  14715. case m.op.Is(OpUpdate | OpDelete):
  14716. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  14717. default:
  14718. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14719. }
  14720. }
  14721. // SetCreatedAt sets the "created_at" field.
  14722. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  14723. m.created_at = &t
  14724. }
  14725. // CreatedAt returns the value of the "created_at" field in the mutation.
  14726. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  14727. v := m.created_at
  14728. if v == nil {
  14729. return
  14730. }
  14731. return *v, true
  14732. }
  14733. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  14734. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14736. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14737. if !m.op.Is(OpUpdateOne) {
  14738. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14739. }
  14740. if m.id == nil || m.oldValue == nil {
  14741. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14742. }
  14743. oldValue, err := m.oldValue(ctx)
  14744. if err != nil {
  14745. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14746. }
  14747. return oldValue.CreatedAt, nil
  14748. }
  14749. // ResetCreatedAt resets all changes to the "created_at" field.
  14750. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  14751. m.created_at = nil
  14752. }
  14753. // SetUpdatedAt sets the "updated_at" field.
  14754. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  14755. m.updated_at = &t
  14756. }
  14757. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14758. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  14759. v := m.updated_at
  14760. if v == nil {
  14761. return
  14762. }
  14763. return *v, true
  14764. }
  14765. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  14766. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14768. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14769. if !m.op.Is(OpUpdateOne) {
  14770. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14771. }
  14772. if m.id == nil || m.oldValue == nil {
  14773. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14774. }
  14775. oldValue, err := m.oldValue(ctx)
  14776. if err != nil {
  14777. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14778. }
  14779. return oldValue.UpdatedAt, nil
  14780. }
  14781. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14782. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  14783. m.updated_at = nil
  14784. }
  14785. // SetStatus sets the "status" field.
  14786. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  14787. m.status = &u
  14788. m.addstatus = nil
  14789. }
  14790. // Status returns the value of the "status" field in the mutation.
  14791. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  14792. v := m.status
  14793. if v == nil {
  14794. return
  14795. }
  14796. return *v, true
  14797. }
  14798. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  14799. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14801. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14802. if !m.op.Is(OpUpdateOne) {
  14803. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14804. }
  14805. if m.id == nil || m.oldValue == nil {
  14806. return v, errors.New("OldStatus requires an ID field in the mutation")
  14807. }
  14808. oldValue, err := m.oldValue(ctx)
  14809. if err != nil {
  14810. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14811. }
  14812. return oldValue.Status, nil
  14813. }
  14814. // AddStatus adds u to the "status" field.
  14815. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  14816. if m.addstatus != nil {
  14817. *m.addstatus += u
  14818. } else {
  14819. m.addstatus = &u
  14820. }
  14821. }
  14822. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14823. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  14824. v := m.addstatus
  14825. if v == nil {
  14826. return
  14827. }
  14828. return *v, true
  14829. }
  14830. // ClearStatus clears the value of the "status" field.
  14831. func (m *LabelRelationshipMutation) ClearStatus() {
  14832. m.status = nil
  14833. m.addstatus = nil
  14834. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  14835. }
  14836. // StatusCleared returns if the "status" field was cleared in this mutation.
  14837. func (m *LabelRelationshipMutation) StatusCleared() bool {
  14838. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  14839. return ok
  14840. }
  14841. // ResetStatus resets all changes to the "status" field.
  14842. func (m *LabelRelationshipMutation) ResetStatus() {
  14843. m.status = nil
  14844. m.addstatus = nil
  14845. delete(m.clearedFields, labelrelationship.FieldStatus)
  14846. }
  14847. // SetLabelID sets the "label_id" field.
  14848. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  14849. m.labels = &u
  14850. }
  14851. // LabelID returns the value of the "label_id" field in the mutation.
  14852. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  14853. v := m.labels
  14854. if v == nil {
  14855. return
  14856. }
  14857. return *v, true
  14858. }
  14859. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  14860. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14862. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  14863. if !m.op.Is(OpUpdateOne) {
  14864. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  14865. }
  14866. if m.id == nil || m.oldValue == nil {
  14867. return v, errors.New("OldLabelID requires an ID field in the mutation")
  14868. }
  14869. oldValue, err := m.oldValue(ctx)
  14870. if err != nil {
  14871. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  14872. }
  14873. return oldValue.LabelID, nil
  14874. }
  14875. // ResetLabelID resets all changes to the "label_id" field.
  14876. func (m *LabelRelationshipMutation) ResetLabelID() {
  14877. m.labels = nil
  14878. }
  14879. // SetContactID sets the "contact_id" field.
  14880. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  14881. m.contacts = &u
  14882. }
  14883. // ContactID returns the value of the "contact_id" field in the mutation.
  14884. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  14885. v := m.contacts
  14886. if v == nil {
  14887. return
  14888. }
  14889. return *v, true
  14890. }
  14891. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  14892. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14894. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14895. if !m.op.Is(OpUpdateOne) {
  14896. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14897. }
  14898. if m.id == nil || m.oldValue == nil {
  14899. return v, errors.New("OldContactID requires an ID field in the mutation")
  14900. }
  14901. oldValue, err := m.oldValue(ctx)
  14902. if err != nil {
  14903. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14904. }
  14905. return oldValue.ContactID, nil
  14906. }
  14907. // ResetContactID resets all changes to the "contact_id" field.
  14908. func (m *LabelRelationshipMutation) ResetContactID() {
  14909. m.contacts = nil
  14910. }
  14911. // SetOrganizationID sets the "organization_id" field.
  14912. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  14913. m.organization_id = &u
  14914. m.addorganization_id = nil
  14915. }
  14916. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14917. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  14918. v := m.organization_id
  14919. if v == nil {
  14920. return
  14921. }
  14922. return *v, true
  14923. }
  14924. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  14925. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14927. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14928. if !m.op.Is(OpUpdateOne) {
  14929. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14930. }
  14931. if m.id == nil || m.oldValue == nil {
  14932. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14933. }
  14934. oldValue, err := m.oldValue(ctx)
  14935. if err != nil {
  14936. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14937. }
  14938. return oldValue.OrganizationID, nil
  14939. }
  14940. // AddOrganizationID adds u to the "organization_id" field.
  14941. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  14942. if m.addorganization_id != nil {
  14943. *m.addorganization_id += u
  14944. } else {
  14945. m.addorganization_id = &u
  14946. }
  14947. }
  14948. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14949. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  14950. v := m.addorganization_id
  14951. if v == nil {
  14952. return
  14953. }
  14954. return *v, true
  14955. }
  14956. // ClearOrganizationID clears the value of the "organization_id" field.
  14957. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  14958. m.organization_id = nil
  14959. m.addorganization_id = nil
  14960. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  14961. }
  14962. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14963. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  14964. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  14965. return ok
  14966. }
  14967. // ResetOrganizationID resets all changes to the "organization_id" field.
  14968. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  14969. m.organization_id = nil
  14970. m.addorganization_id = nil
  14971. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  14972. }
  14973. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  14974. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  14975. m.contacts = &id
  14976. }
  14977. // ClearContacts clears the "contacts" edge to the Contact entity.
  14978. func (m *LabelRelationshipMutation) ClearContacts() {
  14979. m.clearedcontacts = true
  14980. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  14981. }
  14982. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  14983. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  14984. return m.clearedcontacts
  14985. }
  14986. // ContactsID returns the "contacts" edge ID in the mutation.
  14987. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  14988. if m.contacts != nil {
  14989. return *m.contacts, true
  14990. }
  14991. return
  14992. }
  14993. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  14994. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14995. // ContactsID instead. It exists only for internal usage by the builders.
  14996. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  14997. if id := m.contacts; id != nil {
  14998. ids = append(ids, *id)
  14999. }
  15000. return
  15001. }
  15002. // ResetContacts resets all changes to the "contacts" edge.
  15003. func (m *LabelRelationshipMutation) ResetContacts() {
  15004. m.contacts = nil
  15005. m.clearedcontacts = false
  15006. }
  15007. // SetLabelsID sets the "labels" edge to the Label entity by id.
  15008. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  15009. m.labels = &id
  15010. }
  15011. // ClearLabels clears the "labels" edge to the Label entity.
  15012. func (m *LabelRelationshipMutation) ClearLabels() {
  15013. m.clearedlabels = true
  15014. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  15015. }
  15016. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  15017. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  15018. return m.clearedlabels
  15019. }
  15020. // LabelsID returns the "labels" edge ID in the mutation.
  15021. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  15022. if m.labels != nil {
  15023. return *m.labels, true
  15024. }
  15025. return
  15026. }
  15027. // LabelsIDs returns the "labels" edge IDs in the mutation.
  15028. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15029. // LabelsID instead. It exists only for internal usage by the builders.
  15030. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  15031. if id := m.labels; id != nil {
  15032. ids = append(ids, *id)
  15033. }
  15034. return
  15035. }
  15036. // ResetLabels resets all changes to the "labels" edge.
  15037. func (m *LabelRelationshipMutation) ResetLabels() {
  15038. m.labels = nil
  15039. m.clearedlabels = false
  15040. }
  15041. // Where appends a list predicates to the LabelRelationshipMutation builder.
  15042. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  15043. m.predicates = append(m.predicates, ps...)
  15044. }
  15045. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  15046. // users can use type-assertion to append predicates that do not depend on any generated package.
  15047. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  15048. p := make([]predicate.LabelRelationship, len(ps))
  15049. for i := range ps {
  15050. p[i] = ps[i]
  15051. }
  15052. m.Where(p...)
  15053. }
  15054. // Op returns the operation name.
  15055. func (m *LabelRelationshipMutation) Op() Op {
  15056. return m.op
  15057. }
  15058. // SetOp allows setting the mutation operation.
  15059. func (m *LabelRelationshipMutation) SetOp(op Op) {
  15060. m.op = op
  15061. }
  15062. // Type returns the node type of this mutation (LabelRelationship).
  15063. func (m *LabelRelationshipMutation) Type() string {
  15064. return m.typ
  15065. }
  15066. // Fields returns all fields that were changed during this mutation. Note that in
  15067. // order to get all numeric fields that were incremented/decremented, call
  15068. // AddedFields().
  15069. func (m *LabelRelationshipMutation) Fields() []string {
  15070. fields := make([]string, 0, 6)
  15071. if m.created_at != nil {
  15072. fields = append(fields, labelrelationship.FieldCreatedAt)
  15073. }
  15074. if m.updated_at != nil {
  15075. fields = append(fields, labelrelationship.FieldUpdatedAt)
  15076. }
  15077. if m.status != nil {
  15078. fields = append(fields, labelrelationship.FieldStatus)
  15079. }
  15080. if m.labels != nil {
  15081. fields = append(fields, labelrelationship.FieldLabelID)
  15082. }
  15083. if m.contacts != nil {
  15084. fields = append(fields, labelrelationship.FieldContactID)
  15085. }
  15086. if m.organization_id != nil {
  15087. fields = append(fields, labelrelationship.FieldOrganizationID)
  15088. }
  15089. return fields
  15090. }
  15091. // Field returns the value of a field with the given name. The second boolean
  15092. // return value indicates that this field was not set, or was not defined in the
  15093. // schema.
  15094. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  15095. switch name {
  15096. case labelrelationship.FieldCreatedAt:
  15097. return m.CreatedAt()
  15098. case labelrelationship.FieldUpdatedAt:
  15099. return m.UpdatedAt()
  15100. case labelrelationship.FieldStatus:
  15101. return m.Status()
  15102. case labelrelationship.FieldLabelID:
  15103. return m.LabelID()
  15104. case labelrelationship.FieldContactID:
  15105. return m.ContactID()
  15106. case labelrelationship.FieldOrganizationID:
  15107. return m.OrganizationID()
  15108. }
  15109. return nil, false
  15110. }
  15111. // OldField returns the old value of the field from the database. An error is
  15112. // returned if the mutation operation is not UpdateOne, or the query to the
  15113. // database failed.
  15114. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15115. switch name {
  15116. case labelrelationship.FieldCreatedAt:
  15117. return m.OldCreatedAt(ctx)
  15118. case labelrelationship.FieldUpdatedAt:
  15119. return m.OldUpdatedAt(ctx)
  15120. case labelrelationship.FieldStatus:
  15121. return m.OldStatus(ctx)
  15122. case labelrelationship.FieldLabelID:
  15123. return m.OldLabelID(ctx)
  15124. case labelrelationship.FieldContactID:
  15125. return m.OldContactID(ctx)
  15126. case labelrelationship.FieldOrganizationID:
  15127. return m.OldOrganizationID(ctx)
  15128. }
  15129. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  15130. }
  15131. // SetField sets the value of a field with the given name. It returns an error if
  15132. // the field is not defined in the schema, or if the type mismatched the field
  15133. // type.
  15134. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  15135. switch name {
  15136. case labelrelationship.FieldCreatedAt:
  15137. v, ok := value.(time.Time)
  15138. if !ok {
  15139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15140. }
  15141. m.SetCreatedAt(v)
  15142. return nil
  15143. case labelrelationship.FieldUpdatedAt:
  15144. v, ok := value.(time.Time)
  15145. if !ok {
  15146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15147. }
  15148. m.SetUpdatedAt(v)
  15149. return nil
  15150. case labelrelationship.FieldStatus:
  15151. v, ok := value.(uint8)
  15152. if !ok {
  15153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15154. }
  15155. m.SetStatus(v)
  15156. return nil
  15157. case labelrelationship.FieldLabelID:
  15158. v, ok := value.(uint64)
  15159. if !ok {
  15160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15161. }
  15162. m.SetLabelID(v)
  15163. return nil
  15164. case labelrelationship.FieldContactID:
  15165. v, ok := value.(uint64)
  15166. if !ok {
  15167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15168. }
  15169. m.SetContactID(v)
  15170. return nil
  15171. case labelrelationship.FieldOrganizationID:
  15172. v, ok := value.(uint64)
  15173. if !ok {
  15174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15175. }
  15176. m.SetOrganizationID(v)
  15177. return nil
  15178. }
  15179. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15180. }
  15181. // AddedFields returns all numeric fields that were incremented/decremented during
  15182. // this mutation.
  15183. func (m *LabelRelationshipMutation) AddedFields() []string {
  15184. var fields []string
  15185. if m.addstatus != nil {
  15186. fields = append(fields, labelrelationship.FieldStatus)
  15187. }
  15188. if m.addorganization_id != nil {
  15189. fields = append(fields, labelrelationship.FieldOrganizationID)
  15190. }
  15191. return fields
  15192. }
  15193. // AddedField returns the numeric value that was incremented/decremented on a field
  15194. // with the given name. The second boolean return value indicates that this field
  15195. // was not set, or was not defined in the schema.
  15196. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  15197. switch name {
  15198. case labelrelationship.FieldStatus:
  15199. return m.AddedStatus()
  15200. case labelrelationship.FieldOrganizationID:
  15201. return m.AddedOrganizationID()
  15202. }
  15203. return nil, false
  15204. }
  15205. // AddField adds the value to the field with the given name. It returns an error if
  15206. // the field is not defined in the schema, or if the type mismatched the field
  15207. // type.
  15208. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  15209. switch name {
  15210. case labelrelationship.FieldStatus:
  15211. v, ok := value.(int8)
  15212. if !ok {
  15213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15214. }
  15215. m.AddStatus(v)
  15216. return nil
  15217. case labelrelationship.FieldOrganizationID:
  15218. v, ok := value.(int64)
  15219. if !ok {
  15220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15221. }
  15222. m.AddOrganizationID(v)
  15223. return nil
  15224. }
  15225. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  15226. }
  15227. // ClearedFields returns all nullable fields that were cleared during this
  15228. // mutation.
  15229. func (m *LabelRelationshipMutation) ClearedFields() []string {
  15230. var fields []string
  15231. if m.FieldCleared(labelrelationship.FieldStatus) {
  15232. fields = append(fields, labelrelationship.FieldStatus)
  15233. }
  15234. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  15235. fields = append(fields, labelrelationship.FieldOrganizationID)
  15236. }
  15237. return fields
  15238. }
  15239. // FieldCleared returns a boolean indicating if a field with the given name was
  15240. // cleared in this mutation.
  15241. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  15242. _, ok := m.clearedFields[name]
  15243. return ok
  15244. }
  15245. // ClearField clears the value of the field with the given name. It returns an
  15246. // error if the field is not defined in the schema.
  15247. func (m *LabelRelationshipMutation) ClearField(name string) error {
  15248. switch name {
  15249. case labelrelationship.FieldStatus:
  15250. m.ClearStatus()
  15251. return nil
  15252. case labelrelationship.FieldOrganizationID:
  15253. m.ClearOrganizationID()
  15254. return nil
  15255. }
  15256. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  15257. }
  15258. // ResetField resets all changes in the mutation for the field with the given name.
  15259. // It returns an error if the field is not defined in the schema.
  15260. func (m *LabelRelationshipMutation) ResetField(name string) error {
  15261. switch name {
  15262. case labelrelationship.FieldCreatedAt:
  15263. m.ResetCreatedAt()
  15264. return nil
  15265. case labelrelationship.FieldUpdatedAt:
  15266. m.ResetUpdatedAt()
  15267. return nil
  15268. case labelrelationship.FieldStatus:
  15269. m.ResetStatus()
  15270. return nil
  15271. case labelrelationship.FieldLabelID:
  15272. m.ResetLabelID()
  15273. return nil
  15274. case labelrelationship.FieldContactID:
  15275. m.ResetContactID()
  15276. return nil
  15277. case labelrelationship.FieldOrganizationID:
  15278. m.ResetOrganizationID()
  15279. return nil
  15280. }
  15281. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15282. }
  15283. // AddedEdges returns all edge names that were set/added in this mutation.
  15284. func (m *LabelRelationshipMutation) AddedEdges() []string {
  15285. edges := make([]string, 0, 2)
  15286. if m.contacts != nil {
  15287. edges = append(edges, labelrelationship.EdgeContacts)
  15288. }
  15289. if m.labels != nil {
  15290. edges = append(edges, labelrelationship.EdgeLabels)
  15291. }
  15292. return edges
  15293. }
  15294. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15295. // name in this mutation.
  15296. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  15297. switch name {
  15298. case labelrelationship.EdgeContacts:
  15299. if id := m.contacts; id != nil {
  15300. return []ent.Value{*id}
  15301. }
  15302. case labelrelationship.EdgeLabels:
  15303. if id := m.labels; id != nil {
  15304. return []ent.Value{*id}
  15305. }
  15306. }
  15307. return nil
  15308. }
  15309. // RemovedEdges returns all edge names that were removed in this mutation.
  15310. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  15311. edges := make([]string, 0, 2)
  15312. return edges
  15313. }
  15314. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15315. // the given name in this mutation.
  15316. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  15317. return nil
  15318. }
  15319. // ClearedEdges returns all edge names that were cleared in this mutation.
  15320. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  15321. edges := make([]string, 0, 2)
  15322. if m.clearedcontacts {
  15323. edges = append(edges, labelrelationship.EdgeContacts)
  15324. }
  15325. if m.clearedlabels {
  15326. edges = append(edges, labelrelationship.EdgeLabels)
  15327. }
  15328. return edges
  15329. }
  15330. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15331. // was cleared in this mutation.
  15332. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  15333. switch name {
  15334. case labelrelationship.EdgeContacts:
  15335. return m.clearedcontacts
  15336. case labelrelationship.EdgeLabels:
  15337. return m.clearedlabels
  15338. }
  15339. return false
  15340. }
  15341. // ClearEdge clears the value of the edge with the given name. It returns an error
  15342. // if that edge is not defined in the schema.
  15343. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  15344. switch name {
  15345. case labelrelationship.EdgeContacts:
  15346. m.ClearContacts()
  15347. return nil
  15348. case labelrelationship.EdgeLabels:
  15349. m.ClearLabels()
  15350. return nil
  15351. }
  15352. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  15353. }
  15354. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15355. // It returns an error if the edge is not defined in the schema.
  15356. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  15357. switch name {
  15358. case labelrelationship.EdgeContacts:
  15359. m.ResetContacts()
  15360. return nil
  15361. case labelrelationship.EdgeLabels:
  15362. m.ResetLabels()
  15363. return nil
  15364. }
  15365. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  15366. }
  15367. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  15368. type LabelTaggingMutation struct {
  15369. config
  15370. op Op
  15371. typ string
  15372. id *uint64
  15373. created_at *time.Time
  15374. updated_at *time.Time
  15375. status *uint8
  15376. addstatus *int8
  15377. deleted_at *time.Time
  15378. organization_id *uint64
  15379. addorganization_id *int64
  15380. _type *int
  15381. add_type *int
  15382. conditions *string
  15383. action_label_add *[]uint64
  15384. appendaction_label_add []uint64
  15385. action_label_del *[]uint64
  15386. appendaction_label_del []uint64
  15387. clearedFields map[string]struct{}
  15388. done bool
  15389. oldValue func(context.Context) (*LabelTagging, error)
  15390. predicates []predicate.LabelTagging
  15391. }
  15392. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  15393. // labeltaggingOption allows management of the mutation configuration using functional options.
  15394. type labeltaggingOption func(*LabelTaggingMutation)
  15395. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  15396. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  15397. m := &LabelTaggingMutation{
  15398. config: c,
  15399. op: op,
  15400. typ: TypeLabelTagging,
  15401. clearedFields: make(map[string]struct{}),
  15402. }
  15403. for _, opt := range opts {
  15404. opt(m)
  15405. }
  15406. return m
  15407. }
  15408. // withLabelTaggingID sets the ID field of the mutation.
  15409. func withLabelTaggingID(id uint64) labeltaggingOption {
  15410. return func(m *LabelTaggingMutation) {
  15411. var (
  15412. err error
  15413. once sync.Once
  15414. value *LabelTagging
  15415. )
  15416. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  15417. once.Do(func() {
  15418. if m.done {
  15419. err = errors.New("querying old values post mutation is not allowed")
  15420. } else {
  15421. value, err = m.Client().LabelTagging.Get(ctx, id)
  15422. }
  15423. })
  15424. return value, err
  15425. }
  15426. m.id = &id
  15427. }
  15428. }
  15429. // withLabelTagging sets the old LabelTagging of the mutation.
  15430. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  15431. return func(m *LabelTaggingMutation) {
  15432. m.oldValue = func(context.Context) (*LabelTagging, error) {
  15433. return node, nil
  15434. }
  15435. m.id = &node.ID
  15436. }
  15437. }
  15438. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15439. // executed in a transaction (ent.Tx), a transactional client is returned.
  15440. func (m LabelTaggingMutation) Client() *Client {
  15441. client := &Client{config: m.config}
  15442. client.init()
  15443. return client
  15444. }
  15445. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15446. // it returns an error otherwise.
  15447. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  15448. if _, ok := m.driver.(*txDriver); !ok {
  15449. return nil, errors.New("ent: mutation is not running in a transaction")
  15450. }
  15451. tx := &Tx{config: m.config}
  15452. tx.init()
  15453. return tx, nil
  15454. }
  15455. // SetID sets the value of the id field. Note that this
  15456. // operation is only accepted on creation of LabelTagging entities.
  15457. func (m *LabelTaggingMutation) SetID(id uint64) {
  15458. m.id = &id
  15459. }
  15460. // ID returns the ID value in the mutation. Note that the ID is only available
  15461. // if it was provided to the builder or after it was returned from the database.
  15462. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  15463. if m.id == nil {
  15464. return
  15465. }
  15466. return *m.id, true
  15467. }
  15468. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15469. // That means, if the mutation is applied within a transaction with an isolation level such
  15470. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15471. // or updated by the mutation.
  15472. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  15473. switch {
  15474. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15475. id, exists := m.ID()
  15476. if exists {
  15477. return []uint64{id}, nil
  15478. }
  15479. fallthrough
  15480. case m.op.Is(OpUpdate | OpDelete):
  15481. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  15482. default:
  15483. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15484. }
  15485. }
  15486. // SetCreatedAt sets the "created_at" field.
  15487. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  15488. m.created_at = &t
  15489. }
  15490. // CreatedAt returns the value of the "created_at" field in the mutation.
  15491. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  15492. v := m.created_at
  15493. if v == nil {
  15494. return
  15495. }
  15496. return *v, true
  15497. }
  15498. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  15499. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15501. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15502. if !m.op.Is(OpUpdateOne) {
  15503. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15504. }
  15505. if m.id == nil || m.oldValue == nil {
  15506. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15507. }
  15508. oldValue, err := m.oldValue(ctx)
  15509. if err != nil {
  15510. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15511. }
  15512. return oldValue.CreatedAt, nil
  15513. }
  15514. // ResetCreatedAt resets all changes to the "created_at" field.
  15515. func (m *LabelTaggingMutation) ResetCreatedAt() {
  15516. m.created_at = nil
  15517. }
  15518. // SetUpdatedAt sets the "updated_at" field.
  15519. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  15520. m.updated_at = &t
  15521. }
  15522. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15523. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  15524. v := m.updated_at
  15525. if v == nil {
  15526. return
  15527. }
  15528. return *v, true
  15529. }
  15530. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  15531. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15533. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15534. if !m.op.Is(OpUpdateOne) {
  15535. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15536. }
  15537. if m.id == nil || m.oldValue == nil {
  15538. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15539. }
  15540. oldValue, err := m.oldValue(ctx)
  15541. if err != nil {
  15542. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15543. }
  15544. return oldValue.UpdatedAt, nil
  15545. }
  15546. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15547. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  15548. m.updated_at = nil
  15549. }
  15550. // SetStatus sets the "status" field.
  15551. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  15552. m.status = &u
  15553. m.addstatus = nil
  15554. }
  15555. // Status returns the value of the "status" field in the mutation.
  15556. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  15557. v := m.status
  15558. if v == nil {
  15559. return
  15560. }
  15561. return *v, true
  15562. }
  15563. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  15564. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15566. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15567. if !m.op.Is(OpUpdateOne) {
  15568. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15569. }
  15570. if m.id == nil || m.oldValue == nil {
  15571. return v, errors.New("OldStatus requires an ID field in the mutation")
  15572. }
  15573. oldValue, err := m.oldValue(ctx)
  15574. if err != nil {
  15575. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15576. }
  15577. return oldValue.Status, nil
  15578. }
  15579. // AddStatus adds u to the "status" field.
  15580. func (m *LabelTaggingMutation) AddStatus(u int8) {
  15581. if m.addstatus != nil {
  15582. *m.addstatus += u
  15583. } else {
  15584. m.addstatus = &u
  15585. }
  15586. }
  15587. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15588. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  15589. v := m.addstatus
  15590. if v == nil {
  15591. return
  15592. }
  15593. return *v, true
  15594. }
  15595. // ClearStatus clears the value of the "status" field.
  15596. func (m *LabelTaggingMutation) ClearStatus() {
  15597. m.status = nil
  15598. m.addstatus = nil
  15599. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  15600. }
  15601. // StatusCleared returns if the "status" field was cleared in this mutation.
  15602. func (m *LabelTaggingMutation) StatusCleared() bool {
  15603. _, ok := m.clearedFields[labeltagging.FieldStatus]
  15604. return ok
  15605. }
  15606. // ResetStatus resets all changes to the "status" field.
  15607. func (m *LabelTaggingMutation) ResetStatus() {
  15608. m.status = nil
  15609. m.addstatus = nil
  15610. delete(m.clearedFields, labeltagging.FieldStatus)
  15611. }
  15612. // SetDeletedAt sets the "deleted_at" field.
  15613. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  15614. m.deleted_at = &t
  15615. }
  15616. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15617. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  15618. v := m.deleted_at
  15619. if v == nil {
  15620. return
  15621. }
  15622. return *v, true
  15623. }
  15624. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  15625. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15627. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15628. if !m.op.Is(OpUpdateOne) {
  15629. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15630. }
  15631. if m.id == nil || m.oldValue == nil {
  15632. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15633. }
  15634. oldValue, err := m.oldValue(ctx)
  15635. if err != nil {
  15636. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15637. }
  15638. return oldValue.DeletedAt, nil
  15639. }
  15640. // ClearDeletedAt clears the value of the "deleted_at" field.
  15641. func (m *LabelTaggingMutation) ClearDeletedAt() {
  15642. m.deleted_at = nil
  15643. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  15644. }
  15645. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15646. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  15647. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  15648. return ok
  15649. }
  15650. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15651. func (m *LabelTaggingMutation) ResetDeletedAt() {
  15652. m.deleted_at = nil
  15653. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  15654. }
  15655. // SetOrganizationID sets the "organization_id" field.
  15656. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  15657. m.organization_id = &u
  15658. m.addorganization_id = nil
  15659. }
  15660. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15661. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  15662. v := m.organization_id
  15663. if v == nil {
  15664. return
  15665. }
  15666. return *v, true
  15667. }
  15668. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  15669. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15671. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15672. if !m.op.Is(OpUpdateOne) {
  15673. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15674. }
  15675. if m.id == nil || m.oldValue == nil {
  15676. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15677. }
  15678. oldValue, err := m.oldValue(ctx)
  15679. if err != nil {
  15680. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15681. }
  15682. return oldValue.OrganizationID, nil
  15683. }
  15684. // AddOrganizationID adds u to the "organization_id" field.
  15685. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  15686. if m.addorganization_id != nil {
  15687. *m.addorganization_id += u
  15688. } else {
  15689. m.addorganization_id = &u
  15690. }
  15691. }
  15692. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15693. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  15694. v := m.addorganization_id
  15695. if v == nil {
  15696. return
  15697. }
  15698. return *v, true
  15699. }
  15700. // ResetOrganizationID resets all changes to the "organization_id" field.
  15701. func (m *LabelTaggingMutation) ResetOrganizationID() {
  15702. m.organization_id = nil
  15703. m.addorganization_id = nil
  15704. }
  15705. // SetType sets the "type" field.
  15706. func (m *LabelTaggingMutation) SetType(i int) {
  15707. m._type = &i
  15708. m.add_type = nil
  15709. }
  15710. // GetType returns the value of the "type" field in the mutation.
  15711. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  15712. v := m._type
  15713. if v == nil {
  15714. return
  15715. }
  15716. return *v, true
  15717. }
  15718. // OldType returns the old "type" field's value of the LabelTagging entity.
  15719. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15721. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  15722. if !m.op.Is(OpUpdateOne) {
  15723. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15724. }
  15725. if m.id == nil || m.oldValue == nil {
  15726. return v, errors.New("OldType requires an ID field in the mutation")
  15727. }
  15728. oldValue, err := m.oldValue(ctx)
  15729. if err != nil {
  15730. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15731. }
  15732. return oldValue.Type, nil
  15733. }
  15734. // AddType adds i to the "type" field.
  15735. func (m *LabelTaggingMutation) AddType(i int) {
  15736. if m.add_type != nil {
  15737. *m.add_type += i
  15738. } else {
  15739. m.add_type = &i
  15740. }
  15741. }
  15742. // AddedType returns the value that was added to the "type" field in this mutation.
  15743. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  15744. v := m.add_type
  15745. if v == nil {
  15746. return
  15747. }
  15748. return *v, true
  15749. }
  15750. // ResetType resets all changes to the "type" field.
  15751. func (m *LabelTaggingMutation) ResetType() {
  15752. m._type = nil
  15753. m.add_type = nil
  15754. }
  15755. // SetConditions sets the "conditions" field.
  15756. func (m *LabelTaggingMutation) SetConditions(s string) {
  15757. m.conditions = &s
  15758. }
  15759. // Conditions returns the value of the "conditions" field in the mutation.
  15760. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  15761. v := m.conditions
  15762. if v == nil {
  15763. return
  15764. }
  15765. return *v, true
  15766. }
  15767. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  15768. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15770. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  15771. if !m.op.Is(OpUpdateOne) {
  15772. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15773. }
  15774. if m.id == nil || m.oldValue == nil {
  15775. return v, errors.New("OldConditions requires an ID field in the mutation")
  15776. }
  15777. oldValue, err := m.oldValue(ctx)
  15778. if err != nil {
  15779. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15780. }
  15781. return oldValue.Conditions, nil
  15782. }
  15783. // ResetConditions resets all changes to the "conditions" field.
  15784. func (m *LabelTaggingMutation) ResetConditions() {
  15785. m.conditions = nil
  15786. }
  15787. // SetActionLabelAdd sets the "action_label_add" field.
  15788. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  15789. m.action_label_add = &u
  15790. m.appendaction_label_add = nil
  15791. }
  15792. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  15793. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  15794. v := m.action_label_add
  15795. if v == nil {
  15796. return
  15797. }
  15798. return *v, true
  15799. }
  15800. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  15801. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15803. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  15804. if !m.op.Is(OpUpdateOne) {
  15805. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  15806. }
  15807. if m.id == nil || m.oldValue == nil {
  15808. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  15809. }
  15810. oldValue, err := m.oldValue(ctx)
  15811. if err != nil {
  15812. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  15813. }
  15814. return oldValue.ActionLabelAdd, nil
  15815. }
  15816. // AppendActionLabelAdd adds u to the "action_label_add" field.
  15817. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  15818. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  15819. }
  15820. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  15821. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  15822. if len(m.appendaction_label_add) == 0 {
  15823. return nil, false
  15824. }
  15825. return m.appendaction_label_add, true
  15826. }
  15827. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  15828. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  15829. m.action_label_add = nil
  15830. m.appendaction_label_add = nil
  15831. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  15832. }
  15833. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  15834. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  15835. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  15836. return ok
  15837. }
  15838. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  15839. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  15840. m.action_label_add = nil
  15841. m.appendaction_label_add = nil
  15842. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  15843. }
  15844. // SetActionLabelDel sets the "action_label_del" field.
  15845. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  15846. m.action_label_del = &u
  15847. m.appendaction_label_del = nil
  15848. }
  15849. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  15850. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  15851. v := m.action_label_del
  15852. if v == nil {
  15853. return
  15854. }
  15855. return *v, true
  15856. }
  15857. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  15858. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15860. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  15861. if !m.op.Is(OpUpdateOne) {
  15862. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  15863. }
  15864. if m.id == nil || m.oldValue == nil {
  15865. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  15866. }
  15867. oldValue, err := m.oldValue(ctx)
  15868. if err != nil {
  15869. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  15870. }
  15871. return oldValue.ActionLabelDel, nil
  15872. }
  15873. // AppendActionLabelDel adds u to the "action_label_del" field.
  15874. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  15875. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  15876. }
  15877. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  15878. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  15879. if len(m.appendaction_label_del) == 0 {
  15880. return nil, false
  15881. }
  15882. return m.appendaction_label_del, true
  15883. }
  15884. // ClearActionLabelDel clears the value of the "action_label_del" field.
  15885. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  15886. m.action_label_del = nil
  15887. m.appendaction_label_del = nil
  15888. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  15889. }
  15890. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  15891. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  15892. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  15893. return ok
  15894. }
  15895. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  15896. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  15897. m.action_label_del = nil
  15898. m.appendaction_label_del = nil
  15899. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  15900. }
  15901. // Where appends a list predicates to the LabelTaggingMutation builder.
  15902. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  15903. m.predicates = append(m.predicates, ps...)
  15904. }
  15905. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  15906. // users can use type-assertion to append predicates that do not depend on any generated package.
  15907. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  15908. p := make([]predicate.LabelTagging, len(ps))
  15909. for i := range ps {
  15910. p[i] = ps[i]
  15911. }
  15912. m.Where(p...)
  15913. }
  15914. // Op returns the operation name.
  15915. func (m *LabelTaggingMutation) Op() Op {
  15916. return m.op
  15917. }
  15918. // SetOp allows setting the mutation operation.
  15919. func (m *LabelTaggingMutation) SetOp(op Op) {
  15920. m.op = op
  15921. }
  15922. // Type returns the node type of this mutation (LabelTagging).
  15923. func (m *LabelTaggingMutation) Type() string {
  15924. return m.typ
  15925. }
  15926. // Fields returns all fields that were changed during this mutation. Note that in
  15927. // order to get all numeric fields that were incremented/decremented, call
  15928. // AddedFields().
  15929. func (m *LabelTaggingMutation) Fields() []string {
  15930. fields := make([]string, 0, 9)
  15931. if m.created_at != nil {
  15932. fields = append(fields, labeltagging.FieldCreatedAt)
  15933. }
  15934. if m.updated_at != nil {
  15935. fields = append(fields, labeltagging.FieldUpdatedAt)
  15936. }
  15937. if m.status != nil {
  15938. fields = append(fields, labeltagging.FieldStatus)
  15939. }
  15940. if m.deleted_at != nil {
  15941. fields = append(fields, labeltagging.FieldDeletedAt)
  15942. }
  15943. if m.organization_id != nil {
  15944. fields = append(fields, labeltagging.FieldOrganizationID)
  15945. }
  15946. if m._type != nil {
  15947. fields = append(fields, labeltagging.FieldType)
  15948. }
  15949. if m.conditions != nil {
  15950. fields = append(fields, labeltagging.FieldConditions)
  15951. }
  15952. if m.action_label_add != nil {
  15953. fields = append(fields, labeltagging.FieldActionLabelAdd)
  15954. }
  15955. if m.action_label_del != nil {
  15956. fields = append(fields, labeltagging.FieldActionLabelDel)
  15957. }
  15958. return fields
  15959. }
  15960. // Field returns the value of a field with the given name. The second boolean
  15961. // return value indicates that this field was not set, or was not defined in the
  15962. // schema.
  15963. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  15964. switch name {
  15965. case labeltagging.FieldCreatedAt:
  15966. return m.CreatedAt()
  15967. case labeltagging.FieldUpdatedAt:
  15968. return m.UpdatedAt()
  15969. case labeltagging.FieldStatus:
  15970. return m.Status()
  15971. case labeltagging.FieldDeletedAt:
  15972. return m.DeletedAt()
  15973. case labeltagging.FieldOrganizationID:
  15974. return m.OrganizationID()
  15975. case labeltagging.FieldType:
  15976. return m.GetType()
  15977. case labeltagging.FieldConditions:
  15978. return m.Conditions()
  15979. case labeltagging.FieldActionLabelAdd:
  15980. return m.ActionLabelAdd()
  15981. case labeltagging.FieldActionLabelDel:
  15982. return m.ActionLabelDel()
  15983. }
  15984. return nil, false
  15985. }
  15986. // OldField returns the old value of the field from the database. An error is
  15987. // returned if the mutation operation is not UpdateOne, or the query to the
  15988. // database failed.
  15989. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15990. switch name {
  15991. case labeltagging.FieldCreatedAt:
  15992. return m.OldCreatedAt(ctx)
  15993. case labeltagging.FieldUpdatedAt:
  15994. return m.OldUpdatedAt(ctx)
  15995. case labeltagging.FieldStatus:
  15996. return m.OldStatus(ctx)
  15997. case labeltagging.FieldDeletedAt:
  15998. return m.OldDeletedAt(ctx)
  15999. case labeltagging.FieldOrganizationID:
  16000. return m.OldOrganizationID(ctx)
  16001. case labeltagging.FieldType:
  16002. return m.OldType(ctx)
  16003. case labeltagging.FieldConditions:
  16004. return m.OldConditions(ctx)
  16005. case labeltagging.FieldActionLabelAdd:
  16006. return m.OldActionLabelAdd(ctx)
  16007. case labeltagging.FieldActionLabelDel:
  16008. return m.OldActionLabelDel(ctx)
  16009. }
  16010. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  16011. }
  16012. // SetField sets the value of a field with the given name. It returns an error if
  16013. // the field is not defined in the schema, or if the type mismatched the field
  16014. // type.
  16015. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  16016. switch name {
  16017. case labeltagging.FieldCreatedAt:
  16018. v, ok := value.(time.Time)
  16019. if !ok {
  16020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16021. }
  16022. m.SetCreatedAt(v)
  16023. return nil
  16024. case labeltagging.FieldUpdatedAt:
  16025. v, ok := value.(time.Time)
  16026. if !ok {
  16027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16028. }
  16029. m.SetUpdatedAt(v)
  16030. return nil
  16031. case labeltagging.FieldStatus:
  16032. v, ok := value.(uint8)
  16033. if !ok {
  16034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16035. }
  16036. m.SetStatus(v)
  16037. return nil
  16038. case labeltagging.FieldDeletedAt:
  16039. v, ok := value.(time.Time)
  16040. if !ok {
  16041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16042. }
  16043. m.SetDeletedAt(v)
  16044. return nil
  16045. case labeltagging.FieldOrganizationID:
  16046. v, ok := value.(uint64)
  16047. if !ok {
  16048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16049. }
  16050. m.SetOrganizationID(v)
  16051. return nil
  16052. case labeltagging.FieldType:
  16053. v, ok := value.(int)
  16054. if !ok {
  16055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16056. }
  16057. m.SetType(v)
  16058. return nil
  16059. case labeltagging.FieldConditions:
  16060. v, ok := value.(string)
  16061. if !ok {
  16062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16063. }
  16064. m.SetConditions(v)
  16065. return nil
  16066. case labeltagging.FieldActionLabelAdd:
  16067. v, ok := value.([]uint64)
  16068. if !ok {
  16069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16070. }
  16071. m.SetActionLabelAdd(v)
  16072. return nil
  16073. case labeltagging.FieldActionLabelDel:
  16074. v, ok := value.([]uint64)
  16075. if !ok {
  16076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16077. }
  16078. m.SetActionLabelDel(v)
  16079. return nil
  16080. }
  16081. return fmt.Errorf("unknown LabelTagging field %s", name)
  16082. }
  16083. // AddedFields returns all numeric fields that were incremented/decremented during
  16084. // this mutation.
  16085. func (m *LabelTaggingMutation) AddedFields() []string {
  16086. var fields []string
  16087. if m.addstatus != nil {
  16088. fields = append(fields, labeltagging.FieldStatus)
  16089. }
  16090. if m.addorganization_id != nil {
  16091. fields = append(fields, labeltagging.FieldOrganizationID)
  16092. }
  16093. if m.add_type != nil {
  16094. fields = append(fields, labeltagging.FieldType)
  16095. }
  16096. return fields
  16097. }
  16098. // AddedField returns the numeric value that was incremented/decremented on a field
  16099. // with the given name. The second boolean return value indicates that this field
  16100. // was not set, or was not defined in the schema.
  16101. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  16102. switch name {
  16103. case labeltagging.FieldStatus:
  16104. return m.AddedStatus()
  16105. case labeltagging.FieldOrganizationID:
  16106. return m.AddedOrganizationID()
  16107. case labeltagging.FieldType:
  16108. return m.AddedType()
  16109. }
  16110. return nil, false
  16111. }
  16112. // AddField adds the value to the field with the given name. It returns an error if
  16113. // the field is not defined in the schema, or if the type mismatched the field
  16114. // type.
  16115. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  16116. switch name {
  16117. case labeltagging.FieldStatus:
  16118. v, ok := value.(int8)
  16119. if !ok {
  16120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16121. }
  16122. m.AddStatus(v)
  16123. return nil
  16124. case labeltagging.FieldOrganizationID:
  16125. v, ok := value.(int64)
  16126. if !ok {
  16127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16128. }
  16129. m.AddOrganizationID(v)
  16130. return nil
  16131. case labeltagging.FieldType:
  16132. v, ok := value.(int)
  16133. if !ok {
  16134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16135. }
  16136. m.AddType(v)
  16137. return nil
  16138. }
  16139. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  16140. }
  16141. // ClearedFields returns all nullable fields that were cleared during this
  16142. // mutation.
  16143. func (m *LabelTaggingMutation) ClearedFields() []string {
  16144. var fields []string
  16145. if m.FieldCleared(labeltagging.FieldStatus) {
  16146. fields = append(fields, labeltagging.FieldStatus)
  16147. }
  16148. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  16149. fields = append(fields, labeltagging.FieldDeletedAt)
  16150. }
  16151. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  16152. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16153. }
  16154. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  16155. fields = append(fields, labeltagging.FieldActionLabelDel)
  16156. }
  16157. return fields
  16158. }
  16159. // FieldCleared returns a boolean indicating if a field with the given name was
  16160. // cleared in this mutation.
  16161. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  16162. _, ok := m.clearedFields[name]
  16163. return ok
  16164. }
  16165. // ClearField clears the value of the field with the given name. It returns an
  16166. // error if the field is not defined in the schema.
  16167. func (m *LabelTaggingMutation) ClearField(name string) error {
  16168. switch name {
  16169. case labeltagging.FieldStatus:
  16170. m.ClearStatus()
  16171. return nil
  16172. case labeltagging.FieldDeletedAt:
  16173. m.ClearDeletedAt()
  16174. return nil
  16175. case labeltagging.FieldActionLabelAdd:
  16176. m.ClearActionLabelAdd()
  16177. return nil
  16178. case labeltagging.FieldActionLabelDel:
  16179. m.ClearActionLabelDel()
  16180. return nil
  16181. }
  16182. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  16183. }
  16184. // ResetField resets all changes in the mutation for the field with the given name.
  16185. // It returns an error if the field is not defined in the schema.
  16186. func (m *LabelTaggingMutation) ResetField(name string) error {
  16187. switch name {
  16188. case labeltagging.FieldCreatedAt:
  16189. m.ResetCreatedAt()
  16190. return nil
  16191. case labeltagging.FieldUpdatedAt:
  16192. m.ResetUpdatedAt()
  16193. return nil
  16194. case labeltagging.FieldStatus:
  16195. m.ResetStatus()
  16196. return nil
  16197. case labeltagging.FieldDeletedAt:
  16198. m.ResetDeletedAt()
  16199. return nil
  16200. case labeltagging.FieldOrganizationID:
  16201. m.ResetOrganizationID()
  16202. return nil
  16203. case labeltagging.FieldType:
  16204. m.ResetType()
  16205. return nil
  16206. case labeltagging.FieldConditions:
  16207. m.ResetConditions()
  16208. return nil
  16209. case labeltagging.FieldActionLabelAdd:
  16210. m.ResetActionLabelAdd()
  16211. return nil
  16212. case labeltagging.FieldActionLabelDel:
  16213. m.ResetActionLabelDel()
  16214. return nil
  16215. }
  16216. return fmt.Errorf("unknown LabelTagging field %s", name)
  16217. }
  16218. // AddedEdges returns all edge names that were set/added in this mutation.
  16219. func (m *LabelTaggingMutation) AddedEdges() []string {
  16220. edges := make([]string, 0, 0)
  16221. return edges
  16222. }
  16223. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16224. // name in this mutation.
  16225. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  16226. return nil
  16227. }
  16228. // RemovedEdges returns all edge names that were removed in this mutation.
  16229. func (m *LabelTaggingMutation) RemovedEdges() []string {
  16230. edges := make([]string, 0, 0)
  16231. return edges
  16232. }
  16233. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16234. // the given name in this mutation.
  16235. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  16236. return nil
  16237. }
  16238. // ClearedEdges returns all edge names that were cleared in this mutation.
  16239. func (m *LabelTaggingMutation) ClearedEdges() []string {
  16240. edges := make([]string, 0, 0)
  16241. return edges
  16242. }
  16243. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16244. // was cleared in this mutation.
  16245. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  16246. return false
  16247. }
  16248. // ClearEdge clears the value of the edge with the given name. It returns an error
  16249. // if that edge is not defined in the schema.
  16250. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  16251. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  16252. }
  16253. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16254. // It returns an error if the edge is not defined in the schema.
  16255. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  16256. return fmt.Errorf("unknown LabelTagging edge %s", name)
  16257. }
  16258. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  16259. type MessageMutation struct {
  16260. config
  16261. op Op
  16262. typ string
  16263. id *int
  16264. wx_wxid *string
  16265. wxid *string
  16266. content *string
  16267. clearedFields map[string]struct{}
  16268. done bool
  16269. oldValue func(context.Context) (*Message, error)
  16270. predicates []predicate.Message
  16271. }
  16272. var _ ent.Mutation = (*MessageMutation)(nil)
  16273. // messageOption allows management of the mutation configuration using functional options.
  16274. type messageOption func(*MessageMutation)
  16275. // newMessageMutation creates new mutation for the Message entity.
  16276. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  16277. m := &MessageMutation{
  16278. config: c,
  16279. op: op,
  16280. typ: TypeMessage,
  16281. clearedFields: make(map[string]struct{}),
  16282. }
  16283. for _, opt := range opts {
  16284. opt(m)
  16285. }
  16286. return m
  16287. }
  16288. // withMessageID sets the ID field of the mutation.
  16289. func withMessageID(id int) messageOption {
  16290. return func(m *MessageMutation) {
  16291. var (
  16292. err error
  16293. once sync.Once
  16294. value *Message
  16295. )
  16296. m.oldValue = func(ctx context.Context) (*Message, error) {
  16297. once.Do(func() {
  16298. if m.done {
  16299. err = errors.New("querying old values post mutation is not allowed")
  16300. } else {
  16301. value, err = m.Client().Message.Get(ctx, id)
  16302. }
  16303. })
  16304. return value, err
  16305. }
  16306. m.id = &id
  16307. }
  16308. }
  16309. // withMessage sets the old Message of the mutation.
  16310. func withMessage(node *Message) messageOption {
  16311. return func(m *MessageMutation) {
  16312. m.oldValue = func(context.Context) (*Message, error) {
  16313. return node, nil
  16314. }
  16315. m.id = &node.ID
  16316. }
  16317. }
  16318. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16319. // executed in a transaction (ent.Tx), a transactional client is returned.
  16320. func (m MessageMutation) Client() *Client {
  16321. client := &Client{config: m.config}
  16322. client.init()
  16323. return client
  16324. }
  16325. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16326. // it returns an error otherwise.
  16327. func (m MessageMutation) Tx() (*Tx, error) {
  16328. if _, ok := m.driver.(*txDriver); !ok {
  16329. return nil, errors.New("ent: mutation is not running in a transaction")
  16330. }
  16331. tx := &Tx{config: m.config}
  16332. tx.init()
  16333. return tx, nil
  16334. }
  16335. // ID returns the ID value in the mutation. Note that the ID is only available
  16336. // if it was provided to the builder or after it was returned from the database.
  16337. func (m *MessageMutation) ID() (id int, exists bool) {
  16338. if m.id == nil {
  16339. return
  16340. }
  16341. return *m.id, true
  16342. }
  16343. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16344. // That means, if the mutation is applied within a transaction with an isolation level such
  16345. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16346. // or updated by the mutation.
  16347. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  16348. switch {
  16349. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16350. id, exists := m.ID()
  16351. if exists {
  16352. return []int{id}, nil
  16353. }
  16354. fallthrough
  16355. case m.op.Is(OpUpdate | OpDelete):
  16356. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  16357. default:
  16358. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16359. }
  16360. }
  16361. // SetWxWxid sets the "wx_wxid" field.
  16362. func (m *MessageMutation) SetWxWxid(s string) {
  16363. m.wx_wxid = &s
  16364. }
  16365. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  16366. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  16367. v := m.wx_wxid
  16368. if v == nil {
  16369. return
  16370. }
  16371. return *v, true
  16372. }
  16373. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  16374. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16376. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  16377. if !m.op.Is(OpUpdateOne) {
  16378. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  16379. }
  16380. if m.id == nil || m.oldValue == nil {
  16381. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  16382. }
  16383. oldValue, err := m.oldValue(ctx)
  16384. if err != nil {
  16385. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  16386. }
  16387. return oldValue.WxWxid, nil
  16388. }
  16389. // ClearWxWxid clears the value of the "wx_wxid" field.
  16390. func (m *MessageMutation) ClearWxWxid() {
  16391. m.wx_wxid = nil
  16392. m.clearedFields[message.FieldWxWxid] = struct{}{}
  16393. }
  16394. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  16395. func (m *MessageMutation) WxWxidCleared() bool {
  16396. _, ok := m.clearedFields[message.FieldWxWxid]
  16397. return ok
  16398. }
  16399. // ResetWxWxid resets all changes to the "wx_wxid" field.
  16400. func (m *MessageMutation) ResetWxWxid() {
  16401. m.wx_wxid = nil
  16402. delete(m.clearedFields, message.FieldWxWxid)
  16403. }
  16404. // SetWxid sets the "wxid" field.
  16405. func (m *MessageMutation) SetWxid(s string) {
  16406. m.wxid = &s
  16407. }
  16408. // Wxid returns the value of the "wxid" field in the mutation.
  16409. func (m *MessageMutation) Wxid() (r string, exists bool) {
  16410. v := m.wxid
  16411. if v == nil {
  16412. return
  16413. }
  16414. return *v, true
  16415. }
  16416. // OldWxid returns the old "wxid" field's value of the Message entity.
  16417. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16419. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  16420. if !m.op.Is(OpUpdateOne) {
  16421. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  16422. }
  16423. if m.id == nil || m.oldValue == nil {
  16424. return v, errors.New("OldWxid requires an ID field in the mutation")
  16425. }
  16426. oldValue, err := m.oldValue(ctx)
  16427. if err != nil {
  16428. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  16429. }
  16430. return oldValue.Wxid, nil
  16431. }
  16432. // ResetWxid resets all changes to the "wxid" field.
  16433. func (m *MessageMutation) ResetWxid() {
  16434. m.wxid = nil
  16435. }
  16436. // SetContent sets the "content" field.
  16437. func (m *MessageMutation) SetContent(s string) {
  16438. m.content = &s
  16439. }
  16440. // Content returns the value of the "content" field in the mutation.
  16441. func (m *MessageMutation) Content() (r string, exists bool) {
  16442. v := m.content
  16443. if v == nil {
  16444. return
  16445. }
  16446. return *v, true
  16447. }
  16448. // OldContent returns the old "content" field's value of the Message entity.
  16449. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16451. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  16452. if !m.op.Is(OpUpdateOne) {
  16453. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16454. }
  16455. if m.id == nil || m.oldValue == nil {
  16456. return v, errors.New("OldContent requires an ID field in the mutation")
  16457. }
  16458. oldValue, err := m.oldValue(ctx)
  16459. if err != nil {
  16460. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16461. }
  16462. return oldValue.Content, nil
  16463. }
  16464. // ResetContent resets all changes to the "content" field.
  16465. func (m *MessageMutation) ResetContent() {
  16466. m.content = nil
  16467. }
  16468. // Where appends a list predicates to the MessageMutation builder.
  16469. func (m *MessageMutation) Where(ps ...predicate.Message) {
  16470. m.predicates = append(m.predicates, ps...)
  16471. }
  16472. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  16473. // users can use type-assertion to append predicates that do not depend on any generated package.
  16474. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  16475. p := make([]predicate.Message, len(ps))
  16476. for i := range ps {
  16477. p[i] = ps[i]
  16478. }
  16479. m.Where(p...)
  16480. }
  16481. // Op returns the operation name.
  16482. func (m *MessageMutation) Op() Op {
  16483. return m.op
  16484. }
  16485. // SetOp allows setting the mutation operation.
  16486. func (m *MessageMutation) SetOp(op Op) {
  16487. m.op = op
  16488. }
  16489. // Type returns the node type of this mutation (Message).
  16490. func (m *MessageMutation) Type() string {
  16491. return m.typ
  16492. }
  16493. // Fields returns all fields that were changed during this mutation. Note that in
  16494. // order to get all numeric fields that were incremented/decremented, call
  16495. // AddedFields().
  16496. func (m *MessageMutation) Fields() []string {
  16497. fields := make([]string, 0, 3)
  16498. if m.wx_wxid != nil {
  16499. fields = append(fields, message.FieldWxWxid)
  16500. }
  16501. if m.wxid != nil {
  16502. fields = append(fields, message.FieldWxid)
  16503. }
  16504. if m.content != nil {
  16505. fields = append(fields, message.FieldContent)
  16506. }
  16507. return fields
  16508. }
  16509. // Field returns the value of a field with the given name. The second boolean
  16510. // return value indicates that this field was not set, or was not defined in the
  16511. // schema.
  16512. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  16513. switch name {
  16514. case message.FieldWxWxid:
  16515. return m.WxWxid()
  16516. case message.FieldWxid:
  16517. return m.Wxid()
  16518. case message.FieldContent:
  16519. return m.Content()
  16520. }
  16521. return nil, false
  16522. }
  16523. // OldField returns the old value of the field from the database. An error is
  16524. // returned if the mutation operation is not UpdateOne, or the query to the
  16525. // database failed.
  16526. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16527. switch name {
  16528. case message.FieldWxWxid:
  16529. return m.OldWxWxid(ctx)
  16530. case message.FieldWxid:
  16531. return m.OldWxid(ctx)
  16532. case message.FieldContent:
  16533. return m.OldContent(ctx)
  16534. }
  16535. return nil, fmt.Errorf("unknown Message field %s", name)
  16536. }
  16537. // SetField sets the value of a field with the given name. It returns an error if
  16538. // the field is not defined in the schema, or if the type mismatched the field
  16539. // type.
  16540. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  16541. switch name {
  16542. case message.FieldWxWxid:
  16543. v, ok := value.(string)
  16544. if !ok {
  16545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16546. }
  16547. m.SetWxWxid(v)
  16548. return nil
  16549. case message.FieldWxid:
  16550. v, ok := value.(string)
  16551. if !ok {
  16552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16553. }
  16554. m.SetWxid(v)
  16555. return nil
  16556. case message.FieldContent:
  16557. v, ok := value.(string)
  16558. if !ok {
  16559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16560. }
  16561. m.SetContent(v)
  16562. return nil
  16563. }
  16564. return fmt.Errorf("unknown Message field %s", name)
  16565. }
  16566. // AddedFields returns all numeric fields that were incremented/decremented during
  16567. // this mutation.
  16568. func (m *MessageMutation) AddedFields() []string {
  16569. return nil
  16570. }
  16571. // AddedField returns the numeric value that was incremented/decremented on a field
  16572. // with the given name. The second boolean return value indicates that this field
  16573. // was not set, or was not defined in the schema.
  16574. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  16575. return nil, false
  16576. }
  16577. // AddField adds the value to the field with the given name. It returns an error if
  16578. // the field is not defined in the schema, or if the type mismatched the field
  16579. // type.
  16580. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  16581. switch name {
  16582. }
  16583. return fmt.Errorf("unknown Message numeric field %s", name)
  16584. }
  16585. // ClearedFields returns all nullable fields that were cleared during this
  16586. // mutation.
  16587. func (m *MessageMutation) ClearedFields() []string {
  16588. var fields []string
  16589. if m.FieldCleared(message.FieldWxWxid) {
  16590. fields = append(fields, message.FieldWxWxid)
  16591. }
  16592. return fields
  16593. }
  16594. // FieldCleared returns a boolean indicating if a field with the given name was
  16595. // cleared in this mutation.
  16596. func (m *MessageMutation) FieldCleared(name string) bool {
  16597. _, ok := m.clearedFields[name]
  16598. return ok
  16599. }
  16600. // ClearField clears the value of the field with the given name. It returns an
  16601. // error if the field is not defined in the schema.
  16602. func (m *MessageMutation) ClearField(name string) error {
  16603. switch name {
  16604. case message.FieldWxWxid:
  16605. m.ClearWxWxid()
  16606. return nil
  16607. }
  16608. return fmt.Errorf("unknown Message nullable field %s", name)
  16609. }
  16610. // ResetField resets all changes in the mutation for the field with the given name.
  16611. // It returns an error if the field is not defined in the schema.
  16612. func (m *MessageMutation) ResetField(name string) error {
  16613. switch name {
  16614. case message.FieldWxWxid:
  16615. m.ResetWxWxid()
  16616. return nil
  16617. case message.FieldWxid:
  16618. m.ResetWxid()
  16619. return nil
  16620. case message.FieldContent:
  16621. m.ResetContent()
  16622. return nil
  16623. }
  16624. return fmt.Errorf("unknown Message field %s", name)
  16625. }
  16626. // AddedEdges returns all edge names that were set/added in this mutation.
  16627. func (m *MessageMutation) AddedEdges() []string {
  16628. edges := make([]string, 0, 0)
  16629. return edges
  16630. }
  16631. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16632. // name in this mutation.
  16633. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  16634. return nil
  16635. }
  16636. // RemovedEdges returns all edge names that were removed in this mutation.
  16637. func (m *MessageMutation) RemovedEdges() []string {
  16638. edges := make([]string, 0, 0)
  16639. return edges
  16640. }
  16641. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16642. // the given name in this mutation.
  16643. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  16644. return nil
  16645. }
  16646. // ClearedEdges returns all edge names that were cleared in this mutation.
  16647. func (m *MessageMutation) ClearedEdges() []string {
  16648. edges := make([]string, 0, 0)
  16649. return edges
  16650. }
  16651. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16652. // was cleared in this mutation.
  16653. func (m *MessageMutation) EdgeCleared(name string) bool {
  16654. return false
  16655. }
  16656. // ClearEdge clears the value of the edge with the given name. It returns an error
  16657. // if that edge is not defined in the schema.
  16658. func (m *MessageMutation) ClearEdge(name string) error {
  16659. return fmt.Errorf("unknown Message unique edge %s", name)
  16660. }
  16661. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16662. // It returns an error if the edge is not defined in the schema.
  16663. func (m *MessageMutation) ResetEdge(name string) error {
  16664. return fmt.Errorf("unknown Message edge %s", name)
  16665. }
  16666. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  16667. type MessageRecordsMutation struct {
  16668. config
  16669. op Op
  16670. typ string
  16671. id *uint64
  16672. created_at *time.Time
  16673. updated_at *time.Time
  16674. status *uint8
  16675. addstatus *int8
  16676. bot_wxid *string
  16677. contact_type *int
  16678. addcontact_type *int
  16679. contact_wxid *string
  16680. content_type *int
  16681. addcontent_type *int
  16682. content *string
  16683. meta *custom_types.Meta
  16684. error_detail *string
  16685. send_time *time.Time
  16686. source_type *int
  16687. addsource_type *int
  16688. organization_id *uint64
  16689. addorganization_id *int64
  16690. clearedFields map[string]struct{}
  16691. sop_stage *uint64
  16692. clearedsop_stage bool
  16693. sop_node *uint64
  16694. clearedsop_node bool
  16695. message_contact *uint64
  16696. clearedmessage_contact bool
  16697. done bool
  16698. oldValue func(context.Context) (*MessageRecords, error)
  16699. predicates []predicate.MessageRecords
  16700. }
  16701. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  16702. // messagerecordsOption allows management of the mutation configuration using functional options.
  16703. type messagerecordsOption func(*MessageRecordsMutation)
  16704. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  16705. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  16706. m := &MessageRecordsMutation{
  16707. config: c,
  16708. op: op,
  16709. typ: TypeMessageRecords,
  16710. clearedFields: make(map[string]struct{}),
  16711. }
  16712. for _, opt := range opts {
  16713. opt(m)
  16714. }
  16715. return m
  16716. }
  16717. // withMessageRecordsID sets the ID field of the mutation.
  16718. func withMessageRecordsID(id uint64) messagerecordsOption {
  16719. return func(m *MessageRecordsMutation) {
  16720. var (
  16721. err error
  16722. once sync.Once
  16723. value *MessageRecords
  16724. )
  16725. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  16726. once.Do(func() {
  16727. if m.done {
  16728. err = errors.New("querying old values post mutation is not allowed")
  16729. } else {
  16730. value, err = m.Client().MessageRecords.Get(ctx, id)
  16731. }
  16732. })
  16733. return value, err
  16734. }
  16735. m.id = &id
  16736. }
  16737. }
  16738. // withMessageRecords sets the old MessageRecords of the mutation.
  16739. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  16740. return func(m *MessageRecordsMutation) {
  16741. m.oldValue = func(context.Context) (*MessageRecords, error) {
  16742. return node, nil
  16743. }
  16744. m.id = &node.ID
  16745. }
  16746. }
  16747. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16748. // executed in a transaction (ent.Tx), a transactional client is returned.
  16749. func (m MessageRecordsMutation) Client() *Client {
  16750. client := &Client{config: m.config}
  16751. client.init()
  16752. return client
  16753. }
  16754. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16755. // it returns an error otherwise.
  16756. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  16757. if _, ok := m.driver.(*txDriver); !ok {
  16758. return nil, errors.New("ent: mutation is not running in a transaction")
  16759. }
  16760. tx := &Tx{config: m.config}
  16761. tx.init()
  16762. return tx, nil
  16763. }
  16764. // SetID sets the value of the id field. Note that this
  16765. // operation is only accepted on creation of MessageRecords entities.
  16766. func (m *MessageRecordsMutation) SetID(id uint64) {
  16767. m.id = &id
  16768. }
  16769. // ID returns the ID value in the mutation. Note that the ID is only available
  16770. // if it was provided to the builder or after it was returned from the database.
  16771. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  16772. if m.id == nil {
  16773. return
  16774. }
  16775. return *m.id, true
  16776. }
  16777. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16778. // That means, if the mutation is applied within a transaction with an isolation level such
  16779. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16780. // or updated by the mutation.
  16781. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  16782. switch {
  16783. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16784. id, exists := m.ID()
  16785. if exists {
  16786. return []uint64{id}, nil
  16787. }
  16788. fallthrough
  16789. case m.op.Is(OpUpdate | OpDelete):
  16790. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  16791. default:
  16792. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16793. }
  16794. }
  16795. // SetCreatedAt sets the "created_at" field.
  16796. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  16797. m.created_at = &t
  16798. }
  16799. // CreatedAt returns the value of the "created_at" field in the mutation.
  16800. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  16801. v := m.created_at
  16802. if v == nil {
  16803. return
  16804. }
  16805. return *v, true
  16806. }
  16807. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  16808. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16810. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16811. if !m.op.Is(OpUpdateOne) {
  16812. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16813. }
  16814. if m.id == nil || m.oldValue == nil {
  16815. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16816. }
  16817. oldValue, err := m.oldValue(ctx)
  16818. if err != nil {
  16819. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16820. }
  16821. return oldValue.CreatedAt, nil
  16822. }
  16823. // ResetCreatedAt resets all changes to the "created_at" field.
  16824. func (m *MessageRecordsMutation) ResetCreatedAt() {
  16825. m.created_at = nil
  16826. }
  16827. // SetUpdatedAt sets the "updated_at" field.
  16828. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  16829. m.updated_at = &t
  16830. }
  16831. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16832. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  16833. v := m.updated_at
  16834. if v == nil {
  16835. return
  16836. }
  16837. return *v, true
  16838. }
  16839. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  16840. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16842. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16843. if !m.op.Is(OpUpdateOne) {
  16844. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16845. }
  16846. if m.id == nil || m.oldValue == nil {
  16847. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16848. }
  16849. oldValue, err := m.oldValue(ctx)
  16850. if err != nil {
  16851. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16852. }
  16853. return oldValue.UpdatedAt, nil
  16854. }
  16855. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16856. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  16857. m.updated_at = nil
  16858. }
  16859. // SetStatus sets the "status" field.
  16860. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  16861. m.status = &u
  16862. m.addstatus = nil
  16863. }
  16864. // Status returns the value of the "status" field in the mutation.
  16865. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  16866. v := m.status
  16867. if v == nil {
  16868. return
  16869. }
  16870. return *v, true
  16871. }
  16872. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  16873. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16875. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16876. if !m.op.Is(OpUpdateOne) {
  16877. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16878. }
  16879. if m.id == nil || m.oldValue == nil {
  16880. return v, errors.New("OldStatus requires an ID field in the mutation")
  16881. }
  16882. oldValue, err := m.oldValue(ctx)
  16883. if err != nil {
  16884. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16885. }
  16886. return oldValue.Status, nil
  16887. }
  16888. // AddStatus adds u to the "status" field.
  16889. func (m *MessageRecordsMutation) AddStatus(u int8) {
  16890. if m.addstatus != nil {
  16891. *m.addstatus += u
  16892. } else {
  16893. m.addstatus = &u
  16894. }
  16895. }
  16896. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16897. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  16898. v := m.addstatus
  16899. if v == nil {
  16900. return
  16901. }
  16902. return *v, true
  16903. }
  16904. // ClearStatus clears the value of the "status" field.
  16905. func (m *MessageRecordsMutation) ClearStatus() {
  16906. m.status = nil
  16907. m.addstatus = nil
  16908. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  16909. }
  16910. // StatusCleared returns if the "status" field was cleared in this mutation.
  16911. func (m *MessageRecordsMutation) StatusCleared() bool {
  16912. _, ok := m.clearedFields[messagerecords.FieldStatus]
  16913. return ok
  16914. }
  16915. // ResetStatus resets all changes to the "status" field.
  16916. func (m *MessageRecordsMutation) ResetStatus() {
  16917. m.status = nil
  16918. m.addstatus = nil
  16919. delete(m.clearedFields, messagerecords.FieldStatus)
  16920. }
  16921. // SetBotWxid sets the "bot_wxid" field.
  16922. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  16923. m.bot_wxid = &s
  16924. }
  16925. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  16926. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  16927. v := m.bot_wxid
  16928. if v == nil {
  16929. return
  16930. }
  16931. return *v, true
  16932. }
  16933. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  16934. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16936. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  16937. if !m.op.Is(OpUpdateOne) {
  16938. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  16939. }
  16940. if m.id == nil || m.oldValue == nil {
  16941. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  16942. }
  16943. oldValue, err := m.oldValue(ctx)
  16944. if err != nil {
  16945. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  16946. }
  16947. return oldValue.BotWxid, nil
  16948. }
  16949. // ResetBotWxid resets all changes to the "bot_wxid" field.
  16950. func (m *MessageRecordsMutation) ResetBotWxid() {
  16951. m.bot_wxid = nil
  16952. }
  16953. // SetContactID sets the "contact_id" field.
  16954. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  16955. m.message_contact = &u
  16956. }
  16957. // ContactID returns the value of the "contact_id" field in the mutation.
  16958. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  16959. v := m.message_contact
  16960. if v == nil {
  16961. return
  16962. }
  16963. return *v, true
  16964. }
  16965. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  16966. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16968. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  16969. if !m.op.Is(OpUpdateOne) {
  16970. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  16971. }
  16972. if m.id == nil || m.oldValue == nil {
  16973. return v, errors.New("OldContactID requires an ID field in the mutation")
  16974. }
  16975. oldValue, err := m.oldValue(ctx)
  16976. if err != nil {
  16977. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  16978. }
  16979. return oldValue.ContactID, nil
  16980. }
  16981. // ClearContactID clears the value of the "contact_id" field.
  16982. func (m *MessageRecordsMutation) ClearContactID() {
  16983. m.message_contact = nil
  16984. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  16985. }
  16986. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  16987. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  16988. _, ok := m.clearedFields[messagerecords.FieldContactID]
  16989. return ok
  16990. }
  16991. // ResetContactID resets all changes to the "contact_id" field.
  16992. func (m *MessageRecordsMutation) ResetContactID() {
  16993. m.message_contact = nil
  16994. delete(m.clearedFields, messagerecords.FieldContactID)
  16995. }
  16996. // SetContactType sets the "contact_type" field.
  16997. func (m *MessageRecordsMutation) SetContactType(i int) {
  16998. m.contact_type = &i
  16999. m.addcontact_type = nil
  17000. }
  17001. // ContactType returns the value of the "contact_type" field in the mutation.
  17002. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  17003. v := m.contact_type
  17004. if v == nil {
  17005. return
  17006. }
  17007. return *v, true
  17008. }
  17009. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  17010. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17012. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  17013. if !m.op.Is(OpUpdateOne) {
  17014. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  17015. }
  17016. if m.id == nil || m.oldValue == nil {
  17017. return v, errors.New("OldContactType requires an ID field in the mutation")
  17018. }
  17019. oldValue, err := m.oldValue(ctx)
  17020. if err != nil {
  17021. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  17022. }
  17023. return oldValue.ContactType, nil
  17024. }
  17025. // AddContactType adds i to the "contact_type" field.
  17026. func (m *MessageRecordsMutation) AddContactType(i int) {
  17027. if m.addcontact_type != nil {
  17028. *m.addcontact_type += i
  17029. } else {
  17030. m.addcontact_type = &i
  17031. }
  17032. }
  17033. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  17034. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  17035. v := m.addcontact_type
  17036. if v == nil {
  17037. return
  17038. }
  17039. return *v, true
  17040. }
  17041. // ResetContactType resets all changes to the "contact_type" field.
  17042. func (m *MessageRecordsMutation) ResetContactType() {
  17043. m.contact_type = nil
  17044. m.addcontact_type = nil
  17045. }
  17046. // SetContactWxid sets the "contact_wxid" field.
  17047. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  17048. m.contact_wxid = &s
  17049. }
  17050. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  17051. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  17052. v := m.contact_wxid
  17053. if v == nil {
  17054. return
  17055. }
  17056. return *v, true
  17057. }
  17058. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  17059. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17061. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  17062. if !m.op.Is(OpUpdateOne) {
  17063. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  17064. }
  17065. if m.id == nil || m.oldValue == nil {
  17066. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  17067. }
  17068. oldValue, err := m.oldValue(ctx)
  17069. if err != nil {
  17070. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  17071. }
  17072. return oldValue.ContactWxid, nil
  17073. }
  17074. // ResetContactWxid resets all changes to the "contact_wxid" field.
  17075. func (m *MessageRecordsMutation) ResetContactWxid() {
  17076. m.contact_wxid = nil
  17077. }
  17078. // SetContentType sets the "content_type" field.
  17079. func (m *MessageRecordsMutation) SetContentType(i int) {
  17080. m.content_type = &i
  17081. m.addcontent_type = nil
  17082. }
  17083. // ContentType returns the value of the "content_type" field in the mutation.
  17084. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  17085. v := m.content_type
  17086. if v == nil {
  17087. return
  17088. }
  17089. return *v, true
  17090. }
  17091. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  17092. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17094. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  17095. if !m.op.Is(OpUpdateOne) {
  17096. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  17097. }
  17098. if m.id == nil || m.oldValue == nil {
  17099. return v, errors.New("OldContentType requires an ID field in the mutation")
  17100. }
  17101. oldValue, err := m.oldValue(ctx)
  17102. if err != nil {
  17103. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  17104. }
  17105. return oldValue.ContentType, nil
  17106. }
  17107. // AddContentType adds i to the "content_type" field.
  17108. func (m *MessageRecordsMutation) AddContentType(i int) {
  17109. if m.addcontent_type != nil {
  17110. *m.addcontent_type += i
  17111. } else {
  17112. m.addcontent_type = &i
  17113. }
  17114. }
  17115. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  17116. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  17117. v := m.addcontent_type
  17118. if v == nil {
  17119. return
  17120. }
  17121. return *v, true
  17122. }
  17123. // ResetContentType resets all changes to the "content_type" field.
  17124. func (m *MessageRecordsMutation) ResetContentType() {
  17125. m.content_type = nil
  17126. m.addcontent_type = nil
  17127. }
  17128. // SetContent sets the "content" field.
  17129. func (m *MessageRecordsMutation) SetContent(s string) {
  17130. m.content = &s
  17131. }
  17132. // Content returns the value of the "content" field in the mutation.
  17133. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  17134. v := m.content
  17135. if v == nil {
  17136. return
  17137. }
  17138. return *v, true
  17139. }
  17140. // OldContent returns the old "content" field's value of the MessageRecords entity.
  17141. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17143. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  17144. if !m.op.Is(OpUpdateOne) {
  17145. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17146. }
  17147. if m.id == nil || m.oldValue == nil {
  17148. return v, errors.New("OldContent requires an ID field in the mutation")
  17149. }
  17150. oldValue, err := m.oldValue(ctx)
  17151. if err != nil {
  17152. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17153. }
  17154. return oldValue.Content, nil
  17155. }
  17156. // ResetContent resets all changes to the "content" field.
  17157. func (m *MessageRecordsMutation) ResetContent() {
  17158. m.content = nil
  17159. }
  17160. // SetMeta sets the "meta" field.
  17161. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  17162. m.meta = &ct
  17163. }
  17164. // Meta returns the value of the "meta" field in the mutation.
  17165. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  17166. v := m.meta
  17167. if v == nil {
  17168. return
  17169. }
  17170. return *v, true
  17171. }
  17172. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  17173. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17175. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  17176. if !m.op.Is(OpUpdateOne) {
  17177. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  17178. }
  17179. if m.id == nil || m.oldValue == nil {
  17180. return v, errors.New("OldMeta requires an ID field in the mutation")
  17181. }
  17182. oldValue, err := m.oldValue(ctx)
  17183. if err != nil {
  17184. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  17185. }
  17186. return oldValue.Meta, nil
  17187. }
  17188. // ClearMeta clears the value of the "meta" field.
  17189. func (m *MessageRecordsMutation) ClearMeta() {
  17190. m.meta = nil
  17191. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  17192. }
  17193. // MetaCleared returns if the "meta" field was cleared in this mutation.
  17194. func (m *MessageRecordsMutation) MetaCleared() bool {
  17195. _, ok := m.clearedFields[messagerecords.FieldMeta]
  17196. return ok
  17197. }
  17198. // ResetMeta resets all changes to the "meta" field.
  17199. func (m *MessageRecordsMutation) ResetMeta() {
  17200. m.meta = nil
  17201. delete(m.clearedFields, messagerecords.FieldMeta)
  17202. }
  17203. // SetErrorDetail sets the "error_detail" field.
  17204. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  17205. m.error_detail = &s
  17206. }
  17207. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  17208. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  17209. v := m.error_detail
  17210. if v == nil {
  17211. return
  17212. }
  17213. return *v, true
  17214. }
  17215. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  17216. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17218. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  17219. if !m.op.Is(OpUpdateOne) {
  17220. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  17221. }
  17222. if m.id == nil || m.oldValue == nil {
  17223. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  17224. }
  17225. oldValue, err := m.oldValue(ctx)
  17226. if err != nil {
  17227. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  17228. }
  17229. return oldValue.ErrorDetail, nil
  17230. }
  17231. // ResetErrorDetail resets all changes to the "error_detail" field.
  17232. func (m *MessageRecordsMutation) ResetErrorDetail() {
  17233. m.error_detail = nil
  17234. }
  17235. // SetSendTime sets the "send_time" field.
  17236. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  17237. m.send_time = &t
  17238. }
  17239. // SendTime returns the value of the "send_time" field in the mutation.
  17240. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  17241. v := m.send_time
  17242. if v == nil {
  17243. return
  17244. }
  17245. return *v, true
  17246. }
  17247. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  17248. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17250. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  17251. if !m.op.Is(OpUpdateOne) {
  17252. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  17253. }
  17254. if m.id == nil || m.oldValue == nil {
  17255. return v, errors.New("OldSendTime requires an ID field in the mutation")
  17256. }
  17257. oldValue, err := m.oldValue(ctx)
  17258. if err != nil {
  17259. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  17260. }
  17261. return oldValue.SendTime, nil
  17262. }
  17263. // ClearSendTime clears the value of the "send_time" field.
  17264. func (m *MessageRecordsMutation) ClearSendTime() {
  17265. m.send_time = nil
  17266. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  17267. }
  17268. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  17269. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  17270. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  17271. return ok
  17272. }
  17273. // ResetSendTime resets all changes to the "send_time" field.
  17274. func (m *MessageRecordsMutation) ResetSendTime() {
  17275. m.send_time = nil
  17276. delete(m.clearedFields, messagerecords.FieldSendTime)
  17277. }
  17278. // SetSourceType sets the "source_type" field.
  17279. func (m *MessageRecordsMutation) SetSourceType(i int) {
  17280. m.source_type = &i
  17281. m.addsource_type = nil
  17282. }
  17283. // SourceType returns the value of the "source_type" field in the mutation.
  17284. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  17285. v := m.source_type
  17286. if v == nil {
  17287. return
  17288. }
  17289. return *v, true
  17290. }
  17291. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  17292. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17294. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  17295. if !m.op.Is(OpUpdateOne) {
  17296. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  17297. }
  17298. if m.id == nil || m.oldValue == nil {
  17299. return v, errors.New("OldSourceType requires an ID field in the mutation")
  17300. }
  17301. oldValue, err := m.oldValue(ctx)
  17302. if err != nil {
  17303. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  17304. }
  17305. return oldValue.SourceType, nil
  17306. }
  17307. // AddSourceType adds i to the "source_type" field.
  17308. func (m *MessageRecordsMutation) AddSourceType(i int) {
  17309. if m.addsource_type != nil {
  17310. *m.addsource_type += i
  17311. } else {
  17312. m.addsource_type = &i
  17313. }
  17314. }
  17315. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  17316. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  17317. v := m.addsource_type
  17318. if v == nil {
  17319. return
  17320. }
  17321. return *v, true
  17322. }
  17323. // ResetSourceType resets all changes to the "source_type" field.
  17324. func (m *MessageRecordsMutation) ResetSourceType() {
  17325. m.source_type = nil
  17326. m.addsource_type = nil
  17327. }
  17328. // SetSourceID sets the "source_id" field.
  17329. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  17330. m.sop_stage = &u
  17331. }
  17332. // SourceID returns the value of the "source_id" field in the mutation.
  17333. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  17334. v := m.sop_stage
  17335. if v == nil {
  17336. return
  17337. }
  17338. return *v, true
  17339. }
  17340. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  17341. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17343. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  17344. if !m.op.Is(OpUpdateOne) {
  17345. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  17346. }
  17347. if m.id == nil || m.oldValue == nil {
  17348. return v, errors.New("OldSourceID requires an ID field in the mutation")
  17349. }
  17350. oldValue, err := m.oldValue(ctx)
  17351. if err != nil {
  17352. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  17353. }
  17354. return oldValue.SourceID, nil
  17355. }
  17356. // ClearSourceID clears the value of the "source_id" field.
  17357. func (m *MessageRecordsMutation) ClearSourceID() {
  17358. m.sop_stage = nil
  17359. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17360. }
  17361. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  17362. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  17363. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  17364. return ok
  17365. }
  17366. // ResetSourceID resets all changes to the "source_id" field.
  17367. func (m *MessageRecordsMutation) ResetSourceID() {
  17368. m.sop_stage = nil
  17369. delete(m.clearedFields, messagerecords.FieldSourceID)
  17370. }
  17371. // SetSubSourceID sets the "sub_source_id" field.
  17372. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  17373. m.sop_node = &u
  17374. }
  17375. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  17376. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  17377. v := m.sop_node
  17378. if v == nil {
  17379. return
  17380. }
  17381. return *v, true
  17382. }
  17383. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  17384. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17386. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  17387. if !m.op.Is(OpUpdateOne) {
  17388. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  17389. }
  17390. if m.id == nil || m.oldValue == nil {
  17391. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  17392. }
  17393. oldValue, err := m.oldValue(ctx)
  17394. if err != nil {
  17395. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  17396. }
  17397. return oldValue.SubSourceID, nil
  17398. }
  17399. // ClearSubSourceID clears the value of the "sub_source_id" field.
  17400. func (m *MessageRecordsMutation) ClearSubSourceID() {
  17401. m.sop_node = nil
  17402. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17403. }
  17404. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  17405. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  17406. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  17407. return ok
  17408. }
  17409. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  17410. func (m *MessageRecordsMutation) ResetSubSourceID() {
  17411. m.sop_node = nil
  17412. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  17413. }
  17414. // SetOrganizationID sets the "organization_id" field.
  17415. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  17416. m.organization_id = &u
  17417. m.addorganization_id = nil
  17418. }
  17419. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17420. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  17421. v := m.organization_id
  17422. if v == nil {
  17423. return
  17424. }
  17425. return *v, true
  17426. }
  17427. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  17428. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17430. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17431. if !m.op.Is(OpUpdateOne) {
  17432. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17433. }
  17434. if m.id == nil || m.oldValue == nil {
  17435. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17436. }
  17437. oldValue, err := m.oldValue(ctx)
  17438. if err != nil {
  17439. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17440. }
  17441. return oldValue.OrganizationID, nil
  17442. }
  17443. // AddOrganizationID adds u to the "organization_id" field.
  17444. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  17445. if m.addorganization_id != nil {
  17446. *m.addorganization_id += u
  17447. } else {
  17448. m.addorganization_id = &u
  17449. }
  17450. }
  17451. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17452. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  17453. v := m.addorganization_id
  17454. if v == nil {
  17455. return
  17456. }
  17457. return *v, true
  17458. }
  17459. // ClearOrganizationID clears the value of the "organization_id" field.
  17460. func (m *MessageRecordsMutation) ClearOrganizationID() {
  17461. m.organization_id = nil
  17462. m.addorganization_id = nil
  17463. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  17464. }
  17465. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17466. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  17467. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  17468. return ok
  17469. }
  17470. // ResetOrganizationID resets all changes to the "organization_id" field.
  17471. func (m *MessageRecordsMutation) ResetOrganizationID() {
  17472. m.organization_id = nil
  17473. m.addorganization_id = nil
  17474. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  17475. }
  17476. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17477. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  17478. m.sop_stage = &id
  17479. }
  17480. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17481. func (m *MessageRecordsMutation) ClearSopStage() {
  17482. m.clearedsop_stage = true
  17483. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17484. }
  17485. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17486. func (m *MessageRecordsMutation) SopStageCleared() bool {
  17487. return m.SourceIDCleared() || m.clearedsop_stage
  17488. }
  17489. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17490. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  17491. if m.sop_stage != nil {
  17492. return *m.sop_stage, true
  17493. }
  17494. return
  17495. }
  17496. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17497. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17498. // SopStageID instead. It exists only for internal usage by the builders.
  17499. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  17500. if id := m.sop_stage; id != nil {
  17501. ids = append(ids, *id)
  17502. }
  17503. return
  17504. }
  17505. // ResetSopStage resets all changes to the "sop_stage" edge.
  17506. func (m *MessageRecordsMutation) ResetSopStage() {
  17507. m.sop_stage = nil
  17508. m.clearedsop_stage = false
  17509. }
  17510. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  17511. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  17512. m.sop_node = &id
  17513. }
  17514. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  17515. func (m *MessageRecordsMutation) ClearSopNode() {
  17516. m.clearedsop_node = true
  17517. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17518. }
  17519. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  17520. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  17521. return m.SubSourceIDCleared() || m.clearedsop_node
  17522. }
  17523. // SopNodeID returns the "sop_node" edge ID in the mutation.
  17524. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  17525. if m.sop_node != nil {
  17526. return *m.sop_node, true
  17527. }
  17528. return
  17529. }
  17530. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  17531. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17532. // SopNodeID instead. It exists only for internal usage by the builders.
  17533. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  17534. if id := m.sop_node; id != nil {
  17535. ids = append(ids, *id)
  17536. }
  17537. return
  17538. }
  17539. // ResetSopNode resets all changes to the "sop_node" edge.
  17540. func (m *MessageRecordsMutation) ResetSopNode() {
  17541. m.sop_node = nil
  17542. m.clearedsop_node = false
  17543. }
  17544. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  17545. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  17546. m.message_contact = &id
  17547. }
  17548. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  17549. func (m *MessageRecordsMutation) ClearMessageContact() {
  17550. m.clearedmessage_contact = true
  17551. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17552. }
  17553. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  17554. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  17555. return m.ContactIDCleared() || m.clearedmessage_contact
  17556. }
  17557. // MessageContactID returns the "message_contact" edge ID in the mutation.
  17558. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  17559. if m.message_contact != nil {
  17560. return *m.message_contact, true
  17561. }
  17562. return
  17563. }
  17564. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  17565. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17566. // MessageContactID instead. It exists only for internal usage by the builders.
  17567. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  17568. if id := m.message_contact; id != nil {
  17569. ids = append(ids, *id)
  17570. }
  17571. return
  17572. }
  17573. // ResetMessageContact resets all changes to the "message_contact" edge.
  17574. func (m *MessageRecordsMutation) ResetMessageContact() {
  17575. m.message_contact = nil
  17576. m.clearedmessage_contact = false
  17577. }
  17578. // Where appends a list predicates to the MessageRecordsMutation builder.
  17579. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  17580. m.predicates = append(m.predicates, ps...)
  17581. }
  17582. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  17583. // users can use type-assertion to append predicates that do not depend on any generated package.
  17584. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  17585. p := make([]predicate.MessageRecords, len(ps))
  17586. for i := range ps {
  17587. p[i] = ps[i]
  17588. }
  17589. m.Where(p...)
  17590. }
  17591. // Op returns the operation name.
  17592. func (m *MessageRecordsMutation) Op() Op {
  17593. return m.op
  17594. }
  17595. // SetOp allows setting the mutation operation.
  17596. func (m *MessageRecordsMutation) SetOp(op Op) {
  17597. m.op = op
  17598. }
  17599. // Type returns the node type of this mutation (MessageRecords).
  17600. func (m *MessageRecordsMutation) Type() string {
  17601. return m.typ
  17602. }
  17603. // Fields returns all fields that were changed during this mutation. Note that in
  17604. // order to get all numeric fields that were incremented/decremented, call
  17605. // AddedFields().
  17606. func (m *MessageRecordsMutation) Fields() []string {
  17607. fields := make([]string, 0, 16)
  17608. if m.created_at != nil {
  17609. fields = append(fields, messagerecords.FieldCreatedAt)
  17610. }
  17611. if m.updated_at != nil {
  17612. fields = append(fields, messagerecords.FieldUpdatedAt)
  17613. }
  17614. if m.status != nil {
  17615. fields = append(fields, messagerecords.FieldStatus)
  17616. }
  17617. if m.bot_wxid != nil {
  17618. fields = append(fields, messagerecords.FieldBotWxid)
  17619. }
  17620. if m.message_contact != nil {
  17621. fields = append(fields, messagerecords.FieldContactID)
  17622. }
  17623. if m.contact_type != nil {
  17624. fields = append(fields, messagerecords.FieldContactType)
  17625. }
  17626. if m.contact_wxid != nil {
  17627. fields = append(fields, messagerecords.FieldContactWxid)
  17628. }
  17629. if m.content_type != nil {
  17630. fields = append(fields, messagerecords.FieldContentType)
  17631. }
  17632. if m.content != nil {
  17633. fields = append(fields, messagerecords.FieldContent)
  17634. }
  17635. if m.meta != nil {
  17636. fields = append(fields, messagerecords.FieldMeta)
  17637. }
  17638. if m.error_detail != nil {
  17639. fields = append(fields, messagerecords.FieldErrorDetail)
  17640. }
  17641. if m.send_time != nil {
  17642. fields = append(fields, messagerecords.FieldSendTime)
  17643. }
  17644. if m.source_type != nil {
  17645. fields = append(fields, messagerecords.FieldSourceType)
  17646. }
  17647. if m.sop_stage != nil {
  17648. fields = append(fields, messagerecords.FieldSourceID)
  17649. }
  17650. if m.sop_node != nil {
  17651. fields = append(fields, messagerecords.FieldSubSourceID)
  17652. }
  17653. if m.organization_id != nil {
  17654. fields = append(fields, messagerecords.FieldOrganizationID)
  17655. }
  17656. return fields
  17657. }
  17658. // Field returns the value of a field with the given name. The second boolean
  17659. // return value indicates that this field was not set, or was not defined in the
  17660. // schema.
  17661. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  17662. switch name {
  17663. case messagerecords.FieldCreatedAt:
  17664. return m.CreatedAt()
  17665. case messagerecords.FieldUpdatedAt:
  17666. return m.UpdatedAt()
  17667. case messagerecords.FieldStatus:
  17668. return m.Status()
  17669. case messagerecords.FieldBotWxid:
  17670. return m.BotWxid()
  17671. case messagerecords.FieldContactID:
  17672. return m.ContactID()
  17673. case messagerecords.FieldContactType:
  17674. return m.ContactType()
  17675. case messagerecords.FieldContactWxid:
  17676. return m.ContactWxid()
  17677. case messagerecords.FieldContentType:
  17678. return m.ContentType()
  17679. case messagerecords.FieldContent:
  17680. return m.Content()
  17681. case messagerecords.FieldMeta:
  17682. return m.Meta()
  17683. case messagerecords.FieldErrorDetail:
  17684. return m.ErrorDetail()
  17685. case messagerecords.FieldSendTime:
  17686. return m.SendTime()
  17687. case messagerecords.FieldSourceType:
  17688. return m.SourceType()
  17689. case messagerecords.FieldSourceID:
  17690. return m.SourceID()
  17691. case messagerecords.FieldSubSourceID:
  17692. return m.SubSourceID()
  17693. case messagerecords.FieldOrganizationID:
  17694. return m.OrganizationID()
  17695. }
  17696. return nil, false
  17697. }
  17698. // OldField returns the old value of the field from the database. An error is
  17699. // returned if the mutation operation is not UpdateOne, or the query to the
  17700. // database failed.
  17701. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17702. switch name {
  17703. case messagerecords.FieldCreatedAt:
  17704. return m.OldCreatedAt(ctx)
  17705. case messagerecords.FieldUpdatedAt:
  17706. return m.OldUpdatedAt(ctx)
  17707. case messagerecords.FieldStatus:
  17708. return m.OldStatus(ctx)
  17709. case messagerecords.FieldBotWxid:
  17710. return m.OldBotWxid(ctx)
  17711. case messagerecords.FieldContactID:
  17712. return m.OldContactID(ctx)
  17713. case messagerecords.FieldContactType:
  17714. return m.OldContactType(ctx)
  17715. case messagerecords.FieldContactWxid:
  17716. return m.OldContactWxid(ctx)
  17717. case messagerecords.FieldContentType:
  17718. return m.OldContentType(ctx)
  17719. case messagerecords.FieldContent:
  17720. return m.OldContent(ctx)
  17721. case messagerecords.FieldMeta:
  17722. return m.OldMeta(ctx)
  17723. case messagerecords.FieldErrorDetail:
  17724. return m.OldErrorDetail(ctx)
  17725. case messagerecords.FieldSendTime:
  17726. return m.OldSendTime(ctx)
  17727. case messagerecords.FieldSourceType:
  17728. return m.OldSourceType(ctx)
  17729. case messagerecords.FieldSourceID:
  17730. return m.OldSourceID(ctx)
  17731. case messagerecords.FieldSubSourceID:
  17732. return m.OldSubSourceID(ctx)
  17733. case messagerecords.FieldOrganizationID:
  17734. return m.OldOrganizationID(ctx)
  17735. }
  17736. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  17737. }
  17738. // SetField sets the value of a field with the given name. It returns an error if
  17739. // the field is not defined in the schema, or if the type mismatched the field
  17740. // type.
  17741. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  17742. switch name {
  17743. case messagerecords.FieldCreatedAt:
  17744. v, ok := value.(time.Time)
  17745. if !ok {
  17746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17747. }
  17748. m.SetCreatedAt(v)
  17749. return nil
  17750. case messagerecords.FieldUpdatedAt:
  17751. v, ok := value.(time.Time)
  17752. if !ok {
  17753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17754. }
  17755. m.SetUpdatedAt(v)
  17756. return nil
  17757. case messagerecords.FieldStatus:
  17758. v, ok := value.(uint8)
  17759. if !ok {
  17760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17761. }
  17762. m.SetStatus(v)
  17763. return nil
  17764. case messagerecords.FieldBotWxid:
  17765. v, ok := value.(string)
  17766. if !ok {
  17767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17768. }
  17769. m.SetBotWxid(v)
  17770. return nil
  17771. case messagerecords.FieldContactID:
  17772. v, ok := value.(uint64)
  17773. if !ok {
  17774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17775. }
  17776. m.SetContactID(v)
  17777. return nil
  17778. case messagerecords.FieldContactType:
  17779. v, ok := value.(int)
  17780. if !ok {
  17781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17782. }
  17783. m.SetContactType(v)
  17784. return nil
  17785. case messagerecords.FieldContactWxid:
  17786. v, ok := value.(string)
  17787. if !ok {
  17788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17789. }
  17790. m.SetContactWxid(v)
  17791. return nil
  17792. case messagerecords.FieldContentType:
  17793. v, ok := value.(int)
  17794. if !ok {
  17795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17796. }
  17797. m.SetContentType(v)
  17798. return nil
  17799. case messagerecords.FieldContent:
  17800. v, ok := value.(string)
  17801. if !ok {
  17802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17803. }
  17804. m.SetContent(v)
  17805. return nil
  17806. case messagerecords.FieldMeta:
  17807. v, ok := value.(custom_types.Meta)
  17808. if !ok {
  17809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17810. }
  17811. m.SetMeta(v)
  17812. return nil
  17813. case messagerecords.FieldErrorDetail:
  17814. v, ok := value.(string)
  17815. if !ok {
  17816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17817. }
  17818. m.SetErrorDetail(v)
  17819. return nil
  17820. case messagerecords.FieldSendTime:
  17821. v, ok := value.(time.Time)
  17822. if !ok {
  17823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17824. }
  17825. m.SetSendTime(v)
  17826. return nil
  17827. case messagerecords.FieldSourceType:
  17828. v, ok := value.(int)
  17829. if !ok {
  17830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17831. }
  17832. m.SetSourceType(v)
  17833. return nil
  17834. case messagerecords.FieldSourceID:
  17835. v, ok := value.(uint64)
  17836. if !ok {
  17837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17838. }
  17839. m.SetSourceID(v)
  17840. return nil
  17841. case messagerecords.FieldSubSourceID:
  17842. v, ok := value.(uint64)
  17843. if !ok {
  17844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17845. }
  17846. m.SetSubSourceID(v)
  17847. return nil
  17848. case messagerecords.FieldOrganizationID:
  17849. v, ok := value.(uint64)
  17850. if !ok {
  17851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17852. }
  17853. m.SetOrganizationID(v)
  17854. return nil
  17855. }
  17856. return fmt.Errorf("unknown MessageRecords field %s", name)
  17857. }
  17858. // AddedFields returns all numeric fields that were incremented/decremented during
  17859. // this mutation.
  17860. func (m *MessageRecordsMutation) AddedFields() []string {
  17861. var fields []string
  17862. if m.addstatus != nil {
  17863. fields = append(fields, messagerecords.FieldStatus)
  17864. }
  17865. if m.addcontact_type != nil {
  17866. fields = append(fields, messagerecords.FieldContactType)
  17867. }
  17868. if m.addcontent_type != nil {
  17869. fields = append(fields, messagerecords.FieldContentType)
  17870. }
  17871. if m.addsource_type != nil {
  17872. fields = append(fields, messagerecords.FieldSourceType)
  17873. }
  17874. if m.addorganization_id != nil {
  17875. fields = append(fields, messagerecords.FieldOrganizationID)
  17876. }
  17877. return fields
  17878. }
  17879. // AddedField returns the numeric value that was incremented/decremented on a field
  17880. // with the given name. The second boolean return value indicates that this field
  17881. // was not set, or was not defined in the schema.
  17882. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  17883. switch name {
  17884. case messagerecords.FieldStatus:
  17885. return m.AddedStatus()
  17886. case messagerecords.FieldContactType:
  17887. return m.AddedContactType()
  17888. case messagerecords.FieldContentType:
  17889. return m.AddedContentType()
  17890. case messagerecords.FieldSourceType:
  17891. return m.AddedSourceType()
  17892. case messagerecords.FieldOrganizationID:
  17893. return m.AddedOrganizationID()
  17894. }
  17895. return nil, false
  17896. }
  17897. // AddField adds the value to the field with the given name. It returns an error if
  17898. // the field is not defined in the schema, or if the type mismatched the field
  17899. // type.
  17900. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  17901. switch name {
  17902. case messagerecords.FieldStatus:
  17903. v, ok := value.(int8)
  17904. if !ok {
  17905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17906. }
  17907. m.AddStatus(v)
  17908. return nil
  17909. case messagerecords.FieldContactType:
  17910. v, ok := value.(int)
  17911. if !ok {
  17912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17913. }
  17914. m.AddContactType(v)
  17915. return nil
  17916. case messagerecords.FieldContentType:
  17917. v, ok := value.(int)
  17918. if !ok {
  17919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17920. }
  17921. m.AddContentType(v)
  17922. return nil
  17923. case messagerecords.FieldSourceType:
  17924. v, ok := value.(int)
  17925. if !ok {
  17926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17927. }
  17928. m.AddSourceType(v)
  17929. return nil
  17930. case messagerecords.FieldOrganizationID:
  17931. v, ok := value.(int64)
  17932. if !ok {
  17933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17934. }
  17935. m.AddOrganizationID(v)
  17936. return nil
  17937. }
  17938. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  17939. }
  17940. // ClearedFields returns all nullable fields that were cleared during this
  17941. // mutation.
  17942. func (m *MessageRecordsMutation) ClearedFields() []string {
  17943. var fields []string
  17944. if m.FieldCleared(messagerecords.FieldStatus) {
  17945. fields = append(fields, messagerecords.FieldStatus)
  17946. }
  17947. if m.FieldCleared(messagerecords.FieldContactID) {
  17948. fields = append(fields, messagerecords.FieldContactID)
  17949. }
  17950. if m.FieldCleared(messagerecords.FieldMeta) {
  17951. fields = append(fields, messagerecords.FieldMeta)
  17952. }
  17953. if m.FieldCleared(messagerecords.FieldSendTime) {
  17954. fields = append(fields, messagerecords.FieldSendTime)
  17955. }
  17956. if m.FieldCleared(messagerecords.FieldSourceID) {
  17957. fields = append(fields, messagerecords.FieldSourceID)
  17958. }
  17959. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  17960. fields = append(fields, messagerecords.FieldSubSourceID)
  17961. }
  17962. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  17963. fields = append(fields, messagerecords.FieldOrganizationID)
  17964. }
  17965. return fields
  17966. }
  17967. // FieldCleared returns a boolean indicating if a field with the given name was
  17968. // cleared in this mutation.
  17969. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  17970. _, ok := m.clearedFields[name]
  17971. return ok
  17972. }
  17973. // ClearField clears the value of the field with the given name. It returns an
  17974. // error if the field is not defined in the schema.
  17975. func (m *MessageRecordsMutation) ClearField(name string) error {
  17976. switch name {
  17977. case messagerecords.FieldStatus:
  17978. m.ClearStatus()
  17979. return nil
  17980. case messagerecords.FieldContactID:
  17981. m.ClearContactID()
  17982. return nil
  17983. case messagerecords.FieldMeta:
  17984. m.ClearMeta()
  17985. return nil
  17986. case messagerecords.FieldSendTime:
  17987. m.ClearSendTime()
  17988. return nil
  17989. case messagerecords.FieldSourceID:
  17990. m.ClearSourceID()
  17991. return nil
  17992. case messagerecords.FieldSubSourceID:
  17993. m.ClearSubSourceID()
  17994. return nil
  17995. case messagerecords.FieldOrganizationID:
  17996. m.ClearOrganizationID()
  17997. return nil
  17998. }
  17999. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  18000. }
  18001. // ResetField resets all changes in the mutation for the field with the given name.
  18002. // It returns an error if the field is not defined in the schema.
  18003. func (m *MessageRecordsMutation) ResetField(name string) error {
  18004. switch name {
  18005. case messagerecords.FieldCreatedAt:
  18006. m.ResetCreatedAt()
  18007. return nil
  18008. case messagerecords.FieldUpdatedAt:
  18009. m.ResetUpdatedAt()
  18010. return nil
  18011. case messagerecords.FieldStatus:
  18012. m.ResetStatus()
  18013. return nil
  18014. case messagerecords.FieldBotWxid:
  18015. m.ResetBotWxid()
  18016. return nil
  18017. case messagerecords.FieldContactID:
  18018. m.ResetContactID()
  18019. return nil
  18020. case messagerecords.FieldContactType:
  18021. m.ResetContactType()
  18022. return nil
  18023. case messagerecords.FieldContactWxid:
  18024. m.ResetContactWxid()
  18025. return nil
  18026. case messagerecords.FieldContentType:
  18027. m.ResetContentType()
  18028. return nil
  18029. case messagerecords.FieldContent:
  18030. m.ResetContent()
  18031. return nil
  18032. case messagerecords.FieldMeta:
  18033. m.ResetMeta()
  18034. return nil
  18035. case messagerecords.FieldErrorDetail:
  18036. m.ResetErrorDetail()
  18037. return nil
  18038. case messagerecords.FieldSendTime:
  18039. m.ResetSendTime()
  18040. return nil
  18041. case messagerecords.FieldSourceType:
  18042. m.ResetSourceType()
  18043. return nil
  18044. case messagerecords.FieldSourceID:
  18045. m.ResetSourceID()
  18046. return nil
  18047. case messagerecords.FieldSubSourceID:
  18048. m.ResetSubSourceID()
  18049. return nil
  18050. case messagerecords.FieldOrganizationID:
  18051. m.ResetOrganizationID()
  18052. return nil
  18053. }
  18054. return fmt.Errorf("unknown MessageRecords field %s", name)
  18055. }
  18056. // AddedEdges returns all edge names that were set/added in this mutation.
  18057. func (m *MessageRecordsMutation) AddedEdges() []string {
  18058. edges := make([]string, 0, 3)
  18059. if m.sop_stage != nil {
  18060. edges = append(edges, messagerecords.EdgeSopStage)
  18061. }
  18062. if m.sop_node != nil {
  18063. edges = append(edges, messagerecords.EdgeSopNode)
  18064. }
  18065. if m.message_contact != nil {
  18066. edges = append(edges, messagerecords.EdgeMessageContact)
  18067. }
  18068. return edges
  18069. }
  18070. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18071. // name in this mutation.
  18072. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  18073. switch name {
  18074. case messagerecords.EdgeSopStage:
  18075. if id := m.sop_stage; id != nil {
  18076. return []ent.Value{*id}
  18077. }
  18078. case messagerecords.EdgeSopNode:
  18079. if id := m.sop_node; id != nil {
  18080. return []ent.Value{*id}
  18081. }
  18082. case messagerecords.EdgeMessageContact:
  18083. if id := m.message_contact; id != nil {
  18084. return []ent.Value{*id}
  18085. }
  18086. }
  18087. return nil
  18088. }
  18089. // RemovedEdges returns all edge names that were removed in this mutation.
  18090. func (m *MessageRecordsMutation) RemovedEdges() []string {
  18091. edges := make([]string, 0, 3)
  18092. return edges
  18093. }
  18094. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18095. // the given name in this mutation.
  18096. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  18097. return nil
  18098. }
  18099. // ClearedEdges returns all edge names that were cleared in this mutation.
  18100. func (m *MessageRecordsMutation) ClearedEdges() []string {
  18101. edges := make([]string, 0, 3)
  18102. if m.clearedsop_stage {
  18103. edges = append(edges, messagerecords.EdgeSopStage)
  18104. }
  18105. if m.clearedsop_node {
  18106. edges = append(edges, messagerecords.EdgeSopNode)
  18107. }
  18108. if m.clearedmessage_contact {
  18109. edges = append(edges, messagerecords.EdgeMessageContact)
  18110. }
  18111. return edges
  18112. }
  18113. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18114. // was cleared in this mutation.
  18115. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  18116. switch name {
  18117. case messagerecords.EdgeSopStage:
  18118. return m.clearedsop_stage
  18119. case messagerecords.EdgeSopNode:
  18120. return m.clearedsop_node
  18121. case messagerecords.EdgeMessageContact:
  18122. return m.clearedmessage_contact
  18123. }
  18124. return false
  18125. }
  18126. // ClearEdge clears the value of the edge with the given name. It returns an error
  18127. // if that edge is not defined in the schema.
  18128. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  18129. switch name {
  18130. case messagerecords.EdgeSopStage:
  18131. m.ClearSopStage()
  18132. return nil
  18133. case messagerecords.EdgeSopNode:
  18134. m.ClearSopNode()
  18135. return nil
  18136. case messagerecords.EdgeMessageContact:
  18137. m.ClearMessageContact()
  18138. return nil
  18139. }
  18140. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  18141. }
  18142. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18143. // It returns an error if the edge is not defined in the schema.
  18144. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  18145. switch name {
  18146. case messagerecords.EdgeSopStage:
  18147. m.ResetSopStage()
  18148. return nil
  18149. case messagerecords.EdgeSopNode:
  18150. m.ResetSopNode()
  18151. return nil
  18152. case messagerecords.EdgeMessageContact:
  18153. m.ResetMessageContact()
  18154. return nil
  18155. }
  18156. return fmt.Errorf("unknown MessageRecords edge %s", name)
  18157. }
  18158. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  18159. type MsgMutation struct {
  18160. config
  18161. op Op
  18162. typ string
  18163. id *uint64
  18164. created_at *time.Time
  18165. updated_at *time.Time
  18166. deleted_at *time.Time
  18167. status *uint8
  18168. addstatus *int8
  18169. fromwxid *string
  18170. toid *string
  18171. msgtype *int32
  18172. addmsgtype *int32
  18173. msg *string
  18174. batch_no *string
  18175. clearedFields map[string]struct{}
  18176. done bool
  18177. oldValue func(context.Context) (*Msg, error)
  18178. predicates []predicate.Msg
  18179. }
  18180. var _ ent.Mutation = (*MsgMutation)(nil)
  18181. // msgOption allows management of the mutation configuration using functional options.
  18182. type msgOption func(*MsgMutation)
  18183. // newMsgMutation creates new mutation for the Msg entity.
  18184. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  18185. m := &MsgMutation{
  18186. config: c,
  18187. op: op,
  18188. typ: TypeMsg,
  18189. clearedFields: make(map[string]struct{}),
  18190. }
  18191. for _, opt := range opts {
  18192. opt(m)
  18193. }
  18194. return m
  18195. }
  18196. // withMsgID sets the ID field of the mutation.
  18197. func withMsgID(id uint64) msgOption {
  18198. return func(m *MsgMutation) {
  18199. var (
  18200. err error
  18201. once sync.Once
  18202. value *Msg
  18203. )
  18204. m.oldValue = func(ctx context.Context) (*Msg, error) {
  18205. once.Do(func() {
  18206. if m.done {
  18207. err = errors.New("querying old values post mutation is not allowed")
  18208. } else {
  18209. value, err = m.Client().Msg.Get(ctx, id)
  18210. }
  18211. })
  18212. return value, err
  18213. }
  18214. m.id = &id
  18215. }
  18216. }
  18217. // withMsg sets the old Msg of the mutation.
  18218. func withMsg(node *Msg) msgOption {
  18219. return func(m *MsgMutation) {
  18220. m.oldValue = func(context.Context) (*Msg, error) {
  18221. return node, nil
  18222. }
  18223. m.id = &node.ID
  18224. }
  18225. }
  18226. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18227. // executed in a transaction (ent.Tx), a transactional client is returned.
  18228. func (m MsgMutation) Client() *Client {
  18229. client := &Client{config: m.config}
  18230. client.init()
  18231. return client
  18232. }
  18233. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18234. // it returns an error otherwise.
  18235. func (m MsgMutation) Tx() (*Tx, error) {
  18236. if _, ok := m.driver.(*txDriver); !ok {
  18237. return nil, errors.New("ent: mutation is not running in a transaction")
  18238. }
  18239. tx := &Tx{config: m.config}
  18240. tx.init()
  18241. return tx, nil
  18242. }
  18243. // SetID sets the value of the id field. Note that this
  18244. // operation is only accepted on creation of Msg entities.
  18245. func (m *MsgMutation) SetID(id uint64) {
  18246. m.id = &id
  18247. }
  18248. // ID returns the ID value in the mutation. Note that the ID is only available
  18249. // if it was provided to the builder or after it was returned from the database.
  18250. func (m *MsgMutation) ID() (id uint64, exists bool) {
  18251. if m.id == nil {
  18252. return
  18253. }
  18254. return *m.id, true
  18255. }
  18256. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18257. // That means, if the mutation is applied within a transaction with an isolation level such
  18258. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18259. // or updated by the mutation.
  18260. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  18261. switch {
  18262. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18263. id, exists := m.ID()
  18264. if exists {
  18265. return []uint64{id}, nil
  18266. }
  18267. fallthrough
  18268. case m.op.Is(OpUpdate | OpDelete):
  18269. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  18270. default:
  18271. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18272. }
  18273. }
  18274. // SetCreatedAt sets the "created_at" field.
  18275. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  18276. m.created_at = &t
  18277. }
  18278. // CreatedAt returns the value of the "created_at" field in the mutation.
  18279. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  18280. v := m.created_at
  18281. if v == nil {
  18282. return
  18283. }
  18284. return *v, true
  18285. }
  18286. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  18287. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18289. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18290. if !m.op.Is(OpUpdateOne) {
  18291. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18292. }
  18293. if m.id == nil || m.oldValue == nil {
  18294. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18295. }
  18296. oldValue, err := m.oldValue(ctx)
  18297. if err != nil {
  18298. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18299. }
  18300. return oldValue.CreatedAt, nil
  18301. }
  18302. // ResetCreatedAt resets all changes to the "created_at" field.
  18303. func (m *MsgMutation) ResetCreatedAt() {
  18304. m.created_at = nil
  18305. }
  18306. // SetUpdatedAt sets the "updated_at" field.
  18307. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  18308. m.updated_at = &t
  18309. }
  18310. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18311. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  18312. v := m.updated_at
  18313. if v == nil {
  18314. return
  18315. }
  18316. return *v, true
  18317. }
  18318. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  18319. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18321. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18322. if !m.op.Is(OpUpdateOne) {
  18323. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18324. }
  18325. if m.id == nil || m.oldValue == nil {
  18326. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18327. }
  18328. oldValue, err := m.oldValue(ctx)
  18329. if err != nil {
  18330. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18331. }
  18332. return oldValue.UpdatedAt, nil
  18333. }
  18334. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18335. func (m *MsgMutation) ResetUpdatedAt() {
  18336. m.updated_at = nil
  18337. }
  18338. // SetDeletedAt sets the "deleted_at" field.
  18339. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  18340. m.deleted_at = &t
  18341. }
  18342. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18343. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  18344. v := m.deleted_at
  18345. if v == nil {
  18346. return
  18347. }
  18348. return *v, true
  18349. }
  18350. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  18351. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18353. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18354. if !m.op.Is(OpUpdateOne) {
  18355. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18356. }
  18357. if m.id == nil || m.oldValue == nil {
  18358. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18359. }
  18360. oldValue, err := m.oldValue(ctx)
  18361. if err != nil {
  18362. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18363. }
  18364. return oldValue.DeletedAt, nil
  18365. }
  18366. // ClearDeletedAt clears the value of the "deleted_at" field.
  18367. func (m *MsgMutation) ClearDeletedAt() {
  18368. m.deleted_at = nil
  18369. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  18370. }
  18371. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18372. func (m *MsgMutation) DeletedAtCleared() bool {
  18373. _, ok := m.clearedFields[msg.FieldDeletedAt]
  18374. return ok
  18375. }
  18376. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18377. func (m *MsgMutation) ResetDeletedAt() {
  18378. m.deleted_at = nil
  18379. delete(m.clearedFields, msg.FieldDeletedAt)
  18380. }
  18381. // SetStatus sets the "status" field.
  18382. func (m *MsgMutation) SetStatus(u uint8) {
  18383. m.status = &u
  18384. m.addstatus = nil
  18385. }
  18386. // Status returns the value of the "status" field in the mutation.
  18387. func (m *MsgMutation) Status() (r uint8, exists bool) {
  18388. v := m.status
  18389. if v == nil {
  18390. return
  18391. }
  18392. return *v, true
  18393. }
  18394. // OldStatus returns the old "status" field's value of the Msg entity.
  18395. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18397. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18398. if !m.op.Is(OpUpdateOne) {
  18399. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18400. }
  18401. if m.id == nil || m.oldValue == nil {
  18402. return v, errors.New("OldStatus requires an ID field in the mutation")
  18403. }
  18404. oldValue, err := m.oldValue(ctx)
  18405. if err != nil {
  18406. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18407. }
  18408. return oldValue.Status, nil
  18409. }
  18410. // AddStatus adds u to the "status" field.
  18411. func (m *MsgMutation) AddStatus(u int8) {
  18412. if m.addstatus != nil {
  18413. *m.addstatus += u
  18414. } else {
  18415. m.addstatus = &u
  18416. }
  18417. }
  18418. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18419. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  18420. v := m.addstatus
  18421. if v == nil {
  18422. return
  18423. }
  18424. return *v, true
  18425. }
  18426. // ClearStatus clears the value of the "status" field.
  18427. func (m *MsgMutation) ClearStatus() {
  18428. m.status = nil
  18429. m.addstatus = nil
  18430. m.clearedFields[msg.FieldStatus] = struct{}{}
  18431. }
  18432. // StatusCleared returns if the "status" field was cleared in this mutation.
  18433. func (m *MsgMutation) StatusCleared() bool {
  18434. _, ok := m.clearedFields[msg.FieldStatus]
  18435. return ok
  18436. }
  18437. // ResetStatus resets all changes to the "status" field.
  18438. func (m *MsgMutation) ResetStatus() {
  18439. m.status = nil
  18440. m.addstatus = nil
  18441. delete(m.clearedFields, msg.FieldStatus)
  18442. }
  18443. // SetFromwxid sets the "fromwxid" field.
  18444. func (m *MsgMutation) SetFromwxid(s string) {
  18445. m.fromwxid = &s
  18446. }
  18447. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  18448. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  18449. v := m.fromwxid
  18450. if v == nil {
  18451. return
  18452. }
  18453. return *v, true
  18454. }
  18455. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  18456. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18458. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  18459. if !m.op.Is(OpUpdateOne) {
  18460. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  18461. }
  18462. if m.id == nil || m.oldValue == nil {
  18463. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  18464. }
  18465. oldValue, err := m.oldValue(ctx)
  18466. if err != nil {
  18467. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  18468. }
  18469. return oldValue.Fromwxid, nil
  18470. }
  18471. // ClearFromwxid clears the value of the "fromwxid" field.
  18472. func (m *MsgMutation) ClearFromwxid() {
  18473. m.fromwxid = nil
  18474. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  18475. }
  18476. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  18477. func (m *MsgMutation) FromwxidCleared() bool {
  18478. _, ok := m.clearedFields[msg.FieldFromwxid]
  18479. return ok
  18480. }
  18481. // ResetFromwxid resets all changes to the "fromwxid" field.
  18482. func (m *MsgMutation) ResetFromwxid() {
  18483. m.fromwxid = nil
  18484. delete(m.clearedFields, msg.FieldFromwxid)
  18485. }
  18486. // SetToid sets the "toid" field.
  18487. func (m *MsgMutation) SetToid(s string) {
  18488. m.toid = &s
  18489. }
  18490. // Toid returns the value of the "toid" field in the mutation.
  18491. func (m *MsgMutation) Toid() (r string, exists bool) {
  18492. v := m.toid
  18493. if v == nil {
  18494. return
  18495. }
  18496. return *v, true
  18497. }
  18498. // OldToid returns the old "toid" field's value of the Msg entity.
  18499. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18501. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  18502. if !m.op.Is(OpUpdateOne) {
  18503. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  18504. }
  18505. if m.id == nil || m.oldValue == nil {
  18506. return v, errors.New("OldToid requires an ID field in the mutation")
  18507. }
  18508. oldValue, err := m.oldValue(ctx)
  18509. if err != nil {
  18510. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  18511. }
  18512. return oldValue.Toid, nil
  18513. }
  18514. // ClearToid clears the value of the "toid" field.
  18515. func (m *MsgMutation) ClearToid() {
  18516. m.toid = nil
  18517. m.clearedFields[msg.FieldToid] = struct{}{}
  18518. }
  18519. // ToidCleared returns if the "toid" field was cleared in this mutation.
  18520. func (m *MsgMutation) ToidCleared() bool {
  18521. _, ok := m.clearedFields[msg.FieldToid]
  18522. return ok
  18523. }
  18524. // ResetToid resets all changes to the "toid" field.
  18525. func (m *MsgMutation) ResetToid() {
  18526. m.toid = nil
  18527. delete(m.clearedFields, msg.FieldToid)
  18528. }
  18529. // SetMsgtype sets the "msgtype" field.
  18530. func (m *MsgMutation) SetMsgtype(i int32) {
  18531. m.msgtype = &i
  18532. m.addmsgtype = nil
  18533. }
  18534. // Msgtype returns the value of the "msgtype" field in the mutation.
  18535. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  18536. v := m.msgtype
  18537. if v == nil {
  18538. return
  18539. }
  18540. return *v, true
  18541. }
  18542. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  18543. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18545. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  18546. if !m.op.Is(OpUpdateOne) {
  18547. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  18548. }
  18549. if m.id == nil || m.oldValue == nil {
  18550. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  18551. }
  18552. oldValue, err := m.oldValue(ctx)
  18553. if err != nil {
  18554. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  18555. }
  18556. return oldValue.Msgtype, nil
  18557. }
  18558. // AddMsgtype adds i to the "msgtype" field.
  18559. func (m *MsgMutation) AddMsgtype(i int32) {
  18560. if m.addmsgtype != nil {
  18561. *m.addmsgtype += i
  18562. } else {
  18563. m.addmsgtype = &i
  18564. }
  18565. }
  18566. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  18567. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  18568. v := m.addmsgtype
  18569. if v == nil {
  18570. return
  18571. }
  18572. return *v, true
  18573. }
  18574. // ClearMsgtype clears the value of the "msgtype" field.
  18575. func (m *MsgMutation) ClearMsgtype() {
  18576. m.msgtype = nil
  18577. m.addmsgtype = nil
  18578. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  18579. }
  18580. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  18581. func (m *MsgMutation) MsgtypeCleared() bool {
  18582. _, ok := m.clearedFields[msg.FieldMsgtype]
  18583. return ok
  18584. }
  18585. // ResetMsgtype resets all changes to the "msgtype" field.
  18586. func (m *MsgMutation) ResetMsgtype() {
  18587. m.msgtype = nil
  18588. m.addmsgtype = nil
  18589. delete(m.clearedFields, msg.FieldMsgtype)
  18590. }
  18591. // SetMsg sets the "msg" field.
  18592. func (m *MsgMutation) SetMsg(s string) {
  18593. m.msg = &s
  18594. }
  18595. // Msg returns the value of the "msg" field in the mutation.
  18596. func (m *MsgMutation) Msg() (r string, exists bool) {
  18597. v := m.msg
  18598. if v == nil {
  18599. return
  18600. }
  18601. return *v, true
  18602. }
  18603. // OldMsg returns the old "msg" field's value of the Msg entity.
  18604. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18606. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  18607. if !m.op.Is(OpUpdateOne) {
  18608. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  18609. }
  18610. if m.id == nil || m.oldValue == nil {
  18611. return v, errors.New("OldMsg requires an ID field in the mutation")
  18612. }
  18613. oldValue, err := m.oldValue(ctx)
  18614. if err != nil {
  18615. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  18616. }
  18617. return oldValue.Msg, nil
  18618. }
  18619. // ClearMsg clears the value of the "msg" field.
  18620. func (m *MsgMutation) ClearMsg() {
  18621. m.msg = nil
  18622. m.clearedFields[msg.FieldMsg] = struct{}{}
  18623. }
  18624. // MsgCleared returns if the "msg" field was cleared in this mutation.
  18625. func (m *MsgMutation) MsgCleared() bool {
  18626. _, ok := m.clearedFields[msg.FieldMsg]
  18627. return ok
  18628. }
  18629. // ResetMsg resets all changes to the "msg" field.
  18630. func (m *MsgMutation) ResetMsg() {
  18631. m.msg = nil
  18632. delete(m.clearedFields, msg.FieldMsg)
  18633. }
  18634. // SetBatchNo sets the "batch_no" field.
  18635. func (m *MsgMutation) SetBatchNo(s string) {
  18636. m.batch_no = &s
  18637. }
  18638. // BatchNo returns the value of the "batch_no" field in the mutation.
  18639. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  18640. v := m.batch_no
  18641. if v == nil {
  18642. return
  18643. }
  18644. return *v, true
  18645. }
  18646. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  18647. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18649. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  18650. if !m.op.Is(OpUpdateOne) {
  18651. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  18652. }
  18653. if m.id == nil || m.oldValue == nil {
  18654. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  18655. }
  18656. oldValue, err := m.oldValue(ctx)
  18657. if err != nil {
  18658. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  18659. }
  18660. return oldValue.BatchNo, nil
  18661. }
  18662. // ClearBatchNo clears the value of the "batch_no" field.
  18663. func (m *MsgMutation) ClearBatchNo() {
  18664. m.batch_no = nil
  18665. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  18666. }
  18667. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  18668. func (m *MsgMutation) BatchNoCleared() bool {
  18669. _, ok := m.clearedFields[msg.FieldBatchNo]
  18670. return ok
  18671. }
  18672. // ResetBatchNo resets all changes to the "batch_no" field.
  18673. func (m *MsgMutation) ResetBatchNo() {
  18674. m.batch_no = nil
  18675. delete(m.clearedFields, msg.FieldBatchNo)
  18676. }
  18677. // Where appends a list predicates to the MsgMutation builder.
  18678. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  18679. m.predicates = append(m.predicates, ps...)
  18680. }
  18681. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  18682. // users can use type-assertion to append predicates that do not depend on any generated package.
  18683. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  18684. p := make([]predicate.Msg, len(ps))
  18685. for i := range ps {
  18686. p[i] = ps[i]
  18687. }
  18688. m.Where(p...)
  18689. }
  18690. // Op returns the operation name.
  18691. func (m *MsgMutation) Op() Op {
  18692. return m.op
  18693. }
  18694. // SetOp allows setting the mutation operation.
  18695. func (m *MsgMutation) SetOp(op Op) {
  18696. m.op = op
  18697. }
  18698. // Type returns the node type of this mutation (Msg).
  18699. func (m *MsgMutation) Type() string {
  18700. return m.typ
  18701. }
  18702. // Fields returns all fields that were changed during this mutation. Note that in
  18703. // order to get all numeric fields that were incremented/decremented, call
  18704. // AddedFields().
  18705. func (m *MsgMutation) Fields() []string {
  18706. fields := make([]string, 0, 9)
  18707. if m.created_at != nil {
  18708. fields = append(fields, msg.FieldCreatedAt)
  18709. }
  18710. if m.updated_at != nil {
  18711. fields = append(fields, msg.FieldUpdatedAt)
  18712. }
  18713. if m.deleted_at != nil {
  18714. fields = append(fields, msg.FieldDeletedAt)
  18715. }
  18716. if m.status != nil {
  18717. fields = append(fields, msg.FieldStatus)
  18718. }
  18719. if m.fromwxid != nil {
  18720. fields = append(fields, msg.FieldFromwxid)
  18721. }
  18722. if m.toid != nil {
  18723. fields = append(fields, msg.FieldToid)
  18724. }
  18725. if m.msgtype != nil {
  18726. fields = append(fields, msg.FieldMsgtype)
  18727. }
  18728. if m.msg != nil {
  18729. fields = append(fields, msg.FieldMsg)
  18730. }
  18731. if m.batch_no != nil {
  18732. fields = append(fields, msg.FieldBatchNo)
  18733. }
  18734. return fields
  18735. }
  18736. // Field returns the value of a field with the given name. The second boolean
  18737. // return value indicates that this field was not set, or was not defined in the
  18738. // schema.
  18739. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  18740. switch name {
  18741. case msg.FieldCreatedAt:
  18742. return m.CreatedAt()
  18743. case msg.FieldUpdatedAt:
  18744. return m.UpdatedAt()
  18745. case msg.FieldDeletedAt:
  18746. return m.DeletedAt()
  18747. case msg.FieldStatus:
  18748. return m.Status()
  18749. case msg.FieldFromwxid:
  18750. return m.Fromwxid()
  18751. case msg.FieldToid:
  18752. return m.Toid()
  18753. case msg.FieldMsgtype:
  18754. return m.Msgtype()
  18755. case msg.FieldMsg:
  18756. return m.Msg()
  18757. case msg.FieldBatchNo:
  18758. return m.BatchNo()
  18759. }
  18760. return nil, false
  18761. }
  18762. // OldField returns the old value of the field from the database. An error is
  18763. // returned if the mutation operation is not UpdateOne, or the query to the
  18764. // database failed.
  18765. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18766. switch name {
  18767. case msg.FieldCreatedAt:
  18768. return m.OldCreatedAt(ctx)
  18769. case msg.FieldUpdatedAt:
  18770. return m.OldUpdatedAt(ctx)
  18771. case msg.FieldDeletedAt:
  18772. return m.OldDeletedAt(ctx)
  18773. case msg.FieldStatus:
  18774. return m.OldStatus(ctx)
  18775. case msg.FieldFromwxid:
  18776. return m.OldFromwxid(ctx)
  18777. case msg.FieldToid:
  18778. return m.OldToid(ctx)
  18779. case msg.FieldMsgtype:
  18780. return m.OldMsgtype(ctx)
  18781. case msg.FieldMsg:
  18782. return m.OldMsg(ctx)
  18783. case msg.FieldBatchNo:
  18784. return m.OldBatchNo(ctx)
  18785. }
  18786. return nil, fmt.Errorf("unknown Msg field %s", name)
  18787. }
  18788. // SetField sets the value of a field with the given name. It returns an error if
  18789. // the field is not defined in the schema, or if the type mismatched the field
  18790. // type.
  18791. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  18792. switch name {
  18793. case msg.FieldCreatedAt:
  18794. v, ok := value.(time.Time)
  18795. if !ok {
  18796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18797. }
  18798. m.SetCreatedAt(v)
  18799. return nil
  18800. case msg.FieldUpdatedAt:
  18801. v, ok := value.(time.Time)
  18802. if !ok {
  18803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18804. }
  18805. m.SetUpdatedAt(v)
  18806. return nil
  18807. case msg.FieldDeletedAt:
  18808. v, ok := value.(time.Time)
  18809. if !ok {
  18810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18811. }
  18812. m.SetDeletedAt(v)
  18813. return nil
  18814. case msg.FieldStatus:
  18815. v, ok := value.(uint8)
  18816. if !ok {
  18817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18818. }
  18819. m.SetStatus(v)
  18820. return nil
  18821. case msg.FieldFromwxid:
  18822. v, ok := value.(string)
  18823. if !ok {
  18824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18825. }
  18826. m.SetFromwxid(v)
  18827. return nil
  18828. case msg.FieldToid:
  18829. v, ok := value.(string)
  18830. if !ok {
  18831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18832. }
  18833. m.SetToid(v)
  18834. return nil
  18835. case msg.FieldMsgtype:
  18836. v, ok := value.(int32)
  18837. if !ok {
  18838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18839. }
  18840. m.SetMsgtype(v)
  18841. return nil
  18842. case msg.FieldMsg:
  18843. v, ok := value.(string)
  18844. if !ok {
  18845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18846. }
  18847. m.SetMsg(v)
  18848. return nil
  18849. case msg.FieldBatchNo:
  18850. v, ok := value.(string)
  18851. if !ok {
  18852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18853. }
  18854. m.SetBatchNo(v)
  18855. return nil
  18856. }
  18857. return fmt.Errorf("unknown Msg field %s", name)
  18858. }
  18859. // AddedFields returns all numeric fields that were incremented/decremented during
  18860. // this mutation.
  18861. func (m *MsgMutation) AddedFields() []string {
  18862. var fields []string
  18863. if m.addstatus != nil {
  18864. fields = append(fields, msg.FieldStatus)
  18865. }
  18866. if m.addmsgtype != nil {
  18867. fields = append(fields, msg.FieldMsgtype)
  18868. }
  18869. return fields
  18870. }
  18871. // AddedField returns the numeric value that was incremented/decremented on a field
  18872. // with the given name. The second boolean return value indicates that this field
  18873. // was not set, or was not defined in the schema.
  18874. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  18875. switch name {
  18876. case msg.FieldStatus:
  18877. return m.AddedStatus()
  18878. case msg.FieldMsgtype:
  18879. return m.AddedMsgtype()
  18880. }
  18881. return nil, false
  18882. }
  18883. // AddField adds the value to the field with the given name. It returns an error if
  18884. // the field is not defined in the schema, or if the type mismatched the field
  18885. // type.
  18886. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  18887. switch name {
  18888. case msg.FieldStatus:
  18889. v, ok := value.(int8)
  18890. if !ok {
  18891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18892. }
  18893. m.AddStatus(v)
  18894. return nil
  18895. case msg.FieldMsgtype:
  18896. v, ok := value.(int32)
  18897. if !ok {
  18898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18899. }
  18900. m.AddMsgtype(v)
  18901. return nil
  18902. }
  18903. return fmt.Errorf("unknown Msg numeric field %s", name)
  18904. }
  18905. // ClearedFields returns all nullable fields that were cleared during this
  18906. // mutation.
  18907. func (m *MsgMutation) ClearedFields() []string {
  18908. var fields []string
  18909. if m.FieldCleared(msg.FieldDeletedAt) {
  18910. fields = append(fields, msg.FieldDeletedAt)
  18911. }
  18912. if m.FieldCleared(msg.FieldStatus) {
  18913. fields = append(fields, msg.FieldStatus)
  18914. }
  18915. if m.FieldCleared(msg.FieldFromwxid) {
  18916. fields = append(fields, msg.FieldFromwxid)
  18917. }
  18918. if m.FieldCleared(msg.FieldToid) {
  18919. fields = append(fields, msg.FieldToid)
  18920. }
  18921. if m.FieldCleared(msg.FieldMsgtype) {
  18922. fields = append(fields, msg.FieldMsgtype)
  18923. }
  18924. if m.FieldCleared(msg.FieldMsg) {
  18925. fields = append(fields, msg.FieldMsg)
  18926. }
  18927. if m.FieldCleared(msg.FieldBatchNo) {
  18928. fields = append(fields, msg.FieldBatchNo)
  18929. }
  18930. return fields
  18931. }
  18932. // FieldCleared returns a boolean indicating if a field with the given name was
  18933. // cleared in this mutation.
  18934. func (m *MsgMutation) FieldCleared(name string) bool {
  18935. _, ok := m.clearedFields[name]
  18936. return ok
  18937. }
  18938. // ClearField clears the value of the field with the given name. It returns an
  18939. // error if the field is not defined in the schema.
  18940. func (m *MsgMutation) ClearField(name string) error {
  18941. switch name {
  18942. case msg.FieldDeletedAt:
  18943. m.ClearDeletedAt()
  18944. return nil
  18945. case msg.FieldStatus:
  18946. m.ClearStatus()
  18947. return nil
  18948. case msg.FieldFromwxid:
  18949. m.ClearFromwxid()
  18950. return nil
  18951. case msg.FieldToid:
  18952. m.ClearToid()
  18953. return nil
  18954. case msg.FieldMsgtype:
  18955. m.ClearMsgtype()
  18956. return nil
  18957. case msg.FieldMsg:
  18958. m.ClearMsg()
  18959. return nil
  18960. case msg.FieldBatchNo:
  18961. m.ClearBatchNo()
  18962. return nil
  18963. }
  18964. return fmt.Errorf("unknown Msg nullable field %s", name)
  18965. }
  18966. // ResetField resets all changes in the mutation for the field with the given name.
  18967. // It returns an error if the field is not defined in the schema.
  18968. func (m *MsgMutation) ResetField(name string) error {
  18969. switch name {
  18970. case msg.FieldCreatedAt:
  18971. m.ResetCreatedAt()
  18972. return nil
  18973. case msg.FieldUpdatedAt:
  18974. m.ResetUpdatedAt()
  18975. return nil
  18976. case msg.FieldDeletedAt:
  18977. m.ResetDeletedAt()
  18978. return nil
  18979. case msg.FieldStatus:
  18980. m.ResetStatus()
  18981. return nil
  18982. case msg.FieldFromwxid:
  18983. m.ResetFromwxid()
  18984. return nil
  18985. case msg.FieldToid:
  18986. m.ResetToid()
  18987. return nil
  18988. case msg.FieldMsgtype:
  18989. m.ResetMsgtype()
  18990. return nil
  18991. case msg.FieldMsg:
  18992. m.ResetMsg()
  18993. return nil
  18994. case msg.FieldBatchNo:
  18995. m.ResetBatchNo()
  18996. return nil
  18997. }
  18998. return fmt.Errorf("unknown Msg field %s", name)
  18999. }
  19000. // AddedEdges returns all edge names that were set/added in this mutation.
  19001. func (m *MsgMutation) AddedEdges() []string {
  19002. edges := make([]string, 0, 0)
  19003. return edges
  19004. }
  19005. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19006. // name in this mutation.
  19007. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  19008. return nil
  19009. }
  19010. // RemovedEdges returns all edge names that were removed in this mutation.
  19011. func (m *MsgMutation) RemovedEdges() []string {
  19012. edges := make([]string, 0, 0)
  19013. return edges
  19014. }
  19015. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19016. // the given name in this mutation.
  19017. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  19018. return nil
  19019. }
  19020. // ClearedEdges returns all edge names that were cleared in this mutation.
  19021. func (m *MsgMutation) ClearedEdges() []string {
  19022. edges := make([]string, 0, 0)
  19023. return edges
  19024. }
  19025. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19026. // was cleared in this mutation.
  19027. func (m *MsgMutation) EdgeCleared(name string) bool {
  19028. return false
  19029. }
  19030. // ClearEdge clears the value of the edge with the given name. It returns an error
  19031. // if that edge is not defined in the schema.
  19032. func (m *MsgMutation) ClearEdge(name string) error {
  19033. return fmt.Errorf("unknown Msg unique edge %s", name)
  19034. }
  19035. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19036. // It returns an error if the edge is not defined in the schema.
  19037. func (m *MsgMutation) ResetEdge(name string) error {
  19038. return fmt.Errorf("unknown Msg edge %s", name)
  19039. }
  19040. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  19041. type PayRechargeMutation struct {
  19042. config
  19043. op Op
  19044. typ string
  19045. id *uint64
  19046. created_at *time.Time
  19047. updated_at *time.Time
  19048. deleted_at *time.Time
  19049. user_id *string
  19050. number *float32
  19051. addnumber *float32
  19052. status *int
  19053. addstatus *int
  19054. money *float32
  19055. addmoney *float32
  19056. out_trade_no *string
  19057. organization_id *uint64
  19058. addorganization_id *int64
  19059. clearedFields map[string]struct{}
  19060. done bool
  19061. oldValue func(context.Context) (*PayRecharge, error)
  19062. predicates []predicate.PayRecharge
  19063. }
  19064. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  19065. // payrechargeOption allows management of the mutation configuration using functional options.
  19066. type payrechargeOption func(*PayRechargeMutation)
  19067. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  19068. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  19069. m := &PayRechargeMutation{
  19070. config: c,
  19071. op: op,
  19072. typ: TypePayRecharge,
  19073. clearedFields: make(map[string]struct{}),
  19074. }
  19075. for _, opt := range opts {
  19076. opt(m)
  19077. }
  19078. return m
  19079. }
  19080. // withPayRechargeID sets the ID field of the mutation.
  19081. func withPayRechargeID(id uint64) payrechargeOption {
  19082. return func(m *PayRechargeMutation) {
  19083. var (
  19084. err error
  19085. once sync.Once
  19086. value *PayRecharge
  19087. )
  19088. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  19089. once.Do(func() {
  19090. if m.done {
  19091. err = errors.New("querying old values post mutation is not allowed")
  19092. } else {
  19093. value, err = m.Client().PayRecharge.Get(ctx, id)
  19094. }
  19095. })
  19096. return value, err
  19097. }
  19098. m.id = &id
  19099. }
  19100. }
  19101. // withPayRecharge sets the old PayRecharge of the mutation.
  19102. func withPayRecharge(node *PayRecharge) payrechargeOption {
  19103. return func(m *PayRechargeMutation) {
  19104. m.oldValue = func(context.Context) (*PayRecharge, error) {
  19105. return node, nil
  19106. }
  19107. m.id = &node.ID
  19108. }
  19109. }
  19110. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19111. // executed in a transaction (ent.Tx), a transactional client is returned.
  19112. func (m PayRechargeMutation) Client() *Client {
  19113. client := &Client{config: m.config}
  19114. client.init()
  19115. return client
  19116. }
  19117. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19118. // it returns an error otherwise.
  19119. func (m PayRechargeMutation) Tx() (*Tx, error) {
  19120. if _, ok := m.driver.(*txDriver); !ok {
  19121. return nil, errors.New("ent: mutation is not running in a transaction")
  19122. }
  19123. tx := &Tx{config: m.config}
  19124. tx.init()
  19125. return tx, nil
  19126. }
  19127. // SetID sets the value of the id field. Note that this
  19128. // operation is only accepted on creation of PayRecharge entities.
  19129. func (m *PayRechargeMutation) SetID(id uint64) {
  19130. m.id = &id
  19131. }
  19132. // ID returns the ID value in the mutation. Note that the ID is only available
  19133. // if it was provided to the builder or after it was returned from the database.
  19134. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  19135. if m.id == nil {
  19136. return
  19137. }
  19138. return *m.id, true
  19139. }
  19140. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19141. // That means, if the mutation is applied within a transaction with an isolation level such
  19142. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19143. // or updated by the mutation.
  19144. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  19145. switch {
  19146. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19147. id, exists := m.ID()
  19148. if exists {
  19149. return []uint64{id}, nil
  19150. }
  19151. fallthrough
  19152. case m.op.Is(OpUpdate | OpDelete):
  19153. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  19154. default:
  19155. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19156. }
  19157. }
  19158. // SetCreatedAt sets the "created_at" field.
  19159. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  19160. m.created_at = &t
  19161. }
  19162. // CreatedAt returns the value of the "created_at" field in the mutation.
  19163. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  19164. v := m.created_at
  19165. if v == nil {
  19166. return
  19167. }
  19168. return *v, true
  19169. }
  19170. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  19171. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19173. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19174. if !m.op.Is(OpUpdateOne) {
  19175. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19176. }
  19177. if m.id == nil || m.oldValue == nil {
  19178. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19179. }
  19180. oldValue, err := m.oldValue(ctx)
  19181. if err != nil {
  19182. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19183. }
  19184. return oldValue.CreatedAt, nil
  19185. }
  19186. // ResetCreatedAt resets all changes to the "created_at" field.
  19187. func (m *PayRechargeMutation) ResetCreatedAt() {
  19188. m.created_at = nil
  19189. }
  19190. // SetUpdatedAt sets the "updated_at" field.
  19191. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  19192. m.updated_at = &t
  19193. }
  19194. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19195. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  19196. v := m.updated_at
  19197. if v == nil {
  19198. return
  19199. }
  19200. return *v, true
  19201. }
  19202. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  19203. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19205. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19206. if !m.op.Is(OpUpdateOne) {
  19207. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19208. }
  19209. if m.id == nil || m.oldValue == nil {
  19210. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19211. }
  19212. oldValue, err := m.oldValue(ctx)
  19213. if err != nil {
  19214. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19215. }
  19216. return oldValue.UpdatedAt, nil
  19217. }
  19218. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19219. func (m *PayRechargeMutation) ResetUpdatedAt() {
  19220. m.updated_at = nil
  19221. }
  19222. // SetDeletedAt sets the "deleted_at" field.
  19223. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  19224. m.deleted_at = &t
  19225. }
  19226. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19227. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  19228. v := m.deleted_at
  19229. if v == nil {
  19230. return
  19231. }
  19232. return *v, true
  19233. }
  19234. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  19235. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19237. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19238. if !m.op.Is(OpUpdateOne) {
  19239. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19240. }
  19241. if m.id == nil || m.oldValue == nil {
  19242. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19243. }
  19244. oldValue, err := m.oldValue(ctx)
  19245. if err != nil {
  19246. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19247. }
  19248. return oldValue.DeletedAt, nil
  19249. }
  19250. // ClearDeletedAt clears the value of the "deleted_at" field.
  19251. func (m *PayRechargeMutation) ClearDeletedAt() {
  19252. m.deleted_at = nil
  19253. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  19254. }
  19255. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19256. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  19257. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  19258. return ok
  19259. }
  19260. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19261. func (m *PayRechargeMutation) ResetDeletedAt() {
  19262. m.deleted_at = nil
  19263. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  19264. }
  19265. // SetUserID sets the "user_id" field.
  19266. func (m *PayRechargeMutation) SetUserID(s string) {
  19267. m.user_id = &s
  19268. }
  19269. // UserID returns the value of the "user_id" field in the mutation.
  19270. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  19271. v := m.user_id
  19272. if v == nil {
  19273. return
  19274. }
  19275. return *v, true
  19276. }
  19277. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  19278. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19280. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  19281. if !m.op.Is(OpUpdateOne) {
  19282. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  19283. }
  19284. if m.id == nil || m.oldValue == nil {
  19285. return v, errors.New("OldUserID requires an ID field in the mutation")
  19286. }
  19287. oldValue, err := m.oldValue(ctx)
  19288. if err != nil {
  19289. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  19290. }
  19291. return oldValue.UserID, nil
  19292. }
  19293. // ResetUserID resets all changes to the "user_id" field.
  19294. func (m *PayRechargeMutation) ResetUserID() {
  19295. m.user_id = nil
  19296. }
  19297. // SetNumber sets the "number" field.
  19298. func (m *PayRechargeMutation) SetNumber(f float32) {
  19299. m.number = &f
  19300. m.addnumber = nil
  19301. }
  19302. // Number returns the value of the "number" field in the mutation.
  19303. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  19304. v := m.number
  19305. if v == nil {
  19306. return
  19307. }
  19308. return *v, true
  19309. }
  19310. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  19311. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19313. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  19314. if !m.op.Is(OpUpdateOne) {
  19315. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  19316. }
  19317. if m.id == nil || m.oldValue == nil {
  19318. return v, errors.New("OldNumber requires an ID field in the mutation")
  19319. }
  19320. oldValue, err := m.oldValue(ctx)
  19321. if err != nil {
  19322. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  19323. }
  19324. return oldValue.Number, nil
  19325. }
  19326. // AddNumber adds f to the "number" field.
  19327. func (m *PayRechargeMutation) AddNumber(f float32) {
  19328. if m.addnumber != nil {
  19329. *m.addnumber += f
  19330. } else {
  19331. m.addnumber = &f
  19332. }
  19333. }
  19334. // AddedNumber returns the value that was added to the "number" field in this mutation.
  19335. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  19336. v := m.addnumber
  19337. if v == nil {
  19338. return
  19339. }
  19340. return *v, true
  19341. }
  19342. // ResetNumber resets all changes to the "number" field.
  19343. func (m *PayRechargeMutation) ResetNumber() {
  19344. m.number = nil
  19345. m.addnumber = nil
  19346. }
  19347. // SetStatus sets the "status" field.
  19348. func (m *PayRechargeMutation) SetStatus(i int) {
  19349. m.status = &i
  19350. m.addstatus = nil
  19351. }
  19352. // Status returns the value of the "status" field in the mutation.
  19353. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  19354. v := m.status
  19355. if v == nil {
  19356. return
  19357. }
  19358. return *v, true
  19359. }
  19360. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  19361. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19363. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  19364. if !m.op.Is(OpUpdateOne) {
  19365. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19366. }
  19367. if m.id == nil || m.oldValue == nil {
  19368. return v, errors.New("OldStatus requires an ID field in the mutation")
  19369. }
  19370. oldValue, err := m.oldValue(ctx)
  19371. if err != nil {
  19372. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19373. }
  19374. return oldValue.Status, nil
  19375. }
  19376. // AddStatus adds i to the "status" field.
  19377. func (m *PayRechargeMutation) AddStatus(i int) {
  19378. if m.addstatus != nil {
  19379. *m.addstatus += i
  19380. } else {
  19381. m.addstatus = &i
  19382. }
  19383. }
  19384. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19385. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  19386. v := m.addstatus
  19387. if v == nil {
  19388. return
  19389. }
  19390. return *v, true
  19391. }
  19392. // ClearStatus clears the value of the "status" field.
  19393. func (m *PayRechargeMutation) ClearStatus() {
  19394. m.status = nil
  19395. m.addstatus = nil
  19396. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  19397. }
  19398. // StatusCleared returns if the "status" field was cleared in this mutation.
  19399. func (m *PayRechargeMutation) StatusCleared() bool {
  19400. _, ok := m.clearedFields[payrecharge.FieldStatus]
  19401. return ok
  19402. }
  19403. // ResetStatus resets all changes to the "status" field.
  19404. func (m *PayRechargeMutation) ResetStatus() {
  19405. m.status = nil
  19406. m.addstatus = nil
  19407. delete(m.clearedFields, payrecharge.FieldStatus)
  19408. }
  19409. // SetMoney sets the "money" field.
  19410. func (m *PayRechargeMutation) SetMoney(f float32) {
  19411. m.money = &f
  19412. m.addmoney = nil
  19413. }
  19414. // Money returns the value of the "money" field in the mutation.
  19415. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  19416. v := m.money
  19417. if v == nil {
  19418. return
  19419. }
  19420. return *v, true
  19421. }
  19422. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  19423. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19425. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  19426. if !m.op.Is(OpUpdateOne) {
  19427. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  19428. }
  19429. if m.id == nil || m.oldValue == nil {
  19430. return v, errors.New("OldMoney requires an ID field in the mutation")
  19431. }
  19432. oldValue, err := m.oldValue(ctx)
  19433. if err != nil {
  19434. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  19435. }
  19436. return oldValue.Money, nil
  19437. }
  19438. // AddMoney adds f to the "money" field.
  19439. func (m *PayRechargeMutation) AddMoney(f float32) {
  19440. if m.addmoney != nil {
  19441. *m.addmoney += f
  19442. } else {
  19443. m.addmoney = &f
  19444. }
  19445. }
  19446. // AddedMoney returns the value that was added to the "money" field in this mutation.
  19447. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  19448. v := m.addmoney
  19449. if v == nil {
  19450. return
  19451. }
  19452. return *v, true
  19453. }
  19454. // ClearMoney clears the value of the "money" field.
  19455. func (m *PayRechargeMutation) ClearMoney() {
  19456. m.money = nil
  19457. m.addmoney = nil
  19458. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  19459. }
  19460. // MoneyCleared returns if the "money" field was cleared in this mutation.
  19461. func (m *PayRechargeMutation) MoneyCleared() bool {
  19462. _, ok := m.clearedFields[payrecharge.FieldMoney]
  19463. return ok
  19464. }
  19465. // ResetMoney resets all changes to the "money" field.
  19466. func (m *PayRechargeMutation) ResetMoney() {
  19467. m.money = nil
  19468. m.addmoney = nil
  19469. delete(m.clearedFields, payrecharge.FieldMoney)
  19470. }
  19471. // SetOutTradeNo sets the "out_trade_no" field.
  19472. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  19473. m.out_trade_no = &s
  19474. }
  19475. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  19476. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  19477. v := m.out_trade_no
  19478. if v == nil {
  19479. return
  19480. }
  19481. return *v, true
  19482. }
  19483. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  19484. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19486. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  19487. if !m.op.Is(OpUpdateOne) {
  19488. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  19489. }
  19490. if m.id == nil || m.oldValue == nil {
  19491. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  19492. }
  19493. oldValue, err := m.oldValue(ctx)
  19494. if err != nil {
  19495. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  19496. }
  19497. return oldValue.OutTradeNo, nil
  19498. }
  19499. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  19500. func (m *PayRechargeMutation) ClearOutTradeNo() {
  19501. m.out_trade_no = nil
  19502. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  19503. }
  19504. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  19505. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  19506. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  19507. return ok
  19508. }
  19509. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  19510. func (m *PayRechargeMutation) ResetOutTradeNo() {
  19511. m.out_trade_no = nil
  19512. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  19513. }
  19514. // SetOrganizationID sets the "organization_id" field.
  19515. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  19516. m.organization_id = &u
  19517. m.addorganization_id = nil
  19518. }
  19519. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19520. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  19521. v := m.organization_id
  19522. if v == nil {
  19523. return
  19524. }
  19525. return *v, true
  19526. }
  19527. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  19528. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19530. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19531. if !m.op.Is(OpUpdateOne) {
  19532. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19533. }
  19534. if m.id == nil || m.oldValue == nil {
  19535. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19536. }
  19537. oldValue, err := m.oldValue(ctx)
  19538. if err != nil {
  19539. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19540. }
  19541. return oldValue.OrganizationID, nil
  19542. }
  19543. // AddOrganizationID adds u to the "organization_id" field.
  19544. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  19545. if m.addorganization_id != nil {
  19546. *m.addorganization_id += u
  19547. } else {
  19548. m.addorganization_id = &u
  19549. }
  19550. }
  19551. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19552. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  19553. v := m.addorganization_id
  19554. if v == nil {
  19555. return
  19556. }
  19557. return *v, true
  19558. }
  19559. // ResetOrganizationID resets all changes to the "organization_id" field.
  19560. func (m *PayRechargeMutation) ResetOrganizationID() {
  19561. m.organization_id = nil
  19562. m.addorganization_id = nil
  19563. }
  19564. // Where appends a list predicates to the PayRechargeMutation builder.
  19565. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  19566. m.predicates = append(m.predicates, ps...)
  19567. }
  19568. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  19569. // users can use type-assertion to append predicates that do not depend on any generated package.
  19570. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  19571. p := make([]predicate.PayRecharge, len(ps))
  19572. for i := range ps {
  19573. p[i] = ps[i]
  19574. }
  19575. m.Where(p...)
  19576. }
  19577. // Op returns the operation name.
  19578. func (m *PayRechargeMutation) Op() Op {
  19579. return m.op
  19580. }
  19581. // SetOp allows setting the mutation operation.
  19582. func (m *PayRechargeMutation) SetOp(op Op) {
  19583. m.op = op
  19584. }
  19585. // Type returns the node type of this mutation (PayRecharge).
  19586. func (m *PayRechargeMutation) Type() string {
  19587. return m.typ
  19588. }
  19589. // Fields returns all fields that were changed during this mutation. Note that in
  19590. // order to get all numeric fields that were incremented/decremented, call
  19591. // AddedFields().
  19592. func (m *PayRechargeMutation) Fields() []string {
  19593. fields := make([]string, 0, 9)
  19594. if m.created_at != nil {
  19595. fields = append(fields, payrecharge.FieldCreatedAt)
  19596. }
  19597. if m.updated_at != nil {
  19598. fields = append(fields, payrecharge.FieldUpdatedAt)
  19599. }
  19600. if m.deleted_at != nil {
  19601. fields = append(fields, payrecharge.FieldDeletedAt)
  19602. }
  19603. if m.user_id != nil {
  19604. fields = append(fields, payrecharge.FieldUserID)
  19605. }
  19606. if m.number != nil {
  19607. fields = append(fields, payrecharge.FieldNumber)
  19608. }
  19609. if m.status != nil {
  19610. fields = append(fields, payrecharge.FieldStatus)
  19611. }
  19612. if m.money != nil {
  19613. fields = append(fields, payrecharge.FieldMoney)
  19614. }
  19615. if m.out_trade_no != nil {
  19616. fields = append(fields, payrecharge.FieldOutTradeNo)
  19617. }
  19618. if m.organization_id != nil {
  19619. fields = append(fields, payrecharge.FieldOrganizationID)
  19620. }
  19621. return fields
  19622. }
  19623. // Field returns the value of a field with the given name. The second boolean
  19624. // return value indicates that this field was not set, or was not defined in the
  19625. // schema.
  19626. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  19627. switch name {
  19628. case payrecharge.FieldCreatedAt:
  19629. return m.CreatedAt()
  19630. case payrecharge.FieldUpdatedAt:
  19631. return m.UpdatedAt()
  19632. case payrecharge.FieldDeletedAt:
  19633. return m.DeletedAt()
  19634. case payrecharge.FieldUserID:
  19635. return m.UserID()
  19636. case payrecharge.FieldNumber:
  19637. return m.Number()
  19638. case payrecharge.FieldStatus:
  19639. return m.Status()
  19640. case payrecharge.FieldMoney:
  19641. return m.Money()
  19642. case payrecharge.FieldOutTradeNo:
  19643. return m.OutTradeNo()
  19644. case payrecharge.FieldOrganizationID:
  19645. return m.OrganizationID()
  19646. }
  19647. return nil, false
  19648. }
  19649. // OldField returns the old value of the field from the database. An error is
  19650. // returned if the mutation operation is not UpdateOne, or the query to the
  19651. // database failed.
  19652. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19653. switch name {
  19654. case payrecharge.FieldCreatedAt:
  19655. return m.OldCreatedAt(ctx)
  19656. case payrecharge.FieldUpdatedAt:
  19657. return m.OldUpdatedAt(ctx)
  19658. case payrecharge.FieldDeletedAt:
  19659. return m.OldDeletedAt(ctx)
  19660. case payrecharge.FieldUserID:
  19661. return m.OldUserID(ctx)
  19662. case payrecharge.FieldNumber:
  19663. return m.OldNumber(ctx)
  19664. case payrecharge.FieldStatus:
  19665. return m.OldStatus(ctx)
  19666. case payrecharge.FieldMoney:
  19667. return m.OldMoney(ctx)
  19668. case payrecharge.FieldOutTradeNo:
  19669. return m.OldOutTradeNo(ctx)
  19670. case payrecharge.FieldOrganizationID:
  19671. return m.OldOrganizationID(ctx)
  19672. }
  19673. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  19674. }
  19675. // SetField sets the value of a field with the given name. It returns an error if
  19676. // the field is not defined in the schema, or if the type mismatched the field
  19677. // type.
  19678. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  19679. switch name {
  19680. case payrecharge.FieldCreatedAt:
  19681. v, ok := value.(time.Time)
  19682. if !ok {
  19683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19684. }
  19685. m.SetCreatedAt(v)
  19686. return nil
  19687. case payrecharge.FieldUpdatedAt:
  19688. v, ok := value.(time.Time)
  19689. if !ok {
  19690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19691. }
  19692. m.SetUpdatedAt(v)
  19693. return nil
  19694. case payrecharge.FieldDeletedAt:
  19695. v, ok := value.(time.Time)
  19696. if !ok {
  19697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19698. }
  19699. m.SetDeletedAt(v)
  19700. return nil
  19701. case payrecharge.FieldUserID:
  19702. v, ok := value.(string)
  19703. if !ok {
  19704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19705. }
  19706. m.SetUserID(v)
  19707. return nil
  19708. case payrecharge.FieldNumber:
  19709. v, ok := value.(float32)
  19710. if !ok {
  19711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19712. }
  19713. m.SetNumber(v)
  19714. return nil
  19715. case payrecharge.FieldStatus:
  19716. v, ok := value.(int)
  19717. if !ok {
  19718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19719. }
  19720. m.SetStatus(v)
  19721. return nil
  19722. case payrecharge.FieldMoney:
  19723. v, ok := value.(float32)
  19724. if !ok {
  19725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19726. }
  19727. m.SetMoney(v)
  19728. return nil
  19729. case payrecharge.FieldOutTradeNo:
  19730. v, ok := value.(string)
  19731. if !ok {
  19732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19733. }
  19734. m.SetOutTradeNo(v)
  19735. return nil
  19736. case payrecharge.FieldOrganizationID:
  19737. v, ok := value.(uint64)
  19738. if !ok {
  19739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19740. }
  19741. m.SetOrganizationID(v)
  19742. return nil
  19743. }
  19744. return fmt.Errorf("unknown PayRecharge field %s", name)
  19745. }
  19746. // AddedFields returns all numeric fields that were incremented/decremented during
  19747. // this mutation.
  19748. func (m *PayRechargeMutation) AddedFields() []string {
  19749. var fields []string
  19750. if m.addnumber != nil {
  19751. fields = append(fields, payrecharge.FieldNumber)
  19752. }
  19753. if m.addstatus != nil {
  19754. fields = append(fields, payrecharge.FieldStatus)
  19755. }
  19756. if m.addmoney != nil {
  19757. fields = append(fields, payrecharge.FieldMoney)
  19758. }
  19759. if m.addorganization_id != nil {
  19760. fields = append(fields, payrecharge.FieldOrganizationID)
  19761. }
  19762. return fields
  19763. }
  19764. // AddedField returns the numeric value that was incremented/decremented on a field
  19765. // with the given name. The second boolean return value indicates that this field
  19766. // was not set, or was not defined in the schema.
  19767. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  19768. switch name {
  19769. case payrecharge.FieldNumber:
  19770. return m.AddedNumber()
  19771. case payrecharge.FieldStatus:
  19772. return m.AddedStatus()
  19773. case payrecharge.FieldMoney:
  19774. return m.AddedMoney()
  19775. case payrecharge.FieldOrganizationID:
  19776. return m.AddedOrganizationID()
  19777. }
  19778. return nil, false
  19779. }
  19780. // AddField adds the value to the field with the given name. It returns an error if
  19781. // the field is not defined in the schema, or if the type mismatched the field
  19782. // type.
  19783. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  19784. switch name {
  19785. case payrecharge.FieldNumber:
  19786. v, ok := value.(float32)
  19787. if !ok {
  19788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19789. }
  19790. m.AddNumber(v)
  19791. return nil
  19792. case payrecharge.FieldStatus:
  19793. v, ok := value.(int)
  19794. if !ok {
  19795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19796. }
  19797. m.AddStatus(v)
  19798. return nil
  19799. case payrecharge.FieldMoney:
  19800. v, ok := value.(float32)
  19801. if !ok {
  19802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19803. }
  19804. m.AddMoney(v)
  19805. return nil
  19806. case payrecharge.FieldOrganizationID:
  19807. v, ok := value.(int64)
  19808. if !ok {
  19809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19810. }
  19811. m.AddOrganizationID(v)
  19812. return nil
  19813. }
  19814. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  19815. }
  19816. // ClearedFields returns all nullable fields that were cleared during this
  19817. // mutation.
  19818. func (m *PayRechargeMutation) ClearedFields() []string {
  19819. var fields []string
  19820. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  19821. fields = append(fields, payrecharge.FieldDeletedAt)
  19822. }
  19823. if m.FieldCleared(payrecharge.FieldStatus) {
  19824. fields = append(fields, payrecharge.FieldStatus)
  19825. }
  19826. if m.FieldCleared(payrecharge.FieldMoney) {
  19827. fields = append(fields, payrecharge.FieldMoney)
  19828. }
  19829. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  19830. fields = append(fields, payrecharge.FieldOutTradeNo)
  19831. }
  19832. return fields
  19833. }
  19834. // FieldCleared returns a boolean indicating if a field with the given name was
  19835. // cleared in this mutation.
  19836. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  19837. _, ok := m.clearedFields[name]
  19838. return ok
  19839. }
  19840. // ClearField clears the value of the field with the given name. It returns an
  19841. // error if the field is not defined in the schema.
  19842. func (m *PayRechargeMutation) ClearField(name string) error {
  19843. switch name {
  19844. case payrecharge.FieldDeletedAt:
  19845. m.ClearDeletedAt()
  19846. return nil
  19847. case payrecharge.FieldStatus:
  19848. m.ClearStatus()
  19849. return nil
  19850. case payrecharge.FieldMoney:
  19851. m.ClearMoney()
  19852. return nil
  19853. case payrecharge.FieldOutTradeNo:
  19854. m.ClearOutTradeNo()
  19855. return nil
  19856. }
  19857. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  19858. }
  19859. // ResetField resets all changes in the mutation for the field with the given name.
  19860. // It returns an error if the field is not defined in the schema.
  19861. func (m *PayRechargeMutation) ResetField(name string) error {
  19862. switch name {
  19863. case payrecharge.FieldCreatedAt:
  19864. m.ResetCreatedAt()
  19865. return nil
  19866. case payrecharge.FieldUpdatedAt:
  19867. m.ResetUpdatedAt()
  19868. return nil
  19869. case payrecharge.FieldDeletedAt:
  19870. m.ResetDeletedAt()
  19871. return nil
  19872. case payrecharge.FieldUserID:
  19873. m.ResetUserID()
  19874. return nil
  19875. case payrecharge.FieldNumber:
  19876. m.ResetNumber()
  19877. return nil
  19878. case payrecharge.FieldStatus:
  19879. m.ResetStatus()
  19880. return nil
  19881. case payrecharge.FieldMoney:
  19882. m.ResetMoney()
  19883. return nil
  19884. case payrecharge.FieldOutTradeNo:
  19885. m.ResetOutTradeNo()
  19886. return nil
  19887. case payrecharge.FieldOrganizationID:
  19888. m.ResetOrganizationID()
  19889. return nil
  19890. }
  19891. return fmt.Errorf("unknown PayRecharge field %s", name)
  19892. }
  19893. // AddedEdges returns all edge names that were set/added in this mutation.
  19894. func (m *PayRechargeMutation) AddedEdges() []string {
  19895. edges := make([]string, 0, 0)
  19896. return edges
  19897. }
  19898. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19899. // name in this mutation.
  19900. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  19901. return nil
  19902. }
  19903. // RemovedEdges returns all edge names that were removed in this mutation.
  19904. func (m *PayRechargeMutation) RemovedEdges() []string {
  19905. edges := make([]string, 0, 0)
  19906. return edges
  19907. }
  19908. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19909. // the given name in this mutation.
  19910. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  19911. return nil
  19912. }
  19913. // ClearedEdges returns all edge names that were cleared in this mutation.
  19914. func (m *PayRechargeMutation) ClearedEdges() []string {
  19915. edges := make([]string, 0, 0)
  19916. return edges
  19917. }
  19918. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19919. // was cleared in this mutation.
  19920. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  19921. return false
  19922. }
  19923. // ClearEdge clears the value of the edge with the given name. It returns an error
  19924. // if that edge is not defined in the schema.
  19925. func (m *PayRechargeMutation) ClearEdge(name string) error {
  19926. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  19927. }
  19928. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19929. // It returns an error if the edge is not defined in the schema.
  19930. func (m *PayRechargeMutation) ResetEdge(name string) error {
  19931. return fmt.Errorf("unknown PayRecharge edge %s", name)
  19932. }
  19933. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  19934. type ServerMutation struct {
  19935. config
  19936. op Op
  19937. typ string
  19938. id *uint64
  19939. created_at *time.Time
  19940. updated_at *time.Time
  19941. status *uint8
  19942. addstatus *int8
  19943. deleted_at *time.Time
  19944. name *string
  19945. public_ip *string
  19946. private_ip *string
  19947. admin_port *string
  19948. clearedFields map[string]struct{}
  19949. wxs map[uint64]struct{}
  19950. removedwxs map[uint64]struct{}
  19951. clearedwxs bool
  19952. done bool
  19953. oldValue func(context.Context) (*Server, error)
  19954. predicates []predicate.Server
  19955. }
  19956. var _ ent.Mutation = (*ServerMutation)(nil)
  19957. // serverOption allows management of the mutation configuration using functional options.
  19958. type serverOption func(*ServerMutation)
  19959. // newServerMutation creates new mutation for the Server entity.
  19960. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  19961. m := &ServerMutation{
  19962. config: c,
  19963. op: op,
  19964. typ: TypeServer,
  19965. clearedFields: make(map[string]struct{}),
  19966. }
  19967. for _, opt := range opts {
  19968. opt(m)
  19969. }
  19970. return m
  19971. }
  19972. // withServerID sets the ID field of the mutation.
  19973. func withServerID(id uint64) serverOption {
  19974. return func(m *ServerMutation) {
  19975. var (
  19976. err error
  19977. once sync.Once
  19978. value *Server
  19979. )
  19980. m.oldValue = func(ctx context.Context) (*Server, error) {
  19981. once.Do(func() {
  19982. if m.done {
  19983. err = errors.New("querying old values post mutation is not allowed")
  19984. } else {
  19985. value, err = m.Client().Server.Get(ctx, id)
  19986. }
  19987. })
  19988. return value, err
  19989. }
  19990. m.id = &id
  19991. }
  19992. }
  19993. // withServer sets the old Server of the mutation.
  19994. func withServer(node *Server) serverOption {
  19995. return func(m *ServerMutation) {
  19996. m.oldValue = func(context.Context) (*Server, error) {
  19997. return node, nil
  19998. }
  19999. m.id = &node.ID
  20000. }
  20001. }
  20002. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20003. // executed in a transaction (ent.Tx), a transactional client is returned.
  20004. func (m ServerMutation) Client() *Client {
  20005. client := &Client{config: m.config}
  20006. client.init()
  20007. return client
  20008. }
  20009. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20010. // it returns an error otherwise.
  20011. func (m ServerMutation) Tx() (*Tx, error) {
  20012. if _, ok := m.driver.(*txDriver); !ok {
  20013. return nil, errors.New("ent: mutation is not running in a transaction")
  20014. }
  20015. tx := &Tx{config: m.config}
  20016. tx.init()
  20017. return tx, nil
  20018. }
  20019. // SetID sets the value of the id field. Note that this
  20020. // operation is only accepted on creation of Server entities.
  20021. func (m *ServerMutation) SetID(id uint64) {
  20022. m.id = &id
  20023. }
  20024. // ID returns the ID value in the mutation. Note that the ID is only available
  20025. // if it was provided to the builder or after it was returned from the database.
  20026. func (m *ServerMutation) ID() (id uint64, exists bool) {
  20027. if m.id == nil {
  20028. return
  20029. }
  20030. return *m.id, true
  20031. }
  20032. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20033. // That means, if the mutation is applied within a transaction with an isolation level such
  20034. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20035. // or updated by the mutation.
  20036. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  20037. switch {
  20038. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20039. id, exists := m.ID()
  20040. if exists {
  20041. return []uint64{id}, nil
  20042. }
  20043. fallthrough
  20044. case m.op.Is(OpUpdate | OpDelete):
  20045. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  20046. default:
  20047. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20048. }
  20049. }
  20050. // SetCreatedAt sets the "created_at" field.
  20051. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  20052. m.created_at = &t
  20053. }
  20054. // CreatedAt returns the value of the "created_at" field in the mutation.
  20055. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  20056. v := m.created_at
  20057. if v == nil {
  20058. return
  20059. }
  20060. return *v, true
  20061. }
  20062. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  20063. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20065. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20066. if !m.op.Is(OpUpdateOne) {
  20067. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20068. }
  20069. if m.id == nil || m.oldValue == nil {
  20070. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20071. }
  20072. oldValue, err := m.oldValue(ctx)
  20073. if err != nil {
  20074. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20075. }
  20076. return oldValue.CreatedAt, nil
  20077. }
  20078. // ResetCreatedAt resets all changes to the "created_at" field.
  20079. func (m *ServerMutation) ResetCreatedAt() {
  20080. m.created_at = nil
  20081. }
  20082. // SetUpdatedAt sets the "updated_at" field.
  20083. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  20084. m.updated_at = &t
  20085. }
  20086. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20087. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  20088. v := m.updated_at
  20089. if v == nil {
  20090. return
  20091. }
  20092. return *v, true
  20093. }
  20094. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  20095. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20097. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20098. if !m.op.Is(OpUpdateOne) {
  20099. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20100. }
  20101. if m.id == nil || m.oldValue == nil {
  20102. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20103. }
  20104. oldValue, err := m.oldValue(ctx)
  20105. if err != nil {
  20106. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20107. }
  20108. return oldValue.UpdatedAt, nil
  20109. }
  20110. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20111. func (m *ServerMutation) ResetUpdatedAt() {
  20112. m.updated_at = nil
  20113. }
  20114. // SetStatus sets the "status" field.
  20115. func (m *ServerMutation) SetStatus(u uint8) {
  20116. m.status = &u
  20117. m.addstatus = nil
  20118. }
  20119. // Status returns the value of the "status" field in the mutation.
  20120. func (m *ServerMutation) Status() (r uint8, exists bool) {
  20121. v := m.status
  20122. if v == nil {
  20123. return
  20124. }
  20125. return *v, true
  20126. }
  20127. // OldStatus returns the old "status" field's value of the Server entity.
  20128. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20130. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20131. if !m.op.Is(OpUpdateOne) {
  20132. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20133. }
  20134. if m.id == nil || m.oldValue == nil {
  20135. return v, errors.New("OldStatus requires an ID field in the mutation")
  20136. }
  20137. oldValue, err := m.oldValue(ctx)
  20138. if err != nil {
  20139. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20140. }
  20141. return oldValue.Status, nil
  20142. }
  20143. // AddStatus adds u to the "status" field.
  20144. func (m *ServerMutation) AddStatus(u int8) {
  20145. if m.addstatus != nil {
  20146. *m.addstatus += u
  20147. } else {
  20148. m.addstatus = &u
  20149. }
  20150. }
  20151. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20152. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  20153. v := m.addstatus
  20154. if v == nil {
  20155. return
  20156. }
  20157. return *v, true
  20158. }
  20159. // ClearStatus clears the value of the "status" field.
  20160. func (m *ServerMutation) ClearStatus() {
  20161. m.status = nil
  20162. m.addstatus = nil
  20163. m.clearedFields[server.FieldStatus] = struct{}{}
  20164. }
  20165. // StatusCleared returns if the "status" field was cleared in this mutation.
  20166. func (m *ServerMutation) StatusCleared() bool {
  20167. _, ok := m.clearedFields[server.FieldStatus]
  20168. return ok
  20169. }
  20170. // ResetStatus resets all changes to the "status" field.
  20171. func (m *ServerMutation) ResetStatus() {
  20172. m.status = nil
  20173. m.addstatus = nil
  20174. delete(m.clearedFields, server.FieldStatus)
  20175. }
  20176. // SetDeletedAt sets the "deleted_at" field.
  20177. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  20178. m.deleted_at = &t
  20179. }
  20180. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20181. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  20182. v := m.deleted_at
  20183. if v == nil {
  20184. return
  20185. }
  20186. return *v, true
  20187. }
  20188. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  20189. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20191. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20192. if !m.op.Is(OpUpdateOne) {
  20193. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20194. }
  20195. if m.id == nil || m.oldValue == nil {
  20196. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20197. }
  20198. oldValue, err := m.oldValue(ctx)
  20199. if err != nil {
  20200. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20201. }
  20202. return oldValue.DeletedAt, nil
  20203. }
  20204. // ClearDeletedAt clears the value of the "deleted_at" field.
  20205. func (m *ServerMutation) ClearDeletedAt() {
  20206. m.deleted_at = nil
  20207. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  20208. }
  20209. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20210. func (m *ServerMutation) DeletedAtCleared() bool {
  20211. _, ok := m.clearedFields[server.FieldDeletedAt]
  20212. return ok
  20213. }
  20214. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20215. func (m *ServerMutation) ResetDeletedAt() {
  20216. m.deleted_at = nil
  20217. delete(m.clearedFields, server.FieldDeletedAt)
  20218. }
  20219. // SetName sets the "name" field.
  20220. func (m *ServerMutation) SetName(s string) {
  20221. m.name = &s
  20222. }
  20223. // Name returns the value of the "name" field in the mutation.
  20224. func (m *ServerMutation) Name() (r string, exists bool) {
  20225. v := m.name
  20226. if v == nil {
  20227. return
  20228. }
  20229. return *v, true
  20230. }
  20231. // OldName returns the old "name" field's value of the Server entity.
  20232. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20234. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  20235. if !m.op.Is(OpUpdateOne) {
  20236. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20237. }
  20238. if m.id == nil || m.oldValue == nil {
  20239. return v, errors.New("OldName requires an ID field in the mutation")
  20240. }
  20241. oldValue, err := m.oldValue(ctx)
  20242. if err != nil {
  20243. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20244. }
  20245. return oldValue.Name, nil
  20246. }
  20247. // ResetName resets all changes to the "name" field.
  20248. func (m *ServerMutation) ResetName() {
  20249. m.name = nil
  20250. }
  20251. // SetPublicIP sets the "public_ip" field.
  20252. func (m *ServerMutation) SetPublicIP(s string) {
  20253. m.public_ip = &s
  20254. }
  20255. // PublicIP returns the value of the "public_ip" field in the mutation.
  20256. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  20257. v := m.public_ip
  20258. if v == nil {
  20259. return
  20260. }
  20261. return *v, true
  20262. }
  20263. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  20264. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20266. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  20267. if !m.op.Is(OpUpdateOne) {
  20268. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  20269. }
  20270. if m.id == nil || m.oldValue == nil {
  20271. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  20272. }
  20273. oldValue, err := m.oldValue(ctx)
  20274. if err != nil {
  20275. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  20276. }
  20277. return oldValue.PublicIP, nil
  20278. }
  20279. // ResetPublicIP resets all changes to the "public_ip" field.
  20280. func (m *ServerMutation) ResetPublicIP() {
  20281. m.public_ip = nil
  20282. }
  20283. // SetPrivateIP sets the "private_ip" field.
  20284. func (m *ServerMutation) SetPrivateIP(s string) {
  20285. m.private_ip = &s
  20286. }
  20287. // PrivateIP returns the value of the "private_ip" field in the mutation.
  20288. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  20289. v := m.private_ip
  20290. if v == nil {
  20291. return
  20292. }
  20293. return *v, true
  20294. }
  20295. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  20296. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20298. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  20299. if !m.op.Is(OpUpdateOne) {
  20300. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  20301. }
  20302. if m.id == nil || m.oldValue == nil {
  20303. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  20304. }
  20305. oldValue, err := m.oldValue(ctx)
  20306. if err != nil {
  20307. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  20308. }
  20309. return oldValue.PrivateIP, nil
  20310. }
  20311. // ResetPrivateIP resets all changes to the "private_ip" field.
  20312. func (m *ServerMutation) ResetPrivateIP() {
  20313. m.private_ip = nil
  20314. }
  20315. // SetAdminPort sets the "admin_port" field.
  20316. func (m *ServerMutation) SetAdminPort(s string) {
  20317. m.admin_port = &s
  20318. }
  20319. // AdminPort returns the value of the "admin_port" field in the mutation.
  20320. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  20321. v := m.admin_port
  20322. if v == nil {
  20323. return
  20324. }
  20325. return *v, true
  20326. }
  20327. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  20328. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20330. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  20331. if !m.op.Is(OpUpdateOne) {
  20332. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  20333. }
  20334. if m.id == nil || m.oldValue == nil {
  20335. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  20336. }
  20337. oldValue, err := m.oldValue(ctx)
  20338. if err != nil {
  20339. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  20340. }
  20341. return oldValue.AdminPort, nil
  20342. }
  20343. // ResetAdminPort resets all changes to the "admin_port" field.
  20344. func (m *ServerMutation) ResetAdminPort() {
  20345. m.admin_port = nil
  20346. }
  20347. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  20348. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  20349. if m.wxs == nil {
  20350. m.wxs = make(map[uint64]struct{})
  20351. }
  20352. for i := range ids {
  20353. m.wxs[ids[i]] = struct{}{}
  20354. }
  20355. }
  20356. // ClearWxs clears the "wxs" edge to the Wx entity.
  20357. func (m *ServerMutation) ClearWxs() {
  20358. m.clearedwxs = true
  20359. }
  20360. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  20361. func (m *ServerMutation) WxsCleared() bool {
  20362. return m.clearedwxs
  20363. }
  20364. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  20365. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  20366. if m.removedwxs == nil {
  20367. m.removedwxs = make(map[uint64]struct{})
  20368. }
  20369. for i := range ids {
  20370. delete(m.wxs, ids[i])
  20371. m.removedwxs[ids[i]] = struct{}{}
  20372. }
  20373. }
  20374. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  20375. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  20376. for id := range m.removedwxs {
  20377. ids = append(ids, id)
  20378. }
  20379. return
  20380. }
  20381. // WxsIDs returns the "wxs" edge IDs in the mutation.
  20382. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  20383. for id := range m.wxs {
  20384. ids = append(ids, id)
  20385. }
  20386. return
  20387. }
  20388. // ResetWxs resets all changes to the "wxs" edge.
  20389. func (m *ServerMutation) ResetWxs() {
  20390. m.wxs = nil
  20391. m.clearedwxs = false
  20392. m.removedwxs = nil
  20393. }
  20394. // Where appends a list predicates to the ServerMutation builder.
  20395. func (m *ServerMutation) Where(ps ...predicate.Server) {
  20396. m.predicates = append(m.predicates, ps...)
  20397. }
  20398. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  20399. // users can use type-assertion to append predicates that do not depend on any generated package.
  20400. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  20401. p := make([]predicate.Server, len(ps))
  20402. for i := range ps {
  20403. p[i] = ps[i]
  20404. }
  20405. m.Where(p...)
  20406. }
  20407. // Op returns the operation name.
  20408. func (m *ServerMutation) Op() Op {
  20409. return m.op
  20410. }
  20411. // SetOp allows setting the mutation operation.
  20412. func (m *ServerMutation) SetOp(op Op) {
  20413. m.op = op
  20414. }
  20415. // Type returns the node type of this mutation (Server).
  20416. func (m *ServerMutation) Type() string {
  20417. return m.typ
  20418. }
  20419. // Fields returns all fields that were changed during this mutation. Note that in
  20420. // order to get all numeric fields that were incremented/decremented, call
  20421. // AddedFields().
  20422. func (m *ServerMutation) Fields() []string {
  20423. fields := make([]string, 0, 8)
  20424. if m.created_at != nil {
  20425. fields = append(fields, server.FieldCreatedAt)
  20426. }
  20427. if m.updated_at != nil {
  20428. fields = append(fields, server.FieldUpdatedAt)
  20429. }
  20430. if m.status != nil {
  20431. fields = append(fields, server.FieldStatus)
  20432. }
  20433. if m.deleted_at != nil {
  20434. fields = append(fields, server.FieldDeletedAt)
  20435. }
  20436. if m.name != nil {
  20437. fields = append(fields, server.FieldName)
  20438. }
  20439. if m.public_ip != nil {
  20440. fields = append(fields, server.FieldPublicIP)
  20441. }
  20442. if m.private_ip != nil {
  20443. fields = append(fields, server.FieldPrivateIP)
  20444. }
  20445. if m.admin_port != nil {
  20446. fields = append(fields, server.FieldAdminPort)
  20447. }
  20448. return fields
  20449. }
  20450. // Field returns the value of a field with the given name. The second boolean
  20451. // return value indicates that this field was not set, or was not defined in the
  20452. // schema.
  20453. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  20454. switch name {
  20455. case server.FieldCreatedAt:
  20456. return m.CreatedAt()
  20457. case server.FieldUpdatedAt:
  20458. return m.UpdatedAt()
  20459. case server.FieldStatus:
  20460. return m.Status()
  20461. case server.FieldDeletedAt:
  20462. return m.DeletedAt()
  20463. case server.FieldName:
  20464. return m.Name()
  20465. case server.FieldPublicIP:
  20466. return m.PublicIP()
  20467. case server.FieldPrivateIP:
  20468. return m.PrivateIP()
  20469. case server.FieldAdminPort:
  20470. return m.AdminPort()
  20471. }
  20472. return nil, false
  20473. }
  20474. // OldField returns the old value of the field from the database. An error is
  20475. // returned if the mutation operation is not UpdateOne, or the query to the
  20476. // database failed.
  20477. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20478. switch name {
  20479. case server.FieldCreatedAt:
  20480. return m.OldCreatedAt(ctx)
  20481. case server.FieldUpdatedAt:
  20482. return m.OldUpdatedAt(ctx)
  20483. case server.FieldStatus:
  20484. return m.OldStatus(ctx)
  20485. case server.FieldDeletedAt:
  20486. return m.OldDeletedAt(ctx)
  20487. case server.FieldName:
  20488. return m.OldName(ctx)
  20489. case server.FieldPublicIP:
  20490. return m.OldPublicIP(ctx)
  20491. case server.FieldPrivateIP:
  20492. return m.OldPrivateIP(ctx)
  20493. case server.FieldAdminPort:
  20494. return m.OldAdminPort(ctx)
  20495. }
  20496. return nil, fmt.Errorf("unknown Server field %s", name)
  20497. }
  20498. // SetField sets the value of a field with the given name. It returns an error if
  20499. // the field is not defined in the schema, or if the type mismatched the field
  20500. // type.
  20501. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  20502. switch name {
  20503. case server.FieldCreatedAt:
  20504. v, ok := value.(time.Time)
  20505. if !ok {
  20506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20507. }
  20508. m.SetCreatedAt(v)
  20509. return nil
  20510. case server.FieldUpdatedAt:
  20511. v, ok := value.(time.Time)
  20512. if !ok {
  20513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20514. }
  20515. m.SetUpdatedAt(v)
  20516. return nil
  20517. case server.FieldStatus:
  20518. v, ok := value.(uint8)
  20519. if !ok {
  20520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20521. }
  20522. m.SetStatus(v)
  20523. return nil
  20524. case server.FieldDeletedAt:
  20525. v, ok := value.(time.Time)
  20526. if !ok {
  20527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20528. }
  20529. m.SetDeletedAt(v)
  20530. return nil
  20531. case server.FieldName:
  20532. v, ok := value.(string)
  20533. if !ok {
  20534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20535. }
  20536. m.SetName(v)
  20537. return nil
  20538. case server.FieldPublicIP:
  20539. v, ok := value.(string)
  20540. if !ok {
  20541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20542. }
  20543. m.SetPublicIP(v)
  20544. return nil
  20545. case server.FieldPrivateIP:
  20546. v, ok := value.(string)
  20547. if !ok {
  20548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20549. }
  20550. m.SetPrivateIP(v)
  20551. return nil
  20552. case server.FieldAdminPort:
  20553. v, ok := value.(string)
  20554. if !ok {
  20555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20556. }
  20557. m.SetAdminPort(v)
  20558. return nil
  20559. }
  20560. return fmt.Errorf("unknown Server field %s", name)
  20561. }
  20562. // AddedFields returns all numeric fields that were incremented/decremented during
  20563. // this mutation.
  20564. func (m *ServerMutation) AddedFields() []string {
  20565. var fields []string
  20566. if m.addstatus != nil {
  20567. fields = append(fields, server.FieldStatus)
  20568. }
  20569. return fields
  20570. }
  20571. // AddedField returns the numeric value that was incremented/decremented on a field
  20572. // with the given name. The second boolean return value indicates that this field
  20573. // was not set, or was not defined in the schema.
  20574. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  20575. switch name {
  20576. case server.FieldStatus:
  20577. return m.AddedStatus()
  20578. }
  20579. return nil, false
  20580. }
  20581. // AddField adds the value to the field with the given name. It returns an error if
  20582. // the field is not defined in the schema, or if the type mismatched the field
  20583. // type.
  20584. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  20585. switch name {
  20586. case server.FieldStatus:
  20587. v, ok := value.(int8)
  20588. if !ok {
  20589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20590. }
  20591. m.AddStatus(v)
  20592. return nil
  20593. }
  20594. return fmt.Errorf("unknown Server numeric field %s", name)
  20595. }
  20596. // ClearedFields returns all nullable fields that were cleared during this
  20597. // mutation.
  20598. func (m *ServerMutation) ClearedFields() []string {
  20599. var fields []string
  20600. if m.FieldCleared(server.FieldStatus) {
  20601. fields = append(fields, server.FieldStatus)
  20602. }
  20603. if m.FieldCleared(server.FieldDeletedAt) {
  20604. fields = append(fields, server.FieldDeletedAt)
  20605. }
  20606. return fields
  20607. }
  20608. // FieldCleared returns a boolean indicating if a field with the given name was
  20609. // cleared in this mutation.
  20610. func (m *ServerMutation) FieldCleared(name string) bool {
  20611. _, ok := m.clearedFields[name]
  20612. return ok
  20613. }
  20614. // ClearField clears the value of the field with the given name. It returns an
  20615. // error if the field is not defined in the schema.
  20616. func (m *ServerMutation) ClearField(name string) error {
  20617. switch name {
  20618. case server.FieldStatus:
  20619. m.ClearStatus()
  20620. return nil
  20621. case server.FieldDeletedAt:
  20622. m.ClearDeletedAt()
  20623. return nil
  20624. }
  20625. return fmt.Errorf("unknown Server nullable field %s", name)
  20626. }
  20627. // ResetField resets all changes in the mutation for the field with the given name.
  20628. // It returns an error if the field is not defined in the schema.
  20629. func (m *ServerMutation) ResetField(name string) error {
  20630. switch name {
  20631. case server.FieldCreatedAt:
  20632. m.ResetCreatedAt()
  20633. return nil
  20634. case server.FieldUpdatedAt:
  20635. m.ResetUpdatedAt()
  20636. return nil
  20637. case server.FieldStatus:
  20638. m.ResetStatus()
  20639. return nil
  20640. case server.FieldDeletedAt:
  20641. m.ResetDeletedAt()
  20642. return nil
  20643. case server.FieldName:
  20644. m.ResetName()
  20645. return nil
  20646. case server.FieldPublicIP:
  20647. m.ResetPublicIP()
  20648. return nil
  20649. case server.FieldPrivateIP:
  20650. m.ResetPrivateIP()
  20651. return nil
  20652. case server.FieldAdminPort:
  20653. m.ResetAdminPort()
  20654. return nil
  20655. }
  20656. return fmt.Errorf("unknown Server field %s", name)
  20657. }
  20658. // AddedEdges returns all edge names that were set/added in this mutation.
  20659. func (m *ServerMutation) AddedEdges() []string {
  20660. edges := make([]string, 0, 1)
  20661. if m.wxs != nil {
  20662. edges = append(edges, server.EdgeWxs)
  20663. }
  20664. return edges
  20665. }
  20666. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20667. // name in this mutation.
  20668. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  20669. switch name {
  20670. case server.EdgeWxs:
  20671. ids := make([]ent.Value, 0, len(m.wxs))
  20672. for id := range m.wxs {
  20673. ids = append(ids, id)
  20674. }
  20675. return ids
  20676. }
  20677. return nil
  20678. }
  20679. // RemovedEdges returns all edge names that were removed in this mutation.
  20680. func (m *ServerMutation) RemovedEdges() []string {
  20681. edges := make([]string, 0, 1)
  20682. if m.removedwxs != nil {
  20683. edges = append(edges, server.EdgeWxs)
  20684. }
  20685. return edges
  20686. }
  20687. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20688. // the given name in this mutation.
  20689. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  20690. switch name {
  20691. case server.EdgeWxs:
  20692. ids := make([]ent.Value, 0, len(m.removedwxs))
  20693. for id := range m.removedwxs {
  20694. ids = append(ids, id)
  20695. }
  20696. return ids
  20697. }
  20698. return nil
  20699. }
  20700. // ClearedEdges returns all edge names that were cleared in this mutation.
  20701. func (m *ServerMutation) ClearedEdges() []string {
  20702. edges := make([]string, 0, 1)
  20703. if m.clearedwxs {
  20704. edges = append(edges, server.EdgeWxs)
  20705. }
  20706. return edges
  20707. }
  20708. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20709. // was cleared in this mutation.
  20710. func (m *ServerMutation) EdgeCleared(name string) bool {
  20711. switch name {
  20712. case server.EdgeWxs:
  20713. return m.clearedwxs
  20714. }
  20715. return false
  20716. }
  20717. // ClearEdge clears the value of the edge with the given name. It returns an error
  20718. // if that edge is not defined in the schema.
  20719. func (m *ServerMutation) ClearEdge(name string) error {
  20720. switch name {
  20721. }
  20722. return fmt.Errorf("unknown Server unique edge %s", name)
  20723. }
  20724. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20725. // It returns an error if the edge is not defined in the schema.
  20726. func (m *ServerMutation) ResetEdge(name string) error {
  20727. switch name {
  20728. case server.EdgeWxs:
  20729. m.ResetWxs()
  20730. return nil
  20731. }
  20732. return fmt.Errorf("unknown Server edge %s", name)
  20733. }
  20734. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  20735. type SopNodeMutation struct {
  20736. config
  20737. op Op
  20738. typ string
  20739. id *uint64
  20740. created_at *time.Time
  20741. updated_at *time.Time
  20742. status *uint8
  20743. addstatus *int8
  20744. deleted_at *time.Time
  20745. parent_id *uint64
  20746. addparent_id *int64
  20747. name *string
  20748. condition_type *int
  20749. addcondition_type *int
  20750. condition_list *[]string
  20751. appendcondition_list []string
  20752. no_reply_condition *uint64
  20753. addno_reply_condition *int64
  20754. no_reply_unit *string
  20755. action_message *[]custom_types.Action
  20756. appendaction_message []custom_types.Action
  20757. action_label_add *[]uint64
  20758. appendaction_label_add []uint64
  20759. action_label_del *[]uint64
  20760. appendaction_label_del []uint64
  20761. action_forward **custom_types.ActionForward
  20762. clearedFields map[string]struct{}
  20763. sop_stage *uint64
  20764. clearedsop_stage bool
  20765. node_messages map[uint64]struct{}
  20766. removednode_messages map[uint64]struct{}
  20767. clearednode_messages bool
  20768. done bool
  20769. oldValue func(context.Context) (*SopNode, error)
  20770. predicates []predicate.SopNode
  20771. }
  20772. var _ ent.Mutation = (*SopNodeMutation)(nil)
  20773. // sopnodeOption allows management of the mutation configuration using functional options.
  20774. type sopnodeOption func(*SopNodeMutation)
  20775. // newSopNodeMutation creates new mutation for the SopNode entity.
  20776. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  20777. m := &SopNodeMutation{
  20778. config: c,
  20779. op: op,
  20780. typ: TypeSopNode,
  20781. clearedFields: make(map[string]struct{}),
  20782. }
  20783. for _, opt := range opts {
  20784. opt(m)
  20785. }
  20786. return m
  20787. }
  20788. // withSopNodeID sets the ID field of the mutation.
  20789. func withSopNodeID(id uint64) sopnodeOption {
  20790. return func(m *SopNodeMutation) {
  20791. var (
  20792. err error
  20793. once sync.Once
  20794. value *SopNode
  20795. )
  20796. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  20797. once.Do(func() {
  20798. if m.done {
  20799. err = errors.New("querying old values post mutation is not allowed")
  20800. } else {
  20801. value, err = m.Client().SopNode.Get(ctx, id)
  20802. }
  20803. })
  20804. return value, err
  20805. }
  20806. m.id = &id
  20807. }
  20808. }
  20809. // withSopNode sets the old SopNode of the mutation.
  20810. func withSopNode(node *SopNode) sopnodeOption {
  20811. return func(m *SopNodeMutation) {
  20812. m.oldValue = func(context.Context) (*SopNode, error) {
  20813. return node, nil
  20814. }
  20815. m.id = &node.ID
  20816. }
  20817. }
  20818. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20819. // executed in a transaction (ent.Tx), a transactional client is returned.
  20820. func (m SopNodeMutation) Client() *Client {
  20821. client := &Client{config: m.config}
  20822. client.init()
  20823. return client
  20824. }
  20825. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20826. // it returns an error otherwise.
  20827. func (m SopNodeMutation) Tx() (*Tx, error) {
  20828. if _, ok := m.driver.(*txDriver); !ok {
  20829. return nil, errors.New("ent: mutation is not running in a transaction")
  20830. }
  20831. tx := &Tx{config: m.config}
  20832. tx.init()
  20833. return tx, nil
  20834. }
  20835. // SetID sets the value of the id field. Note that this
  20836. // operation is only accepted on creation of SopNode entities.
  20837. func (m *SopNodeMutation) SetID(id uint64) {
  20838. m.id = &id
  20839. }
  20840. // ID returns the ID value in the mutation. Note that the ID is only available
  20841. // if it was provided to the builder or after it was returned from the database.
  20842. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  20843. if m.id == nil {
  20844. return
  20845. }
  20846. return *m.id, true
  20847. }
  20848. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20849. // That means, if the mutation is applied within a transaction with an isolation level such
  20850. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20851. // or updated by the mutation.
  20852. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20853. switch {
  20854. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20855. id, exists := m.ID()
  20856. if exists {
  20857. return []uint64{id}, nil
  20858. }
  20859. fallthrough
  20860. case m.op.Is(OpUpdate | OpDelete):
  20861. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  20862. default:
  20863. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20864. }
  20865. }
  20866. // SetCreatedAt sets the "created_at" field.
  20867. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  20868. m.created_at = &t
  20869. }
  20870. // CreatedAt returns the value of the "created_at" field in the mutation.
  20871. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  20872. v := m.created_at
  20873. if v == nil {
  20874. return
  20875. }
  20876. return *v, true
  20877. }
  20878. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  20879. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20881. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20882. if !m.op.Is(OpUpdateOne) {
  20883. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20884. }
  20885. if m.id == nil || m.oldValue == nil {
  20886. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20887. }
  20888. oldValue, err := m.oldValue(ctx)
  20889. if err != nil {
  20890. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20891. }
  20892. return oldValue.CreatedAt, nil
  20893. }
  20894. // ResetCreatedAt resets all changes to the "created_at" field.
  20895. func (m *SopNodeMutation) ResetCreatedAt() {
  20896. m.created_at = nil
  20897. }
  20898. // SetUpdatedAt sets the "updated_at" field.
  20899. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  20900. m.updated_at = &t
  20901. }
  20902. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20903. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  20904. v := m.updated_at
  20905. if v == nil {
  20906. return
  20907. }
  20908. return *v, true
  20909. }
  20910. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  20911. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20913. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20914. if !m.op.Is(OpUpdateOne) {
  20915. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20916. }
  20917. if m.id == nil || m.oldValue == nil {
  20918. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20919. }
  20920. oldValue, err := m.oldValue(ctx)
  20921. if err != nil {
  20922. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20923. }
  20924. return oldValue.UpdatedAt, nil
  20925. }
  20926. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20927. func (m *SopNodeMutation) ResetUpdatedAt() {
  20928. m.updated_at = nil
  20929. }
  20930. // SetStatus sets the "status" field.
  20931. func (m *SopNodeMutation) SetStatus(u uint8) {
  20932. m.status = &u
  20933. m.addstatus = nil
  20934. }
  20935. // Status returns the value of the "status" field in the mutation.
  20936. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  20937. v := m.status
  20938. if v == nil {
  20939. return
  20940. }
  20941. return *v, true
  20942. }
  20943. // OldStatus returns the old "status" field's value of the SopNode entity.
  20944. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20946. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20947. if !m.op.Is(OpUpdateOne) {
  20948. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20949. }
  20950. if m.id == nil || m.oldValue == nil {
  20951. return v, errors.New("OldStatus requires an ID field in the mutation")
  20952. }
  20953. oldValue, err := m.oldValue(ctx)
  20954. if err != nil {
  20955. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20956. }
  20957. return oldValue.Status, nil
  20958. }
  20959. // AddStatus adds u to the "status" field.
  20960. func (m *SopNodeMutation) AddStatus(u int8) {
  20961. if m.addstatus != nil {
  20962. *m.addstatus += u
  20963. } else {
  20964. m.addstatus = &u
  20965. }
  20966. }
  20967. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20968. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  20969. v := m.addstatus
  20970. if v == nil {
  20971. return
  20972. }
  20973. return *v, true
  20974. }
  20975. // ClearStatus clears the value of the "status" field.
  20976. func (m *SopNodeMutation) ClearStatus() {
  20977. m.status = nil
  20978. m.addstatus = nil
  20979. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  20980. }
  20981. // StatusCleared returns if the "status" field was cleared in this mutation.
  20982. func (m *SopNodeMutation) StatusCleared() bool {
  20983. _, ok := m.clearedFields[sopnode.FieldStatus]
  20984. return ok
  20985. }
  20986. // ResetStatus resets all changes to the "status" field.
  20987. func (m *SopNodeMutation) ResetStatus() {
  20988. m.status = nil
  20989. m.addstatus = nil
  20990. delete(m.clearedFields, sopnode.FieldStatus)
  20991. }
  20992. // SetDeletedAt sets the "deleted_at" field.
  20993. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  20994. m.deleted_at = &t
  20995. }
  20996. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20997. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  20998. v := m.deleted_at
  20999. if v == nil {
  21000. return
  21001. }
  21002. return *v, true
  21003. }
  21004. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  21005. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21007. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21008. if !m.op.Is(OpUpdateOne) {
  21009. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21010. }
  21011. if m.id == nil || m.oldValue == nil {
  21012. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21013. }
  21014. oldValue, err := m.oldValue(ctx)
  21015. if err != nil {
  21016. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21017. }
  21018. return oldValue.DeletedAt, nil
  21019. }
  21020. // ClearDeletedAt clears the value of the "deleted_at" field.
  21021. func (m *SopNodeMutation) ClearDeletedAt() {
  21022. m.deleted_at = nil
  21023. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  21024. }
  21025. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21026. func (m *SopNodeMutation) DeletedAtCleared() bool {
  21027. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  21028. return ok
  21029. }
  21030. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21031. func (m *SopNodeMutation) ResetDeletedAt() {
  21032. m.deleted_at = nil
  21033. delete(m.clearedFields, sopnode.FieldDeletedAt)
  21034. }
  21035. // SetStageID sets the "stage_id" field.
  21036. func (m *SopNodeMutation) SetStageID(u uint64) {
  21037. m.sop_stage = &u
  21038. }
  21039. // StageID returns the value of the "stage_id" field in the mutation.
  21040. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  21041. v := m.sop_stage
  21042. if v == nil {
  21043. return
  21044. }
  21045. return *v, true
  21046. }
  21047. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  21048. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21050. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  21051. if !m.op.Is(OpUpdateOne) {
  21052. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  21053. }
  21054. if m.id == nil || m.oldValue == nil {
  21055. return v, errors.New("OldStageID requires an ID field in the mutation")
  21056. }
  21057. oldValue, err := m.oldValue(ctx)
  21058. if err != nil {
  21059. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  21060. }
  21061. return oldValue.StageID, nil
  21062. }
  21063. // ResetStageID resets all changes to the "stage_id" field.
  21064. func (m *SopNodeMutation) ResetStageID() {
  21065. m.sop_stage = nil
  21066. }
  21067. // SetParentID sets the "parent_id" field.
  21068. func (m *SopNodeMutation) SetParentID(u uint64) {
  21069. m.parent_id = &u
  21070. m.addparent_id = nil
  21071. }
  21072. // ParentID returns the value of the "parent_id" field in the mutation.
  21073. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  21074. v := m.parent_id
  21075. if v == nil {
  21076. return
  21077. }
  21078. return *v, true
  21079. }
  21080. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  21081. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21083. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  21084. if !m.op.Is(OpUpdateOne) {
  21085. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  21086. }
  21087. if m.id == nil || m.oldValue == nil {
  21088. return v, errors.New("OldParentID requires an ID field in the mutation")
  21089. }
  21090. oldValue, err := m.oldValue(ctx)
  21091. if err != nil {
  21092. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  21093. }
  21094. return oldValue.ParentID, nil
  21095. }
  21096. // AddParentID adds u to the "parent_id" field.
  21097. func (m *SopNodeMutation) AddParentID(u int64) {
  21098. if m.addparent_id != nil {
  21099. *m.addparent_id += u
  21100. } else {
  21101. m.addparent_id = &u
  21102. }
  21103. }
  21104. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  21105. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  21106. v := m.addparent_id
  21107. if v == nil {
  21108. return
  21109. }
  21110. return *v, true
  21111. }
  21112. // ResetParentID resets all changes to the "parent_id" field.
  21113. func (m *SopNodeMutation) ResetParentID() {
  21114. m.parent_id = nil
  21115. m.addparent_id = nil
  21116. }
  21117. // SetName sets the "name" field.
  21118. func (m *SopNodeMutation) SetName(s string) {
  21119. m.name = &s
  21120. }
  21121. // Name returns the value of the "name" field in the mutation.
  21122. func (m *SopNodeMutation) Name() (r string, exists bool) {
  21123. v := m.name
  21124. if v == nil {
  21125. return
  21126. }
  21127. return *v, true
  21128. }
  21129. // OldName returns the old "name" field's value of the SopNode entity.
  21130. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21132. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  21133. if !m.op.Is(OpUpdateOne) {
  21134. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21135. }
  21136. if m.id == nil || m.oldValue == nil {
  21137. return v, errors.New("OldName requires an ID field in the mutation")
  21138. }
  21139. oldValue, err := m.oldValue(ctx)
  21140. if err != nil {
  21141. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21142. }
  21143. return oldValue.Name, nil
  21144. }
  21145. // ResetName resets all changes to the "name" field.
  21146. func (m *SopNodeMutation) ResetName() {
  21147. m.name = nil
  21148. }
  21149. // SetConditionType sets the "condition_type" field.
  21150. func (m *SopNodeMutation) SetConditionType(i int) {
  21151. m.condition_type = &i
  21152. m.addcondition_type = nil
  21153. }
  21154. // ConditionType returns the value of the "condition_type" field in the mutation.
  21155. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  21156. v := m.condition_type
  21157. if v == nil {
  21158. return
  21159. }
  21160. return *v, true
  21161. }
  21162. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  21163. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21165. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  21166. if !m.op.Is(OpUpdateOne) {
  21167. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  21168. }
  21169. if m.id == nil || m.oldValue == nil {
  21170. return v, errors.New("OldConditionType requires an ID field in the mutation")
  21171. }
  21172. oldValue, err := m.oldValue(ctx)
  21173. if err != nil {
  21174. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  21175. }
  21176. return oldValue.ConditionType, nil
  21177. }
  21178. // AddConditionType adds i to the "condition_type" field.
  21179. func (m *SopNodeMutation) AddConditionType(i int) {
  21180. if m.addcondition_type != nil {
  21181. *m.addcondition_type += i
  21182. } else {
  21183. m.addcondition_type = &i
  21184. }
  21185. }
  21186. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  21187. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  21188. v := m.addcondition_type
  21189. if v == nil {
  21190. return
  21191. }
  21192. return *v, true
  21193. }
  21194. // ResetConditionType resets all changes to the "condition_type" field.
  21195. func (m *SopNodeMutation) ResetConditionType() {
  21196. m.condition_type = nil
  21197. m.addcondition_type = nil
  21198. }
  21199. // SetConditionList sets the "condition_list" field.
  21200. func (m *SopNodeMutation) SetConditionList(s []string) {
  21201. m.condition_list = &s
  21202. m.appendcondition_list = nil
  21203. }
  21204. // ConditionList returns the value of the "condition_list" field in the mutation.
  21205. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  21206. v := m.condition_list
  21207. if v == nil {
  21208. return
  21209. }
  21210. return *v, true
  21211. }
  21212. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  21213. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21215. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  21216. if !m.op.Is(OpUpdateOne) {
  21217. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  21218. }
  21219. if m.id == nil || m.oldValue == nil {
  21220. return v, errors.New("OldConditionList requires an ID field in the mutation")
  21221. }
  21222. oldValue, err := m.oldValue(ctx)
  21223. if err != nil {
  21224. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  21225. }
  21226. return oldValue.ConditionList, nil
  21227. }
  21228. // AppendConditionList adds s to the "condition_list" field.
  21229. func (m *SopNodeMutation) AppendConditionList(s []string) {
  21230. m.appendcondition_list = append(m.appendcondition_list, s...)
  21231. }
  21232. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  21233. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  21234. if len(m.appendcondition_list) == 0 {
  21235. return nil, false
  21236. }
  21237. return m.appendcondition_list, true
  21238. }
  21239. // ClearConditionList clears the value of the "condition_list" field.
  21240. func (m *SopNodeMutation) ClearConditionList() {
  21241. m.condition_list = nil
  21242. m.appendcondition_list = nil
  21243. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  21244. }
  21245. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  21246. func (m *SopNodeMutation) ConditionListCleared() bool {
  21247. _, ok := m.clearedFields[sopnode.FieldConditionList]
  21248. return ok
  21249. }
  21250. // ResetConditionList resets all changes to the "condition_list" field.
  21251. func (m *SopNodeMutation) ResetConditionList() {
  21252. m.condition_list = nil
  21253. m.appendcondition_list = nil
  21254. delete(m.clearedFields, sopnode.FieldConditionList)
  21255. }
  21256. // SetNoReplyCondition sets the "no_reply_condition" field.
  21257. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  21258. m.no_reply_condition = &u
  21259. m.addno_reply_condition = nil
  21260. }
  21261. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  21262. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  21263. v := m.no_reply_condition
  21264. if v == nil {
  21265. return
  21266. }
  21267. return *v, true
  21268. }
  21269. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  21270. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21272. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  21273. if !m.op.Is(OpUpdateOne) {
  21274. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  21275. }
  21276. if m.id == nil || m.oldValue == nil {
  21277. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  21278. }
  21279. oldValue, err := m.oldValue(ctx)
  21280. if err != nil {
  21281. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  21282. }
  21283. return oldValue.NoReplyCondition, nil
  21284. }
  21285. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  21286. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  21287. if m.addno_reply_condition != nil {
  21288. *m.addno_reply_condition += u
  21289. } else {
  21290. m.addno_reply_condition = &u
  21291. }
  21292. }
  21293. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  21294. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  21295. v := m.addno_reply_condition
  21296. if v == nil {
  21297. return
  21298. }
  21299. return *v, true
  21300. }
  21301. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  21302. func (m *SopNodeMutation) ResetNoReplyCondition() {
  21303. m.no_reply_condition = nil
  21304. m.addno_reply_condition = nil
  21305. }
  21306. // SetNoReplyUnit sets the "no_reply_unit" field.
  21307. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  21308. m.no_reply_unit = &s
  21309. }
  21310. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  21311. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  21312. v := m.no_reply_unit
  21313. if v == nil {
  21314. return
  21315. }
  21316. return *v, true
  21317. }
  21318. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  21319. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21321. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  21322. if !m.op.Is(OpUpdateOne) {
  21323. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  21324. }
  21325. if m.id == nil || m.oldValue == nil {
  21326. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  21327. }
  21328. oldValue, err := m.oldValue(ctx)
  21329. if err != nil {
  21330. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  21331. }
  21332. return oldValue.NoReplyUnit, nil
  21333. }
  21334. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  21335. func (m *SopNodeMutation) ResetNoReplyUnit() {
  21336. m.no_reply_unit = nil
  21337. }
  21338. // SetActionMessage sets the "action_message" field.
  21339. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  21340. m.action_message = &ct
  21341. m.appendaction_message = nil
  21342. }
  21343. // ActionMessage returns the value of the "action_message" field in the mutation.
  21344. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  21345. v := m.action_message
  21346. if v == nil {
  21347. return
  21348. }
  21349. return *v, true
  21350. }
  21351. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  21352. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21354. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  21355. if !m.op.Is(OpUpdateOne) {
  21356. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  21357. }
  21358. if m.id == nil || m.oldValue == nil {
  21359. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  21360. }
  21361. oldValue, err := m.oldValue(ctx)
  21362. if err != nil {
  21363. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  21364. }
  21365. return oldValue.ActionMessage, nil
  21366. }
  21367. // AppendActionMessage adds ct to the "action_message" field.
  21368. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  21369. m.appendaction_message = append(m.appendaction_message, ct...)
  21370. }
  21371. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  21372. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  21373. if len(m.appendaction_message) == 0 {
  21374. return nil, false
  21375. }
  21376. return m.appendaction_message, true
  21377. }
  21378. // ClearActionMessage clears the value of the "action_message" field.
  21379. func (m *SopNodeMutation) ClearActionMessage() {
  21380. m.action_message = nil
  21381. m.appendaction_message = nil
  21382. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  21383. }
  21384. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  21385. func (m *SopNodeMutation) ActionMessageCleared() bool {
  21386. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  21387. return ok
  21388. }
  21389. // ResetActionMessage resets all changes to the "action_message" field.
  21390. func (m *SopNodeMutation) ResetActionMessage() {
  21391. m.action_message = nil
  21392. m.appendaction_message = nil
  21393. delete(m.clearedFields, sopnode.FieldActionMessage)
  21394. }
  21395. // SetActionLabelAdd sets the "action_label_add" field.
  21396. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  21397. m.action_label_add = &u
  21398. m.appendaction_label_add = nil
  21399. }
  21400. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21401. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21402. v := m.action_label_add
  21403. if v == nil {
  21404. return
  21405. }
  21406. return *v, true
  21407. }
  21408. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  21409. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21411. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21412. if !m.op.Is(OpUpdateOne) {
  21413. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21414. }
  21415. if m.id == nil || m.oldValue == nil {
  21416. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21417. }
  21418. oldValue, err := m.oldValue(ctx)
  21419. if err != nil {
  21420. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21421. }
  21422. return oldValue.ActionLabelAdd, nil
  21423. }
  21424. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21425. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  21426. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21427. }
  21428. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21429. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21430. if len(m.appendaction_label_add) == 0 {
  21431. return nil, false
  21432. }
  21433. return m.appendaction_label_add, true
  21434. }
  21435. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21436. func (m *SopNodeMutation) ClearActionLabelAdd() {
  21437. m.action_label_add = nil
  21438. m.appendaction_label_add = nil
  21439. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  21440. }
  21441. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21442. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  21443. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  21444. return ok
  21445. }
  21446. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21447. func (m *SopNodeMutation) ResetActionLabelAdd() {
  21448. m.action_label_add = nil
  21449. m.appendaction_label_add = nil
  21450. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  21451. }
  21452. // SetActionLabelDel sets the "action_label_del" field.
  21453. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  21454. m.action_label_del = &u
  21455. m.appendaction_label_del = nil
  21456. }
  21457. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21458. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  21459. v := m.action_label_del
  21460. if v == nil {
  21461. return
  21462. }
  21463. return *v, true
  21464. }
  21465. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  21466. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21468. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21469. if !m.op.Is(OpUpdateOne) {
  21470. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21471. }
  21472. if m.id == nil || m.oldValue == nil {
  21473. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21474. }
  21475. oldValue, err := m.oldValue(ctx)
  21476. if err != nil {
  21477. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21478. }
  21479. return oldValue.ActionLabelDel, nil
  21480. }
  21481. // AppendActionLabelDel adds u to the "action_label_del" field.
  21482. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  21483. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21484. }
  21485. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21486. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21487. if len(m.appendaction_label_del) == 0 {
  21488. return nil, false
  21489. }
  21490. return m.appendaction_label_del, true
  21491. }
  21492. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21493. func (m *SopNodeMutation) ClearActionLabelDel() {
  21494. m.action_label_del = nil
  21495. m.appendaction_label_del = nil
  21496. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  21497. }
  21498. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21499. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  21500. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  21501. return ok
  21502. }
  21503. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21504. func (m *SopNodeMutation) ResetActionLabelDel() {
  21505. m.action_label_del = nil
  21506. m.appendaction_label_del = nil
  21507. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  21508. }
  21509. // SetActionForward sets the "action_forward" field.
  21510. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  21511. m.action_forward = &ctf
  21512. }
  21513. // ActionForward returns the value of the "action_forward" field in the mutation.
  21514. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  21515. v := m.action_forward
  21516. if v == nil {
  21517. return
  21518. }
  21519. return *v, true
  21520. }
  21521. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  21522. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21524. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  21525. if !m.op.Is(OpUpdateOne) {
  21526. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  21527. }
  21528. if m.id == nil || m.oldValue == nil {
  21529. return v, errors.New("OldActionForward requires an ID field in the mutation")
  21530. }
  21531. oldValue, err := m.oldValue(ctx)
  21532. if err != nil {
  21533. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  21534. }
  21535. return oldValue.ActionForward, nil
  21536. }
  21537. // ClearActionForward clears the value of the "action_forward" field.
  21538. func (m *SopNodeMutation) ClearActionForward() {
  21539. m.action_forward = nil
  21540. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  21541. }
  21542. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  21543. func (m *SopNodeMutation) ActionForwardCleared() bool {
  21544. _, ok := m.clearedFields[sopnode.FieldActionForward]
  21545. return ok
  21546. }
  21547. // ResetActionForward resets all changes to the "action_forward" field.
  21548. func (m *SopNodeMutation) ResetActionForward() {
  21549. m.action_forward = nil
  21550. delete(m.clearedFields, sopnode.FieldActionForward)
  21551. }
  21552. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21553. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  21554. m.sop_stage = &id
  21555. }
  21556. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21557. func (m *SopNodeMutation) ClearSopStage() {
  21558. m.clearedsop_stage = true
  21559. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  21560. }
  21561. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21562. func (m *SopNodeMutation) SopStageCleared() bool {
  21563. return m.clearedsop_stage
  21564. }
  21565. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21566. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  21567. if m.sop_stage != nil {
  21568. return *m.sop_stage, true
  21569. }
  21570. return
  21571. }
  21572. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21573. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21574. // SopStageID instead. It exists only for internal usage by the builders.
  21575. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  21576. if id := m.sop_stage; id != nil {
  21577. ids = append(ids, *id)
  21578. }
  21579. return
  21580. }
  21581. // ResetSopStage resets all changes to the "sop_stage" edge.
  21582. func (m *SopNodeMutation) ResetSopStage() {
  21583. m.sop_stage = nil
  21584. m.clearedsop_stage = false
  21585. }
  21586. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  21587. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  21588. if m.node_messages == nil {
  21589. m.node_messages = make(map[uint64]struct{})
  21590. }
  21591. for i := range ids {
  21592. m.node_messages[ids[i]] = struct{}{}
  21593. }
  21594. }
  21595. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  21596. func (m *SopNodeMutation) ClearNodeMessages() {
  21597. m.clearednode_messages = true
  21598. }
  21599. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  21600. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  21601. return m.clearednode_messages
  21602. }
  21603. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  21604. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  21605. if m.removednode_messages == nil {
  21606. m.removednode_messages = make(map[uint64]struct{})
  21607. }
  21608. for i := range ids {
  21609. delete(m.node_messages, ids[i])
  21610. m.removednode_messages[ids[i]] = struct{}{}
  21611. }
  21612. }
  21613. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  21614. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  21615. for id := range m.removednode_messages {
  21616. ids = append(ids, id)
  21617. }
  21618. return
  21619. }
  21620. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  21621. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  21622. for id := range m.node_messages {
  21623. ids = append(ids, id)
  21624. }
  21625. return
  21626. }
  21627. // ResetNodeMessages resets all changes to the "node_messages" edge.
  21628. func (m *SopNodeMutation) ResetNodeMessages() {
  21629. m.node_messages = nil
  21630. m.clearednode_messages = false
  21631. m.removednode_messages = nil
  21632. }
  21633. // Where appends a list predicates to the SopNodeMutation builder.
  21634. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  21635. m.predicates = append(m.predicates, ps...)
  21636. }
  21637. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  21638. // users can use type-assertion to append predicates that do not depend on any generated package.
  21639. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  21640. p := make([]predicate.SopNode, len(ps))
  21641. for i := range ps {
  21642. p[i] = ps[i]
  21643. }
  21644. m.Where(p...)
  21645. }
  21646. // Op returns the operation name.
  21647. func (m *SopNodeMutation) Op() Op {
  21648. return m.op
  21649. }
  21650. // SetOp allows setting the mutation operation.
  21651. func (m *SopNodeMutation) SetOp(op Op) {
  21652. m.op = op
  21653. }
  21654. // Type returns the node type of this mutation (SopNode).
  21655. func (m *SopNodeMutation) Type() string {
  21656. return m.typ
  21657. }
  21658. // Fields returns all fields that were changed during this mutation. Note that in
  21659. // order to get all numeric fields that were incremented/decremented, call
  21660. // AddedFields().
  21661. func (m *SopNodeMutation) Fields() []string {
  21662. fields := make([]string, 0, 15)
  21663. if m.created_at != nil {
  21664. fields = append(fields, sopnode.FieldCreatedAt)
  21665. }
  21666. if m.updated_at != nil {
  21667. fields = append(fields, sopnode.FieldUpdatedAt)
  21668. }
  21669. if m.status != nil {
  21670. fields = append(fields, sopnode.FieldStatus)
  21671. }
  21672. if m.deleted_at != nil {
  21673. fields = append(fields, sopnode.FieldDeletedAt)
  21674. }
  21675. if m.sop_stage != nil {
  21676. fields = append(fields, sopnode.FieldStageID)
  21677. }
  21678. if m.parent_id != nil {
  21679. fields = append(fields, sopnode.FieldParentID)
  21680. }
  21681. if m.name != nil {
  21682. fields = append(fields, sopnode.FieldName)
  21683. }
  21684. if m.condition_type != nil {
  21685. fields = append(fields, sopnode.FieldConditionType)
  21686. }
  21687. if m.condition_list != nil {
  21688. fields = append(fields, sopnode.FieldConditionList)
  21689. }
  21690. if m.no_reply_condition != nil {
  21691. fields = append(fields, sopnode.FieldNoReplyCondition)
  21692. }
  21693. if m.no_reply_unit != nil {
  21694. fields = append(fields, sopnode.FieldNoReplyUnit)
  21695. }
  21696. if m.action_message != nil {
  21697. fields = append(fields, sopnode.FieldActionMessage)
  21698. }
  21699. if m.action_label_add != nil {
  21700. fields = append(fields, sopnode.FieldActionLabelAdd)
  21701. }
  21702. if m.action_label_del != nil {
  21703. fields = append(fields, sopnode.FieldActionLabelDel)
  21704. }
  21705. if m.action_forward != nil {
  21706. fields = append(fields, sopnode.FieldActionForward)
  21707. }
  21708. return fields
  21709. }
  21710. // Field returns the value of a field with the given name. The second boolean
  21711. // return value indicates that this field was not set, or was not defined in the
  21712. // schema.
  21713. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  21714. switch name {
  21715. case sopnode.FieldCreatedAt:
  21716. return m.CreatedAt()
  21717. case sopnode.FieldUpdatedAt:
  21718. return m.UpdatedAt()
  21719. case sopnode.FieldStatus:
  21720. return m.Status()
  21721. case sopnode.FieldDeletedAt:
  21722. return m.DeletedAt()
  21723. case sopnode.FieldStageID:
  21724. return m.StageID()
  21725. case sopnode.FieldParentID:
  21726. return m.ParentID()
  21727. case sopnode.FieldName:
  21728. return m.Name()
  21729. case sopnode.FieldConditionType:
  21730. return m.ConditionType()
  21731. case sopnode.FieldConditionList:
  21732. return m.ConditionList()
  21733. case sopnode.FieldNoReplyCondition:
  21734. return m.NoReplyCondition()
  21735. case sopnode.FieldNoReplyUnit:
  21736. return m.NoReplyUnit()
  21737. case sopnode.FieldActionMessage:
  21738. return m.ActionMessage()
  21739. case sopnode.FieldActionLabelAdd:
  21740. return m.ActionLabelAdd()
  21741. case sopnode.FieldActionLabelDel:
  21742. return m.ActionLabelDel()
  21743. case sopnode.FieldActionForward:
  21744. return m.ActionForward()
  21745. }
  21746. return nil, false
  21747. }
  21748. // OldField returns the old value of the field from the database. An error is
  21749. // returned if the mutation operation is not UpdateOne, or the query to the
  21750. // database failed.
  21751. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21752. switch name {
  21753. case sopnode.FieldCreatedAt:
  21754. return m.OldCreatedAt(ctx)
  21755. case sopnode.FieldUpdatedAt:
  21756. return m.OldUpdatedAt(ctx)
  21757. case sopnode.FieldStatus:
  21758. return m.OldStatus(ctx)
  21759. case sopnode.FieldDeletedAt:
  21760. return m.OldDeletedAt(ctx)
  21761. case sopnode.FieldStageID:
  21762. return m.OldStageID(ctx)
  21763. case sopnode.FieldParentID:
  21764. return m.OldParentID(ctx)
  21765. case sopnode.FieldName:
  21766. return m.OldName(ctx)
  21767. case sopnode.FieldConditionType:
  21768. return m.OldConditionType(ctx)
  21769. case sopnode.FieldConditionList:
  21770. return m.OldConditionList(ctx)
  21771. case sopnode.FieldNoReplyCondition:
  21772. return m.OldNoReplyCondition(ctx)
  21773. case sopnode.FieldNoReplyUnit:
  21774. return m.OldNoReplyUnit(ctx)
  21775. case sopnode.FieldActionMessage:
  21776. return m.OldActionMessage(ctx)
  21777. case sopnode.FieldActionLabelAdd:
  21778. return m.OldActionLabelAdd(ctx)
  21779. case sopnode.FieldActionLabelDel:
  21780. return m.OldActionLabelDel(ctx)
  21781. case sopnode.FieldActionForward:
  21782. return m.OldActionForward(ctx)
  21783. }
  21784. return nil, fmt.Errorf("unknown SopNode field %s", name)
  21785. }
  21786. // SetField sets the value of a field with the given name. It returns an error if
  21787. // the field is not defined in the schema, or if the type mismatched the field
  21788. // type.
  21789. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  21790. switch name {
  21791. case sopnode.FieldCreatedAt:
  21792. v, ok := value.(time.Time)
  21793. if !ok {
  21794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21795. }
  21796. m.SetCreatedAt(v)
  21797. return nil
  21798. case sopnode.FieldUpdatedAt:
  21799. v, ok := value.(time.Time)
  21800. if !ok {
  21801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21802. }
  21803. m.SetUpdatedAt(v)
  21804. return nil
  21805. case sopnode.FieldStatus:
  21806. v, ok := value.(uint8)
  21807. if !ok {
  21808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21809. }
  21810. m.SetStatus(v)
  21811. return nil
  21812. case sopnode.FieldDeletedAt:
  21813. v, ok := value.(time.Time)
  21814. if !ok {
  21815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21816. }
  21817. m.SetDeletedAt(v)
  21818. return nil
  21819. case sopnode.FieldStageID:
  21820. v, ok := value.(uint64)
  21821. if !ok {
  21822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21823. }
  21824. m.SetStageID(v)
  21825. return nil
  21826. case sopnode.FieldParentID:
  21827. v, ok := value.(uint64)
  21828. if !ok {
  21829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21830. }
  21831. m.SetParentID(v)
  21832. return nil
  21833. case sopnode.FieldName:
  21834. v, ok := value.(string)
  21835. if !ok {
  21836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21837. }
  21838. m.SetName(v)
  21839. return nil
  21840. case sopnode.FieldConditionType:
  21841. v, ok := value.(int)
  21842. if !ok {
  21843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21844. }
  21845. m.SetConditionType(v)
  21846. return nil
  21847. case sopnode.FieldConditionList:
  21848. v, ok := value.([]string)
  21849. if !ok {
  21850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21851. }
  21852. m.SetConditionList(v)
  21853. return nil
  21854. case sopnode.FieldNoReplyCondition:
  21855. v, ok := value.(uint64)
  21856. if !ok {
  21857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21858. }
  21859. m.SetNoReplyCondition(v)
  21860. return nil
  21861. case sopnode.FieldNoReplyUnit:
  21862. v, ok := value.(string)
  21863. if !ok {
  21864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21865. }
  21866. m.SetNoReplyUnit(v)
  21867. return nil
  21868. case sopnode.FieldActionMessage:
  21869. v, ok := value.([]custom_types.Action)
  21870. if !ok {
  21871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21872. }
  21873. m.SetActionMessage(v)
  21874. return nil
  21875. case sopnode.FieldActionLabelAdd:
  21876. v, ok := value.([]uint64)
  21877. if !ok {
  21878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21879. }
  21880. m.SetActionLabelAdd(v)
  21881. return nil
  21882. case sopnode.FieldActionLabelDel:
  21883. v, ok := value.([]uint64)
  21884. if !ok {
  21885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21886. }
  21887. m.SetActionLabelDel(v)
  21888. return nil
  21889. case sopnode.FieldActionForward:
  21890. v, ok := value.(*custom_types.ActionForward)
  21891. if !ok {
  21892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21893. }
  21894. m.SetActionForward(v)
  21895. return nil
  21896. }
  21897. return fmt.Errorf("unknown SopNode field %s", name)
  21898. }
  21899. // AddedFields returns all numeric fields that were incremented/decremented during
  21900. // this mutation.
  21901. func (m *SopNodeMutation) AddedFields() []string {
  21902. var fields []string
  21903. if m.addstatus != nil {
  21904. fields = append(fields, sopnode.FieldStatus)
  21905. }
  21906. if m.addparent_id != nil {
  21907. fields = append(fields, sopnode.FieldParentID)
  21908. }
  21909. if m.addcondition_type != nil {
  21910. fields = append(fields, sopnode.FieldConditionType)
  21911. }
  21912. if m.addno_reply_condition != nil {
  21913. fields = append(fields, sopnode.FieldNoReplyCondition)
  21914. }
  21915. return fields
  21916. }
  21917. // AddedField returns the numeric value that was incremented/decremented on a field
  21918. // with the given name. The second boolean return value indicates that this field
  21919. // was not set, or was not defined in the schema.
  21920. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  21921. switch name {
  21922. case sopnode.FieldStatus:
  21923. return m.AddedStatus()
  21924. case sopnode.FieldParentID:
  21925. return m.AddedParentID()
  21926. case sopnode.FieldConditionType:
  21927. return m.AddedConditionType()
  21928. case sopnode.FieldNoReplyCondition:
  21929. return m.AddedNoReplyCondition()
  21930. }
  21931. return nil, false
  21932. }
  21933. // AddField adds the value to the field with the given name. It returns an error if
  21934. // the field is not defined in the schema, or if the type mismatched the field
  21935. // type.
  21936. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  21937. switch name {
  21938. case sopnode.FieldStatus:
  21939. v, ok := value.(int8)
  21940. if !ok {
  21941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21942. }
  21943. m.AddStatus(v)
  21944. return nil
  21945. case sopnode.FieldParentID:
  21946. v, ok := value.(int64)
  21947. if !ok {
  21948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21949. }
  21950. m.AddParentID(v)
  21951. return nil
  21952. case sopnode.FieldConditionType:
  21953. v, ok := value.(int)
  21954. if !ok {
  21955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21956. }
  21957. m.AddConditionType(v)
  21958. return nil
  21959. case sopnode.FieldNoReplyCondition:
  21960. v, ok := value.(int64)
  21961. if !ok {
  21962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21963. }
  21964. m.AddNoReplyCondition(v)
  21965. return nil
  21966. }
  21967. return fmt.Errorf("unknown SopNode numeric field %s", name)
  21968. }
  21969. // ClearedFields returns all nullable fields that were cleared during this
  21970. // mutation.
  21971. func (m *SopNodeMutation) ClearedFields() []string {
  21972. var fields []string
  21973. if m.FieldCleared(sopnode.FieldStatus) {
  21974. fields = append(fields, sopnode.FieldStatus)
  21975. }
  21976. if m.FieldCleared(sopnode.FieldDeletedAt) {
  21977. fields = append(fields, sopnode.FieldDeletedAt)
  21978. }
  21979. if m.FieldCleared(sopnode.FieldConditionList) {
  21980. fields = append(fields, sopnode.FieldConditionList)
  21981. }
  21982. if m.FieldCleared(sopnode.FieldActionMessage) {
  21983. fields = append(fields, sopnode.FieldActionMessage)
  21984. }
  21985. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  21986. fields = append(fields, sopnode.FieldActionLabelAdd)
  21987. }
  21988. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  21989. fields = append(fields, sopnode.FieldActionLabelDel)
  21990. }
  21991. if m.FieldCleared(sopnode.FieldActionForward) {
  21992. fields = append(fields, sopnode.FieldActionForward)
  21993. }
  21994. return fields
  21995. }
  21996. // FieldCleared returns a boolean indicating if a field with the given name was
  21997. // cleared in this mutation.
  21998. func (m *SopNodeMutation) FieldCleared(name string) bool {
  21999. _, ok := m.clearedFields[name]
  22000. return ok
  22001. }
  22002. // ClearField clears the value of the field with the given name. It returns an
  22003. // error if the field is not defined in the schema.
  22004. func (m *SopNodeMutation) ClearField(name string) error {
  22005. switch name {
  22006. case sopnode.FieldStatus:
  22007. m.ClearStatus()
  22008. return nil
  22009. case sopnode.FieldDeletedAt:
  22010. m.ClearDeletedAt()
  22011. return nil
  22012. case sopnode.FieldConditionList:
  22013. m.ClearConditionList()
  22014. return nil
  22015. case sopnode.FieldActionMessage:
  22016. m.ClearActionMessage()
  22017. return nil
  22018. case sopnode.FieldActionLabelAdd:
  22019. m.ClearActionLabelAdd()
  22020. return nil
  22021. case sopnode.FieldActionLabelDel:
  22022. m.ClearActionLabelDel()
  22023. return nil
  22024. case sopnode.FieldActionForward:
  22025. m.ClearActionForward()
  22026. return nil
  22027. }
  22028. return fmt.Errorf("unknown SopNode nullable field %s", name)
  22029. }
  22030. // ResetField resets all changes in the mutation for the field with the given name.
  22031. // It returns an error if the field is not defined in the schema.
  22032. func (m *SopNodeMutation) ResetField(name string) error {
  22033. switch name {
  22034. case sopnode.FieldCreatedAt:
  22035. m.ResetCreatedAt()
  22036. return nil
  22037. case sopnode.FieldUpdatedAt:
  22038. m.ResetUpdatedAt()
  22039. return nil
  22040. case sopnode.FieldStatus:
  22041. m.ResetStatus()
  22042. return nil
  22043. case sopnode.FieldDeletedAt:
  22044. m.ResetDeletedAt()
  22045. return nil
  22046. case sopnode.FieldStageID:
  22047. m.ResetStageID()
  22048. return nil
  22049. case sopnode.FieldParentID:
  22050. m.ResetParentID()
  22051. return nil
  22052. case sopnode.FieldName:
  22053. m.ResetName()
  22054. return nil
  22055. case sopnode.FieldConditionType:
  22056. m.ResetConditionType()
  22057. return nil
  22058. case sopnode.FieldConditionList:
  22059. m.ResetConditionList()
  22060. return nil
  22061. case sopnode.FieldNoReplyCondition:
  22062. m.ResetNoReplyCondition()
  22063. return nil
  22064. case sopnode.FieldNoReplyUnit:
  22065. m.ResetNoReplyUnit()
  22066. return nil
  22067. case sopnode.FieldActionMessage:
  22068. m.ResetActionMessage()
  22069. return nil
  22070. case sopnode.FieldActionLabelAdd:
  22071. m.ResetActionLabelAdd()
  22072. return nil
  22073. case sopnode.FieldActionLabelDel:
  22074. m.ResetActionLabelDel()
  22075. return nil
  22076. case sopnode.FieldActionForward:
  22077. m.ResetActionForward()
  22078. return nil
  22079. }
  22080. return fmt.Errorf("unknown SopNode field %s", name)
  22081. }
  22082. // AddedEdges returns all edge names that were set/added in this mutation.
  22083. func (m *SopNodeMutation) AddedEdges() []string {
  22084. edges := make([]string, 0, 2)
  22085. if m.sop_stage != nil {
  22086. edges = append(edges, sopnode.EdgeSopStage)
  22087. }
  22088. if m.node_messages != nil {
  22089. edges = append(edges, sopnode.EdgeNodeMessages)
  22090. }
  22091. return edges
  22092. }
  22093. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22094. // name in this mutation.
  22095. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  22096. switch name {
  22097. case sopnode.EdgeSopStage:
  22098. if id := m.sop_stage; id != nil {
  22099. return []ent.Value{*id}
  22100. }
  22101. case sopnode.EdgeNodeMessages:
  22102. ids := make([]ent.Value, 0, len(m.node_messages))
  22103. for id := range m.node_messages {
  22104. ids = append(ids, id)
  22105. }
  22106. return ids
  22107. }
  22108. return nil
  22109. }
  22110. // RemovedEdges returns all edge names that were removed in this mutation.
  22111. func (m *SopNodeMutation) RemovedEdges() []string {
  22112. edges := make([]string, 0, 2)
  22113. if m.removednode_messages != nil {
  22114. edges = append(edges, sopnode.EdgeNodeMessages)
  22115. }
  22116. return edges
  22117. }
  22118. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22119. // the given name in this mutation.
  22120. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  22121. switch name {
  22122. case sopnode.EdgeNodeMessages:
  22123. ids := make([]ent.Value, 0, len(m.removednode_messages))
  22124. for id := range m.removednode_messages {
  22125. ids = append(ids, id)
  22126. }
  22127. return ids
  22128. }
  22129. return nil
  22130. }
  22131. // ClearedEdges returns all edge names that were cleared in this mutation.
  22132. func (m *SopNodeMutation) ClearedEdges() []string {
  22133. edges := make([]string, 0, 2)
  22134. if m.clearedsop_stage {
  22135. edges = append(edges, sopnode.EdgeSopStage)
  22136. }
  22137. if m.clearednode_messages {
  22138. edges = append(edges, sopnode.EdgeNodeMessages)
  22139. }
  22140. return edges
  22141. }
  22142. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22143. // was cleared in this mutation.
  22144. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  22145. switch name {
  22146. case sopnode.EdgeSopStage:
  22147. return m.clearedsop_stage
  22148. case sopnode.EdgeNodeMessages:
  22149. return m.clearednode_messages
  22150. }
  22151. return false
  22152. }
  22153. // ClearEdge clears the value of the edge with the given name. It returns an error
  22154. // if that edge is not defined in the schema.
  22155. func (m *SopNodeMutation) ClearEdge(name string) error {
  22156. switch name {
  22157. case sopnode.EdgeSopStage:
  22158. m.ClearSopStage()
  22159. return nil
  22160. }
  22161. return fmt.Errorf("unknown SopNode unique edge %s", name)
  22162. }
  22163. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22164. // It returns an error if the edge is not defined in the schema.
  22165. func (m *SopNodeMutation) ResetEdge(name string) error {
  22166. switch name {
  22167. case sopnode.EdgeSopStage:
  22168. m.ResetSopStage()
  22169. return nil
  22170. case sopnode.EdgeNodeMessages:
  22171. m.ResetNodeMessages()
  22172. return nil
  22173. }
  22174. return fmt.Errorf("unknown SopNode edge %s", name)
  22175. }
  22176. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  22177. type SopStageMutation struct {
  22178. config
  22179. op Op
  22180. typ string
  22181. id *uint64
  22182. created_at *time.Time
  22183. updated_at *time.Time
  22184. status *uint8
  22185. addstatus *int8
  22186. deleted_at *time.Time
  22187. name *string
  22188. condition_type *int
  22189. addcondition_type *int
  22190. condition_operator *int
  22191. addcondition_operator *int
  22192. condition_list *[]custom_types.Condition
  22193. appendcondition_list []custom_types.Condition
  22194. action_message *[]custom_types.Action
  22195. appendaction_message []custom_types.Action
  22196. action_label_add *[]uint64
  22197. appendaction_label_add []uint64
  22198. action_label_del *[]uint64
  22199. appendaction_label_del []uint64
  22200. action_forward **custom_types.ActionForward
  22201. index_sort *int
  22202. addindex_sort *int
  22203. clearedFields map[string]struct{}
  22204. sop_task *uint64
  22205. clearedsop_task bool
  22206. stage_nodes map[uint64]struct{}
  22207. removedstage_nodes map[uint64]struct{}
  22208. clearedstage_nodes bool
  22209. stage_messages map[uint64]struct{}
  22210. removedstage_messages map[uint64]struct{}
  22211. clearedstage_messages bool
  22212. done bool
  22213. oldValue func(context.Context) (*SopStage, error)
  22214. predicates []predicate.SopStage
  22215. }
  22216. var _ ent.Mutation = (*SopStageMutation)(nil)
  22217. // sopstageOption allows management of the mutation configuration using functional options.
  22218. type sopstageOption func(*SopStageMutation)
  22219. // newSopStageMutation creates new mutation for the SopStage entity.
  22220. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  22221. m := &SopStageMutation{
  22222. config: c,
  22223. op: op,
  22224. typ: TypeSopStage,
  22225. clearedFields: make(map[string]struct{}),
  22226. }
  22227. for _, opt := range opts {
  22228. opt(m)
  22229. }
  22230. return m
  22231. }
  22232. // withSopStageID sets the ID field of the mutation.
  22233. func withSopStageID(id uint64) sopstageOption {
  22234. return func(m *SopStageMutation) {
  22235. var (
  22236. err error
  22237. once sync.Once
  22238. value *SopStage
  22239. )
  22240. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  22241. once.Do(func() {
  22242. if m.done {
  22243. err = errors.New("querying old values post mutation is not allowed")
  22244. } else {
  22245. value, err = m.Client().SopStage.Get(ctx, id)
  22246. }
  22247. })
  22248. return value, err
  22249. }
  22250. m.id = &id
  22251. }
  22252. }
  22253. // withSopStage sets the old SopStage of the mutation.
  22254. func withSopStage(node *SopStage) sopstageOption {
  22255. return func(m *SopStageMutation) {
  22256. m.oldValue = func(context.Context) (*SopStage, error) {
  22257. return node, nil
  22258. }
  22259. m.id = &node.ID
  22260. }
  22261. }
  22262. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22263. // executed in a transaction (ent.Tx), a transactional client is returned.
  22264. func (m SopStageMutation) Client() *Client {
  22265. client := &Client{config: m.config}
  22266. client.init()
  22267. return client
  22268. }
  22269. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22270. // it returns an error otherwise.
  22271. func (m SopStageMutation) Tx() (*Tx, error) {
  22272. if _, ok := m.driver.(*txDriver); !ok {
  22273. return nil, errors.New("ent: mutation is not running in a transaction")
  22274. }
  22275. tx := &Tx{config: m.config}
  22276. tx.init()
  22277. return tx, nil
  22278. }
  22279. // SetID sets the value of the id field. Note that this
  22280. // operation is only accepted on creation of SopStage entities.
  22281. func (m *SopStageMutation) SetID(id uint64) {
  22282. m.id = &id
  22283. }
  22284. // ID returns the ID value in the mutation. Note that the ID is only available
  22285. // if it was provided to the builder or after it was returned from the database.
  22286. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  22287. if m.id == nil {
  22288. return
  22289. }
  22290. return *m.id, true
  22291. }
  22292. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22293. // That means, if the mutation is applied within a transaction with an isolation level such
  22294. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22295. // or updated by the mutation.
  22296. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  22297. switch {
  22298. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22299. id, exists := m.ID()
  22300. if exists {
  22301. return []uint64{id}, nil
  22302. }
  22303. fallthrough
  22304. case m.op.Is(OpUpdate | OpDelete):
  22305. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  22306. default:
  22307. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22308. }
  22309. }
  22310. // SetCreatedAt sets the "created_at" field.
  22311. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  22312. m.created_at = &t
  22313. }
  22314. // CreatedAt returns the value of the "created_at" field in the mutation.
  22315. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  22316. v := m.created_at
  22317. if v == nil {
  22318. return
  22319. }
  22320. return *v, true
  22321. }
  22322. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  22323. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22325. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22326. if !m.op.Is(OpUpdateOne) {
  22327. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22328. }
  22329. if m.id == nil || m.oldValue == nil {
  22330. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22331. }
  22332. oldValue, err := m.oldValue(ctx)
  22333. if err != nil {
  22334. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22335. }
  22336. return oldValue.CreatedAt, nil
  22337. }
  22338. // ResetCreatedAt resets all changes to the "created_at" field.
  22339. func (m *SopStageMutation) ResetCreatedAt() {
  22340. m.created_at = nil
  22341. }
  22342. // SetUpdatedAt sets the "updated_at" field.
  22343. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  22344. m.updated_at = &t
  22345. }
  22346. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22347. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  22348. v := m.updated_at
  22349. if v == nil {
  22350. return
  22351. }
  22352. return *v, true
  22353. }
  22354. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  22355. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22357. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22358. if !m.op.Is(OpUpdateOne) {
  22359. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22360. }
  22361. if m.id == nil || m.oldValue == nil {
  22362. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22363. }
  22364. oldValue, err := m.oldValue(ctx)
  22365. if err != nil {
  22366. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22367. }
  22368. return oldValue.UpdatedAt, nil
  22369. }
  22370. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22371. func (m *SopStageMutation) ResetUpdatedAt() {
  22372. m.updated_at = nil
  22373. }
  22374. // SetStatus sets the "status" field.
  22375. func (m *SopStageMutation) SetStatus(u uint8) {
  22376. m.status = &u
  22377. m.addstatus = nil
  22378. }
  22379. // Status returns the value of the "status" field in the mutation.
  22380. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  22381. v := m.status
  22382. if v == nil {
  22383. return
  22384. }
  22385. return *v, true
  22386. }
  22387. // OldStatus returns the old "status" field's value of the SopStage entity.
  22388. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22390. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22391. if !m.op.Is(OpUpdateOne) {
  22392. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22393. }
  22394. if m.id == nil || m.oldValue == nil {
  22395. return v, errors.New("OldStatus requires an ID field in the mutation")
  22396. }
  22397. oldValue, err := m.oldValue(ctx)
  22398. if err != nil {
  22399. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22400. }
  22401. return oldValue.Status, nil
  22402. }
  22403. // AddStatus adds u to the "status" field.
  22404. func (m *SopStageMutation) AddStatus(u int8) {
  22405. if m.addstatus != nil {
  22406. *m.addstatus += u
  22407. } else {
  22408. m.addstatus = &u
  22409. }
  22410. }
  22411. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22412. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  22413. v := m.addstatus
  22414. if v == nil {
  22415. return
  22416. }
  22417. return *v, true
  22418. }
  22419. // ClearStatus clears the value of the "status" field.
  22420. func (m *SopStageMutation) ClearStatus() {
  22421. m.status = nil
  22422. m.addstatus = nil
  22423. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  22424. }
  22425. // StatusCleared returns if the "status" field was cleared in this mutation.
  22426. func (m *SopStageMutation) StatusCleared() bool {
  22427. _, ok := m.clearedFields[sopstage.FieldStatus]
  22428. return ok
  22429. }
  22430. // ResetStatus resets all changes to the "status" field.
  22431. func (m *SopStageMutation) ResetStatus() {
  22432. m.status = nil
  22433. m.addstatus = nil
  22434. delete(m.clearedFields, sopstage.FieldStatus)
  22435. }
  22436. // SetDeletedAt sets the "deleted_at" field.
  22437. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  22438. m.deleted_at = &t
  22439. }
  22440. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22441. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  22442. v := m.deleted_at
  22443. if v == nil {
  22444. return
  22445. }
  22446. return *v, true
  22447. }
  22448. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  22449. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22451. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22452. if !m.op.Is(OpUpdateOne) {
  22453. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22454. }
  22455. if m.id == nil || m.oldValue == nil {
  22456. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22457. }
  22458. oldValue, err := m.oldValue(ctx)
  22459. if err != nil {
  22460. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22461. }
  22462. return oldValue.DeletedAt, nil
  22463. }
  22464. // ClearDeletedAt clears the value of the "deleted_at" field.
  22465. func (m *SopStageMutation) ClearDeletedAt() {
  22466. m.deleted_at = nil
  22467. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  22468. }
  22469. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22470. func (m *SopStageMutation) DeletedAtCleared() bool {
  22471. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  22472. return ok
  22473. }
  22474. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22475. func (m *SopStageMutation) ResetDeletedAt() {
  22476. m.deleted_at = nil
  22477. delete(m.clearedFields, sopstage.FieldDeletedAt)
  22478. }
  22479. // SetTaskID sets the "task_id" field.
  22480. func (m *SopStageMutation) SetTaskID(u uint64) {
  22481. m.sop_task = &u
  22482. }
  22483. // TaskID returns the value of the "task_id" field in the mutation.
  22484. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  22485. v := m.sop_task
  22486. if v == nil {
  22487. return
  22488. }
  22489. return *v, true
  22490. }
  22491. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  22492. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22494. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  22495. if !m.op.Is(OpUpdateOne) {
  22496. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  22497. }
  22498. if m.id == nil || m.oldValue == nil {
  22499. return v, errors.New("OldTaskID requires an ID field in the mutation")
  22500. }
  22501. oldValue, err := m.oldValue(ctx)
  22502. if err != nil {
  22503. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  22504. }
  22505. return oldValue.TaskID, nil
  22506. }
  22507. // ResetTaskID resets all changes to the "task_id" field.
  22508. func (m *SopStageMutation) ResetTaskID() {
  22509. m.sop_task = nil
  22510. }
  22511. // SetName sets the "name" field.
  22512. func (m *SopStageMutation) SetName(s string) {
  22513. m.name = &s
  22514. }
  22515. // Name returns the value of the "name" field in the mutation.
  22516. func (m *SopStageMutation) Name() (r string, exists bool) {
  22517. v := m.name
  22518. if v == nil {
  22519. return
  22520. }
  22521. return *v, true
  22522. }
  22523. // OldName returns the old "name" field's value of the SopStage entity.
  22524. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22526. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  22527. if !m.op.Is(OpUpdateOne) {
  22528. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22529. }
  22530. if m.id == nil || m.oldValue == nil {
  22531. return v, errors.New("OldName requires an ID field in the mutation")
  22532. }
  22533. oldValue, err := m.oldValue(ctx)
  22534. if err != nil {
  22535. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22536. }
  22537. return oldValue.Name, nil
  22538. }
  22539. // ResetName resets all changes to the "name" field.
  22540. func (m *SopStageMutation) ResetName() {
  22541. m.name = nil
  22542. }
  22543. // SetConditionType sets the "condition_type" field.
  22544. func (m *SopStageMutation) SetConditionType(i int) {
  22545. m.condition_type = &i
  22546. m.addcondition_type = nil
  22547. }
  22548. // ConditionType returns the value of the "condition_type" field in the mutation.
  22549. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  22550. v := m.condition_type
  22551. if v == nil {
  22552. return
  22553. }
  22554. return *v, true
  22555. }
  22556. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  22557. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22559. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22560. if !m.op.Is(OpUpdateOne) {
  22561. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22562. }
  22563. if m.id == nil || m.oldValue == nil {
  22564. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22565. }
  22566. oldValue, err := m.oldValue(ctx)
  22567. if err != nil {
  22568. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22569. }
  22570. return oldValue.ConditionType, nil
  22571. }
  22572. // AddConditionType adds i to the "condition_type" field.
  22573. func (m *SopStageMutation) AddConditionType(i int) {
  22574. if m.addcondition_type != nil {
  22575. *m.addcondition_type += i
  22576. } else {
  22577. m.addcondition_type = &i
  22578. }
  22579. }
  22580. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22581. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  22582. v := m.addcondition_type
  22583. if v == nil {
  22584. return
  22585. }
  22586. return *v, true
  22587. }
  22588. // ResetConditionType resets all changes to the "condition_type" field.
  22589. func (m *SopStageMutation) ResetConditionType() {
  22590. m.condition_type = nil
  22591. m.addcondition_type = nil
  22592. }
  22593. // SetConditionOperator sets the "condition_operator" field.
  22594. func (m *SopStageMutation) SetConditionOperator(i int) {
  22595. m.condition_operator = &i
  22596. m.addcondition_operator = nil
  22597. }
  22598. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  22599. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  22600. v := m.condition_operator
  22601. if v == nil {
  22602. return
  22603. }
  22604. return *v, true
  22605. }
  22606. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  22607. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22609. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  22610. if !m.op.Is(OpUpdateOne) {
  22611. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  22612. }
  22613. if m.id == nil || m.oldValue == nil {
  22614. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  22615. }
  22616. oldValue, err := m.oldValue(ctx)
  22617. if err != nil {
  22618. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  22619. }
  22620. return oldValue.ConditionOperator, nil
  22621. }
  22622. // AddConditionOperator adds i to the "condition_operator" field.
  22623. func (m *SopStageMutation) AddConditionOperator(i int) {
  22624. if m.addcondition_operator != nil {
  22625. *m.addcondition_operator += i
  22626. } else {
  22627. m.addcondition_operator = &i
  22628. }
  22629. }
  22630. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  22631. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  22632. v := m.addcondition_operator
  22633. if v == nil {
  22634. return
  22635. }
  22636. return *v, true
  22637. }
  22638. // ResetConditionOperator resets all changes to the "condition_operator" field.
  22639. func (m *SopStageMutation) ResetConditionOperator() {
  22640. m.condition_operator = nil
  22641. m.addcondition_operator = nil
  22642. }
  22643. // SetConditionList sets the "condition_list" field.
  22644. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  22645. m.condition_list = &ct
  22646. m.appendcondition_list = nil
  22647. }
  22648. // ConditionList returns the value of the "condition_list" field in the mutation.
  22649. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  22650. v := m.condition_list
  22651. if v == nil {
  22652. return
  22653. }
  22654. return *v, true
  22655. }
  22656. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  22657. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22659. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  22660. if !m.op.Is(OpUpdateOne) {
  22661. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22662. }
  22663. if m.id == nil || m.oldValue == nil {
  22664. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22665. }
  22666. oldValue, err := m.oldValue(ctx)
  22667. if err != nil {
  22668. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22669. }
  22670. return oldValue.ConditionList, nil
  22671. }
  22672. // AppendConditionList adds ct to the "condition_list" field.
  22673. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  22674. m.appendcondition_list = append(m.appendcondition_list, ct...)
  22675. }
  22676. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22677. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  22678. if len(m.appendcondition_list) == 0 {
  22679. return nil, false
  22680. }
  22681. return m.appendcondition_list, true
  22682. }
  22683. // ResetConditionList resets all changes to the "condition_list" field.
  22684. func (m *SopStageMutation) ResetConditionList() {
  22685. m.condition_list = nil
  22686. m.appendcondition_list = nil
  22687. }
  22688. // SetActionMessage sets the "action_message" field.
  22689. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  22690. m.action_message = &ct
  22691. m.appendaction_message = nil
  22692. }
  22693. // ActionMessage returns the value of the "action_message" field in the mutation.
  22694. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22695. v := m.action_message
  22696. if v == nil {
  22697. return
  22698. }
  22699. return *v, true
  22700. }
  22701. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  22702. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22704. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22705. if !m.op.Is(OpUpdateOne) {
  22706. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22707. }
  22708. if m.id == nil || m.oldValue == nil {
  22709. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22710. }
  22711. oldValue, err := m.oldValue(ctx)
  22712. if err != nil {
  22713. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22714. }
  22715. return oldValue.ActionMessage, nil
  22716. }
  22717. // AppendActionMessage adds ct to the "action_message" field.
  22718. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  22719. m.appendaction_message = append(m.appendaction_message, ct...)
  22720. }
  22721. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22722. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22723. if len(m.appendaction_message) == 0 {
  22724. return nil, false
  22725. }
  22726. return m.appendaction_message, true
  22727. }
  22728. // ClearActionMessage clears the value of the "action_message" field.
  22729. func (m *SopStageMutation) ClearActionMessage() {
  22730. m.action_message = nil
  22731. m.appendaction_message = nil
  22732. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  22733. }
  22734. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22735. func (m *SopStageMutation) ActionMessageCleared() bool {
  22736. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  22737. return ok
  22738. }
  22739. // ResetActionMessage resets all changes to the "action_message" field.
  22740. func (m *SopStageMutation) ResetActionMessage() {
  22741. m.action_message = nil
  22742. m.appendaction_message = nil
  22743. delete(m.clearedFields, sopstage.FieldActionMessage)
  22744. }
  22745. // SetActionLabelAdd sets the "action_label_add" field.
  22746. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  22747. m.action_label_add = &u
  22748. m.appendaction_label_add = nil
  22749. }
  22750. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22751. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22752. v := m.action_label_add
  22753. if v == nil {
  22754. return
  22755. }
  22756. return *v, true
  22757. }
  22758. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  22759. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22761. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22762. if !m.op.Is(OpUpdateOne) {
  22763. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22764. }
  22765. if m.id == nil || m.oldValue == nil {
  22766. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22767. }
  22768. oldValue, err := m.oldValue(ctx)
  22769. if err != nil {
  22770. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22771. }
  22772. return oldValue.ActionLabelAdd, nil
  22773. }
  22774. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22775. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  22776. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22777. }
  22778. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22779. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22780. if len(m.appendaction_label_add) == 0 {
  22781. return nil, false
  22782. }
  22783. return m.appendaction_label_add, true
  22784. }
  22785. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22786. func (m *SopStageMutation) ClearActionLabelAdd() {
  22787. m.action_label_add = nil
  22788. m.appendaction_label_add = nil
  22789. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  22790. }
  22791. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22792. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  22793. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  22794. return ok
  22795. }
  22796. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22797. func (m *SopStageMutation) ResetActionLabelAdd() {
  22798. m.action_label_add = nil
  22799. m.appendaction_label_add = nil
  22800. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  22801. }
  22802. // SetActionLabelDel sets the "action_label_del" field.
  22803. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  22804. m.action_label_del = &u
  22805. m.appendaction_label_del = nil
  22806. }
  22807. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22808. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  22809. v := m.action_label_del
  22810. if v == nil {
  22811. return
  22812. }
  22813. return *v, true
  22814. }
  22815. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  22816. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22818. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22819. if !m.op.Is(OpUpdateOne) {
  22820. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22821. }
  22822. if m.id == nil || m.oldValue == nil {
  22823. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22824. }
  22825. oldValue, err := m.oldValue(ctx)
  22826. if err != nil {
  22827. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22828. }
  22829. return oldValue.ActionLabelDel, nil
  22830. }
  22831. // AppendActionLabelDel adds u to the "action_label_del" field.
  22832. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  22833. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22834. }
  22835. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22836. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22837. if len(m.appendaction_label_del) == 0 {
  22838. return nil, false
  22839. }
  22840. return m.appendaction_label_del, true
  22841. }
  22842. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22843. func (m *SopStageMutation) ClearActionLabelDel() {
  22844. m.action_label_del = nil
  22845. m.appendaction_label_del = nil
  22846. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  22847. }
  22848. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22849. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  22850. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  22851. return ok
  22852. }
  22853. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22854. func (m *SopStageMutation) ResetActionLabelDel() {
  22855. m.action_label_del = nil
  22856. m.appendaction_label_del = nil
  22857. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  22858. }
  22859. // SetActionForward sets the "action_forward" field.
  22860. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22861. m.action_forward = &ctf
  22862. }
  22863. // ActionForward returns the value of the "action_forward" field in the mutation.
  22864. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22865. v := m.action_forward
  22866. if v == nil {
  22867. return
  22868. }
  22869. return *v, true
  22870. }
  22871. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  22872. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22874. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22875. if !m.op.Is(OpUpdateOne) {
  22876. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22877. }
  22878. if m.id == nil || m.oldValue == nil {
  22879. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22880. }
  22881. oldValue, err := m.oldValue(ctx)
  22882. if err != nil {
  22883. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22884. }
  22885. return oldValue.ActionForward, nil
  22886. }
  22887. // ClearActionForward clears the value of the "action_forward" field.
  22888. func (m *SopStageMutation) ClearActionForward() {
  22889. m.action_forward = nil
  22890. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  22891. }
  22892. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22893. func (m *SopStageMutation) ActionForwardCleared() bool {
  22894. _, ok := m.clearedFields[sopstage.FieldActionForward]
  22895. return ok
  22896. }
  22897. // ResetActionForward resets all changes to the "action_forward" field.
  22898. func (m *SopStageMutation) ResetActionForward() {
  22899. m.action_forward = nil
  22900. delete(m.clearedFields, sopstage.FieldActionForward)
  22901. }
  22902. // SetIndexSort sets the "index_sort" field.
  22903. func (m *SopStageMutation) SetIndexSort(i int) {
  22904. m.index_sort = &i
  22905. m.addindex_sort = nil
  22906. }
  22907. // IndexSort returns the value of the "index_sort" field in the mutation.
  22908. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  22909. v := m.index_sort
  22910. if v == nil {
  22911. return
  22912. }
  22913. return *v, true
  22914. }
  22915. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  22916. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22918. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  22919. if !m.op.Is(OpUpdateOne) {
  22920. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  22921. }
  22922. if m.id == nil || m.oldValue == nil {
  22923. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  22924. }
  22925. oldValue, err := m.oldValue(ctx)
  22926. if err != nil {
  22927. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  22928. }
  22929. return oldValue.IndexSort, nil
  22930. }
  22931. // AddIndexSort adds i to the "index_sort" field.
  22932. func (m *SopStageMutation) AddIndexSort(i int) {
  22933. if m.addindex_sort != nil {
  22934. *m.addindex_sort += i
  22935. } else {
  22936. m.addindex_sort = &i
  22937. }
  22938. }
  22939. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  22940. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  22941. v := m.addindex_sort
  22942. if v == nil {
  22943. return
  22944. }
  22945. return *v, true
  22946. }
  22947. // ClearIndexSort clears the value of the "index_sort" field.
  22948. func (m *SopStageMutation) ClearIndexSort() {
  22949. m.index_sort = nil
  22950. m.addindex_sort = nil
  22951. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  22952. }
  22953. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  22954. func (m *SopStageMutation) IndexSortCleared() bool {
  22955. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  22956. return ok
  22957. }
  22958. // ResetIndexSort resets all changes to the "index_sort" field.
  22959. func (m *SopStageMutation) ResetIndexSort() {
  22960. m.index_sort = nil
  22961. m.addindex_sort = nil
  22962. delete(m.clearedFields, sopstage.FieldIndexSort)
  22963. }
  22964. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  22965. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  22966. m.sop_task = &id
  22967. }
  22968. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  22969. func (m *SopStageMutation) ClearSopTask() {
  22970. m.clearedsop_task = true
  22971. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  22972. }
  22973. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  22974. func (m *SopStageMutation) SopTaskCleared() bool {
  22975. return m.clearedsop_task
  22976. }
  22977. // SopTaskID returns the "sop_task" edge ID in the mutation.
  22978. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  22979. if m.sop_task != nil {
  22980. return *m.sop_task, true
  22981. }
  22982. return
  22983. }
  22984. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  22985. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22986. // SopTaskID instead. It exists only for internal usage by the builders.
  22987. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  22988. if id := m.sop_task; id != nil {
  22989. ids = append(ids, *id)
  22990. }
  22991. return
  22992. }
  22993. // ResetSopTask resets all changes to the "sop_task" edge.
  22994. func (m *SopStageMutation) ResetSopTask() {
  22995. m.sop_task = nil
  22996. m.clearedsop_task = false
  22997. }
  22998. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  22999. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  23000. if m.stage_nodes == nil {
  23001. m.stage_nodes = make(map[uint64]struct{})
  23002. }
  23003. for i := range ids {
  23004. m.stage_nodes[ids[i]] = struct{}{}
  23005. }
  23006. }
  23007. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  23008. func (m *SopStageMutation) ClearStageNodes() {
  23009. m.clearedstage_nodes = true
  23010. }
  23011. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  23012. func (m *SopStageMutation) StageNodesCleared() bool {
  23013. return m.clearedstage_nodes
  23014. }
  23015. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  23016. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  23017. if m.removedstage_nodes == nil {
  23018. m.removedstage_nodes = make(map[uint64]struct{})
  23019. }
  23020. for i := range ids {
  23021. delete(m.stage_nodes, ids[i])
  23022. m.removedstage_nodes[ids[i]] = struct{}{}
  23023. }
  23024. }
  23025. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  23026. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  23027. for id := range m.removedstage_nodes {
  23028. ids = append(ids, id)
  23029. }
  23030. return
  23031. }
  23032. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  23033. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  23034. for id := range m.stage_nodes {
  23035. ids = append(ids, id)
  23036. }
  23037. return
  23038. }
  23039. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  23040. func (m *SopStageMutation) ResetStageNodes() {
  23041. m.stage_nodes = nil
  23042. m.clearedstage_nodes = false
  23043. m.removedstage_nodes = nil
  23044. }
  23045. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  23046. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  23047. if m.stage_messages == nil {
  23048. m.stage_messages = make(map[uint64]struct{})
  23049. }
  23050. for i := range ids {
  23051. m.stage_messages[ids[i]] = struct{}{}
  23052. }
  23053. }
  23054. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  23055. func (m *SopStageMutation) ClearStageMessages() {
  23056. m.clearedstage_messages = true
  23057. }
  23058. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  23059. func (m *SopStageMutation) StageMessagesCleared() bool {
  23060. return m.clearedstage_messages
  23061. }
  23062. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  23063. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  23064. if m.removedstage_messages == nil {
  23065. m.removedstage_messages = make(map[uint64]struct{})
  23066. }
  23067. for i := range ids {
  23068. delete(m.stage_messages, ids[i])
  23069. m.removedstage_messages[ids[i]] = struct{}{}
  23070. }
  23071. }
  23072. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  23073. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  23074. for id := range m.removedstage_messages {
  23075. ids = append(ids, id)
  23076. }
  23077. return
  23078. }
  23079. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  23080. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  23081. for id := range m.stage_messages {
  23082. ids = append(ids, id)
  23083. }
  23084. return
  23085. }
  23086. // ResetStageMessages resets all changes to the "stage_messages" edge.
  23087. func (m *SopStageMutation) ResetStageMessages() {
  23088. m.stage_messages = nil
  23089. m.clearedstage_messages = false
  23090. m.removedstage_messages = nil
  23091. }
  23092. // Where appends a list predicates to the SopStageMutation builder.
  23093. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  23094. m.predicates = append(m.predicates, ps...)
  23095. }
  23096. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  23097. // users can use type-assertion to append predicates that do not depend on any generated package.
  23098. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  23099. p := make([]predicate.SopStage, len(ps))
  23100. for i := range ps {
  23101. p[i] = ps[i]
  23102. }
  23103. m.Where(p...)
  23104. }
  23105. // Op returns the operation name.
  23106. func (m *SopStageMutation) Op() Op {
  23107. return m.op
  23108. }
  23109. // SetOp allows setting the mutation operation.
  23110. func (m *SopStageMutation) SetOp(op Op) {
  23111. m.op = op
  23112. }
  23113. // Type returns the node type of this mutation (SopStage).
  23114. func (m *SopStageMutation) Type() string {
  23115. return m.typ
  23116. }
  23117. // Fields returns all fields that were changed during this mutation. Note that in
  23118. // order to get all numeric fields that were incremented/decremented, call
  23119. // AddedFields().
  23120. func (m *SopStageMutation) Fields() []string {
  23121. fields := make([]string, 0, 14)
  23122. if m.created_at != nil {
  23123. fields = append(fields, sopstage.FieldCreatedAt)
  23124. }
  23125. if m.updated_at != nil {
  23126. fields = append(fields, sopstage.FieldUpdatedAt)
  23127. }
  23128. if m.status != nil {
  23129. fields = append(fields, sopstage.FieldStatus)
  23130. }
  23131. if m.deleted_at != nil {
  23132. fields = append(fields, sopstage.FieldDeletedAt)
  23133. }
  23134. if m.sop_task != nil {
  23135. fields = append(fields, sopstage.FieldTaskID)
  23136. }
  23137. if m.name != nil {
  23138. fields = append(fields, sopstage.FieldName)
  23139. }
  23140. if m.condition_type != nil {
  23141. fields = append(fields, sopstage.FieldConditionType)
  23142. }
  23143. if m.condition_operator != nil {
  23144. fields = append(fields, sopstage.FieldConditionOperator)
  23145. }
  23146. if m.condition_list != nil {
  23147. fields = append(fields, sopstage.FieldConditionList)
  23148. }
  23149. if m.action_message != nil {
  23150. fields = append(fields, sopstage.FieldActionMessage)
  23151. }
  23152. if m.action_label_add != nil {
  23153. fields = append(fields, sopstage.FieldActionLabelAdd)
  23154. }
  23155. if m.action_label_del != nil {
  23156. fields = append(fields, sopstage.FieldActionLabelDel)
  23157. }
  23158. if m.action_forward != nil {
  23159. fields = append(fields, sopstage.FieldActionForward)
  23160. }
  23161. if m.index_sort != nil {
  23162. fields = append(fields, sopstage.FieldIndexSort)
  23163. }
  23164. return fields
  23165. }
  23166. // Field returns the value of a field with the given name. The second boolean
  23167. // return value indicates that this field was not set, or was not defined in the
  23168. // schema.
  23169. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  23170. switch name {
  23171. case sopstage.FieldCreatedAt:
  23172. return m.CreatedAt()
  23173. case sopstage.FieldUpdatedAt:
  23174. return m.UpdatedAt()
  23175. case sopstage.FieldStatus:
  23176. return m.Status()
  23177. case sopstage.FieldDeletedAt:
  23178. return m.DeletedAt()
  23179. case sopstage.FieldTaskID:
  23180. return m.TaskID()
  23181. case sopstage.FieldName:
  23182. return m.Name()
  23183. case sopstage.FieldConditionType:
  23184. return m.ConditionType()
  23185. case sopstage.FieldConditionOperator:
  23186. return m.ConditionOperator()
  23187. case sopstage.FieldConditionList:
  23188. return m.ConditionList()
  23189. case sopstage.FieldActionMessage:
  23190. return m.ActionMessage()
  23191. case sopstage.FieldActionLabelAdd:
  23192. return m.ActionLabelAdd()
  23193. case sopstage.FieldActionLabelDel:
  23194. return m.ActionLabelDel()
  23195. case sopstage.FieldActionForward:
  23196. return m.ActionForward()
  23197. case sopstage.FieldIndexSort:
  23198. return m.IndexSort()
  23199. }
  23200. return nil, false
  23201. }
  23202. // OldField returns the old value of the field from the database. An error is
  23203. // returned if the mutation operation is not UpdateOne, or the query to the
  23204. // database failed.
  23205. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23206. switch name {
  23207. case sopstage.FieldCreatedAt:
  23208. return m.OldCreatedAt(ctx)
  23209. case sopstage.FieldUpdatedAt:
  23210. return m.OldUpdatedAt(ctx)
  23211. case sopstage.FieldStatus:
  23212. return m.OldStatus(ctx)
  23213. case sopstage.FieldDeletedAt:
  23214. return m.OldDeletedAt(ctx)
  23215. case sopstage.FieldTaskID:
  23216. return m.OldTaskID(ctx)
  23217. case sopstage.FieldName:
  23218. return m.OldName(ctx)
  23219. case sopstage.FieldConditionType:
  23220. return m.OldConditionType(ctx)
  23221. case sopstage.FieldConditionOperator:
  23222. return m.OldConditionOperator(ctx)
  23223. case sopstage.FieldConditionList:
  23224. return m.OldConditionList(ctx)
  23225. case sopstage.FieldActionMessage:
  23226. return m.OldActionMessage(ctx)
  23227. case sopstage.FieldActionLabelAdd:
  23228. return m.OldActionLabelAdd(ctx)
  23229. case sopstage.FieldActionLabelDel:
  23230. return m.OldActionLabelDel(ctx)
  23231. case sopstage.FieldActionForward:
  23232. return m.OldActionForward(ctx)
  23233. case sopstage.FieldIndexSort:
  23234. return m.OldIndexSort(ctx)
  23235. }
  23236. return nil, fmt.Errorf("unknown SopStage field %s", name)
  23237. }
  23238. // SetField sets the value of a field with the given name. It returns an error if
  23239. // the field is not defined in the schema, or if the type mismatched the field
  23240. // type.
  23241. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  23242. switch name {
  23243. case sopstage.FieldCreatedAt:
  23244. v, ok := value.(time.Time)
  23245. if !ok {
  23246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23247. }
  23248. m.SetCreatedAt(v)
  23249. return nil
  23250. case sopstage.FieldUpdatedAt:
  23251. v, ok := value.(time.Time)
  23252. if !ok {
  23253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23254. }
  23255. m.SetUpdatedAt(v)
  23256. return nil
  23257. case sopstage.FieldStatus:
  23258. v, ok := value.(uint8)
  23259. if !ok {
  23260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23261. }
  23262. m.SetStatus(v)
  23263. return nil
  23264. case sopstage.FieldDeletedAt:
  23265. v, ok := value.(time.Time)
  23266. if !ok {
  23267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23268. }
  23269. m.SetDeletedAt(v)
  23270. return nil
  23271. case sopstage.FieldTaskID:
  23272. v, ok := value.(uint64)
  23273. if !ok {
  23274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23275. }
  23276. m.SetTaskID(v)
  23277. return nil
  23278. case sopstage.FieldName:
  23279. v, ok := value.(string)
  23280. if !ok {
  23281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23282. }
  23283. m.SetName(v)
  23284. return nil
  23285. case sopstage.FieldConditionType:
  23286. v, ok := value.(int)
  23287. if !ok {
  23288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23289. }
  23290. m.SetConditionType(v)
  23291. return nil
  23292. case sopstage.FieldConditionOperator:
  23293. v, ok := value.(int)
  23294. if !ok {
  23295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23296. }
  23297. m.SetConditionOperator(v)
  23298. return nil
  23299. case sopstage.FieldConditionList:
  23300. v, ok := value.([]custom_types.Condition)
  23301. if !ok {
  23302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23303. }
  23304. m.SetConditionList(v)
  23305. return nil
  23306. case sopstage.FieldActionMessage:
  23307. v, ok := value.([]custom_types.Action)
  23308. if !ok {
  23309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23310. }
  23311. m.SetActionMessage(v)
  23312. return nil
  23313. case sopstage.FieldActionLabelAdd:
  23314. v, ok := value.([]uint64)
  23315. if !ok {
  23316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23317. }
  23318. m.SetActionLabelAdd(v)
  23319. return nil
  23320. case sopstage.FieldActionLabelDel:
  23321. v, ok := value.([]uint64)
  23322. if !ok {
  23323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23324. }
  23325. m.SetActionLabelDel(v)
  23326. return nil
  23327. case sopstage.FieldActionForward:
  23328. v, ok := value.(*custom_types.ActionForward)
  23329. if !ok {
  23330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23331. }
  23332. m.SetActionForward(v)
  23333. return nil
  23334. case sopstage.FieldIndexSort:
  23335. v, ok := value.(int)
  23336. if !ok {
  23337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23338. }
  23339. m.SetIndexSort(v)
  23340. return nil
  23341. }
  23342. return fmt.Errorf("unknown SopStage field %s", name)
  23343. }
  23344. // AddedFields returns all numeric fields that were incremented/decremented during
  23345. // this mutation.
  23346. func (m *SopStageMutation) AddedFields() []string {
  23347. var fields []string
  23348. if m.addstatus != nil {
  23349. fields = append(fields, sopstage.FieldStatus)
  23350. }
  23351. if m.addcondition_type != nil {
  23352. fields = append(fields, sopstage.FieldConditionType)
  23353. }
  23354. if m.addcondition_operator != nil {
  23355. fields = append(fields, sopstage.FieldConditionOperator)
  23356. }
  23357. if m.addindex_sort != nil {
  23358. fields = append(fields, sopstage.FieldIndexSort)
  23359. }
  23360. return fields
  23361. }
  23362. // AddedField returns the numeric value that was incremented/decremented on a field
  23363. // with the given name. The second boolean return value indicates that this field
  23364. // was not set, or was not defined in the schema.
  23365. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  23366. switch name {
  23367. case sopstage.FieldStatus:
  23368. return m.AddedStatus()
  23369. case sopstage.FieldConditionType:
  23370. return m.AddedConditionType()
  23371. case sopstage.FieldConditionOperator:
  23372. return m.AddedConditionOperator()
  23373. case sopstage.FieldIndexSort:
  23374. return m.AddedIndexSort()
  23375. }
  23376. return nil, false
  23377. }
  23378. // AddField adds the value to the field with the given name. It returns an error if
  23379. // the field is not defined in the schema, or if the type mismatched the field
  23380. // type.
  23381. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  23382. switch name {
  23383. case sopstage.FieldStatus:
  23384. v, ok := value.(int8)
  23385. if !ok {
  23386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23387. }
  23388. m.AddStatus(v)
  23389. return nil
  23390. case sopstage.FieldConditionType:
  23391. v, ok := value.(int)
  23392. if !ok {
  23393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23394. }
  23395. m.AddConditionType(v)
  23396. return nil
  23397. case sopstage.FieldConditionOperator:
  23398. v, ok := value.(int)
  23399. if !ok {
  23400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23401. }
  23402. m.AddConditionOperator(v)
  23403. return nil
  23404. case sopstage.FieldIndexSort:
  23405. v, ok := value.(int)
  23406. if !ok {
  23407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23408. }
  23409. m.AddIndexSort(v)
  23410. return nil
  23411. }
  23412. return fmt.Errorf("unknown SopStage numeric field %s", name)
  23413. }
  23414. // ClearedFields returns all nullable fields that were cleared during this
  23415. // mutation.
  23416. func (m *SopStageMutation) ClearedFields() []string {
  23417. var fields []string
  23418. if m.FieldCleared(sopstage.FieldStatus) {
  23419. fields = append(fields, sopstage.FieldStatus)
  23420. }
  23421. if m.FieldCleared(sopstage.FieldDeletedAt) {
  23422. fields = append(fields, sopstage.FieldDeletedAt)
  23423. }
  23424. if m.FieldCleared(sopstage.FieldActionMessage) {
  23425. fields = append(fields, sopstage.FieldActionMessage)
  23426. }
  23427. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  23428. fields = append(fields, sopstage.FieldActionLabelAdd)
  23429. }
  23430. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  23431. fields = append(fields, sopstage.FieldActionLabelDel)
  23432. }
  23433. if m.FieldCleared(sopstage.FieldActionForward) {
  23434. fields = append(fields, sopstage.FieldActionForward)
  23435. }
  23436. if m.FieldCleared(sopstage.FieldIndexSort) {
  23437. fields = append(fields, sopstage.FieldIndexSort)
  23438. }
  23439. return fields
  23440. }
  23441. // FieldCleared returns a boolean indicating if a field with the given name was
  23442. // cleared in this mutation.
  23443. func (m *SopStageMutation) FieldCleared(name string) bool {
  23444. _, ok := m.clearedFields[name]
  23445. return ok
  23446. }
  23447. // ClearField clears the value of the field with the given name. It returns an
  23448. // error if the field is not defined in the schema.
  23449. func (m *SopStageMutation) ClearField(name string) error {
  23450. switch name {
  23451. case sopstage.FieldStatus:
  23452. m.ClearStatus()
  23453. return nil
  23454. case sopstage.FieldDeletedAt:
  23455. m.ClearDeletedAt()
  23456. return nil
  23457. case sopstage.FieldActionMessage:
  23458. m.ClearActionMessage()
  23459. return nil
  23460. case sopstage.FieldActionLabelAdd:
  23461. m.ClearActionLabelAdd()
  23462. return nil
  23463. case sopstage.FieldActionLabelDel:
  23464. m.ClearActionLabelDel()
  23465. return nil
  23466. case sopstage.FieldActionForward:
  23467. m.ClearActionForward()
  23468. return nil
  23469. case sopstage.FieldIndexSort:
  23470. m.ClearIndexSort()
  23471. return nil
  23472. }
  23473. return fmt.Errorf("unknown SopStage nullable field %s", name)
  23474. }
  23475. // ResetField resets all changes in the mutation for the field with the given name.
  23476. // It returns an error if the field is not defined in the schema.
  23477. func (m *SopStageMutation) ResetField(name string) error {
  23478. switch name {
  23479. case sopstage.FieldCreatedAt:
  23480. m.ResetCreatedAt()
  23481. return nil
  23482. case sopstage.FieldUpdatedAt:
  23483. m.ResetUpdatedAt()
  23484. return nil
  23485. case sopstage.FieldStatus:
  23486. m.ResetStatus()
  23487. return nil
  23488. case sopstage.FieldDeletedAt:
  23489. m.ResetDeletedAt()
  23490. return nil
  23491. case sopstage.FieldTaskID:
  23492. m.ResetTaskID()
  23493. return nil
  23494. case sopstage.FieldName:
  23495. m.ResetName()
  23496. return nil
  23497. case sopstage.FieldConditionType:
  23498. m.ResetConditionType()
  23499. return nil
  23500. case sopstage.FieldConditionOperator:
  23501. m.ResetConditionOperator()
  23502. return nil
  23503. case sopstage.FieldConditionList:
  23504. m.ResetConditionList()
  23505. return nil
  23506. case sopstage.FieldActionMessage:
  23507. m.ResetActionMessage()
  23508. return nil
  23509. case sopstage.FieldActionLabelAdd:
  23510. m.ResetActionLabelAdd()
  23511. return nil
  23512. case sopstage.FieldActionLabelDel:
  23513. m.ResetActionLabelDel()
  23514. return nil
  23515. case sopstage.FieldActionForward:
  23516. m.ResetActionForward()
  23517. return nil
  23518. case sopstage.FieldIndexSort:
  23519. m.ResetIndexSort()
  23520. return nil
  23521. }
  23522. return fmt.Errorf("unknown SopStage field %s", name)
  23523. }
  23524. // AddedEdges returns all edge names that were set/added in this mutation.
  23525. func (m *SopStageMutation) AddedEdges() []string {
  23526. edges := make([]string, 0, 3)
  23527. if m.sop_task != nil {
  23528. edges = append(edges, sopstage.EdgeSopTask)
  23529. }
  23530. if m.stage_nodes != nil {
  23531. edges = append(edges, sopstage.EdgeStageNodes)
  23532. }
  23533. if m.stage_messages != nil {
  23534. edges = append(edges, sopstage.EdgeStageMessages)
  23535. }
  23536. return edges
  23537. }
  23538. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23539. // name in this mutation.
  23540. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  23541. switch name {
  23542. case sopstage.EdgeSopTask:
  23543. if id := m.sop_task; id != nil {
  23544. return []ent.Value{*id}
  23545. }
  23546. case sopstage.EdgeStageNodes:
  23547. ids := make([]ent.Value, 0, len(m.stage_nodes))
  23548. for id := range m.stage_nodes {
  23549. ids = append(ids, id)
  23550. }
  23551. return ids
  23552. case sopstage.EdgeStageMessages:
  23553. ids := make([]ent.Value, 0, len(m.stage_messages))
  23554. for id := range m.stage_messages {
  23555. ids = append(ids, id)
  23556. }
  23557. return ids
  23558. }
  23559. return nil
  23560. }
  23561. // RemovedEdges returns all edge names that were removed in this mutation.
  23562. func (m *SopStageMutation) RemovedEdges() []string {
  23563. edges := make([]string, 0, 3)
  23564. if m.removedstage_nodes != nil {
  23565. edges = append(edges, sopstage.EdgeStageNodes)
  23566. }
  23567. if m.removedstage_messages != nil {
  23568. edges = append(edges, sopstage.EdgeStageMessages)
  23569. }
  23570. return edges
  23571. }
  23572. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23573. // the given name in this mutation.
  23574. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  23575. switch name {
  23576. case sopstage.EdgeStageNodes:
  23577. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  23578. for id := range m.removedstage_nodes {
  23579. ids = append(ids, id)
  23580. }
  23581. return ids
  23582. case sopstage.EdgeStageMessages:
  23583. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  23584. for id := range m.removedstage_messages {
  23585. ids = append(ids, id)
  23586. }
  23587. return ids
  23588. }
  23589. return nil
  23590. }
  23591. // ClearedEdges returns all edge names that were cleared in this mutation.
  23592. func (m *SopStageMutation) ClearedEdges() []string {
  23593. edges := make([]string, 0, 3)
  23594. if m.clearedsop_task {
  23595. edges = append(edges, sopstage.EdgeSopTask)
  23596. }
  23597. if m.clearedstage_nodes {
  23598. edges = append(edges, sopstage.EdgeStageNodes)
  23599. }
  23600. if m.clearedstage_messages {
  23601. edges = append(edges, sopstage.EdgeStageMessages)
  23602. }
  23603. return edges
  23604. }
  23605. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23606. // was cleared in this mutation.
  23607. func (m *SopStageMutation) EdgeCleared(name string) bool {
  23608. switch name {
  23609. case sopstage.EdgeSopTask:
  23610. return m.clearedsop_task
  23611. case sopstage.EdgeStageNodes:
  23612. return m.clearedstage_nodes
  23613. case sopstage.EdgeStageMessages:
  23614. return m.clearedstage_messages
  23615. }
  23616. return false
  23617. }
  23618. // ClearEdge clears the value of the edge with the given name. It returns an error
  23619. // if that edge is not defined in the schema.
  23620. func (m *SopStageMutation) ClearEdge(name string) error {
  23621. switch name {
  23622. case sopstage.EdgeSopTask:
  23623. m.ClearSopTask()
  23624. return nil
  23625. }
  23626. return fmt.Errorf("unknown SopStage unique edge %s", name)
  23627. }
  23628. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23629. // It returns an error if the edge is not defined in the schema.
  23630. func (m *SopStageMutation) ResetEdge(name string) error {
  23631. switch name {
  23632. case sopstage.EdgeSopTask:
  23633. m.ResetSopTask()
  23634. return nil
  23635. case sopstage.EdgeStageNodes:
  23636. m.ResetStageNodes()
  23637. return nil
  23638. case sopstage.EdgeStageMessages:
  23639. m.ResetStageMessages()
  23640. return nil
  23641. }
  23642. return fmt.Errorf("unknown SopStage edge %s", name)
  23643. }
  23644. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  23645. type SopTaskMutation struct {
  23646. config
  23647. op Op
  23648. typ string
  23649. id *uint64
  23650. created_at *time.Time
  23651. updated_at *time.Time
  23652. status *uint8
  23653. addstatus *int8
  23654. deleted_at *time.Time
  23655. name *string
  23656. bot_wxid_list *[]string
  23657. appendbot_wxid_list []string
  23658. _type *int
  23659. add_type *int
  23660. plan_start_time *time.Time
  23661. plan_end_time *time.Time
  23662. creator_id *string
  23663. organization_id *uint64
  23664. addorganization_id *int64
  23665. token *[]string
  23666. appendtoken []string
  23667. clearedFields map[string]struct{}
  23668. task_stages map[uint64]struct{}
  23669. removedtask_stages map[uint64]struct{}
  23670. clearedtask_stages bool
  23671. done bool
  23672. oldValue func(context.Context) (*SopTask, error)
  23673. predicates []predicate.SopTask
  23674. }
  23675. var _ ent.Mutation = (*SopTaskMutation)(nil)
  23676. // soptaskOption allows management of the mutation configuration using functional options.
  23677. type soptaskOption func(*SopTaskMutation)
  23678. // newSopTaskMutation creates new mutation for the SopTask entity.
  23679. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  23680. m := &SopTaskMutation{
  23681. config: c,
  23682. op: op,
  23683. typ: TypeSopTask,
  23684. clearedFields: make(map[string]struct{}),
  23685. }
  23686. for _, opt := range opts {
  23687. opt(m)
  23688. }
  23689. return m
  23690. }
  23691. // withSopTaskID sets the ID field of the mutation.
  23692. func withSopTaskID(id uint64) soptaskOption {
  23693. return func(m *SopTaskMutation) {
  23694. var (
  23695. err error
  23696. once sync.Once
  23697. value *SopTask
  23698. )
  23699. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  23700. once.Do(func() {
  23701. if m.done {
  23702. err = errors.New("querying old values post mutation is not allowed")
  23703. } else {
  23704. value, err = m.Client().SopTask.Get(ctx, id)
  23705. }
  23706. })
  23707. return value, err
  23708. }
  23709. m.id = &id
  23710. }
  23711. }
  23712. // withSopTask sets the old SopTask of the mutation.
  23713. func withSopTask(node *SopTask) soptaskOption {
  23714. return func(m *SopTaskMutation) {
  23715. m.oldValue = func(context.Context) (*SopTask, error) {
  23716. return node, nil
  23717. }
  23718. m.id = &node.ID
  23719. }
  23720. }
  23721. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23722. // executed in a transaction (ent.Tx), a transactional client is returned.
  23723. func (m SopTaskMutation) Client() *Client {
  23724. client := &Client{config: m.config}
  23725. client.init()
  23726. return client
  23727. }
  23728. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23729. // it returns an error otherwise.
  23730. func (m SopTaskMutation) Tx() (*Tx, error) {
  23731. if _, ok := m.driver.(*txDriver); !ok {
  23732. return nil, errors.New("ent: mutation is not running in a transaction")
  23733. }
  23734. tx := &Tx{config: m.config}
  23735. tx.init()
  23736. return tx, nil
  23737. }
  23738. // SetID sets the value of the id field. Note that this
  23739. // operation is only accepted on creation of SopTask entities.
  23740. func (m *SopTaskMutation) SetID(id uint64) {
  23741. m.id = &id
  23742. }
  23743. // ID returns the ID value in the mutation. Note that the ID is only available
  23744. // if it was provided to the builder or after it was returned from the database.
  23745. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  23746. if m.id == nil {
  23747. return
  23748. }
  23749. return *m.id, true
  23750. }
  23751. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23752. // That means, if the mutation is applied within a transaction with an isolation level such
  23753. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23754. // or updated by the mutation.
  23755. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  23756. switch {
  23757. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23758. id, exists := m.ID()
  23759. if exists {
  23760. return []uint64{id}, nil
  23761. }
  23762. fallthrough
  23763. case m.op.Is(OpUpdate | OpDelete):
  23764. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  23765. default:
  23766. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23767. }
  23768. }
  23769. // SetCreatedAt sets the "created_at" field.
  23770. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  23771. m.created_at = &t
  23772. }
  23773. // CreatedAt returns the value of the "created_at" field in the mutation.
  23774. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  23775. v := m.created_at
  23776. if v == nil {
  23777. return
  23778. }
  23779. return *v, true
  23780. }
  23781. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  23782. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23784. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23785. if !m.op.Is(OpUpdateOne) {
  23786. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23787. }
  23788. if m.id == nil || m.oldValue == nil {
  23789. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23790. }
  23791. oldValue, err := m.oldValue(ctx)
  23792. if err != nil {
  23793. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23794. }
  23795. return oldValue.CreatedAt, nil
  23796. }
  23797. // ResetCreatedAt resets all changes to the "created_at" field.
  23798. func (m *SopTaskMutation) ResetCreatedAt() {
  23799. m.created_at = nil
  23800. }
  23801. // SetUpdatedAt sets the "updated_at" field.
  23802. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  23803. m.updated_at = &t
  23804. }
  23805. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23806. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  23807. v := m.updated_at
  23808. if v == nil {
  23809. return
  23810. }
  23811. return *v, true
  23812. }
  23813. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  23814. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23816. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23817. if !m.op.Is(OpUpdateOne) {
  23818. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23819. }
  23820. if m.id == nil || m.oldValue == nil {
  23821. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23822. }
  23823. oldValue, err := m.oldValue(ctx)
  23824. if err != nil {
  23825. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23826. }
  23827. return oldValue.UpdatedAt, nil
  23828. }
  23829. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23830. func (m *SopTaskMutation) ResetUpdatedAt() {
  23831. m.updated_at = nil
  23832. }
  23833. // SetStatus sets the "status" field.
  23834. func (m *SopTaskMutation) SetStatus(u uint8) {
  23835. m.status = &u
  23836. m.addstatus = nil
  23837. }
  23838. // Status returns the value of the "status" field in the mutation.
  23839. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  23840. v := m.status
  23841. if v == nil {
  23842. return
  23843. }
  23844. return *v, true
  23845. }
  23846. // OldStatus returns the old "status" field's value of the SopTask entity.
  23847. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23849. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23850. if !m.op.Is(OpUpdateOne) {
  23851. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23852. }
  23853. if m.id == nil || m.oldValue == nil {
  23854. return v, errors.New("OldStatus requires an ID field in the mutation")
  23855. }
  23856. oldValue, err := m.oldValue(ctx)
  23857. if err != nil {
  23858. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23859. }
  23860. return oldValue.Status, nil
  23861. }
  23862. // AddStatus adds u to the "status" field.
  23863. func (m *SopTaskMutation) AddStatus(u int8) {
  23864. if m.addstatus != nil {
  23865. *m.addstatus += u
  23866. } else {
  23867. m.addstatus = &u
  23868. }
  23869. }
  23870. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23871. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  23872. v := m.addstatus
  23873. if v == nil {
  23874. return
  23875. }
  23876. return *v, true
  23877. }
  23878. // ClearStatus clears the value of the "status" field.
  23879. func (m *SopTaskMutation) ClearStatus() {
  23880. m.status = nil
  23881. m.addstatus = nil
  23882. m.clearedFields[soptask.FieldStatus] = struct{}{}
  23883. }
  23884. // StatusCleared returns if the "status" field was cleared in this mutation.
  23885. func (m *SopTaskMutation) StatusCleared() bool {
  23886. _, ok := m.clearedFields[soptask.FieldStatus]
  23887. return ok
  23888. }
  23889. // ResetStatus resets all changes to the "status" field.
  23890. func (m *SopTaskMutation) ResetStatus() {
  23891. m.status = nil
  23892. m.addstatus = nil
  23893. delete(m.clearedFields, soptask.FieldStatus)
  23894. }
  23895. // SetDeletedAt sets the "deleted_at" field.
  23896. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  23897. m.deleted_at = &t
  23898. }
  23899. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23900. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  23901. v := m.deleted_at
  23902. if v == nil {
  23903. return
  23904. }
  23905. return *v, true
  23906. }
  23907. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  23908. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23910. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23911. if !m.op.Is(OpUpdateOne) {
  23912. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23913. }
  23914. if m.id == nil || m.oldValue == nil {
  23915. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23916. }
  23917. oldValue, err := m.oldValue(ctx)
  23918. if err != nil {
  23919. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23920. }
  23921. return oldValue.DeletedAt, nil
  23922. }
  23923. // ClearDeletedAt clears the value of the "deleted_at" field.
  23924. func (m *SopTaskMutation) ClearDeletedAt() {
  23925. m.deleted_at = nil
  23926. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  23927. }
  23928. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23929. func (m *SopTaskMutation) DeletedAtCleared() bool {
  23930. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  23931. return ok
  23932. }
  23933. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23934. func (m *SopTaskMutation) ResetDeletedAt() {
  23935. m.deleted_at = nil
  23936. delete(m.clearedFields, soptask.FieldDeletedAt)
  23937. }
  23938. // SetName sets the "name" field.
  23939. func (m *SopTaskMutation) SetName(s string) {
  23940. m.name = &s
  23941. }
  23942. // Name returns the value of the "name" field in the mutation.
  23943. func (m *SopTaskMutation) Name() (r string, exists bool) {
  23944. v := m.name
  23945. if v == nil {
  23946. return
  23947. }
  23948. return *v, true
  23949. }
  23950. // OldName returns the old "name" field's value of the SopTask entity.
  23951. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23953. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  23954. if !m.op.Is(OpUpdateOne) {
  23955. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23956. }
  23957. if m.id == nil || m.oldValue == nil {
  23958. return v, errors.New("OldName requires an ID field in the mutation")
  23959. }
  23960. oldValue, err := m.oldValue(ctx)
  23961. if err != nil {
  23962. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23963. }
  23964. return oldValue.Name, nil
  23965. }
  23966. // ResetName resets all changes to the "name" field.
  23967. func (m *SopTaskMutation) ResetName() {
  23968. m.name = nil
  23969. }
  23970. // SetBotWxidList sets the "bot_wxid_list" field.
  23971. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  23972. m.bot_wxid_list = &s
  23973. m.appendbot_wxid_list = nil
  23974. }
  23975. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  23976. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  23977. v := m.bot_wxid_list
  23978. if v == nil {
  23979. return
  23980. }
  23981. return *v, true
  23982. }
  23983. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  23984. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23986. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  23987. if !m.op.Is(OpUpdateOne) {
  23988. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  23989. }
  23990. if m.id == nil || m.oldValue == nil {
  23991. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  23992. }
  23993. oldValue, err := m.oldValue(ctx)
  23994. if err != nil {
  23995. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  23996. }
  23997. return oldValue.BotWxidList, nil
  23998. }
  23999. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  24000. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  24001. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  24002. }
  24003. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  24004. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  24005. if len(m.appendbot_wxid_list) == 0 {
  24006. return nil, false
  24007. }
  24008. return m.appendbot_wxid_list, true
  24009. }
  24010. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  24011. func (m *SopTaskMutation) ClearBotWxidList() {
  24012. m.bot_wxid_list = nil
  24013. m.appendbot_wxid_list = nil
  24014. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  24015. }
  24016. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  24017. func (m *SopTaskMutation) BotWxidListCleared() bool {
  24018. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  24019. return ok
  24020. }
  24021. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  24022. func (m *SopTaskMutation) ResetBotWxidList() {
  24023. m.bot_wxid_list = nil
  24024. m.appendbot_wxid_list = nil
  24025. delete(m.clearedFields, soptask.FieldBotWxidList)
  24026. }
  24027. // SetType sets the "type" field.
  24028. func (m *SopTaskMutation) SetType(i int) {
  24029. m._type = &i
  24030. m.add_type = nil
  24031. }
  24032. // GetType returns the value of the "type" field in the mutation.
  24033. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  24034. v := m._type
  24035. if v == nil {
  24036. return
  24037. }
  24038. return *v, true
  24039. }
  24040. // OldType returns the old "type" field's value of the SopTask entity.
  24041. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24043. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  24044. if !m.op.Is(OpUpdateOne) {
  24045. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24046. }
  24047. if m.id == nil || m.oldValue == nil {
  24048. return v, errors.New("OldType requires an ID field in the mutation")
  24049. }
  24050. oldValue, err := m.oldValue(ctx)
  24051. if err != nil {
  24052. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24053. }
  24054. return oldValue.Type, nil
  24055. }
  24056. // AddType adds i to the "type" field.
  24057. func (m *SopTaskMutation) AddType(i int) {
  24058. if m.add_type != nil {
  24059. *m.add_type += i
  24060. } else {
  24061. m.add_type = &i
  24062. }
  24063. }
  24064. // AddedType returns the value that was added to the "type" field in this mutation.
  24065. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  24066. v := m.add_type
  24067. if v == nil {
  24068. return
  24069. }
  24070. return *v, true
  24071. }
  24072. // ResetType resets all changes to the "type" field.
  24073. func (m *SopTaskMutation) ResetType() {
  24074. m._type = nil
  24075. m.add_type = nil
  24076. }
  24077. // SetPlanStartTime sets the "plan_start_time" field.
  24078. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  24079. m.plan_start_time = &t
  24080. }
  24081. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  24082. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  24083. v := m.plan_start_time
  24084. if v == nil {
  24085. return
  24086. }
  24087. return *v, true
  24088. }
  24089. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  24090. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24092. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  24093. if !m.op.Is(OpUpdateOne) {
  24094. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  24095. }
  24096. if m.id == nil || m.oldValue == nil {
  24097. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  24098. }
  24099. oldValue, err := m.oldValue(ctx)
  24100. if err != nil {
  24101. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  24102. }
  24103. return oldValue.PlanStartTime, nil
  24104. }
  24105. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  24106. func (m *SopTaskMutation) ClearPlanStartTime() {
  24107. m.plan_start_time = nil
  24108. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  24109. }
  24110. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  24111. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  24112. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  24113. return ok
  24114. }
  24115. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  24116. func (m *SopTaskMutation) ResetPlanStartTime() {
  24117. m.plan_start_time = nil
  24118. delete(m.clearedFields, soptask.FieldPlanStartTime)
  24119. }
  24120. // SetPlanEndTime sets the "plan_end_time" field.
  24121. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  24122. m.plan_end_time = &t
  24123. }
  24124. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  24125. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  24126. v := m.plan_end_time
  24127. if v == nil {
  24128. return
  24129. }
  24130. return *v, true
  24131. }
  24132. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  24133. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24135. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  24136. if !m.op.Is(OpUpdateOne) {
  24137. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  24138. }
  24139. if m.id == nil || m.oldValue == nil {
  24140. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  24141. }
  24142. oldValue, err := m.oldValue(ctx)
  24143. if err != nil {
  24144. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  24145. }
  24146. return oldValue.PlanEndTime, nil
  24147. }
  24148. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  24149. func (m *SopTaskMutation) ClearPlanEndTime() {
  24150. m.plan_end_time = nil
  24151. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  24152. }
  24153. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  24154. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  24155. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  24156. return ok
  24157. }
  24158. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  24159. func (m *SopTaskMutation) ResetPlanEndTime() {
  24160. m.plan_end_time = nil
  24161. delete(m.clearedFields, soptask.FieldPlanEndTime)
  24162. }
  24163. // SetCreatorID sets the "creator_id" field.
  24164. func (m *SopTaskMutation) SetCreatorID(s string) {
  24165. m.creator_id = &s
  24166. }
  24167. // CreatorID returns the value of the "creator_id" field in the mutation.
  24168. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  24169. v := m.creator_id
  24170. if v == nil {
  24171. return
  24172. }
  24173. return *v, true
  24174. }
  24175. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  24176. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24178. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  24179. if !m.op.Is(OpUpdateOne) {
  24180. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  24181. }
  24182. if m.id == nil || m.oldValue == nil {
  24183. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  24184. }
  24185. oldValue, err := m.oldValue(ctx)
  24186. if err != nil {
  24187. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  24188. }
  24189. return oldValue.CreatorID, nil
  24190. }
  24191. // ClearCreatorID clears the value of the "creator_id" field.
  24192. func (m *SopTaskMutation) ClearCreatorID() {
  24193. m.creator_id = nil
  24194. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  24195. }
  24196. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  24197. func (m *SopTaskMutation) CreatorIDCleared() bool {
  24198. _, ok := m.clearedFields[soptask.FieldCreatorID]
  24199. return ok
  24200. }
  24201. // ResetCreatorID resets all changes to the "creator_id" field.
  24202. func (m *SopTaskMutation) ResetCreatorID() {
  24203. m.creator_id = nil
  24204. delete(m.clearedFields, soptask.FieldCreatorID)
  24205. }
  24206. // SetOrganizationID sets the "organization_id" field.
  24207. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  24208. m.organization_id = &u
  24209. m.addorganization_id = nil
  24210. }
  24211. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24212. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  24213. v := m.organization_id
  24214. if v == nil {
  24215. return
  24216. }
  24217. return *v, true
  24218. }
  24219. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  24220. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24222. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24223. if !m.op.Is(OpUpdateOne) {
  24224. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24225. }
  24226. if m.id == nil || m.oldValue == nil {
  24227. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24228. }
  24229. oldValue, err := m.oldValue(ctx)
  24230. if err != nil {
  24231. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24232. }
  24233. return oldValue.OrganizationID, nil
  24234. }
  24235. // AddOrganizationID adds u to the "organization_id" field.
  24236. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  24237. if m.addorganization_id != nil {
  24238. *m.addorganization_id += u
  24239. } else {
  24240. m.addorganization_id = &u
  24241. }
  24242. }
  24243. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24244. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  24245. v := m.addorganization_id
  24246. if v == nil {
  24247. return
  24248. }
  24249. return *v, true
  24250. }
  24251. // ClearOrganizationID clears the value of the "organization_id" field.
  24252. func (m *SopTaskMutation) ClearOrganizationID() {
  24253. m.organization_id = nil
  24254. m.addorganization_id = nil
  24255. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  24256. }
  24257. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24258. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  24259. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  24260. return ok
  24261. }
  24262. // ResetOrganizationID resets all changes to the "organization_id" field.
  24263. func (m *SopTaskMutation) ResetOrganizationID() {
  24264. m.organization_id = nil
  24265. m.addorganization_id = nil
  24266. delete(m.clearedFields, soptask.FieldOrganizationID)
  24267. }
  24268. // SetToken sets the "token" field.
  24269. func (m *SopTaskMutation) SetToken(s []string) {
  24270. m.token = &s
  24271. m.appendtoken = nil
  24272. }
  24273. // Token returns the value of the "token" field in the mutation.
  24274. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  24275. v := m.token
  24276. if v == nil {
  24277. return
  24278. }
  24279. return *v, true
  24280. }
  24281. // OldToken returns the old "token" field's value of the SopTask entity.
  24282. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24284. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  24285. if !m.op.Is(OpUpdateOne) {
  24286. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24287. }
  24288. if m.id == nil || m.oldValue == nil {
  24289. return v, errors.New("OldToken requires an ID field in the mutation")
  24290. }
  24291. oldValue, err := m.oldValue(ctx)
  24292. if err != nil {
  24293. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  24294. }
  24295. return oldValue.Token, nil
  24296. }
  24297. // AppendToken adds s to the "token" field.
  24298. func (m *SopTaskMutation) AppendToken(s []string) {
  24299. m.appendtoken = append(m.appendtoken, s...)
  24300. }
  24301. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  24302. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  24303. if len(m.appendtoken) == 0 {
  24304. return nil, false
  24305. }
  24306. return m.appendtoken, true
  24307. }
  24308. // ClearToken clears the value of the "token" field.
  24309. func (m *SopTaskMutation) ClearToken() {
  24310. m.token = nil
  24311. m.appendtoken = nil
  24312. m.clearedFields[soptask.FieldToken] = struct{}{}
  24313. }
  24314. // TokenCleared returns if the "token" field was cleared in this mutation.
  24315. func (m *SopTaskMutation) TokenCleared() bool {
  24316. _, ok := m.clearedFields[soptask.FieldToken]
  24317. return ok
  24318. }
  24319. // ResetToken resets all changes to the "token" field.
  24320. func (m *SopTaskMutation) ResetToken() {
  24321. m.token = nil
  24322. m.appendtoken = nil
  24323. delete(m.clearedFields, soptask.FieldToken)
  24324. }
  24325. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  24326. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  24327. if m.task_stages == nil {
  24328. m.task_stages = make(map[uint64]struct{})
  24329. }
  24330. for i := range ids {
  24331. m.task_stages[ids[i]] = struct{}{}
  24332. }
  24333. }
  24334. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  24335. func (m *SopTaskMutation) ClearTaskStages() {
  24336. m.clearedtask_stages = true
  24337. }
  24338. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  24339. func (m *SopTaskMutation) TaskStagesCleared() bool {
  24340. return m.clearedtask_stages
  24341. }
  24342. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  24343. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  24344. if m.removedtask_stages == nil {
  24345. m.removedtask_stages = make(map[uint64]struct{})
  24346. }
  24347. for i := range ids {
  24348. delete(m.task_stages, ids[i])
  24349. m.removedtask_stages[ids[i]] = struct{}{}
  24350. }
  24351. }
  24352. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  24353. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  24354. for id := range m.removedtask_stages {
  24355. ids = append(ids, id)
  24356. }
  24357. return
  24358. }
  24359. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  24360. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  24361. for id := range m.task_stages {
  24362. ids = append(ids, id)
  24363. }
  24364. return
  24365. }
  24366. // ResetTaskStages resets all changes to the "task_stages" edge.
  24367. func (m *SopTaskMutation) ResetTaskStages() {
  24368. m.task_stages = nil
  24369. m.clearedtask_stages = false
  24370. m.removedtask_stages = nil
  24371. }
  24372. // Where appends a list predicates to the SopTaskMutation builder.
  24373. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  24374. m.predicates = append(m.predicates, ps...)
  24375. }
  24376. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  24377. // users can use type-assertion to append predicates that do not depend on any generated package.
  24378. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  24379. p := make([]predicate.SopTask, len(ps))
  24380. for i := range ps {
  24381. p[i] = ps[i]
  24382. }
  24383. m.Where(p...)
  24384. }
  24385. // Op returns the operation name.
  24386. func (m *SopTaskMutation) Op() Op {
  24387. return m.op
  24388. }
  24389. // SetOp allows setting the mutation operation.
  24390. func (m *SopTaskMutation) SetOp(op Op) {
  24391. m.op = op
  24392. }
  24393. // Type returns the node type of this mutation (SopTask).
  24394. func (m *SopTaskMutation) Type() string {
  24395. return m.typ
  24396. }
  24397. // Fields returns all fields that were changed during this mutation. Note that in
  24398. // order to get all numeric fields that were incremented/decremented, call
  24399. // AddedFields().
  24400. func (m *SopTaskMutation) Fields() []string {
  24401. fields := make([]string, 0, 12)
  24402. if m.created_at != nil {
  24403. fields = append(fields, soptask.FieldCreatedAt)
  24404. }
  24405. if m.updated_at != nil {
  24406. fields = append(fields, soptask.FieldUpdatedAt)
  24407. }
  24408. if m.status != nil {
  24409. fields = append(fields, soptask.FieldStatus)
  24410. }
  24411. if m.deleted_at != nil {
  24412. fields = append(fields, soptask.FieldDeletedAt)
  24413. }
  24414. if m.name != nil {
  24415. fields = append(fields, soptask.FieldName)
  24416. }
  24417. if m.bot_wxid_list != nil {
  24418. fields = append(fields, soptask.FieldBotWxidList)
  24419. }
  24420. if m._type != nil {
  24421. fields = append(fields, soptask.FieldType)
  24422. }
  24423. if m.plan_start_time != nil {
  24424. fields = append(fields, soptask.FieldPlanStartTime)
  24425. }
  24426. if m.plan_end_time != nil {
  24427. fields = append(fields, soptask.FieldPlanEndTime)
  24428. }
  24429. if m.creator_id != nil {
  24430. fields = append(fields, soptask.FieldCreatorID)
  24431. }
  24432. if m.organization_id != nil {
  24433. fields = append(fields, soptask.FieldOrganizationID)
  24434. }
  24435. if m.token != nil {
  24436. fields = append(fields, soptask.FieldToken)
  24437. }
  24438. return fields
  24439. }
  24440. // Field returns the value of a field with the given name. The second boolean
  24441. // return value indicates that this field was not set, or was not defined in the
  24442. // schema.
  24443. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  24444. switch name {
  24445. case soptask.FieldCreatedAt:
  24446. return m.CreatedAt()
  24447. case soptask.FieldUpdatedAt:
  24448. return m.UpdatedAt()
  24449. case soptask.FieldStatus:
  24450. return m.Status()
  24451. case soptask.FieldDeletedAt:
  24452. return m.DeletedAt()
  24453. case soptask.FieldName:
  24454. return m.Name()
  24455. case soptask.FieldBotWxidList:
  24456. return m.BotWxidList()
  24457. case soptask.FieldType:
  24458. return m.GetType()
  24459. case soptask.FieldPlanStartTime:
  24460. return m.PlanStartTime()
  24461. case soptask.FieldPlanEndTime:
  24462. return m.PlanEndTime()
  24463. case soptask.FieldCreatorID:
  24464. return m.CreatorID()
  24465. case soptask.FieldOrganizationID:
  24466. return m.OrganizationID()
  24467. case soptask.FieldToken:
  24468. return m.Token()
  24469. }
  24470. return nil, false
  24471. }
  24472. // OldField returns the old value of the field from the database. An error is
  24473. // returned if the mutation operation is not UpdateOne, or the query to the
  24474. // database failed.
  24475. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24476. switch name {
  24477. case soptask.FieldCreatedAt:
  24478. return m.OldCreatedAt(ctx)
  24479. case soptask.FieldUpdatedAt:
  24480. return m.OldUpdatedAt(ctx)
  24481. case soptask.FieldStatus:
  24482. return m.OldStatus(ctx)
  24483. case soptask.FieldDeletedAt:
  24484. return m.OldDeletedAt(ctx)
  24485. case soptask.FieldName:
  24486. return m.OldName(ctx)
  24487. case soptask.FieldBotWxidList:
  24488. return m.OldBotWxidList(ctx)
  24489. case soptask.FieldType:
  24490. return m.OldType(ctx)
  24491. case soptask.FieldPlanStartTime:
  24492. return m.OldPlanStartTime(ctx)
  24493. case soptask.FieldPlanEndTime:
  24494. return m.OldPlanEndTime(ctx)
  24495. case soptask.FieldCreatorID:
  24496. return m.OldCreatorID(ctx)
  24497. case soptask.FieldOrganizationID:
  24498. return m.OldOrganizationID(ctx)
  24499. case soptask.FieldToken:
  24500. return m.OldToken(ctx)
  24501. }
  24502. return nil, fmt.Errorf("unknown SopTask field %s", name)
  24503. }
  24504. // SetField sets the value of a field with the given name. It returns an error if
  24505. // the field is not defined in the schema, or if the type mismatched the field
  24506. // type.
  24507. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  24508. switch name {
  24509. case soptask.FieldCreatedAt:
  24510. v, ok := value.(time.Time)
  24511. if !ok {
  24512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24513. }
  24514. m.SetCreatedAt(v)
  24515. return nil
  24516. case soptask.FieldUpdatedAt:
  24517. v, ok := value.(time.Time)
  24518. if !ok {
  24519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24520. }
  24521. m.SetUpdatedAt(v)
  24522. return nil
  24523. case soptask.FieldStatus:
  24524. v, ok := value.(uint8)
  24525. if !ok {
  24526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24527. }
  24528. m.SetStatus(v)
  24529. return nil
  24530. case soptask.FieldDeletedAt:
  24531. v, ok := value.(time.Time)
  24532. if !ok {
  24533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24534. }
  24535. m.SetDeletedAt(v)
  24536. return nil
  24537. case soptask.FieldName:
  24538. v, ok := value.(string)
  24539. if !ok {
  24540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24541. }
  24542. m.SetName(v)
  24543. return nil
  24544. case soptask.FieldBotWxidList:
  24545. v, ok := value.([]string)
  24546. if !ok {
  24547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24548. }
  24549. m.SetBotWxidList(v)
  24550. return nil
  24551. case soptask.FieldType:
  24552. v, ok := value.(int)
  24553. if !ok {
  24554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24555. }
  24556. m.SetType(v)
  24557. return nil
  24558. case soptask.FieldPlanStartTime:
  24559. v, ok := value.(time.Time)
  24560. if !ok {
  24561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24562. }
  24563. m.SetPlanStartTime(v)
  24564. return nil
  24565. case soptask.FieldPlanEndTime:
  24566. v, ok := value.(time.Time)
  24567. if !ok {
  24568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24569. }
  24570. m.SetPlanEndTime(v)
  24571. return nil
  24572. case soptask.FieldCreatorID:
  24573. v, ok := value.(string)
  24574. if !ok {
  24575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24576. }
  24577. m.SetCreatorID(v)
  24578. return nil
  24579. case soptask.FieldOrganizationID:
  24580. v, ok := value.(uint64)
  24581. if !ok {
  24582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24583. }
  24584. m.SetOrganizationID(v)
  24585. return nil
  24586. case soptask.FieldToken:
  24587. v, ok := value.([]string)
  24588. if !ok {
  24589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24590. }
  24591. m.SetToken(v)
  24592. return nil
  24593. }
  24594. return fmt.Errorf("unknown SopTask field %s", name)
  24595. }
  24596. // AddedFields returns all numeric fields that were incremented/decremented during
  24597. // this mutation.
  24598. func (m *SopTaskMutation) AddedFields() []string {
  24599. var fields []string
  24600. if m.addstatus != nil {
  24601. fields = append(fields, soptask.FieldStatus)
  24602. }
  24603. if m.add_type != nil {
  24604. fields = append(fields, soptask.FieldType)
  24605. }
  24606. if m.addorganization_id != nil {
  24607. fields = append(fields, soptask.FieldOrganizationID)
  24608. }
  24609. return fields
  24610. }
  24611. // AddedField returns the numeric value that was incremented/decremented on a field
  24612. // with the given name. The second boolean return value indicates that this field
  24613. // was not set, or was not defined in the schema.
  24614. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  24615. switch name {
  24616. case soptask.FieldStatus:
  24617. return m.AddedStatus()
  24618. case soptask.FieldType:
  24619. return m.AddedType()
  24620. case soptask.FieldOrganizationID:
  24621. return m.AddedOrganizationID()
  24622. }
  24623. return nil, false
  24624. }
  24625. // AddField adds the value to the field with the given name. It returns an error if
  24626. // the field is not defined in the schema, or if the type mismatched the field
  24627. // type.
  24628. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  24629. switch name {
  24630. case soptask.FieldStatus:
  24631. v, ok := value.(int8)
  24632. if !ok {
  24633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24634. }
  24635. m.AddStatus(v)
  24636. return nil
  24637. case soptask.FieldType:
  24638. v, ok := value.(int)
  24639. if !ok {
  24640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24641. }
  24642. m.AddType(v)
  24643. return nil
  24644. case soptask.FieldOrganizationID:
  24645. v, ok := value.(int64)
  24646. if !ok {
  24647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24648. }
  24649. m.AddOrganizationID(v)
  24650. return nil
  24651. }
  24652. return fmt.Errorf("unknown SopTask numeric field %s", name)
  24653. }
  24654. // ClearedFields returns all nullable fields that were cleared during this
  24655. // mutation.
  24656. func (m *SopTaskMutation) ClearedFields() []string {
  24657. var fields []string
  24658. if m.FieldCleared(soptask.FieldStatus) {
  24659. fields = append(fields, soptask.FieldStatus)
  24660. }
  24661. if m.FieldCleared(soptask.FieldDeletedAt) {
  24662. fields = append(fields, soptask.FieldDeletedAt)
  24663. }
  24664. if m.FieldCleared(soptask.FieldBotWxidList) {
  24665. fields = append(fields, soptask.FieldBotWxidList)
  24666. }
  24667. if m.FieldCleared(soptask.FieldPlanStartTime) {
  24668. fields = append(fields, soptask.FieldPlanStartTime)
  24669. }
  24670. if m.FieldCleared(soptask.FieldPlanEndTime) {
  24671. fields = append(fields, soptask.FieldPlanEndTime)
  24672. }
  24673. if m.FieldCleared(soptask.FieldCreatorID) {
  24674. fields = append(fields, soptask.FieldCreatorID)
  24675. }
  24676. if m.FieldCleared(soptask.FieldOrganizationID) {
  24677. fields = append(fields, soptask.FieldOrganizationID)
  24678. }
  24679. if m.FieldCleared(soptask.FieldToken) {
  24680. fields = append(fields, soptask.FieldToken)
  24681. }
  24682. return fields
  24683. }
  24684. // FieldCleared returns a boolean indicating if a field with the given name was
  24685. // cleared in this mutation.
  24686. func (m *SopTaskMutation) FieldCleared(name string) bool {
  24687. _, ok := m.clearedFields[name]
  24688. return ok
  24689. }
  24690. // ClearField clears the value of the field with the given name. It returns an
  24691. // error if the field is not defined in the schema.
  24692. func (m *SopTaskMutation) ClearField(name string) error {
  24693. switch name {
  24694. case soptask.FieldStatus:
  24695. m.ClearStatus()
  24696. return nil
  24697. case soptask.FieldDeletedAt:
  24698. m.ClearDeletedAt()
  24699. return nil
  24700. case soptask.FieldBotWxidList:
  24701. m.ClearBotWxidList()
  24702. return nil
  24703. case soptask.FieldPlanStartTime:
  24704. m.ClearPlanStartTime()
  24705. return nil
  24706. case soptask.FieldPlanEndTime:
  24707. m.ClearPlanEndTime()
  24708. return nil
  24709. case soptask.FieldCreatorID:
  24710. m.ClearCreatorID()
  24711. return nil
  24712. case soptask.FieldOrganizationID:
  24713. m.ClearOrganizationID()
  24714. return nil
  24715. case soptask.FieldToken:
  24716. m.ClearToken()
  24717. return nil
  24718. }
  24719. return fmt.Errorf("unknown SopTask nullable field %s", name)
  24720. }
  24721. // ResetField resets all changes in the mutation for the field with the given name.
  24722. // It returns an error if the field is not defined in the schema.
  24723. func (m *SopTaskMutation) ResetField(name string) error {
  24724. switch name {
  24725. case soptask.FieldCreatedAt:
  24726. m.ResetCreatedAt()
  24727. return nil
  24728. case soptask.FieldUpdatedAt:
  24729. m.ResetUpdatedAt()
  24730. return nil
  24731. case soptask.FieldStatus:
  24732. m.ResetStatus()
  24733. return nil
  24734. case soptask.FieldDeletedAt:
  24735. m.ResetDeletedAt()
  24736. return nil
  24737. case soptask.FieldName:
  24738. m.ResetName()
  24739. return nil
  24740. case soptask.FieldBotWxidList:
  24741. m.ResetBotWxidList()
  24742. return nil
  24743. case soptask.FieldType:
  24744. m.ResetType()
  24745. return nil
  24746. case soptask.FieldPlanStartTime:
  24747. m.ResetPlanStartTime()
  24748. return nil
  24749. case soptask.FieldPlanEndTime:
  24750. m.ResetPlanEndTime()
  24751. return nil
  24752. case soptask.FieldCreatorID:
  24753. m.ResetCreatorID()
  24754. return nil
  24755. case soptask.FieldOrganizationID:
  24756. m.ResetOrganizationID()
  24757. return nil
  24758. case soptask.FieldToken:
  24759. m.ResetToken()
  24760. return nil
  24761. }
  24762. return fmt.Errorf("unknown SopTask field %s", name)
  24763. }
  24764. // AddedEdges returns all edge names that were set/added in this mutation.
  24765. func (m *SopTaskMutation) AddedEdges() []string {
  24766. edges := make([]string, 0, 1)
  24767. if m.task_stages != nil {
  24768. edges = append(edges, soptask.EdgeTaskStages)
  24769. }
  24770. return edges
  24771. }
  24772. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24773. // name in this mutation.
  24774. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  24775. switch name {
  24776. case soptask.EdgeTaskStages:
  24777. ids := make([]ent.Value, 0, len(m.task_stages))
  24778. for id := range m.task_stages {
  24779. ids = append(ids, id)
  24780. }
  24781. return ids
  24782. }
  24783. return nil
  24784. }
  24785. // RemovedEdges returns all edge names that were removed in this mutation.
  24786. func (m *SopTaskMutation) RemovedEdges() []string {
  24787. edges := make([]string, 0, 1)
  24788. if m.removedtask_stages != nil {
  24789. edges = append(edges, soptask.EdgeTaskStages)
  24790. }
  24791. return edges
  24792. }
  24793. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24794. // the given name in this mutation.
  24795. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  24796. switch name {
  24797. case soptask.EdgeTaskStages:
  24798. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  24799. for id := range m.removedtask_stages {
  24800. ids = append(ids, id)
  24801. }
  24802. return ids
  24803. }
  24804. return nil
  24805. }
  24806. // ClearedEdges returns all edge names that were cleared in this mutation.
  24807. func (m *SopTaskMutation) ClearedEdges() []string {
  24808. edges := make([]string, 0, 1)
  24809. if m.clearedtask_stages {
  24810. edges = append(edges, soptask.EdgeTaskStages)
  24811. }
  24812. return edges
  24813. }
  24814. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24815. // was cleared in this mutation.
  24816. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  24817. switch name {
  24818. case soptask.EdgeTaskStages:
  24819. return m.clearedtask_stages
  24820. }
  24821. return false
  24822. }
  24823. // ClearEdge clears the value of the edge with the given name. It returns an error
  24824. // if that edge is not defined in the schema.
  24825. func (m *SopTaskMutation) ClearEdge(name string) error {
  24826. switch name {
  24827. }
  24828. return fmt.Errorf("unknown SopTask unique edge %s", name)
  24829. }
  24830. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24831. // It returns an error if the edge is not defined in the schema.
  24832. func (m *SopTaskMutation) ResetEdge(name string) error {
  24833. switch name {
  24834. case soptask.EdgeTaskStages:
  24835. m.ResetTaskStages()
  24836. return nil
  24837. }
  24838. return fmt.Errorf("unknown SopTask edge %s", name)
  24839. }
  24840. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  24841. type TokenMutation struct {
  24842. config
  24843. op Op
  24844. typ string
  24845. id *uint64
  24846. created_at *time.Time
  24847. updated_at *time.Time
  24848. deleted_at *time.Time
  24849. expire_at *time.Time
  24850. token *string
  24851. mac *string
  24852. organization_id *uint64
  24853. addorganization_id *int64
  24854. custom_agent_base *string
  24855. custom_agent_key *string
  24856. openai_base *string
  24857. openai_key *string
  24858. clearedFields map[string]struct{}
  24859. agent *uint64
  24860. clearedagent bool
  24861. done bool
  24862. oldValue func(context.Context) (*Token, error)
  24863. predicates []predicate.Token
  24864. }
  24865. var _ ent.Mutation = (*TokenMutation)(nil)
  24866. // tokenOption allows management of the mutation configuration using functional options.
  24867. type tokenOption func(*TokenMutation)
  24868. // newTokenMutation creates new mutation for the Token entity.
  24869. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  24870. m := &TokenMutation{
  24871. config: c,
  24872. op: op,
  24873. typ: TypeToken,
  24874. clearedFields: make(map[string]struct{}),
  24875. }
  24876. for _, opt := range opts {
  24877. opt(m)
  24878. }
  24879. return m
  24880. }
  24881. // withTokenID sets the ID field of the mutation.
  24882. func withTokenID(id uint64) tokenOption {
  24883. return func(m *TokenMutation) {
  24884. var (
  24885. err error
  24886. once sync.Once
  24887. value *Token
  24888. )
  24889. m.oldValue = func(ctx context.Context) (*Token, error) {
  24890. once.Do(func() {
  24891. if m.done {
  24892. err = errors.New("querying old values post mutation is not allowed")
  24893. } else {
  24894. value, err = m.Client().Token.Get(ctx, id)
  24895. }
  24896. })
  24897. return value, err
  24898. }
  24899. m.id = &id
  24900. }
  24901. }
  24902. // withToken sets the old Token of the mutation.
  24903. func withToken(node *Token) tokenOption {
  24904. return func(m *TokenMutation) {
  24905. m.oldValue = func(context.Context) (*Token, error) {
  24906. return node, nil
  24907. }
  24908. m.id = &node.ID
  24909. }
  24910. }
  24911. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24912. // executed in a transaction (ent.Tx), a transactional client is returned.
  24913. func (m TokenMutation) Client() *Client {
  24914. client := &Client{config: m.config}
  24915. client.init()
  24916. return client
  24917. }
  24918. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24919. // it returns an error otherwise.
  24920. func (m TokenMutation) Tx() (*Tx, error) {
  24921. if _, ok := m.driver.(*txDriver); !ok {
  24922. return nil, errors.New("ent: mutation is not running in a transaction")
  24923. }
  24924. tx := &Tx{config: m.config}
  24925. tx.init()
  24926. return tx, nil
  24927. }
  24928. // SetID sets the value of the id field. Note that this
  24929. // operation is only accepted on creation of Token entities.
  24930. func (m *TokenMutation) SetID(id uint64) {
  24931. m.id = &id
  24932. }
  24933. // ID returns the ID value in the mutation. Note that the ID is only available
  24934. // if it was provided to the builder or after it was returned from the database.
  24935. func (m *TokenMutation) ID() (id uint64, exists bool) {
  24936. if m.id == nil {
  24937. return
  24938. }
  24939. return *m.id, true
  24940. }
  24941. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24942. // That means, if the mutation is applied within a transaction with an isolation level such
  24943. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24944. // or updated by the mutation.
  24945. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  24946. switch {
  24947. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24948. id, exists := m.ID()
  24949. if exists {
  24950. return []uint64{id}, nil
  24951. }
  24952. fallthrough
  24953. case m.op.Is(OpUpdate | OpDelete):
  24954. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  24955. default:
  24956. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24957. }
  24958. }
  24959. // SetCreatedAt sets the "created_at" field.
  24960. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  24961. m.created_at = &t
  24962. }
  24963. // CreatedAt returns the value of the "created_at" field in the mutation.
  24964. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  24965. v := m.created_at
  24966. if v == nil {
  24967. return
  24968. }
  24969. return *v, true
  24970. }
  24971. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  24972. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24974. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24975. if !m.op.Is(OpUpdateOne) {
  24976. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24977. }
  24978. if m.id == nil || m.oldValue == nil {
  24979. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24980. }
  24981. oldValue, err := m.oldValue(ctx)
  24982. if err != nil {
  24983. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24984. }
  24985. return oldValue.CreatedAt, nil
  24986. }
  24987. // ResetCreatedAt resets all changes to the "created_at" field.
  24988. func (m *TokenMutation) ResetCreatedAt() {
  24989. m.created_at = nil
  24990. }
  24991. // SetUpdatedAt sets the "updated_at" field.
  24992. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  24993. m.updated_at = &t
  24994. }
  24995. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24996. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  24997. v := m.updated_at
  24998. if v == nil {
  24999. return
  25000. }
  25001. return *v, true
  25002. }
  25003. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  25004. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25006. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25007. if !m.op.Is(OpUpdateOne) {
  25008. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25009. }
  25010. if m.id == nil || m.oldValue == nil {
  25011. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25012. }
  25013. oldValue, err := m.oldValue(ctx)
  25014. if err != nil {
  25015. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25016. }
  25017. return oldValue.UpdatedAt, nil
  25018. }
  25019. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25020. func (m *TokenMutation) ResetUpdatedAt() {
  25021. m.updated_at = nil
  25022. }
  25023. // SetDeletedAt sets the "deleted_at" field.
  25024. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  25025. m.deleted_at = &t
  25026. }
  25027. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25028. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  25029. v := m.deleted_at
  25030. if v == nil {
  25031. return
  25032. }
  25033. return *v, true
  25034. }
  25035. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  25036. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25038. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25039. if !m.op.Is(OpUpdateOne) {
  25040. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25041. }
  25042. if m.id == nil || m.oldValue == nil {
  25043. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25044. }
  25045. oldValue, err := m.oldValue(ctx)
  25046. if err != nil {
  25047. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25048. }
  25049. return oldValue.DeletedAt, nil
  25050. }
  25051. // ClearDeletedAt clears the value of the "deleted_at" field.
  25052. func (m *TokenMutation) ClearDeletedAt() {
  25053. m.deleted_at = nil
  25054. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  25055. }
  25056. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25057. func (m *TokenMutation) DeletedAtCleared() bool {
  25058. _, ok := m.clearedFields[token.FieldDeletedAt]
  25059. return ok
  25060. }
  25061. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25062. func (m *TokenMutation) ResetDeletedAt() {
  25063. m.deleted_at = nil
  25064. delete(m.clearedFields, token.FieldDeletedAt)
  25065. }
  25066. // SetExpireAt sets the "expire_at" field.
  25067. func (m *TokenMutation) SetExpireAt(t time.Time) {
  25068. m.expire_at = &t
  25069. }
  25070. // ExpireAt returns the value of the "expire_at" field in the mutation.
  25071. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  25072. v := m.expire_at
  25073. if v == nil {
  25074. return
  25075. }
  25076. return *v, true
  25077. }
  25078. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  25079. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25081. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  25082. if !m.op.Is(OpUpdateOne) {
  25083. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  25084. }
  25085. if m.id == nil || m.oldValue == nil {
  25086. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  25087. }
  25088. oldValue, err := m.oldValue(ctx)
  25089. if err != nil {
  25090. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  25091. }
  25092. return oldValue.ExpireAt, nil
  25093. }
  25094. // ClearExpireAt clears the value of the "expire_at" field.
  25095. func (m *TokenMutation) ClearExpireAt() {
  25096. m.expire_at = nil
  25097. m.clearedFields[token.FieldExpireAt] = struct{}{}
  25098. }
  25099. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  25100. func (m *TokenMutation) ExpireAtCleared() bool {
  25101. _, ok := m.clearedFields[token.FieldExpireAt]
  25102. return ok
  25103. }
  25104. // ResetExpireAt resets all changes to the "expire_at" field.
  25105. func (m *TokenMutation) ResetExpireAt() {
  25106. m.expire_at = nil
  25107. delete(m.clearedFields, token.FieldExpireAt)
  25108. }
  25109. // SetToken sets the "token" field.
  25110. func (m *TokenMutation) SetToken(s string) {
  25111. m.token = &s
  25112. }
  25113. // Token returns the value of the "token" field in the mutation.
  25114. func (m *TokenMutation) Token() (r string, exists bool) {
  25115. v := m.token
  25116. if v == nil {
  25117. return
  25118. }
  25119. return *v, true
  25120. }
  25121. // OldToken returns the old "token" field's value of the Token entity.
  25122. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25124. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  25125. if !m.op.Is(OpUpdateOne) {
  25126. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25127. }
  25128. if m.id == nil || m.oldValue == nil {
  25129. return v, errors.New("OldToken requires an ID field in the mutation")
  25130. }
  25131. oldValue, err := m.oldValue(ctx)
  25132. if err != nil {
  25133. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25134. }
  25135. return oldValue.Token, nil
  25136. }
  25137. // ClearToken clears the value of the "token" field.
  25138. func (m *TokenMutation) ClearToken() {
  25139. m.token = nil
  25140. m.clearedFields[token.FieldToken] = struct{}{}
  25141. }
  25142. // TokenCleared returns if the "token" field was cleared in this mutation.
  25143. func (m *TokenMutation) TokenCleared() bool {
  25144. _, ok := m.clearedFields[token.FieldToken]
  25145. return ok
  25146. }
  25147. // ResetToken resets all changes to the "token" field.
  25148. func (m *TokenMutation) ResetToken() {
  25149. m.token = nil
  25150. delete(m.clearedFields, token.FieldToken)
  25151. }
  25152. // SetMAC sets the "mac" field.
  25153. func (m *TokenMutation) SetMAC(s string) {
  25154. m.mac = &s
  25155. }
  25156. // MAC returns the value of the "mac" field in the mutation.
  25157. func (m *TokenMutation) MAC() (r string, exists bool) {
  25158. v := m.mac
  25159. if v == nil {
  25160. return
  25161. }
  25162. return *v, true
  25163. }
  25164. // OldMAC returns the old "mac" field's value of the Token entity.
  25165. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25167. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  25168. if !m.op.Is(OpUpdateOne) {
  25169. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  25170. }
  25171. if m.id == nil || m.oldValue == nil {
  25172. return v, errors.New("OldMAC requires an ID field in the mutation")
  25173. }
  25174. oldValue, err := m.oldValue(ctx)
  25175. if err != nil {
  25176. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  25177. }
  25178. return oldValue.MAC, nil
  25179. }
  25180. // ClearMAC clears the value of the "mac" field.
  25181. func (m *TokenMutation) ClearMAC() {
  25182. m.mac = nil
  25183. m.clearedFields[token.FieldMAC] = struct{}{}
  25184. }
  25185. // MACCleared returns if the "mac" field was cleared in this mutation.
  25186. func (m *TokenMutation) MACCleared() bool {
  25187. _, ok := m.clearedFields[token.FieldMAC]
  25188. return ok
  25189. }
  25190. // ResetMAC resets all changes to the "mac" field.
  25191. func (m *TokenMutation) ResetMAC() {
  25192. m.mac = nil
  25193. delete(m.clearedFields, token.FieldMAC)
  25194. }
  25195. // SetOrganizationID sets the "organization_id" field.
  25196. func (m *TokenMutation) SetOrganizationID(u uint64) {
  25197. m.organization_id = &u
  25198. m.addorganization_id = nil
  25199. }
  25200. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25201. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  25202. v := m.organization_id
  25203. if v == nil {
  25204. return
  25205. }
  25206. return *v, true
  25207. }
  25208. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  25209. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25211. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25212. if !m.op.Is(OpUpdateOne) {
  25213. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25214. }
  25215. if m.id == nil || m.oldValue == nil {
  25216. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25217. }
  25218. oldValue, err := m.oldValue(ctx)
  25219. if err != nil {
  25220. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25221. }
  25222. return oldValue.OrganizationID, nil
  25223. }
  25224. // AddOrganizationID adds u to the "organization_id" field.
  25225. func (m *TokenMutation) AddOrganizationID(u int64) {
  25226. if m.addorganization_id != nil {
  25227. *m.addorganization_id += u
  25228. } else {
  25229. m.addorganization_id = &u
  25230. }
  25231. }
  25232. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25233. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  25234. v := m.addorganization_id
  25235. if v == nil {
  25236. return
  25237. }
  25238. return *v, true
  25239. }
  25240. // ResetOrganizationID resets all changes to the "organization_id" field.
  25241. func (m *TokenMutation) ResetOrganizationID() {
  25242. m.organization_id = nil
  25243. m.addorganization_id = nil
  25244. }
  25245. // SetAgentID sets the "agent_id" field.
  25246. func (m *TokenMutation) SetAgentID(u uint64) {
  25247. m.agent = &u
  25248. }
  25249. // AgentID returns the value of the "agent_id" field in the mutation.
  25250. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  25251. v := m.agent
  25252. if v == nil {
  25253. return
  25254. }
  25255. return *v, true
  25256. }
  25257. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  25258. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25260. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  25261. if !m.op.Is(OpUpdateOne) {
  25262. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  25263. }
  25264. if m.id == nil || m.oldValue == nil {
  25265. return v, errors.New("OldAgentID requires an ID field in the mutation")
  25266. }
  25267. oldValue, err := m.oldValue(ctx)
  25268. if err != nil {
  25269. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  25270. }
  25271. return oldValue.AgentID, nil
  25272. }
  25273. // ResetAgentID resets all changes to the "agent_id" field.
  25274. func (m *TokenMutation) ResetAgentID() {
  25275. m.agent = nil
  25276. }
  25277. // SetCustomAgentBase sets the "custom_agent_base" field.
  25278. func (m *TokenMutation) SetCustomAgentBase(s string) {
  25279. m.custom_agent_base = &s
  25280. }
  25281. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  25282. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  25283. v := m.custom_agent_base
  25284. if v == nil {
  25285. return
  25286. }
  25287. return *v, true
  25288. }
  25289. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  25290. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25292. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  25293. if !m.op.Is(OpUpdateOne) {
  25294. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  25295. }
  25296. if m.id == nil || m.oldValue == nil {
  25297. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  25298. }
  25299. oldValue, err := m.oldValue(ctx)
  25300. if err != nil {
  25301. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  25302. }
  25303. return oldValue.CustomAgentBase, nil
  25304. }
  25305. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  25306. func (m *TokenMutation) ClearCustomAgentBase() {
  25307. m.custom_agent_base = nil
  25308. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  25309. }
  25310. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  25311. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  25312. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  25313. return ok
  25314. }
  25315. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  25316. func (m *TokenMutation) ResetCustomAgentBase() {
  25317. m.custom_agent_base = nil
  25318. delete(m.clearedFields, token.FieldCustomAgentBase)
  25319. }
  25320. // SetCustomAgentKey sets the "custom_agent_key" field.
  25321. func (m *TokenMutation) SetCustomAgentKey(s string) {
  25322. m.custom_agent_key = &s
  25323. }
  25324. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  25325. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  25326. v := m.custom_agent_key
  25327. if v == nil {
  25328. return
  25329. }
  25330. return *v, true
  25331. }
  25332. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  25333. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25335. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  25336. if !m.op.Is(OpUpdateOne) {
  25337. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  25338. }
  25339. if m.id == nil || m.oldValue == nil {
  25340. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  25341. }
  25342. oldValue, err := m.oldValue(ctx)
  25343. if err != nil {
  25344. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  25345. }
  25346. return oldValue.CustomAgentKey, nil
  25347. }
  25348. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  25349. func (m *TokenMutation) ClearCustomAgentKey() {
  25350. m.custom_agent_key = nil
  25351. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  25352. }
  25353. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  25354. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  25355. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  25356. return ok
  25357. }
  25358. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  25359. func (m *TokenMutation) ResetCustomAgentKey() {
  25360. m.custom_agent_key = nil
  25361. delete(m.clearedFields, token.FieldCustomAgentKey)
  25362. }
  25363. // SetOpenaiBase sets the "openai_base" field.
  25364. func (m *TokenMutation) SetOpenaiBase(s string) {
  25365. m.openai_base = &s
  25366. }
  25367. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  25368. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  25369. v := m.openai_base
  25370. if v == nil {
  25371. return
  25372. }
  25373. return *v, true
  25374. }
  25375. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  25376. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25378. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  25379. if !m.op.Is(OpUpdateOne) {
  25380. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  25381. }
  25382. if m.id == nil || m.oldValue == nil {
  25383. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  25384. }
  25385. oldValue, err := m.oldValue(ctx)
  25386. if err != nil {
  25387. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  25388. }
  25389. return oldValue.OpenaiBase, nil
  25390. }
  25391. // ClearOpenaiBase clears the value of the "openai_base" field.
  25392. func (m *TokenMutation) ClearOpenaiBase() {
  25393. m.openai_base = nil
  25394. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  25395. }
  25396. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  25397. func (m *TokenMutation) OpenaiBaseCleared() bool {
  25398. _, ok := m.clearedFields[token.FieldOpenaiBase]
  25399. return ok
  25400. }
  25401. // ResetOpenaiBase resets all changes to the "openai_base" field.
  25402. func (m *TokenMutation) ResetOpenaiBase() {
  25403. m.openai_base = nil
  25404. delete(m.clearedFields, token.FieldOpenaiBase)
  25405. }
  25406. // SetOpenaiKey sets the "openai_key" field.
  25407. func (m *TokenMutation) SetOpenaiKey(s string) {
  25408. m.openai_key = &s
  25409. }
  25410. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  25411. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  25412. v := m.openai_key
  25413. if v == nil {
  25414. return
  25415. }
  25416. return *v, true
  25417. }
  25418. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  25419. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25421. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  25422. if !m.op.Is(OpUpdateOne) {
  25423. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  25424. }
  25425. if m.id == nil || m.oldValue == nil {
  25426. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  25427. }
  25428. oldValue, err := m.oldValue(ctx)
  25429. if err != nil {
  25430. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  25431. }
  25432. return oldValue.OpenaiKey, nil
  25433. }
  25434. // ClearOpenaiKey clears the value of the "openai_key" field.
  25435. func (m *TokenMutation) ClearOpenaiKey() {
  25436. m.openai_key = nil
  25437. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  25438. }
  25439. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  25440. func (m *TokenMutation) OpenaiKeyCleared() bool {
  25441. _, ok := m.clearedFields[token.FieldOpenaiKey]
  25442. return ok
  25443. }
  25444. // ResetOpenaiKey resets all changes to the "openai_key" field.
  25445. func (m *TokenMutation) ResetOpenaiKey() {
  25446. m.openai_key = nil
  25447. delete(m.clearedFields, token.FieldOpenaiKey)
  25448. }
  25449. // ClearAgent clears the "agent" edge to the Agent entity.
  25450. func (m *TokenMutation) ClearAgent() {
  25451. m.clearedagent = true
  25452. m.clearedFields[token.FieldAgentID] = struct{}{}
  25453. }
  25454. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  25455. func (m *TokenMutation) AgentCleared() bool {
  25456. return m.clearedagent
  25457. }
  25458. // AgentIDs returns the "agent" edge IDs in the mutation.
  25459. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25460. // AgentID instead. It exists only for internal usage by the builders.
  25461. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  25462. if id := m.agent; id != nil {
  25463. ids = append(ids, *id)
  25464. }
  25465. return
  25466. }
  25467. // ResetAgent resets all changes to the "agent" edge.
  25468. func (m *TokenMutation) ResetAgent() {
  25469. m.agent = nil
  25470. m.clearedagent = false
  25471. }
  25472. // Where appends a list predicates to the TokenMutation builder.
  25473. func (m *TokenMutation) Where(ps ...predicate.Token) {
  25474. m.predicates = append(m.predicates, ps...)
  25475. }
  25476. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  25477. // users can use type-assertion to append predicates that do not depend on any generated package.
  25478. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  25479. p := make([]predicate.Token, len(ps))
  25480. for i := range ps {
  25481. p[i] = ps[i]
  25482. }
  25483. m.Where(p...)
  25484. }
  25485. // Op returns the operation name.
  25486. func (m *TokenMutation) Op() Op {
  25487. return m.op
  25488. }
  25489. // SetOp allows setting the mutation operation.
  25490. func (m *TokenMutation) SetOp(op Op) {
  25491. m.op = op
  25492. }
  25493. // Type returns the node type of this mutation (Token).
  25494. func (m *TokenMutation) Type() string {
  25495. return m.typ
  25496. }
  25497. // Fields returns all fields that were changed during this mutation. Note that in
  25498. // order to get all numeric fields that were incremented/decremented, call
  25499. // AddedFields().
  25500. func (m *TokenMutation) Fields() []string {
  25501. fields := make([]string, 0, 12)
  25502. if m.created_at != nil {
  25503. fields = append(fields, token.FieldCreatedAt)
  25504. }
  25505. if m.updated_at != nil {
  25506. fields = append(fields, token.FieldUpdatedAt)
  25507. }
  25508. if m.deleted_at != nil {
  25509. fields = append(fields, token.FieldDeletedAt)
  25510. }
  25511. if m.expire_at != nil {
  25512. fields = append(fields, token.FieldExpireAt)
  25513. }
  25514. if m.token != nil {
  25515. fields = append(fields, token.FieldToken)
  25516. }
  25517. if m.mac != nil {
  25518. fields = append(fields, token.FieldMAC)
  25519. }
  25520. if m.organization_id != nil {
  25521. fields = append(fields, token.FieldOrganizationID)
  25522. }
  25523. if m.agent != nil {
  25524. fields = append(fields, token.FieldAgentID)
  25525. }
  25526. if m.custom_agent_base != nil {
  25527. fields = append(fields, token.FieldCustomAgentBase)
  25528. }
  25529. if m.custom_agent_key != nil {
  25530. fields = append(fields, token.FieldCustomAgentKey)
  25531. }
  25532. if m.openai_base != nil {
  25533. fields = append(fields, token.FieldOpenaiBase)
  25534. }
  25535. if m.openai_key != nil {
  25536. fields = append(fields, token.FieldOpenaiKey)
  25537. }
  25538. return fields
  25539. }
  25540. // Field returns the value of a field with the given name. The second boolean
  25541. // return value indicates that this field was not set, or was not defined in the
  25542. // schema.
  25543. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  25544. switch name {
  25545. case token.FieldCreatedAt:
  25546. return m.CreatedAt()
  25547. case token.FieldUpdatedAt:
  25548. return m.UpdatedAt()
  25549. case token.FieldDeletedAt:
  25550. return m.DeletedAt()
  25551. case token.FieldExpireAt:
  25552. return m.ExpireAt()
  25553. case token.FieldToken:
  25554. return m.Token()
  25555. case token.FieldMAC:
  25556. return m.MAC()
  25557. case token.FieldOrganizationID:
  25558. return m.OrganizationID()
  25559. case token.FieldAgentID:
  25560. return m.AgentID()
  25561. case token.FieldCustomAgentBase:
  25562. return m.CustomAgentBase()
  25563. case token.FieldCustomAgentKey:
  25564. return m.CustomAgentKey()
  25565. case token.FieldOpenaiBase:
  25566. return m.OpenaiBase()
  25567. case token.FieldOpenaiKey:
  25568. return m.OpenaiKey()
  25569. }
  25570. return nil, false
  25571. }
  25572. // OldField returns the old value of the field from the database. An error is
  25573. // returned if the mutation operation is not UpdateOne, or the query to the
  25574. // database failed.
  25575. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25576. switch name {
  25577. case token.FieldCreatedAt:
  25578. return m.OldCreatedAt(ctx)
  25579. case token.FieldUpdatedAt:
  25580. return m.OldUpdatedAt(ctx)
  25581. case token.FieldDeletedAt:
  25582. return m.OldDeletedAt(ctx)
  25583. case token.FieldExpireAt:
  25584. return m.OldExpireAt(ctx)
  25585. case token.FieldToken:
  25586. return m.OldToken(ctx)
  25587. case token.FieldMAC:
  25588. return m.OldMAC(ctx)
  25589. case token.FieldOrganizationID:
  25590. return m.OldOrganizationID(ctx)
  25591. case token.FieldAgentID:
  25592. return m.OldAgentID(ctx)
  25593. case token.FieldCustomAgentBase:
  25594. return m.OldCustomAgentBase(ctx)
  25595. case token.FieldCustomAgentKey:
  25596. return m.OldCustomAgentKey(ctx)
  25597. case token.FieldOpenaiBase:
  25598. return m.OldOpenaiBase(ctx)
  25599. case token.FieldOpenaiKey:
  25600. return m.OldOpenaiKey(ctx)
  25601. }
  25602. return nil, fmt.Errorf("unknown Token field %s", name)
  25603. }
  25604. // SetField sets the value of a field with the given name. It returns an error if
  25605. // the field is not defined in the schema, or if the type mismatched the field
  25606. // type.
  25607. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  25608. switch name {
  25609. case token.FieldCreatedAt:
  25610. v, ok := value.(time.Time)
  25611. if !ok {
  25612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25613. }
  25614. m.SetCreatedAt(v)
  25615. return nil
  25616. case token.FieldUpdatedAt:
  25617. v, ok := value.(time.Time)
  25618. if !ok {
  25619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25620. }
  25621. m.SetUpdatedAt(v)
  25622. return nil
  25623. case token.FieldDeletedAt:
  25624. v, ok := value.(time.Time)
  25625. if !ok {
  25626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25627. }
  25628. m.SetDeletedAt(v)
  25629. return nil
  25630. case token.FieldExpireAt:
  25631. v, ok := value.(time.Time)
  25632. if !ok {
  25633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25634. }
  25635. m.SetExpireAt(v)
  25636. return nil
  25637. case token.FieldToken:
  25638. v, ok := value.(string)
  25639. if !ok {
  25640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25641. }
  25642. m.SetToken(v)
  25643. return nil
  25644. case token.FieldMAC:
  25645. v, ok := value.(string)
  25646. if !ok {
  25647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25648. }
  25649. m.SetMAC(v)
  25650. return nil
  25651. case token.FieldOrganizationID:
  25652. v, ok := value.(uint64)
  25653. if !ok {
  25654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25655. }
  25656. m.SetOrganizationID(v)
  25657. return nil
  25658. case token.FieldAgentID:
  25659. v, ok := value.(uint64)
  25660. if !ok {
  25661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25662. }
  25663. m.SetAgentID(v)
  25664. return nil
  25665. case token.FieldCustomAgentBase:
  25666. v, ok := value.(string)
  25667. if !ok {
  25668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25669. }
  25670. m.SetCustomAgentBase(v)
  25671. return nil
  25672. case token.FieldCustomAgentKey:
  25673. v, ok := value.(string)
  25674. if !ok {
  25675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25676. }
  25677. m.SetCustomAgentKey(v)
  25678. return nil
  25679. case token.FieldOpenaiBase:
  25680. v, ok := value.(string)
  25681. if !ok {
  25682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25683. }
  25684. m.SetOpenaiBase(v)
  25685. return nil
  25686. case token.FieldOpenaiKey:
  25687. v, ok := value.(string)
  25688. if !ok {
  25689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25690. }
  25691. m.SetOpenaiKey(v)
  25692. return nil
  25693. }
  25694. return fmt.Errorf("unknown Token field %s", name)
  25695. }
  25696. // AddedFields returns all numeric fields that were incremented/decremented during
  25697. // this mutation.
  25698. func (m *TokenMutation) AddedFields() []string {
  25699. var fields []string
  25700. if m.addorganization_id != nil {
  25701. fields = append(fields, token.FieldOrganizationID)
  25702. }
  25703. return fields
  25704. }
  25705. // AddedField returns the numeric value that was incremented/decremented on a field
  25706. // with the given name. The second boolean return value indicates that this field
  25707. // was not set, or was not defined in the schema.
  25708. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  25709. switch name {
  25710. case token.FieldOrganizationID:
  25711. return m.AddedOrganizationID()
  25712. }
  25713. return nil, false
  25714. }
  25715. // AddField adds the value to the field with the given name. It returns an error if
  25716. // the field is not defined in the schema, or if the type mismatched the field
  25717. // type.
  25718. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  25719. switch name {
  25720. case token.FieldOrganizationID:
  25721. v, ok := value.(int64)
  25722. if !ok {
  25723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25724. }
  25725. m.AddOrganizationID(v)
  25726. return nil
  25727. }
  25728. return fmt.Errorf("unknown Token numeric field %s", name)
  25729. }
  25730. // ClearedFields returns all nullable fields that were cleared during this
  25731. // mutation.
  25732. func (m *TokenMutation) ClearedFields() []string {
  25733. var fields []string
  25734. if m.FieldCleared(token.FieldDeletedAt) {
  25735. fields = append(fields, token.FieldDeletedAt)
  25736. }
  25737. if m.FieldCleared(token.FieldExpireAt) {
  25738. fields = append(fields, token.FieldExpireAt)
  25739. }
  25740. if m.FieldCleared(token.FieldToken) {
  25741. fields = append(fields, token.FieldToken)
  25742. }
  25743. if m.FieldCleared(token.FieldMAC) {
  25744. fields = append(fields, token.FieldMAC)
  25745. }
  25746. if m.FieldCleared(token.FieldCustomAgentBase) {
  25747. fields = append(fields, token.FieldCustomAgentBase)
  25748. }
  25749. if m.FieldCleared(token.FieldCustomAgentKey) {
  25750. fields = append(fields, token.FieldCustomAgentKey)
  25751. }
  25752. if m.FieldCleared(token.FieldOpenaiBase) {
  25753. fields = append(fields, token.FieldOpenaiBase)
  25754. }
  25755. if m.FieldCleared(token.FieldOpenaiKey) {
  25756. fields = append(fields, token.FieldOpenaiKey)
  25757. }
  25758. return fields
  25759. }
  25760. // FieldCleared returns a boolean indicating if a field with the given name was
  25761. // cleared in this mutation.
  25762. func (m *TokenMutation) FieldCleared(name string) bool {
  25763. _, ok := m.clearedFields[name]
  25764. return ok
  25765. }
  25766. // ClearField clears the value of the field with the given name. It returns an
  25767. // error if the field is not defined in the schema.
  25768. func (m *TokenMutation) ClearField(name string) error {
  25769. switch name {
  25770. case token.FieldDeletedAt:
  25771. m.ClearDeletedAt()
  25772. return nil
  25773. case token.FieldExpireAt:
  25774. m.ClearExpireAt()
  25775. return nil
  25776. case token.FieldToken:
  25777. m.ClearToken()
  25778. return nil
  25779. case token.FieldMAC:
  25780. m.ClearMAC()
  25781. return nil
  25782. case token.FieldCustomAgentBase:
  25783. m.ClearCustomAgentBase()
  25784. return nil
  25785. case token.FieldCustomAgentKey:
  25786. m.ClearCustomAgentKey()
  25787. return nil
  25788. case token.FieldOpenaiBase:
  25789. m.ClearOpenaiBase()
  25790. return nil
  25791. case token.FieldOpenaiKey:
  25792. m.ClearOpenaiKey()
  25793. return nil
  25794. }
  25795. return fmt.Errorf("unknown Token nullable field %s", name)
  25796. }
  25797. // ResetField resets all changes in the mutation for the field with the given name.
  25798. // It returns an error if the field is not defined in the schema.
  25799. func (m *TokenMutation) ResetField(name string) error {
  25800. switch name {
  25801. case token.FieldCreatedAt:
  25802. m.ResetCreatedAt()
  25803. return nil
  25804. case token.FieldUpdatedAt:
  25805. m.ResetUpdatedAt()
  25806. return nil
  25807. case token.FieldDeletedAt:
  25808. m.ResetDeletedAt()
  25809. return nil
  25810. case token.FieldExpireAt:
  25811. m.ResetExpireAt()
  25812. return nil
  25813. case token.FieldToken:
  25814. m.ResetToken()
  25815. return nil
  25816. case token.FieldMAC:
  25817. m.ResetMAC()
  25818. return nil
  25819. case token.FieldOrganizationID:
  25820. m.ResetOrganizationID()
  25821. return nil
  25822. case token.FieldAgentID:
  25823. m.ResetAgentID()
  25824. return nil
  25825. case token.FieldCustomAgentBase:
  25826. m.ResetCustomAgentBase()
  25827. return nil
  25828. case token.FieldCustomAgentKey:
  25829. m.ResetCustomAgentKey()
  25830. return nil
  25831. case token.FieldOpenaiBase:
  25832. m.ResetOpenaiBase()
  25833. return nil
  25834. case token.FieldOpenaiKey:
  25835. m.ResetOpenaiKey()
  25836. return nil
  25837. }
  25838. return fmt.Errorf("unknown Token field %s", name)
  25839. }
  25840. // AddedEdges returns all edge names that were set/added in this mutation.
  25841. func (m *TokenMutation) AddedEdges() []string {
  25842. edges := make([]string, 0, 1)
  25843. if m.agent != nil {
  25844. edges = append(edges, token.EdgeAgent)
  25845. }
  25846. return edges
  25847. }
  25848. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25849. // name in this mutation.
  25850. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  25851. switch name {
  25852. case token.EdgeAgent:
  25853. if id := m.agent; id != nil {
  25854. return []ent.Value{*id}
  25855. }
  25856. }
  25857. return nil
  25858. }
  25859. // RemovedEdges returns all edge names that were removed in this mutation.
  25860. func (m *TokenMutation) RemovedEdges() []string {
  25861. edges := make([]string, 0, 1)
  25862. return edges
  25863. }
  25864. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25865. // the given name in this mutation.
  25866. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  25867. return nil
  25868. }
  25869. // ClearedEdges returns all edge names that were cleared in this mutation.
  25870. func (m *TokenMutation) ClearedEdges() []string {
  25871. edges := make([]string, 0, 1)
  25872. if m.clearedagent {
  25873. edges = append(edges, token.EdgeAgent)
  25874. }
  25875. return edges
  25876. }
  25877. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25878. // was cleared in this mutation.
  25879. func (m *TokenMutation) EdgeCleared(name string) bool {
  25880. switch name {
  25881. case token.EdgeAgent:
  25882. return m.clearedagent
  25883. }
  25884. return false
  25885. }
  25886. // ClearEdge clears the value of the edge with the given name. It returns an error
  25887. // if that edge is not defined in the schema.
  25888. func (m *TokenMutation) ClearEdge(name string) error {
  25889. switch name {
  25890. case token.EdgeAgent:
  25891. m.ClearAgent()
  25892. return nil
  25893. }
  25894. return fmt.Errorf("unknown Token unique edge %s", name)
  25895. }
  25896. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25897. // It returns an error if the edge is not defined in the schema.
  25898. func (m *TokenMutation) ResetEdge(name string) error {
  25899. switch name {
  25900. case token.EdgeAgent:
  25901. m.ResetAgent()
  25902. return nil
  25903. }
  25904. return fmt.Errorf("unknown Token edge %s", name)
  25905. }
  25906. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  25907. type TutorialMutation struct {
  25908. config
  25909. op Op
  25910. typ string
  25911. id *uint64
  25912. created_at *time.Time
  25913. updated_at *time.Time
  25914. deleted_at *time.Time
  25915. index *int
  25916. addindex *int
  25917. title *string
  25918. content *string
  25919. organization_id *uint64
  25920. addorganization_id *int64
  25921. clearedFields map[string]struct{}
  25922. employee *uint64
  25923. clearedemployee bool
  25924. done bool
  25925. oldValue func(context.Context) (*Tutorial, error)
  25926. predicates []predicate.Tutorial
  25927. }
  25928. var _ ent.Mutation = (*TutorialMutation)(nil)
  25929. // tutorialOption allows management of the mutation configuration using functional options.
  25930. type tutorialOption func(*TutorialMutation)
  25931. // newTutorialMutation creates new mutation for the Tutorial entity.
  25932. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  25933. m := &TutorialMutation{
  25934. config: c,
  25935. op: op,
  25936. typ: TypeTutorial,
  25937. clearedFields: make(map[string]struct{}),
  25938. }
  25939. for _, opt := range opts {
  25940. opt(m)
  25941. }
  25942. return m
  25943. }
  25944. // withTutorialID sets the ID field of the mutation.
  25945. func withTutorialID(id uint64) tutorialOption {
  25946. return func(m *TutorialMutation) {
  25947. var (
  25948. err error
  25949. once sync.Once
  25950. value *Tutorial
  25951. )
  25952. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  25953. once.Do(func() {
  25954. if m.done {
  25955. err = errors.New("querying old values post mutation is not allowed")
  25956. } else {
  25957. value, err = m.Client().Tutorial.Get(ctx, id)
  25958. }
  25959. })
  25960. return value, err
  25961. }
  25962. m.id = &id
  25963. }
  25964. }
  25965. // withTutorial sets the old Tutorial of the mutation.
  25966. func withTutorial(node *Tutorial) tutorialOption {
  25967. return func(m *TutorialMutation) {
  25968. m.oldValue = func(context.Context) (*Tutorial, error) {
  25969. return node, nil
  25970. }
  25971. m.id = &node.ID
  25972. }
  25973. }
  25974. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25975. // executed in a transaction (ent.Tx), a transactional client is returned.
  25976. func (m TutorialMutation) Client() *Client {
  25977. client := &Client{config: m.config}
  25978. client.init()
  25979. return client
  25980. }
  25981. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25982. // it returns an error otherwise.
  25983. func (m TutorialMutation) Tx() (*Tx, error) {
  25984. if _, ok := m.driver.(*txDriver); !ok {
  25985. return nil, errors.New("ent: mutation is not running in a transaction")
  25986. }
  25987. tx := &Tx{config: m.config}
  25988. tx.init()
  25989. return tx, nil
  25990. }
  25991. // SetID sets the value of the id field. Note that this
  25992. // operation is only accepted on creation of Tutorial entities.
  25993. func (m *TutorialMutation) SetID(id uint64) {
  25994. m.id = &id
  25995. }
  25996. // ID returns the ID value in the mutation. Note that the ID is only available
  25997. // if it was provided to the builder or after it was returned from the database.
  25998. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  25999. if m.id == nil {
  26000. return
  26001. }
  26002. return *m.id, true
  26003. }
  26004. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26005. // That means, if the mutation is applied within a transaction with an isolation level such
  26006. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26007. // or updated by the mutation.
  26008. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  26009. switch {
  26010. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26011. id, exists := m.ID()
  26012. if exists {
  26013. return []uint64{id}, nil
  26014. }
  26015. fallthrough
  26016. case m.op.Is(OpUpdate | OpDelete):
  26017. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  26018. default:
  26019. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26020. }
  26021. }
  26022. // SetCreatedAt sets the "created_at" field.
  26023. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  26024. m.created_at = &t
  26025. }
  26026. // CreatedAt returns the value of the "created_at" field in the mutation.
  26027. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  26028. v := m.created_at
  26029. if v == nil {
  26030. return
  26031. }
  26032. return *v, true
  26033. }
  26034. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  26035. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26037. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26038. if !m.op.Is(OpUpdateOne) {
  26039. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26040. }
  26041. if m.id == nil || m.oldValue == nil {
  26042. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26043. }
  26044. oldValue, err := m.oldValue(ctx)
  26045. if err != nil {
  26046. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26047. }
  26048. return oldValue.CreatedAt, nil
  26049. }
  26050. // ResetCreatedAt resets all changes to the "created_at" field.
  26051. func (m *TutorialMutation) ResetCreatedAt() {
  26052. m.created_at = nil
  26053. }
  26054. // SetUpdatedAt sets the "updated_at" field.
  26055. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  26056. m.updated_at = &t
  26057. }
  26058. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26059. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  26060. v := m.updated_at
  26061. if v == nil {
  26062. return
  26063. }
  26064. return *v, true
  26065. }
  26066. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  26067. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26069. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26070. if !m.op.Is(OpUpdateOne) {
  26071. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26072. }
  26073. if m.id == nil || m.oldValue == nil {
  26074. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26075. }
  26076. oldValue, err := m.oldValue(ctx)
  26077. if err != nil {
  26078. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26079. }
  26080. return oldValue.UpdatedAt, nil
  26081. }
  26082. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26083. func (m *TutorialMutation) ResetUpdatedAt() {
  26084. m.updated_at = nil
  26085. }
  26086. // SetDeletedAt sets the "deleted_at" field.
  26087. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  26088. m.deleted_at = &t
  26089. }
  26090. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26091. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  26092. v := m.deleted_at
  26093. if v == nil {
  26094. return
  26095. }
  26096. return *v, true
  26097. }
  26098. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  26099. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26101. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26102. if !m.op.Is(OpUpdateOne) {
  26103. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26104. }
  26105. if m.id == nil || m.oldValue == nil {
  26106. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26107. }
  26108. oldValue, err := m.oldValue(ctx)
  26109. if err != nil {
  26110. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26111. }
  26112. return oldValue.DeletedAt, nil
  26113. }
  26114. // ClearDeletedAt clears the value of the "deleted_at" field.
  26115. func (m *TutorialMutation) ClearDeletedAt() {
  26116. m.deleted_at = nil
  26117. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  26118. }
  26119. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26120. func (m *TutorialMutation) DeletedAtCleared() bool {
  26121. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  26122. return ok
  26123. }
  26124. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26125. func (m *TutorialMutation) ResetDeletedAt() {
  26126. m.deleted_at = nil
  26127. delete(m.clearedFields, tutorial.FieldDeletedAt)
  26128. }
  26129. // SetEmployeeID sets the "employee_id" field.
  26130. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  26131. m.employee = &u
  26132. }
  26133. // EmployeeID returns the value of the "employee_id" field in the mutation.
  26134. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  26135. v := m.employee
  26136. if v == nil {
  26137. return
  26138. }
  26139. return *v, true
  26140. }
  26141. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  26142. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26144. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  26145. if !m.op.Is(OpUpdateOne) {
  26146. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  26147. }
  26148. if m.id == nil || m.oldValue == nil {
  26149. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  26150. }
  26151. oldValue, err := m.oldValue(ctx)
  26152. if err != nil {
  26153. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  26154. }
  26155. return oldValue.EmployeeID, nil
  26156. }
  26157. // ResetEmployeeID resets all changes to the "employee_id" field.
  26158. func (m *TutorialMutation) ResetEmployeeID() {
  26159. m.employee = nil
  26160. }
  26161. // SetIndex sets the "index" field.
  26162. func (m *TutorialMutation) SetIndex(i int) {
  26163. m.index = &i
  26164. m.addindex = nil
  26165. }
  26166. // Index returns the value of the "index" field in the mutation.
  26167. func (m *TutorialMutation) Index() (r int, exists bool) {
  26168. v := m.index
  26169. if v == nil {
  26170. return
  26171. }
  26172. return *v, true
  26173. }
  26174. // OldIndex returns the old "index" field's value of the Tutorial entity.
  26175. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26177. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  26178. if !m.op.Is(OpUpdateOne) {
  26179. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  26180. }
  26181. if m.id == nil || m.oldValue == nil {
  26182. return v, errors.New("OldIndex requires an ID field in the mutation")
  26183. }
  26184. oldValue, err := m.oldValue(ctx)
  26185. if err != nil {
  26186. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  26187. }
  26188. return oldValue.Index, nil
  26189. }
  26190. // AddIndex adds i to the "index" field.
  26191. func (m *TutorialMutation) AddIndex(i int) {
  26192. if m.addindex != nil {
  26193. *m.addindex += i
  26194. } else {
  26195. m.addindex = &i
  26196. }
  26197. }
  26198. // AddedIndex returns the value that was added to the "index" field in this mutation.
  26199. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  26200. v := m.addindex
  26201. if v == nil {
  26202. return
  26203. }
  26204. return *v, true
  26205. }
  26206. // ResetIndex resets all changes to the "index" field.
  26207. func (m *TutorialMutation) ResetIndex() {
  26208. m.index = nil
  26209. m.addindex = nil
  26210. }
  26211. // SetTitle sets the "title" field.
  26212. func (m *TutorialMutation) SetTitle(s string) {
  26213. m.title = &s
  26214. }
  26215. // Title returns the value of the "title" field in the mutation.
  26216. func (m *TutorialMutation) Title() (r string, exists bool) {
  26217. v := m.title
  26218. if v == nil {
  26219. return
  26220. }
  26221. return *v, true
  26222. }
  26223. // OldTitle returns the old "title" field's value of the Tutorial entity.
  26224. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26226. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  26227. if !m.op.Is(OpUpdateOne) {
  26228. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  26229. }
  26230. if m.id == nil || m.oldValue == nil {
  26231. return v, errors.New("OldTitle requires an ID field in the mutation")
  26232. }
  26233. oldValue, err := m.oldValue(ctx)
  26234. if err != nil {
  26235. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  26236. }
  26237. return oldValue.Title, nil
  26238. }
  26239. // ResetTitle resets all changes to the "title" field.
  26240. func (m *TutorialMutation) ResetTitle() {
  26241. m.title = nil
  26242. }
  26243. // SetContent sets the "content" field.
  26244. func (m *TutorialMutation) SetContent(s string) {
  26245. m.content = &s
  26246. }
  26247. // Content returns the value of the "content" field in the mutation.
  26248. func (m *TutorialMutation) Content() (r string, exists bool) {
  26249. v := m.content
  26250. if v == nil {
  26251. return
  26252. }
  26253. return *v, true
  26254. }
  26255. // OldContent returns the old "content" field's value of the Tutorial entity.
  26256. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26258. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  26259. if !m.op.Is(OpUpdateOne) {
  26260. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  26261. }
  26262. if m.id == nil || m.oldValue == nil {
  26263. return v, errors.New("OldContent requires an ID field in the mutation")
  26264. }
  26265. oldValue, err := m.oldValue(ctx)
  26266. if err != nil {
  26267. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  26268. }
  26269. return oldValue.Content, nil
  26270. }
  26271. // ResetContent resets all changes to the "content" field.
  26272. func (m *TutorialMutation) ResetContent() {
  26273. m.content = nil
  26274. }
  26275. // SetOrganizationID sets the "organization_id" field.
  26276. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  26277. m.organization_id = &u
  26278. m.addorganization_id = nil
  26279. }
  26280. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26281. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  26282. v := m.organization_id
  26283. if v == nil {
  26284. return
  26285. }
  26286. return *v, true
  26287. }
  26288. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  26289. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26291. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26292. if !m.op.Is(OpUpdateOne) {
  26293. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26294. }
  26295. if m.id == nil || m.oldValue == nil {
  26296. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26297. }
  26298. oldValue, err := m.oldValue(ctx)
  26299. if err != nil {
  26300. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26301. }
  26302. return oldValue.OrganizationID, nil
  26303. }
  26304. // AddOrganizationID adds u to the "organization_id" field.
  26305. func (m *TutorialMutation) AddOrganizationID(u int64) {
  26306. if m.addorganization_id != nil {
  26307. *m.addorganization_id += u
  26308. } else {
  26309. m.addorganization_id = &u
  26310. }
  26311. }
  26312. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26313. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  26314. v := m.addorganization_id
  26315. if v == nil {
  26316. return
  26317. }
  26318. return *v, true
  26319. }
  26320. // ResetOrganizationID resets all changes to the "organization_id" field.
  26321. func (m *TutorialMutation) ResetOrganizationID() {
  26322. m.organization_id = nil
  26323. m.addorganization_id = nil
  26324. }
  26325. // ClearEmployee clears the "employee" edge to the Employee entity.
  26326. func (m *TutorialMutation) ClearEmployee() {
  26327. m.clearedemployee = true
  26328. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  26329. }
  26330. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  26331. func (m *TutorialMutation) EmployeeCleared() bool {
  26332. return m.clearedemployee
  26333. }
  26334. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  26335. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26336. // EmployeeID instead. It exists only for internal usage by the builders.
  26337. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  26338. if id := m.employee; id != nil {
  26339. ids = append(ids, *id)
  26340. }
  26341. return
  26342. }
  26343. // ResetEmployee resets all changes to the "employee" edge.
  26344. func (m *TutorialMutation) ResetEmployee() {
  26345. m.employee = nil
  26346. m.clearedemployee = false
  26347. }
  26348. // Where appends a list predicates to the TutorialMutation builder.
  26349. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  26350. m.predicates = append(m.predicates, ps...)
  26351. }
  26352. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  26353. // users can use type-assertion to append predicates that do not depend on any generated package.
  26354. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  26355. p := make([]predicate.Tutorial, len(ps))
  26356. for i := range ps {
  26357. p[i] = ps[i]
  26358. }
  26359. m.Where(p...)
  26360. }
  26361. // Op returns the operation name.
  26362. func (m *TutorialMutation) Op() Op {
  26363. return m.op
  26364. }
  26365. // SetOp allows setting the mutation operation.
  26366. func (m *TutorialMutation) SetOp(op Op) {
  26367. m.op = op
  26368. }
  26369. // Type returns the node type of this mutation (Tutorial).
  26370. func (m *TutorialMutation) Type() string {
  26371. return m.typ
  26372. }
  26373. // Fields returns all fields that were changed during this mutation. Note that in
  26374. // order to get all numeric fields that were incremented/decremented, call
  26375. // AddedFields().
  26376. func (m *TutorialMutation) Fields() []string {
  26377. fields := make([]string, 0, 8)
  26378. if m.created_at != nil {
  26379. fields = append(fields, tutorial.FieldCreatedAt)
  26380. }
  26381. if m.updated_at != nil {
  26382. fields = append(fields, tutorial.FieldUpdatedAt)
  26383. }
  26384. if m.deleted_at != nil {
  26385. fields = append(fields, tutorial.FieldDeletedAt)
  26386. }
  26387. if m.employee != nil {
  26388. fields = append(fields, tutorial.FieldEmployeeID)
  26389. }
  26390. if m.index != nil {
  26391. fields = append(fields, tutorial.FieldIndex)
  26392. }
  26393. if m.title != nil {
  26394. fields = append(fields, tutorial.FieldTitle)
  26395. }
  26396. if m.content != nil {
  26397. fields = append(fields, tutorial.FieldContent)
  26398. }
  26399. if m.organization_id != nil {
  26400. fields = append(fields, tutorial.FieldOrganizationID)
  26401. }
  26402. return fields
  26403. }
  26404. // Field returns the value of a field with the given name. The second boolean
  26405. // return value indicates that this field was not set, or was not defined in the
  26406. // schema.
  26407. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  26408. switch name {
  26409. case tutorial.FieldCreatedAt:
  26410. return m.CreatedAt()
  26411. case tutorial.FieldUpdatedAt:
  26412. return m.UpdatedAt()
  26413. case tutorial.FieldDeletedAt:
  26414. return m.DeletedAt()
  26415. case tutorial.FieldEmployeeID:
  26416. return m.EmployeeID()
  26417. case tutorial.FieldIndex:
  26418. return m.Index()
  26419. case tutorial.FieldTitle:
  26420. return m.Title()
  26421. case tutorial.FieldContent:
  26422. return m.Content()
  26423. case tutorial.FieldOrganizationID:
  26424. return m.OrganizationID()
  26425. }
  26426. return nil, false
  26427. }
  26428. // OldField returns the old value of the field from the database. An error is
  26429. // returned if the mutation operation is not UpdateOne, or the query to the
  26430. // database failed.
  26431. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26432. switch name {
  26433. case tutorial.FieldCreatedAt:
  26434. return m.OldCreatedAt(ctx)
  26435. case tutorial.FieldUpdatedAt:
  26436. return m.OldUpdatedAt(ctx)
  26437. case tutorial.FieldDeletedAt:
  26438. return m.OldDeletedAt(ctx)
  26439. case tutorial.FieldEmployeeID:
  26440. return m.OldEmployeeID(ctx)
  26441. case tutorial.FieldIndex:
  26442. return m.OldIndex(ctx)
  26443. case tutorial.FieldTitle:
  26444. return m.OldTitle(ctx)
  26445. case tutorial.FieldContent:
  26446. return m.OldContent(ctx)
  26447. case tutorial.FieldOrganizationID:
  26448. return m.OldOrganizationID(ctx)
  26449. }
  26450. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  26451. }
  26452. // SetField sets the value of a field with the given name. It returns an error if
  26453. // the field is not defined in the schema, or if the type mismatched the field
  26454. // type.
  26455. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  26456. switch name {
  26457. case tutorial.FieldCreatedAt:
  26458. v, ok := value.(time.Time)
  26459. if !ok {
  26460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26461. }
  26462. m.SetCreatedAt(v)
  26463. return nil
  26464. case tutorial.FieldUpdatedAt:
  26465. v, ok := value.(time.Time)
  26466. if !ok {
  26467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26468. }
  26469. m.SetUpdatedAt(v)
  26470. return nil
  26471. case tutorial.FieldDeletedAt:
  26472. v, ok := value.(time.Time)
  26473. if !ok {
  26474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26475. }
  26476. m.SetDeletedAt(v)
  26477. return nil
  26478. case tutorial.FieldEmployeeID:
  26479. v, ok := value.(uint64)
  26480. if !ok {
  26481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26482. }
  26483. m.SetEmployeeID(v)
  26484. return nil
  26485. case tutorial.FieldIndex:
  26486. v, ok := value.(int)
  26487. if !ok {
  26488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26489. }
  26490. m.SetIndex(v)
  26491. return nil
  26492. case tutorial.FieldTitle:
  26493. v, ok := value.(string)
  26494. if !ok {
  26495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26496. }
  26497. m.SetTitle(v)
  26498. return nil
  26499. case tutorial.FieldContent:
  26500. v, ok := value.(string)
  26501. if !ok {
  26502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26503. }
  26504. m.SetContent(v)
  26505. return nil
  26506. case tutorial.FieldOrganizationID:
  26507. v, ok := value.(uint64)
  26508. if !ok {
  26509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26510. }
  26511. m.SetOrganizationID(v)
  26512. return nil
  26513. }
  26514. return fmt.Errorf("unknown Tutorial field %s", name)
  26515. }
  26516. // AddedFields returns all numeric fields that were incremented/decremented during
  26517. // this mutation.
  26518. func (m *TutorialMutation) AddedFields() []string {
  26519. var fields []string
  26520. if m.addindex != nil {
  26521. fields = append(fields, tutorial.FieldIndex)
  26522. }
  26523. if m.addorganization_id != nil {
  26524. fields = append(fields, tutorial.FieldOrganizationID)
  26525. }
  26526. return fields
  26527. }
  26528. // AddedField returns the numeric value that was incremented/decremented on a field
  26529. // with the given name. The second boolean return value indicates that this field
  26530. // was not set, or was not defined in the schema.
  26531. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  26532. switch name {
  26533. case tutorial.FieldIndex:
  26534. return m.AddedIndex()
  26535. case tutorial.FieldOrganizationID:
  26536. return m.AddedOrganizationID()
  26537. }
  26538. return nil, false
  26539. }
  26540. // AddField adds the value to the field with the given name. It returns an error if
  26541. // the field is not defined in the schema, or if the type mismatched the field
  26542. // type.
  26543. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  26544. switch name {
  26545. case tutorial.FieldIndex:
  26546. v, ok := value.(int)
  26547. if !ok {
  26548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26549. }
  26550. m.AddIndex(v)
  26551. return nil
  26552. case tutorial.FieldOrganizationID:
  26553. v, ok := value.(int64)
  26554. if !ok {
  26555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26556. }
  26557. m.AddOrganizationID(v)
  26558. return nil
  26559. }
  26560. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  26561. }
  26562. // ClearedFields returns all nullable fields that were cleared during this
  26563. // mutation.
  26564. func (m *TutorialMutation) ClearedFields() []string {
  26565. var fields []string
  26566. if m.FieldCleared(tutorial.FieldDeletedAt) {
  26567. fields = append(fields, tutorial.FieldDeletedAt)
  26568. }
  26569. return fields
  26570. }
  26571. // FieldCleared returns a boolean indicating if a field with the given name was
  26572. // cleared in this mutation.
  26573. func (m *TutorialMutation) FieldCleared(name string) bool {
  26574. _, ok := m.clearedFields[name]
  26575. return ok
  26576. }
  26577. // ClearField clears the value of the field with the given name. It returns an
  26578. // error if the field is not defined in the schema.
  26579. func (m *TutorialMutation) ClearField(name string) error {
  26580. switch name {
  26581. case tutorial.FieldDeletedAt:
  26582. m.ClearDeletedAt()
  26583. return nil
  26584. }
  26585. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  26586. }
  26587. // ResetField resets all changes in the mutation for the field with the given name.
  26588. // It returns an error if the field is not defined in the schema.
  26589. func (m *TutorialMutation) ResetField(name string) error {
  26590. switch name {
  26591. case tutorial.FieldCreatedAt:
  26592. m.ResetCreatedAt()
  26593. return nil
  26594. case tutorial.FieldUpdatedAt:
  26595. m.ResetUpdatedAt()
  26596. return nil
  26597. case tutorial.FieldDeletedAt:
  26598. m.ResetDeletedAt()
  26599. return nil
  26600. case tutorial.FieldEmployeeID:
  26601. m.ResetEmployeeID()
  26602. return nil
  26603. case tutorial.FieldIndex:
  26604. m.ResetIndex()
  26605. return nil
  26606. case tutorial.FieldTitle:
  26607. m.ResetTitle()
  26608. return nil
  26609. case tutorial.FieldContent:
  26610. m.ResetContent()
  26611. return nil
  26612. case tutorial.FieldOrganizationID:
  26613. m.ResetOrganizationID()
  26614. return nil
  26615. }
  26616. return fmt.Errorf("unknown Tutorial field %s", name)
  26617. }
  26618. // AddedEdges returns all edge names that were set/added in this mutation.
  26619. func (m *TutorialMutation) AddedEdges() []string {
  26620. edges := make([]string, 0, 1)
  26621. if m.employee != nil {
  26622. edges = append(edges, tutorial.EdgeEmployee)
  26623. }
  26624. return edges
  26625. }
  26626. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26627. // name in this mutation.
  26628. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  26629. switch name {
  26630. case tutorial.EdgeEmployee:
  26631. if id := m.employee; id != nil {
  26632. return []ent.Value{*id}
  26633. }
  26634. }
  26635. return nil
  26636. }
  26637. // RemovedEdges returns all edge names that were removed in this mutation.
  26638. func (m *TutorialMutation) RemovedEdges() []string {
  26639. edges := make([]string, 0, 1)
  26640. return edges
  26641. }
  26642. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26643. // the given name in this mutation.
  26644. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  26645. return nil
  26646. }
  26647. // ClearedEdges returns all edge names that were cleared in this mutation.
  26648. func (m *TutorialMutation) ClearedEdges() []string {
  26649. edges := make([]string, 0, 1)
  26650. if m.clearedemployee {
  26651. edges = append(edges, tutorial.EdgeEmployee)
  26652. }
  26653. return edges
  26654. }
  26655. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26656. // was cleared in this mutation.
  26657. func (m *TutorialMutation) EdgeCleared(name string) bool {
  26658. switch name {
  26659. case tutorial.EdgeEmployee:
  26660. return m.clearedemployee
  26661. }
  26662. return false
  26663. }
  26664. // ClearEdge clears the value of the edge with the given name. It returns an error
  26665. // if that edge is not defined in the schema.
  26666. func (m *TutorialMutation) ClearEdge(name string) error {
  26667. switch name {
  26668. case tutorial.EdgeEmployee:
  26669. m.ClearEmployee()
  26670. return nil
  26671. }
  26672. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  26673. }
  26674. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26675. // It returns an error if the edge is not defined in the schema.
  26676. func (m *TutorialMutation) ResetEdge(name string) error {
  26677. switch name {
  26678. case tutorial.EdgeEmployee:
  26679. m.ResetEmployee()
  26680. return nil
  26681. }
  26682. return fmt.Errorf("unknown Tutorial edge %s", name)
  26683. }
  26684. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  26685. type UsageDetailMutation struct {
  26686. config
  26687. op Op
  26688. typ string
  26689. id *uint64
  26690. created_at *time.Time
  26691. updated_at *time.Time
  26692. status *uint8
  26693. addstatus *int8
  26694. _type *int
  26695. add_type *int
  26696. bot_id *string
  26697. receiver_id *string
  26698. app *int
  26699. addapp *int
  26700. session_id *uint64
  26701. addsession_id *int64
  26702. request *string
  26703. response *string
  26704. original_data *custom_types.OriginalData
  26705. total_tokens *uint64
  26706. addtotal_tokens *int64
  26707. prompt_tokens *uint64
  26708. addprompt_tokens *int64
  26709. completion_tokens *uint64
  26710. addcompletion_tokens *int64
  26711. organization_id *uint64
  26712. addorganization_id *int64
  26713. clearedFields map[string]struct{}
  26714. done bool
  26715. oldValue func(context.Context) (*UsageDetail, error)
  26716. predicates []predicate.UsageDetail
  26717. }
  26718. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  26719. // usagedetailOption allows management of the mutation configuration using functional options.
  26720. type usagedetailOption func(*UsageDetailMutation)
  26721. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  26722. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  26723. m := &UsageDetailMutation{
  26724. config: c,
  26725. op: op,
  26726. typ: TypeUsageDetail,
  26727. clearedFields: make(map[string]struct{}),
  26728. }
  26729. for _, opt := range opts {
  26730. opt(m)
  26731. }
  26732. return m
  26733. }
  26734. // withUsageDetailID sets the ID field of the mutation.
  26735. func withUsageDetailID(id uint64) usagedetailOption {
  26736. return func(m *UsageDetailMutation) {
  26737. var (
  26738. err error
  26739. once sync.Once
  26740. value *UsageDetail
  26741. )
  26742. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  26743. once.Do(func() {
  26744. if m.done {
  26745. err = errors.New("querying old values post mutation is not allowed")
  26746. } else {
  26747. value, err = m.Client().UsageDetail.Get(ctx, id)
  26748. }
  26749. })
  26750. return value, err
  26751. }
  26752. m.id = &id
  26753. }
  26754. }
  26755. // withUsageDetail sets the old UsageDetail of the mutation.
  26756. func withUsageDetail(node *UsageDetail) usagedetailOption {
  26757. return func(m *UsageDetailMutation) {
  26758. m.oldValue = func(context.Context) (*UsageDetail, error) {
  26759. return node, nil
  26760. }
  26761. m.id = &node.ID
  26762. }
  26763. }
  26764. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26765. // executed in a transaction (ent.Tx), a transactional client is returned.
  26766. func (m UsageDetailMutation) Client() *Client {
  26767. client := &Client{config: m.config}
  26768. client.init()
  26769. return client
  26770. }
  26771. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26772. // it returns an error otherwise.
  26773. func (m UsageDetailMutation) Tx() (*Tx, error) {
  26774. if _, ok := m.driver.(*txDriver); !ok {
  26775. return nil, errors.New("ent: mutation is not running in a transaction")
  26776. }
  26777. tx := &Tx{config: m.config}
  26778. tx.init()
  26779. return tx, nil
  26780. }
  26781. // SetID sets the value of the id field. Note that this
  26782. // operation is only accepted on creation of UsageDetail entities.
  26783. func (m *UsageDetailMutation) SetID(id uint64) {
  26784. m.id = &id
  26785. }
  26786. // ID returns the ID value in the mutation. Note that the ID is only available
  26787. // if it was provided to the builder or after it was returned from the database.
  26788. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  26789. if m.id == nil {
  26790. return
  26791. }
  26792. return *m.id, true
  26793. }
  26794. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26795. // That means, if the mutation is applied within a transaction with an isolation level such
  26796. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26797. // or updated by the mutation.
  26798. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  26799. switch {
  26800. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26801. id, exists := m.ID()
  26802. if exists {
  26803. return []uint64{id}, nil
  26804. }
  26805. fallthrough
  26806. case m.op.Is(OpUpdate | OpDelete):
  26807. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  26808. default:
  26809. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26810. }
  26811. }
  26812. // SetCreatedAt sets the "created_at" field.
  26813. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  26814. m.created_at = &t
  26815. }
  26816. // CreatedAt returns the value of the "created_at" field in the mutation.
  26817. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  26818. v := m.created_at
  26819. if v == nil {
  26820. return
  26821. }
  26822. return *v, true
  26823. }
  26824. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  26825. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26827. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26828. if !m.op.Is(OpUpdateOne) {
  26829. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26830. }
  26831. if m.id == nil || m.oldValue == nil {
  26832. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26833. }
  26834. oldValue, err := m.oldValue(ctx)
  26835. if err != nil {
  26836. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26837. }
  26838. return oldValue.CreatedAt, nil
  26839. }
  26840. // ResetCreatedAt resets all changes to the "created_at" field.
  26841. func (m *UsageDetailMutation) ResetCreatedAt() {
  26842. m.created_at = nil
  26843. }
  26844. // SetUpdatedAt sets the "updated_at" field.
  26845. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  26846. m.updated_at = &t
  26847. }
  26848. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26849. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  26850. v := m.updated_at
  26851. if v == nil {
  26852. return
  26853. }
  26854. return *v, true
  26855. }
  26856. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  26857. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26859. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26860. if !m.op.Is(OpUpdateOne) {
  26861. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26862. }
  26863. if m.id == nil || m.oldValue == nil {
  26864. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26865. }
  26866. oldValue, err := m.oldValue(ctx)
  26867. if err != nil {
  26868. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26869. }
  26870. return oldValue.UpdatedAt, nil
  26871. }
  26872. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26873. func (m *UsageDetailMutation) ResetUpdatedAt() {
  26874. m.updated_at = nil
  26875. }
  26876. // SetStatus sets the "status" field.
  26877. func (m *UsageDetailMutation) SetStatus(u uint8) {
  26878. m.status = &u
  26879. m.addstatus = nil
  26880. }
  26881. // Status returns the value of the "status" field in the mutation.
  26882. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  26883. v := m.status
  26884. if v == nil {
  26885. return
  26886. }
  26887. return *v, true
  26888. }
  26889. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  26890. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26892. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26893. if !m.op.Is(OpUpdateOne) {
  26894. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26895. }
  26896. if m.id == nil || m.oldValue == nil {
  26897. return v, errors.New("OldStatus requires an ID field in the mutation")
  26898. }
  26899. oldValue, err := m.oldValue(ctx)
  26900. if err != nil {
  26901. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26902. }
  26903. return oldValue.Status, nil
  26904. }
  26905. // AddStatus adds u to the "status" field.
  26906. func (m *UsageDetailMutation) AddStatus(u int8) {
  26907. if m.addstatus != nil {
  26908. *m.addstatus += u
  26909. } else {
  26910. m.addstatus = &u
  26911. }
  26912. }
  26913. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26914. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  26915. v := m.addstatus
  26916. if v == nil {
  26917. return
  26918. }
  26919. return *v, true
  26920. }
  26921. // ClearStatus clears the value of the "status" field.
  26922. func (m *UsageDetailMutation) ClearStatus() {
  26923. m.status = nil
  26924. m.addstatus = nil
  26925. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  26926. }
  26927. // StatusCleared returns if the "status" field was cleared in this mutation.
  26928. func (m *UsageDetailMutation) StatusCleared() bool {
  26929. _, ok := m.clearedFields[usagedetail.FieldStatus]
  26930. return ok
  26931. }
  26932. // ResetStatus resets all changes to the "status" field.
  26933. func (m *UsageDetailMutation) ResetStatus() {
  26934. m.status = nil
  26935. m.addstatus = nil
  26936. delete(m.clearedFields, usagedetail.FieldStatus)
  26937. }
  26938. // SetType sets the "type" field.
  26939. func (m *UsageDetailMutation) SetType(i int) {
  26940. m._type = &i
  26941. m.add_type = nil
  26942. }
  26943. // GetType returns the value of the "type" field in the mutation.
  26944. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  26945. v := m._type
  26946. if v == nil {
  26947. return
  26948. }
  26949. return *v, true
  26950. }
  26951. // OldType returns the old "type" field's value of the UsageDetail entity.
  26952. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26954. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  26955. if !m.op.Is(OpUpdateOne) {
  26956. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26957. }
  26958. if m.id == nil || m.oldValue == nil {
  26959. return v, errors.New("OldType requires an ID field in the mutation")
  26960. }
  26961. oldValue, err := m.oldValue(ctx)
  26962. if err != nil {
  26963. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26964. }
  26965. return oldValue.Type, nil
  26966. }
  26967. // AddType adds i to the "type" field.
  26968. func (m *UsageDetailMutation) AddType(i int) {
  26969. if m.add_type != nil {
  26970. *m.add_type += i
  26971. } else {
  26972. m.add_type = &i
  26973. }
  26974. }
  26975. // AddedType returns the value that was added to the "type" field in this mutation.
  26976. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  26977. v := m.add_type
  26978. if v == nil {
  26979. return
  26980. }
  26981. return *v, true
  26982. }
  26983. // ClearType clears the value of the "type" field.
  26984. func (m *UsageDetailMutation) ClearType() {
  26985. m._type = nil
  26986. m.add_type = nil
  26987. m.clearedFields[usagedetail.FieldType] = struct{}{}
  26988. }
  26989. // TypeCleared returns if the "type" field was cleared in this mutation.
  26990. func (m *UsageDetailMutation) TypeCleared() bool {
  26991. _, ok := m.clearedFields[usagedetail.FieldType]
  26992. return ok
  26993. }
  26994. // ResetType resets all changes to the "type" field.
  26995. func (m *UsageDetailMutation) ResetType() {
  26996. m._type = nil
  26997. m.add_type = nil
  26998. delete(m.clearedFields, usagedetail.FieldType)
  26999. }
  27000. // SetBotID sets the "bot_id" field.
  27001. func (m *UsageDetailMutation) SetBotID(s string) {
  27002. m.bot_id = &s
  27003. }
  27004. // BotID returns the value of the "bot_id" field in the mutation.
  27005. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  27006. v := m.bot_id
  27007. if v == nil {
  27008. return
  27009. }
  27010. return *v, true
  27011. }
  27012. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  27013. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27015. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  27016. if !m.op.Is(OpUpdateOne) {
  27017. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  27018. }
  27019. if m.id == nil || m.oldValue == nil {
  27020. return v, errors.New("OldBotID requires an ID field in the mutation")
  27021. }
  27022. oldValue, err := m.oldValue(ctx)
  27023. if err != nil {
  27024. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27025. }
  27026. return oldValue.BotID, nil
  27027. }
  27028. // ResetBotID resets all changes to the "bot_id" field.
  27029. func (m *UsageDetailMutation) ResetBotID() {
  27030. m.bot_id = nil
  27031. }
  27032. // SetReceiverID sets the "receiver_id" field.
  27033. func (m *UsageDetailMutation) SetReceiverID(s string) {
  27034. m.receiver_id = &s
  27035. }
  27036. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  27037. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  27038. v := m.receiver_id
  27039. if v == nil {
  27040. return
  27041. }
  27042. return *v, true
  27043. }
  27044. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  27045. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27047. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  27048. if !m.op.Is(OpUpdateOne) {
  27049. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  27050. }
  27051. if m.id == nil || m.oldValue == nil {
  27052. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  27053. }
  27054. oldValue, err := m.oldValue(ctx)
  27055. if err != nil {
  27056. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  27057. }
  27058. return oldValue.ReceiverID, nil
  27059. }
  27060. // ResetReceiverID resets all changes to the "receiver_id" field.
  27061. func (m *UsageDetailMutation) ResetReceiverID() {
  27062. m.receiver_id = nil
  27063. }
  27064. // SetApp sets the "app" field.
  27065. func (m *UsageDetailMutation) SetApp(i int) {
  27066. m.app = &i
  27067. m.addapp = nil
  27068. }
  27069. // App returns the value of the "app" field in the mutation.
  27070. func (m *UsageDetailMutation) App() (r int, exists bool) {
  27071. v := m.app
  27072. if v == nil {
  27073. return
  27074. }
  27075. return *v, true
  27076. }
  27077. // OldApp returns the old "app" field's value of the UsageDetail entity.
  27078. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27080. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  27081. if !m.op.Is(OpUpdateOne) {
  27082. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  27083. }
  27084. if m.id == nil || m.oldValue == nil {
  27085. return v, errors.New("OldApp requires an ID field in the mutation")
  27086. }
  27087. oldValue, err := m.oldValue(ctx)
  27088. if err != nil {
  27089. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  27090. }
  27091. return oldValue.App, nil
  27092. }
  27093. // AddApp adds i to the "app" field.
  27094. func (m *UsageDetailMutation) AddApp(i int) {
  27095. if m.addapp != nil {
  27096. *m.addapp += i
  27097. } else {
  27098. m.addapp = &i
  27099. }
  27100. }
  27101. // AddedApp returns the value that was added to the "app" field in this mutation.
  27102. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  27103. v := m.addapp
  27104. if v == nil {
  27105. return
  27106. }
  27107. return *v, true
  27108. }
  27109. // ClearApp clears the value of the "app" field.
  27110. func (m *UsageDetailMutation) ClearApp() {
  27111. m.app = nil
  27112. m.addapp = nil
  27113. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  27114. }
  27115. // AppCleared returns if the "app" field was cleared in this mutation.
  27116. func (m *UsageDetailMutation) AppCleared() bool {
  27117. _, ok := m.clearedFields[usagedetail.FieldApp]
  27118. return ok
  27119. }
  27120. // ResetApp resets all changes to the "app" field.
  27121. func (m *UsageDetailMutation) ResetApp() {
  27122. m.app = nil
  27123. m.addapp = nil
  27124. delete(m.clearedFields, usagedetail.FieldApp)
  27125. }
  27126. // SetSessionID sets the "session_id" field.
  27127. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  27128. m.session_id = &u
  27129. m.addsession_id = nil
  27130. }
  27131. // SessionID returns the value of the "session_id" field in the mutation.
  27132. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  27133. v := m.session_id
  27134. if v == nil {
  27135. return
  27136. }
  27137. return *v, true
  27138. }
  27139. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  27140. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27142. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  27143. if !m.op.Is(OpUpdateOne) {
  27144. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  27145. }
  27146. if m.id == nil || m.oldValue == nil {
  27147. return v, errors.New("OldSessionID requires an ID field in the mutation")
  27148. }
  27149. oldValue, err := m.oldValue(ctx)
  27150. if err != nil {
  27151. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  27152. }
  27153. return oldValue.SessionID, nil
  27154. }
  27155. // AddSessionID adds u to the "session_id" field.
  27156. func (m *UsageDetailMutation) AddSessionID(u int64) {
  27157. if m.addsession_id != nil {
  27158. *m.addsession_id += u
  27159. } else {
  27160. m.addsession_id = &u
  27161. }
  27162. }
  27163. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  27164. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  27165. v := m.addsession_id
  27166. if v == nil {
  27167. return
  27168. }
  27169. return *v, true
  27170. }
  27171. // ClearSessionID clears the value of the "session_id" field.
  27172. func (m *UsageDetailMutation) ClearSessionID() {
  27173. m.session_id = nil
  27174. m.addsession_id = nil
  27175. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  27176. }
  27177. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  27178. func (m *UsageDetailMutation) SessionIDCleared() bool {
  27179. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  27180. return ok
  27181. }
  27182. // ResetSessionID resets all changes to the "session_id" field.
  27183. func (m *UsageDetailMutation) ResetSessionID() {
  27184. m.session_id = nil
  27185. m.addsession_id = nil
  27186. delete(m.clearedFields, usagedetail.FieldSessionID)
  27187. }
  27188. // SetRequest sets the "request" field.
  27189. func (m *UsageDetailMutation) SetRequest(s string) {
  27190. m.request = &s
  27191. }
  27192. // Request returns the value of the "request" field in the mutation.
  27193. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  27194. v := m.request
  27195. if v == nil {
  27196. return
  27197. }
  27198. return *v, true
  27199. }
  27200. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  27201. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27203. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  27204. if !m.op.Is(OpUpdateOne) {
  27205. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  27206. }
  27207. if m.id == nil || m.oldValue == nil {
  27208. return v, errors.New("OldRequest requires an ID field in the mutation")
  27209. }
  27210. oldValue, err := m.oldValue(ctx)
  27211. if err != nil {
  27212. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  27213. }
  27214. return oldValue.Request, nil
  27215. }
  27216. // ResetRequest resets all changes to the "request" field.
  27217. func (m *UsageDetailMutation) ResetRequest() {
  27218. m.request = nil
  27219. }
  27220. // SetResponse sets the "response" field.
  27221. func (m *UsageDetailMutation) SetResponse(s string) {
  27222. m.response = &s
  27223. }
  27224. // Response returns the value of the "response" field in the mutation.
  27225. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  27226. v := m.response
  27227. if v == nil {
  27228. return
  27229. }
  27230. return *v, true
  27231. }
  27232. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  27233. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27235. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  27236. if !m.op.Is(OpUpdateOne) {
  27237. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  27238. }
  27239. if m.id == nil || m.oldValue == nil {
  27240. return v, errors.New("OldResponse requires an ID field in the mutation")
  27241. }
  27242. oldValue, err := m.oldValue(ctx)
  27243. if err != nil {
  27244. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  27245. }
  27246. return oldValue.Response, nil
  27247. }
  27248. // ResetResponse resets all changes to the "response" field.
  27249. func (m *UsageDetailMutation) ResetResponse() {
  27250. m.response = nil
  27251. }
  27252. // SetOriginalData sets the "original_data" field.
  27253. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  27254. m.original_data = &ctd
  27255. }
  27256. // OriginalData returns the value of the "original_data" field in the mutation.
  27257. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  27258. v := m.original_data
  27259. if v == nil {
  27260. return
  27261. }
  27262. return *v, true
  27263. }
  27264. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  27265. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27267. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  27268. if !m.op.Is(OpUpdateOne) {
  27269. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  27270. }
  27271. if m.id == nil || m.oldValue == nil {
  27272. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  27273. }
  27274. oldValue, err := m.oldValue(ctx)
  27275. if err != nil {
  27276. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  27277. }
  27278. return oldValue.OriginalData, nil
  27279. }
  27280. // ResetOriginalData resets all changes to the "original_data" field.
  27281. func (m *UsageDetailMutation) ResetOriginalData() {
  27282. m.original_data = nil
  27283. }
  27284. // SetTotalTokens sets the "total_tokens" field.
  27285. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  27286. m.total_tokens = &u
  27287. m.addtotal_tokens = nil
  27288. }
  27289. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  27290. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  27291. v := m.total_tokens
  27292. if v == nil {
  27293. return
  27294. }
  27295. return *v, true
  27296. }
  27297. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  27298. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27300. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  27301. if !m.op.Is(OpUpdateOne) {
  27302. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  27303. }
  27304. if m.id == nil || m.oldValue == nil {
  27305. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  27306. }
  27307. oldValue, err := m.oldValue(ctx)
  27308. if err != nil {
  27309. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  27310. }
  27311. return oldValue.TotalTokens, nil
  27312. }
  27313. // AddTotalTokens adds u to the "total_tokens" field.
  27314. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  27315. if m.addtotal_tokens != nil {
  27316. *m.addtotal_tokens += u
  27317. } else {
  27318. m.addtotal_tokens = &u
  27319. }
  27320. }
  27321. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  27322. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  27323. v := m.addtotal_tokens
  27324. if v == nil {
  27325. return
  27326. }
  27327. return *v, true
  27328. }
  27329. // ClearTotalTokens clears the value of the "total_tokens" field.
  27330. func (m *UsageDetailMutation) ClearTotalTokens() {
  27331. m.total_tokens = nil
  27332. m.addtotal_tokens = nil
  27333. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  27334. }
  27335. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  27336. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  27337. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  27338. return ok
  27339. }
  27340. // ResetTotalTokens resets all changes to the "total_tokens" field.
  27341. func (m *UsageDetailMutation) ResetTotalTokens() {
  27342. m.total_tokens = nil
  27343. m.addtotal_tokens = nil
  27344. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  27345. }
  27346. // SetPromptTokens sets the "prompt_tokens" field.
  27347. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  27348. m.prompt_tokens = &u
  27349. m.addprompt_tokens = nil
  27350. }
  27351. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  27352. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  27353. v := m.prompt_tokens
  27354. if v == nil {
  27355. return
  27356. }
  27357. return *v, true
  27358. }
  27359. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  27360. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27362. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  27363. if !m.op.Is(OpUpdateOne) {
  27364. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  27365. }
  27366. if m.id == nil || m.oldValue == nil {
  27367. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  27368. }
  27369. oldValue, err := m.oldValue(ctx)
  27370. if err != nil {
  27371. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  27372. }
  27373. return oldValue.PromptTokens, nil
  27374. }
  27375. // AddPromptTokens adds u to the "prompt_tokens" field.
  27376. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  27377. if m.addprompt_tokens != nil {
  27378. *m.addprompt_tokens += u
  27379. } else {
  27380. m.addprompt_tokens = &u
  27381. }
  27382. }
  27383. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  27384. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  27385. v := m.addprompt_tokens
  27386. if v == nil {
  27387. return
  27388. }
  27389. return *v, true
  27390. }
  27391. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  27392. func (m *UsageDetailMutation) ClearPromptTokens() {
  27393. m.prompt_tokens = nil
  27394. m.addprompt_tokens = nil
  27395. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  27396. }
  27397. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  27398. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  27399. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  27400. return ok
  27401. }
  27402. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  27403. func (m *UsageDetailMutation) ResetPromptTokens() {
  27404. m.prompt_tokens = nil
  27405. m.addprompt_tokens = nil
  27406. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  27407. }
  27408. // SetCompletionTokens sets the "completion_tokens" field.
  27409. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  27410. m.completion_tokens = &u
  27411. m.addcompletion_tokens = nil
  27412. }
  27413. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  27414. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  27415. v := m.completion_tokens
  27416. if v == nil {
  27417. return
  27418. }
  27419. return *v, true
  27420. }
  27421. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  27422. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27424. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  27425. if !m.op.Is(OpUpdateOne) {
  27426. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  27427. }
  27428. if m.id == nil || m.oldValue == nil {
  27429. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  27430. }
  27431. oldValue, err := m.oldValue(ctx)
  27432. if err != nil {
  27433. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  27434. }
  27435. return oldValue.CompletionTokens, nil
  27436. }
  27437. // AddCompletionTokens adds u to the "completion_tokens" field.
  27438. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  27439. if m.addcompletion_tokens != nil {
  27440. *m.addcompletion_tokens += u
  27441. } else {
  27442. m.addcompletion_tokens = &u
  27443. }
  27444. }
  27445. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  27446. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  27447. v := m.addcompletion_tokens
  27448. if v == nil {
  27449. return
  27450. }
  27451. return *v, true
  27452. }
  27453. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  27454. func (m *UsageDetailMutation) ClearCompletionTokens() {
  27455. m.completion_tokens = nil
  27456. m.addcompletion_tokens = nil
  27457. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  27458. }
  27459. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  27460. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  27461. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  27462. return ok
  27463. }
  27464. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  27465. func (m *UsageDetailMutation) ResetCompletionTokens() {
  27466. m.completion_tokens = nil
  27467. m.addcompletion_tokens = nil
  27468. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  27469. }
  27470. // SetOrganizationID sets the "organization_id" field.
  27471. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  27472. m.organization_id = &u
  27473. m.addorganization_id = nil
  27474. }
  27475. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27476. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  27477. v := m.organization_id
  27478. if v == nil {
  27479. return
  27480. }
  27481. return *v, true
  27482. }
  27483. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  27484. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27486. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27487. if !m.op.Is(OpUpdateOne) {
  27488. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27489. }
  27490. if m.id == nil || m.oldValue == nil {
  27491. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27492. }
  27493. oldValue, err := m.oldValue(ctx)
  27494. if err != nil {
  27495. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27496. }
  27497. return oldValue.OrganizationID, nil
  27498. }
  27499. // AddOrganizationID adds u to the "organization_id" field.
  27500. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  27501. if m.addorganization_id != nil {
  27502. *m.addorganization_id += u
  27503. } else {
  27504. m.addorganization_id = &u
  27505. }
  27506. }
  27507. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27508. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  27509. v := m.addorganization_id
  27510. if v == nil {
  27511. return
  27512. }
  27513. return *v, true
  27514. }
  27515. // ClearOrganizationID clears the value of the "organization_id" field.
  27516. func (m *UsageDetailMutation) ClearOrganizationID() {
  27517. m.organization_id = nil
  27518. m.addorganization_id = nil
  27519. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  27520. }
  27521. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27522. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  27523. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  27524. return ok
  27525. }
  27526. // ResetOrganizationID resets all changes to the "organization_id" field.
  27527. func (m *UsageDetailMutation) ResetOrganizationID() {
  27528. m.organization_id = nil
  27529. m.addorganization_id = nil
  27530. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  27531. }
  27532. // Where appends a list predicates to the UsageDetailMutation builder.
  27533. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  27534. m.predicates = append(m.predicates, ps...)
  27535. }
  27536. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  27537. // users can use type-assertion to append predicates that do not depend on any generated package.
  27538. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  27539. p := make([]predicate.UsageDetail, len(ps))
  27540. for i := range ps {
  27541. p[i] = ps[i]
  27542. }
  27543. m.Where(p...)
  27544. }
  27545. // Op returns the operation name.
  27546. func (m *UsageDetailMutation) Op() Op {
  27547. return m.op
  27548. }
  27549. // SetOp allows setting the mutation operation.
  27550. func (m *UsageDetailMutation) SetOp(op Op) {
  27551. m.op = op
  27552. }
  27553. // Type returns the node type of this mutation (UsageDetail).
  27554. func (m *UsageDetailMutation) Type() string {
  27555. return m.typ
  27556. }
  27557. // Fields returns all fields that were changed during this mutation. Note that in
  27558. // order to get all numeric fields that were incremented/decremented, call
  27559. // AddedFields().
  27560. func (m *UsageDetailMutation) Fields() []string {
  27561. fields := make([]string, 0, 15)
  27562. if m.created_at != nil {
  27563. fields = append(fields, usagedetail.FieldCreatedAt)
  27564. }
  27565. if m.updated_at != nil {
  27566. fields = append(fields, usagedetail.FieldUpdatedAt)
  27567. }
  27568. if m.status != nil {
  27569. fields = append(fields, usagedetail.FieldStatus)
  27570. }
  27571. if m._type != nil {
  27572. fields = append(fields, usagedetail.FieldType)
  27573. }
  27574. if m.bot_id != nil {
  27575. fields = append(fields, usagedetail.FieldBotID)
  27576. }
  27577. if m.receiver_id != nil {
  27578. fields = append(fields, usagedetail.FieldReceiverID)
  27579. }
  27580. if m.app != nil {
  27581. fields = append(fields, usagedetail.FieldApp)
  27582. }
  27583. if m.session_id != nil {
  27584. fields = append(fields, usagedetail.FieldSessionID)
  27585. }
  27586. if m.request != nil {
  27587. fields = append(fields, usagedetail.FieldRequest)
  27588. }
  27589. if m.response != nil {
  27590. fields = append(fields, usagedetail.FieldResponse)
  27591. }
  27592. if m.original_data != nil {
  27593. fields = append(fields, usagedetail.FieldOriginalData)
  27594. }
  27595. if m.total_tokens != nil {
  27596. fields = append(fields, usagedetail.FieldTotalTokens)
  27597. }
  27598. if m.prompt_tokens != nil {
  27599. fields = append(fields, usagedetail.FieldPromptTokens)
  27600. }
  27601. if m.completion_tokens != nil {
  27602. fields = append(fields, usagedetail.FieldCompletionTokens)
  27603. }
  27604. if m.organization_id != nil {
  27605. fields = append(fields, usagedetail.FieldOrganizationID)
  27606. }
  27607. return fields
  27608. }
  27609. // Field returns the value of a field with the given name. The second boolean
  27610. // return value indicates that this field was not set, or was not defined in the
  27611. // schema.
  27612. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  27613. switch name {
  27614. case usagedetail.FieldCreatedAt:
  27615. return m.CreatedAt()
  27616. case usagedetail.FieldUpdatedAt:
  27617. return m.UpdatedAt()
  27618. case usagedetail.FieldStatus:
  27619. return m.Status()
  27620. case usagedetail.FieldType:
  27621. return m.GetType()
  27622. case usagedetail.FieldBotID:
  27623. return m.BotID()
  27624. case usagedetail.FieldReceiverID:
  27625. return m.ReceiverID()
  27626. case usagedetail.FieldApp:
  27627. return m.App()
  27628. case usagedetail.FieldSessionID:
  27629. return m.SessionID()
  27630. case usagedetail.FieldRequest:
  27631. return m.Request()
  27632. case usagedetail.FieldResponse:
  27633. return m.Response()
  27634. case usagedetail.FieldOriginalData:
  27635. return m.OriginalData()
  27636. case usagedetail.FieldTotalTokens:
  27637. return m.TotalTokens()
  27638. case usagedetail.FieldPromptTokens:
  27639. return m.PromptTokens()
  27640. case usagedetail.FieldCompletionTokens:
  27641. return m.CompletionTokens()
  27642. case usagedetail.FieldOrganizationID:
  27643. return m.OrganizationID()
  27644. }
  27645. return nil, false
  27646. }
  27647. // OldField returns the old value of the field from the database. An error is
  27648. // returned if the mutation operation is not UpdateOne, or the query to the
  27649. // database failed.
  27650. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27651. switch name {
  27652. case usagedetail.FieldCreatedAt:
  27653. return m.OldCreatedAt(ctx)
  27654. case usagedetail.FieldUpdatedAt:
  27655. return m.OldUpdatedAt(ctx)
  27656. case usagedetail.FieldStatus:
  27657. return m.OldStatus(ctx)
  27658. case usagedetail.FieldType:
  27659. return m.OldType(ctx)
  27660. case usagedetail.FieldBotID:
  27661. return m.OldBotID(ctx)
  27662. case usagedetail.FieldReceiverID:
  27663. return m.OldReceiverID(ctx)
  27664. case usagedetail.FieldApp:
  27665. return m.OldApp(ctx)
  27666. case usagedetail.FieldSessionID:
  27667. return m.OldSessionID(ctx)
  27668. case usagedetail.FieldRequest:
  27669. return m.OldRequest(ctx)
  27670. case usagedetail.FieldResponse:
  27671. return m.OldResponse(ctx)
  27672. case usagedetail.FieldOriginalData:
  27673. return m.OldOriginalData(ctx)
  27674. case usagedetail.FieldTotalTokens:
  27675. return m.OldTotalTokens(ctx)
  27676. case usagedetail.FieldPromptTokens:
  27677. return m.OldPromptTokens(ctx)
  27678. case usagedetail.FieldCompletionTokens:
  27679. return m.OldCompletionTokens(ctx)
  27680. case usagedetail.FieldOrganizationID:
  27681. return m.OldOrganizationID(ctx)
  27682. }
  27683. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  27684. }
  27685. // SetField sets the value of a field with the given name. It returns an error if
  27686. // the field is not defined in the schema, or if the type mismatched the field
  27687. // type.
  27688. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  27689. switch name {
  27690. case usagedetail.FieldCreatedAt:
  27691. v, ok := value.(time.Time)
  27692. if !ok {
  27693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27694. }
  27695. m.SetCreatedAt(v)
  27696. return nil
  27697. case usagedetail.FieldUpdatedAt:
  27698. v, ok := value.(time.Time)
  27699. if !ok {
  27700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27701. }
  27702. m.SetUpdatedAt(v)
  27703. return nil
  27704. case usagedetail.FieldStatus:
  27705. v, ok := value.(uint8)
  27706. if !ok {
  27707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27708. }
  27709. m.SetStatus(v)
  27710. return nil
  27711. case usagedetail.FieldType:
  27712. v, ok := value.(int)
  27713. if !ok {
  27714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27715. }
  27716. m.SetType(v)
  27717. return nil
  27718. case usagedetail.FieldBotID:
  27719. v, ok := value.(string)
  27720. if !ok {
  27721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27722. }
  27723. m.SetBotID(v)
  27724. return nil
  27725. case usagedetail.FieldReceiverID:
  27726. v, ok := value.(string)
  27727. if !ok {
  27728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27729. }
  27730. m.SetReceiverID(v)
  27731. return nil
  27732. case usagedetail.FieldApp:
  27733. v, ok := value.(int)
  27734. if !ok {
  27735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27736. }
  27737. m.SetApp(v)
  27738. return nil
  27739. case usagedetail.FieldSessionID:
  27740. v, ok := value.(uint64)
  27741. if !ok {
  27742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27743. }
  27744. m.SetSessionID(v)
  27745. return nil
  27746. case usagedetail.FieldRequest:
  27747. v, ok := value.(string)
  27748. if !ok {
  27749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27750. }
  27751. m.SetRequest(v)
  27752. return nil
  27753. case usagedetail.FieldResponse:
  27754. v, ok := value.(string)
  27755. if !ok {
  27756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27757. }
  27758. m.SetResponse(v)
  27759. return nil
  27760. case usagedetail.FieldOriginalData:
  27761. v, ok := value.(custom_types.OriginalData)
  27762. if !ok {
  27763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27764. }
  27765. m.SetOriginalData(v)
  27766. return nil
  27767. case usagedetail.FieldTotalTokens:
  27768. v, ok := value.(uint64)
  27769. if !ok {
  27770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27771. }
  27772. m.SetTotalTokens(v)
  27773. return nil
  27774. case usagedetail.FieldPromptTokens:
  27775. v, ok := value.(uint64)
  27776. if !ok {
  27777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27778. }
  27779. m.SetPromptTokens(v)
  27780. return nil
  27781. case usagedetail.FieldCompletionTokens:
  27782. v, ok := value.(uint64)
  27783. if !ok {
  27784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27785. }
  27786. m.SetCompletionTokens(v)
  27787. return nil
  27788. case usagedetail.FieldOrganizationID:
  27789. v, ok := value.(uint64)
  27790. if !ok {
  27791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27792. }
  27793. m.SetOrganizationID(v)
  27794. return nil
  27795. }
  27796. return fmt.Errorf("unknown UsageDetail field %s", name)
  27797. }
  27798. // AddedFields returns all numeric fields that were incremented/decremented during
  27799. // this mutation.
  27800. func (m *UsageDetailMutation) AddedFields() []string {
  27801. var fields []string
  27802. if m.addstatus != nil {
  27803. fields = append(fields, usagedetail.FieldStatus)
  27804. }
  27805. if m.add_type != nil {
  27806. fields = append(fields, usagedetail.FieldType)
  27807. }
  27808. if m.addapp != nil {
  27809. fields = append(fields, usagedetail.FieldApp)
  27810. }
  27811. if m.addsession_id != nil {
  27812. fields = append(fields, usagedetail.FieldSessionID)
  27813. }
  27814. if m.addtotal_tokens != nil {
  27815. fields = append(fields, usagedetail.FieldTotalTokens)
  27816. }
  27817. if m.addprompt_tokens != nil {
  27818. fields = append(fields, usagedetail.FieldPromptTokens)
  27819. }
  27820. if m.addcompletion_tokens != nil {
  27821. fields = append(fields, usagedetail.FieldCompletionTokens)
  27822. }
  27823. if m.addorganization_id != nil {
  27824. fields = append(fields, usagedetail.FieldOrganizationID)
  27825. }
  27826. return fields
  27827. }
  27828. // AddedField returns the numeric value that was incremented/decremented on a field
  27829. // with the given name. The second boolean return value indicates that this field
  27830. // was not set, or was not defined in the schema.
  27831. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  27832. switch name {
  27833. case usagedetail.FieldStatus:
  27834. return m.AddedStatus()
  27835. case usagedetail.FieldType:
  27836. return m.AddedType()
  27837. case usagedetail.FieldApp:
  27838. return m.AddedApp()
  27839. case usagedetail.FieldSessionID:
  27840. return m.AddedSessionID()
  27841. case usagedetail.FieldTotalTokens:
  27842. return m.AddedTotalTokens()
  27843. case usagedetail.FieldPromptTokens:
  27844. return m.AddedPromptTokens()
  27845. case usagedetail.FieldCompletionTokens:
  27846. return m.AddedCompletionTokens()
  27847. case usagedetail.FieldOrganizationID:
  27848. return m.AddedOrganizationID()
  27849. }
  27850. return nil, false
  27851. }
  27852. // AddField adds the value to the field with the given name. It returns an error if
  27853. // the field is not defined in the schema, or if the type mismatched the field
  27854. // type.
  27855. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  27856. switch name {
  27857. case usagedetail.FieldStatus:
  27858. v, ok := value.(int8)
  27859. if !ok {
  27860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27861. }
  27862. m.AddStatus(v)
  27863. return nil
  27864. case usagedetail.FieldType:
  27865. v, ok := value.(int)
  27866. if !ok {
  27867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27868. }
  27869. m.AddType(v)
  27870. return nil
  27871. case usagedetail.FieldApp:
  27872. v, ok := value.(int)
  27873. if !ok {
  27874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27875. }
  27876. m.AddApp(v)
  27877. return nil
  27878. case usagedetail.FieldSessionID:
  27879. v, ok := value.(int64)
  27880. if !ok {
  27881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27882. }
  27883. m.AddSessionID(v)
  27884. return nil
  27885. case usagedetail.FieldTotalTokens:
  27886. v, ok := value.(int64)
  27887. if !ok {
  27888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27889. }
  27890. m.AddTotalTokens(v)
  27891. return nil
  27892. case usagedetail.FieldPromptTokens:
  27893. v, ok := value.(int64)
  27894. if !ok {
  27895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27896. }
  27897. m.AddPromptTokens(v)
  27898. return nil
  27899. case usagedetail.FieldCompletionTokens:
  27900. v, ok := value.(int64)
  27901. if !ok {
  27902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27903. }
  27904. m.AddCompletionTokens(v)
  27905. return nil
  27906. case usagedetail.FieldOrganizationID:
  27907. v, ok := value.(int64)
  27908. if !ok {
  27909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27910. }
  27911. m.AddOrganizationID(v)
  27912. return nil
  27913. }
  27914. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  27915. }
  27916. // ClearedFields returns all nullable fields that were cleared during this
  27917. // mutation.
  27918. func (m *UsageDetailMutation) ClearedFields() []string {
  27919. var fields []string
  27920. if m.FieldCleared(usagedetail.FieldStatus) {
  27921. fields = append(fields, usagedetail.FieldStatus)
  27922. }
  27923. if m.FieldCleared(usagedetail.FieldType) {
  27924. fields = append(fields, usagedetail.FieldType)
  27925. }
  27926. if m.FieldCleared(usagedetail.FieldApp) {
  27927. fields = append(fields, usagedetail.FieldApp)
  27928. }
  27929. if m.FieldCleared(usagedetail.FieldSessionID) {
  27930. fields = append(fields, usagedetail.FieldSessionID)
  27931. }
  27932. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  27933. fields = append(fields, usagedetail.FieldTotalTokens)
  27934. }
  27935. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  27936. fields = append(fields, usagedetail.FieldPromptTokens)
  27937. }
  27938. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  27939. fields = append(fields, usagedetail.FieldCompletionTokens)
  27940. }
  27941. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  27942. fields = append(fields, usagedetail.FieldOrganizationID)
  27943. }
  27944. return fields
  27945. }
  27946. // FieldCleared returns a boolean indicating if a field with the given name was
  27947. // cleared in this mutation.
  27948. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  27949. _, ok := m.clearedFields[name]
  27950. return ok
  27951. }
  27952. // ClearField clears the value of the field with the given name. It returns an
  27953. // error if the field is not defined in the schema.
  27954. func (m *UsageDetailMutation) ClearField(name string) error {
  27955. switch name {
  27956. case usagedetail.FieldStatus:
  27957. m.ClearStatus()
  27958. return nil
  27959. case usagedetail.FieldType:
  27960. m.ClearType()
  27961. return nil
  27962. case usagedetail.FieldApp:
  27963. m.ClearApp()
  27964. return nil
  27965. case usagedetail.FieldSessionID:
  27966. m.ClearSessionID()
  27967. return nil
  27968. case usagedetail.FieldTotalTokens:
  27969. m.ClearTotalTokens()
  27970. return nil
  27971. case usagedetail.FieldPromptTokens:
  27972. m.ClearPromptTokens()
  27973. return nil
  27974. case usagedetail.FieldCompletionTokens:
  27975. m.ClearCompletionTokens()
  27976. return nil
  27977. case usagedetail.FieldOrganizationID:
  27978. m.ClearOrganizationID()
  27979. return nil
  27980. }
  27981. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  27982. }
  27983. // ResetField resets all changes in the mutation for the field with the given name.
  27984. // It returns an error if the field is not defined in the schema.
  27985. func (m *UsageDetailMutation) ResetField(name string) error {
  27986. switch name {
  27987. case usagedetail.FieldCreatedAt:
  27988. m.ResetCreatedAt()
  27989. return nil
  27990. case usagedetail.FieldUpdatedAt:
  27991. m.ResetUpdatedAt()
  27992. return nil
  27993. case usagedetail.FieldStatus:
  27994. m.ResetStatus()
  27995. return nil
  27996. case usagedetail.FieldType:
  27997. m.ResetType()
  27998. return nil
  27999. case usagedetail.FieldBotID:
  28000. m.ResetBotID()
  28001. return nil
  28002. case usagedetail.FieldReceiverID:
  28003. m.ResetReceiverID()
  28004. return nil
  28005. case usagedetail.FieldApp:
  28006. m.ResetApp()
  28007. return nil
  28008. case usagedetail.FieldSessionID:
  28009. m.ResetSessionID()
  28010. return nil
  28011. case usagedetail.FieldRequest:
  28012. m.ResetRequest()
  28013. return nil
  28014. case usagedetail.FieldResponse:
  28015. m.ResetResponse()
  28016. return nil
  28017. case usagedetail.FieldOriginalData:
  28018. m.ResetOriginalData()
  28019. return nil
  28020. case usagedetail.FieldTotalTokens:
  28021. m.ResetTotalTokens()
  28022. return nil
  28023. case usagedetail.FieldPromptTokens:
  28024. m.ResetPromptTokens()
  28025. return nil
  28026. case usagedetail.FieldCompletionTokens:
  28027. m.ResetCompletionTokens()
  28028. return nil
  28029. case usagedetail.FieldOrganizationID:
  28030. m.ResetOrganizationID()
  28031. return nil
  28032. }
  28033. return fmt.Errorf("unknown UsageDetail field %s", name)
  28034. }
  28035. // AddedEdges returns all edge names that were set/added in this mutation.
  28036. func (m *UsageDetailMutation) AddedEdges() []string {
  28037. edges := make([]string, 0, 0)
  28038. return edges
  28039. }
  28040. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28041. // name in this mutation.
  28042. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  28043. return nil
  28044. }
  28045. // RemovedEdges returns all edge names that were removed in this mutation.
  28046. func (m *UsageDetailMutation) RemovedEdges() []string {
  28047. edges := make([]string, 0, 0)
  28048. return edges
  28049. }
  28050. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28051. // the given name in this mutation.
  28052. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  28053. return nil
  28054. }
  28055. // ClearedEdges returns all edge names that were cleared in this mutation.
  28056. func (m *UsageDetailMutation) ClearedEdges() []string {
  28057. edges := make([]string, 0, 0)
  28058. return edges
  28059. }
  28060. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28061. // was cleared in this mutation.
  28062. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  28063. return false
  28064. }
  28065. // ClearEdge clears the value of the edge with the given name. It returns an error
  28066. // if that edge is not defined in the schema.
  28067. func (m *UsageDetailMutation) ClearEdge(name string) error {
  28068. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  28069. }
  28070. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28071. // It returns an error if the edge is not defined in the schema.
  28072. func (m *UsageDetailMutation) ResetEdge(name string) error {
  28073. return fmt.Errorf("unknown UsageDetail edge %s", name)
  28074. }
  28075. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  28076. type UsageStatisticDayMutation struct {
  28077. config
  28078. op Op
  28079. typ string
  28080. id *uint64
  28081. created_at *time.Time
  28082. updated_at *time.Time
  28083. status *uint8
  28084. addstatus *int8
  28085. deleted_at *time.Time
  28086. addtime *uint64
  28087. addaddtime *int64
  28088. _type *int
  28089. add_type *int
  28090. bot_id *string
  28091. organization_id *uint64
  28092. addorganization_id *int64
  28093. ai_response *uint64
  28094. addai_response *int64
  28095. sop_run *uint64
  28096. addsop_run *int64
  28097. total_friend *uint64
  28098. addtotal_friend *int64
  28099. total_group *uint64
  28100. addtotal_group *int64
  28101. account_balance *uint64
  28102. addaccount_balance *int64
  28103. consume_token *uint64
  28104. addconsume_token *int64
  28105. active_user *uint64
  28106. addactive_user *int64
  28107. new_user *int64
  28108. addnew_user *int64
  28109. label_dist *[]custom_types.LabelDist
  28110. appendlabel_dist []custom_types.LabelDist
  28111. clearedFields map[string]struct{}
  28112. done bool
  28113. oldValue func(context.Context) (*UsageStatisticDay, error)
  28114. predicates []predicate.UsageStatisticDay
  28115. }
  28116. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  28117. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  28118. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  28119. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  28120. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  28121. m := &UsageStatisticDayMutation{
  28122. config: c,
  28123. op: op,
  28124. typ: TypeUsageStatisticDay,
  28125. clearedFields: make(map[string]struct{}),
  28126. }
  28127. for _, opt := range opts {
  28128. opt(m)
  28129. }
  28130. return m
  28131. }
  28132. // withUsageStatisticDayID sets the ID field of the mutation.
  28133. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  28134. return func(m *UsageStatisticDayMutation) {
  28135. var (
  28136. err error
  28137. once sync.Once
  28138. value *UsageStatisticDay
  28139. )
  28140. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  28141. once.Do(func() {
  28142. if m.done {
  28143. err = errors.New("querying old values post mutation is not allowed")
  28144. } else {
  28145. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  28146. }
  28147. })
  28148. return value, err
  28149. }
  28150. m.id = &id
  28151. }
  28152. }
  28153. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  28154. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  28155. return func(m *UsageStatisticDayMutation) {
  28156. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  28157. return node, nil
  28158. }
  28159. m.id = &node.ID
  28160. }
  28161. }
  28162. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28163. // executed in a transaction (ent.Tx), a transactional client is returned.
  28164. func (m UsageStatisticDayMutation) Client() *Client {
  28165. client := &Client{config: m.config}
  28166. client.init()
  28167. return client
  28168. }
  28169. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28170. // it returns an error otherwise.
  28171. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  28172. if _, ok := m.driver.(*txDriver); !ok {
  28173. return nil, errors.New("ent: mutation is not running in a transaction")
  28174. }
  28175. tx := &Tx{config: m.config}
  28176. tx.init()
  28177. return tx, nil
  28178. }
  28179. // SetID sets the value of the id field. Note that this
  28180. // operation is only accepted on creation of UsageStatisticDay entities.
  28181. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  28182. m.id = &id
  28183. }
  28184. // ID returns the ID value in the mutation. Note that the ID is only available
  28185. // if it was provided to the builder or after it was returned from the database.
  28186. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  28187. if m.id == nil {
  28188. return
  28189. }
  28190. return *m.id, true
  28191. }
  28192. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28193. // That means, if the mutation is applied within a transaction with an isolation level such
  28194. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28195. // or updated by the mutation.
  28196. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  28197. switch {
  28198. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28199. id, exists := m.ID()
  28200. if exists {
  28201. return []uint64{id}, nil
  28202. }
  28203. fallthrough
  28204. case m.op.Is(OpUpdate | OpDelete):
  28205. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  28206. default:
  28207. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28208. }
  28209. }
  28210. // SetCreatedAt sets the "created_at" field.
  28211. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  28212. m.created_at = &t
  28213. }
  28214. // CreatedAt returns the value of the "created_at" field in the mutation.
  28215. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  28216. v := m.created_at
  28217. if v == nil {
  28218. return
  28219. }
  28220. return *v, true
  28221. }
  28222. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  28223. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28225. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28226. if !m.op.Is(OpUpdateOne) {
  28227. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28228. }
  28229. if m.id == nil || m.oldValue == nil {
  28230. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28231. }
  28232. oldValue, err := m.oldValue(ctx)
  28233. if err != nil {
  28234. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28235. }
  28236. return oldValue.CreatedAt, nil
  28237. }
  28238. // ResetCreatedAt resets all changes to the "created_at" field.
  28239. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  28240. m.created_at = nil
  28241. }
  28242. // SetUpdatedAt sets the "updated_at" field.
  28243. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  28244. m.updated_at = &t
  28245. }
  28246. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28247. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  28248. v := m.updated_at
  28249. if v == nil {
  28250. return
  28251. }
  28252. return *v, true
  28253. }
  28254. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  28255. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28257. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28258. if !m.op.Is(OpUpdateOne) {
  28259. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28260. }
  28261. if m.id == nil || m.oldValue == nil {
  28262. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28263. }
  28264. oldValue, err := m.oldValue(ctx)
  28265. if err != nil {
  28266. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28267. }
  28268. return oldValue.UpdatedAt, nil
  28269. }
  28270. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28271. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  28272. m.updated_at = nil
  28273. }
  28274. // SetStatus sets the "status" field.
  28275. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  28276. m.status = &u
  28277. m.addstatus = nil
  28278. }
  28279. // Status returns the value of the "status" field in the mutation.
  28280. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  28281. v := m.status
  28282. if v == nil {
  28283. return
  28284. }
  28285. return *v, true
  28286. }
  28287. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  28288. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28290. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28291. if !m.op.Is(OpUpdateOne) {
  28292. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28293. }
  28294. if m.id == nil || m.oldValue == nil {
  28295. return v, errors.New("OldStatus requires an ID field in the mutation")
  28296. }
  28297. oldValue, err := m.oldValue(ctx)
  28298. if err != nil {
  28299. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28300. }
  28301. return oldValue.Status, nil
  28302. }
  28303. // AddStatus adds u to the "status" field.
  28304. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  28305. if m.addstatus != nil {
  28306. *m.addstatus += u
  28307. } else {
  28308. m.addstatus = &u
  28309. }
  28310. }
  28311. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28312. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  28313. v := m.addstatus
  28314. if v == nil {
  28315. return
  28316. }
  28317. return *v, true
  28318. }
  28319. // ClearStatus clears the value of the "status" field.
  28320. func (m *UsageStatisticDayMutation) ClearStatus() {
  28321. m.status = nil
  28322. m.addstatus = nil
  28323. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  28324. }
  28325. // StatusCleared returns if the "status" field was cleared in this mutation.
  28326. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  28327. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  28328. return ok
  28329. }
  28330. // ResetStatus resets all changes to the "status" field.
  28331. func (m *UsageStatisticDayMutation) ResetStatus() {
  28332. m.status = nil
  28333. m.addstatus = nil
  28334. delete(m.clearedFields, usagestatisticday.FieldStatus)
  28335. }
  28336. // SetDeletedAt sets the "deleted_at" field.
  28337. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  28338. m.deleted_at = &t
  28339. }
  28340. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28341. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  28342. v := m.deleted_at
  28343. if v == nil {
  28344. return
  28345. }
  28346. return *v, true
  28347. }
  28348. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  28349. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28351. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28352. if !m.op.Is(OpUpdateOne) {
  28353. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28354. }
  28355. if m.id == nil || m.oldValue == nil {
  28356. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28357. }
  28358. oldValue, err := m.oldValue(ctx)
  28359. if err != nil {
  28360. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28361. }
  28362. return oldValue.DeletedAt, nil
  28363. }
  28364. // ClearDeletedAt clears the value of the "deleted_at" field.
  28365. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  28366. m.deleted_at = nil
  28367. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  28368. }
  28369. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28370. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  28371. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  28372. return ok
  28373. }
  28374. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28375. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  28376. m.deleted_at = nil
  28377. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  28378. }
  28379. // SetAddtime sets the "addtime" field.
  28380. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  28381. m.addtime = &u
  28382. m.addaddtime = nil
  28383. }
  28384. // Addtime returns the value of the "addtime" field in the mutation.
  28385. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  28386. v := m.addtime
  28387. if v == nil {
  28388. return
  28389. }
  28390. return *v, true
  28391. }
  28392. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  28393. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28395. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  28396. if !m.op.Is(OpUpdateOne) {
  28397. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  28398. }
  28399. if m.id == nil || m.oldValue == nil {
  28400. return v, errors.New("OldAddtime requires an ID field in the mutation")
  28401. }
  28402. oldValue, err := m.oldValue(ctx)
  28403. if err != nil {
  28404. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  28405. }
  28406. return oldValue.Addtime, nil
  28407. }
  28408. // AddAddtime adds u to the "addtime" field.
  28409. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  28410. if m.addaddtime != nil {
  28411. *m.addaddtime += u
  28412. } else {
  28413. m.addaddtime = &u
  28414. }
  28415. }
  28416. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  28417. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  28418. v := m.addaddtime
  28419. if v == nil {
  28420. return
  28421. }
  28422. return *v, true
  28423. }
  28424. // ResetAddtime resets all changes to the "addtime" field.
  28425. func (m *UsageStatisticDayMutation) ResetAddtime() {
  28426. m.addtime = nil
  28427. m.addaddtime = nil
  28428. }
  28429. // SetType sets the "type" field.
  28430. func (m *UsageStatisticDayMutation) SetType(i int) {
  28431. m._type = &i
  28432. m.add_type = nil
  28433. }
  28434. // GetType returns the value of the "type" field in the mutation.
  28435. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  28436. v := m._type
  28437. if v == nil {
  28438. return
  28439. }
  28440. return *v, true
  28441. }
  28442. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  28443. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28445. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  28446. if !m.op.Is(OpUpdateOne) {
  28447. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28448. }
  28449. if m.id == nil || m.oldValue == nil {
  28450. return v, errors.New("OldType requires an ID field in the mutation")
  28451. }
  28452. oldValue, err := m.oldValue(ctx)
  28453. if err != nil {
  28454. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28455. }
  28456. return oldValue.Type, nil
  28457. }
  28458. // AddType adds i to the "type" field.
  28459. func (m *UsageStatisticDayMutation) AddType(i int) {
  28460. if m.add_type != nil {
  28461. *m.add_type += i
  28462. } else {
  28463. m.add_type = &i
  28464. }
  28465. }
  28466. // AddedType returns the value that was added to the "type" field in this mutation.
  28467. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  28468. v := m.add_type
  28469. if v == nil {
  28470. return
  28471. }
  28472. return *v, true
  28473. }
  28474. // ResetType resets all changes to the "type" field.
  28475. func (m *UsageStatisticDayMutation) ResetType() {
  28476. m._type = nil
  28477. m.add_type = nil
  28478. }
  28479. // SetBotID sets the "bot_id" field.
  28480. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  28481. m.bot_id = &s
  28482. }
  28483. // BotID returns the value of the "bot_id" field in the mutation.
  28484. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  28485. v := m.bot_id
  28486. if v == nil {
  28487. return
  28488. }
  28489. return *v, true
  28490. }
  28491. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  28492. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28494. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  28495. if !m.op.Is(OpUpdateOne) {
  28496. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28497. }
  28498. if m.id == nil || m.oldValue == nil {
  28499. return v, errors.New("OldBotID requires an ID field in the mutation")
  28500. }
  28501. oldValue, err := m.oldValue(ctx)
  28502. if err != nil {
  28503. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28504. }
  28505. return oldValue.BotID, nil
  28506. }
  28507. // ClearBotID clears the value of the "bot_id" field.
  28508. func (m *UsageStatisticDayMutation) ClearBotID() {
  28509. m.bot_id = nil
  28510. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  28511. }
  28512. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28513. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  28514. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  28515. return ok
  28516. }
  28517. // ResetBotID resets all changes to the "bot_id" field.
  28518. func (m *UsageStatisticDayMutation) ResetBotID() {
  28519. m.bot_id = nil
  28520. delete(m.clearedFields, usagestatisticday.FieldBotID)
  28521. }
  28522. // SetOrganizationID sets the "organization_id" field.
  28523. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  28524. m.organization_id = &u
  28525. m.addorganization_id = nil
  28526. }
  28527. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28528. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  28529. v := m.organization_id
  28530. if v == nil {
  28531. return
  28532. }
  28533. return *v, true
  28534. }
  28535. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  28536. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28538. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28539. if !m.op.Is(OpUpdateOne) {
  28540. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28541. }
  28542. if m.id == nil || m.oldValue == nil {
  28543. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28544. }
  28545. oldValue, err := m.oldValue(ctx)
  28546. if err != nil {
  28547. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28548. }
  28549. return oldValue.OrganizationID, nil
  28550. }
  28551. // AddOrganizationID adds u to the "organization_id" field.
  28552. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  28553. if m.addorganization_id != nil {
  28554. *m.addorganization_id += u
  28555. } else {
  28556. m.addorganization_id = &u
  28557. }
  28558. }
  28559. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28560. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  28561. v := m.addorganization_id
  28562. if v == nil {
  28563. return
  28564. }
  28565. return *v, true
  28566. }
  28567. // ClearOrganizationID clears the value of the "organization_id" field.
  28568. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  28569. m.organization_id = nil
  28570. m.addorganization_id = nil
  28571. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  28572. }
  28573. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28574. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  28575. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  28576. return ok
  28577. }
  28578. // ResetOrganizationID resets all changes to the "organization_id" field.
  28579. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  28580. m.organization_id = nil
  28581. m.addorganization_id = nil
  28582. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  28583. }
  28584. // SetAiResponse sets the "ai_response" field.
  28585. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  28586. m.ai_response = &u
  28587. m.addai_response = nil
  28588. }
  28589. // AiResponse returns the value of the "ai_response" field in the mutation.
  28590. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  28591. v := m.ai_response
  28592. if v == nil {
  28593. return
  28594. }
  28595. return *v, true
  28596. }
  28597. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  28598. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28600. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28601. if !m.op.Is(OpUpdateOne) {
  28602. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28603. }
  28604. if m.id == nil || m.oldValue == nil {
  28605. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28606. }
  28607. oldValue, err := m.oldValue(ctx)
  28608. if err != nil {
  28609. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28610. }
  28611. return oldValue.AiResponse, nil
  28612. }
  28613. // AddAiResponse adds u to the "ai_response" field.
  28614. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  28615. if m.addai_response != nil {
  28616. *m.addai_response += u
  28617. } else {
  28618. m.addai_response = &u
  28619. }
  28620. }
  28621. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28622. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  28623. v := m.addai_response
  28624. if v == nil {
  28625. return
  28626. }
  28627. return *v, true
  28628. }
  28629. // ResetAiResponse resets all changes to the "ai_response" field.
  28630. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  28631. m.ai_response = nil
  28632. m.addai_response = nil
  28633. }
  28634. // SetSopRun sets the "sop_run" field.
  28635. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  28636. m.sop_run = &u
  28637. m.addsop_run = nil
  28638. }
  28639. // SopRun returns the value of the "sop_run" field in the mutation.
  28640. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  28641. v := m.sop_run
  28642. if v == nil {
  28643. return
  28644. }
  28645. return *v, true
  28646. }
  28647. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  28648. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28650. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  28651. if !m.op.Is(OpUpdateOne) {
  28652. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28653. }
  28654. if m.id == nil || m.oldValue == nil {
  28655. return v, errors.New("OldSopRun requires an ID field in the mutation")
  28656. }
  28657. oldValue, err := m.oldValue(ctx)
  28658. if err != nil {
  28659. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  28660. }
  28661. return oldValue.SopRun, nil
  28662. }
  28663. // AddSopRun adds u to the "sop_run" field.
  28664. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  28665. if m.addsop_run != nil {
  28666. *m.addsop_run += u
  28667. } else {
  28668. m.addsop_run = &u
  28669. }
  28670. }
  28671. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  28672. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  28673. v := m.addsop_run
  28674. if v == nil {
  28675. return
  28676. }
  28677. return *v, true
  28678. }
  28679. // ResetSopRun resets all changes to the "sop_run" field.
  28680. func (m *UsageStatisticDayMutation) ResetSopRun() {
  28681. m.sop_run = nil
  28682. m.addsop_run = nil
  28683. }
  28684. // SetTotalFriend sets the "total_friend" field.
  28685. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  28686. m.total_friend = &u
  28687. m.addtotal_friend = nil
  28688. }
  28689. // TotalFriend returns the value of the "total_friend" field in the mutation.
  28690. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  28691. v := m.total_friend
  28692. if v == nil {
  28693. return
  28694. }
  28695. return *v, true
  28696. }
  28697. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  28698. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28700. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  28701. if !m.op.Is(OpUpdateOne) {
  28702. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  28703. }
  28704. if m.id == nil || m.oldValue == nil {
  28705. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  28706. }
  28707. oldValue, err := m.oldValue(ctx)
  28708. if err != nil {
  28709. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  28710. }
  28711. return oldValue.TotalFriend, nil
  28712. }
  28713. // AddTotalFriend adds u to the "total_friend" field.
  28714. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  28715. if m.addtotal_friend != nil {
  28716. *m.addtotal_friend += u
  28717. } else {
  28718. m.addtotal_friend = &u
  28719. }
  28720. }
  28721. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  28722. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  28723. v := m.addtotal_friend
  28724. if v == nil {
  28725. return
  28726. }
  28727. return *v, true
  28728. }
  28729. // ResetTotalFriend resets all changes to the "total_friend" field.
  28730. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  28731. m.total_friend = nil
  28732. m.addtotal_friend = nil
  28733. }
  28734. // SetTotalGroup sets the "total_group" field.
  28735. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  28736. m.total_group = &u
  28737. m.addtotal_group = nil
  28738. }
  28739. // TotalGroup returns the value of the "total_group" field in the mutation.
  28740. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  28741. v := m.total_group
  28742. if v == nil {
  28743. return
  28744. }
  28745. return *v, true
  28746. }
  28747. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  28748. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28750. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  28751. if !m.op.Is(OpUpdateOne) {
  28752. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  28753. }
  28754. if m.id == nil || m.oldValue == nil {
  28755. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  28756. }
  28757. oldValue, err := m.oldValue(ctx)
  28758. if err != nil {
  28759. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  28760. }
  28761. return oldValue.TotalGroup, nil
  28762. }
  28763. // AddTotalGroup adds u to the "total_group" field.
  28764. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  28765. if m.addtotal_group != nil {
  28766. *m.addtotal_group += u
  28767. } else {
  28768. m.addtotal_group = &u
  28769. }
  28770. }
  28771. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  28772. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  28773. v := m.addtotal_group
  28774. if v == nil {
  28775. return
  28776. }
  28777. return *v, true
  28778. }
  28779. // ResetTotalGroup resets all changes to the "total_group" field.
  28780. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  28781. m.total_group = nil
  28782. m.addtotal_group = nil
  28783. }
  28784. // SetAccountBalance sets the "account_balance" field.
  28785. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  28786. m.account_balance = &u
  28787. m.addaccount_balance = nil
  28788. }
  28789. // AccountBalance returns the value of the "account_balance" field in the mutation.
  28790. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  28791. v := m.account_balance
  28792. if v == nil {
  28793. return
  28794. }
  28795. return *v, true
  28796. }
  28797. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  28798. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28800. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  28801. if !m.op.Is(OpUpdateOne) {
  28802. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  28803. }
  28804. if m.id == nil || m.oldValue == nil {
  28805. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  28806. }
  28807. oldValue, err := m.oldValue(ctx)
  28808. if err != nil {
  28809. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  28810. }
  28811. return oldValue.AccountBalance, nil
  28812. }
  28813. // AddAccountBalance adds u to the "account_balance" field.
  28814. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  28815. if m.addaccount_balance != nil {
  28816. *m.addaccount_balance += u
  28817. } else {
  28818. m.addaccount_balance = &u
  28819. }
  28820. }
  28821. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  28822. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  28823. v := m.addaccount_balance
  28824. if v == nil {
  28825. return
  28826. }
  28827. return *v, true
  28828. }
  28829. // ResetAccountBalance resets all changes to the "account_balance" field.
  28830. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  28831. m.account_balance = nil
  28832. m.addaccount_balance = nil
  28833. }
  28834. // SetConsumeToken sets the "consume_token" field.
  28835. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  28836. m.consume_token = &u
  28837. m.addconsume_token = nil
  28838. }
  28839. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  28840. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  28841. v := m.consume_token
  28842. if v == nil {
  28843. return
  28844. }
  28845. return *v, true
  28846. }
  28847. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  28848. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28850. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  28851. if !m.op.Is(OpUpdateOne) {
  28852. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  28853. }
  28854. if m.id == nil || m.oldValue == nil {
  28855. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  28856. }
  28857. oldValue, err := m.oldValue(ctx)
  28858. if err != nil {
  28859. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  28860. }
  28861. return oldValue.ConsumeToken, nil
  28862. }
  28863. // AddConsumeToken adds u to the "consume_token" field.
  28864. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  28865. if m.addconsume_token != nil {
  28866. *m.addconsume_token += u
  28867. } else {
  28868. m.addconsume_token = &u
  28869. }
  28870. }
  28871. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  28872. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  28873. v := m.addconsume_token
  28874. if v == nil {
  28875. return
  28876. }
  28877. return *v, true
  28878. }
  28879. // ResetConsumeToken resets all changes to the "consume_token" field.
  28880. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  28881. m.consume_token = nil
  28882. m.addconsume_token = nil
  28883. }
  28884. // SetActiveUser sets the "active_user" field.
  28885. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  28886. m.active_user = &u
  28887. m.addactive_user = nil
  28888. }
  28889. // ActiveUser returns the value of the "active_user" field in the mutation.
  28890. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  28891. v := m.active_user
  28892. if v == nil {
  28893. return
  28894. }
  28895. return *v, true
  28896. }
  28897. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  28898. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28900. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  28901. if !m.op.Is(OpUpdateOne) {
  28902. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  28903. }
  28904. if m.id == nil || m.oldValue == nil {
  28905. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  28906. }
  28907. oldValue, err := m.oldValue(ctx)
  28908. if err != nil {
  28909. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  28910. }
  28911. return oldValue.ActiveUser, nil
  28912. }
  28913. // AddActiveUser adds u to the "active_user" field.
  28914. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  28915. if m.addactive_user != nil {
  28916. *m.addactive_user += u
  28917. } else {
  28918. m.addactive_user = &u
  28919. }
  28920. }
  28921. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  28922. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  28923. v := m.addactive_user
  28924. if v == nil {
  28925. return
  28926. }
  28927. return *v, true
  28928. }
  28929. // ResetActiveUser resets all changes to the "active_user" field.
  28930. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  28931. m.active_user = nil
  28932. m.addactive_user = nil
  28933. }
  28934. // SetNewUser sets the "new_user" field.
  28935. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  28936. m.new_user = &i
  28937. m.addnew_user = nil
  28938. }
  28939. // NewUser returns the value of the "new_user" field in the mutation.
  28940. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  28941. v := m.new_user
  28942. if v == nil {
  28943. return
  28944. }
  28945. return *v, true
  28946. }
  28947. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  28948. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28950. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  28951. if !m.op.Is(OpUpdateOne) {
  28952. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  28953. }
  28954. if m.id == nil || m.oldValue == nil {
  28955. return v, errors.New("OldNewUser requires an ID field in the mutation")
  28956. }
  28957. oldValue, err := m.oldValue(ctx)
  28958. if err != nil {
  28959. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28960. }
  28961. return oldValue.NewUser, nil
  28962. }
  28963. // AddNewUser adds i to the "new_user" field.
  28964. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  28965. if m.addnew_user != nil {
  28966. *m.addnew_user += i
  28967. } else {
  28968. m.addnew_user = &i
  28969. }
  28970. }
  28971. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28972. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  28973. v := m.addnew_user
  28974. if v == nil {
  28975. return
  28976. }
  28977. return *v, true
  28978. }
  28979. // ResetNewUser resets all changes to the "new_user" field.
  28980. func (m *UsageStatisticDayMutation) ResetNewUser() {
  28981. m.new_user = nil
  28982. m.addnew_user = nil
  28983. }
  28984. // SetLabelDist sets the "label_dist" field.
  28985. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  28986. m.label_dist = &ctd
  28987. m.appendlabel_dist = nil
  28988. }
  28989. // LabelDist returns the value of the "label_dist" field in the mutation.
  28990. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  28991. v := m.label_dist
  28992. if v == nil {
  28993. return
  28994. }
  28995. return *v, true
  28996. }
  28997. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  28998. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29000. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  29001. if !m.op.Is(OpUpdateOne) {
  29002. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  29003. }
  29004. if m.id == nil || m.oldValue == nil {
  29005. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  29006. }
  29007. oldValue, err := m.oldValue(ctx)
  29008. if err != nil {
  29009. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  29010. }
  29011. return oldValue.LabelDist, nil
  29012. }
  29013. // AppendLabelDist adds ctd to the "label_dist" field.
  29014. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  29015. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  29016. }
  29017. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  29018. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  29019. if len(m.appendlabel_dist) == 0 {
  29020. return nil, false
  29021. }
  29022. return m.appendlabel_dist, true
  29023. }
  29024. // ResetLabelDist resets all changes to the "label_dist" field.
  29025. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  29026. m.label_dist = nil
  29027. m.appendlabel_dist = nil
  29028. }
  29029. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  29030. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  29031. m.predicates = append(m.predicates, ps...)
  29032. }
  29033. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  29034. // users can use type-assertion to append predicates that do not depend on any generated package.
  29035. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  29036. p := make([]predicate.UsageStatisticDay, len(ps))
  29037. for i := range ps {
  29038. p[i] = ps[i]
  29039. }
  29040. m.Where(p...)
  29041. }
  29042. // Op returns the operation name.
  29043. func (m *UsageStatisticDayMutation) Op() Op {
  29044. return m.op
  29045. }
  29046. // SetOp allows setting the mutation operation.
  29047. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  29048. m.op = op
  29049. }
  29050. // Type returns the node type of this mutation (UsageStatisticDay).
  29051. func (m *UsageStatisticDayMutation) Type() string {
  29052. return m.typ
  29053. }
  29054. // Fields returns all fields that were changed during this mutation. Note that in
  29055. // order to get all numeric fields that were incremented/decremented, call
  29056. // AddedFields().
  29057. func (m *UsageStatisticDayMutation) Fields() []string {
  29058. fields := make([]string, 0, 17)
  29059. if m.created_at != nil {
  29060. fields = append(fields, usagestatisticday.FieldCreatedAt)
  29061. }
  29062. if m.updated_at != nil {
  29063. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  29064. }
  29065. if m.status != nil {
  29066. fields = append(fields, usagestatisticday.FieldStatus)
  29067. }
  29068. if m.deleted_at != nil {
  29069. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29070. }
  29071. if m.addtime != nil {
  29072. fields = append(fields, usagestatisticday.FieldAddtime)
  29073. }
  29074. if m._type != nil {
  29075. fields = append(fields, usagestatisticday.FieldType)
  29076. }
  29077. if m.bot_id != nil {
  29078. fields = append(fields, usagestatisticday.FieldBotID)
  29079. }
  29080. if m.organization_id != nil {
  29081. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29082. }
  29083. if m.ai_response != nil {
  29084. fields = append(fields, usagestatisticday.FieldAiResponse)
  29085. }
  29086. if m.sop_run != nil {
  29087. fields = append(fields, usagestatisticday.FieldSopRun)
  29088. }
  29089. if m.total_friend != nil {
  29090. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29091. }
  29092. if m.total_group != nil {
  29093. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29094. }
  29095. if m.account_balance != nil {
  29096. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29097. }
  29098. if m.consume_token != nil {
  29099. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29100. }
  29101. if m.active_user != nil {
  29102. fields = append(fields, usagestatisticday.FieldActiveUser)
  29103. }
  29104. if m.new_user != nil {
  29105. fields = append(fields, usagestatisticday.FieldNewUser)
  29106. }
  29107. if m.label_dist != nil {
  29108. fields = append(fields, usagestatisticday.FieldLabelDist)
  29109. }
  29110. return fields
  29111. }
  29112. // Field returns the value of a field with the given name. The second boolean
  29113. // return value indicates that this field was not set, or was not defined in the
  29114. // schema.
  29115. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  29116. switch name {
  29117. case usagestatisticday.FieldCreatedAt:
  29118. return m.CreatedAt()
  29119. case usagestatisticday.FieldUpdatedAt:
  29120. return m.UpdatedAt()
  29121. case usagestatisticday.FieldStatus:
  29122. return m.Status()
  29123. case usagestatisticday.FieldDeletedAt:
  29124. return m.DeletedAt()
  29125. case usagestatisticday.FieldAddtime:
  29126. return m.Addtime()
  29127. case usagestatisticday.FieldType:
  29128. return m.GetType()
  29129. case usagestatisticday.FieldBotID:
  29130. return m.BotID()
  29131. case usagestatisticday.FieldOrganizationID:
  29132. return m.OrganizationID()
  29133. case usagestatisticday.FieldAiResponse:
  29134. return m.AiResponse()
  29135. case usagestatisticday.FieldSopRun:
  29136. return m.SopRun()
  29137. case usagestatisticday.FieldTotalFriend:
  29138. return m.TotalFriend()
  29139. case usagestatisticday.FieldTotalGroup:
  29140. return m.TotalGroup()
  29141. case usagestatisticday.FieldAccountBalance:
  29142. return m.AccountBalance()
  29143. case usagestatisticday.FieldConsumeToken:
  29144. return m.ConsumeToken()
  29145. case usagestatisticday.FieldActiveUser:
  29146. return m.ActiveUser()
  29147. case usagestatisticday.FieldNewUser:
  29148. return m.NewUser()
  29149. case usagestatisticday.FieldLabelDist:
  29150. return m.LabelDist()
  29151. }
  29152. return nil, false
  29153. }
  29154. // OldField returns the old value of the field from the database. An error is
  29155. // returned if the mutation operation is not UpdateOne, or the query to the
  29156. // database failed.
  29157. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29158. switch name {
  29159. case usagestatisticday.FieldCreatedAt:
  29160. return m.OldCreatedAt(ctx)
  29161. case usagestatisticday.FieldUpdatedAt:
  29162. return m.OldUpdatedAt(ctx)
  29163. case usagestatisticday.FieldStatus:
  29164. return m.OldStatus(ctx)
  29165. case usagestatisticday.FieldDeletedAt:
  29166. return m.OldDeletedAt(ctx)
  29167. case usagestatisticday.FieldAddtime:
  29168. return m.OldAddtime(ctx)
  29169. case usagestatisticday.FieldType:
  29170. return m.OldType(ctx)
  29171. case usagestatisticday.FieldBotID:
  29172. return m.OldBotID(ctx)
  29173. case usagestatisticday.FieldOrganizationID:
  29174. return m.OldOrganizationID(ctx)
  29175. case usagestatisticday.FieldAiResponse:
  29176. return m.OldAiResponse(ctx)
  29177. case usagestatisticday.FieldSopRun:
  29178. return m.OldSopRun(ctx)
  29179. case usagestatisticday.FieldTotalFriend:
  29180. return m.OldTotalFriend(ctx)
  29181. case usagestatisticday.FieldTotalGroup:
  29182. return m.OldTotalGroup(ctx)
  29183. case usagestatisticday.FieldAccountBalance:
  29184. return m.OldAccountBalance(ctx)
  29185. case usagestatisticday.FieldConsumeToken:
  29186. return m.OldConsumeToken(ctx)
  29187. case usagestatisticday.FieldActiveUser:
  29188. return m.OldActiveUser(ctx)
  29189. case usagestatisticday.FieldNewUser:
  29190. return m.OldNewUser(ctx)
  29191. case usagestatisticday.FieldLabelDist:
  29192. return m.OldLabelDist(ctx)
  29193. }
  29194. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29195. }
  29196. // SetField sets the value of a field with the given name. It returns an error if
  29197. // the field is not defined in the schema, or if the type mismatched the field
  29198. // type.
  29199. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  29200. switch name {
  29201. case usagestatisticday.FieldCreatedAt:
  29202. v, ok := value.(time.Time)
  29203. if !ok {
  29204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29205. }
  29206. m.SetCreatedAt(v)
  29207. return nil
  29208. case usagestatisticday.FieldUpdatedAt:
  29209. v, ok := value.(time.Time)
  29210. if !ok {
  29211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29212. }
  29213. m.SetUpdatedAt(v)
  29214. return nil
  29215. case usagestatisticday.FieldStatus:
  29216. v, ok := value.(uint8)
  29217. if !ok {
  29218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29219. }
  29220. m.SetStatus(v)
  29221. return nil
  29222. case usagestatisticday.FieldDeletedAt:
  29223. v, ok := value.(time.Time)
  29224. if !ok {
  29225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29226. }
  29227. m.SetDeletedAt(v)
  29228. return nil
  29229. case usagestatisticday.FieldAddtime:
  29230. v, ok := value.(uint64)
  29231. if !ok {
  29232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29233. }
  29234. m.SetAddtime(v)
  29235. return nil
  29236. case usagestatisticday.FieldType:
  29237. v, ok := value.(int)
  29238. if !ok {
  29239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29240. }
  29241. m.SetType(v)
  29242. return nil
  29243. case usagestatisticday.FieldBotID:
  29244. v, ok := value.(string)
  29245. if !ok {
  29246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29247. }
  29248. m.SetBotID(v)
  29249. return nil
  29250. case usagestatisticday.FieldOrganizationID:
  29251. v, ok := value.(uint64)
  29252. if !ok {
  29253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29254. }
  29255. m.SetOrganizationID(v)
  29256. return nil
  29257. case usagestatisticday.FieldAiResponse:
  29258. v, ok := value.(uint64)
  29259. if !ok {
  29260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29261. }
  29262. m.SetAiResponse(v)
  29263. return nil
  29264. case usagestatisticday.FieldSopRun:
  29265. v, ok := value.(uint64)
  29266. if !ok {
  29267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29268. }
  29269. m.SetSopRun(v)
  29270. return nil
  29271. case usagestatisticday.FieldTotalFriend:
  29272. v, ok := value.(uint64)
  29273. if !ok {
  29274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29275. }
  29276. m.SetTotalFriend(v)
  29277. return nil
  29278. case usagestatisticday.FieldTotalGroup:
  29279. v, ok := value.(uint64)
  29280. if !ok {
  29281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29282. }
  29283. m.SetTotalGroup(v)
  29284. return nil
  29285. case usagestatisticday.FieldAccountBalance:
  29286. v, ok := value.(uint64)
  29287. if !ok {
  29288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29289. }
  29290. m.SetAccountBalance(v)
  29291. return nil
  29292. case usagestatisticday.FieldConsumeToken:
  29293. v, ok := value.(uint64)
  29294. if !ok {
  29295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29296. }
  29297. m.SetConsumeToken(v)
  29298. return nil
  29299. case usagestatisticday.FieldActiveUser:
  29300. v, ok := value.(uint64)
  29301. if !ok {
  29302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29303. }
  29304. m.SetActiveUser(v)
  29305. return nil
  29306. case usagestatisticday.FieldNewUser:
  29307. v, ok := value.(int64)
  29308. if !ok {
  29309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29310. }
  29311. m.SetNewUser(v)
  29312. return nil
  29313. case usagestatisticday.FieldLabelDist:
  29314. v, ok := value.([]custom_types.LabelDist)
  29315. if !ok {
  29316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29317. }
  29318. m.SetLabelDist(v)
  29319. return nil
  29320. }
  29321. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29322. }
  29323. // AddedFields returns all numeric fields that were incremented/decremented during
  29324. // this mutation.
  29325. func (m *UsageStatisticDayMutation) AddedFields() []string {
  29326. var fields []string
  29327. if m.addstatus != nil {
  29328. fields = append(fields, usagestatisticday.FieldStatus)
  29329. }
  29330. if m.addaddtime != nil {
  29331. fields = append(fields, usagestatisticday.FieldAddtime)
  29332. }
  29333. if m.add_type != nil {
  29334. fields = append(fields, usagestatisticday.FieldType)
  29335. }
  29336. if m.addorganization_id != nil {
  29337. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29338. }
  29339. if m.addai_response != nil {
  29340. fields = append(fields, usagestatisticday.FieldAiResponse)
  29341. }
  29342. if m.addsop_run != nil {
  29343. fields = append(fields, usagestatisticday.FieldSopRun)
  29344. }
  29345. if m.addtotal_friend != nil {
  29346. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29347. }
  29348. if m.addtotal_group != nil {
  29349. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29350. }
  29351. if m.addaccount_balance != nil {
  29352. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29353. }
  29354. if m.addconsume_token != nil {
  29355. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29356. }
  29357. if m.addactive_user != nil {
  29358. fields = append(fields, usagestatisticday.FieldActiveUser)
  29359. }
  29360. if m.addnew_user != nil {
  29361. fields = append(fields, usagestatisticday.FieldNewUser)
  29362. }
  29363. return fields
  29364. }
  29365. // AddedField returns the numeric value that was incremented/decremented on a field
  29366. // with the given name. The second boolean return value indicates that this field
  29367. // was not set, or was not defined in the schema.
  29368. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  29369. switch name {
  29370. case usagestatisticday.FieldStatus:
  29371. return m.AddedStatus()
  29372. case usagestatisticday.FieldAddtime:
  29373. return m.AddedAddtime()
  29374. case usagestatisticday.FieldType:
  29375. return m.AddedType()
  29376. case usagestatisticday.FieldOrganizationID:
  29377. return m.AddedOrganizationID()
  29378. case usagestatisticday.FieldAiResponse:
  29379. return m.AddedAiResponse()
  29380. case usagestatisticday.FieldSopRun:
  29381. return m.AddedSopRun()
  29382. case usagestatisticday.FieldTotalFriend:
  29383. return m.AddedTotalFriend()
  29384. case usagestatisticday.FieldTotalGroup:
  29385. return m.AddedTotalGroup()
  29386. case usagestatisticday.FieldAccountBalance:
  29387. return m.AddedAccountBalance()
  29388. case usagestatisticday.FieldConsumeToken:
  29389. return m.AddedConsumeToken()
  29390. case usagestatisticday.FieldActiveUser:
  29391. return m.AddedActiveUser()
  29392. case usagestatisticday.FieldNewUser:
  29393. return m.AddedNewUser()
  29394. }
  29395. return nil, false
  29396. }
  29397. // AddField adds the value to the field with the given name. It returns an error if
  29398. // the field is not defined in the schema, or if the type mismatched the field
  29399. // type.
  29400. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  29401. switch name {
  29402. case usagestatisticday.FieldStatus:
  29403. v, ok := value.(int8)
  29404. if !ok {
  29405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29406. }
  29407. m.AddStatus(v)
  29408. return nil
  29409. case usagestatisticday.FieldAddtime:
  29410. v, ok := value.(int64)
  29411. if !ok {
  29412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29413. }
  29414. m.AddAddtime(v)
  29415. return nil
  29416. case usagestatisticday.FieldType:
  29417. v, ok := value.(int)
  29418. if !ok {
  29419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29420. }
  29421. m.AddType(v)
  29422. return nil
  29423. case usagestatisticday.FieldOrganizationID:
  29424. v, ok := value.(int64)
  29425. if !ok {
  29426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29427. }
  29428. m.AddOrganizationID(v)
  29429. return nil
  29430. case usagestatisticday.FieldAiResponse:
  29431. v, ok := value.(int64)
  29432. if !ok {
  29433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29434. }
  29435. m.AddAiResponse(v)
  29436. return nil
  29437. case usagestatisticday.FieldSopRun:
  29438. v, ok := value.(int64)
  29439. if !ok {
  29440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29441. }
  29442. m.AddSopRun(v)
  29443. return nil
  29444. case usagestatisticday.FieldTotalFriend:
  29445. v, ok := value.(int64)
  29446. if !ok {
  29447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29448. }
  29449. m.AddTotalFriend(v)
  29450. return nil
  29451. case usagestatisticday.FieldTotalGroup:
  29452. v, ok := value.(int64)
  29453. if !ok {
  29454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29455. }
  29456. m.AddTotalGroup(v)
  29457. return nil
  29458. case usagestatisticday.FieldAccountBalance:
  29459. v, ok := value.(int64)
  29460. if !ok {
  29461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29462. }
  29463. m.AddAccountBalance(v)
  29464. return nil
  29465. case usagestatisticday.FieldConsumeToken:
  29466. v, ok := value.(int64)
  29467. if !ok {
  29468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29469. }
  29470. m.AddConsumeToken(v)
  29471. return nil
  29472. case usagestatisticday.FieldActiveUser:
  29473. v, ok := value.(int64)
  29474. if !ok {
  29475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29476. }
  29477. m.AddActiveUser(v)
  29478. return nil
  29479. case usagestatisticday.FieldNewUser:
  29480. v, ok := value.(int64)
  29481. if !ok {
  29482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29483. }
  29484. m.AddNewUser(v)
  29485. return nil
  29486. }
  29487. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  29488. }
  29489. // ClearedFields returns all nullable fields that were cleared during this
  29490. // mutation.
  29491. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  29492. var fields []string
  29493. if m.FieldCleared(usagestatisticday.FieldStatus) {
  29494. fields = append(fields, usagestatisticday.FieldStatus)
  29495. }
  29496. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  29497. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29498. }
  29499. if m.FieldCleared(usagestatisticday.FieldBotID) {
  29500. fields = append(fields, usagestatisticday.FieldBotID)
  29501. }
  29502. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  29503. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29504. }
  29505. return fields
  29506. }
  29507. // FieldCleared returns a boolean indicating if a field with the given name was
  29508. // cleared in this mutation.
  29509. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  29510. _, ok := m.clearedFields[name]
  29511. return ok
  29512. }
  29513. // ClearField clears the value of the field with the given name. It returns an
  29514. // error if the field is not defined in the schema.
  29515. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  29516. switch name {
  29517. case usagestatisticday.FieldStatus:
  29518. m.ClearStatus()
  29519. return nil
  29520. case usagestatisticday.FieldDeletedAt:
  29521. m.ClearDeletedAt()
  29522. return nil
  29523. case usagestatisticday.FieldBotID:
  29524. m.ClearBotID()
  29525. return nil
  29526. case usagestatisticday.FieldOrganizationID:
  29527. m.ClearOrganizationID()
  29528. return nil
  29529. }
  29530. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  29531. }
  29532. // ResetField resets all changes in the mutation for the field with the given name.
  29533. // It returns an error if the field is not defined in the schema.
  29534. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  29535. switch name {
  29536. case usagestatisticday.FieldCreatedAt:
  29537. m.ResetCreatedAt()
  29538. return nil
  29539. case usagestatisticday.FieldUpdatedAt:
  29540. m.ResetUpdatedAt()
  29541. return nil
  29542. case usagestatisticday.FieldStatus:
  29543. m.ResetStatus()
  29544. return nil
  29545. case usagestatisticday.FieldDeletedAt:
  29546. m.ResetDeletedAt()
  29547. return nil
  29548. case usagestatisticday.FieldAddtime:
  29549. m.ResetAddtime()
  29550. return nil
  29551. case usagestatisticday.FieldType:
  29552. m.ResetType()
  29553. return nil
  29554. case usagestatisticday.FieldBotID:
  29555. m.ResetBotID()
  29556. return nil
  29557. case usagestatisticday.FieldOrganizationID:
  29558. m.ResetOrganizationID()
  29559. return nil
  29560. case usagestatisticday.FieldAiResponse:
  29561. m.ResetAiResponse()
  29562. return nil
  29563. case usagestatisticday.FieldSopRun:
  29564. m.ResetSopRun()
  29565. return nil
  29566. case usagestatisticday.FieldTotalFriend:
  29567. m.ResetTotalFriend()
  29568. return nil
  29569. case usagestatisticday.FieldTotalGroup:
  29570. m.ResetTotalGroup()
  29571. return nil
  29572. case usagestatisticday.FieldAccountBalance:
  29573. m.ResetAccountBalance()
  29574. return nil
  29575. case usagestatisticday.FieldConsumeToken:
  29576. m.ResetConsumeToken()
  29577. return nil
  29578. case usagestatisticday.FieldActiveUser:
  29579. m.ResetActiveUser()
  29580. return nil
  29581. case usagestatisticday.FieldNewUser:
  29582. m.ResetNewUser()
  29583. return nil
  29584. case usagestatisticday.FieldLabelDist:
  29585. m.ResetLabelDist()
  29586. return nil
  29587. }
  29588. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29589. }
  29590. // AddedEdges returns all edge names that were set/added in this mutation.
  29591. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  29592. edges := make([]string, 0, 0)
  29593. return edges
  29594. }
  29595. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29596. // name in this mutation.
  29597. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  29598. return nil
  29599. }
  29600. // RemovedEdges returns all edge names that were removed in this mutation.
  29601. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  29602. edges := make([]string, 0, 0)
  29603. return edges
  29604. }
  29605. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29606. // the given name in this mutation.
  29607. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  29608. return nil
  29609. }
  29610. // ClearedEdges returns all edge names that were cleared in this mutation.
  29611. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  29612. edges := make([]string, 0, 0)
  29613. return edges
  29614. }
  29615. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29616. // was cleared in this mutation.
  29617. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  29618. return false
  29619. }
  29620. // ClearEdge clears the value of the edge with the given name. It returns an error
  29621. // if that edge is not defined in the schema.
  29622. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  29623. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  29624. }
  29625. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29626. // It returns an error if the edge is not defined in the schema.
  29627. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  29628. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  29629. }
  29630. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  29631. type UsageStatisticHourMutation struct {
  29632. config
  29633. op Op
  29634. typ string
  29635. id *uint64
  29636. created_at *time.Time
  29637. updated_at *time.Time
  29638. status *uint8
  29639. addstatus *int8
  29640. deleted_at *time.Time
  29641. addtime *uint64
  29642. addaddtime *int64
  29643. _type *int
  29644. add_type *int
  29645. bot_id *string
  29646. organization_id *uint64
  29647. addorganization_id *int64
  29648. ai_response *uint64
  29649. addai_response *int64
  29650. sop_run *uint64
  29651. addsop_run *int64
  29652. total_friend *uint64
  29653. addtotal_friend *int64
  29654. total_group *uint64
  29655. addtotal_group *int64
  29656. account_balance *uint64
  29657. addaccount_balance *int64
  29658. consume_token *uint64
  29659. addconsume_token *int64
  29660. active_user *uint64
  29661. addactive_user *int64
  29662. new_user *int64
  29663. addnew_user *int64
  29664. label_dist *[]custom_types.LabelDist
  29665. appendlabel_dist []custom_types.LabelDist
  29666. clearedFields map[string]struct{}
  29667. done bool
  29668. oldValue func(context.Context) (*UsageStatisticHour, error)
  29669. predicates []predicate.UsageStatisticHour
  29670. }
  29671. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  29672. // usagestatistichourOption allows management of the mutation configuration using functional options.
  29673. type usagestatistichourOption func(*UsageStatisticHourMutation)
  29674. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  29675. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  29676. m := &UsageStatisticHourMutation{
  29677. config: c,
  29678. op: op,
  29679. typ: TypeUsageStatisticHour,
  29680. clearedFields: make(map[string]struct{}),
  29681. }
  29682. for _, opt := range opts {
  29683. opt(m)
  29684. }
  29685. return m
  29686. }
  29687. // withUsageStatisticHourID sets the ID field of the mutation.
  29688. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  29689. return func(m *UsageStatisticHourMutation) {
  29690. var (
  29691. err error
  29692. once sync.Once
  29693. value *UsageStatisticHour
  29694. )
  29695. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  29696. once.Do(func() {
  29697. if m.done {
  29698. err = errors.New("querying old values post mutation is not allowed")
  29699. } else {
  29700. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  29701. }
  29702. })
  29703. return value, err
  29704. }
  29705. m.id = &id
  29706. }
  29707. }
  29708. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  29709. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  29710. return func(m *UsageStatisticHourMutation) {
  29711. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  29712. return node, nil
  29713. }
  29714. m.id = &node.ID
  29715. }
  29716. }
  29717. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29718. // executed in a transaction (ent.Tx), a transactional client is returned.
  29719. func (m UsageStatisticHourMutation) Client() *Client {
  29720. client := &Client{config: m.config}
  29721. client.init()
  29722. return client
  29723. }
  29724. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29725. // it returns an error otherwise.
  29726. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  29727. if _, ok := m.driver.(*txDriver); !ok {
  29728. return nil, errors.New("ent: mutation is not running in a transaction")
  29729. }
  29730. tx := &Tx{config: m.config}
  29731. tx.init()
  29732. return tx, nil
  29733. }
  29734. // SetID sets the value of the id field. Note that this
  29735. // operation is only accepted on creation of UsageStatisticHour entities.
  29736. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  29737. m.id = &id
  29738. }
  29739. // ID returns the ID value in the mutation. Note that the ID is only available
  29740. // if it was provided to the builder or after it was returned from the database.
  29741. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  29742. if m.id == nil {
  29743. return
  29744. }
  29745. return *m.id, true
  29746. }
  29747. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29748. // That means, if the mutation is applied within a transaction with an isolation level such
  29749. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29750. // or updated by the mutation.
  29751. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  29752. switch {
  29753. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29754. id, exists := m.ID()
  29755. if exists {
  29756. return []uint64{id}, nil
  29757. }
  29758. fallthrough
  29759. case m.op.Is(OpUpdate | OpDelete):
  29760. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  29761. default:
  29762. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29763. }
  29764. }
  29765. // SetCreatedAt sets the "created_at" field.
  29766. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  29767. m.created_at = &t
  29768. }
  29769. // CreatedAt returns the value of the "created_at" field in the mutation.
  29770. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  29771. v := m.created_at
  29772. if v == nil {
  29773. return
  29774. }
  29775. return *v, true
  29776. }
  29777. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  29778. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29780. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29781. if !m.op.Is(OpUpdateOne) {
  29782. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29783. }
  29784. if m.id == nil || m.oldValue == nil {
  29785. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29786. }
  29787. oldValue, err := m.oldValue(ctx)
  29788. if err != nil {
  29789. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29790. }
  29791. return oldValue.CreatedAt, nil
  29792. }
  29793. // ResetCreatedAt resets all changes to the "created_at" field.
  29794. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  29795. m.created_at = nil
  29796. }
  29797. // SetUpdatedAt sets the "updated_at" field.
  29798. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  29799. m.updated_at = &t
  29800. }
  29801. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29802. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  29803. v := m.updated_at
  29804. if v == nil {
  29805. return
  29806. }
  29807. return *v, true
  29808. }
  29809. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  29810. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29812. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29813. if !m.op.Is(OpUpdateOne) {
  29814. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29815. }
  29816. if m.id == nil || m.oldValue == nil {
  29817. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29818. }
  29819. oldValue, err := m.oldValue(ctx)
  29820. if err != nil {
  29821. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29822. }
  29823. return oldValue.UpdatedAt, nil
  29824. }
  29825. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29826. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  29827. m.updated_at = nil
  29828. }
  29829. // SetStatus sets the "status" field.
  29830. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  29831. m.status = &u
  29832. m.addstatus = nil
  29833. }
  29834. // Status returns the value of the "status" field in the mutation.
  29835. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  29836. v := m.status
  29837. if v == nil {
  29838. return
  29839. }
  29840. return *v, true
  29841. }
  29842. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  29843. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29845. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29846. if !m.op.Is(OpUpdateOne) {
  29847. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29848. }
  29849. if m.id == nil || m.oldValue == nil {
  29850. return v, errors.New("OldStatus requires an ID field in the mutation")
  29851. }
  29852. oldValue, err := m.oldValue(ctx)
  29853. if err != nil {
  29854. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29855. }
  29856. return oldValue.Status, nil
  29857. }
  29858. // AddStatus adds u to the "status" field.
  29859. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  29860. if m.addstatus != nil {
  29861. *m.addstatus += u
  29862. } else {
  29863. m.addstatus = &u
  29864. }
  29865. }
  29866. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29867. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  29868. v := m.addstatus
  29869. if v == nil {
  29870. return
  29871. }
  29872. return *v, true
  29873. }
  29874. // ClearStatus clears the value of the "status" field.
  29875. func (m *UsageStatisticHourMutation) ClearStatus() {
  29876. m.status = nil
  29877. m.addstatus = nil
  29878. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  29879. }
  29880. // StatusCleared returns if the "status" field was cleared in this mutation.
  29881. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  29882. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  29883. return ok
  29884. }
  29885. // ResetStatus resets all changes to the "status" field.
  29886. func (m *UsageStatisticHourMutation) ResetStatus() {
  29887. m.status = nil
  29888. m.addstatus = nil
  29889. delete(m.clearedFields, usagestatistichour.FieldStatus)
  29890. }
  29891. // SetDeletedAt sets the "deleted_at" field.
  29892. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  29893. m.deleted_at = &t
  29894. }
  29895. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29896. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  29897. v := m.deleted_at
  29898. if v == nil {
  29899. return
  29900. }
  29901. return *v, true
  29902. }
  29903. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  29904. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29906. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29907. if !m.op.Is(OpUpdateOne) {
  29908. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29909. }
  29910. if m.id == nil || m.oldValue == nil {
  29911. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29912. }
  29913. oldValue, err := m.oldValue(ctx)
  29914. if err != nil {
  29915. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29916. }
  29917. return oldValue.DeletedAt, nil
  29918. }
  29919. // ClearDeletedAt clears the value of the "deleted_at" field.
  29920. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  29921. m.deleted_at = nil
  29922. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  29923. }
  29924. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29925. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  29926. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  29927. return ok
  29928. }
  29929. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29930. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  29931. m.deleted_at = nil
  29932. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  29933. }
  29934. // SetAddtime sets the "addtime" field.
  29935. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  29936. m.addtime = &u
  29937. m.addaddtime = nil
  29938. }
  29939. // Addtime returns the value of the "addtime" field in the mutation.
  29940. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  29941. v := m.addtime
  29942. if v == nil {
  29943. return
  29944. }
  29945. return *v, true
  29946. }
  29947. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  29948. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29950. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29951. if !m.op.Is(OpUpdateOne) {
  29952. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29953. }
  29954. if m.id == nil || m.oldValue == nil {
  29955. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29956. }
  29957. oldValue, err := m.oldValue(ctx)
  29958. if err != nil {
  29959. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29960. }
  29961. return oldValue.Addtime, nil
  29962. }
  29963. // AddAddtime adds u to the "addtime" field.
  29964. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  29965. if m.addaddtime != nil {
  29966. *m.addaddtime += u
  29967. } else {
  29968. m.addaddtime = &u
  29969. }
  29970. }
  29971. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29972. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  29973. v := m.addaddtime
  29974. if v == nil {
  29975. return
  29976. }
  29977. return *v, true
  29978. }
  29979. // ResetAddtime resets all changes to the "addtime" field.
  29980. func (m *UsageStatisticHourMutation) ResetAddtime() {
  29981. m.addtime = nil
  29982. m.addaddtime = nil
  29983. }
  29984. // SetType sets the "type" field.
  29985. func (m *UsageStatisticHourMutation) SetType(i int) {
  29986. m._type = &i
  29987. m.add_type = nil
  29988. }
  29989. // GetType returns the value of the "type" field in the mutation.
  29990. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  29991. v := m._type
  29992. if v == nil {
  29993. return
  29994. }
  29995. return *v, true
  29996. }
  29997. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  29998. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30000. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  30001. if !m.op.Is(OpUpdateOne) {
  30002. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30003. }
  30004. if m.id == nil || m.oldValue == nil {
  30005. return v, errors.New("OldType requires an ID field in the mutation")
  30006. }
  30007. oldValue, err := m.oldValue(ctx)
  30008. if err != nil {
  30009. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30010. }
  30011. return oldValue.Type, nil
  30012. }
  30013. // AddType adds i to the "type" field.
  30014. func (m *UsageStatisticHourMutation) AddType(i int) {
  30015. if m.add_type != nil {
  30016. *m.add_type += i
  30017. } else {
  30018. m.add_type = &i
  30019. }
  30020. }
  30021. // AddedType returns the value that was added to the "type" field in this mutation.
  30022. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  30023. v := m.add_type
  30024. if v == nil {
  30025. return
  30026. }
  30027. return *v, true
  30028. }
  30029. // ResetType resets all changes to the "type" field.
  30030. func (m *UsageStatisticHourMutation) ResetType() {
  30031. m._type = nil
  30032. m.add_type = nil
  30033. }
  30034. // SetBotID sets the "bot_id" field.
  30035. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  30036. m.bot_id = &s
  30037. }
  30038. // BotID returns the value of the "bot_id" field in the mutation.
  30039. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  30040. v := m.bot_id
  30041. if v == nil {
  30042. return
  30043. }
  30044. return *v, true
  30045. }
  30046. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  30047. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30049. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  30050. if !m.op.Is(OpUpdateOne) {
  30051. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30052. }
  30053. if m.id == nil || m.oldValue == nil {
  30054. return v, errors.New("OldBotID requires an ID field in the mutation")
  30055. }
  30056. oldValue, err := m.oldValue(ctx)
  30057. if err != nil {
  30058. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30059. }
  30060. return oldValue.BotID, nil
  30061. }
  30062. // ClearBotID clears the value of the "bot_id" field.
  30063. func (m *UsageStatisticHourMutation) ClearBotID() {
  30064. m.bot_id = nil
  30065. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  30066. }
  30067. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30068. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  30069. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  30070. return ok
  30071. }
  30072. // ResetBotID resets all changes to the "bot_id" field.
  30073. func (m *UsageStatisticHourMutation) ResetBotID() {
  30074. m.bot_id = nil
  30075. delete(m.clearedFields, usagestatistichour.FieldBotID)
  30076. }
  30077. // SetOrganizationID sets the "organization_id" field.
  30078. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  30079. m.organization_id = &u
  30080. m.addorganization_id = nil
  30081. }
  30082. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30083. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  30084. v := m.organization_id
  30085. if v == nil {
  30086. return
  30087. }
  30088. return *v, true
  30089. }
  30090. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  30091. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30093. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30094. if !m.op.Is(OpUpdateOne) {
  30095. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30096. }
  30097. if m.id == nil || m.oldValue == nil {
  30098. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30099. }
  30100. oldValue, err := m.oldValue(ctx)
  30101. if err != nil {
  30102. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30103. }
  30104. return oldValue.OrganizationID, nil
  30105. }
  30106. // AddOrganizationID adds u to the "organization_id" field.
  30107. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  30108. if m.addorganization_id != nil {
  30109. *m.addorganization_id += u
  30110. } else {
  30111. m.addorganization_id = &u
  30112. }
  30113. }
  30114. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30115. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  30116. v := m.addorganization_id
  30117. if v == nil {
  30118. return
  30119. }
  30120. return *v, true
  30121. }
  30122. // ClearOrganizationID clears the value of the "organization_id" field.
  30123. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  30124. m.organization_id = nil
  30125. m.addorganization_id = nil
  30126. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  30127. }
  30128. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30129. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  30130. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  30131. return ok
  30132. }
  30133. // ResetOrganizationID resets all changes to the "organization_id" field.
  30134. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  30135. m.organization_id = nil
  30136. m.addorganization_id = nil
  30137. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  30138. }
  30139. // SetAiResponse sets the "ai_response" field.
  30140. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  30141. m.ai_response = &u
  30142. m.addai_response = nil
  30143. }
  30144. // AiResponse returns the value of the "ai_response" field in the mutation.
  30145. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  30146. v := m.ai_response
  30147. if v == nil {
  30148. return
  30149. }
  30150. return *v, true
  30151. }
  30152. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  30153. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30155. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30156. if !m.op.Is(OpUpdateOne) {
  30157. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30158. }
  30159. if m.id == nil || m.oldValue == nil {
  30160. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30161. }
  30162. oldValue, err := m.oldValue(ctx)
  30163. if err != nil {
  30164. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30165. }
  30166. return oldValue.AiResponse, nil
  30167. }
  30168. // AddAiResponse adds u to the "ai_response" field.
  30169. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  30170. if m.addai_response != nil {
  30171. *m.addai_response += u
  30172. } else {
  30173. m.addai_response = &u
  30174. }
  30175. }
  30176. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30177. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  30178. v := m.addai_response
  30179. if v == nil {
  30180. return
  30181. }
  30182. return *v, true
  30183. }
  30184. // ResetAiResponse resets all changes to the "ai_response" field.
  30185. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  30186. m.ai_response = nil
  30187. m.addai_response = nil
  30188. }
  30189. // SetSopRun sets the "sop_run" field.
  30190. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  30191. m.sop_run = &u
  30192. m.addsop_run = nil
  30193. }
  30194. // SopRun returns the value of the "sop_run" field in the mutation.
  30195. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  30196. v := m.sop_run
  30197. if v == nil {
  30198. return
  30199. }
  30200. return *v, true
  30201. }
  30202. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  30203. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30205. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30206. if !m.op.Is(OpUpdateOne) {
  30207. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30208. }
  30209. if m.id == nil || m.oldValue == nil {
  30210. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30211. }
  30212. oldValue, err := m.oldValue(ctx)
  30213. if err != nil {
  30214. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30215. }
  30216. return oldValue.SopRun, nil
  30217. }
  30218. // AddSopRun adds u to the "sop_run" field.
  30219. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  30220. if m.addsop_run != nil {
  30221. *m.addsop_run += u
  30222. } else {
  30223. m.addsop_run = &u
  30224. }
  30225. }
  30226. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30227. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  30228. v := m.addsop_run
  30229. if v == nil {
  30230. return
  30231. }
  30232. return *v, true
  30233. }
  30234. // ResetSopRun resets all changes to the "sop_run" field.
  30235. func (m *UsageStatisticHourMutation) ResetSopRun() {
  30236. m.sop_run = nil
  30237. m.addsop_run = nil
  30238. }
  30239. // SetTotalFriend sets the "total_friend" field.
  30240. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  30241. m.total_friend = &u
  30242. m.addtotal_friend = nil
  30243. }
  30244. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30245. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  30246. v := m.total_friend
  30247. if v == nil {
  30248. return
  30249. }
  30250. return *v, true
  30251. }
  30252. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  30253. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30255. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30256. if !m.op.Is(OpUpdateOne) {
  30257. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30258. }
  30259. if m.id == nil || m.oldValue == nil {
  30260. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30261. }
  30262. oldValue, err := m.oldValue(ctx)
  30263. if err != nil {
  30264. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30265. }
  30266. return oldValue.TotalFriend, nil
  30267. }
  30268. // AddTotalFriend adds u to the "total_friend" field.
  30269. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  30270. if m.addtotal_friend != nil {
  30271. *m.addtotal_friend += u
  30272. } else {
  30273. m.addtotal_friend = &u
  30274. }
  30275. }
  30276. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30277. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  30278. v := m.addtotal_friend
  30279. if v == nil {
  30280. return
  30281. }
  30282. return *v, true
  30283. }
  30284. // ResetTotalFriend resets all changes to the "total_friend" field.
  30285. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  30286. m.total_friend = nil
  30287. m.addtotal_friend = nil
  30288. }
  30289. // SetTotalGroup sets the "total_group" field.
  30290. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  30291. m.total_group = &u
  30292. m.addtotal_group = nil
  30293. }
  30294. // TotalGroup returns the value of the "total_group" field in the mutation.
  30295. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  30296. v := m.total_group
  30297. if v == nil {
  30298. return
  30299. }
  30300. return *v, true
  30301. }
  30302. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  30303. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30305. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30306. if !m.op.Is(OpUpdateOne) {
  30307. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30308. }
  30309. if m.id == nil || m.oldValue == nil {
  30310. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30311. }
  30312. oldValue, err := m.oldValue(ctx)
  30313. if err != nil {
  30314. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30315. }
  30316. return oldValue.TotalGroup, nil
  30317. }
  30318. // AddTotalGroup adds u to the "total_group" field.
  30319. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  30320. if m.addtotal_group != nil {
  30321. *m.addtotal_group += u
  30322. } else {
  30323. m.addtotal_group = &u
  30324. }
  30325. }
  30326. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30327. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  30328. v := m.addtotal_group
  30329. if v == nil {
  30330. return
  30331. }
  30332. return *v, true
  30333. }
  30334. // ResetTotalGroup resets all changes to the "total_group" field.
  30335. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  30336. m.total_group = nil
  30337. m.addtotal_group = nil
  30338. }
  30339. // SetAccountBalance sets the "account_balance" field.
  30340. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  30341. m.account_balance = &u
  30342. m.addaccount_balance = nil
  30343. }
  30344. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30345. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  30346. v := m.account_balance
  30347. if v == nil {
  30348. return
  30349. }
  30350. return *v, true
  30351. }
  30352. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  30353. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30355. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30356. if !m.op.Is(OpUpdateOne) {
  30357. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30358. }
  30359. if m.id == nil || m.oldValue == nil {
  30360. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30361. }
  30362. oldValue, err := m.oldValue(ctx)
  30363. if err != nil {
  30364. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30365. }
  30366. return oldValue.AccountBalance, nil
  30367. }
  30368. // AddAccountBalance adds u to the "account_balance" field.
  30369. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  30370. if m.addaccount_balance != nil {
  30371. *m.addaccount_balance += u
  30372. } else {
  30373. m.addaccount_balance = &u
  30374. }
  30375. }
  30376. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30377. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  30378. v := m.addaccount_balance
  30379. if v == nil {
  30380. return
  30381. }
  30382. return *v, true
  30383. }
  30384. // ResetAccountBalance resets all changes to the "account_balance" field.
  30385. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  30386. m.account_balance = nil
  30387. m.addaccount_balance = nil
  30388. }
  30389. // SetConsumeToken sets the "consume_token" field.
  30390. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  30391. m.consume_token = &u
  30392. m.addconsume_token = nil
  30393. }
  30394. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  30395. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  30396. v := m.consume_token
  30397. if v == nil {
  30398. return
  30399. }
  30400. return *v, true
  30401. }
  30402. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  30403. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30405. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  30406. if !m.op.Is(OpUpdateOne) {
  30407. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  30408. }
  30409. if m.id == nil || m.oldValue == nil {
  30410. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  30411. }
  30412. oldValue, err := m.oldValue(ctx)
  30413. if err != nil {
  30414. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  30415. }
  30416. return oldValue.ConsumeToken, nil
  30417. }
  30418. // AddConsumeToken adds u to the "consume_token" field.
  30419. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  30420. if m.addconsume_token != nil {
  30421. *m.addconsume_token += u
  30422. } else {
  30423. m.addconsume_token = &u
  30424. }
  30425. }
  30426. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  30427. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  30428. v := m.addconsume_token
  30429. if v == nil {
  30430. return
  30431. }
  30432. return *v, true
  30433. }
  30434. // ResetConsumeToken resets all changes to the "consume_token" field.
  30435. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  30436. m.consume_token = nil
  30437. m.addconsume_token = nil
  30438. }
  30439. // SetActiveUser sets the "active_user" field.
  30440. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  30441. m.active_user = &u
  30442. m.addactive_user = nil
  30443. }
  30444. // ActiveUser returns the value of the "active_user" field in the mutation.
  30445. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  30446. v := m.active_user
  30447. if v == nil {
  30448. return
  30449. }
  30450. return *v, true
  30451. }
  30452. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  30453. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30455. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  30456. if !m.op.Is(OpUpdateOne) {
  30457. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30458. }
  30459. if m.id == nil || m.oldValue == nil {
  30460. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30461. }
  30462. oldValue, err := m.oldValue(ctx)
  30463. if err != nil {
  30464. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30465. }
  30466. return oldValue.ActiveUser, nil
  30467. }
  30468. // AddActiveUser adds u to the "active_user" field.
  30469. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  30470. if m.addactive_user != nil {
  30471. *m.addactive_user += u
  30472. } else {
  30473. m.addactive_user = &u
  30474. }
  30475. }
  30476. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30477. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  30478. v := m.addactive_user
  30479. if v == nil {
  30480. return
  30481. }
  30482. return *v, true
  30483. }
  30484. // ResetActiveUser resets all changes to the "active_user" field.
  30485. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  30486. m.active_user = nil
  30487. m.addactive_user = nil
  30488. }
  30489. // SetNewUser sets the "new_user" field.
  30490. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  30491. m.new_user = &i
  30492. m.addnew_user = nil
  30493. }
  30494. // NewUser returns the value of the "new_user" field in the mutation.
  30495. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  30496. v := m.new_user
  30497. if v == nil {
  30498. return
  30499. }
  30500. return *v, true
  30501. }
  30502. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  30503. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30505. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30506. if !m.op.Is(OpUpdateOne) {
  30507. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30508. }
  30509. if m.id == nil || m.oldValue == nil {
  30510. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30511. }
  30512. oldValue, err := m.oldValue(ctx)
  30513. if err != nil {
  30514. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30515. }
  30516. return oldValue.NewUser, nil
  30517. }
  30518. // AddNewUser adds i to the "new_user" field.
  30519. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  30520. if m.addnew_user != nil {
  30521. *m.addnew_user += i
  30522. } else {
  30523. m.addnew_user = &i
  30524. }
  30525. }
  30526. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30527. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  30528. v := m.addnew_user
  30529. if v == nil {
  30530. return
  30531. }
  30532. return *v, true
  30533. }
  30534. // ResetNewUser resets all changes to the "new_user" field.
  30535. func (m *UsageStatisticHourMutation) ResetNewUser() {
  30536. m.new_user = nil
  30537. m.addnew_user = nil
  30538. }
  30539. // SetLabelDist sets the "label_dist" field.
  30540. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30541. m.label_dist = &ctd
  30542. m.appendlabel_dist = nil
  30543. }
  30544. // LabelDist returns the value of the "label_dist" field in the mutation.
  30545. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30546. v := m.label_dist
  30547. if v == nil {
  30548. return
  30549. }
  30550. return *v, true
  30551. }
  30552. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  30553. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30555. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30556. if !m.op.Is(OpUpdateOne) {
  30557. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30558. }
  30559. if m.id == nil || m.oldValue == nil {
  30560. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30561. }
  30562. oldValue, err := m.oldValue(ctx)
  30563. if err != nil {
  30564. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30565. }
  30566. return oldValue.LabelDist, nil
  30567. }
  30568. // AppendLabelDist adds ctd to the "label_dist" field.
  30569. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30570. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30571. }
  30572. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30573. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30574. if len(m.appendlabel_dist) == 0 {
  30575. return nil, false
  30576. }
  30577. return m.appendlabel_dist, true
  30578. }
  30579. // ResetLabelDist resets all changes to the "label_dist" field.
  30580. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  30581. m.label_dist = nil
  30582. m.appendlabel_dist = nil
  30583. }
  30584. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  30585. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  30586. m.predicates = append(m.predicates, ps...)
  30587. }
  30588. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  30589. // users can use type-assertion to append predicates that do not depend on any generated package.
  30590. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  30591. p := make([]predicate.UsageStatisticHour, len(ps))
  30592. for i := range ps {
  30593. p[i] = ps[i]
  30594. }
  30595. m.Where(p...)
  30596. }
  30597. // Op returns the operation name.
  30598. func (m *UsageStatisticHourMutation) Op() Op {
  30599. return m.op
  30600. }
  30601. // SetOp allows setting the mutation operation.
  30602. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  30603. m.op = op
  30604. }
  30605. // Type returns the node type of this mutation (UsageStatisticHour).
  30606. func (m *UsageStatisticHourMutation) Type() string {
  30607. return m.typ
  30608. }
  30609. // Fields returns all fields that were changed during this mutation. Note that in
  30610. // order to get all numeric fields that were incremented/decremented, call
  30611. // AddedFields().
  30612. func (m *UsageStatisticHourMutation) Fields() []string {
  30613. fields := make([]string, 0, 17)
  30614. if m.created_at != nil {
  30615. fields = append(fields, usagestatistichour.FieldCreatedAt)
  30616. }
  30617. if m.updated_at != nil {
  30618. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  30619. }
  30620. if m.status != nil {
  30621. fields = append(fields, usagestatistichour.FieldStatus)
  30622. }
  30623. if m.deleted_at != nil {
  30624. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30625. }
  30626. if m.addtime != nil {
  30627. fields = append(fields, usagestatistichour.FieldAddtime)
  30628. }
  30629. if m._type != nil {
  30630. fields = append(fields, usagestatistichour.FieldType)
  30631. }
  30632. if m.bot_id != nil {
  30633. fields = append(fields, usagestatistichour.FieldBotID)
  30634. }
  30635. if m.organization_id != nil {
  30636. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30637. }
  30638. if m.ai_response != nil {
  30639. fields = append(fields, usagestatistichour.FieldAiResponse)
  30640. }
  30641. if m.sop_run != nil {
  30642. fields = append(fields, usagestatistichour.FieldSopRun)
  30643. }
  30644. if m.total_friend != nil {
  30645. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30646. }
  30647. if m.total_group != nil {
  30648. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30649. }
  30650. if m.account_balance != nil {
  30651. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30652. }
  30653. if m.consume_token != nil {
  30654. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30655. }
  30656. if m.active_user != nil {
  30657. fields = append(fields, usagestatistichour.FieldActiveUser)
  30658. }
  30659. if m.new_user != nil {
  30660. fields = append(fields, usagestatistichour.FieldNewUser)
  30661. }
  30662. if m.label_dist != nil {
  30663. fields = append(fields, usagestatistichour.FieldLabelDist)
  30664. }
  30665. return fields
  30666. }
  30667. // Field returns the value of a field with the given name. The second boolean
  30668. // return value indicates that this field was not set, or was not defined in the
  30669. // schema.
  30670. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  30671. switch name {
  30672. case usagestatistichour.FieldCreatedAt:
  30673. return m.CreatedAt()
  30674. case usagestatistichour.FieldUpdatedAt:
  30675. return m.UpdatedAt()
  30676. case usagestatistichour.FieldStatus:
  30677. return m.Status()
  30678. case usagestatistichour.FieldDeletedAt:
  30679. return m.DeletedAt()
  30680. case usagestatistichour.FieldAddtime:
  30681. return m.Addtime()
  30682. case usagestatistichour.FieldType:
  30683. return m.GetType()
  30684. case usagestatistichour.FieldBotID:
  30685. return m.BotID()
  30686. case usagestatistichour.FieldOrganizationID:
  30687. return m.OrganizationID()
  30688. case usagestatistichour.FieldAiResponse:
  30689. return m.AiResponse()
  30690. case usagestatistichour.FieldSopRun:
  30691. return m.SopRun()
  30692. case usagestatistichour.FieldTotalFriend:
  30693. return m.TotalFriend()
  30694. case usagestatistichour.FieldTotalGroup:
  30695. return m.TotalGroup()
  30696. case usagestatistichour.FieldAccountBalance:
  30697. return m.AccountBalance()
  30698. case usagestatistichour.FieldConsumeToken:
  30699. return m.ConsumeToken()
  30700. case usagestatistichour.FieldActiveUser:
  30701. return m.ActiveUser()
  30702. case usagestatistichour.FieldNewUser:
  30703. return m.NewUser()
  30704. case usagestatistichour.FieldLabelDist:
  30705. return m.LabelDist()
  30706. }
  30707. return nil, false
  30708. }
  30709. // OldField returns the old value of the field from the database. An error is
  30710. // returned if the mutation operation is not UpdateOne, or the query to the
  30711. // database failed.
  30712. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30713. switch name {
  30714. case usagestatistichour.FieldCreatedAt:
  30715. return m.OldCreatedAt(ctx)
  30716. case usagestatistichour.FieldUpdatedAt:
  30717. return m.OldUpdatedAt(ctx)
  30718. case usagestatistichour.FieldStatus:
  30719. return m.OldStatus(ctx)
  30720. case usagestatistichour.FieldDeletedAt:
  30721. return m.OldDeletedAt(ctx)
  30722. case usagestatistichour.FieldAddtime:
  30723. return m.OldAddtime(ctx)
  30724. case usagestatistichour.FieldType:
  30725. return m.OldType(ctx)
  30726. case usagestatistichour.FieldBotID:
  30727. return m.OldBotID(ctx)
  30728. case usagestatistichour.FieldOrganizationID:
  30729. return m.OldOrganizationID(ctx)
  30730. case usagestatistichour.FieldAiResponse:
  30731. return m.OldAiResponse(ctx)
  30732. case usagestatistichour.FieldSopRun:
  30733. return m.OldSopRun(ctx)
  30734. case usagestatistichour.FieldTotalFriend:
  30735. return m.OldTotalFriend(ctx)
  30736. case usagestatistichour.FieldTotalGroup:
  30737. return m.OldTotalGroup(ctx)
  30738. case usagestatistichour.FieldAccountBalance:
  30739. return m.OldAccountBalance(ctx)
  30740. case usagestatistichour.FieldConsumeToken:
  30741. return m.OldConsumeToken(ctx)
  30742. case usagestatistichour.FieldActiveUser:
  30743. return m.OldActiveUser(ctx)
  30744. case usagestatistichour.FieldNewUser:
  30745. return m.OldNewUser(ctx)
  30746. case usagestatistichour.FieldLabelDist:
  30747. return m.OldLabelDist(ctx)
  30748. }
  30749. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30750. }
  30751. // SetField sets the value of a field with the given name. It returns an error if
  30752. // the field is not defined in the schema, or if the type mismatched the field
  30753. // type.
  30754. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  30755. switch name {
  30756. case usagestatistichour.FieldCreatedAt:
  30757. v, ok := value.(time.Time)
  30758. if !ok {
  30759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30760. }
  30761. m.SetCreatedAt(v)
  30762. return nil
  30763. case usagestatistichour.FieldUpdatedAt:
  30764. v, ok := value.(time.Time)
  30765. if !ok {
  30766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30767. }
  30768. m.SetUpdatedAt(v)
  30769. return nil
  30770. case usagestatistichour.FieldStatus:
  30771. v, ok := value.(uint8)
  30772. if !ok {
  30773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30774. }
  30775. m.SetStatus(v)
  30776. return nil
  30777. case usagestatistichour.FieldDeletedAt:
  30778. v, ok := value.(time.Time)
  30779. if !ok {
  30780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30781. }
  30782. m.SetDeletedAt(v)
  30783. return nil
  30784. case usagestatistichour.FieldAddtime:
  30785. v, ok := value.(uint64)
  30786. if !ok {
  30787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30788. }
  30789. m.SetAddtime(v)
  30790. return nil
  30791. case usagestatistichour.FieldType:
  30792. v, ok := value.(int)
  30793. if !ok {
  30794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30795. }
  30796. m.SetType(v)
  30797. return nil
  30798. case usagestatistichour.FieldBotID:
  30799. v, ok := value.(string)
  30800. if !ok {
  30801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30802. }
  30803. m.SetBotID(v)
  30804. return nil
  30805. case usagestatistichour.FieldOrganizationID:
  30806. v, ok := value.(uint64)
  30807. if !ok {
  30808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30809. }
  30810. m.SetOrganizationID(v)
  30811. return nil
  30812. case usagestatistichour.FieldAiResponse:
  30813. v, ok := value.(uint64)
  30814. if !ok {
  30815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30816. }
  30817. m.SetAiResponse(v)
  30818. return nil
  30819. case usagestatistichour.FieldSopRun:
  30820. v, ok := value.(uint64)
  30821. if !ok {
  30822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30823. }
  30824. m.SetSopRun(v)
  30825. return nil
  30826. case usagestatistichour.FieldTotalFriend:
  30827. v, ok := value.(uint64)
  30828. if !ok {
  30829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30830. }
  30831. m.SetTotalFriend(v)
  30832. return nil
  30833. case usagestatistichour.FieldTotalGroup:
  30834. v, ok := value.(uint64)
  30835. if !ok {
  30836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30837. }
  30838. m.SetTotalGroup(v)
  30839. return nil
  30840. case usagestatistichour.FieldAccountBalance:
  30841. v, ok := value.(uint64)
  30842. if !ok {
  30843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30844. }
  30845. m.SetAccountBalance(v)
  30846. return nil
  30847. case usagestatistichour.FieldConsumeToken:
  30848. v, ok := value.(uint64)
  30849. if !ok {
  30850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30851. }
  30852. m.SetConsumeToken(v)
  30853. return nil
  30854. case usagestatistichour.FieldActiveUser:
  30855. v, ok := value.(uint64)
  30856. if !ok {
  30857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30858. }
  30859. m.SetActiveUser(v)
  30860. return nil
  30861. case usagestatistichour.FieldNewUser:
  30862. v, ok := value.(int64)
  30863. if !ok {
  30864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30865. }
  30866. m.SetNewUser(v)
  30867. return nil
  30868. case usagestatistichour.FieldLabelDist:
  30869. v, ok := value.([]custom_types.LabelDist)
  30870. if !ok {
  30871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30872. }
  30873. m.SetLabelDist(v)
  30874. return nil
  30875. }
  30876. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30877. }
  30878. // AddedFields returns all numeric fields that were incremented/decremented during
  30879. // this mutation.
  30880. func (m *UsageStatisticHourMutation) AddedFields() []string {
  30881. var fields []string
  30882. if m.addstatus != nil {
  30883. fields = append(fields, usagestatistichour.FieldStatus)
  30884. }
  30885. if m.addaddtime != nil {
  30886. fields = append(fields, usagestatistichour.FieldAddtime)
  30887. }
  30888. if m.add_type != nil {
  30889. fields = append(fields, usagestatistichour.FieldType)
  30890. }
  30891. if m.addorganization_id != nil {
  30892. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30893. }
  30894. if m.addai_response != nil {
  30895. fields = append(fields, usagestatistichour.FieldAiResponse)
  30896. }
  30897. if m.addsop_run != nil {
  30898. fields = append(fields, usagestatistichour.FieldSopRun)
  30899. }
  30900. if m.addtotal_friend != nil {
  30901. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30902. }
  30903. if m.addtotal_group != nil {
  30904. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30905. }
  30906. if m.addaccount_balance != nil {
  30907. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30908. }
  30909. if m.addconsume_token != nil {
  30910. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30911. }
  30912. if m.addactive_user != nil {
  30913. fields = append(fields, usagestatistichour.FieldActiveUser)
  30914. }
  30915. if m.addnew_user != nil {
  30916. fields = append(fields, usagestatistichour.FieldNewUser)
  30917. }
  30918. return fields
  30919. }
  30920. // AddedField returns the numeric value that was incremented/decremented on a field
  30921. // with the given name. The second boolean return value indicates that this field
  30922. // was not set, or was not defined in the schema.
  30923. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  30924. switch name {
  30925. case usagestatistichour.FieldStatus:
  30926. return m.AddedStatus()
  30927. case usagestatistichour.FieldAddtime:
  30928. return m.AddedAddtime()
  30929. case usagestatistichour.FieldType:
  30930. return m.AddedType()
  30931. case usagestatistichour.FieldOrganizationID:
  30932. return m.AddedOrganizationID()
  30933. case usagestatistichour.FieldAiResponse:
  30934. return m.AddedAiResponse()
  30935. case usagestatistichour.FieldSopRun:
  30936. return m.AddedSopRun()
  30937. case usagestatistichour.FieldTotalFriend:
  30938. return m.AddedTotalFriend()
  30939. case usagestatistichour.FieldTotalGroup:
  30940. return m.AddedTotalGroup()
  30941. case usagestatistichour.FieldAccountBalance:
  30942. return m.AddedAccountBalance()
  30943. case usagestatistichour.FieldConsumeToken:
  30944. return m.AddedConsumeToken()
  30945. case usagestatistichour.FieldActiveUser:
  30946. return m.AddedActiveUser()
  30947. case usagestatistichour.FieldNewUser:
  30948. return m.AddedNewUser()
  30949. }
  30950. return nil, false
  30951. }
  30952. // AddField adds the value to the field with the given name. It returns an error if
  30953. // the field is not defined in the schema, or if the type mismatched the field
  30954. // type.
  30955. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  30956. switch name {
  30957. case usagestatistichour.FieldStatus:
  30958. v, ok := value.(int8)
  30959. if !ok {
  30960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30961. }
  30962. m.AddStatus(v)
  30963. return nil
  30964. case usagestatistichour.FieldAddtime:
  30965. v, ok := value.(int64)
  30966. if !ok {
  30967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30968. }
  30969. m.AddAddtime(v)
  30970. return nil
  30971. case usagestatistichour.FieldType:
  30972. v, ok := value.(int)
  30973. if !ok {
  30974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30975. }
  30976. m.AddType(v)
  30977. return nil
  30978. case usagestatistichour.FieldOrganizationID:
  30979. v, ok := value.(int64)
  30980. if !ok {
  30981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30982. }
  30983. m.AddOrganizationID(v)
  30984. return nil
  30985. case usagestatistichour.FieldAiResponse:
  30986. v, ok := value.(int64)
  30987. if !ok {
  30988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30989. }
  30990. m.AddAiResponse(v)
  30991. return nil
  30992. case usagestatistichour.FieldSopRun:
  30993. v, ok := value.(int64)
  30994. if !ok {
  30995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30996. }
  30997. m.AddSopRun(v)
  30998. return nil
  30999. case usagestatistichour.FieldTotalFriend:
  31000. v, ok := value.(int64)
  31001. if !ok {
  31002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31003. }
  31004. m.AddTotalFriend(v)
  31005. return nil
  31006. case usagestatistichour.FieldTotalGroup:
  31007. v, ok := value.(int64)
  31008. if !ok {
  31009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31010. }
  31011. m.AddTotalGroup(v)
  31012. return nil
  31013. case usagestatistichour.FieldAccountBalance:
  31014. v, ok := value.(int64)
  31015. if !ok {
  31016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31017. }
  31018. m.AddAccountBalance(v)
  31019. return nil
  31020. case usagestatistichour.FieldConsumeToken:
  31021. v, ok := value.(int64)
  31022. if !ok {
  31023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31024. }
  31025. m.AddConsumeToken(v)
  31026. return nil
  31027. case usagestatistichour.FieldActiveUser:
  31028. v, ok := value.(int64)
  31029. if !ok {
  31030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31031. }
  31032. m.AddActiveUser(v)
  31033. return nil
  31034. case usagestatistichour.FieldNewUser:
  31035. v, ok := value.(int64)
  31036. if !ok {
  31037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31038. }
  31039. m.AddNewUser(v)
  31040. return nil
  31041. }
  31042. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  31043. }
  31044. // ClearedFields returns all nullable fields that were cleared during this
  31045. // mutation.
  31046. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  31047. var fields []string
  31048. if m.FieldCleared(usagestatistichour.FieldStatus) {
  31049. fields = append(fields, usagestatistichour.FieldStatus)
  31050. }
  31051. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  31052. fields = append(fields, usagestatistichour.FieldDeletedAt)
  31053. }
  31054. if m.FieldCleared(usagestatistichour.FieldBotID) {
  31055. fields = append(fields, usagestatistichour.FieldBotID)
  31056. }
  31057. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  31058. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31059. }
  31060. return fields
  31061. }
  31062. // FieldCleared returns a boolean indicating if a field with the given name was
  31063. // cleared in this mutation.
  31064. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  31065. _, ok := m.clearedFields[name]
  31066. return ok
  31067. }
  31068. // ClearField clears the value of the field with the given name. It returns an
  31069. // error if the field is not defined in the schema.
  31070. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  31071. switch name {
  31072. case usagestatistichour.FieldStatus:
  31073. m.ClearStatus()
  31074. return nil
  31075. case usagestatistichour.FieldDeletedAt:
  31076. m.ClearDeletedAt()
  31077. return nil
  31078. case usagestatistichour.FieldBotID:
  31079. m.ClearBotID()
  31080. return nil
  31081. case usagestatistichour.FieldOrganizationID:
  31082. m.ClearOrganizationID()
  31083. return nil
  31084. }
  31085. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  31086. }
  31087. // ResetField resets all changes in the mutation for the field with the given name.
  31088. // It returns an error if the field is not defined in the schema.
  31089. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  31090. switch name {
  31091. case usagestatistichour.FieldCreatedAt:
  31092. m.ResetCreatedAt()
  31093. return nil
  31094. case usagestatistichour.FieldUpdatedAt:
  31095. m.ResetUpdatedAt()
  31096. return nil
  31097. case usagestatistichour.FieldStatus:
  31098. m.ResetStatus()
  31099. return nil
  31100. case usagestatistichour.FieldDeletedAt:
  31101. m.ResetDeletedAt()
  31102. return nil
  31103. case usagestatistichour.FieldAddtime:
  31104. m.ResetAddtime()
  31105. return nil
  31106. case usagestatistichour.FieldType:
  31107. m.ResetType()
  31108. return nil
  31109. case usagestatistichour.FieldBotID:
  31110. m.ResetBotID()
  31111. return nil
  31112. case usagestatistichour.FieldOrganizationID:
  31113. m.ResetOrganizationID()
  31114. return nil
  31115. case usagestatistichour.FieldAiResponse:
  31116. m.ResetAiResponse()
  31117. return nil
  31118. case usagestatistichour.FieldSopRun:
  31119. m.ResetSopRun()
  31120. return nil
  31121. case usagestatistichour.FieldTotalFriend:
  31122. m.ResetTotalFriend()
  31123. return nil
  31124. case usagestatistichour.FieldTotalGroup:
  31125. m.ResetTotalGroup()
  31126. return nil
  31127. case usagestatistichour.FieldAccountBalance:
  31128. m.ResetAccountBalance()
  31129. return nil
  31130. case usagestatistichour.FieldConsumeToken:
  31131. m.ResetConsumeToken()
  31132. return nil
  31133. case usagestatistichour.FieldActiveUser:
  31134. m.ResetActiveUser()
  31135. return nil
  31136. case usagestatistichour.FieldNewUser:
  31137. m.ResetNewUser()
  31138. return nil
  31139. case usagestatistichour.FieldLabelDist:
  31140. m.ResetLabelDist()
  31141. return nil
  31142. }
  31143. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31144. }
  31145. // AddedEdges returns all edge names that were set/added in this mutation.
  31146. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  31147. edges := make([]string, 0, 0)
  31148. return edges
  31149. }
  31150. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31151. // name in this mutation.
  31152. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  31153. return nil
  31154. }
  31155. // RemovedEdges returns all edge names that were removed in this mutation.
  31156. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  31157. edges := make([]string, 0, 0)
  31158. return edges
  31159. }
  31160. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31161. // the given name in this mutation.
  31162. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  31163. return nil
  31164. }
  31165. // ClearedEdges returns all edge names that were cleared in this mutation.
  31166. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  31167. edges := make([]string, 0, 0)
  31168. return edges
  31169. }
  31170. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31171. // was cleared in this mutation.
  31172. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  31173. return false
  31174. }
  31175. // ClearEdge clears the value of the edge with the given name. It returns an error
  31176. // if that edge is not defined in the schema.
  31177. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  31178. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  31179. }
  31180. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31181. // It returns an error if the edge is not defined in the schema.
  31182. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  31183. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  31184. }
  31185. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  31186. type UsageStatisticMonthMutation struct {
  31187. config
  31188. op Op
  31189. typ string
  31190. id *uint64
  31191. created_at *time.Time
  31192. updated_at *time.Time
  31193. status *uint8
  31194. addstatus *int8
  31195. deleted_at *time.Time
  31196. addtime *uint64
  31197. addaddtime *int64
  31198. _type *int
  31199. add_type *int
  31200. bot_id *string
  31201. organization_id *uint64
  31202. addorganization_id *int64
  31203. ai_response *uint64
  31204. addai_response *int64
  31205. sop_run *uint64
  31206. addsop_run *int64
  31207. total_friend *uint64
  31208. addtotal_friend *int64
  31209. total_group *uint64
  31210. addtotal_group *int64
  31211. account_balance *uint64
  31212. addaccount_balance *int64
  31213. consume_token *uint64
  31214. addconsume_token *int64
  31215. active_user *uint64
  31216. addactive_user *int64
  31217. new_user *int64
  31218. addnew_user *int64
  31219. label_dist *[]custom_types.LabelDist
  31220. appendlabel_dist []custom_types.LabelDist
  31221. clearedFields map[string]struct{}
  31222. done bool
  31223. oldValue func(context.Context) (*UsageStatisticMonth, error)
  31224. predicates []predicate.UsageStatisticMonth
  31225. }
  31226. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  31227. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  31228. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  31229. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  31230. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  31231. m := &UsageStatisticMonthMutation{
  31232. config: c,
  31233. op: op,
  31234. typ: TypeUsageStatisticMonth,
  31235. clearedFields: make(map[string]struct{}),
  31236. }
  31237. for _, opt := range opts {
  31238. opt(m)
  31239. }
  31240. return m
  31241. }
  31242. // withUsageStatisticMonthID sets the ID field of the mutation.
  31243. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  31244. return func(m *UsageStatisticMonthMutation) {
  31245. var (
  31246. err error
  31247. once sync.Once
  31248. value *UsageStatisticMonth
  31249. )
  31250. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  31251. once.Do(func() {
  31252. if m.done {
  31253. err = errors.New("querying old values post mutation is not allowed")
  31254. } else {
  31255. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  31256. }
  31257. })
  31258. return value, err
  31259. }
  31260. m.id = &id
  31261. }
  31262. }
  31263. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  31264. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  31265. return func(m *UsageStatisticMonthMutation) {
  31266. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  31267. return node, nil
  31268. }
  31269. m.id = &node.ID
  31270. }
  31271. }
  31272. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31273. // executed in a transaction (ent.Tx), a transactional client is returned.
  31274. func (m UsageStatisticMonthMutation) Client() *Client {
  31275. client := &Client{config: m.config}
  31276. client.init()
  31277. return client
  31278. }
  31279. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31280. // it returns an error otherwise.
  31281. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  31282. if _, ok := m.driver.(*txDriver); !ok {
  31283. return nil, errors.New("ent: mutation is not running in a transaction")
  31284. }
  31285. tx := &Tx{config: m.config}
  31286. tx.init()
  31287. return tx, nil
  31288. }
  31289. // SetID sets the value of the id field. Note that this
  31290. // operation is only accepted on creation of UsageStatisticMonth entities.
  31291. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  31292. m.id = &id
  31293. }
  31294. // ID returns the ID value in the mutation. Note that the ID is only available
  31295. // if it was provided to the builder or after it was returned from the database.
  31296. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  31297. if m.id == nil {
  31298. return
  31299. }
  31300. return *m.id, true
  31301. }
  31302. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31303. // That means, if the mutation is applied within a transaction with an isolation level such
  31304. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31305. // or updated by the mutation.
  31306. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  31307. switch {
  31308. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31309. id, exists := m.ID()
  31310. if exists {
  31311. return []uint64{id}, nil
  31312. }
  31313. fallthrough
  31314. case m.op.Is(OpUpdate | OpDelete):
  31315. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  31316. default:
  31317. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31318. }
  31319. }
  31320. // SetCreatedAt sets the "created_at" field.
  31321. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  31322. m.created_at = &t
  31323. }
  31324. // CreatedAt returns the value of the "created_at" field in the mutation.
  31325. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  31326. v := m.created_at
  31327. if v == nil {
  31328. return
  31329. }
  31330. return *v, true
  31331. }
  31332. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  31333. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31335. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31336. if !m.op.Is(OpUpdateOne) {
  31337. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31338. }
  31339. if m.id == nil || m.oldValue == nil {
  31340. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31341. }
  31342. oldValue, err := m.oldValue(ctx)
  31343. if err != nil {
  31344. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31345. }
  31346. return oldValue.CreatedAt, nil
  31347. }
  31348. // ResetCreatedAt resets all changes to the "created_at" field.
  31349. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  31350. m.created_at = nil
  31351. }
  31352. // SetUpdatedAt sets the "updated_at" field.
  31353. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  31354. m.updated_at = &t
  31355. }
  31356. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31357. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  31358. v := m.updated_at
  31359. if v == nil {
  31360. return
  31361. }
  31362. return *v, true
  31363. }
  31364. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  31365. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31367. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31368. if !m.op.Is(OpUpdateOne) {
  31369. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31370. }
  31371. if m.id == nil || m.oldValue == nil {
  31372. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31373. }
  31374. oldValue, err := m.oldValue(ctx)
  31375. if err != nil {
  31376. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31377. }
  31378. return oldValue.UpdatedAt, nil
  31379. }
  31380. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31381. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  31382. m.updated_at = nil
  31383. }
  31384. // SetStatus sets the "status" field.
  31385. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  31386. m.status = &u
  31387. m.addstatus = nil
  31388. }
  31389. // Status returns the value of the "status" field in the mutation.
  31390. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  31391. v := m.status
  31392. if v == nil {
  31393. return
  31394. }
  31395. return *v, true
  31396. }
  31397. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  31398. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31400. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31401. if !m.op.Is(OpUpdateOne) {
  31402. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31403. }
  31404. if m.id == nil || m.oldValue == nil {
  31405. return v, errors.New("OldStatus requires an ID field in the mutation")
  31406. }
  31407. oldValue, err := m.oldValue(ctx)
  31408. if err != nil {
  31409. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31410. }
  31411. return oldValue.Status, nil
  31412. }
  31413. // AddStatus adds u to the "status" field.
  31414. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  31415. if m.addstatus != nil {
  31416. *m.addstatus += u
  31417. } else {
  31418. m.addstatus = &u
  31419. }
  31420. }
  31421. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31422. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  31423. v := m.addstatus
  31424. if v == nil {
  31425. return
  31426. }
  31427. return *v, true
  31428. }
  31429. // ClearStatus clears the value of the "status" field.
  31430. func (m *UsageStatisticMonthMutation) ClearStatus() {
  31431. m.status = nil
  31432. m.addstatus = nil
  31433. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  31434. }
  31435. // StatusCleared returns if the "status" field was cleared in this mutation.
  31436. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  31437. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  31438. return ok
  31439. }
  31440. // ResetStatus resets all changes to the "status" field.
  31441. func (m *UsageStatisticMonthMutation) ResetStatus() {
  31442. m.status = nil
  31443. m.addstatus = nil
  31444. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  31445. }
  31446. // SetDeletedAt sets the "deleted_at" field.
  31447. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  31448. m.deleted_at = &t
  31449. }
  31450. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31451. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  31452. v := m.deleted_at
  31453. if v == nil {
  31454. return
  31455. }
  31456. return *v, true
  31457. }
  31458. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  31459. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31461. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31462. if !m.op.Is(OpUpdateOne) {
  31463. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31464. }
  31465. if m.id == nil || m.oldValue == nil {
  31466. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31467. }
  31468. oldValue, err := m.oldValue(ctx)
  31469. if err != nil {
  31470. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31471. }
  31472. return oldValue.DeletedAt, nil
  31473. }
  31474. // ClearDeletedAt clears the value of the "deleted_at" field.
  31475. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  31476. m.deleted_at = nil
  31477. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  31478. }
  31479. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31480. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  31481. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  31482. return ok
  31483. }
  31484. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31485. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  31486. m.deleted_at = nil
  31487. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  31488. }
  31489. // SetAddtime sets the "addtime" field.
  31490. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  31491. m.addtime = &u
  31492. m.addaddtime = nil
  31493. }
  31494. // Addtime returns the value of the "addtime" field in the mutation.
  31495. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  31496. v := m.addtime
  31497. if v == nil {
  31498. return
  31499. }
  31500. return *v, true
  31501. }
  31502. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  31503. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31505. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31506. if !m.op.Is(OpUpdateOne) {
  31507. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31508. }
  31509. if m.id == nil || m.oldValue == nil {
  31510. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31511. }
  31512. oldValue, err := m.oldValue(ctx)
  31513. if err != nil {
  31514. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31515. }
  31516. return oldValue.Addtime, nil
  31517. }
  31518. // AddAddtime adds u to the "addtime" field.
  31519. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  31520. if m.addaddtime != nil {
  31521. *m.addaddtime += u
  31522. } else {
  31523. m.addaddtime = &u
  31524. }
  31525. }
  31526. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31527. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  31528. v := m.addaddtime
  31529. if v == nil {
  31530. return
  31531. }
  31532. return *v, true
  31533. }
  31534. // ResetAddtime resets all changes to the "addtime" field.
  31535. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  31536. m.addtime = nil
  31537. m.addaddtime = nil
  31538. }
  31539. // SetType sets the "type" field.
  31540. func (m *UsageStatisticMonthMutation) SetType(i int) {
  31541. m._type = &i
  31542. m.add_type = nil
  31543. }
  31544. // GetType returns the value of the "type" field in the mutation.
  31545. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  31546. v := m._type
  31547. if v == nil {
  31548. return
  31549. }
  31550. return *v, true
  31551. }
  31552. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  31553. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31555. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  31556. if !m.op.Is(OpUpdateOne) {
  31557. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31558. }
  31559. if m.id == nil || m.oldValue == nil {
  31560. return v, errors.New("OldType requires an ID field in the mutation")
  31561. }
  31562. oldValue, err := m.oldValue(ctx)
  31563. if err != nil {
  31564. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31565. }
  31566. return oldValue.Type, nil
  31567. }
  31568. // AddType adds i to the "type" field.
  31569. func (m *UsageStatisticMonthMutation) AddType(i int) {
  31570. if m.add_type != nil {
  31571. *m.add_type += i
  31572. } else {
  31573. m.add_type = &i
  31574. }
  31575. }
  31576. // AddedType returns the value that was added to the "type" field in this mutation.
  31577. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  31578. v := m.add_type
  31579. if v == nil {
  31580. return
  31581. }
  31582. return *v, true
  31583. }
  31584. // ResetType resets all changes to the "type" field.
  31585. func (m *UsageStatisticMonthMutation) ResetType() {
  31586. m._type = nil
  31587. m.add_type = nil
  31588. }
  31589. // SetBotID sets the "bot_id" field.
  31590. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  31591. m.bot_id = &s
  31592. }
  31593. // BotID returns the value of the "bot_id" field in the mutation.
  31594. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  31595. v := m.bot_id
  31596. if v == nil {
  31597. return
  31598. }
  31599. return *v, true
  31600. }
  31601. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  31602. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31604. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  31605. if !m.op.Is(OpUpdateOne) {
  31606. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31607. }
  31608. if m.id == nil || m.oldValue == nil {
  31609. return v, errors.New("OldBotID requires an ID field in the mutation")
  31610. }
  31611. oldValue, err := m.oldValue(ctx)
  31612. if err != nil {
  31613. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31614. }
  31615. return oldValue.BotID, nil
  31616. }
  31617. // ClearBotID clears the value of the "bot_id" field.
  31618. func (m *UsageStatisticMonthMutation) ClearBotID() {
  31619. m.bot_id = nil
  31620. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  31621. }
  31622. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31623. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  31624. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  31625. return ok
  31626. }
  31627. // ResetBotID resets all changes to the "bot_id" field.
  31628. func (m *UsageStatisticMonthMutation) ResetBotID() {
  31629. m.bot_id = nil
  31630. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  31631. }
  31632. // SetOrganizationID sets the "organization_id" field.
  31633. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  31634. m.organization_id = &u
  31635. m.addorganization_id = nil
  31636. }
  31637. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31638. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  31639. v := m.organization_id
  31640. if v == nil {
  31641. return
  31642. }
  31643. return *v, true
  31644. }
  31645. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  31646. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31648. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31649. if !m.op.Is(OpUpdateOne) {
  31650. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31651. }
  31652. if m.id == nil || m.oldValue == nil {
  31653. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31654. }
  31655. oldValue, err := m.oldValue(ctx)
  31656. if err != nil {
  31657. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31658. }
  31659. return oldValue.OrganizationID, nil
  31660. }
  31661. // AddOrganizationID adds u to the "organization_id" field.
  31662. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  31663. if m.addorganization_id != nil {
  31664. *m.addorganization_id += u
  31665. } else {
  31666. m.addorganization_id = &u
  31667. }
  31668. }
  31669. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31670. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  31671. v := m.addorganization_id
  31672. if v == nil {
  31673. return
  31674. }
  31675. return *v, true
  31676. }
  31677. // ClearOrganizationID clears the value of the "organization_id" field.
  31678. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  31679. m.organization_id = nil
  31680. m.addorganization_id = nil
  31681. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  31682. }
  31683. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31684. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  31685. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  31686. return ok
  31687. }
  31688. // ResetOrganizationID resets all changes to the "organization_id" field.
  31689. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  31690. m.organization_id = nil
  31691. m.addorganization_id = nil
  31692. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  31693. }
  31694. // SetAiResponse sets the "ai_response" field.
  31695. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  31696. m.ai_response = &u
  31697. m.addai_response = nil
  31698. }
  31699. // AiResponse returns the value of the "ai_response" field in the mutation.
  31700. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  31701. v := m.ai_response
  31702. if v == nil {
  31703. return
  31704. }
  31705. return *v, true
  31706. }
  31707. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  31708. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31710. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31711. if !m.op.Is(OpUpdateOne) {
  31712. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31713. }
  31714. if m.id == nil || m.oldValue == nil {
  31715. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31716. }
  31717. oldValue, err := m.oldValue(ctx)
  31718. if err != nil {
  31719. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31720. }
  31721. return oldValue.AiResponse, nil
  31722. }
  31723. // AddAiResponse adds u to the "ai_response" field.
  31724. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  31725. if m.addai_response != nil {
  31726. *m.addai_response += u
  31727. } else {
  31728. m.addai_response = &u
  31729. }
  31730. }
  31731. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31732. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  31733. v := m.addai_response
  31734. if v == nil {
  31735. return
  31736. }
  31737. return *v, true
  31738. }
  31739. // ResetAiResponse resets all changes to the "ai_response" field.
  31740. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  31741. m.ai_response = nil
  31742. m.addai_response = nil
  31743. }
  31744. // SetSopRun sets the "sop_run" field.
  31745. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  31746. m.sop_run = &u
  31747. m.addsop_run = nil
  31748. }
  31749. // SopRun returns the value of the "sop_run" field in the mutation.
  31750. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  31751. v := m.sop_run
  31752. if v == nil {
  31753. return
  31754. }
  31755. return *v, true
  31756. }
  31757. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  31758. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31760. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31761. if !m.op.Is(OpUpdateOne) {
  31762. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31763. }
  31764. if m.id == nil || m.oldValue == nil {
  31765. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31766. }
  31767. oldValue, err := m.oldValue(ctx)
  31768. if err != nil {
  31769. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31770. }
  31771. return oldValue.SopRun, nil
  31772. }
  31773. // AddSopRun adds u to the "sop_run" field.
  31774. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  31775. if m.addsop_run != nil {
  31776. *m.addsop_run += u
  31777. } else {
  31778. m.addsop_run = &u
  31779. }
  31780. }
  31781. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31782. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  31783. v := m.addsop_run
  31784. if v == nil {
  31785. return
  31786. }
  31787. return *v, true
  31788. }
  31789. // ResetSopRun resets all changes to the "sop_run" field.
  31790. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  31791. m.sop_run = nil
  31792. m.addsop_run = nil
  31793. }
  31794. // SetTotalFriend sets the "total_friend" field.
  31795. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  31796. m.total_friend = &u
  31797. m.addtotal_friend = nil
  31798. }
  31799. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31800. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  31801. v := m.total_friend
  31802. if v == nil {
  31803. return
  31804. }
  31805. return *v, true
  31806. }
  31807. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  31808. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31810. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31811. if !m.op.Is(OpUpdateOne) {
  31812. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31813. }
  31814. if m.id == nil || m.oldValue == nil {
  31815. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31816. }
  31817. oldValue, err := m.oldValue(ctx)
  31818. if err != nil {
  31819. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31820. }
  31821. return oldValue.TotalFriend, nil
  31822. }
  31823. // AddTotalFriend adds u to the "total_friend" field.
  31824. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  31825. if m.addtotal_friend != nil {
  31826. *m.addtotal_friend += u
  31827. } else {
  31828. m.addtotal_friend = &u
  31829. }
  31830. }
  31831. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31832. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  31833. v := m.addtotal_friend
  31834. if v == nil {
  31835. return
  31836. }
  31837. return *v, true
  31838. }
  31839. // ResetTotalFriend resets all changes to the "total_friend" field.
  31840. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  31841. m.total_friend = nil
  31842. m.addtotal_friend = nil
  31843. }
  31844. // SetTotalGroup sets the "total_group" field.
  31845. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  31846. m.total_group = &u
  31847. m.addtotal_group = nil
  31848. }
  31849. // TotalGroup returns the value of the "total_group" field in the mutation.
  31850. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  31851. v := m.total_group
  31852. if v == nil {
  31853. return
  31854. }
  31855. return *v, true
  31856. }
  31857. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  31858. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31860. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31861. if !m.op.Is(OpUpdateOne) {
  31862. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31863. }
  31864. if m.id == nil || m.oldValue == nil {
  31865. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31866. }
  31867. oldValue, err := m.oldValue(ctx)
  31868. if err != nil {
  31869. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31870. }
  31871. return oldValue.TotalGroup, nil
  31872. }
  31873. // AddTotalGroup adds u to the "total_group" field.
  31874. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  31875. if m.addtotal_group != nil {
  31876. *m.addtotal_group += u
  31877. } else {
  31878. m.addtotal_group = &u
  31879. }
  31880. }
  31881. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31882. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  31883. v := m.addtotal_group
  31884. if v == nil {
  31885. return
  31886. }
  31887. return *v, true
  31888. }
  31889. // ResetTotalGroup resets all changes to the "total_group" field.
  31890. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  31891. m.total_group = nil
  31892. m.addtotal_group = nil
  31893. }
  31894. // SetAccountBalance sets the "account_balance" field.
  31895. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  31896. m.account_balance = &u
  31897. m.addaccount_balance = nil
  31898. }
  31899. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31900. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  31901. v := m.account_balance
  31902. if v == nil {
  31903. return
  31904. }
  31905. return *v, true
  31906. }
  31907. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  31908. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31910. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31911. if !m.op.Is(OpUpdateOne) {
  31912. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31913. }
  31914. if m.id == nil || m.oldValue == nil {
  31915. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31916. }
  31917. oldValue, err := m.oldValue(ctx)
  31918. if err != nil {
  31919. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31920. }
  31921. return oldValue.AccountBalance, nil
  31922. }
  31923. // AddAccountBalance adds u to the "account_balance" field.
  31924. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  31925. if m.addaccount_balance != nil {
  31926. *m.addaccount_balance += u
  31927. } else {
  31928. m.addaccount_balance = &u
  31929. }
  31930. }
  31931. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31932. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  31933. v := m.addaccount_balance
  31934. if v == nil {
  31935. return
  31936. }
  31937. return *v, true
  31938. }
  31939. // ResetAccountBalance resets all changes to the "account_balance" field.
  31940. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  31941. m.account_balance = nil
  31942. m.addaccount_balance = nil
  31943. }
  31944. // SetConsumeToken sets the "consume_token" field.
  31945. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  31946. m.consume_token = &u
  31947. m.addconsume_token = nil
  31948. }
  31949. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31950. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  31951. v := m.consume_token
  31952. if v == nil {
  31953. return
  31954. }
  31955. return *v, true
  31956. }
  31957. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  31958. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31960. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31961. if !m.op.Is(OpUpdateOne) {
  31962. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31963. }
  31964. if m.id == nil || m.oldValue == nil {
  31965. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31966. }
  31967. oldValue, err := m.oldValue(ctx)
  31968. if err != nil {
  31969. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31970. }
  31971. return oldValue.ConsumeToken, nil
  31972. }
  31973. // AddConsumeToken adds u to the "consume_token" field.
  31974. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  31975. if m.addconsume_token != nil {
  31976. *m.addconsume_token += u
  31977. } else {
  31978. m.addconsume_token = &u
  31979. }
  31980. }
  31981. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31982. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  31983. v := m.addconsume_token
  31984. if v == nil {
  31985. return
  31986. }
  31987. return *v, true
  31988. }
  31989. // ResetConsumeToken resets all changes to the "consume_token" field.
  31990. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  31991. m.consume_token = nil
  31992. m.addconsume_token = nil
  31993. }
  31994. // SetActiveUser sets the "active_user" field.
  31995. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  31996. m.active_user = &u
  31997. m.addactive_user = nil
  31998. }
  31999. // ActiveUser returns the value of the "active_user" field in the mutation.
  32000. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  32001. v := m.active_user
  32002. if v == nil {
  32003. return
  32004. }
  32005. return *v, true
  32006. }
  32007. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  32008. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32010. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32011. if !m.op.Is(OpUpdateOne) {
  32012. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32013. }
  32014. if m.id == nil || m.oldValue == nil {
  32015. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32016. }
  32017. oldValue, err := m.oldValue(ctx)
  32018. if err != nil {
  32019. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32020. }
  32021. return oldValue.ActiveUser, nil
  32022. }
  32023. // AddActiveUser adds u to the "active_user" field.
  32024. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  32025. if m.addactive_user != nil {
  32026. *m.addactive_user += u
  32027. } else {
  32028. m.addactive_user = &u
  32029. }
  32030. }
  32031. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32032. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  32033. v := m.addactive_user
  32034. if v == nil {
  32035. return
  32036. }
  32037. return *v, true
  32038. }
  32039. // ResetActiveUser resets all changes to the "active_user" field.
  32040. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  32041. m.active_user = nil
  32042. m.addactive_user = nil
  32043. }
  32044. // SetNewUser sets the "new_user" field.
  32045. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  32046. m.new_user = &i
  32047. m.addnew_user = nil
  32048. }
  32049. // NewUser returns the value of the "new_user" field in the mutation.
  32050. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  32051. v := m.new_user
  32052. if v == nil {
  32053. return
  32054. }
  32055. return *v, true
  32056. }
  32057. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  32058. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32060. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32061. if !m.op.Is(OpUpdateOne) {
  32062. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32063. }
  32064. if m.id == nil || m.oldValue == nil {
  32065. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32066. }
  32067. oldValue, err := m.oldValue(ctx)
  32068. if err != nil {
  32069. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32070. }
  32071. return oldValue.NewUser, nil
  32072. }
  32073. // AddNewUser adds i to the "new_user" field.
  32074. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  32075. if m.addnew_user != nil {
  32076. *m.addnew_user += i
  32077. } else {
  32078. m.addnew_user = &i
  32079. }
  32080. }
  32081. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32082. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  32083. v := m.addnew_user
  32084. if v == nil {
  32085. return
  32086. }
  32087. return *v, true
  32088. }
  32089. // ResetNewUser resets all changes to the "new_user" field.
  32090. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  32091. m.new_user = nil
  32092. m.addnew_user = nil
  32093. }
  32094. // SetLabelDist sets the "label_dist" field.
  32095. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32096. m.label_dist = &ctd
  32097. m.appendlabel_dist = nil
  32098. }
  32099. // LabelDist returns the value of the "label_dist" field in the mutation.
  32100. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32101. v := m.label_dist
  32102. if v == nil {
  32103. return
  32104. }
  32105. return *v, true
  32106. }
  32107. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  32108. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32110. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32111. if !m.op.Is(OpUpdateOne) {
  32112. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32113. }
  32114. if m.id == nil || m.oldValue == nil {
  32115. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32116. }
  32117. oldValue, err := m.oldValue(ctx)
  32118. if err != nil {
  32119. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32120. }
  32121. return oldValue.LabelDist, nil
  32122. }
  32123. // AppendLabelDist adds ctd to the "label_dist" field.
  32124. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32125. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32126. }
  32127. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32128. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32129. if len(m.appendlabel_dist) == 0 {
  32130. return nil, false
  32131. }
  32132. return m.appendlabel_dist, true
  32133. }
  32134. // ResetLabelDist resets all changes to the "label_dist" field.
  32135. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  32136. m.label_dist = nil
  32137. m.appendlabel_dist = nil
  32138. }
  32139. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  32140. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  32141. m.predicates = append(m.predicates, ps...)
  32142. }
  32143. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  32144. // users can use type-assertion to append predicates that do not depend on any generated package.
  32145. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  32146. p := make([]predicate.UsageStatisticMonth, len(ps))
  32147. for i := range ps {
  32148. p[i] = ps[i]
  32149. }
  32150. m.Where(p...)
  32151. }
  32152. // Op returns the operation name.
  32153. func (m *UsageStatisticMonthMutation) Op() Op {
  32154. return m.op
  32155. }
  32156. // SetOp allows setting the mutation operation.
  32157. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  32158. m.op = op
  32159. }
  32160. // Type returns the node type of this mutation (UsageStatisticMonth).
  32161. func (m *UsageStatisticMonthMutation) Type() string {
  32162. return m.typ
  32163. }
  32164. // Fields returns all fields that were changed during this mutation. Note that in
  32165. // order to get all numeric fields that were incremented/decremented, call
  32166. // AddedFields().
  32167. func (m *UsageStatisticMonthMutation) Fields() []string {
  32168. fields := make([]string, 0, 17)
  32169. if m.created_at != nil {
  32170. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  32171. }
  32172. if m.updated_at != nil {
  32173. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  32174. }
  32175. if m.status != nil {
  32176. fields = append(fields, usagestatisticmonth.FieldStatus)
  32177. }
  32178. if m.deleted_at != nil {
  32179. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32180. }
  32181. if m.addtime != nil {
  32182. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32183. }
  32184. if m._type != nil {
  32185. fields = append(fields, usagestatisticmonth.FieldType)
  32186. }
  32187. if m.bot_id != nil {
  32188. fields = append(fields, usagestatisticmonth.FieldBotID)
  32189. }
  32190. if m.organization_id != nil {
  32191. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32192. }
  32193. if m.ai_response != nil {
  32194. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32195. }
  32196. if m.sop_run != nil {
  32197. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32198. }
  32199. if m.total_friend != nil {
  32200. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32201. }
  32202. if m.total_group != nil {
  32203. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32204. }
  32205. if m.account_balance != nil {
  32206. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32207. }
  32208. if m.consume_token != nil {
  32209. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32210. }
  32211. if m.active_user != nil {
  32212. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32213. }
  32214. if m.new_user != nil {
  32215. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32216. }
  32217. if m.label_dist != nil {
  32218. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  32219. }
  32220. return fields
  32221. }
  32222. // Field returns the value of a field with the given name. The second boolean
  32223. // return value indicates that this field was not set, or was not defined in the
  32224. // schema.
  32225. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  32226. switch name {
  32227. case usagestatisticmonth.FieldCreatedAt:
  32228. return m.CreatedAt()
  32229. case usagestatisticmonth.FieldUpdatedAt:
  32230. return m.UpdatedAt()
  32231. case usagestatisticmonth.FieldStatus:
  32232. return m.Status()
  32233. case usagestatisticmonth.FieldDeletedAt:
  32234. return m.DeletedAt()
  32235. case usagestatisticmonth.FieldAddtime:
  32236. return m.Addtime()
  32237. case usagestatisticmonth.FieldType:
  32238. return m.GetType()
  32239. case usagestatisticmonth.FieldBotID:
  32240. return m.BotID()
  32241. case usagestatisticmonth.FieldOrganizationID:
  32242. return m.OrganizationID()
  32243. case usagestatisticmonth.FieldAiResponse:
  32244. return m.AiResponse()
  32245. case usagestatisticmonth.FieldSopRun:
  32246. return m.SopRun()
  32247. case usagestatisticmonth.FieldTotalFriend:
  32248. return m.TotalFriend()
  32249. case usagestatisticmonth.FieldTotalGroup:
  32250. return m.TotalGroup()
  32251. case usagestatisticmonth.FieldAccountBalance:
  32252. return m.AccountBalance()
  32253. case usagestatisticmonth.FieldConsumeToken:
  32254. return m.ConsumeToken()
  32255. case usagestatisticmonth.FieldActiveUser:
  32256. return m.ActiveUser()
  32257. case usagestatisticmonth.FieldNewUser:
  32258. return m.NewUser()
  32259. case usagestatisticmonth.FieldLabelDist:
  32260. return m.LabelDist()
  32261. }
  32262. return nil, false
  32263. }
  32264. // OldField returns the old value of the field from the database. An error is
  32265. // returned if the mutation operation is not UpdateOne, or the query to the
  32266. // database failed.
  32267. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32268. switch name {
  32269. case usagestatisticmonth.FieldCreatedAt:
  32270. return m.OldCreatedAt(ctx)
  32271. case usagestatisticmonth.FieldUpdatedAt:
  32272. return m.OldUpdatedAt(ctx)
  32273. case usagestatisticmonth.FieldStatus:
  32274. return m.OldStatus(ctx)
  32275. case usagestatisticmonth.FieldDeletedAt:
  32276. return m.OldDeletedAt(ctx)
  32277. case usagestatisticmonth.FieldAddtime:
  32278. return m.OldAddtime(ctx)
  32279. case usagestatisticmonth.FieldType:
  32280. return m.OldType(ctx)
  32281. case usagestatisticmonth.FieldBotID:
  32282. return m.OldBotID(ctx)
  32283. case usagestatisticmonth.FieldOrganizationID:
  32284. return m.OldOrganizationID(ctx)
  32285. case usagestatisticmonth.FieldAiResponse:
  32286. return m.OldAiResponse(ctx)
  32287. case usagestatisticmonth.FieldSopRun:
  32288. return m.OldSopRun(ctx)
  32289. case usagestatisticmonth.FieldTotalFriend:
  32290. return m.OldTotalFriend(ctx)
  32291. case usagestatisticmonth.FieldTotalGroup:
  32292. return m.OldTotalGroup(ctx)
  32293. case usagestatisticmonth.FieldAccountBalance:
  32294. return m.OldAccountBalance(ctx)
  32295. case usagestatisticmonth.FieldConsumeToken:
  32296. return m.OldConsumeToken(ctx)
  32297. case usagestatisticmonth.FieldActiveUser:
  32298. return m.OldActiveUser(ctx)
  32299. case usagestatisticmonth.FieldNewUser:
  32300. return m.OldNewUser(ctx)
  32301. case usagestatisticmonth.FieldLabelDist:
  32302. return m.OldLabelDist(ctx)
  32303. }
  32304. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32305. }
  32306. // SetField sets the value of a field with the given name. It returns an error if
  32307. // the field is not defined in the schema, or if the type mismatched the field
  32308. // type.
  32309. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  32310. switch name {
  32311. case usagestatisticmonth.FieldCreatedAt:
  32312. v, ok := value.(time.Time)
  32313. if !ok {
  32314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32315. }
  32316. m.SetCreatedAt(v)
  32317. return nil
  32318. case usagestatisticmonth.FieldUpdatedAt:
  32319. v, ok := value.(time.Time)
  32320. if !ok {
  32321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32322. }
  32323. m.SetUpdatedAt(v)
  32324. return nil
  32325. case usagestatisticmonth.FieldStatus:
  32326. v, ok := value.(uint8)
  32327. if !ok {
  32328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32329. }
  32330. m.SetStatus(v)
  32331. return nil
  32332. case usagestatisticmonth.FieldDeletedAt:
  32333. v, ok := value.(time.Time)
  32334. if !ok {
  32335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32336. }
  32337. m.SetDeletedAt(v)
  32338. return nil
  32339. case usagestatisticmonth.FieldAddtime:
  32340. v, ok := value.(uint64)
  32341. if !ok {
  32342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32343. }
  32344. m.SetAddtime(v)
  32345. return nil
  32346. case usagestatisticmonth.FieldType:
  32347. v, ok := value.(int)
  32348. if !ok {
  32349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32350. }
  32351. m.SetType(v)
  32352. return nil
  32353. case usagestatisticmonth.FieldBotID:
  32354. v, ok := value.(string)
  32355. if !ok {
  32356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32357. }
  32358. m.SetBotID(v)
  32359. return nil
  32360. case usagestatisticmonth.FieldOrganizationID:
  32361. v, ok := value.(uint64)
  32362. if !ok {
  32363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32364. }
  32365. m.SetOrganizationID(v)
  32366. return nil
  32367. case usagestatisticmonth.FieldAiResponse:
  32368. v, ok := value.(uint64)
  32369. if !ok {
  32370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32371. }
  32372. m.SetAiResponse(v)
  32373. return nil
  32374. case usagestatisticmonth.FieldSopRun:
  32375. v, ok := value.(uint64)
  32376. if !ok {
  32377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32378. }
  32379. m.SetSopRun(v)
  32380. return nil
  32381. case usagestatisticmonth.FieldTotalFriend:
  32382. v, ok := value.(uint64)
  32383. if !ok {
  32384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32385. }
  32386. m.SetTotalFriend(v)
  32387. return nil
  32388. case usagestatisticmonth.FieldTotalGroup:
  32389. v, ok := value.(uint64)
  32390. if !ok {
  32391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32392. }
  32393. m.SetTotalGroup(v)
  32394. return nil
  32395. case usagestatisticmonth.FieldAccountBalance:
  32396. v, ok := value.(uint64)
  32397. if !ok {
  32398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32399. }
  32400. m.SetAccountBalance(v)
  32401. return nil
  32402. case usagestatisticmonth.FieldConsumeToken:
  32403. v, ok := value.(uint64)
  32404. if !ok {
  32405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32406. }
  32407. m.SetConsumeToken(v)
  32408. return nil
  32409. case usagestatisticmonth.FieldActiveUser:
  32410. v, ok := value.(uint64)
  32411. if !ok {
  32412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32413. }
  32414. m.SetActiveUser(v)
  32415. return nil
  32416. case usagestatisticmonth.FieldNewUser:
  32417. v, ok := value.(int64)
  32418. if !ok {
  32419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32420. }
  32421. m.SetNewUser(v)
  32422. return nil
  32423. case usagestatisticmonth.FieldLabelDist:
  32424. v, ok := value.([]custom_types.LabelDist)
  32425. if !ok {
  32426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32427. }
  32428. m.SetLabelDist(v)
  32429. return nil
  32430. }
  32431. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32432. }
  32433. // AddedFields returns all numeric fields that were incremented/decremented during
  32434. // this mutation.
  32435. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  32436. var fields []string
  32437. if m.addstatus != nil {
  32438. fields = append(fields, usagestatisticmonth.FieldStatus)
  32439. }
  32440. if m.addaddtime != nil {
  32441. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32442. }
  32443. if m.add_type != nil {
  32444. fields = append(fields, usagestatisticmonth.FieldType)
  32445. }
  32446. if m.addorganization_id != nil {
  32447. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32448. }
  32449. if m.addai_response != nil {
  32450. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32451. }
  32452. if m.addsop_run != nil {
  32453. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32454. }
  32455. if m.addtotal_friend != nil {
  32456. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32457. }
  32458. if m.addtotal_group != nil {
  32459. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32460. }
  32461. if m.addaccount_balance != nil {
  32462. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32463. }
  32464. if m.addconsume_token != nil {
  32465. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32466. }
  32467. if m.addactive_user != nil {
  32468. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32469. }
  32470. if m.addnew_user != nil {
  32471. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32472. }
  32473. return fields
  32474. }
  32475. // AddedField returns the numeric value that was incremented/decremented on a field
  32476. // with the given name. The second boolean return value indicates that this field
  32477. // was not set, or was not defined in the schema.
  32478. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  32479. switch name {
  32480. case usagestatisticmonth.FieldStatus:
  32481. return m.AddedStatus()
  32482. case usagestatisticmonth.FieldAddtime:
  32483. return m.AddedAddtime()
  32484. case usagestatisticmonth.FieldType:
  32485. return m.AddedType()
  32486. case usagestatisticmonth.FieldOrganizationID:
  32487. return m.AddedOrganizationID()
  32488. case usagestatisticmonth.FieldAiResponse:
  32489. return m.AddedAiResponse()
  32490. case usagestatisticmonth.FieldSopRun:
  32491. return m.AddedSopRun()
  32492. case usagestatisticmonth.FieldTotalFriend:
  32493. return m.AddedTotalFriend()
  32494. case usagestatisticmonth.FieldTotalGroup:
  32495. return m.AddedTotalGroup()
  32496. case usagestatisticmonth.FieldAccountBalance:
  32497. return m.AddedAccountBalance()
  32498. case usagestatisticmonth.FieldConsumeToken:
  32499. return m.AddedConsumeToken()
  32500. case usagestatisticmonth.FieldActiveUser:
  32501. return m.AddedActiveUser()
  32502. case usagestatisticmonth.FieldNewUser:
  32503. return m.AddedNewUser()
  32504. }
  32505. return nil, false
  32506. }
  32507. // AddField adds the value to the field with the given name. It returns an error if
  32508. // the field is not defined in the schema, or if the type mismatched the field
  32509. // type.
  32510. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  32511. switch name {
  32512. case usagestatisticmonth.FieldStatus:
  32513. v, ok := value.(int8)
  32514. if !ok {
  32515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32516. }
  32517. m.AddStatus(v)
  32518. return nil
  32519. case usagestatisticmonth.FieldAddtime:
  32520. v, ok := value.(int64)
  32521. if !ok {
  32522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32523. }
  32524. m.AddAddtime(v)
  32525. return nil
  32526. case usagestatisticmonth.FieldType:
  32527. v, ok := value.(int)
  32528. if !ok {
  32529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32530. }
  32531. m.AddType(v)
  32532. return nil
  32533. case usagestatisticmonth.FieldOrganizationID:
  32534. v, ok := value.(int64)
  32535. if !ok {
  32536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32537. }
  32538. m.AddOrganizationID(v)
  32539. return nil
  32540. case usagestatisticmonth.FieldAiResponse:
  32541. v, ok := value.(int64)
  32542. if !ok {
  32543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32544. }
  32545. m.AddAiResponse(v)
  32546. return nil
  32547. case usagestatisticmonth.FieldSopRun:
  32548. v, ok := value.(int64)
  32549. if !ok {
  32550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32551. }
  32552. m.AddSopRun(v)
  32553. return nil
  32554. case usagestatisticmonth.FieldTotalFriend:
  32555. v, ok := value.(int64)
  32556. if !ok {
  32557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32558. }
  32559. m.AddTotalFriend(v)
  32560. return nil
  32561. case usagestatisticmonth.FieldTotalGroup:
  32562. v, ok := value.(int64)
  32563. if !ok {
  32564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32565. }
  32566. m.AddTotalGroup(v)
  32567. return nil
  32568. case usagestatisticmonth.FieldAccountBalance:
  32569. v, ok := value.(int64)
  32570. if !ok {
  32571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32572. }
  32573. m.AddAccountBalance(v)
  32574. return nil
  32575. case usagestatisticmonth.FieldConsumeToken:
  32576. v, ok := value.(int64)
  32577. if !ok {
  32578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32579. }
  32580. m.AddConsumeToken(v)
  32581. return nil
  32582. case usagestatisticmonth.FieldActiveUser:
  32583. v, ok := value.(int64)
  32584. if !ok {
  32585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32586. }
  32587. m.AddActiveUser(v)
  32588. return nil
  32589. case usagestatisticmonth.FieldNewUser:
  32590. v, ok := value.(int64)
  32591. if !ok {
  32592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32593. }
  32594. m.AddNewUser(v)
  32595. return nil
  32596. }
  32597. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  32598. }
  32599. // ClearedFields returns all nullable fields that were cleared during this
  32600. // mutation.
  32601. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  32602. var fields []string
  32603. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  32604. fields = append(fields, usagestatisticmonth.FieldStatus)
  32605. }
  32606. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  32607. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32608. }
  32609. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  32610. fields = append(fields, usagestatisticmonth.FieldBotID)
  32611. }
  32612. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  32613. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32614. }
  32615. return fields
  32616. }
  32617. // FieldCleared returns a boolean indicating if a field with the given name was
  32618. // cleared in this mutation.
  32619. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  32620. _, ok := m.clearedFields[name]
  32621. return ok
  32622. }
  32623. // ClearField clears the value of the field with the given name. It returns an
  32624. // error if the field is not defined in the schema.
  32625. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  32626. switch name {
  32627. case usagestatisticmonth.FieldStatus:
  32628. m.ClearStatus()
  32629. return nil
  32630. case usagestatisticmonth.FieldDeletedAt:
  32631. m.ClearDeletedAt()
  32632. return nil
  32633. case usagestatisticmonth.FieldBotID:
  32634. m.ClearBotID()
  32635. return nil
  32636. case usagestatisticmonth.FieldOrganizationID:
  32637. m.ClearOrganizationID()
  32638. return nil
  32639. }
  32640. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  32641. }
  32642. // ResetField resets all changes in the mutation for the field with the given name.
  32643. // It returns an error if the field is not defined in the schema.
  32644. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  32645. switch name {
  32646. case usagestatisticmonth.FieldCreatedAt:
  32647. m.ResetCreatedAt()
  32648. return nil
  32649. case usagestatisticmonth.FieldUpdatedAt:
  32650. m.ResetUpdatedAt()
  32651. return nil
  32652. case usagestatisticmonth.FieldStatus:
  32653. m.ResetStatus()
  32654. return nil
  32655. case usagestatisticmonth.FieldDeletedAt:
  32656. m.ResetDeletedAt()
  32657. return nil
  32658. case usagestatisticmonth.FieldAddtime:
  32659. m.ResetAddtime()
  32660. return nil
  32661. case usagestatisticmonth.FieldType:
  32662. m.ResetType()
  32663. return nil
  32664. case usagestatisticmonth.FieldBotID:
  32665. m.ResetBotID()
  32666. return nil
  32667. case usagestatisticmonth.FieldOrganizationID:
  32668. m.ResetOrganizationID()
  32669. return nil
  32670. case usagestatisticmonth.FieldAiResponse:
  32671. m.ResetAiResponse()
  32672. return nil
  32673. case usagestatisticmonth.FieldSopRun:
  32674. m.ResetSopRun()
  32675. return nil
  32676. case usagestatisticmonth.FieldTotalFriend:
  32677. m.ResetTotalFriend()
  32678. return nil
  32679. case usagestatisticmonth.FieldTotalGroup:
  32680. m.ResetTotalGroup()
  32681. return nil
  32682. case usagestatisticmonth.FieldAccountBalance:
  32683. m.ResetAccountBalance()
  32684. return nil
  32685. case usagestatisticmonth.FieldConsumeToken:
  32686. m.ResetConsumeToken()
  32687. return nil
  32688. case usagestatisticmonth.FieldActiveUser:
  32689. m.ResetActiveUser()
  32690. return nil
  32691. case usagestatisticmonth.FieldNewUser:
  32692. m.ResetNewUser()
  32693. return nil
  32694. case usagestatisticmonth.FieldLabelDist:
  32695. m.ResetLabelDist()
  32696. return nil
  32697. }
  32698. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32699. }
  32700. // AddedEdges returns all edge names that were set/added in this mutation.
  32701. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  32702. edges := make([]string, 0, 0)
  32703. return edges
  32704. }
  32705. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32706. // name in this mutation.
  32707. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  32708. return nil
  32709. }
  32710. // RemovedEdges returns all edge names that were removed in this mutation.
  32711. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  32712. edges := make([]string, 0, 0)
  32713. return edges
  32714. }
  32715. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32716. // the given name in this mutation.
  32717. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  32718. return nil
  32719. }
  32720. // ClearedEdges returns all edge names that were cleared in this mutation.
  32721. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  32722. edges := make([]string, 0, 0)
  32723. return edges
  32724. }
  32725. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32726. // was cleared in this mutation.
  32727. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  32728. return false
  32729. }
  32730. // ClearEdge clears the value of the edge with the given name. It returns an error
  32731. // if that edge is not defined in the schema.
  32732. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  32733. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  32734. }
  32735. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32736. // It returns an error if the edge is not defined in the schema.
  32737. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  32738. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  32739. }
  32740. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  32741. type UsageTotalMutation struct {
  32742. config
  32743. op Op
  32744. typ string
  32745. id *uint64
  32746. created_at *time.Time
  32747. updated_at *time.Time
  32748. status *uint8
  32749. addstatus *int8
  32750. _type *int
  32751. add_type *int
  32752. bot_id *string
  32753. total_tokens *uint64
  32754. addtotal_tokens *int64
  32755. start_index *uint64
  32756. addstart_index *int64
  32757. end_index *uint64
  32758. addend_index *int64
  32759. organization_id *uint64
  32760. addorganization_id *int64
  32761. clearedFields map[string]struct{}
  32762. done bool
  32763. oldValue func(context.Context) (*UsageTotal, error)
  32764. predicates []predicate.UsageTotal
  32765. }
  32766. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  32767. // usagetotalOption allows management of the mutation configuration using functional options.
  32768. type usagetotalOption func(*UsageTotalMutation)
  32769. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  32770. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  32771. m := &UsageTotalMutation{
  32772. config: c,
  32773. op: op,
  32774. typ: TypeUsageTotal,
  32775. clearedFields: make(map[string]struct{}),
  32776. }
  32777. for _, opt := range opts {
  32778. opt(m)
  32779. }
  32780. return m
  32781. }
  32782. // withUsageTotalID sets the ID field of the mutation.
  32783. func withUsageTotalID(id uint64) usagetotalOption {
  32784. return func(m *UsageTotalMutation) {
  32785. var (
  32786. err error
  32787. once sync.Once
  32788. value *UsageTotal
  32789. )
  32790. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  32791. once.Do(func() {
  32792. if m.done {
  32793. err = errors.New("querying old values post mutation is not allowed")
  32794. } else {
  32795. value, err = m.Client().UsageTotal.Get(ctx, id)
  32796. }
  32797. })
  32798. return value, err
  32799. }
  32800. m.id = &id
  32801. }
  32802. }
  32803. // withUsageTotal sets the old UsageTotal of the mutation.
  32804. func withUsageTotal(node *UsageTotal) usagetotalOption {
  32805. return func(m *UsageTotalMutation) {
  32806. m.oldValue = func(context.Context) (*UsageTotal, error) {
  32807. return node, nil
  32808. }
  32809. m.id = &node.ID
  32810. }
  32811. }
  32812. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32813. // executed in a transaction (ent.Tx), a transactional client is returned.
  32814. func (m UsageTotalMutation) Client() *Client {
  32815. client := &Client{config: m.config}
  32816. client.init()
  32817. return client
  32818. }
  32819. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32820. // it returns an error otherwise.
  32821. func (m UsageTotalMutation) Tx() (*Tx, error) {
  32822. if _, ok := m.driver.(*txDriver); !ok {
  32823. return nil, errors.New("ent: mutation is not running in a transaction")
  32824. }
  32825. tx := &Tx{config: m.config}
  32826. tx.init()
  32827. return tx, nil
  32828. }
  32829. // SetID sets the value of the id field. Note that this
  32830. // operation is only accepted on creation of UsageTotal entities.
  32831. func (m *UsageTotalMutation) SetID(id uint64) {
  32832. m.id = &id
  32833. }
  32834. // ID returns the ID value in the mutation. Note that the ID is only available
  32835. // if it was provided to the builder or after it was returned from the database.
  32836. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  32837. if m.id == nil {
  32838. return
  32839. }
  32840. return *m.id, true
  32841. }
  32842. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32843. // That means, if the mutation is applied within a transaction with an isolation level such
  32844. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32845. // or updated by the mutation.
  32846. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  32847. switch {
  32848. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32849. id, exists := m.ID()
  32850. if exists {
  32851. return []uint64{id}, nil
  32852. }
  32853. fallthrough
  32854. case m.op.Is(OpUpdate | OpDelete):
  32855. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  32856. default:
  32857. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32858. }
  32859. }
  32860. // SetCreatedAt sets the "created_at" field.
  32861. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  32862. m.created_at = &t
  32863. }
  32864. // CreatedAt returns the value of the "created_at" field in the mutation.
  32865. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  32866. v := m.created_at
  32867. if v == nil {
  32868. return
  32869. }
  32870. return *v, true
  32871. }
  32872. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  32873. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32875. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32876. if !m.op.Is(OpUpdateOne) {
  32877. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32878. }
  32879. if m.id == nil || m.oldValue == nil {
  32880. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32881. }
  32882. oldValue, err := m.oldValue(ctx)
  32883. if err != nil {
  32884. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32885. }
  32886. return oldValue.CreatedAt, nil
  32887. }
  32888. // ResetCreatedAt resets all changes to the "created_at" field.
  32889. func (m *UsageTotalMutation) ResetCreatedAt() {
  32890. m.created_at = nil
  32891. }
  32892. // SetUpdatedAt sets the "updated_at" field.
  32893. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  32894. m.updated_at = &t
  32895. }
  32896. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32897. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  32898. v := m.updated_at
  32899. if v == nil {
  32900. return
  32901. }
  32902. return *v, true
  32903. }
  32904. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  32905. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32907. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32908. if !m.op.Is(OpUpdateOne) {
  32909. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32910. }
  32911. if m.id == nil || m.oldValue == nil {
  32912. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32913. }
  32914. oldValue, err := m.oldValue(ctx)
  32915. if err != nil {
  32916. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32917. }
  32918. return oldValue.UpdatedAt, nil
  32919. }
  32920. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32921. func (m *UsageTotalMutation) ResetUpdatedAt() {
  32922. m.updated_at = nil
  32923. }
  32924. // SetStatus sets the "status" field.
  32925. func (m *UsageTotalMutation) SetStatus(u uint8) {
  32926. m.status = &u
  32927. m.addstatus = nil
  32928. }
  32929. // Status returns the value of the "status" field in the mutation.
  32930. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  32931. v := m.status
  32932. if v == nil {
  32933. return
  32934. }
  32935. return *v, true
  32936. }
  32937. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  32938. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32940. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32941. if !m.op.Is(OpUpdateOne) {
  32942. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32943. }
  32944. if m.id == nil || m.oldValue == nil {
  32945. return v, errors.New("OldStatus requires an ID field in the mutation")
  32946. }
  32947. oldValue, err := m.oldValue(ctx)
  32948. if err != nil {
  32949. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32950. }
  32951. return oldValue.Status, nil
  32952. }
  32953. // AddStatus adds u to the "status" field.
  32954. func (m *UsageTotalMutation) AddStatus(u int8) {
  32955. if m.addstatus != nil {
  32956. *m.addstatus += u
  32957. } else {
  32958. m.addstatus = &u
  32959. }
  32960. }
  32961. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32962. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  32963. v := m.addstatus
  32964. if v == nil {
  32965. return
  32966. }
  32967. return *v, true
  32968. }
  32969. // ClearStatus clears the value of the "status" field.
  32970. func (m *UsageTotalMutation) ClearStatus() {
  32971. m.status = nil
  32972. m.addstatus = nil
  32973. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  32974. }
  32975. // StatusCleared returns if the "status" field was cleared in this mutation.
  32976. func (m *UsageTotalMutation) StatusCleared() bool {
  32977. _, ok := m.clearedFields[usagetotal.FieldStatus]
  32978. return ok
  32979. }
  32980. // ResetStatus resets all changes to the "status" field.
  32981. func (m *UsageTotalMutation) ResetStatus() {
  32982. m.status = nil
  32983. m.addstatus = nil
  32984. delete(m.clearedFields, usagetotal.FieldStatus)
  32985. }
  32986. // SetType sets the "type" field.
  32987. func (m *UsageTotalMutation) SetType(i int) {
  32988. m._type = &i
  32989. m.add_type = nil
  32990. }
  32991. // GetType returns the value of the "type" field in the mutation.
  32992. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  32993. v := m._type
  32994. if v == nil {
  32995. return
  32996. }
  32997. return *v, true
  32998. }
  32999. // OldType returns the old "type" field's value of the UsageTotal entity.
  33000. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33002. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  33003. if !m.op.Is(OpUpdateOne) {
  33004. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33005. }
  33006. if m.id == nil || m.oldValue == nil {
  33007. return v, errors.New("OldType requires an ID field in the mutation")
  33008. }
  33009. oldValue, err := m.oldValue(ctx)
  33010. if err != nil {
  33011. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33012. }
  33013. return oldValue.Type, nil
  33014. }
  33015. // AddType adds i to the "type" field.
  33016. func (m *UsageTotalMutation) AddType(i int) {
  33017. if m.add_type != nil {
  33018. *m.add_type += i
  33019. } else {
  33020. m.add_type = &i
  33021. }
  33022. }
  33023. // AddedType returns the value that was added to the "type" field in this mutation.
  33024. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  33025. v := m.add_type
  33026. if v == nil {
  33027. return
  33028. }
  33029. return *v, true
  33030. }
  33031. // ClearType clears the value of the "type" field.
  33032. func (m *UsageTotalMutation) ClearType() {
  33033. m._type = nil
  33034. m.add_type = nil
  33035. m.clearedFields[usagetotal.FieldType] = struct{}{}
  33036. }
  33037. // TypeCleared returns if the "type" field was cleared in this mutation.
  33038. func (m *UsageTotalMutation) TypeCleared() bool {
  33039. _, ok := m.clearedFields[usagetotal.FieldType]
  33040. return ok
  33041. }
  33042. // ResetType resets all changes to the "type" field.
  33043. func (m *UsageTotalMutation) ResetType() {
  33044. m._type = nil
  33045. m.add_type = nil
  33046. delete(m.clearedFields, usagetotal.FieldType)
  33047. }
  33048. // SetBotID sets the "bot_id" field.
  33049. func (m *UsageTotalMutation) SetBotID(s string) {
  33050. m.bot_id = &s
  33051. }
  33052. // BotID returns the value of the "bot_id" field in the mutation.
  33053. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  33054. v := m.bot_id
  33055. if v == nil {
  33056. return
  33057. }
  33058. return *v, true
  33059. }
  33060. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  33061. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33063. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  33064. if !m.op.Is(OpUpdateOne) {
  33065. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33066. }
  33067. if m.id == nil || m.oldValue == nil {
  33068. return v, errors.New("OldBotID requires an ID field in the mutation")
  33069. }
  33070. oldValue, err := m.oldValue(ctx)
  33071. if err != nil {
  33072. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33073. }
  33074. return oldValue.BotID, nil
  33075. }
  33076. // ResetBotID resets all changes to the "bot_id" field.
  33077. func (m *UsageTotalMutation) ResetBotID() {
  33078. m.bot_id = nil
  33079. }
  33080. // SetTotalTokens sets the "total_tokens" field.
  33081. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  33082. m.total_tokens = &u
  33083. m.addtotal_tokens = nil
  33084. }
  33085. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  33086. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  33087. v := m.total_tokens
  33088. if v == nil {
  33089. return
  33090. }
  33091. return *v, true
  33092. }
  33093. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  33094. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33096. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  33097. if !m.op.Is(OpUpdateOne) {
  33098. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  33099. }
  33100. if m.id == nil || m.oldValue == nil {
  33101. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  33102. }
  33103. oldValue, err := m.oldValue(ctx)
  33104. if err != nil {
  33105. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  33106. }
  33107. return oldValue.TotalTokens, nil
  33108. }
  33109. // AddTotalTokens adds u to the "total_tokens" field.
  33110. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  33111. if m.addtotal_tokens != nil {
  33112. *m.addtotal_tokens += u
  33113. } else {
  33114. m.addtotal_tokens = &u
  33115. }
  33116. }
  33117. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  33118. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  33119. v := m.addtotal_tokens
  33120. if v == nil {
  33121. return
  33122. }
  33123. return *v, true
  33124. }
  33125. // ClearTotalTokens clears the value of the "total_tokens" field.
  33126. func (m *UsageTotalMutation) ClearTotalTokens() {
  33127. m.total_tokens = nil
  33128. m.addtotal_tokens = nil
  33129. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  33130. }
  33131. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33132. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  33133. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  33134. return ok
  33135. }
  33136. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33137. func (m *UsageTotalMutation) ResetTotalTokens() {
  33138. m.total_tokens = nil
  33139. m.addtotal_tokens = nil
  33140. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  33141. }
  33142. // SetStartIndex sets the "start_index" field.
  33143. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  33144. m.start_index = &u
  33145. m.addstart_index = nil
  33146. }
  33147. // StartIndex returns the value of the "start_index" field in the mutation.
  33148. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  33149. v := m.start_index
  33150. if v == nil {
  33151. return
  33152. }
  33153. return *v, true
  33154. }
  33155. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  33156. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33158. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  33159. if !m.op.Is(OpUpdateOne) {
  33160. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  33161. }
  33162. if m.id == nil || m.oldValue == nil {
  33163. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  33164. }
  33165. oldValue, err := m.oldValue(ctx)
  33166. if err != nil {
  33167. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  33168. }
  33169. return oldValue.StartIndex, nil
  33170. }
  33171. // AddStartIndex adds u to the "start_index" field.
  33172. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  33173. if m.addstart_index != nil {
  33174. *m.addstart_index += u
  33175. } else {
  33176. m.addstart_index = &u
  33177. }
  33178. }
  33179. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  33180. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  33181. v := m.addstart_index
  33182. if v == nil {
  33183. return
  33184. }
  33185. return *v, true
  33186. }
  33187. // ClearStartIndex clears the value of the "start_index" field.
  33188. func (m *UsageTotalMutation) ClearStartIndex() {
  33189. m.start_index = nil
  33190. m.addstart_index = nil
  33191. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  33192. }
  33193. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  33194. func (m *UsageTotalMutation) StartIndexCleared() bool {
  33195. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  33196. return ok
  33197. }
  33198. // ResetStartIndex resets all changes to the "start_index" field.
  33199. func (m *UsageTotalMutation) ResetStartIndex() {
  33200. m.start_index = nil
  33201. m.addstart_index = nil
  33202. delete(m.clearedFields, usagetotal.FieldStartIndex)
  33203. }
  33204. // SetEndIndex sets the "end_index" field.
  33205. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  33206. m.end_index = &u
  33207. m.addend_index = nil
  33208. }
  33209. // EndIndex returns the value of the "end_index" field in the mutation.
  33210. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  33211. v := m.end_index
  33212. if v == nil {
  33213. return
  33214. }
  33215. return *v, true
  33216. }
  33217. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  33218. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33220. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  33221. if !m.op.Is(OpUpdateOne) {
  33222. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  33223. }
  33224. if m.id == nil || m.oldValue == nil {
  33225. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  33226. }
  33227. oldValue, err := m.oldValue(ctx)
  33228. if err != nil {
  33229. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  33230. }
  33231. return oldValue.EndIndex, nil
  33232. }
  33233. // AddEndIndex adds u to the "end_index" field.
  33234. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  33235. if m.addend_index != nil {
  33236. *m.addend_index += u
  33237. } else {
  33238. m.addend_index = &u
  33239. }
  33240. }
  33241. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  33242. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  33243. v := m.addend_index
  33244. if v == nil {
  33245. return
  33246. }
  33247. return *v, true
  33248. }
  33249. // ClearEndIndex clears the value of the "end_index" field.
  33250. func (m *UsageTotalMutation) ClearEndIndex() {
  33251. m.end_index = nil
  33252. m.addend_index = nil
  33253. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  33254. }
  33255. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  33256. func (m *UsageTotalMutation) EndIndexCleared() bool {
  33257. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  33258. return ok
  33259. }
  33260. // ResetEndIndex resets all changes to the "end_index" field.
  33261. func (m *UsageTotalMutation) ResetEndIndex() {
  33262. m.end_index = nil
  33263. m.addend_index = nil
  33264. delete(m.clearedFields, usagetotal.FieldEndIndex)
  33265. }
  33266. // SetOrganizationID sets the "organization_id" field.
  33267. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  33268. m.organization_id = &u
  33269. m.addorganization_id = nil
  33270. }
  33271. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33272. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  33273. v := m.organization_id
  33274. if v == nil {
  33275. return
  33276. }
  33277. return *v, true
  33278. }
  33279. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  33280. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33282. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33283. if !m.op.Is(OpUpdateOne) {
  33284. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33285. }
  33286. if m.id == nil || m.oldValue == nil {
  33287. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33288. }
  33289. oldValue, err := m.oldValue(ctx)
  33290. if err != nil {
  33291. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33292. }
  33293. return oldValue.OrganizationID, nil
  33294. }
  33295. // AddOrganizationID adds u to the "organization_id" field.
  33296. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  33297. if m.addorganization_id != nil {
  33298. *m.addorganization_id += u
  33299. } else {
  33300. m.addorganization_id = &u
  33301. }
  33302. }
  33303. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33304. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  33305. v := m.addorganization_id
  33306. if v == nil {
  33307. return
  33308. }
  33309. return *v, true
  33310. }
  33311. // ClearOrganizationID clears the value of the "organization_id" field.
  33312. func (m *UsageTotalMutation) ClearOrganizationID() {
  33313. m.organization_id = nil
  33314. m.addorganization_id = nil
  33315. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  33316. }
  33317. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33318. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  33319. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  33320. return ok
  33321. }
  33322. // ResetOrganizationID resets all changes to the "organization_id" field.
  33323. func (m *UsageTotalMutation) ResetOrganizationID() {
  33324. m.organization_id = nil
  33325. m.addorganization_id = nil
  33326. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  33327. }
  33328. // Where appends a list predicates to the UsageTotalMutation builder.
  33329. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  33330. m.predicates = append(m.predicates, ps...)
  33331. }
  33332. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  33333. // users can use type-assertion to append predicates that do not depend on any generated package.
  33334. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  33335. p := make([]predicate.UsageTotal, len(ps))
  33336. for i := range ps {
  33337. p[i] = ps[i]
  33338. }
  33339. m.Where(p...)
  33340. }
  33341. // Op returns the operation name.
  33342. func (m *UsageTotalMutation) Op() Op {
  33343. return m.op
  33344. }
  33345. // SetOp allows setting the mutation operation.
  33346. func (m *UsageTotalMutation) SetOp(op Op) {
  33347. m.op = op
  33348. }
  33349. // Type returns the node type of this mutation (UsageTotal).
  33350. func (m *UsageTotalMutation) Type() string {
  33351. return m.typ
  33352. }
  33353. // Fields returns all fields that were changed during this mutation. Note that in
  33354. // order to get all numeric fields that were incremented/decremented, call
  33355. // AddedFields().
  33356. func (m *UsageTotalMutation) Fields() []string {
  33357. fields := make([]string, 0, 9)
  33358. if m.created_at != nil {
  33359. fields = append(fields, usagetotal.FieldCreatedAt)
  33360. }
  33361. if m.updated_at != nil {
  33362. fields = append(fields, usagetotal.FieldUpdatedAt)
  33363. }
  33364. if m.status != nil {
  33365. fields = append(fields, usagetotal.FieldStatus)
  33366. }
  33367. if m._type != nil {
  33368. fields = append(fields, usagetotal.FieldType)
  33369. }
  33370. if m.bot_id != nil {
  33371. fields = append(fields, usagetotal.FieldBotID)
  33372. }
  33373. if m.total_tokens != nil {
  33374. fields = append(fields, usagetotal.FieldTotalTokens)
  33375. }
  33376. if m.start_index != nil {
  33377. fields = append(fields, usagetotal.FieldStartIndex)
  33378. }
  33379. if m.end_index != nil {
  33380. fields = append(fields, usagetotal.FieldEndIndex)
  33381. }
  33382. if m.organization_id != nil {
  33383. fields = append(fields, usagetotal.FieldOrganizationID)
  33384. }
  33385. return fields
  33386. }
  33387. // Field returns the value of a field with the given name. The second boolean
  33388. // return value indicates that this field was not set, or was not defined in the
  33389. // schema.
  33390. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  33391. switch name {
  33392. case usagetotal.FieldCreatedAt:
  33393. return m.CreatedAt()
  33394. case usagetotal.FieldUpdatedAt:
  33395. return m.UpdatedAt()
  33396. case usagetotal.FieldStatus:
  33397. return m.Status()
  33398. case usagetotal.FieldType:
  33399. return m.GetType()
  33400. case usagetotal.FieldBotID:
  33401. return m.BotID()
  33402. case usagetotal.FieldTotalTokens:
  33403. return m.TotalTokens()
  33404. case usagetotal.FieldStartIndex:
  33405. return m.StartIndex()
  33406. case usagetotal.FieldEndIndex:
  33407. return m.EndIndex()
  33408. case usagetotal.FieldOrganizationID:
  33409. return m.OrganizationID()
  33410. }
  33411. return nil, false
  33412. }
  33413. // OldField returns the old value of the field from the database. An error is
  33414. // returned if the mutation operation is not UpdateOne, or the query to the
  33415. // database failed.
  33416. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33417. switch name {
  33418. case usagetotal.FieldCreatedAt:
  33419. return m.OldCreatedAt(ctx)
  33420. case usagetotal.FieldUpdatedAt:
  33421. return m.OldUpdatedAt(ctx)
  33422. case usagetotal.FieldStatus:
  33423. return m.OldStatus(ctx)
  33424. case usagetotal.FieldType:
  33425. return m.OldType(ctx)
  33426. case usagetotal.FieldBotID:
  33427. return m.OldBotID(ctx)
  33428. case usagetotal.FieldTotalTokens:
  33429. return m.OldTotalTokens(ctx)
  33430. case usagetotal.FieldStartIndex:
  33431. return m.OldStartIndex(ctx)
  33432. case usagetotal.FieldEndIndex:
  33433. return m.OldEndIndex(ctx)
  33434. case usagetotal.FieldOrganizationID:
  33435. return m.OldOrganizationID(ctx)
  33436. }
  33437. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  33438. }
  33439. // SetField sets the value of a field with the given name. It returns an error if
  33440. // the field is not defined in the schema, or if the type mismatched the field
  33441. // type.
  33442. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  33443. switch name {
  33444. case usagetotal.FieldCreatedAt:
  33445. v, ok := value.(time.Time)
  33446. if !ok {
  33447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33448. }
  33449. m.SetCreatedAt(v)
  33450. return nil
  33451. case usagetotal.FieldUpdatedAt:
  33452. v, ok := value.(time.Time)
  33453. if !ok {
  33454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33455. }
  33456. m.SetUpdatedAt(v)
  33457. return nil
  33458. case usagetotal.FieldStatus:
  33459. v, ok := value.(uint8)
  33460. if !ok {
  33461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33462. }
  33463. m.SetStatus(v)
  33464. return nil
  33465. case usagetotal.FieldType:
  33466. v, ok := value.(int)
  33467. if !ok {
  33468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33469. }
  33470. m.SetType(v)
  33471. return nil
  33472. case usagetotal.FieldBotID:
  33473. v, ok := value.(string)
  33474. if !ok {
  33475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33476. }
  33477. m.SetBotID(v)
  33478. return nil
  33479. case usagetotal.FieldTotalTokens:
  33480. v, ok := value.(uint64)
  33481. if !ok {
  33482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33483. }
  33484. m.SetTotalTokens(v)
  33485. return nil
  33486. case usagetotal.FieldStartIndex:
  33487. v, ok := value.(uint64)
  33488. if !ok {
  33489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33490. }
  33491. m.SetStartIndex(v)
  33492. return nil
  33493. case usagetotal.FieldEndIndex:
  33494. v, ok := value.(uint64)
  33495. if !ok {
  33496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33497. }
  33498. m.SetEndIndex(v)
  33499. return nil
  33500. case usagetotal.FieldOrganizationID:
  33501. v, ok := value.(uint64)
  33502. if !ok {
  33503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33504. }
  33505. m.SetOrganizationID(v)
  33506. return nil
  33507. }
  33508. return fmt.Errorf("unknown UsageTotal field %s", name)
  33509. }
  33510. // AddedFields returns all numeric fields that were incremented/decremented during
  33511. // this mutation.
  33512. func (m *UsageTotalMutation) AddedFields() []string {
  33513. var fields []string
  33514. if m.addstatus != nil {
  33515. fields = append(fields, usagetotal.FieldStatus)
  33516. }
  33517. if m.add_type != nil {
  33518. fields = append(fields, usagetotal.FieldType)
  33519. }
  33520. if m.addtotal_tokens != nil {
  33521. fields = append(fields, usagetotal.FieldTotalTokens)
  33522. }
  33523. if m.addstart_index != nil {
  33524. fields = append(fields, usagetotal.FieldStartIndex)
  33525. }
  33526. if m.addend_index != nil {
  33527. fields = append(fields, usagetotal.FieldEndIndex)
  33528. }
  33529. if m.addorganization_id != nil {
  33530. fields = append(fields, usagetotal.FieldOrganizationID)
  33531. }
  33532. return fields
  33533. }
  33534. // AddedField returns the numeric value that was incremented/decremented on a field
  33535. // with the given name. The second boolean return value indicates that this field
  33536. // was not set, or was not defined in the schema.
  33537. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  33538. switch name {
  33539. case usagetotal.FieldStatus:
  33540. return m.AddedStatus()
  33541. case usagetotal.FieldType:
  33542. return m.AddedType()
  33543. case usagetotal.FieldTotalTokens:
  33544. return m.AddedTotalTokens()
  33545. case usagetotal.FieldStartIndex:
  33546. return m.AddedStartIndex()
  33547. case usagetotal.FieldEndIndex:
  33548. return m.AddedEndIndex()
  33549. case usagetotal.FieldOrganizationID:
  33550. return m.AddedOrganizationID()
  33551. }
  33552. return nil, false
  33553. }
  33554. // AddField adds the value to the field with the given name. It returns an error if
  33555. // the field is not defined in the schema, or if the type mismatched the field
  33556. // type.
  33557. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  33558. switch name {
  33559. case usagetotal.FieldStatus:
  33560. v, ok := value.(int8)
  33561. if !ok {
  33562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33563. }
  33564. m.AddStatus(v)
  33565. return nil
  33566. case usagetotal.FieldType:
  33567. v, ok := value.(int)
  33568. if !ok {
  33569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33570. }
  33571. m.AddType(v)
  33572. return nil
  33573. case usagetotal.FieldTotalTokens:
  33574. v, ok := value.(int64)
  33575. if !ok {
  33576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33577. }
  33578. m.AddTotalTokens(v)
  33579. return nil
  33580. case usagetotal.FieldStartIndex:
  33581. v, ok := value.(int64)
  33582. if !ok {
  33583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33584. }
  33585. m.AddStartIndex(v)
  33586. return nil
  33587. case usagetotal.FieldEndIndex:
  33588. v, ok := value.(int64)
  33589. if !ok {
  33590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33591. }
  33592. m.AddEndIndex(v)
  33593. return nil
  33594. case usagetotal.FieldOrganizationID:
  33595. v, ok := value.(int64)
  33596. if !ok {
  33597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33598. }
  33599. m.AddOrganizationID(v)
  33600. return nil
  33601. }
  33602. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  33603. }
  33604. // ClearedFields returns all nullable fields that were cleared during this
  33605. // mutation.
  33606. func (m *UsageTotalMutation) ClearedFields() []string {
  33607. var fields []string
  33608. if m.FieldCleared(usagetotal.FieldStatus) {
  33609. fields = append(fields, usagetotal.FieldStatus)
  33610. }
  33611. if m.FieldCleared(usagetotal.FieldType) {
  33612. fields = append(fields, usagetotal.FieldType)
  33613. }
  33614. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  33615. fields = append(fields, usagetotal.FieldTotalTokens)
  33616. }
  33617. if m.FieldCleared(usagetotal.FieldStartIndex) {
  33618. fields = append(fields, usagetotal.FieldStartIndex)
  33619. }
  33620. if m.FieldCleared(usagetotal.FieldEndIndex) {
  33621. fields = append(fields, usagetotal.FieldEndIndex)
  33622. }
  33623. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  33624. fields = append(fields, usagetotal.FieldOrganizationID)
  33625. }
  33626. return fields
  33627. }
  33628. // FieldCleared returns a boolean indicating if a field with the given name was
  33629. // cleared in this mutation.
  33630. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  33631. _, ok := m.clearedFields[name]
  33632. return ok
  33633. }
  33634. // ClearField clears the value of the field with the given name. It returns an
  33635. // error if the field is not defined in the schema.
  33636. func (m *UsageTotalMutation) ClearField(name string) error {
  33637. switch name {
  33638. case usagetotal.FieldStatus:
  33639. m.ClearStatus()
  33640. return nil
  33641. case usagetotal.FieldType:
  33642. m.ClearType()
  33643. return nil
  33644. case usagetotal.FieldTotalTokens:
  33645. m.ClearTotalTokens()
  33646. return nil
  33647. case usagetotal.FieldStartIndex:
  33648. m.ClearStartIndex()
  33649. return nil
  33650. case usagetotal.FieldEndIndex:
  33651. m.ClearEndIndex()
  33652. return nil
  33653. case usagetotal.FieldOrganizationID:
  33654. m.ClearOrganizationID()
  33655. return nil
  33656. }
  33657. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  33658. }
  33659. // ResetField resets all changes in the mutation for the field with the given name.
  33660. // It returns an error if the field is not defined in the schema.
  33661. func (m *UsageTotalMutation) ResetField(name string) error {
  33662. switch name {
  33663. case usagetotal.FieldCreatedAt:
  33664. m.ResetCreatedAt()
  33665. return nil
  33666. case usagetotal.FieldUpdatedAt:
  33667. m.ResetUpdatedAt()
  33668. return nil
  33669. case usagetotal.FieldStatus:
  33670. m.ResetStatus()
  33671. return nil
  33672. case usagetotal.FieldType:
  33673. m.ResetType()
  33674. return nil
  33675. case usagetotal.FieldBotID:
  33676. m.ResetBotID()
  33677. return nil
  33678. case usagetotal.FieldTotalTokens:
  33679. m.ResetTotalTokens()
  33680. return nil
  33681. case usagetotal.FieldStartIndex:
  33682. m.ResetStartIndex()
  33683. return nil
  33684. case usagetotal.FieldEndIndex:
  33685. m.ResetEndIndex()
  33686. return nil
  33687. case usagetotal.FieldOrganizationID:
  33688. m.ResetOrganizationID()
  33689. return nil
  33690. }
  33691. return fmt.Errorf("unknown UsageTotal field %s", name)
  33692. }
  33693. // AddedEdges returns all edge names that were set/added in this mutation.
  33694. func (m *UsageTotalMutation) AddedEdges() []string {
  33695. edges := make([]string, 0, 0)
  33696. return edges
  33697. }
  33698. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33699. // name in this mutation.
  33700. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  33701. return nil
  33702. }
  33703. // RemovedEdges returns all edge names that were removed in this mutation.
  33704. func (m *UsageTotalMutation) RemovedEdges() []string {
  33705. edges := make([]string, 0, 0)
  33706. return edges
  33707. }
  33708. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33709. // the given name in this mutation.
  33710. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  33711. return nil
  33712. }
  33713. // ClearedEdges returns all edge names that were cleared in this mutation.
  33714. func (m *UsageTotalMutation) ClearedEdges() []string {
  33715. edges := make([]string, 0, 0)
  33716. return edges
  33717. }
  33718. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33719. // was cleared in this mutation.
  33720. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  33721. return false
  33722. }
  33723. // ClearEdge clears the value of the edge with the given name. It returns an error
  33724. // if that edge is not defined in the schema.
  33725. func (m *UsageTotalMutation) ClearEdge(name string) error {
  33726. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  33727. }
  33728. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33729. // It returns an error if the edge is not defined in the schema.
  33730. func (m *UsageTotalMutation) ResetEdge(name string) error {
  33731. return fmt.Errorf("unknown UsageTotal edge %s", name)
  33732. }
  33733. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  33734. type WhatsappMutation struct {
  33735. config
  33736. op Op
  33737. typ string
  33738. id *uint64
  33739. created_at *time.Time
  33740. updated_at *time.Time
  33741. status *uint8
  33742. addstatus *int8
  33743. deleted_at *time.Time
  33744. wa_id *uint64
  33745. addwa_id *int64
  33746. callback *string
  33747. account *string
  33748. nickname *string
  33749. phone *string
  33750. phone_name *string
  33751. phone_status *int8
  33752. addphone_status *int8
  33753. organization_id *uint64
  33754. addorganization_id *int64
  33755. api_base *string
  33756. api_key *string
  33757. allow_list *[]string
  33758. appendallow_list []string
  33759. group_allow_list *[]string
  33760. appendgroup_allow_list []string
  33761. block_list *[]string
  33762. appendblock_list []string
  33763. group_block_list *[]string
  33764. appendgroup_block_list []string
  33765. clearedFields map[string]struct{}
  33766. agent *uint64
  33767. clearedagent bool
  33768. done bool
  33769. oldValue func(context.Context) (*Whatsapp, error)
  33770. predicates []predicate.Whatsapp
  33771. }
  33772. var _ ent.Mutation = (*WhatsappMutation)(nil)
  33773. // whatsappOption allows management of the mutation configuration using functional options.
  33774. type whatsappOption func(*WhatsappMutation)
  33775. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  33776. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  33777. m := &WhatsappMutation{
  33778. config: c,
  33779. op: op,
  33780. typ: TypeWhatsapp,
  33781. clearedFields: make(map[string]struct{}),
  33782. }
  33783. for _, opt := range opts {
  33784. opt(m)
  33785. }
  33786. return m
  33787. }
  33788. // withWhatsappID sets the ID field of the mutation.
  33789. func withWhatsappID(id uint64) whatsappOption {
  33790. return func(m *WhatsappMutation) {
  33791. var (
  33792. err error
  33793. once sync.Once
  33794. value *Whatsapp
  33795. )
  33796. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  33797. once.Do(func() {
  33798. if m.done {
  33799. err = errors.New("querying old values post mutation is not allowed")
  33800. } else {
  33801. value, err = m.Client().Whatsapp.Get(ctx, id)
  33802. }
  33803. })
  33804. return value, err
  33805. }
  33806. m.id = &id
  33807. }
  33808. }
  33809. // withWhatsapp sets the old Whatsapp of the mutation.
  33810. func withWhatsapp(node *Whatsapp) whatsappOption {
  33811. return func(m *WhatsappMutation) {
  33812. m.oldValue = func(context.Context) (*Whatsapp, error) {
  33813. return node, nil
  33814. }
  33815. m.id = &node.ID
  33816. }
  33817. }
  33818. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33819. // executed in a transaction (ent.Tx), a transactional client is returned.
  33820. func (m WhatsappMutation) Client() *Client {
  33821. client := &Client{config: m.config}
  33822. client.init()
  33823. return client
  33824. }
  33825. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33826. // it returns an error otherwise.
  33827. func (m WhatsappMutation) Tx() (*Tx, error) {
  33828. if _, ok := m.driver.(*txDriver); !ok {
  33829. return nil, errors.New("ent: mutation is not running in a transaction")
  33830. }
  33831. tx := &Tx{config: m.config}
  33832. tx.init()
  33833. return tx, nil
  33834. }
  33835. // SetID sets the value of the id field. Note that this
  33836. // operation is only accepted on creation of Whatsapp entities.
  33837. func (m *WhatsappMutation) SetID(id uint64) {
  33838. m.id = &id
  33839. }
  33840. // ID returns the ID value in the mutation. Note that the ID is only available
  33841. // if it was provided to the builder or after it was returned from the database.
  33842. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  33843. if m.id == nil {
  33844. return
  33845. }
  33846. return *m.id, true
  33847. }
  33848. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33849. // That means, if the mutation is applied within a transaction with an isolation level such
  33850. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33851. // or updated by the mutation.
  33852. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  33853. switch {
  33854. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33855. id, exists := m.ID()
  33856. if exists {
  33857. return []uint64{id}, nil
  33858. }
  33859. fallthrough
  33860. case m.op.Is(OpUpdate | OpDelete):
  33861. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  33862. default:
  33863. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33864. }
  33865. }
  33866. // SetCreatedAt sets the "created_at" field.
  33867. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  33868. m.created_at = &t
  33869. }
  33870. // CreatedAt returns the value of the "created_at" field in the mutation.
  33871. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  33872. v := m.created_at
  33873. if v == nil {
  33874. return
  33875. }
  33876. return *v, true
  33877. }
  33878. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  33879. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33881. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33882. if !m.op.Is(OpUpdateOne) {
  33883. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33884. }
  33885. if m.id == nil || m.oldValue == nil {
  33886. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33887. }
  33888. oldValue, err := m.oldValue(ctx)
  33889. if err != nil {
  33890. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33891. }
  33892. return oldValue.CreatedAt, nil
  33893. }
  33894. // ResetCreatedAt resets all changes to the "created_at" field.
  33895. func (m *WhatsappMutation) ResetCreatedAt() {
  33896. m.created_at = nil
  33897. }
  33898. // SetUpdatedAt sets the "updated_at" field.
  33899. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  33900. m.updated_at = &t
  33901. }
  33902. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33903. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  33904. v := m.updated_at
  33905. if v == nil {
  33906. return
  33907. }
  33908. return *v, true
  33909. }
  33910. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  33911. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33913. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33914. if !m.op.Is(OpUpdateOne) {
  33915. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33916. }
  33917. if m.id == nil || m.oldValue == nil {
  33918. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33919. }
  33920. oldValue, err := m.oldValue(ctx)
  33921. if err != nil {
  33922. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33923. }
  33924. return oldValue.UpdatedAt, nil
  33925. }
  33926. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33927. func (m *WhatsappMutation) ResetUpdatedAt() {
  33928. m.updated_at = nil
  33929. }
  33930. // SetStatus sets the "status" field.
  33931. func (m *WhatsappMutation) SetStatus(u uint8) {
  33932. m.status = &u
  33933. m.addstatus = nil
  33934. }
  33935. // Status returns the value of the "status" field in the mutation.
  33936. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  33937. v := m.status
  33938. if v == nil {
  33939. return
  33940. }
  33941. return *v, true
  33942. }
  33943. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  33944. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33946. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33947. if !m.op.Is(OpUpdateOne) {
  33948. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33949. }
  33950. if m.id == nil || m.oldValue == nil {
  33951. return v, errors.New("OldStatus requires an ID field in the mutation")
  33952. }
  33953. oldValue, err := m.oldValue(ctx)
  33954. if err != nil {
  33955. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33956. }
  33957. return oldValue.Status, nil
  33958. }
  33959. // AddStatus adds u to the "status" field.
  33960. func (m *WhatsappMutation) AddStatus(u int8) {
  33961. if m.addstatus != nil {
  33962. *m.addstatus += u
  33963. } else {
  33964. m.addstatus = &u
  33965. }
  33966. }
  33967. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33968. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  33969. v := m.addstatus
  33970. if v == nil {
  33971. return
  33972. }
  33973. return *v, true
  33974. }
  33975. // ClearStatus clears the value of the "status" field.
  33976. func (m *WhatsappMutation) ClearStatus() {
  33977. m.status = nil
  33978. m.addstatus = nil
  33979. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  33980. }
  33981. // StatusCleared returns if the "status" field was cleared in this mutation.
  33982. func (m *WhatsappMutation) StatusCleared() bool {
  33983. _, ok := m.clearedFields[whatsapp.FieldStatus]
  33984. return ok
  33985. }
  33986. // ResetStatus resets all changes to the "status" field.
  33987. func (m *WhatsappMutation) ResetStatus() {
  33988. m.status = nil
  33989. m.addstatus = nil
  33990. delete(m.clearedFields, whatsapp.FieldStatus)
  33991. }
  33992. // SetDeletedAt sets the "deleted_at" field.
  33993. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  33994. m.deleted_at = &t
  33995. }
  33996. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33997. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  33998. v := m.deleted_at
  33999. if v == nil {
  34000. return
  34001. }
  34002. return *v, true
  34003. }
  34004. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  34005. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34007. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34008. if !m.op.Is(OpUpdateOne) {
  34009. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34010. }
  34011. if m.id == nil || m.oldValue == nil {
  34012. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34013. }
  34014. oldValue, err := m.oldValue(ctx)
  34015. if err != nil {
  34016. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34017. }
  34018. return oldValue.DeletedAt, nil
  34019. }
  34020. // ClearDeletedAt clears the value of the "deleted_at" field.
  34021. func (m *WhatsappMutation) ClearDeletedAt() {
  34022. m.deleted_at = nil
  34023. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  34024. }
  34025. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34026. func (m *WhatsappMutation) DeletedAtCleared() bool {
  34027. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  34028. return ok
  34029. }
  34030. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34031. func (m *WhatsappMutation) ResetDeletedAt() {
  34032. m.deleted_at = nil
  34033. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  34034. }
  34035. // SetWaID sets the "wa_id" field.
  34036. func (m *WhatsappMutation) SetWaID(u uint64) {
  34037. m.wa_id = &u
  34038. m.addwa_id = nil
  34039. }
  34040. // WaID returns the value of the "wa_id" field in the mutation.
  34041. func (m *WhatsappMutation) WaID() (r uint64, exists bool) {
  34042. v := m.wa_id
  34043. if v == nil {
  34044. return
  34045. }
  34046. return *v, true
  34047. }
  34048. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  34049. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34051. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v uint64, err error) {
  34052. if !m.op.Is(OpUpdateOne) {
  34053. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  34054. }
  34055. if m.id == nil || m.oldValue == nil {
  34056. return v, errors.New("OldWaID requires an ID field in the mutation")
  34057. }
  34058. oldValue, err := m.oldValue(ctx)
  34059. if err != nil {
  34060. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  34061. }
  34062. return oldValue.WaID, nil
  34063. }
  34064. // AddWaID adds u to the "wa_id" field.
  34065. func (m *WhatsappMutation) AddWaID(u int64) {
  34066. if m.addwa_id != nil {
  34067. *m.addwa_id += u
  34068. } else {
  34069. m.addwa_id = &u
  34070. }
  34071. }
  34072. // AddedWaID returns the value that was added to the "wa_id" field in this mutation.
  34073. func (m *WhatsappMutation) AddedWaID() (r int64, exists bool) {
  34074. v := m.addwa_id
  34075. if v == nil {
  34076. return
  34077. }
  34078. return *v, true
  34079. }
  34080. // ClearWaID clears the value of the "wa_id" field.
  34081. func (m *WhatsappMutation) ClearWaID() {
  34082. m.wa_id = nil
  34083. m.addwa_id = nil
  34084. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  34085. }
  34086. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  34087. func (m *WhatsappMutation) WaIDCleared() bool {
  34088. _, ok := m.clearedFields[whatsapp.FieldWaID]
  34089. return ok
  34090. }
  34091. // ResetWaID resets all changes to the "wa_id" field.
  34092. func (m *WhatsappMutation) ResetWaID() {
  34093. m.wa_id = nil
  34094. m.addwa_id = nil
  34095. delete(m.clearedFields, whatsapp.FieldWaID)
  34096. }
  34097. // SetCallback sets the "callback" field.
  34098. func (m *WhatsappMutation) SetCallback(s string) {
  34099. m.callback = &s
  34100. }
  34101. // Callback returns the value of the "callback" field in the mutation.
  34102. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  34103. v := m.callback
  34104. if v == nil {
  34105. return
  34106. }
  34107. return *v, true
  34108. }
  34109. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  34110. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34112. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  34113. if !m.op.Is(OpUpdateOne) {
  34114. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  34115. }
  34116. if m.id == nil || m.oldValue == nil {
  34117. return v, errors.New("OldCallback requires an ID field in the mutation")
  34118. }
  34119. oldValue, err := m.oldValue(ctx)
  34120. if err != nil {
  34121. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  34122. }
  34123. return oldValue.Callback, nil
  34124. }
  34125. // ClearCallback clears the value of the "callback" field.
  34126. func (m *WhatsappMutation) ClearCallback() {
  34127. m.callback = nil
  34128. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  34129. }
  34130. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  34131. func (m *WhatsappMutation) CallbackCleared() bool {
  34132. _, ok := m.clearedFields[whatsapp.FieldCallback]
  34133. return ok
  34134. }
  34135. // ResetCallback resets all changes to the "callback" field.
  34136. func (m *WhatsappMutation) ResetCallback() {
  34137. m.callback = nil
  34138. delete(m.clearedFields, whatsapp.FieldCallback)
  34139. }
  34140. // SetAgentID sets the "agent_id" field.
  34141. func (m *WhatsappMutation) SetAgentID(u uint64) {
  34142. m.agent = &u
  34143. }
  34144. // AgentID returns the value of the "agent_id" field in the mutation.
  34145. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  34146. v := m.agent
  34147. if v == nil {
  34148. return
  34149. }
  34150. return *v, true
  34151. }
  34152. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  34153. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34155. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  34156. if !m.op.Is(OpUpdateOne) {
  34157. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  34158. }
  34159. if m.id == nil || m.oldValue == nil {
  34160. return v, errors.New("OldAgentID requires an ID field in the mutation")
  34161. }
  34162. oldValue, err := m.oldValue(ctx)
  34163. if err != nil {
  34164. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  34165. }
  34166. return oldValue.AgentID, nil
  34167. }
  34168. // ResetAgentID resets all changes to the "agent_id" field.
  34169. func (m *WhatsappMutation) ResetAgentID() {
  34170. m.agent = nil
  34171. }
  34172. // SetAccount sets the "account" field.
  34173. func (m *WhatsappMutation) SetAccount(s string) {
  34174. m.account = &s
  34175. }
  34176. // Account returns the value of the "account" field in the mutation.
  34177. func (m *WhatsappMutation) Account() (r string, exists bool) {
  34178. v := m.account
  34179. if v == nil {
  34180. return
  34181. }
  34182. return *v, true
  34183. }
  34184. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  34185. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34187. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  34188. if !m.op.Is(OpUpdateOne) {
  34189. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  34190. }
  34191. if m.id == nil || m.oldValue == nil {
  34192. return v, errors.New("OldAccount requires an ID field in the mutation")
  34193. }
  34194. oldValue, err := m.oldValue(ctx)
  34195. if err != nil {
  34196. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  34197. }
  34198. return oldValue.Account, nil
  34199. }
  34200. // ClearAccount clears the value of the "account" field.
  34201. func (m *WhatsappMutation) ClearAccount() {
  34202. m.account = nil
  34203. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  34204. }
  34205. // AccountCleared returns if the "account" field was cleared in this mutation.
  34206. func (m *WhatsappMutation) AccountCleared() bool {
  34207. _, ok := m.clearedFields[whatsapp.FieldAccount]
  34208. return ok
  34209. }
  34210. // ResetAccount resets all changes to the "account" field.
  34211. func (m *WhatsappMutation) ResetAccount() {
  34212. m.account = nil
  34213. delete(m.clearedFields, whatsapp.FieldAccount)
  34214. }
  34215. // SetNickname sets the "nickname" field.
  34216. func (m *WhatsappMutation) SetNickname(s string) {
  34217. m.nickname = &s
  34218. }
  34219. // Nickname returns the value of the "nickname" field in the mutation.
  34220. func (m *WhatsappMutation) Nickname() (r string, exists bool) {
  34221. v := m.nickname
  34222. if v == nil {
  34223. return
  34224. }
  34225. return *v, true
  34226. }
  34227. // OldNickname returns the old "nickname" field's value of the Whatsapp entity.
  34228. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34230. func (m *WhatsappMutation) OldNickname(ctx context.Context) (v string, err error) {
  34231. if !m.op.Is(OpUpdateOne) {
  34232. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  34233. }
  34234. if m.id == nil || m.oldValue == nil {
  34235. return v, errors.New("OldNickname requires an ID field in the mutation")
  34236. }
  34237. oldValue, err := m.oldValue(ctx)
  34238. if err != nil {
  34239. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  34240. }
  34241. return oldValue.Nickname, nil
  34242. }
  34243. // ResetNickname resets all changes to the "nickname" field.
  34244. func (m *WhatsappMutation) ResetNickname() {
  34245. m.nickname = nil
  34246. }
  34247. // SetPhone sets the "phone" field.
  34248. func (m *WhatsappMutation) SetPhone(s string) {
  34249. m.phone = &s
  34250. }
  34251. // Phone returns the value of the "phone" field in the mutation.
  34252. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  34253. v := m.phone
  34254. if v == nil {
  34255. return
  34256. }
  34257. return *v, true
  34258. }
  34259. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  34260. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34262. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  34263. if !m.op.Is(OpUpdateOne) {
  34264. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  34265. }
  34266. if m.id == nil || m.oldValue == nil {
  34267. return v, errors.New("OldPhone requires an ID field in the mutation")
  34268. }
  34269. oldValue, err := m.oldValue(ctx)
  34270. if err != nil {
  34271. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  34272. }
  34273. return oldValue.Phone, nil
  34274. }
  34275. // ResetPhone resets all changes to the "phone" field.
  34276. func (m *WhatsappMutation) ResetPhone() {
  34277. m.phone = nil
  34278. }
  34279. // SetPhoneName sets the "phone_name" field.
  34280. func (m *WhatsappMutation) SetPhoneName(s string) {
  34281. m.phone_name = &s
  34282. }
  34283. // PhoneName returns the value of the "phone_name" field in the mutation.
  34284. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  34285. v := m.phone_name
  34286. if v == nil {
  34287. return
  34288. }
  34289. return *v, true
  34290. }
  34291. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  34292. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34294. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  34295. if !m.op.Is(OpUpdateOne) {
  34296. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  34297. }
  34298. if m.id == nil || m.oldValue == nil {
  34299. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  34300. }
  34301. oldValue, err := m.oldValue(ctx)
  34302. if err != nil {
  34303. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  34304. }
  34305. return oldValue.PhoneName, nil
  34306. }
  34307. // ResetPhoneName resets all changes to the "phone_name" field.
  34308. func (m *WhatsappMutation) ResetPhoneName() {
  34309. m.phone_name = nil
  34310. }
  34311. // SetPhoneStatus sets the "phone_status" field.
  34312. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  34313. m.phone_status = &i
  34314. m.addphone_status = nil
  34315. }
  34316. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  34317. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  34318. v := m.phone_status
  34319. if v == nil {
  34320. return
  34321. }
  34322. return *v, true
  34323. }
  34324. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  34325. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34327. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  34328. if !m.op.Is(OpUpdateOne) {
  34329. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  34330. }
  34331. if m.id == nil || m.oldValue == nil {
  34332. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  34333. }
  34334. oldValue, err := m.oldValue(ctx)
  34335. if err != nil {
  34336. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  34337. }
  34338. return oldValue.PhoneStatus, nil
  34339. }
  34340. // AddPhoneStatus adds i to the "phone_status" field.
  34341. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  34342. if m.addphone_status != nil {
  34343. *m.addphone_status += i
  34344. } else {
  34345. m.addphone_status = &i
  34346. }
  34347. }
  34348. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  34349. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  34350. v := m.addphone_status
  34351. if v == nil {
  34352. return
  34353. }
  34354. return *v, true
  34355. }
  34356. // ResetPhoneStatus resets all changes to the "phone_status" field.
  34357. func (m *WhatsappMutation) ResetPhoneStatus() {
  34358. m.phone_status = nil
  34359. m.addphone_status = nil
  34360. }
  34361. // SetOrganizationID sets the "organization_id" field.
  34362. func (m *WhatsappMutation) 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 *WhatsappMutation) 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 Whatsapp entity.
  34375. // If the Whatsapp 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 *WhatsappMutation) 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 *WhatsappMutation) 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 *WhatsappMutation) 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 *WhatsappMutation) ClearOrganizationID() {
  34408. m.organization_id = nil
  34409. m.addorganization_id = nil
  34410. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  34411. }
  34412. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34413. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  34414. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  34415. return ok
  34416. }
  34417. // ResetOrganizationID resets all changes to the "organization_id" field.
  34418. func (m *WhatsappMutation) ResetOrganizationID() {
  34419. m.organization_id = nil
  34420. m.addorganization_id = nil
  34421. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  34422. }
  34423. // SetAPIBase sets the "api_base" field.
  34424. func (m *WhatsappMutation) SetAPIBase(s string) {
  34425. m.api_base = &s
  34426. }
  34427. // APIBase returns the value of the "api_base" field in the mutation.
  34428. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  34429. v := m.api_base
  34430. if v == nil {
  34431. return
  34432. }
  34433. return *v, true
  34434. }
  34435. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  34436. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34438. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  34439. if !m.op.Is(OpUpdateOne) {
  34440. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  34441. }
  34442. if m.id == nil || m.oldValue == nil {
  34443. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  34444. }
  34445. oldValue, err := m.oldValue(ctx)
  34446. if err != nil {
  34447. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  34448. }
  34449. return oldValue.APIBase, nil
  34450. }
  34451. // ClearAPIBase clears the value of the "api_base" field.
  34452. func (m *WhatsappMutation) ClearAPIBase() {
  34453. m.api_base = nil
  34454. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  34455. }
  34456. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  34457. func (m *WhatsappMutation) APIBaseCleared() bool {
  34458. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  34459. return ok
  34460. }
  34461. // ResetAPIBase resets all changes to the "api_base" field.
  34462. func (m *WhatsappMutation) ResetAPIBase() {
  34463. m.api_base = nil
  34464. delete(m.clearedFields, whatsapp.FieldAPIBase)
  34465. }
  34466. // SetAPIKey sets the "api_key" field.
  34467. func (m *WhatsappMutation) SetAPIKey(s string) {
  34468. m.api_key = &s
  34469. }
  34470. // APIKey returns the value of the "api_key" field in the mutation.
  34471. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  34472. v := m.api_key
  34473. if v == nil {
  34474. return
  34475. }
  34476. return *v, true
  34477. }
  34478. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  34479. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34481. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  34482. if !m.op.Is(OpUpdateOne) {
  34483. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  34484. }
  34485. if m.id == nil || m.oldValue == nil {
  34486. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  34487. }
  34488. oldValue, err := m.oldValue(ctx)
  34489. if err != nil {
  34490. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  34491. }
  34492. return oldValue.APIKey, nil
  34493. }
  34494. // ClearAPIKey clears the value of the "api_key" field.
  34495. func (m *WhatsappMutation) ClearAPIKey() {
  34496. m.api_key = nil
  34497. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  34498. }
  34499. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  34500. func (m *WhatsappMutation) APIKeyCleared() bool {
  34501. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  34502. return ok
  34503. }
  34504. // ResetAPIKey resets all changes to the "api_key" field.
  34505. func (m *WhatsappMutation) ResetAPIKey() {
  34506. m.api_key = nil
  34507. delete(m.clearedFields, whatsapp.FieldAPIKey)
  34508. }
  34509. // SetAllowList sets the "allow_list" field.
  34510. func (m *WhatsappMutation) SetAllowList(s []string) {
  34511. m.allow_list = &s
  34512. m.appendallow_list = nil
  34513. }
  34514. // AllowList returns the value of the "allow_list" field in the mutation.
  34515. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  34516. v := m.allow_list
  34517. if v == nil {
  34518. return
  34519. }
  34520. return *v, true
  34521. }
  34522. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  34523. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34525. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  34526. if !m.op.Is(OpUpdateOne) {
  34527. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  34528. }
  34529. if m.id == nil || m.oldValue == nil {
  34530. return v, errors.New("OldAllowList requires an ID field in the mutation")
  34531. }
  34532. oldValue, err := m.oldValue(ctx)
  34533. if err != nil {
  34534. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  34535. }
  34536. return oldValue.AllowList, nil
  34537. }
  34538. // AppendAllowList adds s to the "allow_list" field.
  34539. func (m *WhatsappMutation) AppendAllowList(s []string) {
  34540. m.appendallow_list = append(m.appendallow_list, s...)
  34541. }
  34542. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  34543. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  34544. if len(m.appendallow_list) == 0 {
  34545. return nil, false
  34546. }
  34547. return m.appendallow_list, true
  34548. }
  34549. // ClearAllowList clears the value of the "allow_list" field.
  34550. func (m *WhatsappMutation) ClearAllowList() {
  34551. m.allow_list = nil
  34552. m.appendallow_list = nil
  34553. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  34554. }
  34555. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  34556. func (m *WhatsappMutation) AllowListCleared() bool {
  34557. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  34558. return ok
  34559. }
  34560. // ResetAllowList resets all changes to the "allow_list" field.
  34561. func (m *WhatsappMutation) ResetAllowList() {
  34562. m.allow_list = nil
  34563. m.appendallow_list = nil
  34564. delete(m.clearedFields, whatsapp.FieldAllowList)
  34565. }
  34566. // SetGroupAllowList sets the "group_allow_list" field.
  34567. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  34568. m.group_allow_list = &s
  34569. m.appendgroup_allow_list = nil
  34570. }
  34571. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  34572. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  34573. v := m.group_allow_list
  34574. if v == nil {
  34575. return
  34576. }
  34577. return *v, true
  34578. }
  34579. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  34580. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34582. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  34583. if !m.op.Is(OpUpdateOne) {
  34584. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  34585. }
  34586. if m.id == nil || m.oldValue == nil {
  34587. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  34588. }
  34589. oldValue, err := m.oldValue(ctx)
  34590. if err != nil {
  34591. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  34592. }
  34593. return oldValue.GroupAllowList, nil
  34594. }
  34595. // AppendGroupAllowList adds s to the "group_allow_list" field.
  34596. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  34597. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  34598. }
  34599. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  34600. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  34601. if len(m.appendgroup_allow_list) == 0 {
  34602. return nil, false
  34603. }
  34604. return m.appendgroup_allow_list, true
  34605. }
  34606. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  34607. func (m *WhatsappMutation) ClearGroupAllowList() {
  34608. m.group_allow_list = nil
  34609. m.appendgroup_allow_list = nil
  34610. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  34611. }
  34612. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  34613. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  34614. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  34615. return ok
  34616. }
  34617. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  34618. func (m *WhatsappMutation) ResetGroupAllowList() {
  34619. m.group_allow_list = nil
  34620. m.appendgroup_allow_list = nil
  34621. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  34622. }
  34623. // SetBlockList sets the "block_list" field.
  34624. func (m *WhatsappMutation) SetBlockList(s []string) {
  34625. m.block_list = &s
  34626. m.appendblock_list = nil
  34627. }
  34628. // BlockList returns the value of the "block_list" field in the mutation.
  34629. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  34630. v := m.block_list
  34631. if v == nil {
  34632. return
  34633. }
  34634. return *v, true
  34635. }
  34636. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  34637. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34639. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  34640. if !m.op.Is(OpUpdateOne) {
  34641. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  34642. }
  34643. if m.id == nil || m.oldValue == nil {
  34644. return v, errors.New("OldBlockList requires an ID field in the mutation")
  34645. }
  34646. oldValue, err := m.oldValue(ctx)
  34647. if err != nil {
  34648. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  34649. }
  34650. return oldValue.BlockList, nil
  34651. }
  34652. // AppendBlockList adds s to the "block_list" field.
  34653. func (m *WhatsappMutation) AppendBlockList(s []string) {
  34654. m.appendblock_list = append(m.appendblock_list, s...)
  34655. }
  34656. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  34657. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  34658. if len(m.appendblock_list) == 0 {
  34659. return nil, false
  34660. }
  34661. return m.appendblock_list, true
  34662. }
  34663. // ClearBlockList clears the value of the "block_list" field.
  34664. func (m *WhatsappMutation) ClearBlockList() {
  34665. m.block_list = nil
  34666. m.appendblock_list = nil
  34667. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  34668. }
  34669. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  34670. func (m *WhatsappMutation) BlockListCleared() bool {
  34671. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  34672. return ok
  34673. }
  34674. // ResetBlockList resets all changes to the "block_list" field.
  34675. func (m *WhatsappMutation) ResetBlockList() {
  34676. m.block_list = nil
  34677. m.appendblock_list = nil
  34678. delete(m.clearedFields, whatsapp.FieldBlockList)
  34679. }
  34680. // SetGroupBlockList sets the "group_block_list" field.
  34681. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  34682. m.group_block_list = &s
  34683. m.appendgroup_block_list = nil
  34684. }
  34685. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  34686. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  34687. v := m.group_block_list
  34688. if v == nil {
  34689. return
  34690. }
  34691. return *v, true
  34692. }
  34693. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  34694. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34696. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  34697. if !m.op.Is(OpUpdateOne) {
  34698. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  34699. }
  34700. if m.id == nil || m.oldValue == nil {
  34701. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  34702. }
  34703. oldValue, err := m.oldValue(ctx)
  34704. if err != nil {
  34705. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  34706. }
  34707. return oldValue.GroupBlockList, nil
  34708. }
  34709. // AppendGroupBlockList adds s to the "group_block_list" field.
  34710. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  34711. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  34712. }
  34713. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  34714. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  34715. if len(m.appendgroup_block_list) == 0 {
  34716. return nil, false
  34717. }
  34718. return m.appendgroup_block_list, true
  34719. }
  34720. // ClearGroupBlockList clears the value of the "group_block_list" field.
  34721. func (m *WhatsappMutation) ClearGroupBlockList() {
  34722. m.group_block_list = nil
  34723. m.appendgroup_block_list = nil
  34724. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  34725. }
  34726. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  34727. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  34728. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  34729. return ok
  34730. }
  34731. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  34732. func (m *WhatsappMutation) ResetGroupBlockList() {
  34733. m.group_block_list = nil
  34734. m.appendgroup_block_list = nil
  34735. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  34736. }
  34737. // ClearAgent clears the "agent" edge to the Agent entity.
  34738. func (m *WhatsappMutation) ClearAgent() {
  34739. m.clearedagent = true
  34740. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  34741. }
  34742. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  34743. func (m *WhatsappMutation) AgentCleared() bool {
  34744. return m.clearedagent
  34745. }
  34746. // AgentIDs returns the "agent" edge IDs in the mutation.
  34747. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34748. // AgentID instead. It exists only for internal usage by the builders.
  34749. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  34750. if id := m.agent; id != nil {
  34751. ids = append(ids, *id)
  34752. }
  34753. return
  34754. }
  34755. // ResetAgent resets all changes to the "agent" edge.
  34756. func (m *WhatsappMutation) ResetAgent() {
  34757. m.agent = nil
  34758. m.clearedagent = false
  34759. }
  34760. // Where appends a list predicates to the WhatsappMutation builder.
  34761. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  34762. m.predicates = append(m.predicates, ps...)
  34763. }
  34764. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  34765. // users can use type-assertion to append predicates that do not depend on any generated package.
  34766. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  34767. p := make([]predicate.Whatsapp, len(ps))
  34768. for i := range ps {
  34769. p[i] = ps[i]
  34770. }
  34771. m.Where(p...)
  34772. }
  34773. // Op returns the operation name.
  34774. func (m *WhatsappMutation) Op() Op {
  34775. return m.op
  34776. }
  34777. // SetOp allows setting the mutation operation.
  34778. func (m *WhatsappMutation) SetOp(op Op) {
  34779. m.op = op
  34780. }
  34781. // Type returns the node type of this mutation (Whatsapp).
  34782. func (m *WhatsappMutation) Type() string {
  34783. return m.typ
  34784. }
  34785. // Fields returns all fields that were changed during this mutation. Note that in
  34786. // order to get all numeric fields that were incremented/decremented, call
  34787. // AddedFields().
  34788. func (m *WhatsappMutation) Fields() []string {
  34789. fields := make([]string, 0, 19)
  34790. if m.created_at != nil {
  34791. fields = append(fields, whatsapp.FieldCreatedAt)
  34792. }
  34793. if m.updated_at != nil {
  34794. fields = append(fields, whatsapp.FieldUpdatedAt)
  34795. }
  34796. if m.status != nil {
  34797. fields = append(fields, whatsapp.FieldStatus)
  34798. }
  34799. if m.deleted_at != nil {
  34800. fields = append(fields, whatsapp.FieldDeletedAt)
  34801. }
  34802. if m.wa_id != nil {
  34803. fields = append(fields, whatsapp.FieldWaID)
  34804. }
  34805. if m.callback != nil {
  34806. fields = append(fields, whatsapp.FieldCallback)
  34807. }
  34808. if m.agent != nil {
  34809. fields = append(fields, whatsapp.FieldAgentID)
  34810. }
  34811. if m.account != nil {
  34812. fields = append(fields, whatsapp.FieldAccount)
  34813. }
  34814. if m.nickname != nil {
  34815. fields = append(fields, whatsapp.FieldNickname)
  34816. }
  34817. if m.phone != nil {
  34818. fields = append(fields, whatsapp.FieldPhone)
  34819. }
  34820. if m.phone_name != nil {
  34821. fields = append(fields, whatsapp.FieldPhoneName)
  34822. }
  34823. if m.phone_status != nil {
  34824. fields = append(fields, whatsapp.FieldPhoneStatus)
  34825. }
  34826. if m.organization_id != nil {
  34827. fields = append(fields, whatsapp.FieldOrganizationID)
  34828. }
  34829. if m.api_base != nil {
  34830. fields = append(fields, whatsapp.FieldAPIBase)
  34831. }
  34832. if m.api_key != nil {
  34833. fields = append(fields, whatsapp.FieldAPIKey)
  34834. }
  34835. if m.allow_list != nil {
  34836. fields = append(fields, whatsapp.FieldAllowList)
  34837. }
  34838. if m.group_allow_list != nil {
  34839. fields = append(fields, whatsapp.FieldGroupAllowList)
  34840. }
  34841. if m.block_list != nil {
  34842. fields = append(fields, whatsapp.FieldBlockList)
  34843. }
  34844. if m.group_block_list != nil {
  34845. fields = append(fields, whatsapp.FieldGroupBlockList)
  34846. }
  34847. return fields
  34848. }
  34849. // Field returns the value of a field with the given name. The second boolean
  34850. // return value indicates that this field was not set, or was not defined in the
  34851. // schema.
  34852. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  34853. switch name {
  34854. case whatsapp.FieldCreatedAt:
  34855. return m.CreatedAt()
  34856. case whatsapp.FieldUpdatedAt:
  34857. return m.UpdatedAt()
  34858. case whatsapp.FieldStatus:
  34859. return m.Status()
  34860. case whatsapp.FieldDeletedAt:
  34861. return m.DeletedAt()
  34862. case whatsapp.FieldWaID:
  34863. return m.WaID()
  34864. case whatsapp.FieldCallback:
  34865. return m.Callback()
  34866. case whatsapp.FieldAgentID:
  34867. return m.AgentID()
  34868. case whatsapp.FieldAccount:
  34869. return m.Account()
  34870. case whatsapp.FieldNickname:
  34871. return m.Nickname()
  34872. case whatsapp.FieldPhone:
  34873. return m.Phone()
  34874. case whatsapp.FieldPhoneName:
  34875. return m.PhoneName()
  34876. case whatsapp.FieldPhoneStatus:
  34877. return m.PhoneStatus()
  34878. case whatsapp.FieldOrganizationID:
  34879. return m.OrganizationID()
  34880. case whatsapp.FieldAPIBase:
  34881. return m.APIBase()
  34882. case whatsapp.FieldAPIKey:
  34883. return m.APIKey()
  34884. case whatsapp.FieldAllowList:
  34885. return m.AllowList()
  34886. case whatsapp.FieldGroupAllowList:
  34887. return m.GroupAllowList()
  34888. case whatsapp.FieldBlockList:
  34889. return m.BlockList()
  34890. case whatsapp.FieldGroupBlockList:
  34891. return m.GroupBlockList()
  34892. }
  34893. return nil, false
  34894. }
  34895. // OldField returns the old value of the field from the database. An error is
  34896. // returned if the mutation operation is not UpdateOne, or the query to the
  34897. // database failed.
  34898. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34899. switch name {
  34900. case whatsapp.FieldCreatedAt:
  34901. return m.OldCreatedAt(ctx)
  34902. case whatsapp.FieldUpdatedAt:
  34903. return m.OldUpdatedAt(ctx)
  34904. case whatsapp.FieldStatus:
  34905. return m.OldStatus(ctx)
  34906. case whatsapp.FieldDeletedAt:
  34907. return m.OldDeletedAt(ctx)
  34908. case whatsapp.FieldWaID:
  34909. return m.OldWaID(ctx)
  34910. case whatsapp.FieldCallback:
  34911. return m.OldCallback(ctx)
  34912. case whatsapp.FieldAgentID:
  34913. return m.OldAgentID(ctx)
  34914. case whatsapp.FieldAccount:
  34915. return m.OldAccount(ctx)
  34916. case whatsapp.FieldNickname:
  34917. return m.OldNickname(ctx)
  34918. case whatsapp.FieldPhone:
  34919. return m.OldPhone(ctx)
  34920. case whatsapp.FieldPhoneName:
  34921. return m.OldPhoneName(ctx)
  34922. case whatsapp.FieldPhoneStatus:
  34923. return m.OldPhoneStatus(ctx)
  34924. case whatsapp.FieldOrganizationID:
  34925. return m.OldOrganizationID(ctx)
  34926. case whatsapp.FieldAPIBase:
  34927. return m.OldAPIBase(ctx)
  34928. case whatsapp.FieldAPIKey:
  34929. return m.OldAPIKey(ctx)
  34930. case whatsapp.FieldAllowList:
  34931. return m.OldAllowList(ctx)
  34932. case whatsapp.FieldGroupAllowList:
  34933. return m.OldGroupAllowList(ctx)
  34934. case whatsapp.FieldBlockList:
  34935. return m.OldBlockList(ctx)
  34936. case whatsapp.FieldGroupBlockList:
  34937. return m.OldGroupBlockList(ctx)
  34938. }
  34939. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  34940. }
  34941. // SetField sets the value of a field with the given name. It returns an error if
  34942. // the field is not defined in the schema, or if the type mismatched the field
  34943. // type.
  34944. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  34945. switch name {
  34946. case whatsapp.FieldCreatedAt:
  34947. v, ok := value.(time.Time)
  34948. if !ok {
  34949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34950. }
  34951. m.SetCreatedAt(v)
  34952. return nil
  34953. case whatsapp.FieldUpdatedAt:
  34954. v, ok := value.(time.Time)
  34955. if !ok {
  34956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34957. }
  34958. m.SetUpdatedAt(v)
  34959. return nil
  34960. case whatsapp.FieldStatus:
  34961. v, ok := value.(uint8)
  34962. if !ok {
  34963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34964. }
  34965. m.SetStatus(v)
  34966. return nil
  34967. case whatsapp.FieldDeletedAt:
  34968. v, ok := value.(time.Time)
  34969. if !ok {
  34970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34971. }
  34972. m.SetDeletedAt(v)
  34973. return nil
  34974. case whatsapp.FieldWaID:
  34975. v, ok := value.(uint64)
  34976. if !ok {
  34977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34978. }
  34979. m.SetWaID(v)
  34980. return nil
  34981. case whatsapp.FieldCallback:
  34982. v, ok := value.(string)
  34983. if !ok {
  34984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34985. }
  34986. m.SetCallback(v)
  34987. return nil
  34988. case whatsapp.FieldAgentID:
  34989. v, ok := value.(uint64)
  34990. if !ok {
  34991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34992. }
  34993. m.SetAgentID(v)
  34994. return nil
  34995. case whatsapp.FieldAccount:
  34996. v, ok := value.(string)
  34997. if !ok {
  34998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34999. }
  35000. m.SetAccount(v)
  35001. return nil
  35002. case whatsapp.FieldNickname:
  35003. v, ok := value.(string)
  35004. if !ok {
  35005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35006. }
  35007. m.SetNickname(v)
  35008. return nil
  35009. case whatsapp.FieldPhone:
  35010. v, ok := value.(string)
  35011. if !ok {
  35012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35013. }
  35014. m.SetPhone(v)
  35015. return nil
  35016. case whatsapp.FieldPhoneName:
  35017. v, ok := value.(string)
  35018. if !ok {
  35019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35020. }
  35021. m.SetPhoneName(v)
  35022. return nil
  35023. case whatsapp.FieldPhoneStatus:
  35024. v, ok := value.(int8)
  35025. if !ok {
  35026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35027. }
  35028. m.SetPhoneStatus(v)
  35029. return nil
  35030. case whatsapp.FieldOrganizationID:
  35031. v, ok := value.(uint64)
  35032. if !ok {
  35033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35034. }
  35035. m.SetOrganizationID(v)
  35036. return nil
  35037. case whatsapp.FieldAPIBase:
  35038. v, ok := value.(string)
  35039. if !ok {
  35040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35041. }
  35042. m.SetAPIBase(v)
  35043. return nil
  35044. case whatsapp.FieldAPIKey:
  35045. v, ok := value.(string)
  35046. if !ok {
  35047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35048. }
  35049. m.SetAPIKey(v)
  35050. return nil
  35051. case whatsapp.FieldAllowList:
  35052. v, ok := value.([]string)
  35053. if !ok {
  35054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35055. }
  35056. m.SetAllowList(v)
  35057. return nil
  35058. case whatsapp.FieldGroupAllowList:
  35059. v, ok := value.([]string)
  35060. if !ok {
  35061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35062. }
  35063. m.SetGroupAllowList(v)
  35064. return nil
  35065. case whatsapp.FieldBlockList:
  35066. v, ok := value.([]string)
  35067. if !ok {
  35068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35069. }
  35070. m.SetBlockList(v)
  35071. return nil
  35072. case whatsapp.FieldGroupBlockList:
  35073. v, ok := value.([]string)
  35074. if !ok {
  35075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35076. }
  35077. m.SetGroupBlockList(v)
  35078. return nil
  35079. }
  35080. return fmt.Errorf("unknown Whatsapp field %s", name)
  35081. }
  35082. // AddedFields returns all numeric fields that were incremented/decremented during
  35083. // this mutation.
  35084. func (m *WhatsappMutation) AddedFields() []string {
  35085. var fields []string
  35086. if m.addstatus != nil {
  35087. fields = append(fields, whatsapp.FieldStatus)
  35088. }
  35089. if m.addwa_id != nil {
  35090. fields = append(fields, whatsapp.FieldWaID)
  35091. }
  35092. if m.addphone_status != nil {
  35093. fields = append(fields, whatsapp.FieldPhoneStatus)
  35094. }
  35095. if m.addorganization_id != nil {
  35096. fields = append(fields, whatsapp.FieldOrganizationID)
  35097. }
  35098. return fields
  35099. }
  35100. // AddedField returns the numeric value that was incremented/decremented on a field
  35101. // with the given name. The second boolean return value indicates that this field
  35102. // was not set, or was not defined in the schema.
  35103. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  35104. switch name {
  35105. case whatsapp.FieldStatus:
  35106. return m.AddedStatus()
  35107. case whatsapp.FieldWaID:
  35108. return m.AddedWaID()
  35109. case whatsapp.FieldPhoneStatus:
  35110. return m.AddedPhoneStatus()
  35111. case whatsapp.FieldOrganizationID:
  35112. return m.AddedOrganizationID()
  35113. }
  35114. return nil, false
  35115. }
  35116. // AddField adds the value to the field with the given name. It returns an error if
  35117. // the field is not defined in the schema, or if the type mismatched the field
  35118. // type.
  35119. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  35120. switch name {
  35121. case whatsapp.FieldStatus:
  35122. v, ok := value.(int8)
  35123. if !ok {
  35124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35125. }
  35126. m.AddStatus(v)
  35127. return nil
  35128. case whatsapp.FieldWaID:
  35129. v, ok := value.(int64)
  35130. if !ok {
  35131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35132. }
  35133. m.AddWaID(v)
  35134. return nil
  35135. case whatsapp.FieldPhoneStatus:
  35136. v, ok := value.(int8)
  35137. if !ok {
  35138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35139. }
  35140. m.AddPhoneStatus(v)
  35141. return nil
  35142. case whatsapp.FieldOrganizationID:
  35143. v, ok := value.(int64)
  35144. if !ok {
  35145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35146. }
  35147. m.AddOrganizationID(v)
  35148. return nil
  35149. }
  35150. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  35151. }
  35152. // ClearedFields returns all nullable fields that were cleared during this
  35153. // mutation.
  35154. func (m *WhatsappMutation) ClearedFields() []string {
  35155. var fields []string
  35156. if m.FieldCleared(whatsapp.FieldStatus) {
  35157. fields = append(fields, whatsapp.FieldStatus)
  35158. }
  35159. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  35160. fields = append(fields, whatsapp.FieldDeletedAt)
  35161. }
  35162. if m.FieldCleared(whatsapp.FieldWaID) {
  35163. fields = append(fields, whatsapp.FieldWaID)
  35164. }
  35165. if m.FieldCleared(whatsapp.FieldCallback) {
  35166. fields = append(fields, whatsapp.FieldCallback)
  35167. }
  35168. if m.FieldCleared(whatsapp.FieldAccount) {
  35169. fields = append(fields, whatsapp.FieldAccount)
  35170. }
  35171. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  35172. fields = append(fields, whatsapp.FieldOrganizationID)
  35173. }
  35174. if m.FieldCleared(whatsapp.FieldAPIBase) {
  35175. fields = append(fields, whatsapp.FieldAPIBase)
  35176. }
  35177. if m.FieldCleared(whatsapp.FieldAPIKey) {
  35178. fields = append(fields, whatsapp.FieldAPIKey)
  35179. }
  35180. if m.FieldCleared(whatsapp.FieldAllowList) {
  35181. fields = append(fields, whatsapp.FieldAllowList)
  35182. }
  35183. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  35184. fields = append(fields, whatsapp.FieldGroupAllowList)
  35185. }
  35186. if m.FieldCleared(whatsapp.FieldBlockList) {
  35187. fields = append(fields, whatsapp.FieldBlockList)
  35188. }
  35189. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  35190. fields = append(fields, whatsapp.FieldGroupBlockList)
  35191. }
  35192. return fields
  35193. }
  35194. // FieldCleared returns a boolean indicating if a field with the given name was
  35195. // cleared in this mutation.
  35196. func (m *WhatsappMutation) FieldCleared(name string) bool {
  35197. _, ok := m.clearedFields[name]
  35198. return ok
  35199. }
  35200. // ClearField clears the value of the field with the given name. It returns an
  35201. // error if the field is not defined in the schema.
  35202. func (m *WhatsappMutation) ClearField(name string) error {
  35203. switch name {
  35204. case whatsapp.FieldStatus:
  35205. m.ClearStatus()
  35206. return nil
  35207. case whatsapp.FieldDeletedAt:
  35208. m.ClearDeletedAt()
  35209. return nil
  35210. case whatsapp.FieldWaID:
  35211. m.ClearWaID()
  35212. return nil
  35213. case whatsapp.FieldCallback:
  35214. m.ClearCallback()
  35215. return nil
  35216. case whatsapp.FieldAccount:
  35217. m.ClearAccount()
  35218. return nil
  35219. case whatsapp.FieldOrganizationID:
  35220. m.ClearOrganizationID()
  35221. return nil
  35222. case whatsapp.FieldAPIBase:
  35223. m.ClearAPIBase()
  35224. return nil
  35225. case whatsapp.FieldAPIKey:
  35226. m.ClearAPIKey()
  35227. return nil
  35228. case whatsapp.FieldAllowList:
  35229. m.ClearAllowList()
  35230. return nil
  35231. case whatsapp.FieldGroupAllowList:
  35232. m.ClearGroupAllowList()
  35233. return nil
  35234. case whatsapp.FieldBlockList:
  35235. m.ClearBlockList()
  35236. return nil
  35237. case whatsapp.FieldGroupBlockList:
  35238. m.ClearGroupBlockList()
  35239. return nil
  35240. }
  35241. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  35242. }
  35243. // ResetField resets all changes in the mutation for the field with the given name.
  35244. // It returns an error if the field is not defined in the schema.
  35245. func (m *WhatsappMutation) ResetField(name string) error {
  35246. switch name {
  35247. case whatsapp.FieldCreatedAt:
  35248. m.ResetCreatedAt()
  35249. return nil
  35250. case whatsapp.FieldUpdatedAt:
  35251. m.ResetUpdatedAt()
  35252. return nil
  35253. case whatsapp.FieldStatus:
  35254. m.ResetStatus()
  35255. return nil
  35256. case whatsapp.FieldDeletedAt:
  35257. m.ResetDeletedAt()
  35258. return nil
  35259. case whatsapp.FieldWaID:
  35260. m.ResetWaID()
  35261. return nil
  35262. case whatsapp.FieldCallback:
  35263. m.ResetCallback()
  35264. return nil
  35265. case whatsapp.FieldAgentID:
  35266. m.ResetAgentID()
  35267. return nil
  35268. case whatsapp.FieldAccount:
  35269. m.ResetAccount()
  35270. return nil
  35271. case whatsapp.FieldNickname:
  35272. m.ResetNickname()
  35273. return nil
  35274. case whatsapp.FieldPhone:
  35275. m.ResetPhone()
  35276. return nil
  35277. case whatsapp.FieldPhoneName:
  35278. m.ResetPhoneName()
  35279. return nil
  35280. case whatsapp.FieldPhoneStatus:
  35281. m.ResetPhoneStatus()
  35282. return nil
  35283. case whatsapp.FieldOrganizationID:
  35284. m.ResetOrganizationID()
  35285. return nil
  35286. case whatsapp.FieldAPIBase:
  35287. m.ResetAPIBase()
  35288. return nil
  35289. case whatsapp.FieldAPIKey:
  35290. m.ResetAPIKey()
  35291. return nil
  35292. case whatsapp.FieldAllowList:
  35293. m.ResetAllowList()
  35294. return nil
  35295. case whatsapp.FieldGroupAllowList:
  35296. m.ResetGroupAllowList()
  35297. return nil
  35298. case whatsapp.FieldBlockList:
  35299. m.ResetBlockList()
  35300. return nil
  35301. case whatsapp.FieldGroupBlockList:
  35302. m.ResetGroupBlockList()
  35303. return nil
  35304. }
  35305. return fmt.Errorf("unknown Whatsapp field %s", name)
  35306. }
  35307. // AddedEdges returns all edge names that were set/added in this mutation.
  35308. func (m *WhatsappMutation) AddedEdges() []string {
  35309. edges := make([]string, 0, 1)
  35310. if m.agent != nil {
  35311. edges = append(edges, whatsapp.EdgeAgent)
  35312. }
  35313. return edges
  35314. }
  35315. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35316. // name in this mutation.
  35317. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  35318. switch name {
  35319. case whatsapp.EdgeAgent:
  35320. if id := m.agent; id != nil {
  35321. return []ent.Value{*id}
  35322. }
  35323. }
  35324. return nil
  35325. }
  35326. // RemovedEdges returns all edge names that were removed in this mutation.
  35327. func (m *WhatsappMutation) RemovedEdges() []string {
  35328. edges := make([]string, 0, 1)
  35329. return edges
  35330. }
  35331. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35332. // the given name in this mutation.
  35333. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  35334. return nil
  35335. }
  35336. // ClearedEdges returns all edge names that were cleared in this mutation.
  35337. func (m *WhatsappMutation) ClearedEdges() []string {
  35338. edges := make([]string, 0, 1)
  35339. if m.clearedagent {
  35340. edges = append(edges, whatsapp.EdgeAgent)
  35341. }
  35342. return edges
  35343. }
  35344. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35345. // was cleared in this mutation.
  35346. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  35347. switch name {
  35348. case whatsapp.EdgeAgent:
  35349. return m.clearedagent
  35350. }
  35351. return false
  35352. }
  35353. // ClearEdge clears the value of the edge with the given name. It returns an error
  35354. // if that edge is not defined in the schema.
  35355. func (m *WhatsappMutation) ClearEdge(name string) error {
  35356. switch name {
  35357. case whatsapp.EdgeAgent:
  35358. m.ClearAgent()
  35359. return nil
  35360. }
  35361. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  35362. }
  35363. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35364. // It returns an error if the edge is not defined in the schema.
  35365. func (m *WhatsappMutation) ResetEdge(name string) error {
  35366. switch name {
  35367. case whatsapp.EdgeAgent:
  35368. m.ResetAgent()
  35369. return nil
  35370. }
  35371. return fmt.Errorf("unknown Whatsapp edge %s", name)
  35372. }
  35373. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  35374. type WhatsappChannelMutation struct {
  35375. config
  35376. op Op
  35377. typ string
  35378. id *uint64
  35379. created_at *time.Time
  35380. updated_at *time.Time
  35381. status *uint8
  35382. addstatus *int8
  35383. deleted_at *time.Time
  35384. ak *string
  35385. sk *string
  35386. wa_id *uint64
  35387. addwa_id *int64
  35388. wa_name *string
  35389. waba_id *uint64
  35390. addwaba_id *int64
  35391. business_id *uint64
  35392. addbusiness_id *int64
  35393. organization_id *uint64
  35394. addorganization_id *int64
  35395. verify_account *string
  35396. clearedFields map[string]struct{}
  35397. done bool
  35398. oldValue func(context.Context) (*WhatsappChannel, error)
  35399. predicates []predicate.WhatsappChannel
  35400. }
  35401. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  35402. // whatsappchannelOption allows management of the mutation configuration using functional options.
  35403. type whatsappchannelOption func(*WhatsappChannelMutation)
  35404. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  35405. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  35406. m := &WhatsappChannelMutation{
  35407. config: c,
  35408. op: op,
  35409. typ: TypeWhatsappChannel,
  35410. clearedFields: make(map[string]struct{}),
  35411. }
  35412. for _, opt := range opts {
  35413. opt(m)
  35414. }
  35415. return m
  35416. }
  35417. // withWhatsappChannelID sets the ID field of the mutation.
  35418. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  35419. return func(m *WhatsappChannelMutation) {
  35420. var (
  35421. err error
  35422. once sync.Once
  35423. value *WhatsappChannel
  35424. )
  35425. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  35426. once.Do(func() {
  35427. if m.done {
  35428. err = errors.New("querying old values post mutation is not allowed")
  35429. } else {
  35430. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  35431. }
  35432. })
  35433. return value, err
  35434. }
  35435. m.id = &id
  35436. }
  35437. }
  35438. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  35439. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  35440. return func(m *WhatsappChannelMutation) {
  35441. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  35442. return node, nil
  35443. }
  35444. m.id = &node.ID
  35445. }
  35446. }
  35447. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35448. // executed in a transaction (ent.Tx), a transactional client is returned.
  35449. func (m WhatsappChannelMutation) Client() *Client {
  35450. client := &Client{config: m.config}
  35451. client.init()
  35452. return client
  35453. }
  35454. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35455. // it returns an error otherwise.
  35456. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  35457. if _, ok := m.driver.(*txDriver); !ok {
  35458. return nil, errors.New("ent: mutation is not running in a transaction")
  35459. }
  35460. tx := &Tx{config: m.config}
  35461. tx.init()
  35462. return tx, nil
  35463. }
  35464. // SetID sets the value of the id field. Note that this
  35465. // operation is only accepted on creation of WhatsappChannel entities.
  35466. func (m *WhatsappChannelMutation) SetID(id uint64) {
  35467. m.id = &id
  35468. }
  35469. // ID returns the ID value in the mutation. Note that the ID is only available
  35470. // if it was provided to the builder or after it was returned from the database.
  35471. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  35472. if m.id == nil {
  35473. return
  35474. }
  35475. return *m.id, true
  35476. }
  35477. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35478. // That means, if the mutation is applied within a transaction with an isolation level such
  35479. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35480. // or updated by the mutation.
  35481. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  35482. switch {
  35483. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35484. id, exists := m.ID()
  35485. if exists {
  35486. return []uint64{id}, nil
  35487. }
  35488. fallthrough
  35489. case m.op.Is(OpUpdate | OpDelete):
  35490. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  35491. default:
  35492. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35493. }
  35494. }
  35495. // SetCreatedAt sets the "created_at" field.
  35496. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  35497. m.created_at = &t
  35498. }
  35499. // CreatedAt returns the value of the "created_at" field in the mutation.
  35500. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  35501. v := m.created_at
  35502. if v == nil {
  35503. return
  35504. }
  35505. return *v, true
  35506. }
  35507. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  35508. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35510. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35511. if !m.op.Is(OpUpdateOne) {
  35512. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35513. }
  35514. if m.id == nil || m.oldValue == nil {
  35515. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35516. }
  35517. oldValue, err := m.oldValue(ctx)
  35518. if err != nil {
  35519. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35520. }
  35521. return oldValue.CreatedAt, nil
  35522. }
  35523. // ResetCreatedAt resets all changes to the "created_at" field.
  35524. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  35525. m.created_at = nil
  35526. }
  35527. // SetUpdatedAt sets the "updated_at" field.
  35528. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  35529. m.updated_at = &t
  35530. }
  35531. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35532. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  35533. v := m.updated_at
  35534. if v == nil {
  35535. return
  35536. }
  35537. return *v, true
  35538. }
  35539. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  35540. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35542. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35543. if !m.op.Is(OpUpdateOne) {
  35544. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35545. }
  35546. if m.id == nil || m.oldValue == nil {
  35547. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35548. }
  35549. oldValue, err := m.oldValue(ctx)
  35550. if err != nil {
  35551. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35552. }
  35553. return oldValue.UpdatedAt, nil
  35554. }
  35555. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35556. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  35557. m.updated_at = nil
  35558. }
  35559. // SetStatus sets the "status" field.
  35560. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  35561. m.status = &u
  35562. m.addstatus = nil
  35563. }
  35564. // Status returns the value of the "status" field in the mutation.
  35565. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  35566. v := m.status
  35567. if v == nil {
  35568. return
  35569. }
  35570. return *v, true
  35571. }
  35572. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  35573. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35575. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35576. if !m.op.Is(OpUpdateOne) {
  35577. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35578. }
  35579. if m.id == nil || m.oldValue == nil {
  35580. return v, errors.New("OldStatus requires an ID field in the mutation")
  35581. }
  35582. oldValue, err := m.oldValue(ctx)
  35583. if err != nil {
  35584. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35585. }
  35586. return oldValue.Status, nil
  35587. }
  35588. // AddStatus adds u to the "status" field.
  35589. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  35590. if m.addstatus != nil {
  35591. *m.addstatus += u
  35592. } else {
  35593. m.addstatus = &u
  35594. }
  35595. }
  35596. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35597. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  35598. v := m.addstatus
  35599. if v == nil {
  35600. return
  35601. }
  35602. return *v, true
  35603. }
  35604. // ClearStatus clears the value of the "status" field.
  35605. func (m *WhatsappChannelMutation) ClearStatus() {
  35606. m.status = nil
  35607. m.addstatus = nil
  35608. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  35609. }
  35610. // StatusCleared returns if the "status" field was cleared in this mutation.
  35611. func (m *WhatsappChannelMutation) StatusCleared() bool {
  35612. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  35613. return ok
  35614. }
  35615. // ResetStatus resets all changes to the "status" field.
  35616. func (m *WhatsappChannelMutation) ResetStatus() {
  35617. m.status = nil
  35618. m.addstatus = nil
  35619. delete(m.clearedFields, whatsappchannel.FieldStatus)
  35620. }
  35621. // SetDeletedAt sets the "deleted_at" field.
  35622. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  35623. m.deleted_at = &t
  35624. }
  35625. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35626. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  35627. v := m.deleted_at
  35628. if v == nil {
  35629. return
  35630. }
  35631. return *v, true
  35632. }
  35633. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  35634. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35636. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35637. if !m.op.Is(OpUpdateOne) {
  35638. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35639. }
  35640. if m.id == nil || m.oldValue == nil {
  35641. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35642. }
  35643. oldValue, err := m.oldValue(ctx)
  35644. if err != nil {
  35645. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35646. }
  35647. return oldValue.DeletedAt, nil
  35648. }
  35649. // ClearDeletedAt clears the value of the "deleted_at" field.
  35650. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  35651. m.deleted_at = nil
  35652. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  35653. }
  35654. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35655. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  35656. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  35657. return ok
  35658. }
  35659. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35660. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  35661. m.deleted_at = nil
  35662. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  35663. }
  35664. // SetAk sets the "ak" field.
  35665. func (m *WhatsappChannelMutation) SetAk(s string) {
  35666. m.ak = &s
  35667. }
  35668. // Ak returns the value of the "ak" field in the mutation.
  35669. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  35670. v := m.ak
  35671. if v == nil {
  35672. return
  35673. }
  35674. return *v, true
  35675. }
  35676. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  35677. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35679. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  35680. if !m.op.Is(OpUpdateOne) {
  35681. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  35682. }
  35683. if m.id == nil || m.oldValue == nil {
  35684. return v, errors.New("OldAk requires an ID field in the mutation")
  35685. }
  35686. oldValue, err := m.oldValue(ctx)
  35687. if err != nil {
  35688. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  35689. }
  35690. return oldValue.Ak, nil
  35691. }
  35692. // ClearAk clears the value of the "ak" field.
  35693. func (m *WhatsappChannelMutation) ClearAk() {
  35694. m.ak = nil
  35695. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  35696. }
  35697. // AkCleared returns if the "ak" field was cleared in this mutation.
  35698. func (m *WhatsappChannelMutation) AkCleared() bool {
  35699. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  35700. return ok
  35701. }
  35702. // ResetAk resets all changes to the "ak" field.
  35703. func (m *WhatsappChannelMutation) ResetAk() {
  35704. m.ak = nil
  35705. delete(m.clearedFields, whatsappchannel.FieldAk)
  35706. }
  35707. // SetSk sets the "sk" field.
  35708. func (m *WhatsappChannelMutation) SetSk(s string) {
  35709. m.sk = &s
  35710. }
  35711. // Sk returns the value of the "sk" field in the mutation.
  35712. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  35713. v := m.sk
  35714. if v == nil {
  35715. return
  35716. }
  35717. return *v, true
  35718. }
  35719. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  35720. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35722. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  35723. if !m.op.Is(OpUpdateOne) {
  35724. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  35725. }
  35726. if m.id == nil || m.oldValue == nil {
  35727. return v, errors.New("OldSk requires an ID field in the mutation")
  35728. }
  35729. oldValue, err := m.oldValue(ctx)
  35730. if err != nil {
  35731. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  35732. }
  35733. return oldValue.Sk, nil
  35734. }
  35735. // ResetSk resets all changes to the "sk" field.
  35736. func (m *WhatsappChannelMutation) ResetSk() {
  35737. m.sk = nil
  35738. }
  35739. // SetWaID sets the "wa_id" field.
  35740. func (m *WhatsappChannelMutation) SetWaID(u uint64) {
  35741. m.wa_id = &u
  35742. m.addwa_id = nil
  35743. }
  35744. // WaID returns the value of the "wa_id" field in the mutation.
  35745. func (m *WhatsappChannelMutation) WaID() (r uint64, exists bool) {
  35746. v := m.wa_id
  35747. if v == nil {
  35748. return
  35749. }
  35750. return *v, true
  35751. }
  35752. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  35753. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35755. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v uint64, err error) {
  35756. if !m.op.Is(OpUpdateOne) {
  35757. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  35758. }
  35759. if m.id == nil || m.oldValue == nil {
  35760. return v, errors.New("OldWaID requires an ID field in the mutation")
  35761. }
  35762. oldValue, err := m.oldValue(ctx)
  35763. if err != nil {
  35764. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  35765. }
  35766. return oldValue.WaID, nil
  35767. }
  35768. // AddWaID adds u to the "wa_id" field.
  35769. func (m *WhatsappChannelMutation) AddWaID(u int64) {
  35770. if m.addwa_id != nil {
  35771. *m.addwa_id += u
  35772. } else {
  35773. m.addwa_id = &u
  35774. }
  35775. }
  35776. // AddedWaID returns the value that was added to the "wa_id" field in this mutation.
  35777. func (m *WhatsappChannelMutation) AddedWaID() (r int64, exists bool) {
  35778. v := m.addwa_id
  35779. if v == nil {
  35780. return
  35781. }
  35782. return *v, true
  35783. }
  35784. // ClearWaID clears the value of the "wa_id" field.
  35785. func (m *WhatsappChannelMutation) ClearWaID() {
  35786. m.wa_id = nil
  35787. m.addwa_id = nil
  35788. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  35789. }
  35790. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  35791. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  35792. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  35793. return ok
  35794. }
  35795. // ResetWaID resets all changes to the "wa_id" field.
  35796. func (m *WhatsappChannelMutation) ResetWaID() {
  35797. m.wa_id = nil
  35798. m.addwa_id = nil
  35799. delete(m.clearedFields, whatsappchannel.FieldWaID)
  35800. }
  35801. // SetWaName sets the "wa_name" field.
  35802. func (m *WhatsappChannelMutation) SetWaName(s string) {
  35803. m.wa_name = &s
  35804. }
  35805. // WaName returns the value of the "wa_name" field in the mutation.
  35806. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  35807. v := m.wa_name
  35808. if v == nil {
  35809. return
  35810. }
  35811. return *v, true
  35812. }
  35813. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  35814. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35816. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  35817. if !m.op.Is(OpUpdateOne) {
  35818. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  35819. }
  35820. if m.id == nil || m.oldValue == nil {
  35821. return v, errors.New("OldWaName requires an ID field in the mutation")
  35822. }
  35823. oldValue, err := m.oldValue(ctx)
  35824. if err != nil {
  35825. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  35826. }
  35827. return oldValue.WaName, nil
  35828. }
  35829. // ClearWaName clears the value of the "wa_name" field.
  35830. func (m *WhatsappChannelMutation) ClearWaName() {
  35831. m.wa_name = nil
  35832. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  35833. }
  35834. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  35835. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  35836. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  35837. return ok
  35838. }
  35839. // ResetWaName resets all changes to the "wa_name" field.
  35840. func (m *WhatsappChannelMutation) ResetWaName() {
  35841. m.wa_name = nil
  35842. delete(m.clearedFields, whatsappchannel.FieldWaName)
  35843. }
  35844. // SetWabaID sets the "waba_id" field.
  35845. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  35846. m.waba_id = &u
  35847. m.addwaba_id = nil
  35848. }
  35849. // WabaID returns the value of the "waba_id" field in the mutation.
  35850. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  35851. v := m.waba_id
  35852. if v == nil {
  35853. return
  35854. }
  35855. return *v, true
  35856. }
  35857. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  35858. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35860. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  35861. if !m.op.Is(OpUpdateOne) {
  35862. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  35863. }
  35864. if m.id == nil || m.oldValue == nil {
  35865. return v, errors.New("OldWabaID requires an ID field in the mutation")
  35866. }
  35867. oldValue, err := m.oldValue(ctx)
  35868. if err != nil {
  35869. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  35870. }
  35871. return oldValue.WabaID, nil
  35872. }
  35873. // AddWabaID adds u to the "waba_id" field.
  35874. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  35875. if m.addwaba_id != nil {
  35876. *m.addwaba_id += u
  35877. } else {
  35878. m.addwaba_id = &u
  35879. }
  35880. }
  35881. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  35882. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  35883. v := m.addwaba_id
  35884. if v == nil {
  35885. return
  35886. }
  35887. return *v, true
  35888. }
  35889. // ResetWabaID resets all changes to the "waba_id" field.
  35890. func (m *WhatsappChannelMutation) ResetWabaID() {
  35891. m.waba_id = nil
  35892. m.addwaba_id = nil
  35893. }
  35894. // SetBusinessID sets the "business_id" field.
  35895. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  35896. m.business_id = &u
  35897. m.addbusiness_id = nil
  35898. }
  35899. // BusinessID returns the value of the "business_id" field in the mutation.
  35900. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  35901. v := m.business_id
  35902. if v == nil {
  35903. return
  35904. }
  35905. return *v, true
  35906. }
  35907. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  35908. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35910. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  35911. if !m.op.Is(OpUpdateOne) {
  35912. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  35913. }
  35914. if m.id == nil || m.oldValue == nil {
  35915. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  35916. }
  35917. oldValue, err := m.oldValue(ctx)
  35918. if err != nil {
  35919. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  35920. }
  35921. return oldValue.BusinessID, nil
  35922. }
  35923. // AddBusinessID adds u to the "business_id" field.
  35924. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  35925. if m.addbusiness_id != nil {
  35926. *m.addbusiness_id += u
  35927. } else {
  35928. m.addbusiness_id = &u
  35929. }
  35930. }
  35931. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  35932. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  35933. v := m.addbusiness_id
  35934. if v == nil {
  35935. return
  35936. }
  35937. return *v, true
  35938. }
  35939. // ResetBusinessID resets all changes to the "business_id" field.
  35940. func (m *WhatsappChannelMutation) ResetBusinessID() {
  35941. m.business_id = nil
  35942. m.addbusiness_id = nil
  35943. }
  35944. // SetOrganizationID sets the "organization_id" field.
  35945. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  35946. m.organization_id = &u
  35947. m.addorganization_id = nil
  35948. }
  35949. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35950. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  35951. v := m.organization_id
  35952. if v == nil {
  35953. return
  35954. }
  35955. return *v, true
  35956. }
  35957. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  35958. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35960. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35961. if !m.op.Is(OpUpdateOne) {
  35962. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35963. }
  35964. if m.id == nil || m.oldValue == nil {
  35965. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35966. }
  35967. oldValue, err := m.oldValue(ctx)
  35968. if err != nil {
  35969. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35970. }
  35971. return oldValue.OrganizationID, nil
  35972. }
  35973. // AddOrganizationID adds u to the "organization_id" field.
  35974. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  35975. if m.addorganization_id != nil {
  35976. *m.addorganization_id += u
  35977. } else {
  35978. m.addorganization_id = &u
  35979. }
  35980. }
  35981. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35982. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  35983. v := m.addorganization_id
  35984. if v == nil {
  35985. return
  35986. }
  35987. return *v, true
  35988. }
  35989. // ClearOrganizationID clears the value of the "organization_id" field.
  35990. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  35991. m.organization_id = nil
  35992. m.addorganization_id = nil
  35993. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  35994. }
  35995. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35996. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  35997. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  35998. return ok
  35999. }
  36000. // ResetOrganizationID resets all changes to the "organization_id" field.
  36001. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  36002. m.organization_id = nil
  36003. m.addorganization_id = nil
  36004. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  36005. }
  36006. // SetVerifyAccount sets the "verify_account" field.
  36007. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  36008. m.verify_account = &s
  36009. }
  36010. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  36011. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  36012. v := m.verify_account
  36013. if v == nil {
  36014. return
  36015. }
  36016. return *v, true
  36017. }
  36018. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  36019. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36021. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  36022. if !m.op.Is(OpUpdateOne) {
  36023. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  36024. }
  36025. if m.id == nil || m.oldValue == nil {
  36026. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  36027. }
  36028. oldValue, err := m.oldValue(ctx)
  36029. if err != nil {
  36030. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  36031. }
  36032. return oldValue.VerifyAccount, nil
  36033. }
  36034. // ResetVerifyAccount resets all changes to the "verify_account" field.
  36035. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  36036. m.verify_account = nil
  36037. }
  36038. // Where appends a list predicates to the WhatsappChannelMutation builder.
  36039. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  36040. m.predicates = append(m.predicates, ps...)
  36041. }
  36042. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  36043. // users can use type-assertion to append predicates that do not depend on any generated package.
  36044. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  36045. p := make([]predicate.WhatsappChannel, len(ps))
  36046. for i := range ps {
  36047. p[i] = ps[i]
  36048. }
  36049. m.Where(p...)
  36050. }
  36051. // Op returns the operation name.
  36052. func (m *WhatsappChannelMutation) Op() Op {
  36053. return m.op
  36054. }
  36055. // SetOp allows setting the mutation operation.
  36056. func (m *WhatsappChannelMutation) SetOp(op Op) {
  36057. m.op = op
  36058. }
  36059. // Type returns the node type of this mutation (WhatsappChannel).
  36060. func (m *WhatsappChannelMutation) Type() string {
  36061. return m.typ
  36062. }
  36063. // Fields returns all fields that were changed during this mutation. Note that in
  36064. // order to get all numeric fields that were incremented/decremented, call
  36065. // AddedFields().
  36066. func (m *WhatsappChannelMutation) Fields() []string {
  36067. fields := make([]string, 0, 12)
  36068. if m.created_at != nil {
  36069. fields = append(fields, whatsappchannel.FieldCreatedAt)
  36070. }
  36071. if m.updated_at != nil {
  36072. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  36073. }
  36074. if m.status != nil {
  36075. fields = append(fields, whatsappchannel.FieldStatus)
  36076. }
  36077. if m.deleted_at != nil {
  36078. fields = append(fields, whatsappchannel.FieldDeletedAt)
  36079. }
  36080. if m.ak != nil {
  36081. fields = append(fields, whatsappchannel.FieldAk)
  36082. }
  36083. if m.sk != nil {
  36084. fields = append(fields, whatsappchannel.FieldSk)
  36085. }
  36086. if m.wa_id != nil {
  36087. fields = append(fields, whatsappchannel.FieldWaID)
  36088. }
  36089. if m.wa_name != nil {
  36090. fields = append(fields, whatsappchannel.FieldWaName)
  36091. }
  36092. if m.waba_id != nil {
  36093. fields = append(fields, whatsappchannel.FieldWabaID)
  36094. }
  36095. if m.business_id != nil {
  36096. fields = append(fields, whatsappchannel.FieldBusinessID)
  36097. }
  36098. if m.organization_id != nil {
  36099. fields = append(fields, whatsappchannel.FieldOrganizationID)
  36100. }
  36101. if m.verify_account != nil {
  36102. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  36103. }
  36104. return fields
  36105. }
  36106. // Field returns the value of a field with the given name. The second boolean
  36107. // return value indicates that this field was not set, or was not defined in the
  36108. // schema.
  36109. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  36110. switch name {
  36111. case whatsappchannel.FieldCreatedAt:
  36112. return m.CreatedAt()
  36113. case whatsappchannel.FieldUpdatedAt:
  36114. return m.UpdatedAt()
  36115. case whatsappchannel.FieldStatus:
  36116. return m.Status()
  36117. case whatsappchannel.FieldDeletedAt:
  36118. return m.DeletedAt()
  36119. case whatsappchannel.FieldAk:
  36120. return m.Ak()
  36121. case whatsappchannel.FieldSk:
  36122. return m.Sk()
  36123. case whatsappchannel.FieldWaID:
  36124. return m.WaID()
  36125. case whatsappchannel.FieldWaName:
  36126. return m.WaName()
  36127. case whatsappchannel.FieldWabaID:
  36128. return m.WabaID()
  36129. case whatsappchannel.FieldBusinessID:
  36130. return m.BusinessID()
  36131. case whatsappchannel.FieldOrganizationID:
  36132. return m.OrganizationID()
  36133. case whatsappchannel.FieldVerifyAccount:
  36134. return m.VerifyAccount()
  36135. }
  36136. return nil, false
  36137. }
  36138. // OldField returns the old value of the field from the database. An error is
  36139. // returned if the mutation operation is not UpdateOne, or the query to the
  36140. // database failed.
  36141. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36142. switch name {
  36143. case whatsappchannel.FieldCreatedAt:
  36144. return m.OldCreatedAt(ctx)
  36145. case whatsappchannel.FieldUpdatedAt:
  36146. return m.OldUpdatedAt(ctx)
  36147. case whatsappchannel.FieldStatus:
  36148. return m.OldStatus(ctx)
  36149. case whatsappchannel.FieldDeletedAt:
  36150. return m.OldDeletedAt(ctx)
  36151. case whatsappchannel.FieldAk:
  36152. return m.OldAk(ctx)
  36153. case whatsappchannel.FieldSk:
  36154. return m.OldSk(ctx)
  36155. case whatsappchannel.FieldWaID:
  36156. return m.OldWaID(ctx)
  36157. case whatsappchannel.FieldWaName:
  36158. return m.OldWaName(ctx)
  36159. case whatsappchannel.FieldWabaID:
  36160. return m.OldWabaID(ctx)
  36161. case whatsappchannel.FieldBusinessID:
  36162. return m.OldBusinessID(ctx)
  36163. case whatsappchannel.FieldOrganizationID:
  36164. return m.OldOrganizationID(ctx)
  36165. case whatsappchannel.FieldVerifyAccount:
  36166. return m.OldVerifyAccount(ctx)
  36167. }
  36168. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  36169. }
  36170. // SetField sets the value of a field with the given name. It returns an error if
  36171. // the field is not defined in the schema, or if the type mismatched the field
  36172. // type.
  36173. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  36174. switch name {
  36175. case whatsappchannel.FieldCreatedAt:
  36176. v, ok := value.(time.Time)
  36177. if !ok {
  36178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36179. }
  36180. m.SetCreatedAt(v)
  36181. return nil
  36182. case whatsappchannel.FieldUpdatedAt:
  36183. v, ok := value.(time.Time)
  36184. if !ok {
  36185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36186. }
  36187. m.SetUpdatedAt(v)
  36188. return nil
  36189. case whatsappchannel.FieldStatus:
  36190. v, ok := value.(uint8)
  36191. if !ok {
  36192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36193. }
  36194. m.SetStatus(v)
  36195. return nil
  36196. case whatsappchannel.FieldDeletedAt:
  36197. v, ok := value.(time.Time)
  36198. if !ok {
  36199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36200. }
  36201. m.SetDeletedAt(v)
  36202. return nil
  36203. case whatsappchannel.FieldAk:
  36204. v, ok := value.(string)
  36205. if !ok {
  36206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36207. }
  36208. m.SetAk(v)
  36209. return nil
  36210. case whatsappchannel.FieldSk:
  36211. v, ok := value.(string)
  36212. if !ok {
  36213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36214. }
  36215. m.SetSk(v)
  36216. return nil
  36217. case whatsappchannel.FieldWaID:
  36218. v, ok := value.(uint64)
  36219. if !ok {
  36220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36221. }
  36222. m.SetWaID(v)
  36223. return nil
  36224. case whatsappchannel.FieldWaName:
  36225. v, ok := value.(string)
  36226. if !ok {
  36227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36228. }
  36229. m.SetWaName(v)
  36230. return nil
  36231. case whatsappchannel.FieldWabaID:
  36232. v, ok := value.(uint64)
  36233. if !ok {
  36234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36235. }
  36236. m.SetWabaID(v)
  36237. return nil
  36238. case whatsappchannel.FieldBusinessID:
  36239. v, ok := value.(uint64)
  36240. if !ok {
  36241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36242. }
  36243. m.SetBusinessID(v)
  36244. return nil
  36245. case whatsappchannel.FieldOrganizationID:
  36246. v, ok := value.(uint64)
  36247. if !ok {
  36248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36249. }
  36250. m.SetOrganizationID(v)
  36251. return nil
  36252. case whatsappchannel.FieldVerifyAccount:
  36253. v, ok := value.(string)
  36254. if !ok {
  36255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36256. }
  36257. m.SetVerifyAccount(v)
  36258. return nil
  36259. }
  36260. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  36261. }
  36262. // AddedFields returns all numeric fields that were incremented/decremented during
  36263. // this mutation.
  36264. func (m *WhatsappChannelMutation) AddedFields() []string {
  36265. var fields []string
  36266. if m.addstatus != nil {
  36267. fields = append(fields, whatsappchannel.FieldStatus)
  36268. }
  36269. if m.addwa_id != nil {
  36270. fields = append(fields, whatsappchannel.FieldWaID)
  36271. }
  36272. if m.addwaba_id != nil {
  36273. fields = append(fields, whatsappchannel.FieldWabaID)
  36274. }
  36275. if m.addbusiness_id != nil {
  36276. fields = append(fields, whatsappchannel.FieldBusinessID)
  36277. }
  36278. if m.addorganization_id != nil {
  36279. fields = append(fields, whatsappchannel.FieldOrganizationID)
  36280. }
  36281. return fields
  36282. }
  36283. // AddedField returns the numeric value that was incremented/decremented on a field
  36284. // with the given name. The second boolean return value indicates that this field
  36285. // was not set, or was not defined in the schema.
  36286. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  36287. switch name {
  36288. case whatsappchannel.FieldStatus:
  36289. return m.AddedStatus()
  36290. case whatsappchannel.FieldWaID:
  36291. return m.AddedWaID()
  36292. case whatsappchannel.FieldWabaID:
  36293. return m.AddedWabaID()
  36294. case whatsappchannel.FieldBusinessID:
  36295. return m.AddedBusinessID()
  36296. case whatsappchannel.FieldOrganizationID:
  36297. return m.AddedOrganizationID()
  36298. }
  36299. return nil, false
  36300. }
  36301. // AddField adds the value to the field with the given name. It returns an error if
  36302. // the field is not defined in the schema, or if the type mismatched the field
  36303. // type.
  36304. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  36305. switch name {
  36306. case whatsappchannel.FieldStatus:
  36307. v, ok := value.(int8)
  36308. if !ok {
  36309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36310. }
  36311. m.AddStatus(v)
  36312. return nil
  36313. case whatsappchannel.FieldWaID:
  36314. v, ok := value.(int64)
  36315. if !ok {
  36316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36317. }
  36318. m.AddWaID(v)
  36319. return nil
  36320. case whatsappchannel.FieldWabaID:
  36321. v, ok := value.(int64)
  36322. if !ok {
  36323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36324. }
  36325. m.AddWabaID(v)
  36326. return nil
  36327. case whatsappchannel.FieldBusinessID:
  36328. v, ok := value.(int64)
  36329. if !ok {
  36330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36331. }
  36332. m.AddBusinessID(v)
  36333. return nil
  36334. case whatsappchannel.FieldOrganizationID:
  36335. v, ok := value.(int64)
  36336. if !ok {
  36337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36338. }
  36339. m.AddOrganizationID(v)
  36340. return nil
  36341. }
  36342. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  36343. }
  36344. // ClearedFields returns all nullable fields that were cleared during this
  36345. // mutation.
  36346. func (m *WhatsappChannelMutation) ClearedFields() []string {
  36347. var fields []string
  36348. if m.FieldCleared(whatsappchannel.FieldStatus) {
  36349. fields = append(fields, whatsappchannel.FieldStatus)
  36350. }
  36351. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  36352. fields = append(fields, whatsappchannel.FieldDeletedAt)
  36353. }
  36354. if m.FieldCleared(whatsappchannel.FieldAk) {
  36355. fields = append(fields, whatsappchannel.FieldAk)
  36356. }
  36357. if m.FieldCleared(whatsappchannel.FieldWaID) {
  36358. fields = append(fields, whatsappchannel.FieldWaID)
  36359. }
  36360. if m.FieldCleared(whatsappchannel.FieldWaName) {
  36361. fields = append(fields, whatsappchannel.FieldWaName)
  36362. }
  36363. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  36364. fields = append(fields, whatsappchannel.FieldOrganizationID)
  36365. }
  36366. return fields
  36367. }
  36368. // FieldCleared returns a boolean indicating if a field with the given name was
  36369. // cleared in this mutation.
  36370. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  36371. _, ok := m.clearedFields[name]
  36372. return ok
  36373. }
  36374. // ClearField clears the value of the field with the given name. It returns an
  36375. // error if the field is not defined in the schema.
  36376. func (m *WhatsappChannelMutation) ClearField(name string) error {
  36377. switch name {
  36378. case whatsappchannel.FieldStatus:
  36379. m.ClearStatus()
  36380. return nil
  36381. case whatsappchannel.FieldDeletedAt:
  36382. m.ClearDeletedAt()
  36383. return nil
  36384. case whatsappchannel.FieldAk:
  36385. m.ClearAk()
  36386. return nil
  36387. case whatsappchannel.FieldWaID:
  36388. m.ClearWaID()
  36389. return nil
  36390. case whatsappchannel.FieldWaName:
  36391. m.ClearWaName()
  36392. return nil
  36393. case whatsappchannel.FieldOrganizationID:
  36394. m.ClearOrganizationID()
  36395. return nil
  36396. }
  36397. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  36398. }
  36399. // ResetField resets all changes in the mutation for the field with the given name.
  36400. // It returns an error if the field is not defined in the schema.
  36401. func (m *WhatsappChannelMutation) ResetField(name string) error {
  36402. switch name {
  36403. case whatsappchannel.FieldCreatedAt:
  36404. m.ResetCreatedAt()
  36405. return nil
  36406. case whatsappchannel.FieldUpdatedAt:
  36407. m.ResetUpdatedAt()
  36408. return nil
  36409. case whatsappchannel.FieldStatus:
  36410. m.ResetStatus()
  36411. return nil
  36412. case whatsappchannel.FieldDeletedAt:
  36413. m.ResetDeletedAt()
  36414. return nil
  36415. case whatsappchannel.FieldAk:
  36416. m.ResetAk()
  36417. return nil
  36418. case whatsappchannel.FieldSk:
  36419. m.ResetSk()
  36420. return nil
  36421. case whatsappchannel.FieldWaID:
  36422. m.ResetWaID()
  36423. return nil
  36424. case whatsappchannel.FieldWaName:
  36425. m.ResetWaName()
  36426. return nil
  36427. case whatsappchannel.FieldWabaID:
  36428. m.ResetWabaID()
  36429. return nil
  36430. case whatsappchannel.FieldBusinessID:
  36431. m.ResetBusinessID()
  36432. return nil
  36433. case whatsappchannel.FieldOrganizationID:
  36434. m.ResetOrganizationID()
  36435. return nil
  36436. case whatsappchannel.FieldVerifyAccount:
  36437. m.ResetVerifyAccount()
  36438. return nil
  36439. }
  36440. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  36441. }
  36442. // AddedEdges returns all edge names that were set/added in this mutation.
  36443. func (m *WhatsappChannelMutation) AddedEdges() []string {
  36444. edges := make([]string, 0, 0)
  36445. return edges
  36446. }
  36447. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36448. // name in this mutation.
  36449. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  36450. return nil
  36451. }
  36452. // RemovedEdges returns all edge names that were removed in this mutation.
  36453. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  36454. edges := make([]string, 0, 0)
  36455. return edges
  36456. }
  36457. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36458. // the given name in this mutation.
  36459. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  36460. return nil
  36461. }
  36462. // ClearedEdges returns all edge names that were cleared in this mutation.
  36463. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  36464. edges := make([]string, 0, 0)
  36465. return edges
  36466. }
  36467. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36468. // was cleared in this mutation.
  36469. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  36470. return false
  36471. }
  36472. // ClearEdge clears the value of the edge with the given name. It returns an error
  36473. // if that edge is not defined in the schema.
  36474. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  36475. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  36476. }
  36477. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36478. // It returns an error if the edge is not defined in the schema.
  36479. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  36480. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  36481. }
  36482. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  36483. type WorkExperienceMutation struct {
  36484. config
  36485. op Op
  36486. typ string
  36487. id *uint64
  36488. created_at *time.Time
  36489. updated_at *time.Time
  36490. deleted_at *time.Time
  36491. start_date *time.Time
  36492. end_date *time.Time
  36493. company *string
  36494. experience *string
  36495. organization_id *uint64
  36496. addorganization_id *int64
  36497. clearedFields map[string]struct{}
  36498. employee *uint64
  36499. clearedemployee bool
  36500. done bool
  36501. oldValue func(context.Context) (*WorkExperience, error)
  36502. predicates []predicate.WorkExperience
  36503. }
  36504. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  36505. // workexperienceOption allows management of the mutation configuration using functional options.
  36506. type workexperienceOption func(*WorkExperienceMutation)
  36507. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  36508. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  36509. m := &WorkExperienceMutation{
  36510. config: c,
  36511. op: op,
  36512. typ: TypeWorkExperience,
  36513. clearedFields: make(map[string]struct{}),
  36514. }
  36515. for _, opt := range opts {
  36516. opt(m)
  36517. }
  36518. return m
  36519. }
  36520. // withWorkExperienceID sets the ID field of the mutation.
  36521. func withWorkExperienceID(id uint64) workexperienceOption {
  36522. return func(m *WorkExperienceMutation) {
  36523. var (
  36524. err error
  36525. once sync.Once
  36526. value *WorkExperience
  36527. )
  36528. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  36529. once.Do(func() {
  36530. if m.done {
  36531. err = errors.New("querying old values post mutation is not allowed")
  36532. } else {
  36533. value, err = m.Client().WorkExperience.Get(ctx, id)
  36534. }
  36535. })
  36536. return value, err
  36537. }
  36538. m.id = &id
  36539. }
  36540. }
  36541. // withWorkExperience sets the old WorkExperience of the mutation.
  36542. func withWorkExperience(node *WorkExperience) workexperienceOption {
  36543. return func(m *WorkExperienceMutation) {
  36544. m.oldValue = func(context.Context) (*WorkExperience, error) {
  36545. return node, nil
  36546. }
  36547. m.id = &node.ID
  36548. }
  36549. }
  36550. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36551. // executed in a transaction (ent.Tx), a transactional client is returned.
  36552. func (m WorkExperienceMutation) Client() *Client {
  36553. client := &Client{config: m.config}
  36554. client.init()
  36555. return client
  36556. }
  36557. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36558. // it returns an error otherwise.
  36559. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  36560. if _, ok := m.driver.(*txDriver); !ok {
  36561. return nil, errors.New("ent: mutation is not running in a transaction")
  36562. }
  36563. tx := &Tx{config: m.config}
  36564. tx.init()
  36565. return tx, nil
  36566. }
  36567. // SetID sets the value of the id field. Note that this
  36568. // operation is only accepted on creation of WorkExperience entities.
  36569. func (m *WorkExperienceMutation) SetID(id uint64) {
  36570. m.id = &id
  36571. }
  36572. // ID returns the ID value in the mutation. Note that the ID is only available
  36573. // if it was provided to the builder or after it was returned from the database.
  36574. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  36575. if m.id == nil {
  36576. return
  36577. }
  36578. return *m.id, true
  36579. }
  36580. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36581. // That means, if the mutation is applied within a transaction with an isolation level such
  36582. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36583. // or updated by the mutation.
  36584. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  36585. switch {
  36586. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36587. id, exists := m.ID()
  36588. if exists {
  36589. return []uint64{id}, nil
  36590. }
  36591. fallthrough
  36592. case m.op.Is(OpUpdate | OpDelete):
  36593. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  36594. default:
  36595. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36596. }
  36597. }
  36598. // SetCreatedAt sets the "created_at" field.
  36599. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  36600. m.created_at = &t
  36601. }
  36602. // CreatedAt returns the value of the "created_at" field in the mutation.
  36603. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  36604. v := m.created_at
  36605. if v == nil {
  36606. return
  36607. }
  36608. return *v, true
  36609. }
  36610. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  36611. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36613. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36614. if !m.op.Is(OpUpdateOne) {
  36615. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36616. }
  36617. if m.id == nil || m.oldValue == nil {
  36618. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36619. }
  36620. oldValue, err := m.oldValue(ctx)
  36621. if err != nil {
  36622. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36623. }
  36624. return oldValue.CreatedAt, nil
  36625. }
  36626. // ResetCreatedAt resets all changes to the "created_at" field.
  36627. func (m *WorkExperienceMutation) ResetCreatedAt() {
  36628. m.created_at = nil
  36629. }
  36630. // SetUpdatedAt sets the "updated_at" field.
  36631. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  36632. m.updated_at = &t
  36633. }
  36634. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36635. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  36636. v := m.updated_at
  36637. if v == nil {
  36638. return
  36639. }
  36640. return *v, true
  36641. }
  36642. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  36643. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36645. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36646. if !m.op.Is(OpUpdateOne) {
  36647. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36648. }
  36649. if m.id == nil || m.oldValue == nil {
  36650. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36651. }
  36652. oldValue, err := m.oldValue(ctx)
  36653. if err != nil {
  36654. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36655. }
  36656. return oldValue.UpdatedAt, nil
  36657. }
  36658. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36659. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  36660. m.updated_at = nil
  36661. }
  36662. // SetDeletedAt sets the "deleted_at" field.
  36663. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  36664. m.deleted_at = &t
  36665. }
  36666. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36667. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  36668. v := m.deleted_at
  36669. if v == nil {
  36670. return
  36671. }
  36672. return *v, true
  36673. }
  36674. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  36675. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36677. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36678. if !m.op.Is(OpUpdateOne) {
  36679. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36680. }
  36681. if m.id == nil || m.oldValue == nil {
  36682. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36683. }
  36684. oldValue, err := m.oldValue(ctx)
  36685. if err != nil {
  36686. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36687. }
  36688. return oldValue.DeletedAt, nil
  36689. }
  36690. // ClearDeletedAt clears the value of the "deleted_at" field.
  36691. func (m *WorkExperienceMutation) ClearDeletedAt() {
  36692. m.deleted_at = nil
  36693. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  36694. }
  36695. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36696. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  36697. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  36698. return ok
  36699. }
  36700. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36701. func (m *WorkExperienceMutation) ResetDeletedAt() {
  36702. m.deleted_at = nil
  36703. delete(m.clearedFields, workexperience.FieldDeletedAt)
  36704. }
  36705. // SetEmployeeID sets the "employee_id" field.
  36706. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  36707. m.employee = &u
  36708. }
  36709. // EmployeeID returns the value of the "employee_id" field in the mutation.
  36710. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  36711. v := m.employee
  36712. if v == nil {
  36713. return
  36714. }
  36715. return *v, true
  36716. }
  36717. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  36718. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36720. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  36721. if !m.op.Is(OpUpdateOne) {
  36722. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  36723. }
  36724. if m.id == nil || m.oldValue == nil {
  36725. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  36726. }
  36727. oldValue, err := m.oldValue(ctx)
  36728. if err != nil {
  36729. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  36730. }
  36731. return oldValue.EmployeeID, nil
  36732. }
  36733. // ResetEmployeeID resets all changes to the "employee_id" field.
  36734. func (m *WorkExperienceMutation) ResetEmployeeID() {
  36735. m.employee = nil
  36736. }
  36737. // SetStartDate sets the "start_date" field.
  36738. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  36739. m.start_date = &t
  36740. }
  36741. // StartDate returns the value of the "start_date" field in the mutation.
  36742. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  36743. v := m.start_date
  36744. if v == nil {
  36745. return
  36746. }
  36747. return *v, true
  36748. }
  36749. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  36750. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36752. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  36753. if !m.op.Is(OpUpdateOne) {
  36754. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  36755. }
  36756. if m.id == nil || m.oldValue == nil {
  36757. return v, errors.New("OldStartDate requires an ID field in the mutation")
  36758. }
  36759. oldValue, err := m.oldValue(ctx)
  36760. if err != nil {
  36761. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  36762. }
  36763. return oldValue.StartDate, nil
  36764. }
  36765. // ResetStartDate resets all changes to the "start_date" field.
  36766. func (m *WorkExperienceMutation) ResetStartDate() {
  36767. m.start_date = nil
  36768. }
  36769. // SetEndDate sets the "end_date" field.
  36770. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  36771. m.end_date = &t
  36772. }
  36773. // EndDate returns the value of the "end_date" field in the mutation.
  36774. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  36775. v := m.end_date
  36776. if v == nil {
  36777. return
  36778. }
  36779. return *v, true
  36780. }
  36781. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  36782. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36784. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  36785. if !m.op.Is(OpUpdateOne) {
  36786. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  36787. }
  36788. if m.id == nil || m.oldValue == nil {
  36789. return v, errors.New("OldEndDate requires an ID field in the mutation")
  36790. }
  36791. oldValue, err := m.oldValue(ctx)
  36792. if err != nil {
  36793. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  36794. }
  36795. return oldValue.EndDate, nil
  36796. }
  36797. // ResetEndDate resets all changes to the "end_date" field.
  36798. func (m *WorkExperienceMutation) ResetEndDate() {
  36799. m.end_date = nil
  36800. }
  36801. // SetCompany sets the "company" field.
  36802. func (m *WorkExperienceMutation) SetCompany(s string) {
  36803. m.company = &s
  36804. }
  36805. // Company returns the value of the "company" field in the mutation.
  36806. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  36807. v := m.company
  36808. if v == nil {
  36809. return
  36810. }
  36811. return *v, true
  36812. }
  36813. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  36814. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36816. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  36817. if !m.op.Is(OpUpdateOne) {
  36818. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  36819. }
  36820. if m.id == nil || m.oldValue == nil {
  36821. return v, errors.New("OldCompany requires an ID field in the mutation")
  36822. }
  36823. oldValue, err := m.oldValue(ctx)
  36824. if err != nil {
  36825. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  36826. }
  36827. return oldValue.Company, nil
  36828. }
  36829. // ResetCompany resets all changes to the "company" field.
  36830. func (m *WorkExperienceMutation) ResetCompany() {
  36831. m.company = nil
  36832. }
  36833. // SetExperience sets the "experience" field.
  36834. func (m *WorkExperienceMutation) SetExperience(s string) {
  36835. m.experience = &s
  36836. }
  36837. // Experience returns the value of the "experience" field in the mutation.
  36838. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  36839. v := m.experience
  36840. if v == nil {
  36841. return
  36842. }
  36843. return *v, true
  36844. }
  36845. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  36846. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36848. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  36849. if !m.op.Is(OpUpdateOne) {
  36850. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  36851. }
  36852. if m.id == nil || m.oldValue == nil {
  36853. return v, errors.New("OldExperience requires an ID field in the mutation")
  36854. }
  36855. oldValue, err := m.oldValue(ctx)
  36856. if err != nil {
  36857. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  36858. }
  36859. return oldValue.Experience, nil
  36860. }
  36861. // ResetExperience resets all changes to the "experience" field.
  36862. func (m *WorkExperienceMutation) ResetExperience() {
  36863. m.experience = nil
  36864. }
  36865. // SetOrganizationID sets the "organization_id" field.
  36866. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  36867. m.organization_id = &u
  36868. m.addorganization_id = nil
  36869. }
  36870. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36871. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  36872. v := m.organization_id
  36873. if v == nil {
  36874. return
  36875. }
  36876. return *v, true
  36877. }
  36878. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  36879. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36881. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36882. if !m.op.Is(OpUpdateOne) {
  36883. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36884. }
  36885. if m.id == nil || m.oldValue == nil {
  36886. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36887. }
  36888. oldValue, err := m.oldValue(ctx)
  36889. if err != nil {
  36890. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36891. }
  36892. return oldValue.OrganizationID, nil
  36893. }
  36894. // AddOrganizationID adds u to the "organization_id" field.
  36895. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  36896. if m.addorganization_id != nil {
  36897. *m.addorganization_id += u
  36898. } else {
  36899. m.addorganization_id = &u
  36900. }
  36901. }
  36902. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36903. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  36904. v := m.addorganization_id
  36905. if v == nil {
  36906. return
  36907. }
  36908. return *v, true
  36909. }
  36910. // ResetOrganizationID resets all changes to the "organization_id" field.
  36911. func (m *WorkExperienceMutation) ResetOrganizationID() {
  36912. m.organization_id = nil
  36913. m.addorganization_id = nil
  36914. }
  36915. // ClearEmployee clears the "employee" edge to the Employee entity.
  36916. func (m *WorkExperienceMutation) ClearEmployee() {
  36917. m.clearedemployee = true
  36918. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  36919. }
  36920. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  36921. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  36922. return m.clearedemployee
  36923. }
  36924. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  36925. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  36926. // EmployeeID instead. It exists only for internal usage by the builders.
  36927. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  36928. if id := m.employee; id != nil {
  36929. ids = append(ids, *id)
  36930. }
  36931. return
  36932. }
  36933. // ResetEmployee resets all changes to the "employee" edge.
  36934. func (m *WorkExperienceMutation) ResetEmployee() {
  36935. m.employee = nil
  36936. m.clearedemployee = false
  36937. }
  36938. // Where appends a list predicates to the WorkExperienceMutation builder.
  36939. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  36940. m.predicates = append(m.predicates, ps...)
  36941. }
  36942. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  36943. // users can use type-assertion to append predicates that do not depend on any generated package.
  36944. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  36945. p := make([]predicate.WorkExperience, len(ps))
  36946. for i := range ps {
  36947. p[i] = ps[i]
  36948. }
  36949. m.Where(p...)
  36950. }
  36951. // Op returns the operation name.
  36952. func (m *WorkExperienceMutation) Op() Op {
  36953. return m.op
  36954. }
  36955. // SetOp allows setting the mutation operation.
  36956. func (m *WorkExperienceMutation) SetOp(op Op) {
  36957. m.op = op
  36958. }
  36959. // Type returns the node type of this mutation (WorkExperience).
  36960. func (m *WorkExperienceMutation) Type() string {
  36961. return m.typ
  36962. }
  36963. // Fields returns all fields that were changed during this mutation. Note that in
  36964. // order to get all numeric fields that were incremented/decremented, call
  36965. // AddedFields().
  36966. func (m *WorkExperienceMutation) Fields() []string {
  36967. fields := make([]string, 0, 9)
  36968. if m.created_at != nil {
  36969. fields = append(fields, workexperience.FieldCreatedAt)
  36970. }
  36971. if m.updated_at != nil {
  36972. fields = append(fields, workexperience.FieldUpdatedAt)
  36973. }
  36974. if m.deleted_at != nil {
  36975. fields = append(fields, workexperience.FieldDeletedAt)
  36976. }
  36977. if m.employee != nil {
  36978. fields = append(fields, workexperience.FieldEmployeeID)
  36979. }
  36980. if m.start_date != nil {
  36981. fields = append(fields, workexperience.FieldStartDate)
  36982. }
  36983. if m.end_date != nil {
  36984. fields = append(fields, workexperience.FieldEndDate)
  36985. }
  36986. if m.company != nil {
  36987. fields = append(fields, workexperience.FieldCompany)
  36988. }
  36989. if m.experience != nil {
  36990. fields = append(fields, workexperience.FieldExperience)
  36991. }
  36992. if m.organization_id != nil {
  36993. fields = append(fields, workexperience.FieldOrganizationID)
  36994. }
  36995. return fields
  36996. }
  36997. // Field returns the value of a field with the given name. The second boolean
  36998. // return value indicates that this field was not set, or was not defined in the
  36999. // schema.
  37000. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  37001. switch name {
  37002. case workexperience.FieldCreatedAt:
  37003. return m.CreatedAt()
  37004. case workexperience.FieldUpdatedAt:
  37005. return m.UpdatedAt()
  37006. case workexperience.FieldDeletedAt:
  37007. return m.DeletedAt()
  37008. case workexperience.FieldEmployeeID:
  37009. return m.EmployeeID()
  37010. case workexperience.FieldStartDate:
  37011. return m.StartDate()
  37012. case workexperience.FieldEndDate:
  37013. return m.EndDate()
  37014. case workexperience.FieldCompany:
  37015. return m.Company()
  37016. case workexperience.FieldExperience:
  37017. return m.Experience()
  37018. case workexperience.FieldOrganizationID:
  37019. return m.OrganizationID()
  37020. }
  37021. return nil, false
  37022. }
  37023. // OldField returns the old value of the field from the database. An error is
  37024. // returned if the mutation operation is not UpdateOne, or the query to the
  37025. // database failed.
  37026. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37027. switch name {
  37028. case workexperience.FieldCreatedAt:
  37029. return m.OldCreatedAt(ctx)
  37030. case workexperience.FieldUpdatedAt:
  37031. return m.OldUpdatedAt(ctx)
  37032. case workexperience.FieldDeletedAt:
  37033. return m.OldDeletedAt(ctx)
  37034. case workexperience.FieldEmployeeID:
  37035. return m.OldEmployeeID(ctx)
  37036. case workexperience.FieldStartDate:
  37037. return m.OldStartDate(ctx)
  37038. case workexperience.FieldEndDate:
  37039. return m.OldEndDate(ctx)
  37040. case workexperience.FieldCompany:
  37041. return m.OldCompany(ctx)
  37042. case workexperience.FieldExperience:
  37043. return m.OldExperience(ctx)
  37044. case workexperience.FieldOrganizationID:
  37045. return m.OldOrganizationID(ctx)
  37046. }
  37047. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  37048. }
  37049. // SetField sets the value of a field with the given name. It returns an error if
  37050. // the field is not defined in the schema, or if the type mismatched the field
  37051. // type.
  37052. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  37053. switch name {
  37054. case workexperience.FieldCreatedAt:
  37055. v, ok := value.(time.Time)
  37056. if !ok {
  37057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37058. }
  37059. m.SetCreatedAt(v)
  37060. return nil
  37061. case workexperience.FieldUpdatedAt:
  37062. v, ok := value.(time.Time)
  37063. if !ok {
  37064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37065. }
  37066. m.SetUpdatedAt(v)
  37067. return nil
  37068. case workexperience.FieldDeletedAt:
  37069. v, ok := value.(time.Time)
  37070. if !ok {
  37071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37072. }
  37073. m.SetDeletedAt(v)
  37074. return nil
  37075. case workexperience.FieldEmployeeID:
  37076. v, ok := value.(uint64)
  37077. if !ok {
  37078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37079. }
  37080. m.SetEmployeeID(v)
  37081. return nil
  37082. case workexperience.FieldStartDate:
  37083. v, ok := value.(time.Time)
  37084. if !ok {
  37085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37086. }
  37087. m.SetStartDate(v)
  37088. return nil
  37089. case workexperience.FieldEndDate:
  37090. v, ok := value.(time.Time)
  37091. if !ok {
  37092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37093. }
  37094. m.SetEndDate(v)
  37095. return nil
  37096. case workexperience.FieldCompany:
  37097. v, ok := value.(string)
  37098. if !ok {
  37099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37100. }
  37101. m.SetCompany(v)
  37102. return nil
  37103. case workexperience.FieldExperience:
  37104. v, ok := value.(string)
  37105. if !ok {
  37106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37107. }
  37108. m.SetExperience(v)
  37109. return nil
  37110. case workexperience.FieldOrganizationID:
  37111. v, ok := value.(uint64)
  37112. if !ok {
  37113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37114. }
  37115. m.SetOrganizationID(v)
  37116. return nil
  37117. }
  37118. return fmt.Errorf("unknown WorkExperience field %s", name)
  37119. }
  37120. // AddedFields returns all numeric fields that were incremented/decremented during
  37121. // this mutation.
  37122. func (m *WorkExperienceMutation) AddedFields() []string {
  37123. var fields []string
  37124. if m.addorganization_id != nil {
  37125. fields = append(fields, workexperience.FieldOrganizationID)
  37126. }
  37127. return fields
  37128. }
  37129. // AddedField returns the numeric value that was incremented/decremented on a field
  37130. // with the given name. The second boolean return value indicates that this field
  37131. // was not set, or was not defined in the schema.
  37132. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  37133. switch name {
  37134. case workexperience.FieldOrganizationID:
  37135. return m.AddedOrganizationID()
  37136. }
  37137. return nil, false
  37138. }
  37139. // AddField adds the value to the field with the given name. It returns an error if
  37140. // the field is not defined in the schema, or if the type mismatched the field
  37141. // type.
  37142. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  37143. switch name {
  37144. case workexperience.FieldOrganizationID:
  37145. v, ok := value.(int64)
  37146. if !ok {
  37147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37148. }
  37149. m.AddOrganizationID(v)
  37150. return nil
  37151. }
  37152. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  37153. }
  37154. // ClearedFields returns all nullable fields that were cleared during this
  37155. // mutation.
  37156. func (m *WorkExperienceMutation) ClearedFields() []string {
  37157. var fields []string
  37158. if m.FieldCleared(workexperience.FieldDeletedAt) {
  37159. fields = append(fields, workexperience.FieldDeletedAt)
  37160. }
  37161. return fields
  37162. }
  37163. // FieldCleared returns a boolean indicating if a field with the given name was
  37164. // cleared in this mutation.
  37165. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  37166. _, ok := m.clearedFields[name]
  37167. return ok
  37168. }
  37169. // ClearField clears the value of the field with the given name. It returns an
  37170. // error if the field is not defined in the schema.
  37171. func (m *WorkExperienceMutation) ClearField(name string) error {
  37172. switch name {
  37173. case workexperience.FieldDeletedAt:
  37174. m.ClearDeletedAt()
  37175. return nil
  37176. }
  37177. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  37178. }
  37179. // ResetField resets all changes in the mutation for the field with the given name.
  37180. // It returns an error if the field is not defined in the schema.
  37181. func (m *WorkExperienceMutation) ResetField(name string) error {
  37182. switch name {
  37183. case workexperience.FieldCreatedAt:
  37184. m.ResetCreatedAt()
  37185. return nil
  37186. case workexperience.FieldUpdatedAt:
  37187. m.ResetUpdatedAt()
  37188. return nil
  37189. case workexperience.FieldDeletedAt:
  37190. m.ResetDeletedAt()
  37191. return nil
  37192. case workexperience.FieldEmployeeID:
  37193. m.ResetEmployeeID()
  37194. return nil
  37195. case workexperience.FieldStartDate:
  37196. m.ResetStartDate()
  37197. return nil
  37198. case workexperience.FieldEndDate:
  37199. m.ResetEndDate()
  37200. return nil
  37201. case workexperience.FieldCompany:
  37202. m.ResetCompany()
  37203. return nil
  37204. case workexperience.FieldExperience:
  37205. m.ResetExperience()
  37206. return nil
  37207. case workexperience.FieldOrganizationID:
  37208. m.ResetOrganizationID()
  37209. return nil
  37210. }
  37211. return fmt.Errorf("unknown WorkExperience field %s", name)
  37212. }
  37213. // AddedEdges returns all edge names that were set/added in this mutation.
  37214. func (m *WorkExperienceMutation) AddedEdges() []string {
  37215. edges := make([]string, 0, 1)
  37216. if m.employee != nil {
  37217. edges = append(edges, workexperience.EdgeEmployee)
  37218. }
  37219. return edges
  37220. }
  37221. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37222. // name in this mutation.
  37223. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  37224. switch name {
  37225. case workexperience.EdgeEmployee:
  37226. if id := m.employee; id != nil {
  37227. return []ent.Value{*id}
  37228. }
  37229. }
  37230. return nil
  37231. }
  37232. // RemovedEdges returns all edge names that were removed in this mutation.
  37233. func (m *WorkExperienceMutation) RemovedEdges() []string {
  37234. edges := make([]string, 0, 1)
  37235. return edges
  37236. }
  37237. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37238. // the given name in this mutation.
  37239. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  37240. return nil
  37241. }
  37242. // ClearedEdges returns all edge names that were cleared in this mutation.
  37243. func (m *WorkExperienceMutation) ClearedEdges() []string {
  37244. edges := make([]string, 0, 1)
  37245. if m.clearedemployee {
  37246. edges = append(edges, workexperience.EdgeEmployee)
  37247. }
  37248. return edges
  37249. }
  37250. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37251. // was cleared in this mutation.
  37252. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  37253. switch name {
  37254. case workexperience.EdgeEmployee:
  37255. return m.clearedemployee
  37256. }
  37257. return false
  37258. }
  37259. // ClearEdge clears the value of the edge with the given name. It returns an error
  37260. // if that edge is not defined in the schema.
  37261. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  37262. switch name {
  37263. case workexperience.EdgeEmployee:
  37264. m.ClearEmployee()
  37265. return nil
  37266. }
  37267. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  37268. }
  37269. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37270. // It returns an error if the edge is not defined in the schema.
  37271. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  37272. switch name {
  37273. case workexperience.EdgeEmployee:
  37274. m.ResetEmployee()
  37275. return nil
  37276. }
  37277. return fmt.Errorf("unknown WorkExperience edge %s", name)
  37278. }
  37279. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  37280. type WpChatroomMutation struct {
  37281. config
  37282. op Op
  37283. typ string
  37284. id *uint64
  37285. created_at *time.Time
  37286. updated_at *time.Time
  37287. status *uint8
  37288. addstatus *int8
  37289. wx_wxid *string
  37290. chatroom_id *string
  37291. nickname *string
  37292. owner *string
  37293. avatar *string
  37294. member_list *[]string
  37295. appendmember_list []string
  37296. clearedFields map[string]struct{}
  37297. done bool
  37298. oldValue func(context.Context) (*WpChatroom, error)
  37299. predicates []predicate.WpChatroom
  37300. }
  37301. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  37302. // wpchatroomOption allows management of the mutation configuration using functional options.
  37303. type wpchatroomOption func(*WpChatroomMutation)
  37304. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  37305. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  37306. m := &WpChatroomMutation{
  37307. config: c,
  37308. op: op,
  37309. typ: TypeWpChatroom,
  37310. clearedFields: make(map[string]struct{}),
  37311. }
  37312. for _, opt := range opts {
  37313. opt(m)
  37314. }
  37315. return m
  37316. }
  37317. // withWpChatroomID sets the ID field of the mutation.
  37318. func withWpChatroomID(id uint64) wpchatroomOption {
  37319. return func(m *WpChatroomMutation) {
  37320. var (
  37321. err error
  37322. once sync.Once
  37323. value *WpChatroom
  37324. )
  37325. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  37326. once.Do(func() {
  37327. if m.done {
  37328. err = errors.New("querying old values post mutation is not allowed")
  37329. } else {
  37330. value, err = m.Client().WpChatroom.Get(ctx, id)
  37331. }
  37332. })
  37333. return value, err
  37334. }
  37335. m.id = &id
  37336. }
  37337. }
  37338. // withWpChatroom sets the old WpChatroom of the mutation.
  37339. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  37340. return func(m *WpChatroomMutation) {
  37341. m.oldValue = func(context.Context) (*WpChatroom, error) {
  37342. return node, nil
  37343. }
  37344. m.id = &node.ID
  37345. }
  37346. }
  37347. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37348. // executed in a transaction (ent.Tx), a transactional client is returned.
  37349. func (m WpChatroomMutation) Client() *Client {
  37350. client := &Client{config: m.config}
  37351. client.init()
  37352. return client
  37353. }
  37354. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37355. // it returns an error otherwise.
  37356. func (m WpChatroomMutation) Tx() (*Tx, error) {
  37357. if _, ok := m.driver.(*txDriver); !ok {
  37358. return nil, errors.New("ent: mutation is not running in a transaction")
  37359. }
  37360. tx := &Tx{config: m.config}
  37361. tx.init()
  37362. return tx, nil
  37363. }
  37364. // SetID sets the value of the id field. Note that this
  37365. // operation is only accepted on creation of WpChatroom entities.
  37366. func (m *WpChatroomMutation) SetID(id uint64) {
  37367. m.id = &id
  37368. }
  37369. // ID returns the ID value in the mutation. Note that the ID is only available
  37370. // if it was provided to the builder or after it was returned from the database.
  37371. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  37372. if m.id == nil {
  37373. return
  37374. }
  37375. return *m.id, true
  37376. }
  37377. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37378. // That means, if the mutation is applied within a transaction with an isolation level such
  37379. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37380. // or updated by the mutation.
  37381. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  37382. switch {
  37383. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37384. id, exists := m.ID()
  37385. if exists {
  37386. return []uint64{id}, nil
  37387. }
  37388. fallthrough
  37389. case m.op.Is(OpUpdate | OpDelete):
  37390. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  37391. default:
  37392. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37393. }
  37394. }
  37395. // SetCreatedAt sets the "created_at" field.
  37396. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  37397. m.created_at = &t
  37398. }
  37399. // CreatedAt returns the value of the "created_at" field in the mutation.
  37400. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  37401. v := m.created_at
  37402. if v == nil {
  37403. return
  37404. }
  37405. return *v, true
  37406. }
  37407. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  37408. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37410. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37411. if !m.op.Is(OpUpdateOne) {
  37412. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37413. }
  37414. if m.id == nil || m.oldValue == nil {
  37415. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37416. }
  37417. oldValue, err := m.oldValue(ctx)
  37418. if err != nil {
  37419. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37420. }
  37421. return oldValue.CreatedAt, nil
  37422. }
  37423. // ResetCreatedAt resets all changes to the "created_at" field.
  37424. func (m *WpChatroomMutation) ResetCreatedAt() {
  37425. m.created_at = nil
  37426. }
  37427. // SetUpdatedAt sets the "updated_at" field.
  37428. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  37429. m.updated_at = &t
  37430. }
  37431. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37432. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  37433. v := m.updated_at
  37434. if v == nil {
  37435. return
  37436. }
  37437. return *v, true
  37438. }
  37439. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  37440. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37442. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37443. if !m.op.Is(OpUpdateOne) {
  37444. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37445. }
  37446. if m.id == nil || m.oldValue == nil {
  37447. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37448. }
  37449. oldValue, err := m.oldValue(ctx)
  37450. if err != nil {
  37451. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37452. }
  37453. return oldValue.UpdatedAt, nil
  37454. }
  37455. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37456. func (m *WpChatroomMutation) ResetUpdatedAt() {
  37457. m.updated_at = nil
  37458. }
  37459. // SetStatus sets the "status" field.
  37460. func (m *WpChatroomMutation) SetStatus(u uint8) {
  37461. m.status = &u
  37462. m.addstatus = nil
  37463. }
  37464. // Status returns the value of the "status" field in the mutation.
  37465. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  37466. v := m.status
  37467. if v == nil {
  37468. return
  37469. }
  37470. return *v, true
  37471. }
  37472. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  37473. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37475. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37476. if !m.op.Is(OpUpdateOne) {
  37477. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37478. }
  37479. if m.id == nil || m.oldValue == nil {
  37480. return v, errors.New("OldStatus requires an ID field in the mutation")
  37481. }
  37482. oldValue, err := m.oldValue(ctx)
  37483. if err != nil {
  37484. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37485. }
  37486. return oldValue.Status, nil
  37487. }
  37488. // AddStatus adds u to the "status" field.
  37489. func (m *WpChatroomMutation) AddStatus(u int8) {
  37490. if m.addstatus != nil {
  37491. *m.addstatus += u
  37492. } else {
  37493. m.addstatus = &u
  37494. }
  37495. }
  37496. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37497. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  37498. v := m.addstatus
  37499. if v == nil {
  37500. return
  37501. }
  37502. return *v, true
  37503. }
  37504. // ClearStatus clears the value of the "status" field.
  37505. func (m *WpChatroomMutation) ClearStatus() {
  37506. m.status = nil
  37507. m.addstatus = nil
  37508. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  37509. }
  37510. // StatusCleared returns if the "status" field was cleared in this mutation.
  37511. func (m *WpChatroomMutation) StatusCleared() bool {
  37512. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  37513. return ok
  37514. }
  37515. // ResetStatus resets all changes to the "status" field.
  37516. func (m *WpChatroomMutation) ResetStatus() {
  37517. m.status = nil
  37518. m.addstatus = nil
  37519. delete(m.clearedFields, wpchatroom.FieldStatus)
  37520. }
  37521. // SetWxWxid sets the "wx_wxid" field.
  37522. func (m *WpChatroomMutation) SetWxWxid(s string) {
  37523. m.wx_wxid = &s
  37524. }
  37525. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  37526. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  37527. v := m.wx_wxid
  37528. if v == nil {
  37529. return
  37530. }
  37531. return *v, true
  37532. }
  37533. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  37534. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37536. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  37537. if !m.op.Is(OpUpdateOne) {
  37538. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  37539. }
  37540. if m.id == nil || m.oldValue == nil {
  37541. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  37542. }
  37543. oldValue, err := m.oldValue(ctx)
  37544. if err != nil {
  37545. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  37546. }
  37547. return oldValue.WxWxid, nil
  37548. }
  37549. // ResetWxWxid resets all changes to the "wx_wxid" field.
  37550. func (m *WpChatroomMutation) ResetWxWxid() {
  37551. m.wx_wxid = nil
  37552. }
  37553. // SetChatroomID sets the "chatroom_id" field.
  37554. func (m *WpChatroomMutation) SetChatroomID(s string) {
  37555. m.chatroom_id = &s
  37556. }
  37557. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  37558. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  37559. v := m.chatroom_id
  37560. if v == nil {
  37561. return
  37562. }
  37563. return *v, true
  37564. }
  37565. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  37566. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37568. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  37569. if !m.op.Is(OpUpdateOne) {
  37570. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  37571. }
  37572. if m.id == nil || m.oldValue == nil {
  37573. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  37574. }
  37575. oldValue, err := m.oldValue(ctx)
  37576. if err != nil {
  37577. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  37578. }
  37579. return oldValue.ChatroomID, nil
  37580. }
  37581. // ResetChatroomID resets all changes to the "chatroom_id" field.
  37582. func (m *WpChatroomMutation) ResetChatroomID() {
  37583. m.chatroom_id = nil
  37584. }
  37585. // SetNickname sets the "nickname" field.
  37586. func (m *WpChatroomMutation) SetNickname(s string) {
  37587. m.nickname = &s
  37588. }
  37589. // Nickname returns the value of the "nickname" field in the mutation.
  37590. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  37591. v := m.nickname
  37592. if v == nil {
  37593. return
  37594. }
  37595. return *v, true
  37596. }
  37597. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  37598. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37600. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  37601. if !m.op.Is(OpUpdateOne) {
  37602. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  37603. }
  37604. if m.id == nil || m.oldValue == nil {
  37605. return v, errors.New("OldNickname requires an ID field in the mutation")
  37606. }
  37607. oldValue, err := m.oldValue(ctx)
  37608. if err != nil {
  37609. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  37610. }
  37611. return oldValue.Nickname, nil
  37612. }
  37613. // ResetNickname resets all changes to the "nickname" field.
  37614. func (m *WpChatroomMutation) ResetNickname() {
  37615. m.nickname = nil
  37616. }
  37617. // SetOwner sets the "owner" field.
  37618. func (m *WpChatroomMutation) SetOwner(s string) {
  37619. m.owner = &s
  37620. }
  37621. // Owner returns the value of the "owner" field in the mutation.
  37622. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  37623. v := m.owner
  37624. if v == nil {
  37625. return
  37626. }
  37627. return *v, true
  37628. }
  37629. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  37630. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37632. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  37633. if !m.op.Is(OpUpdateOne) {
  37634. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  37635. }
  37636. if m.id == nil || m.oldValue == nil {
  37637. return v, errors.New("OldOwner requires an ID field in the mutation")
  37638. }
  37639. oldValue, err := m.oldValue(ctx)
  37640. if err != nil {
  37641. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  37642. }
  37643. return oldValue.Owner, nil
  37644. }
  37645. // ResetOwner resets all changes to the "owner" field.
  37646. func (m *WpChatroomMutation) ResetOwner() {
  37647. m.owner = nil
  37648. }
  37649. // SetAvatar sets the "avatar" field.
  37650. func (m *WpChatroomMutation) SetAvatar(s string) {
  37651. m.avatar = &s
  37652. }
  37653. // Avatar returns the value of the "avatar" field in the mutation.
  37654. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  37655. v := m.avatar
  37656. if v == nil {
  37657. return
  37658. }
  37659. return *v, true
  37660. }
  37661. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  37662. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37664. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  37665. if !m.op.Is(OpUpdateOne) {
  37666. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  37667. }
  37668. if m.id == nil || m.oldValue == nil {
  37669. return v, errors.New("OldAvatar requires an ID field in the mutation")
  37670. }
  37671. oldValue, err := m.oldValue(ctx)
  37672. if err != nil {
  37673. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  37674. }
  37675. return oldValue.Avatar, nil
  37676. }
  37677. // ResetAvatar resets all changes to the "avatar" field.
  37678. func (m *WpChatroomMutation) ResetAvatar() {
  37679. m.avatar = nil
  37680. }
  37681. // SetMemberList sets the "member_list" field.
  37682. func (m *WpChatroomMutation) SetMemberList(s []string) {
  37683. m.member_list = &s
  37684. m.appendmember_list = nil
  37685. }
  37686. // MemberList returns the value of the "member_list" field in the mutation.
  37687. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  37688. v := m.member_list
  37689. if v == nil {
  37690. return
  37691. }
  37692. return *v, true
  37693. }
  37694. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  37695. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37697. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  37698. if !m.op.Is(OpUpdateOne) {
  37699. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  37700. }
  37701. if m.id == nil || m.oldValue == nil {
  37702. return v, errors.New("OldMemberList requires an ID field in the mutation")
  37703. }
  37704. oldValue, err := m.oldValue(ctx)
  37705. if err != nil {
  37706. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  37707. }
  37708. return oldValue.MemberList, nil
  37709. }
  37710. // AppendMemberList adds s to the "member_list" field.
  37711. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  37712. m.appendmember_list = append(m.appendmember_list, s...)
  37713. }
  37714. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  37715. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  37716. if len(m.appendmember_list) == 0 {
  37717. return nil, false
  37718. }
  37719. return m.appendmember_list, true
  37720. }
  37721. // ResetMemberList resets all changes to the "member_list" field.
  37722. func (m *WpChatroomMutation) ResetMemberList() {
  37723. m.member_list = nil
  37724. m.appendmember_list = nil
  37725. }
  37726. // Where appends a list predicates to the WpChatroomMutation builder.
  37727. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  37728. m.predicates = append(m.predicates, ps...)
  37729. }
  37730. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  37731. // users can use type-assertion to append predicates that do not depend on any generated package.
  37732. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  37733. p := make([]predicate.WpChatroom, len(ps))
  37734. for i := range ps {
  37735. p[i] = ps[i]
  37736. }
  37737. m.Where(p...)
  37738. }
  37739. // Op returns the operation name.
  37740. func (m *WpChatroomMutation) Op() Op {
  37741. return m.op
  37742. }
  37743. // SetOp allows setting the mutation operation.
  37744. func (m *WpChatroomMutation) SetOp(op Op) {
  37745. m.op = op
  37746. }
  37747. // Type returns the node type of this mutation (WpChatroom).
  37748. func (m *WpChatroomMutation) Type() string {
  37749. return m.typ
  37750. }
  37751. // Fields returns all fields that were changed during this mutation. Note that in
  37752. // order to get all numeric fields that were incremented/decremented, call
  37753. // AddedFields().
  37754. func (m *WpChatroomMutation) Fields() []string {
  37755. fields := make([]string, 0, 9)
  37756. if m.created_at != nil {
  37757. fields = append(fields, wpchatroom.FieldCreatedAt)
  37758. }
  37759. if m.updated_at != nil {
  37760. fields = append(fields, wpchatroom.FieldUpdatedAt)
  37761. }
  37762. if m.status != nil {
  37763. fields = append(fields, wpchatroom.FieldStatus)
  37764. }
  37765. if m.wx_wxid != nil {
  37766. fields = append(fields, wpchatroom.FieldWxWxid)
  37767. }
  37768. if m.chatroom_id != nil {
  37769. fields = append(fields, wpchatroom.FieldChatroomID)
  37770. }
  37771. if m.nickname != nil {
  37772. fields = append(fields, wpchatroom.FieldNickname)
  37773. }
  37774. if m.owner != nil {
  37775. fields = append(fields, wpchatroom.FieldOwner)
  37776. }
  37777. if m.avatar != nil {
  37778. fields = append(fields, wpchatroom.FieldAvatar)
  37779. }
  37780. if m.member_list != nil {
  37781. fields = append(fields, wpchatroom.FieldMemberList)
  37782. }
  37783. return fields
  37784. }
  37785. // Field returns the value of a field with the given name. The second boolean
  37786. // return value indicates that this field was not set, or was not defined in the
  37787. // schema.
  37788. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  37789. switch name {
  37790. case wpchatroom.FieldCreatedAt:
  37791. return m.CreatedAt()
  37792. case wpchatroom.FieldUpdatedAt:
  37793. return m.UpdatedAt()
  37794. case wpchatroom.FieldStatus:
  37795. return m.Status()
  37796. case wpchatroom.FieldWxWxid:
  37797. return m.WxWxid()
  37798. case wpchatroom.FieldChatroomID:
  37799. return m.ChatroomID()
  37800. case wpchatroom.FieldNickname:
  37801. return m.Nickname()
  37802. case wpchatroom.FieldOwner:
  37803. return m.Owner()
  37804. case wpchatroom.FieldAvatar:
  37805. return m.Avatar()
  37806. case wpchatroom.FieldMemberList:
  37807. return m.MemberList()
  37808. }
  37809. return nil, false
  37810. }
  37811. // OldField returns the old value of the field from the database. An error is
  37812. // returned if the mutation operation is not UpdateOne, or the query to the
  37813. // database failed.
  37814. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37815. switch name {
  37816. case wpchatroom.FieldCreatedAt:
  37817. return m.OldCreatedAt(ctx)
  37818. case wpchatroom.FieldUpdatedAt:
  37819. return m.OldUpdatedAt(ctx)
  37820. case wpchatroom.FieldStatus:
  37821. return m.OldStatus(ctx)
  37822. case wpchatroom.FieldWxWxid:
  37823. return m.OldWxWxid(ctx)
  37824. case wpchatroom.FieldChatroomID:
  37825. return m.OldChatroomID(ctx)
  37826. case wpchatroom.FieldNickname:
  37827. return m.OldNickname(ctx)
  37828. case wpchatroom.FieldOwner:
  37829. return m.OldOwner(ctx)
  37830. case wpchatroom.FieldAvatar:
  37831. return m.OldAvatar(ctx)
  37832. case wpchatroom.FieldMemberList:
  37833. return m.OldMemberList(ctx)
  37834. }
  37835. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  37836. }
  37837. // SetField sets the value of a field with the given name. It returns an error if
  37838. // the field is not defined in the schema, or if the type mismatched the field
  37839. // type.
  37840. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  37841. switch name {
  37842. case wpchatroom.FieldCreatedAt:
  37843. v, ok := value.(time.Time)
  37844. if !ok {
  37845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37846. }
  37847. m.SetCreatedAt(v)
  37848. return nil
  37849. case wpchatroom.FieldUpdatedAt:
  37850. v, ok := value.(time.Time)
  37851. if !ok {
  37852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37853. }
  37854. m.SetUpdatedAt(v)
  37855. return nil
  37856. case wpchatroom.FieldStatus:
  37857. v, ok := value.(uint8)
  37858. if !ok {
  37859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37860. }
  37861. m.SetStatus(v)
  37862. return nil
  37863. case wpchatroom.FieldWxWxid:
  37864. v, ok := value.(string)
  37865. if !ok {
  37866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37867. }
  37868. m.SetWxWxid(v)
  37869. return nil
  37870. case wpchatroom.FieldChatroomID:
  37871. v, ok := value.(string)
  37872. if !ok {
  37873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37874. }
  37875. m.SetChatroomID(v)
  37876. return nil
  37877. case wpchatroom.FieldNickname:
  37878. v, ok := value.(string)
  37879. if !ok {
  37880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37881. }
  37882. m.SetNickname(v)
  37883. return nil
  37884. case wpchatroom.FieldOwner:
  37885. v, ok := value.(string)
  37886. if !ok {
  37887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37888. }
  37889. m.SetOwner(v)
  37890. return nil
  37891. case wpchatroom.FieldAvatar:
  37892. v, ok := value.(string)
  37893. if !ok {
  37894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37895. }
  37896. m.SetAvatar(v)
  37897. return nil
  37898. case wpchatroom.FieldMemberList:
  37899. v, ok := value.([]string)
  37900. if !ok {
  37901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37902. }
  37903. m.SetMemberList(v)
  37904. return nil
  37905. }
  37906. return fmt.Errorf("unknown WpChatroom field %s", name)
  37907. }
  37908. // AddedFields returns all numeric fields that were incremented/decremented during
  37909. // this mutation.
  37910. func (m *WpChatroomMutation) AddedFields() []string {
  37911. var fields []string
  37912. if m.addstatus != nil {
  37913. fields = append(fields, wpchatroom.FieldStatus)
  37914. }
  37915. return fields
  37916. }
  37917. // AddedField returns the numeric value that was incremented/decremented on a field
  37918. // with the given name. The second boolean return value indicates that this field
  37919. // was not set, or was not defined in the schema.
  37920. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  37921. switch name {
  37922. case wpchatroom.FieldStatus:
  37923. return m.AddedStatus()
  37924. }
  37925. return nil, false
  37926. }
  37927. // AddField adds the value to the field with the given name. It returns an error if
  37928. // the field is not defined in the schema, or if the type mismatched the field
  37929. // type.
  37930. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  37931. switch name {
  37932. case wpchatroom.FieldStatus:
  37933. v, ok := value.(int8)
  37934. if !ok {
  37935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37936. }
  37937. m.AddStatus(v)
  37938. return nil
  37939. }
  37940. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  37941. }
  37942. // ClearedFields returns all nullable fields that were cleared during this
  37943. // mutation.
  37944. func (m *WpChatroomMutation) ClearedFields() []string {
  37945. var fields []string
  37946. if m.FieldCleared(wpchatroom.FieldStatus) {
  37947. fields = append(fields, wpchatroom.FieldStatus)
  37948. }
  37949. return fields
  37950. }
  37951. // FieldCleared returns a boolean indicating if a field with the given name was
  37952. // cleared in this mutation.
  37953. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  37954. _, ok := m.clearedFields[name]
  37955. return ok
  37956. }
  37957. // ClearField clears the value of the field with the given name. It returns an
  37958. // error if the field is not defined in the schema.
  37959. func (m *WpChatroomMutation) ClearField(name string) error {
  37960. switch name {
  37961. case wpchatroom.FieldStatus:
  37962. m.ClearStatus()
  37963. return nil
  37964. }
  37965. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  37966. }
  37967. // ResetField resets all changes in the mutation for the field with the given name.
  37968. // It returns an error if the field is not defined in the schema.
  37969. func (m *WpChatroomMutation) ResetField(name string) error {
  37970. switch name {
  37971. case wpchatroom.FieldCreatedAt:
  37972. m.ResetCreatedAt()
  37973. return nil
  37974. case wpchatroom.FieldUpdatedAt:
  37975. m.ResetUpdatedAt()
  37976. return nil
  37977. case wpchatroom.FieldStatus:
  37978. m.ResetStatus()
  37979. return nil
  37980. case wpchatroom.FieldWxWxid:
  37981. m.ResetWxWxid()
  37982. return nil
  37983. case wpchatroom.FieldChatroomID:
  37984. m.ResetChatroomID()
  37985. return nil
  37986. case wpchatroom.FieldNickname:
  37987. m.ResetNickname()
  37988. return nil
  37989. case wpchatroom.FieldOwner:
  37990. m.ResetOwner()
  37991. return nil
  37992. case wpchatroom.FieldAvatar:
  37993. m.ResetAvatar()
  37994. return nil
  37995. case wpchatroom.FieldMemberList:
  37996. m.ResetMemberList()
  37997. return nil
  37998. }
  37999. return fmt.Errorf("unknown WpChatroom field %s", name)
  38000. }
  38001. // AddedEdges returns all edge names that were set/added in this mutation.
  38002. func (m *WpChatroomMutation) AddedEdges() []string {
  38003. edges := make([]string, 0, 0)
  38004. return edges
  38005. }
  38006. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38007. // name in this mutation.
  38008. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  38009. return nil
  38010. }
  38011. // RemovedEdges returns all edge names that were removed in this mutation.
  38012. func (m *WpChatroomMutation) RemovedEdges() []string {
  38013. edges := make([]string, 0, 0)
  38014. return edges
  38015. }
  38016. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38017. // the given name in this mutation.
  38018. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  38019. return nil
  38020. }
  38021. // ClearedEdges returns all edge names that were cleared in this mutation.
  38022. func (m *WpChatroomMutation) ClearedEdges() []string {
  38023. edges := make([]string, 0, 0)
  38024. return edges
  38025. }
  38026. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38027. // was cleared in this mutation.
  38028. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  38029. return false
  38030. }
  38031. // ClearEdge clears the value of the edge with the given name. It returns an error
  38032. // if that edge is not defined in the schema.
  38033. func (m *WpChatroomMutation) ClearEdge(name string) error {
  38034. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  38035. }
  38036. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38037. // It returns an error if the edge is not defined in the schema.
  38038. func (m *WpChatroomMutation) ResetEdge(name string) error {
  38039. return fmt.Errorf("unknown WpChatroom edge %s", name)
  38040. }
  38041. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  38042. type WpChatroomMemberMutation struct {
  38043. config
  38044. op Op
  38045. typ string
  38046. id *uint64
  38047. created_at *time.Time
  38048. updated_at *time.Time
  38049. status *uint8
  38050. addstatus *int8
  38051. wx_wxid *string
  38052. wxid *string
  38053. nickname *string
  38054. avatar *string
  38055. clearedFields map[string]struct{}
  38056. done bool
  38057. oldValue func(context.Context) (*WpChatroomMember, error)
  38058. predicates []predicate.WpChatroomMember
  38059. }
  38060. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  38061. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  38062. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  38063. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  38064. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  38065. m := &WpChatroomMemberMutation{
  38066. config: c,
  38067. op: op,
  38068. typ: TypeWpChatroomMember,
  38069. clearedFields: make(map[string]struct{}),
  38070. }
  38071. for _, opt := range opts {
  38072. opt(m)
  38073. }
  38074. return m
  38075. }
  38076. // withWpChatroomMemberID sets the ID field of the mutation.
  38077. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  38078. return func(m *WpChatroomMemberMutation) {
  38079. var (
  38080. err error
  38081. once sync.Once
  38082. value *WpChatroomMember
  38083. )
  38084. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  38085. once.Do(func() {
  38086. if m.done {
  38087. err = errors.New("querying old values post mutation is not allowed")
  38088. } else {
  38089. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  38090. }
  38091. })
  38092. return value, err
  38093. }
  38094. m.id = &id
  38095. }
  38096. }
  38097. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  38098. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  38099. return func(m *WpChatroomMemberMutation) {
  38100. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  38101. return node, nil
  38102. }
  38103. m.id = &node.ID
  38104. }
  38105. }
  38106. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38107. // executed in a transaction (ent.Tx), a transactional client is returned.
  38108. func (m WpChatroomMemberMutation) Client() *Client {
  38109. client := &Client{config: m.config}
  38110. client.init()
  38111. return client
  38112. }
  38113. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38114. // it returns an error otherwise.
  38115. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  38116. if _, ok := m.driver.(*txDriver); !ok {
  38117. return nil, errors.New("ent: mutation is not running in a transaction")
  38118. }
  38119. tx := &Tx{config: m.config}
  38120. tx.init()
  38121. return tx, nil
  38122. }
  38123. // SetID sets the value of the id field. Note that this
  38124. // operation is only accepted on creation of WpChatroomMember entities.
  38125. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  38126. m.id = &id
  38127. }
  38128. // ID returns the ID value in the mutation. Note that the ID is only available
  38129. // if it was provided to the builder or after it was returned from the database.
  38130. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  38131. if m.id == nil {
  38132. return
  38133. }
  38134. return *m.id, true
  38135. }
  38136. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38137. // That means, if the mutation is applied within a transaction with an isolation level such
  38138. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38139. // or updated by the mutation.
  38140. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  38141. switch {
  38142. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38143. id, exists := m.ID()
  38144. if exists {
  38145. return []uint64{id}, nil
  38146. }
  38147. fallthrough
  38148. case m.op.Is(OpUpdate | OpDelete):
  38149. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  38150. default:
  38151. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38152. }
  38153. }
  38154. // SetCreatedAt sets the "created_at" field.
  38155. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  38156. m.created_at = &t
  38157. }
  38158. // CreatedAt returns the value of the "created_at" field in the mutation.
  38159. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  38160. v := m.created_at
  38161. if v == nil {
  38162. return
  38163. }
  38164. return *v, true
  38165. }
  38166. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  38167. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38169. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38170. if !m.op.Is(OpUpdateOne) {
  38171. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38172. }
  38173. if m.id == nil || m.oldValue == nil {
  38174. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38175. }
  38176. oldValue, err := m.oldValue(ctx)
  38177. if err != nil {
  38178. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38179. }
  38180. return oldValue.CreatedAt, nil
  38181. }
  38182. // ResetCreatedAt resets all changes to the "created_at" field.
  38183. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  38184. m.created_at = nil
  38185. }
  38186. // SetUpdatedAt sets the "updated_at" field.
  38187. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  38188. m.updated_at = &t
  38189. }
  38190. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38191. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  38192. v := m.updated_at
  38193. if v == nil {
  38194. return
  38195. }
  38196. return *v, true
  38197. }
  38198. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  38199. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38201. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38202. if !m.op.Is(OpUpdateOne) {
  38203. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38204. }
  38205. if m.id == nil || m.oldValue == nil {
  38206. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38207. }
  38208. oldValue, err := m.oldValue(ctx)
  38209. if err != nil {
  38210. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38211. }
  38212. return oldValue.UpdatedAt, nil
  38213. }
  38214. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38215. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  38216. m.updated_at = nil
  38217. }
  38218. // SetStatus sets the "status" field.
  38219. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  38220. m.status = &u
  38221. m.addstatus = nil
  38222. }
  38223. // Status returns the value of the "status" field in the mutation.
  38224. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  38225. v := m.status
  38226. if v == nil {
  38227. return
  38228. }
  38229. return *v, true
  38230. }
  38231. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  38232. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38234. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38235. if !m.op.Is(OpUpdateOne) {
  38236. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38237. }
  38238. if m.id == nil || m.oldValue == nil {
  38239. return v, errors.New("OldStatus requires an ID field in the mutation")
  38240. }
  38241. oldValue, err := m.oldValue(ctx)
  38242. if err != nil {
  38243. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38244. }
  38245. return oldValue.Status, nil
  38246. }
  38247. // AddStatus adds u to the "status" field.
  38248. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  38249. if m.addstatus != nil {
  38250. *m.addstatus += u
  38251. } else {
  38252. m.addstatus = &u
  38253. }
  38254. }
  38255. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38256. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  38257. v := m.addstatus
  38258. if v == nil {
  38259. return
  38260. }
  38261. return *v, true
  38262. }
  38263. // ClearStatus clears the value of the "status" field.
  38264. func (m *WpChatroomMemberMutation) ClearStatus() {
  38265. m.status = nil
  38266. m.addstatus = nil
  38267. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  38268. }
  38269. // StatusCleared returns if the "status" field was cleared in this mutation.
  38270. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  38271. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  38272. return ok
  38273. }
  38274. // ResetStatus resets all changes to the "status" field.
  38275. func (m *WpChatroomMemberMutation) ResetStatus() {
  38276. m.status = nil
  38277. m.addstatus = nil
  38278. delete(m.clearedFields, wpchatroommember.FieldStatus)
  38279. }
  38280. // SetWxWxid sets the "wx_wxid" field.
  38281. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  38282. m.wx_wxid = &s
  38283. }
  38284. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  38285. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  38286. v := m.wx_wxid
  38287. if v == nil {
  38288. return
  38289. }
  38290. return *v, true
  38291. }
  38292. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  38293. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38295. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  38296. if !m.op.Is(OpUpdateOne) {
  38297. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  38298. }
  38299. if m.id == nil || m.oldValue == nil {
  38300. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  38301. }
  38302. oldValue, err := m.oldValue(ctx)
  38303. if err != nil {
  38304. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  38305. }
  38306. return oldValue.WxWxid, nil
  38307. }
  38308. // ResetWxWxid resets all changes to the "wx_wxid" field.
  38309. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  38310. m.wx_wxid = nil
  38311. }
  38312. // SetWxid sets the "wxid" field.
  38313. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  38314. m.wxid = &s
  38315. }
  38316. // Wxid returns the value of the "wxid" field in the mutation.
  38317. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  38318. v := m.wxid
  38319. if v == nil {
  38320. return
  38321. }
  38322. return *v, true
  38323. }
  38324. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  38325. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38327. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  38328. if !m.op.Is(OpUpdateOne) {
  38329. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  38330. }
  38331. if m.id == nil || m.oldValue == nil {
  38332. return v, errors.New("OldWxid requires an ID field in the mutation")
  38333. }
  38334. oldValue, err := m.oldValue(ctx)
  38335. if err != nil {
  38336. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  38337. }
  38338. return oldValue.Wxid, nil
  38339. }
  38340. // ResetWxid resets all changes to the "wxid" field.
  38341. func (m *WpChatroomMemberMutation) ResetWxid() {
  38342. m.wxid = nil
  38343. }
  38344. // SetNickname sets the "nickname" field.
  38345. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  38346. m.nickname = &s
  38347. }
  38348. // Nickname returns the value of the "nickname" field in the mutation.
  38349. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  38350. v := m.nickname
  38351. if v == nil {
  38352. return
  38353. }
  38354. return *v, true
  38355. }
  38356. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  38357. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38359. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  38360. if !m.op.Is(OpUpdateOne) {
  38361. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  38362. }
  38363. if m.id == nil || m.oldValue == nil {
  38364. return v, errors.New("OldNickname requires an ID field in the mutation")
  38365. }
  38366. oldValue, err := m.oldValue(ctx)
  38367. if err != nil {
  38368. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  38369. }
  38370. return oldValue.Nickname, nil
  38371. }
  38372. // ResetNickname resets all changes to the "nickname" field.
  38373. func (m *WpChatroomMemberMutation) ResetNickname() {
  38374. m.nickname = nil
  38375. }
  38376. // SetAvatar sets the "avatar" field.
  38377. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  38378. m.avatar = &s
  38379. }
  38380. // Avatar returns the value of the "avatar" field in the mutation.
  38381. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  38382. v := m.avatar
  38383. if v == nil {
  38384. return
  38385. }
  38386. return *v, true
  38387. }
  38388. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  38389. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38391. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  38392. if !m.op.Is(OpUpdateOne) {
  38393. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  38394. }
  38395. if m.id == nil || m.oldValue == nil {
  38396. return v, errors.New("OldAvatar requires an ID field in the mutation")
  38397. }
  38398. oldValue, err := m.oldValue(ctx)
  38399. if err != nil {
  38400. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  38401. }
  38402. return oldValue.Avatar, nil
  38403. }
  38404. // ResetAvatar resets all changes to the "avatar" field.
  38405. func (m *WpChatroomMemberMutation) ResetAvatar() {
  38406. m.avatar = nil
  38407. }
  38408. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  38409. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  38410. m.predicates = append(m.predicates, ps...)
  38411. }
  38412. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  38413. // users can use type-assertion to append predicates that do not depend on any generated package.
  38414. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  38415. p := make([]predicate.WpChatroomMember, len(ps))
  38416. for i := range ps {
  38417. p[i] = ps[i]
  38418. }
  38419. m.Where(p...)
  38420. }
  38421. // Op returns the operation name.
  38422. func (m *WpChatroomMemberMutation) Op() Op {
  38423. return m.op
  38424. }
  38425. // SetOp allows setting the mutation operation.
  38426. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  38427. m.op = op
  38428. }
  38429. // Type returns the node type of this mutation (WpChatroomMember).
  38430. func (m *WpChatroomMemberMutation) Type() string {
  38431. return m.typ
  38432. }
  38433. // Fields returns all fields that were changed during this mutation. Note that in
  38434. // order to get all numeric fields that were incremented/decremented, call
  38435. // AddedFields().
  38436. func (m *WpChatroomMemberMutation) Fields() []string {
  38437. fields := make([]string, 0, 7)
  38438. if m.created_at != nil {
  38439. fields = append(fields, wpchatroommember.FieldCreatedAt)
  38440. }
  38441. if m.updated_at != nil {
  38442. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  38443. }
  38444. if m.status != nil {
  38445. fields = append(fields, wpchatroommember.FieldStatus)
  38446. }
  38447. if m.wx_wxid != nil {
  38448. fields = append(fields, wpchatroommember.FieldWxWxid)
  38449. }
  38450. if m.wxid != nil {
  38451. fields = append(fields, wpchatroommember.FieldWxid)
  38452. }
  38453. if m.nickname != nil {
  38454. fields = append(fields, wpchatroommember.FieldNickname)
  38455. }
  38456. if m.avatar != nil {
  38457. fields = append(fields, wpchatroommember.FieldAvatar)
  38458. }
  38459. return fields
  38460. }
  38461. // Field returns the value of a field with the given name. The second boolean
  38462. // return value indicates that this field was not set, or was not defined in the
  38463. // schema.
  38464. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  38465. switch name {
  38466. case wpchatroommember.FieldCreatedAt:
  38467. return m.CreatedAt()
  38468. case wpchatroommember.FieldUpdatedAt:
  38469. return m.UpdatedAt()
  38470. case wpchatroommember.FieldStatus:
  38471. return m.Status()
  38472. case wpchatroommember.FieldWxWxid:
  38473. return m.WxWxid()
  38474. case wpchatroommember.FieldWxid:
  38475. return m.Wxid()
  38476. case wpchatroommember.FieldNickname:
  38477. return m.Nickname()
  38478. case wpchatroommember.FieldAvatar:
  38479. return m.Avatar()
  38480. }
  38481. return nil, false
  38482. }
  38483. // OldField returns the old value of the field from the database. An error is
  38484. // returned if the mutation operation is not UpdateOne, or the query to the
  38485. // database failed.
  38486. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38487. switch name {
  38488. case wpchatroommember.FieldCreatedAt:
  38489. return m.OldCreatedAt(ctx)
  38490. case wpchatroommember.FieldUpdatedAt:
  38491. return m.OldUpdatedAt(ctx)
  38492. case wpchatroommember.FieldStatus:
  38493. return m.OldStatus(ctx)
  38494. case wpchatroommember.FieldWxWxid:
  38495. return m.OldWxWxid(ctx)
  38496. case wpchatroommember.FieldWxid:
  38497. return m.OldWxid(ctx)
  38498. case wpchatroommember.FieldNickname:
  38499. return m.OldNickname(ctx)
  38500. case wpchatroommember.FieldAvatar:
  38501. return m.OldAvatar(ctx)
  38502. }
  38503. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  38504. }
  38505. // SetField sets the value of a field with the given name. It returns an error if
  38506. // the field is not defined in the schema, or if the type mismatched the field
  38507. // type.
  38508. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  38509. switch name {
  38510. case wpchatroommember.FieldCreatedAt:
  38511. v, ok := value.(time.Time)
  38512. if !ok {
  38513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38514. }
  38515. m.SetCreatedAt(v)
  38516. return nil
  38517. case wpchatroommember.FieldUpdatedAt:
  38518. v, ok := value.(time.Time)
  38519. if !ok {
  38520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38521. }
  38522. m.SetUpdatedAt(v)
  38523. return nil
  38524. case wpchatroommember.FieldStatus:
  38525. v, ok := value.(uint8)
  38526. if !ok {
  38527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38528. }
  38529. m.SetStatus(v)
  38530. return nil
  38531. case wpchatroommember.FieldWxWxid:
  38532. v, ok := value.(string)
  38533. if !ok {
  38534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38535. }
  38536. m.SetWxWxid(v)
  38537. return nil
  38538. case wpchatroommember.FieldWxid:
  38539. v, ok := value.(string)
  38540. if !ok {
  38541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38542. }
  38543. m.SetWxid(v)
  38544. return nil
  38545. case wpchatroommember.FieldNickname:
  38546. v, ok := value.(string)
  38547. if !ok {
  38548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38549. }
  38550. m.SetNickname(v)
  38551. return nil
  38552. case wpchatroommember.FieldAvatar:
  38553. v, ok := value.(string)
  38554. if !ok {
  38555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38556. }
  38557. m.SetAvatar(v)
  38558. return nil
  38559. }
  38560. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  38561. }
  38562. // AddedFields returns all numeric fields that were incremented/decremented during
  38563. // this mutation.
  38564. func (m *WpChatroomMemberMutation) AddedFields() []string {
  38565. var fields []string
  38566. if m.addstatus != nil {
  38567. fields = append(fields, wpchatroommember.FieldStatus)
  38568. }
  38569. return fields
  38570. }
  38571. // AddedField returns the numeric value that was incremented/decremented on a field
  38572. // with the given name. The second boolean return value indicates that this field
  38573. // was not set, or was not defined in the schema.
  38574. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  38575. switch name {
  38576. case wpchatroommember.FieldStatus:
  38577. return m.AddedStatus()
  38578. }
  38579. return nil, false
  38580. }
  38581. // AddField adds the value to the field with the given name. It returns an error if
  38582. // the field is not defined in the schema, or if the type mismatched the field
  38583. // type.
  38584. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  38585. switch name {
  38586. case wpchatroommember.FieldStatus:
  38587. v, ok := value.(int8)
  38588. if !ok {
  38589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38590. }
  38591. m.AddStatus(v)
  38592. return nil
  38593. }
  38594. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  38595. }
  38596. // ClearedFields returns all nullable fields that were cleared during this
  38597. // mutation.
  38598. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  38599. var fields []string
  38600. if m.FieldCleared(wpchatroommember.FieldStatus) {
  38601. fields = append(fields, wpchatroommember.FieldStatus)
  38602. }
  38603. return fields
  38604. }
  38605. // FieldCleared returns a boolean indicating if a field with the given name was
  38606. // cleared in this mutation.
  38607. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  38608. _, ok := m.clearedFields[name]
  38609. return ok
  38610. }
  38611. // ClearField clears the value of the field with the given name. It returns an
  38612. // error if the field is not defined in the schema.
  38613. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  38614. switch name {
  38615. case wpchatroommember.FieldStatus:
  38616. m.ClearStatus()
  38617. return nil
  38618. }
  38619. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  38620. }
  38621. // ResetField resets all changes in the mutation for the field with the given name.
  38622. // It returns an error if the field is not defined in the schema.
  38623. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  38624. switch name {
  38625. case wpchatroommember.FieldCreatedAt:
  38626. m.ResetCreatedAt()
  38627. return nil
  38628. case wpchatroommember.FieldUpdatedAt:
  38629. m.ResetUpdatedAt()
  38630. return nil
  38631. case wpchatroommember.FieldStatus:
  38632. m.ResetStatus()
  38633. return nil
  38634. case wpchatroommember.FieldWxWxid:
  38635. m.ResetWxWxid()
  38636. return nil
  38637. case wpchatroommember.FieldWxid:
  38638. m.ResetWxid()
  38639. return nil
  38640. case wpchatroommember.FieldNickname:
  38641. m.ResetNickname()
  38642. return nil
  38643. case wpchatroommember.FieldAvatar:
  38644. m.ResetAvatar()
  38645. return nil
  38646. }
  38647. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  38648. }
  38649. // AddedEdges returns all edge names that were set/added in this mutation.
  38650. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  38651. edges := make([]string, 0, 0)
  38652. return edges
  38653. }
  38654. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38655. // name in this mutation.
  38656. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  38657. return nil
  38658. }
  38659. // RemovedEdges returns all edge names that were removed in this mutation.
  38660. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  38661. edges := make([]string, 0, 0)
  38662. return edges
  38663. }
  38664. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38665. // the given name in this mutation.
  38666. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  38667. return nil
  38668. }
  38669. // ClearedEdges returns all edge names that were cleared in this mutation.
  38670. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  38671. edges := make([]string, 0, 0)
  38672. return edges
  38673. }
  38674. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38675. // was cleared in this mutation.
  38676. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  38677. return false
  38678. }
  38679. // ClearEdge clears the value of the edge with the given name. It returns an error
  38680. // if that edge is not defined in the schema.
  38681. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  38682. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  38683. }
  38684. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38685. // It returns an error if the edge is not defined in the schema.
  38686. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  38687. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  38688. }
  38689. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  38690. type WxMutation struct {
  38691. config
  38692. op Op
  38693. typ string
  38694. id *uint64
  38695. created_at *time.Time
  38696. updated_at *time.Time
  38697. status *uint8
  38698. addstatus *int8
  38699. deleted_at *time.Time
  38700. port *string
  38701. process_id *string
  38702. callback *string
  38703. wxid *string
  38704. account *string
  38705. nickname *string
  38706. tel *string
  38707. head_big *string
  38708. organization_id *uint64
  38709. addorganization_id *int64
  38710. api_base *string
  38711. api_key *string
  38712. allow_list *[]string
  38713. appendallow_list []string
  38714. group_allow_list *[]string
  38715. appendgroup_allow_list []string
  38716. block_list *[]string
  38717. appendblock_list []string
  38718. group_block_list *[]string
  38719. appendgroup_block_list []string
  38720. clearedFields map[string]struct{}
  38721. server *uint64
  38722. clearedserver bool
  38723. agent *uint64
  38724. clearedagent bool
  38725. done bool
  38726. oldValue func(context.Context) (*Wx, error)
  38727. predicates []predicate.Wx
  38728. }
  38729. var _ ent.Mutation = (*WxMutation)(nil)
  38730. // wxOption allows management of the mutation configuration using functional options.
  38731. type wxOption func(*WxMutation)
  38732. // newWxMutation creates new mutation for the Wx entity.
  38733. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  38734. m := &WxMutation{
  38735. config: c,
  38736. op: op,
  38737. typ: TypeWx,
  38738. clearedFields: make(map[string]struct{}),
  38739. }
  38740. for _, opt := range opts {
  38741. opt(m)
  38742. }
  38743. return m
  38744. }
  38745. // withWxID sets the ID field of the mutation.
  38746. func withWxID(id uint64) wxOption {
  38747. return func(m *WxMutation) {
  38748. var (
  38749. err error
  38750. once sync.Once
  38751. value *Wx
  38752. )
  38753. m.oldValue = func(ctx context.Context) (*Wx, error) {
  38754. once.Do(func() {
  38755. if m.done {
  38756. err = errors.New("querying old values post mutation is not allowed")
  38757. } else {
  38758. value, err = m.Client().Wx.Get(ctx, id)
  38759. }
  38760. })
  38761. return value, err
  38762. }
  38763. m.id = &id
  38764. }
  38765. }
  38766. // withWx sets the old Wx of the mutation.
  38767. func withWx(node *Wx) wxOption {
  38768. return func(m *WxMutation) {
  38769. m.oldValue = func(context.Context) (*Wx, error) {
  38770. return node, nil
  38771. }
  38772. m.id = &node.ID
  38773. }
  38774. }
  38775. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38776. // executed in a transaction (ent.Tx), a transactional client is returned.
  38777. func (m WxMutation) Client() *Client {
  38778. client := &Client{config: m.config}
  38779. client.init()
  38780. return client
  38781. }
  38782. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38783. // it returns an error otherwise.
  38784. func (m WxMutation) Tx() (*Tx, error) {
  38785. if _, ok := m.driver.(*txDriver); !ok {
  38786. return nil, errors.New("ent: mutation is not running in a transaction")
  38787. }
  38788. tx := &Tx{config: m.config}
  38789. tx.init()
  38790. return tx, nil
  38791. }
  38792. // SetID sets the value of the id field. Note that this
  38793. // operation is only accepted on creation of Wx entities.
  38794. func (m *WxMutation) SetID(id uint64) {
  38795. m.id = &id
  38796. }
  38797. // ID returns the ID value in the mutation. Note that the ID is only available
  38798. // if it was provided to the builder or after it was returned from the database.
  38799. func (m *WxMutation) ID() (id uint64, exists bool) {
  38800. if m.id == nil {
  38801. return
  38802. }
  38803. return *m.id, true
  38804. }
  38805. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38806. // That means, if the mutation is applied within a transaction with an isolation level such
  38807. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38808. // or updated by the mutation.
  38809. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  38810. switch {
  38811. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38812. id, exists := m.ID()
  38813. if exists {
  38814. return []uint64{id}, nil
  38815. }
  38816. fallthrough
  38817. case m.op.Is(OpUpdate | OpDelete):
  38818. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  38819. default:
  38820. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38821. }
  38822. }
  38823. // SetCreatedAt sets the "created_at" field.
  38824. func (m *WxMutation) SetCreatedAt(t time.Time) {
  38825. m.created_at = &t
  38826. }
  38827. // CreatedAt returns the value of the "created_at" field in the mutation.
  38828. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  38829. v := m.created_at
  38830. if v == nil {
  38831. return
  38832. }
  38833. return *v, true
  38834. }
  38835. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  38836. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38838. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38839. if !m.op.Is(OpUpdateOne) {
  38840. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38841. }
  38842. if m.id == nil || m.oldValue == nil {
  38843. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38844. }
  38845. oldValue, err := m.oldValue(ctx)
  38846. if err != nil {
  38847. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38848. }
  38849. return oldValue.CreatedAt, nil
  38850. }
  38851. // ResetCreatedAt resets all changes to the "created_at" field.
  38852. func (m *WxMutation) ResetCreatedAt() {
  38853. m.created_at = nil
  38854. }
  38855. // SetUpdatedAt sets the "updated_at" field.
  38856. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  38857. m.updated_at = &t
  38858. }
  38859. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38860. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  38861. v := m.updated_at
  38862. if v == nil {
  38863. return
  38864. }
  38865. return *v, true
  38866. }
  38867. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  38868. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38870. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38871. if !m.op.Is(OpUpdateOne) {
  38872. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38873. }
  38874. if m.id == nil || m.oldValue == nil {
  38875. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38876. }
  38877. oldValue, err := m.oldValue(ctx)
  38878. if err != nil {
  38879. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38880. }
  38881. return oldValue.UpdatedAt, nil
  38882. }
  38883. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38884. func (m *WxMutation) ResetUpdatedAt() {
  38885. m.updated_at = nil
  38886. }
  38887. // SetStatus sets the "status" field.
  38888. func (m *WxMutation) SetStatus(u uint8) {
  38889. m.status = &u
  38890. m.addstatus = nil
  38891. }
  38892. // Status returns the value of the "status" field in the mutation.
  38893. func (m *WxMutation) Status() (r uint8, exists bool) {
  38894. v := m.status
  38895. if v == nil {
  38896. return
  38897. }
  38898. return *v, true
  38899. }
  38900. // OldStatus returns the old "status" field's value of the Wx entity.
  38901. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38903. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38904. if !m.op.Is(OpUpdateOne) {
  38905. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38906. }
  38907. if m.id == nil || m.oldValue == nil {
  38908. return v, errors.New("OldStatus requires an ID field in the mutation")
  38909. }
  38910. oldValue, err := m.oldValue(ctx)
  38911. if err != nil {
  38912. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38913. }
  38914. return oldValue.Status, nil
  38915. }
  38916. // AddStatus adds u to the "status" field.
  38917. func (m *WxMutation) AddStatus(u int8) {
  38918. if m.addstatus != nil {
  38919. *m.addstatus += u
  38920. } else {
  38921. m.addstatus = &u
  38922. }
  38923. }
  38924. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38925. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  38926. v := m.addstatus
  38927. if v == nil {
  38928. return
  38929. }
  38930. return *v, true
  38931. }
  38932. // ClearStatus clears the value of the "status" field.
  38933. func (m *WxMutation) ClearStatus() {
  38934. m.status = nil
  38935. m.addstatus = nil
  38936. m.clearedFields[wx.FieldStatus] = struct{}{}
  38937. }
  38938. // StatusCleared returns if the "status" field was cleared in this mutation.
  38939. func (m *WxMutation) StatusCleared() bool {
  38940. _, ok := m.clearedFields[wx.FieldStatus]
  38941. return ok
  38942. }
  38943. // ResetStatus resets all changes to the "status" field.
  38944. func (m *WxMutation) ResetStatus() {
  38945. m.status = nil
  38946. m.addstatus = nil
  38947. delete(m.clearedFields, wx.FieldStatus)
  38948. }
  38949. // SetDeletedAt sets the "deleted_at" field.
  38950. func (m *WxMutation) SetDeletedAt(t time.Time) {
  38951. m.deleted_at = &t
  38952. }
  38953. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38954. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  38955. v := m.deleted_at
  38956. if v == nil {
  38957. return
  38958. }
  38959. return *v, true
  38960. }
  38961. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  38962. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38964. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38965. if !m.op.Is(OpUpdateOne) {
  38966. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38967. }
  38968. if m.id == nil || m.oldValue == nil {
  38969. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38970. }
  38971. oldValue, err := m.oldValue(ctx)
  38972. if err != nil {
  38973. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38974. }
  38975. return oldValue.DeletedAt, nil
  38976. }
  38977. // ClearDeletedAt clears the value of the "deleted_at" field.
  38978. func (m *WxMutation) ClearDeletedAt() {
  38979. m.deleted_at = nil
  38980. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  38981. }
  38982. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38983. func (m *WxMutation) DeletedAtCleared() bool {
  38984. _, ok := m.clearedFields[wx.FieldDeletedAt]
  38985. return ok
  38986. }
  38987. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38988. func (m *WxMutation) ResetDeletedAt() {
  38989. m.deleted_at = nil
  38990. delete(m.clearedFields, wx.FieldDeletedAt)
  38991. }
  38992. // SetServerID sets the "server_id" field.
  38993. func (m *WxMutation) SetServerID(u uint64) {
  38994. m.server = &u
  38995. }
  38996. // ServerID returns the value of the "server_id" field in the mutation.
  38997. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  38998. v := m.server
  38999. if v == nil {
  39000. return
  39001. }
  39002. return *v, true
  39003. }
  39004. // OldServerID returns the old "server_id" field's value of the Wx entity.
  39005. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39007. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  39008. if !m.op.Is(OpUpdateOne) {
  39009. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  39010. }
  39011. if m.id == nil || m.oldValue == nil {
  39012. return v, errors.New("OldServerID requires an ID field in the mutation")
  39013. }
  39014. oldValue, err := m.oldValue(ctx)
  39015. if err != nil {
  39016. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  39017. }
  39018. return oldValue.ServerID, nil
  39019. }
  39020. // ClearServerID clears the value of the "server_id" field.
  39021. func (m *WxMutation) ClearServerID() {
  39022. m.server = nil
  39023. m.clearedFields[wx.FieldServerID] = struct{}{}
  39024. }
  39025. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  39026. func (m *WxMutation) ServerIDCleared() bool {
  39027. _, ok := m.clearedFields[wx.FieldServerID]
  39028. return ok
  39029. }
  39030. // ResetServerID resets all changes to the "server_id" field.
  39031. func (m *WxMutation) ResetServerID() {
  39032. m.server = nil
  39033. delete(m.clearedFields, wx.FieldServerID)
  39034. }
  39035. // SetPort sets the "port" field.
  39036. func (m *WxMutation) SetPort(s string) {
  39037. m.port = &s
  39038. }
  39039. // Port returns the value of the "port" field in the mutation.
  39040. func (m *WxMutation) Port() (r string, exists bool) {
  39041. v := m.port
  39042. if v == nil {
  39043. return
  39044. }
  39045. return *v, true
  39046. }
  39047. // OldPort returns the old "port" field's value of the Wx entity.
  39048. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39050. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  39051. if !m.op.Is(OpUpdateOne) {
  39052. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  39053. }
  39054. if m.id == nil || m.oldValue == nil {
  39055. return v, errors.New("OldPort requires an ID field in the mutation")
  39056. }
  39057. oldValue, err := m.oldValue(ctx)
  39058. if err != nil {
  39059. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  39060. }
  39061. return oldValue.Port, nil
  39062. }
  39063. // ResetPort resets all changes to the "port" field.
  39064. func (m *WxMutation) ResetPort() {
  39065. m.port = nil
  39066. }
  39067. // SetProcessID sets the "process_id" field.
  39068. func (m *WxMutation) SetProcessID(s string) {
  39069. m.process_id = &s
  39070. }
  39071. // ProcessID returns the value of the "process_id" field in the mutation.
  39072. func (m *WxMutation) ProcessID() (r string, exists bool) {
  39073. v := m.process_id
  39074. if v == nil {
  39075. return
  39076. }
  39077. return *v, true
  39078. }
  39079. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  39080. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39082. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  39083. if !m.op.Is(OpUpdateOne) {
  39084. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  39085. }
  39086. if m.id == nil || m.oldValue == nil {
  39087. return v, errors.New("OldProcessID requires an ID field in the mutation")
  39088. }
  39089. oldValue, err := m.oldValue(ctx)
  39090. if err != nil {
  39091. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  39092. }
  39093. return oldValue.ProcessID, nil
  39094. }
  39095. // ResetProcessID resets all changes to the "process_id" field.
  39096. func (m *WxMutation) ResetProcessID() {
  39097. m.process_id = nil
  39098. }
  39099. // SetCallback sets the "callback" field.
  39100. func (m *WxMutation) SetCallback(s string) {
  39101. m.callback = &s
  39102. }
  39103. // Callback returns the value of the "callback" field in the mutation.
  39104. func (m *WxMutation) Callback() (r string, exists bool) {
  39105. v := m.callback
  39106. if v == nil {
  39107. return
  39108. }
  39109. return *v, true
  39110. }
  39111. // OldCallback returns the old "callback" field's value of the Wx entity.
  39112. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39114. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  39115. if !m.op.Is(OpUpdateOne) {
  39116. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  39117. }
  39118. if m.id == nil || m.oldValue == nil {
  39119. return v, errors.New("OldCallback requires an ID field in the mutation")
  39120. }
  39121. oldValue, err := m.oldValue(ctx)
  39122. if err != nil {
  39123. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  39124. }
  39125. return oldValue.Callback, nil
  39126. }
  39127. // ResetCallback resets all changes to the "callback" field.
  39128. func (m *WxMutation) ResetCallback() {
  39129. m.callback = nil
  39130. }
  39131. // SetWxid sets the "wxid" field.
  39132. func (m *WxMutation) SetWxid(s string) {
  39133. m.wxid = &s
  39134. }
  39135. // Wxid returns the value of the "wxid" field in the mutation.
  39136. func (m *WxMutation) Wxid() (r string, exists bool) {
  39137. v := m.wxid
  39138. if v == nil {
  39139. return
  39140. }
  39141. return *v, true
  39142. }
  39143. // OldWxid returns the old "wxid" field's value of the Wx entity.
  39144. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39146. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  39147. if !m.op.Is(OpUpdateOne) {
  39148. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  39149. }
  39150. if m.id == nil || m.oldValue == nil {
  39151. return v, errors.New("OldWxid requires an ID field in the mutation")
  39152. }
  39153. oldValue, err := m.oldValue(ctx)
  39154. if err != nil {
  39155. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  39156. }
  39157. return oldValue.Wxid, nil
  39158. }
  39159. // ResetWxid resets all changes to the "wxid" field.
  39160. func (m *WxMutation) ResetWxid() {
  39161. m.wxid = nil
  39162. }
  39163. // SetAccount sets the "account" field.
  39164. func (m *WxMutation) SetAccount(s string) {
  39165. m.account = &s
  39166. }
  39167. // Account returns the value of the "account" field in the mutation.
  39168. func (m *WxMutation) Account() (r string, exists bool) {
  39169. v := m.account
  39170. if v == nil {
  39171. return
  39172. }
  39173. return *v, true
  39174. }
  39175. // OldAccount returns the old "account" field's value of the Wx entity.
  39176. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39178. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  39179. if !m.op.Is(OpUpdateOne) {
  39180. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  39181. }
  39182. if m.id == nil || m.oldValue == nil {
  39183. return v, errors.New("OldAccount requires an ID field in the mutation")
  39184. }
  39185. oldValue, err := m.oldValue(ctx)
  39186. if err != nil {
  39187. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  39188. }
  39189. return oldValue.Account, nil
  39190. }
  39191. // ResetAccount resets all changes to the "account" field.
  39192. func (m *WxMutation) ResetAccount() {
  39193. m.account = nil
  39194. }
  39195. // SetNickname sets the "nickname" field.
  39196. func (m *WxMutation) SetNickname(s string) {
  39197. m.nickname = &s
  39198. }
  39199. // Nickname returns the value of the "nickname" field in the mutation.
  39200. func (m *WxMutation) Nickname() (r string, exists bool) {
  39201. v := m.nickname
  39202. if v == nil {
  39203. return
  39204. }
  39205. return *v, true
  39206. }
  39207. // OldNickname returns the old "nickname" field's value of the Wx entity.
  39208. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39210. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  39211. if !m.op.Is(OpUpdateOne) {
  39212. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39213. }
  39214. if m.id == nil || m.oldValue == nil {
  39215. return v, errors.New("OldNickname requires an ID field in the mutation")
  39216. }
  39217. oldValue, err := m.oldValue(ctx)
  39218. if err != nil {
  39219. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39220. }
  39221. return oldValue.Nickname, nil
  39222. }
  39223. // ResetNickname resets all changes to the "nickname" field.
  39224. func (m *WxMutation) ResetNickname() {
  39225. m.nickname = nil
  39226. }
  39227. // SetTel sets the "tel" field.
  39228. func (m *WxMutation) SetTel(s string) {
  39229. m.tel = &s
  39230. }
  39231. // Tel returns the value of the "tel" field in the mutation.
  39232. func (m *WxMutation) Tel() (r string, exists bool) {
  39233. v := m.tel
  39234. if v == nil {
  39235. return
  39236. }
  39237. return *v, true
  39238. }
  39239. // OldTel returns the old "tel" field's value of the Wx entity.
  39240. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39242. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  39243. if !m.op.Is(OpUpdateOne) {
  39244. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  39245. }
  39246. if m.id == nil || m.oldValue == nil {
  39247. return v, errors.New("OldTel requires an ID field in the mutation")
  39248. }
  39249. oldValue, err := m.oldValue(ctx)
  39250. if err != nil {
  39251. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  39252. }
  39253. return oldValue.Tel, nil
  39254. }
  39255. // ResetTel resets all changes to the "tel" field.
  39256. func (m *WxMutation) ResetTel() {
  39257. m.tel = nil
  39258. }
  39259. // SetHeadBig sets the "head_big" field.
  39260. func (m *WxMutation) SetHeadBig(s string) {
  39261. m.head_big = &s
  39262. }
  39263. // HeadBig returns the value of the "head_big" field in the mutation.
  39264. func (m *WxMutation) HeadBig() (r string, exists bool) {
  39265. v := m.head_big
  39266. if v == nil {
  39267. return
  39268. }
  39269. return *v, true
  39270. }
  39271. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  39272. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39274. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  39275. if !m.op.Is(OpUpdateOne) {
  39276. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  39277. }
  39278. if m.id == nil || m.oldValue == nil {
  39279. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  39280. }
  39281. oldValue, err := m.oldValue(ctx)
  39282. if err != nil {
  39283. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  39284. }
  39285. return oldValue.HeadBig, nil
  39286. }
  39287. // ResetHeadBig resets all changes to the "head_big" field.
  39288. func (m *WxMutation) ResetHeadBig() {
  39289. m.head_big = nil
  39290. }
  39291. // SetOrganizationID sets the "organization_id" field.
  39292. func (m *WxMutation) SetOrganizationID(u uint64) {
  39293. m.organization_id = &u
  39294. m.addorganization_id = nil
  39295. }
  39296. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39297. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  39298. v := m.organization_id
  39299. if v == nil {
  39300. return
  39301. }
  39302. return *v, true
  39303. }
  39304. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  39305. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39307. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39308. if !m.op.Is(OpUpdateOne) {
  39309. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39310. }
  39311. if m.id == nil || m.oldValue == nil {
  39312. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39313. }
  39314. oldValue, err := m.oldValue(ctx)
  39315. if err != nil {
  39316. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39317. }
  39318. return oldValue.OrganizationID, nil
  39319. }
  39320. // AddOrganizationID adds u to the "organization_id" field.
  39321. func (m *WxMutation) AddOrganizationID(u int64) {
  39322. if m.addorganization_id != nil {
  39323. *m.addorganization_id += u
  39324. } else {
  39325. m.addorganization_id = &u
  39326. }
  39327. }
  39328. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39329. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  39330. v := m.addorganization_id
  39331. if v == nil {
  39332. return
  39333. }
  39334. return *v, true
  39335. }
  39336. // ClearOrganizationID clears the value of the "organization_id" field.
  39337. func (m *WxMutation) ClearOrganizationID() {
  39338. m.organization_id = nil
  39339. m.addorganization_id = nil
  39340. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  39341. }
  39342. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39343. func (m *WxMutation) OrganizationIDCleared() bool {
  39344. _, ok := m.clearedFields[wx.FieldOrganizationID]
  39345. return ok
  39346. }
  39347. // ResetOrganizationID resets all changes to the "organization_id" field.
  39348. func (m *WxMutation) ResetOrganizationID() {
  39349. m.organization_id = nil
  39350. m.addorganization_id = nil
  39351. delete(m.clearedFields, wx.FieldOrganizationID)
  39352. }
  39353. // SetAgentID sets the "agent_id" field.
  39354. func (m *WxMutation) SetAgentID(u uint64) {
  39355. m.agent = &u
  39356. }
  39357. // AgentID returns the value of the "agent_id" field in the mutation.
  39358. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  39359. v := m.agent
  39360. if v == nil {
  39361. return
  39362. }
  39363. return *v, true
  39364. }
  39365. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  39366. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39368. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  39369. if !m.op.Is(OpUpdateOne) {
  39370. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  39371. }
  39372. if m.id == nil || m.oldValue == nil {
  39373. return v, errors.New("OldAgentID requires an ID field in the mutation")
  39374. }
  39375. oldValue, err := m.oldValue(ctx)
  39376. if err != nil {
  39377. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  39378. }
  39379. return oldValue.AgentID, nil
  39380. }
  39381. // ResetAgentID resets all changes to the "agent_id" field.
  39382. func (m *WxMutation) ResetAgentID() {
  39383. m.agent = nil
  39384. }
  39385. // SetAPIBase sets the "api_base" field.
  39386. func (m *WxMutation) SetAPIBase(s string) {
  39387. m.api_base = &s
  39388. }
  39389. // APIBase returns the value of the "api_base" field in the mutation.
  39390. func (m *WxMutation) APIBase() (r string, exists bool) {
  39391. v := m.api_base
  39392. if v == nil {
  39393. return
  39394. }
  39395. return *v, true
  39396. }
  39397. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  39398. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39400. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  39401. if !m.op.Is(OpUpdateOne) {
  39402. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  39403. }
  39404. if m.id == nil || m.oldValue == nil {
  39405. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  39406. }
  39407. oldValue, err := m.oldValue(ctx)
  39408. if err != nil {
  39409. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  39410. }
  39411. return oldValue.APIBase, nil
  39412. }
  39413. // ClearAPIBase clears the value of the "api_base" field.
  39414. func (m *WxMutation) ClearAPIBase() {
  39415. m.api_base = nil
  39416. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  39417. }
  39418. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  39419. func (m *WxMutation) APIBaseCleared() bool {
  39420. _, ok := m.clearedFields[wx.FieldAPIBase]
  39421. return ok
  39422. }
  39423. // ResetAPIBase resets all changes to the "api_base" field.
  39424. func (m *WxMutation) ResetAPIBase() {
  39425. m.api_base = nil
  39426. delete(m.clearedFields, wx.FieldAPIBase)
  39427. }
  39428. // SetAPIKey sets the "api_key" field.
  39429. func (m *WxMutation) SetAPIKey(s string) {
  39430. m.api_key = &s
  39431. }
  39432. // APIKey returns the value of the "api_key" field in the mutation.
  39433. func (m *WxMutation) APIKey() (r string, exists bool) {
  39434. v := m.api_key
  39435. if v == nil {
  39436. return
  39437. }
  39438. return *v, true
  39439. }
  39440. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  39441. // If the Wx 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 *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  39444. if !m.op.Is(OpUpdateOne) {
  39445. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  39446. }
  39447. if m.id == nil || m.oldValue == nil {
  39448. return v, errors.New("OldAPIKey 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 OldAPIKey: %w", err)
  39453. }
  39454. return oldValue.APIKey, nil
  39455. }
  39456. // ClearAPIKey clears the value of the "api_key" field.
  39457. func (m *WxMutation) ClearAPIKey() {
  39458. m.api_key = nil
  39459. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  39460. }
  39461. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  39462. func (m *WxMutation) APIKeyCleared() bool {
  39463. _, ok := m.clearedFields[wx.FieldAPIKey]
  39464. return ok
  39465. }
  39466. // ResetAPIKey resets all changes to the "api_key" field.
  39467. func (m *WxMutation) ResetAPIKey() {
  39468. m.api_key = nil
  39469. delete(m.clearedFields, wx.FieldAPIKey)
  39470. }
  39471. // SetAllowList sets the "allow_list" field.
  39472. func (m *WxMutation) SetAllowList(s []string) {
  39473. m.allow_list = &s
  39474. m.appendallow_list = nil
  39475. }
  39476. // AllowList returns the value of the "allow_list" field in the mutation.
  39477. func (m *WxMutation) AllowList() (r []string, exists bool) {
  39478. v := m.allow_list
  39479. if v == nil {
  39480. return
  39481. }
  39482. return *v, true
  39483. }
  39484. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  39485. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39487. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  39488. if !m.op.Is(OpUpdateOne) {
  39489. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  39490. }
  39491. if m.id == nil || m.oldValue == nil {
  39492. return v, errors.New("OldAllowList requires an ID field in the mutation")
  39493. }
  39494. oldValue, err := m.oldValue(ctx)
  39495. if err != nil {
  39496. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  39497. }
  39498. return oldValue.AllowList, nil
  39499. }
  39500. // AppendAllowList adds s to the "allow_list" field.
  39501. func (m *WxMutation) AppendAllowList(s []string) {
  39502. m.appendallow_list = append(m.appendallow_list, s...)
  39503. }
  39504. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  39505. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  39506. if len(m.appendallow_list) == 0 {
  39507. return nil, false
  39508. }
  39509. return m.appendallow_list, true
  39510. }
  39511. // ResetAllowList resets all changes to the "allow_list" field.
  39512. func (m *WxMutation) ResetAllowList() {
  39513. m.allow_list = nil
  39514. m.appendallow_list = nil
  39515. }
  39516. // SetGroupAllowList sets the "group_allow_list" field.
  39517. func (m *WxMutation) SetGroupAllowList(s []string) {
  39518. m.group_allow_list = &s
  39519. m.appendgroup_allow_list = nil
  39520. }
  39521. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  39522. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  39523. v := m.group_allow_list
  39524. if v == nil {
  39525. return
  39526. }
  39527. return *v, true
  39528. }
  39529. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  39530. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39532. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  39533. if !m.op.Is(OpUpdateOne) {
  39534. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  39535. }
  39536. if m.id == nil || m.oldValue == nil {
  39537. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  39538. }
  39539. oldValue, err := m.oldValue(ctx)
  39540. if err != nil {
  39541. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  39542. }
  39543. return oldValue.GroupAllowList, nil
  39544. }
  39545. // AppendGroupAllowList adds s to the "group_allow_list" field.
  39546. func (m *WxMutation) AppendGroupAllowList(s []string) {
  39547. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  39548. }
  39549. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  39550. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  39551. if len(m.appendgroup_allow_list) == 0 {
  39552. return nil, false
  39553. }
  39554. return m.appendgroup_allow_list, true
  39555. }
  39556. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  39557. func (m *WxMutation) ResetGroupAllowList() {
  39558. m.group_allow_list = nil
  39559. m.appendgroup_allow_list = nil
  39560. }
  39561. // SetBlockList sets the "block_list" field.
  39562. func (m *WxMutation) SetBlockList(s []string) {
  39563. m.block_list = &s
  39564. m.appendblock_list = nil
  39565. }
  39566. // BlockList returns the value of the "block_list" field in the mutation.
  39567. func (m *WxMutation) BlockList() (r []string, exists bool) {
  39568. v := m.block_list
  39569. if v == nil {
  39570. return
  39571. }
  39572. return *v, true
  39573. }
  39574. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  39575. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39577. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  39578. if !m.op.Is(OpUpdateOne) {
  39579. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  39580. }
  39581. if m.id == nil || m.oldValue == nil {
  39582. return v, errors.New("OldBlockList requires an ID field in the mutation")
  39583. }
  39584. oldValue, err := m.oldValue(ctx)
  39585. if err != nil {
  39586. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  39587. }
  39588. return oldValue.BlockList, nil
  39589. }
  39590. // AppendBlockList adds s to the "block_list" field.
  39591. func (m *WxMutation) AppendBlockList(s []string) {
  39592. m.appendblock_list = append(m.appendblock_list, s...)
  39593. }
  39594. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  39595. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  39596. if len(m.appendblock_list) == 0 {
  39597. return nil, false
  39598. }
  39599. return m.appendblock_list, true
  39600. }
  39601. // ResetBlockList resets all changes to the "block_list" field.
  39602. func (m *WxMutation) ResetBlockList() {
  39603. m.block_list = nil
  39604. m.appendblock_list = nil
  39605. }
  39606. // SetGroupBlockList sets the "group_block_list" field.
  39607. func (m *WxMutation) SetGroupBlockList(s []string) {
  39608. m.group_block_list = &s
  39609. m.appendgroup_block_list = nil
  39610. }
  39611. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  39612. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  39613. v := m.group_block_list
  39614. if v == nil {
  39615. return
  39616. }
  39617. return *v, true
  39618. }
  39619. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  39620. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39622. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  39623. if !m.op.Is(OpUpdateOne) {
  39624. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  39625. }
  39626. if m.id == nil || m.oldValue == nil {
  39627. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  39628. }
  39629. oldValue, err := m.oldValue(ctx)
  39630. if err != nil {
  39631. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  39632. }
  39633. return oldValue.GroupBlockList, nil
  39634. }
  39635. // AppendGroupBlockList adds s to the "group_block_list" field.
  39636. func (m *WxMutation) AppendGroupBlockList(s []string) {
  39637. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  39638. }
  39639. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  39640. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  39641. if len(m.appendgroup_block_list) == 0 {
  39642. return nil, false
  39643. }
  39644. return m.appendgroup_block_list, true
  39645. }
  39646. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  39647. func (m *WxMutation) ResetGroupBlockList() {
  39648. m.group_block_list = nil
  39649. m.appendgroup_block_list = nil
  39650. }
  39651. // ClearServer clears the "server" edge to the Server entity.
  39652. func (m *WxMutation) ClearServer() {
  39653. m.clearedserver = true
  39654. m.clearedFields[wx.FieldServerID] = struct{}{}
  39655. }
  39656. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  39657. func (m *WxMutation) ServerCleared() bool {
  39658. return m.ServerIDCleared() || m.clearedserver
  39659. }
  39660. // ServerIDs returns the "server" edge IDs in the mutation.
  39661. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39662. // ServerID instead. It exists only for internal usage by the builders.
  39663. func (m *WxMutation) ServerIDs() (ids []uint64) {
  39664. if id := m.server; id != nil {
  39665. ids = append(ids, *id)
  39666. }
  39667. return
  39668. }
  39669. // ResetServer resets all changes to the "server" edge.
  39670. func (m *WxMutation) ResetServer() {
  39671. m.server = nil
  39672. m.clearedserver = false
  39673. }
  39674. // ClearAgent clears the "agent" edge to the Agent entity.
  39675. func (m *WxMutation) ClearAgent() {
  39676. m.clearedagent = true
  39677. m.clearedFields[wx.FieldAgentID] = struct{}{}
  39678. }
  39679. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  39680. func (m *WxMutation) AgentCleared() bool {
  39681. return m.clearedagent
  39682. }
  39683. // AgentIDs returns the "agent" edge IDs in the mutation.
  39684. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39685. // AgentID instead. It exists only for internal usage by the builders.
  39686. func (m *WxMutation) AgentIDs() (ids []uint64) {
  39687. if id := m.agent; id != nil {
  39688. ids = append(ids, *id)
  39689. }
  39690. return
  39691. }
  39692. // ResetAgent resets all changes to the "agent" edge.
  39693. func (m *WxMutation) ResetAgent() {
  39694. m.agent = nil
  39695. m.clearedagent = false
  39696. }
  39697. // Where appends a list predicates to the WxMutation builder.
  39698. func (m *WxMutation) Where(ps ...predicate.Wx) {
  39699. m.predicates = append(m.predicates, ps...)
  39700. }
  39701. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  39702. // users can use type-assertion to append predicates that do not depend on any generated package.
  39703. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  39704. p := make([]predicate.Wx, len(ps))
  39705. for i := range ps {
  39706. p[i] = ps[i]
  39707. }
  39708. m.Where(p...)
  39709. }
  39710. // Op returns the operation name.
  39711. func (m *WxMutation) Op() Op {
  39712. return m.op
  39713. }
  39714. // SetOp allows setting the mutation operation.
  39715. func (m *WxMutation) SetOp(op Op) {
  39716. m.op = op
  39717. }
  39718. // Type returns the node type of this mutation (Wx).
  39719. func (m *WxMutation) Type() string {
  39720. return m.typ
  39721. }
  39722. // Fields returns all fields that were changed during this mutation. Note that in
  39723. // order to get all numeric fields that were incremented/decremented, call
  39724. // AddedFields().
  39725. func (m *WxMutation) Fields() []string {
  39726. fields := make([]string, 0, 21)
  39727. if m.created_at != nil {
  39728. fields = append(fields, wx.FieldCreatedAt)
  39729. }
  39730. if m.updated_at != nil {
  39731. fields = append(fields, wx.FieldUpdatedAt)
  39732. }
  39733. if m.status != nil {
  39734. fields = append(fields, wx.FieldStatus)
  39735. }
  39736. if m.deleted_at != nil {
  39737. fields = append(fields, wx.FieldDeletedAt)
  39738. }
  39739. if m.server != nil {
  39740. fields = append(fields, wx.FieldServerID)
  39741. }
  39742. if m.port != nil {
  39743. fields = append(fields, wx.FieldPort)
  39744. }
  39745. if m.process_id != nil {
  39746. fields = append(fields, wx.FieldProcessID)
  39747. }
  39748. if m.callback != nil {
  39749. fields = append(fields, wx.FieldCallback)
  39750. }
  39751. if m.wxid != nil {
  39752. fields = append(fields, wx.FieldWxid)
  39753. }
  39754. if m.account != nil {
  39755. fields = append(fields, wx.FieldAccount)
  39756. }
  39757. if m.nickname != nil {
  39758. fields = append(fields, wx.FieldNickname)
  39759. }
  39760. if m.tel != nil {
  39761. fields = append(fields, wx.FieldTel)
  39762. }
  39763. if m.head_big != nil {
  39764. fields = append(fields, wx.FieldHeadBig)
  39765. }
  39766. if m.organization_id != nil {
  39767. fields = append(fields, wx.FieldOrganizationID)
  39768. }
  39769. if m.agent != nil {
  39770. fields = append(fields, wx.FieldAgentID)
  39771. }
  39772. if m.api_base != nil {
  39773. fields = append(fields, wx.FieldAPIBase)
  39774. }
  39775. if m.api_key != nil {
  39776. fields = append(fields, wx.FieldAPIKey)
  39777. }
  39778. if m.allow_list != nil {
  39779. fields = append(fields, wx.FieldAllowList)
  39780. }
  39781. if m.group_allow_list != nil {
  39782. fields = append(fields, wx.FieldGroupAllowList)
  39783. }
  39784. if m.block_list != nil {
  39785. fields = append(fields, wx.FieldBlockList)
  39786. }
  39787. if m.group_block_list != nil {
  39788. fields = append(fields, wx.FieldGroupBlockList)
  39789. }
  39790. return fields
  39791. }
  39792. // Field returns the value of a field with the given name. The second boolean
  39793. // return value indicates that this field was not set, or was not defined in the
  39794. // schema.
  39795. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  39796. switch name {
  39797. case wx.FieldCreatedAt:
  39798. return m.CreatedAt()
  39799. case wx.FieldUpdatedAt:
  39800. return m.UpdatedAt()
  39801. case wx.FieldStatus:
  39802. return m.Status()
  39803. case wx.FieldDeletedAt:
  39804. return m.DeletedAt()
  39805. case wx.FieldServerID:
  39806. return m.ServerID()
  39807. case wx.FieldPort:
  39808. return m.Port()
  39809. case wx.FieldProcessID:
  39810. return m.ProcessID()
  39811. case wx.FieldCallback:
  39812. return m.Callback()
  39813. case wx.FieldWxid:
  39814. return m.Wxid()
  39815. case wx.FieldAccount:
  39816. return m.Account()
  39817. case wx.FieldNickname:
  39818. return m.Nickname()
  39819. case wx.FieldTel:
  39820. return m.Tel()
  39821. case wx.FieldHeadBig:
  39822. return m.HeadBig()
  39823. case wx.FieldOrganizationID:
  39824. return m.OrganizationID()
  39825. case wx.FieldAgentID:
  39826. return m.AgentID()
  39827. case wx.FieldAPIBase:
  39828. return m.APIBase()
  39829. case wx.FieldAPIKey:
  39830. return m.APIKey()
  39831. case wx.FieldAllowList:
  39832. return m.AllowList()
  39833. case wx.FieldGroupAllowList:
  39834. return m.GroupAllowList()
  39835. case wx.FieldBlockList:
  39836. return m.BlockList()
  39837. case wx.FieldGroupBlockList:
  39838. return m.GroupBlockList()
  39839. }
  39840. return nil, false
  39841. }
  39842. // OldField returns the old value of the field from the database. An error is
  39843. // returned if the mutation operation is not UpdateOne, or the query to the
  39844. // database failed.
  39845. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39846. switch name {
  39847. case wx.FieldCreatedAt:
  39848. return m.OldCreatedAt(ctx)
  39849. case wx.FieldUpdatedAt:
  39850. return m.OldUpdatedAt(ctx)
  39851. case wx.FieldStatus:
  39852. return m.OldStatus(ctx)
  39853. case wx.FieldDeletedAt:
  39854. return m.OldDeletedAt(ctx)
  39855. case wx.FieldServerID:
  39856. return m.OldServerID(ctx)
  39857. case wx.FieldPort:
  39858. return m.OldPort(ctx)
  39859. case wx.FieldProcessID:
  39860. return m.OldProcessID(ctx)
  39861. case wx.FieldCallback:
  39862. return m.OldCallback(ctx)
  39863. case wx.FieldWxid:
  39864. return m.OldWxid(ctx)
  39865. case wx.FieldAccount:
  39866. return m.OldAccount(ctx)
  39867. case wx.FieldNickname:
  39868. return m.OldNickname(ctx)
  39869. case wx.FieldTel:
  39870. return m.OldTel(ctx)
  39871. case wx.FieldHeadBig:
  39872. return m.OldHeadBig(ctx)
  39873. case wx.FieldOrganizationID:
  39874. return m.OldOrganizationID(ctx)
  39875. case wx.FieldAgentID:
  39876. return m.OldAgentID(ctx)
  39877. case wx.FieldAPIBase:
  39878. return m.OldAPIBase(ctx)
  39879. case wx.FieldAPIKey:
  39880. return m.OldAPIKey(ctx)
  39881. case wx.FieldAllowList:
  39882. return m.OldAllowList(ctx)
  39883. case wx.FieldGroupAllowList:
  39884. return m.OldGroupAllowList(ctx)
  39885. case wx.FieldBlockList:
  39886. return m.OldBlockList(ctx)
  39887. case wx.FieldGroupBlockList:
  39888. return m.OldGroupBlockList(ctx)
  39889. }
  39890. return nil, fmt.Errorf("unknown Wx field %s", name)
  39891. }
  39892. // SetField sets the value of a field with the given name. It returns an error if
  39893. // the field is not defined in the schema, or if the type mismatched the field
  39894. // type.
  39895. func (m *WxMutation) SetField(name string, value ent.Value) error {
  39896. switch name {
  39897. case wx.FieldCreatedAt:
  39898. v, ok := value.(time.Time)
  39899. if !ok {
  39900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39901. }
  39902. m.SetCreatedAt(v)
  39903. return nil
  39904. case wx.FieldUpdatedAt:
  39905. v, ok := value.(time.Time)
  39906. if !ok {
  39907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39908. }
  39909. m.SetUpdatedAt(v)
  39910. return nil
  39911. case wx.FieldStatus:
  39912. v, ok := value.(uint8)
  39913. if !ok {
  39914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39915. }
  39916. m.SetStatus(v)
  39917. return nil
  39918. case wx.FieldDeletedAt:
  39919. v, ok := value.(time.Time)
  39920. if !ok {
  39921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39922. }
  39923. m.SetDeletedAt(v)
  39924. return nil
  39925. case wx.FieldServerID:
  39926. v, ok := value.(uint64)
  39927. if !ok {
  39928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39929. }
  39930. m.SetServerID(v)
  39931. return nil
  39932. case wx.FieldPort:
  39933. v, ok := value.(string)
  39934. if !ok {
  39935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39936. }
  39937. m.SetPort(v)
  39938. return nil
  39939. case wx.FieldProcessID:
  39940. v, ok := value.(string)
  39941. if !ok {
  39942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39943. }
  39944. m.SetProcessID(v)
  39945. return nil
  39946. case wx.FieldCallback:
  39947. v, ok := value.(string)
  39948. if !ok {
  39949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39950. }
  39951. m.SetCallback(v)
  39952. return nil
  39953. case wx.FieldWxid:
  39954. v, ok := value.(string)
  39955. if !ok {
  39956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39957. }
  39958. m.SetWxid(v)
  39959. return nil
  39960. case wx.FieldAccount:
  39961. v, ok := value.(string)
  39962. if !ok {
  39963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39964. }
  39965. m.SetAccount(v)
  39966. return nil
  39967. case wx.FieldNickname:
  39968. v, ok := value.(string)
  39969. if !ok {
  39970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39971. }
  39972. m.SetNickname(v)
  39973. return nil
  39974. case wx.FieldTel:
  39975. v, ok := value.(string)
  39976. if !ok {
  39977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39978. }
  39979. m.SetTel(v)
  39980. return nil
  39981. case wx.FieldHeadBig:
  39982. v, ok := value.(string)
  39983. if !ok {
  39984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39985. }
  39986. m.SetHeadBig(v)
  39987. return nil
  39988. case wx.FieldOrganizationID:
  39989. v, ok := value.(uint64)
  39990. if !ok {
  39991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39992. }
  39993. m.SetOrganizationID(v)
  39994. return nil
  39995. case wx.FieldAgentID:
  39996. v, ok := value.(uint64)
  39997. if !ok {
  39998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39999. }
  40000. m.SetAgentID(v)
  40001. return nil
  40002. case wx.FieldAPIBase:
  40003. v, ok := value.(string)
  40004. if !ok {
  40005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40006. }
  40007. m.SetAPIBase(v)
  40008. return nil
  40009. case wx.FieldAPIKey:
  40010. v, ok := value.(string)
  40011. if !ok {
  40012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40013. }
  40014. m.SetAPIKey(v)
  40015. return nil
  40016. case wx.FieldAllowList:
  40017. v, ok := value.([]string)
  40018. if !ok {
  40019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40020. }
  40021. m.SetAllowList(v)
  40022. return nil
  40023. case wx.FieldGroupAllowList:
  40024. v, ok := value.([]string)
  40025. if !ok {
  40026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40027. }
  40028. m.SetGroupAllowList(v)
  40029. return nil
  40030. case wx.FieldBlockList:
  40031. v, ok := value.([]string)
  40032. if !ok {
  40033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40034. }
  40035. m.SetBlockList(v)
  40036. return nil
  40037. case wx.FieldGroupBlockList:
  40038. v, ok := value.([]string)
  40039. if !ok {
  40040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40041. }
  40042. m.SetGroupBlockList(v)
  40043. return nil
  40044. }
  40045. return fmt.Errorf("unknown Wx field %s", name)
  40046. }
  40047. // AddedFields returns all numeric fields that were incremented/decremented during
  40048. // this mutation.
  40049. func (m *WxMutation) AddedFields() []string {
  40050. var fields []string
  40051. if m.addstatus != nil {
  40052. fields = append(fields, wx.FieldStatus)
  40053. }
  40054. if m.addorganization_id != nil {
  40055. fields = append(fields, wx.FieldOrganizationID)
  40056. }
  40057. return fields
  40058. }
  40059. // AddedField returns the numeric value that was incremented/decremented on a field
  40060. // with the given name. The second boolean return value indicates that this field
  40061. // was not set, or was not defined in the schema.
  40062. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  40063. switch name {
  40064. case wx.FieldStatus:
  40065. return m.AddedStatus()
  40066. case wx.FieldOrganizationID:
  40067. return m.AddedOrganizationID()
  40068. }
  40069. return nil, false
  40070. }
  40071. // AddField adds the value to the field with the given name. It returns an error if
  40072. // the field is not defined in the schema, or if the type mismatched the field
  40073. // type.
  40074. func (m *WxMutation) AddField(name string, value ent.Value) error {
  40075. switch name {
  40076. case wx.FieldStatus:
  40077. v, ok := value.(int8)
  40078. if !ok {
  40079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40080. }
  40081. m.AddStatus(v)
  40082. return nil
  40083. case wx.FieldOrganizationID:
  40084. v, ok := value.(int64)
  40085. if !ok {
  40086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40087. }
  40088. m.AddOrganizationID(v)
  40089. return nil
  40090. }
  40091. return fmt.Errorf("unknown Wx numeric field %s", name)
  40092. }
  40093. // ClearedFields returns all nullable fields that were cleared during this
  40094. // mutation.
  40095. func (m *WxMutation) ClearedFields() []string {
  40096. var fields []string
  40097. if m.FieldCleared(wx.FieldStatus) {
  40098. fields = append(fields, wx.FieldStatus)
  40099. }
  40100. if m.FieldCleared(wx.FieldDeletedAt) {
  40101. fields = append(fields, wx.FieldDeletedAt)
  40102. }
  40103. if m.FieldCleared(wx.FieldServerID) {
  40104. fields = append(fields, wx.FieldServerID)
  40105. }
  40106. if m.FieldCleared(wx.FieldOrganizationID) {
  40107. fields = append(fields, wx.FieldOrganizationID)
  40108. }
  40109. if m.FieldCleared(wx.FieldAPIBase) {
  40110. fields = append(fields, wx.FieldAPIBase)
  40111. }
  40112. if m.FieldCleared(wx.FieldAPIKey) {
  40113. fields = append(fields, wx.FieldAPIKey)
  40114. }
  40115. return fields
  40116. }
  40117. // FieldCleared returns a boolean indicating if a field with the given name was
  40118. // cleared in this mutation.
  40119. func (m *WxMutation) FieldCleared(name string) bool {
  40120. _, ok := m.clearedFields[name]
  40121. return ok
  40122. }
  40123. // ClearField clears the value of the field with the given name. It returns an
  40124. // error if the field is not defined in the schema.
  40125. func (m *WxMutation) ClearField(name string) error {
  40126. switch name {
  40127. case wx.FieldStatus:
  40128. m.ClearStatus()
  40129. return nil
  40130. case wx.FieldDeletedAt:
  40131. m.ClearDeletedAt()
  40132. return nil
  40133. case wx.FieldServerID:
  40134. m.ClearServerID()
  40135. return nil
  40136. case wx.FieldOrganizationID:
  40137. m.ClearOrganizationID()
  40138. return nil
  40139. case wx.FieldAPIBase:
  40140. m.ClearAPIBase()
  40141. return nil
  40142. case wx.FieldAPIKey:
  40143. m.ClearAPIKey()
  40144. return nil
  40145. }
  40146. return fmt.Errorf("unknown Wx nullable field %s", name)
  40147. }
  40148. // ResetField resets all changes in the mutation for the field with the given name.
  40149. // It returns an error if the field is not defined in the schema.
  40150. func (m *WxMutation) ResetField(name string) error {
  40151. switch name {
  40152. case wx.FieldCreatedAt:
  40153. m.ResetCreatedAt()
  40154. return nil
  40155. case wx.FieldUpdatedAt:
  40156. m.ResetUpdatedAt()
  40157. return nil
  40158. case wx.FieldStatus:
  40159. m.ResetStatus()
  40160. return nil
  40161. case wx.FieldDeletedAt:
  40162. m.ResetDeletedAt()
  40163. return nil
  40164. case wx.FieldServerID:
  40165. m.ResetServerID()
  40166. return nil
  40167. case wx.FieldPort:
  40168. m.ResetPort()
  40169. return nil
  40170. case wx.FieldProcessID:
  40171. m.ResetProcessID()
  40172. return nil
  40173. case wx.FieldCallback:
  40174. m.ResetCallback()
  40175. return nil
  40176. case wx.FieldWxid:
  40177. m.ResetWxid()
  40178. return nil
  40179. case wx.FieldAccount:
  40180. m.ResetAccount()
  40181. return nil
  40182. case wx.FieldNickname:
  40183. m.ResetNickname()
  40184. return nil
  40185. case wx.FieldTel:
  40186. m.ResetTel()
  40187. return nil
  40188. case wx.FieldHeadBig:
  40189. m.ResetHeadBig()
  40190. return nil
  40191. case wx.FieldOrganizationID:
  40192. m.ResetOrganizationID()
  40193. return nil
  40194. case wx.FieldAgentID:
  40195. m.ResetAgentID()
  40196. return nil
  40197. case wx.FieldAPIBase:
  40198. m.ResetAPIBase()
  40199. return nil
  40200. case wx.FieldAPIKey:
  40201. m.ResetAPIKey()
  40202. return nil
  40203. case wx.FieldAllowList:
  40204. m.ResetAllowList()
  40205. return nil
  40206. case wx.FieldGroupAllowList:
  40207. m.ResetGroupAllowList()
  40208. return nil
  40209. case wx.FieldBlockList:
  40210. m.ResetBlockList()
  40211. return nil
  40212. case wx.FieldGroupBlockList:
  40213. m.ResetGroupBlockList()
  40214. return nil
  40215. }
  40216. return fmt.Errorf("unknown Wx field %s", name)
  40217. }
  40218. // AddedEdges returns all edge names that were set/added in this mutation.
  40219. func (m *WxMutation) AddedEdges() []string {
  40220. edges := make([]string, 0, 2)
  40221. if m.server != nil {
  40222. edges = append(edges, wx.EdgeServer)
  40223. }
  40224. if m.agent != nil {
  40225. edges = append(edges, wx.EdgeAgent)
  40226. }
  40227. return edges
  40228. }
  40229. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40230. // name in this mutation.
  40231. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  40232. switch name {
  40233. case wx.EdgeServer:
  40234. if id := m.server; id != nil {
  40235. return []ent.Value{*id}
  40236. }
  40237. case wx.EdgeAgent:
  40238. if id := m.agent; id != nil {
  40239. return []ent.Value{*id}
  40240. }
  40241. }
  40242. return nil
  40243. }
  40244. // RemovedEdges returns all edge names that were removed in this mutation.
  40245. func (m *WxMutation) RemovedEdges() []string {
  40246. edges := make([]string, 0, 2)
  40247. return edges
  40248. }
  40249. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40250. // the given name in this mutation.
  40251. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  40252. return nil
  40253. }
  40254. // ClearedEdges returns all edge names that were cleared in this mutation.
  40255. func (m *WxMutation) ClearedEdges() []string {
  40256. edges := make([]string, 0, 2)
  40257. if m.clearedserver {
  40258. edges = append(edges, wx.EdgeServer)
  40259. }
  40260. if m.clearedagent {
  40261. edges = append(edges, wx.EdgeAgent)
  40262. }
  40263. return edges
  40264. }
  40265. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40266. // was cleared in this mutation.
  40267. func (m *WxMutation) EdgeCleared(name string) bool {
  40268. switch name {
  40269. case wx.EdgeServer:
  40270. return m.clearedserver
  40271. case wx.EdgeAgent:
  40272. return m.clearedagent
  40273. }
  40274. return false
  40275. }
  40276. // ClearEdge clears the value of the edge with the given name. It returns an error
  40277. // if that edge is not defined in the schema.
  40278. func (m *WxMutation) ClearEdge(name string) error {
  40279. switch name {
  40280. case wx.EdgeServer:
  40281. m.ClearServer()
  40282. return nil
  40283. case wx.EdgeAgent:
  40284. m.ClearAgent()
  40285. return nil
  40286. }
  40287. return fmt.Errorf("unknown Wx unique edge %s", name)
  40288. }
  40289. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40290. // It returns an error if the edge is not defined in the schema.
  40291. func (m *WxMutation) ResetEdge(name string) error {
  40292. switch name {
  40293. case wx.EdgeServer:
  40294. m.ResetServer()
  40295. return nil
  40296. case wx.EdgeAgent:
  40297. m.ResetAgent()
  40298. return nil
  40299. }
  40300. return fmt.Errorf("unknown Wx edge %s", name)
  40301. }
  40302. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  40303. type WxCardMutation struct {
  40304. config
  40305. op Op
  40306. typ string
  40307. id *uint64
  40308. created_at *time.Time
  40309. updated_at *time.Time
  40310. deleted_at *time.Time
  40311. user_id *uint64
  40312. adduser_id *int64
  40313. wx_user_id *uint64
  40314. addwx_user_id *int64
  40315. avatar *string
  40316. logo *string
  40317. name *string
  40318. company *string
  40319. address *string
  40320. phone *string
  40321. official_account *string
  40322. wechat_account *string
  40323. email *string
  40324. api_base *string
  40325. api_key *string
  40326. ai_info *string
  40327. intro *string
  40328. clearedFields map[string]struct{}
  40329. done bool
  40330. oldValue func(context.Context) (*WxCard, error)
  40331. predicates []predicate.WxCard
  40332. }
  40333. var _ ent.Mutation = (*WxCardMutation)(nil)
  40334. // wxcardOption allows management of the mutation configuration using functional options.
  40335. type wxcardOption func(*WxCardMutation)
  40336. // newWxCardMutation creates new mutation for the WxCard entity.
  40337. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  40338. m := &WxCardMutation{
  40339. config: c,
  40340. op: op,
  40341. typ: TypeWxCard,
  40342. clearedFields: make(map[string]struct{}),
  40343. }
  40344. for _, opt := range opts {
  40345. opt(m)
  40346. }
  40347. return m
  40348. }
  40349. // withWxCardID sets the ID field of the mutation.
  40350. func withWxCardID(id uint64) wxcardOption {
  40351. return func(m *WxCardMutation) {
  40352. var (
  40353. err error
  40354. once sync.Once
  40355. value *WxCard
  40356. )
  40357. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  40358. once.Do(func() {
  40359. if m.done {
  40360. err = errors.New("querying old values post mutation is not allowed")
  40361. } else {
  40362. value, err = m.Client().WxCard.Get(ctx, id)
  40363. }
  40364. })
  40365. return value, err
  40366. }
  40367. m.id = &id
  40368. }
  40369. }
  40370. // withWxCard sets the old WxCard of the mutation.
  40371. func withWxCard(node *WxCard) wxcardOption {
  40372. return func(m *WxCardMutation) {
  40373. m.oldValue = func(context.Context) (*WxCard, error) {
  40374. return node, nil
  40375. }
  40376. m.id = &node.ID
  40377. }
  40378. }
  40379. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40380. // executed in a transaction (ent.Tx), a transactional client is returned.
  40381. func (m WxCardMutation) Client() *Client {
  40382. client := &Client{config: m.config}
  40383. client.init()
  40384. return client
  40385. }
  40386. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40387. // it returns an error otherwise.
  40388. func (m WxCardMutation) Tx() (*Tx, error) {
  40389. if _, ok := m.driver.(*txDriver); !ok {
  40390. return nil, errors.New("ent: mutation is not running in a transaction")
  40391. }
  40392. tx := &Tx{config: m.config}
  40393. tx.init()
  40394. return tx, nil
  40395. }
  40396. // SetID sets the value of the id field. Note that this
  40397. // operation is only accepted on creation of WxCard entities.
  40398. func (m *WxCardMutation) SetID(id uint64) {
  40399. m.id = &id
  40400. }
  40401. // ID returns the ID value in the mutation. Note that the ID is only available
  40402. // if it was provided to the builder or after it was returned from the database.
  40403. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  40404. if m.id == nil {
  40405. return
  40406. }
  40407. return *m.id, true
  40408. }
  40409. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40410. // That means, if the mutation is applied within a transaction with an isolation level such
  40411. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40412. // or updated by the mutation.
  40413. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  40414. switch {
  40415. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40416. id, exists := m.ID()
  40417. if exists {
  40418. return []uint64{id}, nil
  40419. }
  40420. fallthrough
  40421. case m.op.Is(OpUpdate | OpDelete):
  40422. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  40423. default:
  40424. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40425. }
  40426. }
  40427. // SetCreatedAt sets the "created_at" field.
  40428. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  40429. m.created_at = &t
  40430. }
  40431. // CreatedAt returns the value of the "created_at" field in the mutation.
  40432. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  40433. v := m.created_at
  40434. if v == nil {
  40435. return
  40436. }
  40437. return *v, true
  40438. }
  40439. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  40440. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40442. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40443. if !m.op.Is(OpUpdateOne) {
  40444. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40445. }
  40446. if m.id == nil || m.oldValue == nil {
  40447. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40448. }
  40449. oldValue, err := m.oldValue(ctx)
  40450. if err != nil {
  40451. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40452. }
  40453. return oldValue.CreatedAt, nil
  40454. }
  40455. // ResetCreatedAt resets all changes to the "created_at" field.
  40456. func (m *WxCardMutation) ResetCreatedAt() {
  40457. m.created_at = nil
  40458. }
  40459. // SetUpdatedAt sets the "updated_at" field.
  40460. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  40461. m.updated_at = &t
  40462. }
  40463. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40464. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  40465. v := m.updated_at
  40466. if v == nil {
  40467. return
  40468. }
  40469. return *v, true
  40470. }
  40471. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  40472. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40474. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40475. if !m.op.Is(OpUpdateOne) {
  40476. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40477. }
  40478. if m.id == nil || m.oldValue == nil {
  40479. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40480. }
  40481. oldValue, err := m.oldValue(ctx)
  40482. if err != nil {
  40483. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40484. }
  40485. return oldValue.UpdatedAt, nil
  40486. }
  40487. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40488. func (m *WxCardMutation) ResetUpdatedAt() {
  40489. m.updated_at = nil
  40490. }
  40491. // SetDeletedAt sets the "deleted_at" field.
  40492. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  40493. m.deleted_at = &t
  40494. }
  40495. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40496. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  40497. v := m.deleted_at
  40498. if v == nil {
  40499. return
  40500. }
  40501. return *v, true
  40502. }
  40503. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  40504. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40506. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40507. if !m.op.Is(OpUpdateOne) {
  40508. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40509. }
  40510. if m.id == nil || m.oldValue == nil {
  40511. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40512. }
  40513. oldValue, err := m.oldValue(ctx)
  40514. if err != nil {
  40515. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40516. }
  40517. return oldValue.DeletedAt, nil
  40518. }
  40519. // ClearDeletedAt clears the value of the "deleted_at" field.
  40520. func (m *WxCardMutation) ClearDeletedAt() {
  40521. m.deleted_at = nil
  40522. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  40523. }
  40524. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40525. func (m *WxCardMutation) DeletedAtCleared() bool {
  40526. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  40527. return ok
  40528. }
  40529. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40530. func (m *WxCardMutation) ResetDeletedAt() {
  40531. m.deleted_at = nil
  40532. delete(m.clearedFields, wxcard.FieldDeletedAt)
  40533. }
  40534. // SetUserID sets the "user_id" field.
  40535. func (m *WxCardMutation) SetUserID(u uint64) {
  40536. m.user_id = &u
  40537. m.adduser_id = nil
  40538. }
  40539. // UserID returns the value of the "user_id" field in the mutation.
  40540. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  40541. v := m.user_id
  40542. if v == nil {
  40543. return
  40544. }
  40545. return *v, true
  40546. }
  40547. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  40548. // If the WxCard 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 *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  40551. if !m.op.Is(OpUpdateOne) {
  40552. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  40553. }
  40554. if m.id == nil || m.oldValue == nil {
  40555. return v, errors.New("OldUserID 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 OldUserID: %w", err)
  40560. }
  40561. return oldValue.UserID, nil
  40562. }
  40563. // AddUserID adds u to the "user_id" field.
  40564. func (m *WxCardMutation) AddUserID(u int64) {
  40565. if m.adduser_id != nil {
  40566. *m.adduser_id += u
  40567. } else {
  40568. m.adduser_id = &u
  40569. }
  40570. }
  40571. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  40572. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  40573. v := m.adduser_id
  40574. if v == nil {
  40575. return
  40576. }
  40577. return *v, true
  40578. }
  40579. // ClearUserID clears the value of the "user_id" field.
  40580. func (m *WxCardMutation) ClearUserID() {
  40581. m.user_id = nil
  40582. m.adduser_id = nil
  40583. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  40584. }
  40585. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  40586. func (m *WxCardMutation) UserIDCleared() bool {
  40587. _, ok := m.clearedFields[wxcard.FieldUserID]
  40588. return ok
  40589. }
  40590. // ResetUserID resets all changes to the "user_id" field.
  40591. func (m *WxCardMutation) ResetUserID() {
  40592. m.user_id = nil
  40593. m.adduser_id = nil
  40594. delete(m.clearedFields, wxcard.FieldUserID)
  40595. }
  40596. // SetWxUserID sets the "wx_user_id" field.
  40597. func (m *WxCardMutation) SetWxUserID(u uint64) {
  40598. m.wx_user_id = &u
  40599. m.addwx_user_id = nil
  40600. }
  40601. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  40602. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  40603. v := m.wx_user_id
  40604. if v == nil {
  40605. return
  40606. }
  40607. return *v, true
  40608. }
  40609. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  40610. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40612. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  40613. if !m.op.Is(OpUpdateOne) {
  40614. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  40615. }
  40616. if m.id == nil || m.oldValue == nil {
  40617. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  40618. }
  40619. oldValue, err := m.oldValue(ctx)
  40620. if err != nil {
  40621. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  40622. }
  40623. return oldValue.WxUserID, nil
  40624. }
  40625. // AddWxUserID adds u to the "wx_user_id" field.
  40626. func (m *WxCardMutation) AddWxUserID(u int64) {
  40627. if m.addwx_user_id != nil {
  40628. *m.addwx_user_id += u
  40629. } else {
  40630. m.addwx_user_id = &u
  40631. }
  40632. }
  40633. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  40634. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  40635. v := m.addwx_user_id
  40636. if v == nil {
  40637. return
  40638. }
  40639. return *v, true
  40640. }
  40641. // ClearWxUserID clears the value of the "wx_user_id" field.
  40642. func (m *WxCardMutation) ClearWxUserID() {
  40643. m.wx_user_id = nil
  40644. m.addwx_user_id = nil
  40645. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  40646. }
  40647. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  40648. func (m *WxCardMutation) WxUserIDCleared() bool {
  40649. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  40650. return ok
  40651. }
  40652. // ResetWxUserID resets all changes to the "wx_user_id" field.
  40653. func (m *WxCardMutation) ResetWxUserID() {
  40654. m.wx_user_id = nil
  40655. m.addwx_user_id = nil
  40656. delete(m.clearedFields, wxcard.FieldWxUserID)
  40657. }
  40658. // SetAvatar sets the "avatar" field.
  40659. func (m *WxCardMutation) SetAvatar(s string) {
  40660. m.avatar = &s
  40661. }
  40662. // Avatar returns the value of the "avatar" field in the mutation.
  40663. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  40664. v := m.avatar
  40665. if v == nil {
  40666. return
  40667. }
  40668. return *v, true
  40669. }
  40670. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  40671. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40673. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40674. if !m.op.Is(OpUpdateOne) {
  40675. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40676. }
  40677. if m.id == nil || m.oldValue == nil {
  40678. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40679. }
  40680. oldValue, err := m.oldValue(ctx)
  40681. if err != nil {
  40682. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40683. }
  40684. return oldValue.Avatar, nil
  40685. }
  40686. // ResetAvatar resets all changes to the "avatar" field.
  40687. func (m *WxCardMutation) ResetAvatar() {
  40688. m.avatar = nil
  40689. }
  40690. // SetLogo sets the "logo" field.
  40691. func (m *WxCardMutation) SetLogo(s string) {
  40692. m.logo = &s
  40693. }
  40694. // Logo returns the value of the "logo" field in the mutation.
  40695. func (m *WxCardMutation) Logo() (r string, exists bool) {
  40696. v := m.logo
  40697. if v == nil {
  40698. return
  40699. }
  40700. return *v, true
  40701. }
  40702. // OldLogo returns the old "logo" field's value of the WxCard entity.
  40703. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40705. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  40706. if !m.op.Is(OpUpdateOne) {
  40707. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  40708. }
  40709. if m.id == nil || m.oldValue == nil {
  40710. return v, errors.New("OldLogo requires an ID field in the mutation")
  40711. }
  40712. oldValue, err := m.oldValue(ctx)
  40713. if err != nil {
  40714. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  40715. }
  40716. return oldValue.Logo, nil
  40717. }
  40718. // ResetLogo resets all changes to the "logo" field.
  40719. func (m *WxCardMutation) ResetLogo() {
  40720. m.logo = nil
  40721. }
  40722. // SetName sets the "name" field.
  40723. func (m *WxCardMutation) SetName(s string) {
  40724. m.name = &s
  40725. }
  40726. // Name returns the value of the "name" field in the mutation.
  40727. func (m *WxCardMutation) Name() (r string, exists bool) {
  40728. v := m.name
  40729. if v == nil {
  40730. return
  40731. }
  40732. return *v, true
  40733. }
  40734. // OldName returns the old "name" field's value of the WxCard entity.
  40735. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40737. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  40738. if !m.op.Is(OpUpdateOne) {
  40739. return v, errors.New("OldName is only allowed on UpdateOne operations")
  40740. }
  40741. if m.id == nil || m.oldValue == nil {
  40742. return v, errors.New("OldName requires an ID field in the mutation")
  40743. }
  40744. oldValue, err := m.oldValue(ctx)
  40745. if err != nil {
  40746. return v, fmt.Errorf("querying old value for OldName: %w", err)
  40747. }
  40748. return oldValue.Name, nil
  40749. }
  40750. // ResetName resets all changes to the "name" field.
  40751. func (m *WxCardMutation) ResetName() {
  40752. m.name = nil
  40753. }
  40754. // SetCompany sets the "company" field.
  40755. func (m *WxCardMutation) SetCompany(s string) {
  40756. m.company = &s
  40757. }
  40758. // Company returns the value of the "company" field in the mutation.
  40759. func (m *WxCardMutation) Company() (r string, exists bool) {
  40760. v := m.company
  40761. if v == nil {
  40762. return
  40763. }
  40764. return *v, true
  40765. }
  40766. // OldCompany returns the old "company" field's value of the WxCard entity.
  40767. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40769. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  40770. if !m.op.Is(OpUpdateOne) {
  40771. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  40772. }
  40773. if m.id == nil || m.oldValue == nil {
  40774. return v, errors.New("OldCompany requires an ID field in the mutation")
  40775. }
  40776. oldValue, err := m.oldValue(ctx)
  40777. if err != nil {
  40778. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  40779. }
  40780. return oldValue.Company, nil
  40781. }
  40782. // ResetCompany resets all changes to the "company" field.
  40783. func (m *WxCardMutation) ResetCompany() {
  40784. m.company = nil
  40785. }
  40786. // SetAddress sets the "address" field.
  40787. func (m *WxCardMutation) SetAddress(s string) {
  40788. m.address = &s
  40789. }
  40790. // Address returns the value of the "address" field in the mutation.
  40791. func (m *WxCardMutation) Address() (r string, exists bool) {
  40792. v := m.address
  40793. if v == nil {
  40794. return
  40795. }
  40796. return *v, true
  40797. }
  40798. // OldAddress returns the old "address" field's value of the WxCard entity.
  40799. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40801. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  40802. if !m.op.Is(OpUpdateOne) {
  40803. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  40804. }
  40805. if m.id == nil || m.oldValue == nil {
  40806. return v, errors.New("OldAddress requires an ID field in the mutation")
  40807. }
  40808. oldValue, err := m.oldValue(ctx)
  40809. if err != nil {
  40810. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  40811. }
  40812. return oldValue.Address, nil
  40813. }
  40814. // ResetAddress resets all changes to the "address" field.
  40815. func (m *WxCardMutation) ResetAddress() {
  40816. m.address = nil
  40817. }
  40818. // SetPhone sets the "phone" field.
  40819. func (m *WxCardMutation) SetPhone(s string) {
  40820. m.phone = &s
  40821. }
  40822. // Phone returns the value of the "phone" field in the mutation.
  40823. func (m *WxCardMutation) Phone() (r string, exists bool) {
  40824. v := m.phone
  40825. if v == nil {
  40826. return
  40827. }
  40828. return *v, true
  40829. }
  40830. // OldPhone returns the old "phone" field's value of the WxCard entity.
  40831. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40833. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  40834. if !m.op.Is(OpUpdateOne) {
  40835. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  40836. }
  40837. if m.id == nil || m.oldValue == nil {
  40838. return v, errors.New("OldPhone requires an ID field in the mutation")
  40839. }
  40840. oldValue, err := m.oldValue(ctx)
  40841. if err != nil {
  40842. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  40843. }
  40844. return oldValue.Phone, nil
  40845. }
  40846. // ResetPhone resets all changes to the "phone" field.
  40847. func (m *WxCardMutation) ResetPhone() {
  40848. m.phone = nil
  40849. }
  40850. // SetOfficialAccount sets the "official_account" field.
  40851. func (m *WxCardMutation) SetOfficialAccount(s string) {
  40852. m.official_account = &s
  40853. }
  40854. // OfficialAccount returns the value of the "official_account" field in the mutation.
  40855. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  40856. v := m.official_account
  40857. if v == nil {
  40858. return
  40859. }
  40860. return *v, true
  40861. }
  40862. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  40863. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40865. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  40866. if !m.op.Is(OpUpdateOne) {
  40867. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  40868. }
  40869. if m.id == nil || m.oldValue == nil {
  40870. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  40871. }
  40872. oldValue, err := m.oldValue(ctx)
  40873. if err != nil {
  40874. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  40875. }
  40876. return oldValue.OfficialAccount, nil
  40877. }
  40878. // ResetOfficialAccount resets all changes to the "official_account" field.
  40879. func (m *WxCardMutation) ResetOfficialAccount() {
  40880. m.official_account = nil
  40881. }
  40882. // SetWechatAccount sets the "wechat_account" field.
  40883. func (m *WxCardMutation) SetWechatAccount(s string) {
  40884. m.wechat_account = &s
  40885. }
  40886. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  40887. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  40888. v := m.wechat_account
  40889. if v == nil {
  40890. return
  40891. }
  40892. return *v, true
  40893. }
  40894. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  40895. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40897. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  40898. if !m.op.Is(OpUpdateOne) {
  40899. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  40900. }
  40901. if m.id == nil || m.oldValue == nil {
  40902. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  40903. }
  40904. oldValue, err := m.oldValue(ctx)
  40905. if err != nil {
  40906. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  40907. }
  40908. return oldValue.WechatAccount, nil
  40909. }
  40910. // ResetWechatAccount resets all changes to the "wechat_account" field.
  40911. func (m *WxCardMutation) ResetWechatAccount() {
  40912. m.wechat_account = nil
  40913. }
  40914. // SetEmail sets the "email" field.
  40915. func (m *WxCardMutation) SetEmail(s string) {
  40916. m.email = &s
  40917. }
  40918. // Email returns the value of the "email" field in the mutation.
  40919. func (m *WxCardMutation) Email() (r string, exists bool) {
  40920. v := m.email
  40921. if v == nil {
  40922. return
  40923. }
  40924. return *v, true
  40925. }
  40926. // OldEmail returns the old "email" field's value of the WxCard entity.
  40927. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40929. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  40930. if !m.op.Is(OpUpdateOne) {
  40931. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  40932. }
  40933. if m.id == nil || m.oldValue == nil {
  40934. return v, errors.New("OldEmail requires an ID field in the mutation")
  40935. }
  40936. oldValue, err := m.oldValue(ctx)
  40937. if err != nil {
  40938. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  40939. }
  40940. return oldValue.Email, nil
  40941. }
  40942. // ClearEmail clears the value of the "email" field.
  40943. func (m *WxCardMutation) ClearEmail() {
  40944. m.email = nil
  40945. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  40946. }
  40947. // EmailCleared returns if the "email" field was cleared in this mutation.
  40948. func (m *WxCardMutation) EmailCleared() bool {
  40949. _, ok := m.clearedFields[wxcard.FieldEmail]
  40950. return ok
  40951. }
  40952. // ResetEmail resets all changes to the "email" field.
  40953. func (m *WxCardMutation) ResetEmail() {
  40954. m.email = nil
  40955. delete(m.clearedFields, wxcard.FieldEmail)
  40956. }
  40957. // SetAPIBase sets the "api_base" field.
  40958. func (m *WxCardMutation) SetAPIBase(s string) {
  40959. m.api_base = &s
  40960. }
  40961. // APIBase returns the value of the "api_base" field in the mutation.
  40962. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  40963. v := m.api_base
  40964. if v == nil {
  40965. return
  40966. }
  40967. return *v, true
  40968. }
  40969. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  40970. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40972. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  40973. if !m.op.Is(OpUpdateOne) {
  40974. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  40975. }
  40976. if m.id == nil || m.oldValue == nil {
  40977. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  40978. }
  40979. oldValue, err := m.oldValue(ctx)
  40980. if err != nil {
  40981. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  40982. }
  40983. return oldValue.APIBase, nil
  40984. }
  40985. // ClearAPIBase clears the value of the "api_base" field.
  40986. func (m *WxCardMutation) ClearAPIBase() {
  40987. m.api_base = nil
  40988. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  40989. }
  40990. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  40991. func (m *WxCardMutation) APIBaseCleared() bool {
  40992. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  40993. return ok
  40994. }
  40995. // ResetAPIBase resets all changes to the "api_base" field.
  40996. func (m *WxCardMutation) ResetAPIBase() {
  40997. m.api_base = nil
  40998. delete(m.clearedFields, wxcard.FieldAPIBase)
  40999. }
  41000. // SetAPIKey sets the "api_key" field.
  41001. func (m *WxCardMutation) SetAPIKey(s string) {
  41002. m.api_key = &s
  41003. }
  41004. // APIKey returns the value of the "api_key" field in the mutation.
  41005. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  41006. v := m.api_key
  41007. if v == nil {
  41008. return
  41009. }
  41010. return *v, true
  41011. }
  41012. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  41013. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41015. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  41016. if !m.op.Is(OpUpdateOne) {
  41017. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  41018. }
  41019. if m.id == nil || m.oldValue == nil {
  41020. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  41021. }
  41022. oldValue, err := m.oldValue(ctx)
  41023. if err != nil {
  41024. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  41025. }
  41026. return oldValue.APIKey, nil
  41027. }
  41028. // ClearAPIKey clears the value of the "api_key" field.
  41029. func (m *WxCardMutation) ClearAPIKey() {
  41030. m.api_key = nil
  41031. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  41032. }
  41033. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  41034. func (m *WxCardMutation) APIKeyCleared() bool {
  41035. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  41036. return ok
  41037. }
  41038. // ResetAPIKey resets all changes to the "api_key" field.
  41039. func (m *WxCardMutation) ResetAPIKey() {
  41040. m.api_key = nil
  41041. delete(m.clearedFields, wxcard.FieldAPIKey)
  41042. }
  41043. // SetAiInfo sets the "ai_info" field.
  41044. func (m *WxCardMutation) SetAiInfo(s string) {
  41045. m.ai_info = &s
  41046. }
  41047. // AiInfo returns the value of the "ai_info" field in the mutation.
  41048. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  41049. v := m.ai_info
  41050. if v == nil {
  41051. return
  41052. }
  41053. return *v, true
  41054. }
  41055. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  41056. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41058. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  41059. if !m.op.Is(OpUpdateOne) {
  41060. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  41061. }
  41062. if m.id == nil || m.oldValue == nil {
  41063. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  41064. }
  41065. oldValue, err := m.oldValue(ctx)
  41066. if err != nil {
  41067. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  41068. }
  41069. return oldValue.AiInfo, nil
  41070. }
  41071. // ClearAiInfo clears the value of the "ai_info" field.
  41072. func (m *WxCardMutation) ClearAiInfo() {
  41073. m.ai_info = nil
  41074. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  41075. }
  41076. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  41077. func (m *WxCardMutation) AiInfoCleared() bool {
  41078. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  41079. return ok
  41080. }
  41081. // ResetAiInfo resets all changes to the "ai_info" field.
  41082. func (m *WxCardMutation) ResetAiInfo() {
  41083. m.ai_info = nil
  41084. delete(m.clearedFields, wxcard.FieldAiInfo)
  41085. }
  41086. // SetIntro sets the "intro" field.
  41087. func (m *WxCardMutation) SetIntro(s string) {
  41088. m.intro = &s
  41089. }
  41090. // Intro returns the value of the "intro" field in the mutation.
  41091. func (m *WxCardMutation) Intro() (r string, exists bool) {
  41092. v := m.intro
  41093. if v == nil {
  41094. return
  41095. }
  41096. return *v, true
  41097. }
  41098. // OldIntro returns the old "intro" field's value of the WxCard entity.
  41099. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41101. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  41102. if !m.op.Is(OpUpdateOne) {
  41103. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  41104. }
  41105. if m.id == nil || m.oldValue == nil {
  41106. return v, errors.New("OldIntro requires an ID field in the mutation")
  41107. }
  41108. oldValue, err := m.oldValue(ctx)
  41109. if err != nil {
  41110. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  41111. }
  41112. return oldValue.Intro, nil
  41113. }
  41114. // ClearIntro clears the value of the "intro" field.
  41115. func (m *WxCardMutation) ClearIntro() {
  41116. m.intro = nil
  41117. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  41118. }
  41119. // IntroCleared returns if the "intro" field was cleared in this mutation.
  41120. func (m *WxCardMutation) IntroCleared() bool {
  41121. _, ok := m.clearedFields[wxcard.FieldIntro]
  41122. return ok
  41123. }
  41124. // ResetIntro resets all changes to the "intro" field.
  41125. func (m *WxCardMutation) ResetIntro() {
  41126. m.intro = nil
  41127. delete(m.clearedFields, wxcard.FieldIntro)
  41128. }
  41129. // Where appends a list predicates to the WxCardMutation builder.
  41130. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  41131. m.predicates = append(m.predicates, ps...)
  41132. }
  41133. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  41134. // users can use type-assertion to append predicates that do not depend on any generated package.
  41135. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  41136. p := make([]predicate.WxCard, len(ps))
  41137. for i := range ps {
  41138. p[i] = ps[i]
  41139. }
  41140. m.Where(p...)
  41141. }
  41142. // Op returns the operation name.
  41143. func (m *WxCardMutation) Op() Op {
  41144. return m.op
  41145. }
  41146. // SetOp allows setting the mutation operation.
  41147. func (m *WxCardMutation) SetOp(op Op) {
  41148. m.op = op
  41149. }
  41150. // Type returns the node type of this mutation (WxCard).
  41151. func (m *WxCardMutation) Type() string {
  41152. return m.typ
  41153. }
  41154. // Fields returns all fields that were changed during this mutation. Note that in
  41155. // order to get all numeric fields that were incremented/decremented, call
  41156. // AddedFields().
  41157. func (m *WxCardMutation) Fields() []string {
  41158. fields := make([]string, 0, 18)
  41159. if m.created_at != nil {
  41160. fields = append(fields, wxcard.FieldCreatedAt)
  41161. }
  41162. if m.updated_at != nil {
  41163. fields = append(fields, wxcard.FieldUpdatedAt)
  41164. }
  41165. if m.deleted_at != nil {
  41166. fields = append(fields, wxcard.FieldDeletedAt)
  41167. }
  41168. if m.user_id != nil {
  41169. fields = append(fields, wxcard.FieldUserID)
  41170. }
  41171. if m.wx_user_id != nil {
  41172. fields = append(fields, wxcard.FieldWxUserID)
  41173. }
  41174. if m.avatar != nil {
  41175. fields = append(fields, wxcard.FieldAvatar)
  41176. }
  41177. if m.logo != nil {
  41178. fields = append(fields, wxcard.FieldLogo)
  41179. }
  41180. if m.name != nil {
  41181. fields = append(fields, wxcard.FieldName)
  41182. }
  41183. if m.company != nil {
  41184. fields = append(fields, wxcard.FieldCompany)
  41185. }
  41186. if m.address != nil {
  41187. fields = append(fields, wxcard.FieldAddress)
  41188. }
  41189. if m.phone != nil {
  41190. fields = append(fields, wxcard.FieldPhone)
  41191. }
  41192. if m.official_account != nil {
  41193. fields = append(fields, wxcard.FieldOfficialAccount)
  41194. }
  41195. if m.wechat_account != nil {
  41196. fields = append(fields, wxcard.FieldWechatAccount)
  41197. }
  41198. if m.email != nil {
  41199. fields = append(fields, wxcard.FieldEmail)
  41200. }
  41201. if m.api_base != nil {
  41202. fields = append(fields, wxcard.FieldAPIBase)
  41203. }
  41204. if m.api_key != nil {
  41205. fields = append(fields, wxcard.FieldAPIKey)
  41206. }
  41207. if m.ai_info != nil {
  41208. fields = append(fields, wxcard.FieldAiInfo)
  41209. }
  41210. if m.intro != nil {
  41211. fields = append(fields, wxcard.FieldIntro)
  41212. }
  41213. return fields
  41214. }
  41215. // Field returns the value of a field with the given name. The second boolean
  41216. // return value indicates that this field was not set, or was not defined in the
  41217. // schema.
  41218. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  41219. switch name {
  41220. case wxcard.FieldCreatedAt:
  41221. return m.CreatedAt()
  41222. case wxcard.FieldUpdatedAt:
  41223. return m.UpdatedAt()
  41224. case wxcard.FieldDeletedAt:
  41225. return m.DeletedAt()
  41226. case wxcard.FieldUserID:
  41227. return m.UserID()
  41228. case wxcard.FieldWxUserID:
  41229. return m.WxUserID()
  41230. case wxcard.FieldAvatar:
  41231. return m.Avatar()
  41232. case wxcard.FieldLogo:
  41233. return m.Logo()
  41234. case wxcard.FieldName:
  41235. return m.Name()
  41236. case wxcard.FieldCompany:
  41237. return m.Company()
  41238. case wxcard.FieldAddress:
  41239. return m.Address()
  41240. case wxcard.FieldPhone:
  41241. return m.Phone()
  41242. case wxcard.FieldOfficialAccount:
  41243. return m.OfficialAccount()
  41244. case wxcard.FieldWechatAccount:
  41245. return m.WechatAccount()
  41246. case wxcard.FieldEmail:
  41247. return m.Email()
  41248. case wxcard.FieldAPIBase:
  41249. return m.APIBase()
  41250. case wxcard.FieldAPIKey:
  41251. return m.APIKey()
  41252. case wxcard.FieldAiInfo:
  41253. return m.AiInfo()
  41254. case wxcard.FieldIntro:
  41255. return m.Intro()
  41256. }
  41257. return nil, false
  41258. }
  41259. // OldField returns the old value of the field from the database. An error is
  41260. // returned if the mutation operation is not UpdateOne, or the query to the
  41261. // database failed.
  41262. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41263. switch name {
  41264. case wxcard.FieldCreatedAt:
  41265. return m.OldCreatedAt(ctx)
  41266. case wxcard.FieldUpdatedAt:
  41267. return m.OldUpdatedAt(ctx)
  41268. case wxcard.FieldDeletedAt:
  41269. return m.OldDeletedAt(ctx)
  41270. case wxcard.FieldUserID:
  41271. return m.OldUserID(ctx)
  41272. case wxcard.FieldWxUserID:
  41273. return m.OldWxUserID(ctx)
  41274. case wxcard.FieldAvatar:
  41275. return m.OldAvatar(ctx)
  41276. case wxcard.FieldLogo:
  41277. return m.OldLogo(ctx)
  41278. case wxcard.FieldName:
  41279. return m.OldName(ctx)
  41280. case wxcard.FieldCompany:
  41281. return m.OldCompany(ctx)
  41282. case wxcard.FieldAddress:
  41283. return m.OldAddress(ctx)
  41284. case wxcard.FieldPhone:
  41285. return m.OldPhone(ctx)
  41286. case wxcard.FieldOfficialAccount:
  41287. return m.OldOfficialAccount(ctx)
  41288. case wxcard.FieldWechatAccount:
  41289. return m.OldWechatAccount(ctx)
  41290. case wxcard.FieldEmail:
  41291. return m.OldEmail(ctx)
  41292. case wxcard.FieldAPIBase:
  41293. return m.OldAPIBase(ctx)
  41294. case wxcard.FieldAPIKey:
  41295. return m.OldAPIKey(ctx)
  41296. case wxcard.FieldAiInfo:
  41297. return m.OldAiInfo(ctx)
  41298. case wxcard.FieldIntro:
  41299. return m.OldIntro(ctx)
  41300. }
  41301. return nil, fmt.Errorf("unknown WxCard field %s", name)
  41302. }
  41303. // SetField sets the value of a field with the given name. It returns an error if
  41304. // the field is not defined in the schema, or if the type mismatched the field
  41305. // type.
  41306. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  41307. switch name {
  41308. case wxcard.FieldCreatedAt:
  41309. v, ok := value.(time.Time)
  41310. if !ok {
  41311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41312. }
  41313. m.SetCreatedAt(v)
  41314. return nil
  41315. case wxcard.FieldUpdatedAt:
  41316. v, ok := value.(time.Time)
  41317. if !ok {
  41318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41319. }
  41320. m.SetUpdatedAt(v)
  41321. return nil
  41322. case wxcard.FieldDeletedAt:
  41323. v, ok := value.(time.Time)
  41324. if !ok {
  41325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41326. }
  41327. m.SetDeletedAt(v)
  41328. return nil
  41329. case wxcard.FieldUserID:
  41330. v, ok := value.(uint64)
  41331. if !ok {
  41332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41333. }
  41334. m.SetUserID(v)
  41335. return nil
  41336. case wxcard.FieldWxUserID:
  41337. v, ok := value.(uint64)
  41338. if !ok {
  41339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41340. }
  41341. m.SetWxUserID(v)
  41342. return nil
  41343. case wxcard.FieldAvatar:
  41344. v, ok := value.(string)
  41345. if !ok {
  41346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41347. }
  41348. m.SetAvatar(v)
  41349. return nil
  41350. case wxcard.FieldLogo:
  41351. v, ok := value.(string)
  41352. if !ok {
  41353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41354. }
  41355. m.SetLogo(v)
  41356. return nil
  41357. case wxcard.FieldName:
  41358. v, ok := value.(string)
  41359. if !ok {
  41360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41361. }
  41362. m.SetName(v)
  41363. return nil
  41364. case wxcard.FieldCompany:
  41365. v, ok := value.(string)
  41366. if !ok {
  41367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41368. }
  41369. m.SetCompany(v)
  41370. return nil
  41371. case wxcard.FieldAddress:
  41372. v, ok := value.(string)
  41373. if !ok {
  41374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41375. }
  41376. m.SetAddress(v)
  41377. return nil
  41378. case wxcard.FieldPhone:
  41379. v, ok := value.(string)
  41380. if !ok {
  41381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41382. }
  41383. m.SetPhone(v)
  41384. return nil
  41385. case wxcard.FieldOfficialAccount:
  41386. v, ok := value.(string)
  41387. if !ok {
  41388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41389. }
  41390. m.SetOfficialAccount(v)
  41391. return nil
  41392. case wxcard.FieldWechatAccount:
  41393. v, ok := value.(string)
  41394. if !ok {
  41395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41396. }
  41397. m.SetWechatAccount(v)
  41398. return nil
  41399. case wxcard.FieldEmail:
  41400. v, ok := value.(string)
  41401. if !ok {
  41402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41403. }
  41404. m.SetEmail(v)
  41405. return nil
  41406. case wxcard.FieldAPIBase:
  41407. v, ok := value.(string)
  41408. if !ok {
  41409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41410. }
  41411. m.SetAPIBase(v)
  41412. return nil
  41413. case wxcard.FieldAPIKey:
  41414. v, ok := value.(string)
  41415. if !ok {
  41416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41417. }
  41418. m.SetAPIKey(v)
  41419. return nil
  41420. case wxcard.FieldAiInfo:
  41421. v, ok := value.(string)
  41422. if !ok {
  41423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41424. }
  41425. m.SetAiInfo(v)
  41426. return nil
  41427. case wxcard.FieldIntro:
  41428. v, ok := value.(string)
  41429. if !ok {
  41430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41431. }
  41432. m.SetIntro(v)
  41433. return nil
  41434. }
  41435. return fmt.Errorf("unknown WxCard field %s", name)
  41436. }
  41437. // AddedFields returns all numeric fields that were incremented/decremented during
  41438. // this mutation.
  41439. func (m *WxCardMutation) AddedFields() []string {
  41440. var fields []string
  41441. if m.adduser_id != nil {
  41442. fields = append(fields, wxcard.FieldUserID)
  41443. }
  41444. if m.addwx_user_id != nil {
  41445. fields = append(fields, wxcard.FieldWxUserID)
  41446. }
  41447. return fields
  41448. }
  41449. // AddedField returns the numeric value that was incremented/decremented on a field
  41450. // with the given name. The second boolean return value indicates that this field
  41451. // was not set, or was not defined in the schema.
  41452. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  41453. switch name {
  41454. case wxcard.FieldUserID:
  41455. return m.AddedUserID()
  41456. case wxcard.FieldWxUserID:
  41457. return m.AddedWxUserID()
  41458. }
  41459. return nil, false
  41460. }
  41461. // AddField adds the value to the field with the given name. It returns an error if
  41462. // the field is not defined in the schema, or if the type mismatched the field
  41463. // type.
  41464. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  41465. switch name {
  41466. case wxcard.FieldUserID:
  41467. v, ok := value.(int64)
  41468. if !ok {
  41469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41470. }
  41471. m.AddUserID(v)
  41472. return nil
  41473. case wxcard.FieldWxUserID:
  41474. v, ok := value.(int64)
  41475. if !ok {
  41476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41477. }
  41478. m.AddWxUserID(v)
  41479. return nil
  41480. }
  41481. return fmt.Errorf("unknown WxCard numeric field %s", name)
  41482. }
  41483. // ClearedFields returns all nullable fields that were cleared during this
  41484. // mutation.
  41485. func (m *WxCardMutation) ClearedFields() []string {
  41486. var fields []string
  41487. if m.FieldCleared(wxcard.FieldDeletedAt) {
  41488. fields = append(fields, wxcard.FieldDeletedAt)
  41489. }
  41490. if m.FieldCleared(wxcard.FieldUserID) {
  41491. fields = append(fields, wxcard.FieldUserID)
  41492. }
  41493. if m.FieldCleared(wxcard.FieldWxUserID) {
  41494. fields = append(fields, wxcard.FieldWxUserID)
  41495. }
  41496. if m.FieldCleared(wxcard.FieldEmail) {
  41497. fields = append(fields, wxcard.FieldEmail)
  41498. }
  41499. if m.FieldCleared(wxcard.FieldAPIBase) {
  41500. fields = append(fields, wxcard.FieldAPIBase)
  41501. }
  41502. if m.FieldCleared(wxcard.FieldAPIKey) {
  41503. fields = append(fields, wxcard.FieldAPIKey)
  41504. }
  41505. if m.FieldCleared(wxcard.FieldAiInfo) {
  41506. fields = append(fields, wxcard.FieldAiInfo)
  41507. }
  41508. if m.FieldCleared(wxcard.FieldIntro) {
  41509. fields = append(fields, wxcard.FieldIntro)
  41510. }
  41511. return fields
  41512. }
  41513. // FieldCleared returns a boolean indicating if a field with the given name was
  41514. // cleared in this mutation.
  41515. func (m *WxCardMutation) FieldCleared(name string) bool {
  41516. _, ok := m.clearedFields[name]
  41517. return ok
  41518. }
  41519. // ClearField clears the value of the field with the given name. It returns an
  41520. // error if the field is not defined in the schema.
  41521. func (m *WxCardMutation) ClearField(name string) error {
  41522. switch name {
  41523. case wxcard.FieldDeletedAt:
  41524. m.ClearDeletedAt()
  41525. return nil
  41526. case wxcard.FieldUserID:
  41527. m.ClearUserID()
  41528. return nil
  41529. case wxcard.FieldWxUserID:
  41530. m.ClearWxUserID()
  41531. return nil
  41532. case wxcard.FieldEmail:
  41533. m.ClearEmail()
  41534. return nil
  41535. case wxcard.FieldAPIBase:
  41536. m.ClearAPIBase()
  41537. return nil
  41538. case wxcard.FieldAPIKey:
  41539. m.ClearAPIKey()
  41540. return nil
  41541. case wxcard.FieldAiInfo:
  41542. m.ClearAiInfo()
  41543. return nil
  41544. case wxcard.FieldIntro:
  41545. m.ClearIntro()
  41546. return nil
  41547. }
  41548. return fmt.Errorf("unknown WxCard nullable field %s", name)
  41549. }
  41550. // ResetField resets all changes in the mutation for the field with the given name.
  41551. // It returns an error if the field is not defined in the schema.
  41552. func (m *WxCardMutation) ResetField(name string) error {
  41553. switch name {
  41554. case wxcard.FieldCreatedAt:
  41555. m.ResetCreatedAt()
  41556. return nil
  41557. case wxcard.FieldUpdatedAt:
  41558. m.ResetUpdatedAt()
  41559. return nil
  41560. case wxcard.FieldDeletedAt:
  41561. m.ResetDeletedAt()
  41562. return nil
  41563. case wxcard.FieldUserID:
  41564. m.ResetUserID()
  41565. return nil
  41566. case wxcard.FieldWxUserID:
  41567. m.ResetWxUserID()
  41568. return nil
  41569. case wxcard.FieldAvatar:
  41570. m.ResetAvatar()
  41571. return nil
  41572. case wxcard.FieldLogo:
  41573. m.ResetLogo()
  41574. return nil
  41575. case wxcard.FieldName:
  41576. m.ResetName()
  41577. return nil
  41578. case wxcard.FieldCompany:
  41579. m.ResetCompany()
  41580. return nil
  41581. case wxcard.FieldAddress:
  41582. m.ResetAddress()
  41583. return nil
  41584. case wxcard.FieldPhone:
  41585. m.ResetPhone()
  41586. return nil
  41587. case wxcard.FieldOfficialAccount:
  41588. m.ResetOfficialAccount()
  41589. return nil
  41590. case wxcard.FieldWechatAccount:
  41591. m.ResetWechatAccount()
  41592. return nil
  41593. case wxcard.FieldEmail:
  41594. m.ResetEmail()
  41595. return nil
  41596. case wxcard.FieldAPIBase:
  41597. m.ResetAPIBase()
  41598. return nil
  41599. case wxcard.FieldAPIKey:
  41600. m.ResetAPIKey()
  41601. return nil
  41602. case wxcard.FieldAiInfo:
  41603. m.ResetAiInfo()
  41604. return nil
  41605. case wxcard.FieldIntro:
  41606. m.ResetIntro()
  41607. return nil
  41608. }
  41609. return fmt.Errorf("unknown WxCard field %s", name)
  41610. }
  41611. // AddedEdges returns all edge names that were set/added in this mutation.
  41612. func (m *WxCardMutation) AddedEdges() []string {
  41613. edges := make([]string, 0, 0)
  41614. return edges
  41615. }
  41616. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41617. // name in this mutation.
  41618. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  41619. return nil
  41620. }
  41621. // RemovedEdges returns all edge names that were removed in this mutation.
  41622. func (m *WxCardMutation) RemovedEdges() []string {
  41623. edges := make([]string, 0, 0)
  41624. return edges
  41625. }
  41626. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41627. // the given name in this mutation.
  41628. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  41629. return nil
  41630. }
  41631. // ClearedEdges returns all edge names that were cleared in this mutation.
  41632. func (m *WxCardMutation) ClearedEdges() []string {
  41633. edges := make([]string, 0, 0)
  41634. return edges
  41635. }
  41636. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41637. // was cleared in this mutation.
  41638. func (m *WxCardMutation) EdgeCleared(name string) bool {
  41639. return false
  41640. }
  41641. // ClearEdge clears the value of the edge with the given name. It returns an error
  41642. // if that edge is not defined in the schema.
  41643. func (m *WxCardMutation) ClearEdge(name string) error {
  41644. return fmt.Errorf("unknown WxCard unique edge %s", name)
  41645. }
  41646. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41647. // It returns an error if the edge is not defined in the schema.
  41648. func (m *WxCardMutation) ResetEdge(name string) error {
  41649. return fmt.Errorf("unknown WxCard edge %s", name)
  41650. }
  41651. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  41652. type WxCardUserMutation struct {
  41653. config
  41654. op Op
  41655. typ string
  41656. id *uint64
  41657. created_at *time.Time
  41658. updated_at *time.Time
  41659. deleted_at *time.Time
  41660. wxid *string
  41661. account *string
  41662. avatar *string
  41663. nickname *string
  41664. remark *string
  41665. phone *string
  41666. open_id *string
  41667. union_id *string
  41668. session_key *string
  41669. is_vip *int
  41670. addis_vip *int
  41671. clearedFields map[string]struct{}
  41672. done bool
  41673. oldValue func(context.Context) (*WxCardUser, error)
  41674. predicates []predicate.WxCardUser
  41675. }
  41676. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  41677. // wxcarduserOption allows management of the mutation configuration using functional options.
  41678. type wxcarduserOption func(*WxCardUserMutation)
  41679. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  41680. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  41681. m := &WxCardUserMutation{
  41682. config: c,
  41683. op: op,
  41684. typ: TypeWxCardUser,
  41685. clearedFields: make(map[string]struct{}),
  41686. }
  41687. for _, opt := range opts {
  41688. opt(m)
  41689. }
  41690. return m
  41691. }
  41692. // withWxCardUserID sets the ID field of the mutation.
  41693. func withWxCardUserID(id uint64) wxcarduserOption {
  41694. return func(m *WxCardUserMutation) {
  41695. var (
  41696. err error
  41697. once sync.Once
  41698. value *WxCardUser
  41699. )
  41700. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  41701. once.Do(func() {
  41702. if m.done {
  41703. err = errors.New("querying old values post mutation is not allowed")
  41704. } else {
  41705. value, err = m.Client().WxCardUser.Get(ctx, id)
  41706. }
  41707. })
  41708. return value, err
  41709. }
  41710. m.id = &id
  41711. }
  41712. }
  41713. // withWxCardUser sets the old WxCardUser of the mutation.
  41714. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  41715. return func(m *WxCardUserMutation) {
  41716. m.oldValue = func(context.Context) (*WxCardUser, error) {
  41717. return node, nil
  41718. }
  41719. m.id = &node.ID
  41720. }
  41721. }
  41722. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41723. // executed in a transaction (ent.Tx), a transactional client is returned.
  41724. func (m WxCardUserMutation) Client() *Client {
  41725. client := &Client{config: m.config}
  41726. client.init()
  41727. return client
  41728. }
  41729. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41730. // it returns an error otherwise.
  41731. func (m WxCardUserMutation) Tx() (*Tx, error) {
  41732. if _, ok := m.driver.(*txDriver); !ok {
  41733. return nil, errors.New("ent: mutation is not running in a transaction")
  41734. }
  41735. tx := &Tx{config: m.config}
  41736. tx.init()
  41737. return tx, nil
  41738. }
  41739. // SetID sets the value of the id field. Note that this
  41740. // operation is only accepted on creation of WxCardUser entities.
  41741. func (m *WxCardUserMutation) SetID(id uint64) {
  41742. m.id = &id
  41743. }
  41744. // ID returns the ID value in the mutation. Note that the ID is only available
  41745. // if it was provided to the builder or after it was returned from the database.
  41746. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  41747. if m.id == nil {
  41748. return
  41749. }
  41750. return *m.id, true
  41751. }
  41752. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41753. // That means, if the mutation is applied within a transaction with an isolation level such
  41754. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41755. // or updated by the mutation.
  41756. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  41757. switch {
  41758. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41759. id, exists := m.ID()
  41760. if exists {
  41761. return []uint64{id}, nil
  41762. }
  41763. fallthrough
  41764. case m.op.Is(OpUpdate | OpDelete):
  41765. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  41766. default:
  41767. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41768. }
  41769. }
  41770. // SetCreatedAt sets the "created_at" field.
  41771. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  41772. m.created_at = &t
  41773. }
  41774. // CreatedAt returns the value of the "created_at" field in the mutation.
  41775. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  41776. v := m.created_at
  41777. if v == nil {
  41778. return
  41779. }
  41780. return *v, true
  41781. }
  41782. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  41783. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41785. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41786. if !m.op.Is(OpUpdateOne) {
  41787. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41788. }
  41789. if m.id == nil || m.oldValue == nil {
  41790. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41791. }
  41792. oldValue, err := m.oldValue(ctx)
  41793. if err != nil {
  41794. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41795. }
  41796. return oldValue.CreatedAt, nil
  41797. }
  41798. // ResetCreatedAt resets all changes to the "created_at" field.
  41799. func (m *WxCardUserMutation) ResetCreatedAt() {
  41800. m.created_at = nil
  41801. }
  41802. // SetUpdatedAt sets the "updated_at" field.
  41803. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  41804. m.updated_at = &t
  41805. }
  41806. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41807. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  41808. v := m.updated_at
  41809. if v == nil {
  41810. return
  41811. }
  41812. return *v, true
  41813. }
  41814. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  41815. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41817. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41818. if !m.op.Is(OpUpdateOne) {
  41819. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41820. }
  41821. if m.id == nil || m.oldValue == nil {
  41822. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41823. }
  41824. oldValue, err := m.oldValue(ctx)
  41825. if err != nil {
  41826. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41827. }
  41828. return oldValue.UpdatedAt, nil
  41829. }
  41830. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41831. func (m *WxCardUserMutation) ResetUpdatedAt() {
  41832. m.updated_at = nil
  41833. }
  41834. // SetDeletedAt sets the "deleted_at" field.
  41835. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  41836. m.deleted_at = &t
  41837. }
  41838. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41839. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  41840. v := m.deleted_at
  41841. if v == nil {
  41842. return
  41843. }
  41844. return *v, true
  41845. }
  41846. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  41847. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41849. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41850. if !m.op.Is(OpUpdateOne) {
  41851. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41852. }
  41853. if m.id == nil || m.oldValue == nil {
  41854. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41855. }
  41856. oldValue, err := m.oldValue(ctx)
  41857. if err != nil {
  41858. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41859. }
  41860. return oldValue.DeletedAt, nil
  41861. }
  41862. // ClearDeletedAt clears the value of the "deleted_at" field.
  41863. func (m *WxCardUserMutation) ClearDeletedAt() {
  41864. m.deleted_at = nil
  41865. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  41866. }
  41867. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41868. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  41869. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  41870. return ok
  41871. }
  41872. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41873. func (m *WxCardUserMutation) ResetDeletedAt() {
  41874. m.deleted_at = nil
  41875. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  41876. }
  41877. // SetWxid sets the "wxid" field.
  41878. func (m *WxCardUserMutation) SetWxid(s string) {
  41879. m.wxid = &s
  41880. }
  41881. // Wxid returns the value of the "wxid" field in the mutation.
  41882. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  41883. v := m.wxid
  41884. if v == nil {
  41885. return
  41886. }
  41887. return *v, true
  41888. }
  41889. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  41890. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41892. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  41893. if !m.op.Is(OpUpdateOne) {
  41894. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  41895. }
  41896. if m.id == nil || m.oldValue == nil {
  41897. return v, errors.New("OldWxid requires an ID field in the mutation")
  41898. }
  41899. oldValue, err := m.oldValue(ctx)
  41900. if err != nil {
  41901. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41902. }
  41903. return oldValue.Wxid, nil
  41904. }
  41905. // ResetWxid resets all changes to the "wxid" field.
  41906. func (m *WxCardUserMutation) ResetWxid() {
  41907. m.wxid = nil
  41908. }
  41909. // SetAccount sets the "account" field.
  41910. func (m *WxCardUserMutation) SetAccount(s string) {
  41911. m.account = &s
  41912. }
  41913. // Account returns the value of the "account" field in the mutation.
  41914. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  41915. v := m.account
  41916. if v == nil {
  41917. return
  41918. }
  41919. return *v, true
  41920. }
  41921. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  41922. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41924. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  41925. if !m.op.Is(OpUpdateOne) {
  41926. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41927. }
  41928. if m.id == nil || m.oldValue == nil {
  41929. return v, errors.New("OldAccount requires an ID field in the mutation")
  41930. }
  41931. oldValue, err := m.oldValue(ctx)
  41932. if err != nil {
  41933. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  41934. }
  41935. return oldValue.Account, nil
  41936. }
  41937. // ResetAccount resets all changes to the "account" field.
  41938. func (m *WxCardUserMutation) ResetAccount() {
  41939. m.account = nil
  41940. }
  41941. // SetAvatar sets the "avatar" field.
  41942. func (m *WxCardUserMutation) SetAvatar(s string) {
  41943. m.avatar = &s
  41944. }
  41945. // Avatar returns the value of the "avatar" field in the mutation.
  41946. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  41947. v := m.avatar
  41948. if v == nil {
  41949. return
  41950. }
  41951. return *v, true
  41952. }
  41953. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  41954. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41956. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41957. if !m.op.Is(OpUpdateOne) {
  41958. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41959. }
  41960. if m.id == nil || m.oldValue == nil {
  41961. return v, errors.New("OldAvatar requires an ID field in the mutation")
  41962. }
  41963. oldValue, err := m.oldValue(ctx)
  41964. if err != nil {
  41965. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  41966. }
  41967. return oldValue.Avatar, nil
  41968. }
  41969. // ResetAvatar resets all changes to the "avatar" field.
  41970. func (m *WxCardUserMutation) ResetAvatar() {
  41971. m.avatar = nil
  41972. }
  41973. // SetNickname sets the "nickname" field.
  41974. func (m *WxCardUserMutation) SetNickname(s string) {
  41975. m.nickname = &s
  41976. }
  41977. // Nickname returns the value of the "nickname" field in the mutation.
  41978. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  41979. v := m.nickname
  41980. if v == nil {
  41981. return
  41982. }
  41983. return *v, true
  41984. }
  41985. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  41986. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41988. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  41989. if !m.op.Is(OpUpdateOne) {
  41990. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41991. }
  41992. if m.id == nil || m.oldValue == nil {
  41993. return v, errors.New("OldNickname requires an ID field in the mutation")
  41994. }
  41995. oldValue, err := m.oldValue(ctx)
  41996. if err != nil {
  41997. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41998. }
  41999. return oldValue.Nickname, nil
  42000. }
  42001. // ResetNickname resets all changes to the "nickname" field.
  42002. func (m *WxCardUserMutation) ResetNickname() {
  42003. m.nickname = nil
  42004. }
  42005. // SetRemark sets the "remark" field.
  42006. func (m *WxCardUserMutation) SetRemark(s string) {
  42007. m.remark = &s
  42008. }
  42009. // Remark returns the value of the "remark" field in the mutation.
  42010. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  42011. v := m.remark
  42012. if v == nil {
  42013. return
  42014. }
  42015. return *v, true
  42016. }
  42017. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  42018. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42020. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  42021. if !m.op.Is(OpUpdateOne) {
  42022. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  42023. }
  42024. if m.id == nil || m.oldValue == nil {
  42025. return v, errors.New("OldRemark requires an ID field in the mutation")
  42026. }
  42027. oldValue, err := m.oldValue(ctx)
  42028. if err != nil {
  42029. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  42030. }
  42031. return oldValue.Remark, nil
  42032. }
  42033. // ResetRemark resets all changes to the "remark" field.
  42034. func (m *WxCardUserMutation) ResetRemark() {
  42035. m.remark = nil
  42036. }
  42037. // SetPhone sets the "phone" field.
  42038. func (m *WxCardUserMutation) SetPhone(s string) {
  42039. m.phone = &s
  42040. }
  42041. // Phone returns the value of the "phone" field in the mutation.
  42042. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  42043. v := m.phone
  42044. if v == nil {
  42045. return
  42046. }
  42047. return *v, true
  42048. }
  42049. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  42050. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42052. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  42053. if !m.op.Is(OpUpdateOne) {
  42054. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  42055. }
  42056. if m.id == nil || m.oldValue == nil {
  42057. return v, errors.New("OldPhone requires an ID field in the mutation")
  42058. }
  42059. oldValue, err := m.oldValue(ctx)
  42060. if err != nil {
  42061. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  42062. }
  42063. return oldValue.Phone, nil
  42064. }
  42065. // ResetPhone resets all changes to the "phone" field.
  42066. func (m *WxCardUserMutation) ResetPhone() {
  42067. m.phone = nil
  42068. }
  42069. // SetOpenID sets the "open_id" field.
  42070. func (m *WxCardUserMutation) SetOpenID(s string) {
  42071. m.open_id = &s
  42072. }
  42073. // OpenID returns the value of the "open_id" field in the mutation.
  42074. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  42075. v := m.open_id
  42076. if v == nil {
  42077. return
  42078. }
  42079. return *v, true
  42080. }
  42081. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  42082. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42084. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  42085. if !m.op.Is(OpUpdateOne) {
  42086. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  42087. }
  42088. if m.id == nil || m.oldValue == nil {
  42089. return v, errors.New("OldOpenID requires an ID field in the mutation")
  42090. }
  42091. oldValue, err := m.oldValue(ctx)
  42092. if err != nil {
  42093. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  42094. }
  42095. return oldValue.OpenID, nil
  42096. }
  42097. // ResetOpenID resets all changes to the "open_id" field.
  42098. func (m *WxCardUserMutation) ResetOpenID() {
  42099. m.open_id = nil
  42100. }
  42101. // SetUnionID sets the "union_id" field.
  42102. func (m *WxCardUserMutation) SetUnionID(s string) {
  42103. m.union_id = &s
  42104. }
  42105. // UnionID returns the value of the "union_id" field in the mutation.
  42106. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  42107. v := m.union_id
  42108. if v == nil {
  42109. return
  42110. }
  42111. return *v, true
  42112. }
  42113. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  42114. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42116. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  42117. if !m.op.Is(OpUpdateOne) {
  42118. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  42119. }
  42120. if m.id == nil || m.oldValue == nil {
  42121. return v, errors.New("OldUnionID requires an ID field in the mutation")
  42122. }
  42123. oldValue, err := m.oldValue(ctx)
  42124. if err != nil {
  42125. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  42126. }
  42127. return oldValue.UnionID, nil
  42128. }
  42129. // ResetUnionID resets all changes to the "union_id" field.
  42130. func (m *WxCardUserMutation) ResetUnionID() {
  42131. m.union_id = nil
  42132. }
  42133. // SetSessionKey sets the "session_key" field.
  42134. func (m *WxCardUserMutation) SetSessionKey(s string) {
  42135. m.session_key = &s
  42136. }
  42137. // SessionKey returns the value of the "session_key" field in the mutation.
  42138. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  42139. v := m.session_key
  42140. if v == nil {
  42141. return
  42142. }
  42143. return *v, true
  42144. }
  42145. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  42146. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42148. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  42149. if !m.op.Is(OpUpdateOne) {
  42150. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  42151. }
  42152. if m.id == nil || m.oldValue == nil {
  42153. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  42154. }
  42155. oldValue, err := m.oldValue(ctx)
  42156. if err != nil {
  42157. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  42158. }
  42159. return oldValue.SessionKey, nil
  42160. }
  42161. // ResetSessionKey resets all changes to the "session_key" field.
  42162. func (m *WxCardUserMutation) ResetSessionKey() {
  42163. m.session_key = nil
  42164. }
  42165. // SetIsVip sets the "is_vip" field.
  42166. func (m *WxCardUserMutation) SetIsVip(i int) {
  42167. m.is_vip = &i
  42168. m.addis_vip = nil
  42169. }
  42170. // IsVip returns the value of the "is_vip" field in the mutation.
  42171. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  42172. v := m.is_vip
  42173. if v == nil {
  42174. return
  42175. }
  42176. return *v, true
  42177. }
  42178. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  42179. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42181. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  42182. if !m.op.Is(OpUpdateOne) {
  42183. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  42184. }
  42185. if m.id == nil || m.oldValue == nil {
  42186. return v, errors.New("OldIsVip requires an ID field in the mutation")
  42187. }
  42188. oldValue, err := m.oldValue(ctx)
  42189. if err != nil {
  42190. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  42191. }
  42192. return oldValue.IsVip, nil
  42193. }
  42194. // AddIsVip adds i to the "is_vip" field.
  42195. func (m *WxCardUserMutation) AddIsVip(i int) {
  42196. if m.addis_vip != nil {
  42197. *m.addis_vip += i
  42198. } else {
  42199. m.addis_vip = &i
  42200. }
  42201. }
  42202. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  42203. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  42204. v := m.addis_vip
  42205. if v == nil {
  42206. return
  42207. }
  42208. return *v, true
  42209. }
  42210. // ResetIsVip resets all changes to the "is_vip" field.
  42211. func (m *WxCardUserMutation) ResetIsVip() {
  42212. m.is_vip = nil
  42213. m.addis_vip = nil
  42214. }
  42215. // Where appends a list predicates to the WxCardUserMutation builder.
  42216. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  42217. m.predicates = append(m.predicates, ps...)
  42218. }
  42219. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  42220. // users can use type-assertion to append predicates that do not depend on any generated package.
  42221. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  42222. p := make([]predicate.WxCardUser, len(ps))
  42223. for i := range ps {
  42224. p[i] = ps[i]
  42225. }
  42226. m.Where(p...)
  42227. }
  42228. // Op returns the operation name.
  42229. func (m *WxCardUserMutation) Op() Op {
  42230. return m.op
  42231. }
  42232. // SetOp allows setting the mutation operation.
  42233. func (m *WxCardUserMutation) SetOp(op Op) {
  42234. m.op = op
  42235. }
  42236. // Type returns the node type of this mutation (WxCardUser).
  42237. func (m *WxCardUserMutation) Type() string {
  42238. return m.typ
  42239. }
  42240. // Fields returns all fields that were changed during this mutation. Note that in
  42241. // order to get all numeric fields that were incremented/decremented, call
  42242. // AddedFields().
  42243. func (m *WxCardUserMutation) Fields() []string {
  42244. fields := make([]string, 0, 13)
  42245. if m.created_at != nil {
  42246. fields = append(fields, wxcarduser.FieldCreatedAt)
  42247. }
  42248. if m.updated_at != nil {
  42249. fields = append(fields, wxcarduser.FieldUpdatedAt)
  42250. }
  42251. if m.deleted_at != nil {
  42252. fields = append(fields, wxcarduser.FieldDeletedAt)
  42253. }
  42254. if m.wxid != nil {
  42255. fields = append(fields, wxcarduser.FieldWxid)
  42256. }
  42257. if m.account != nil {
  42258. fields = append(fields, wxcarduser.FieldAccount)
  42259. }
  42260. if m.avatar != nil {
  42261. fields = append(fields, wxcarduser.FieldAvatar)
  42262. }
  42263. if m.nickname != nil {
  42264. fields = append(fields, wxcarduser.FieldNickname)
  42265. }
  42266. if m.remark != nil {
  42267. fields = append(fields, wxcarduser.FieldRemark)
  42268. }
  42269. if m.phone != nil {
  42270. fields = append(fields, wxcarduser.FieldPhone)
  42271. }
  42272. if m.open_id != nil {
  42273. fields = append(fields, wxcarduser.FieldOpenID)
  42274. }
  42275. if m.union_id != nil {
  42276. fields = append(fields, wxcarduser.FieldUnionID)
  42277. }
  42278. if m.session_key != nil {
  42279. fields = append(fields, wxcarduser.FieldSessionKey)
  42280. }
  42281. if m.is_vip != nil {
  42282. fields = append(fields, wxcarduser.FieldIsVip)
  42283. }
  42284. return fields
  42285. }
  42286. // Field returns the value of a field with the given name. The second boolean
  42287. // return value indicates that this field was not set, or was not defined in the
  42288. // schema.
  42289. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  42290. switch name {
  42291. case wxcarduser.FieldCreatedAt:
  42292. return m.CreatedAt()
  42293. case wxcarduser.FieldUpdatedAt:
  42294. return m.UpdatedAt()
  42295. case wxcarduser.FieldDeletedAt:
  42296. return m.DeletedAt()
  42297. case wxcarduser.FieldWxid:
  42298. return m.Wxid()
  42299. case wxcarduser.FieldAccount:
  42300. return m.Account()
  42301. case wxcarduser.FieldAvatar:
  42302. return m.Avatar()
  42303. case wxcarduser.FieldNickname:
  42304. return m.Nickname()
  42305. case wxcarduser.FieldRemark:
  42306. return m.Remark()
  42307. case wxcarduser.FieldPhone:
  42308. return m.Phone()
  42309. case wxcarduser.FieldOpenID:
  42310. return m.OpenID()
  42311. case wxcarduser.FieldUnionID:
  42312. return m.UnionID()
  42313. case wxcarduser.FieldSessionKey:
  42314. return m.SessionKey()
  42315. case wxcarduser.FieldIsVip:
  42316. return m.IsVip()
  42317. }
  42318. return nil, false
  42319. }
  42320. // OldField returns the old value of the field from the database. An error is
  42321. // returned if the mutation operation is not UpdateOne, or the query to the
  42322. // database failed.
  42323. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42324. switch name {
  42325. case wxcarduser.FieldCreatedAt:
  42326. return m.OldCreatedAt(ctx)
  42327. case wxcarduser.FieldUpdatedAt:
  42328. return m.OldUpdatedAt(ctx)
  42329. case wxcarduser.FieldDeletedAt:
  42330. return m.OldDeletedAt(ctx)
  42331. case wxcarduser.FieldWxid:
  42332. return m.OldWxid(ctx)
  42333. case wxcarduser.FieldAccount:
  42334. return m.OldAccount(ctx)
  42335. case wxcarduser.FieldAvatar:
  42336. return m.OldAvatar(ctx)
  42337. case wxcarduser.FieldNickname:
  42338. return m.OldNickname(ctx)
  42339. case wxcarduser.FieldRemark:
  42340. return m.OldRemark(ctx)
  42341. case wxcarduser.FieldPhone:
  42342. return m.OldPhone(ctx)
  42343. case wxcarduser.FieldOpenID:
  42344. return m.OldOpenID(ctx)
  42345. case wxcarduser.FieldUnionID:
  42346. return m.OldUnionID(ctx)
  42347. case wxcarduser.FieldSessionKey:
  42348. return m.OldSessionKey(ctx)
  42349. case wxcarduser.FieldIsVip:
  42350. return m.OldIsVip(ctx)
  42351. }
  42352. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  42353. }
  42354. // SetField sets the value of a field with the given name. It returns an error if
  42355. // the field is not defined in the schema, or if the type mismatched the field
  42356. // type.
  42357. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  42358. switch name {
  42359. case wxcarduser.FieldCreatedAt:
  42360. v, ok := value.(time.Time)
  42361. if !ok {
  42362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42363. }
  42364. m.SetCreatedAt(v)
  42365. return nil
  42366. case wxcarduser.FieldUpdatedAt:
  42367. v, ok := value.(time.Time)
  42368. if !ok {
  42369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42370. }
  42371. m.SetUpdatedAt(v)
  42372. return nil
  42373. case wxcarduser.FieldDeletedAt:
  42374. v, ok := value.(time.Time)
  42375. if !ok {
  42376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42377. }
  42378. m.SetDeletedAt(v)
  42379. return nil
  42380. case wxcarduser.FieldWxid:
  42381. v, ok := value.(string)
  42382. if !ok {
  42383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42384. }
  42385. m.SetWxid(v)
  42386. return nil
  42387. case wxcarduser.FieldAccount:
  42388. v, ok := value.(string)
  42389. if !ok {
  42390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42391. }
  42392. m.SetAccount(v)
  42393. return nil
  42394. case wxcarduser.FieldAvatar:
  42395. v, ok := value.(string)
  42396. if !ok {
  42397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42398. }
  42399. m.SetAvatar(v)
  42400. return nil
  42401. case wxcarduser.FieldNickname:
  42402. v, ok := value.(string)
  42403. if !ok {
  42404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42405. }
  42406. m.SetNickname(v)
  42407. return nil
  42408. case wxcarduser.FieldRemark:
  42409. v, ok := value.(string)
  42410. if !ok {
  42411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42412. }
  42413. m.SetRemark(v)
  42414. return nil
  42415. case wxcarduser.FieldPhone:
  42416. v, ok := value.(string)
  42417. if !ok {
  42418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42419. }
  42420. m.SetPhone(v)
  42421. return nil
  42422. case wxcarduser.FieldOpenID:
  42423. v, ok := value.(string)
  42424. if !ok {
  42425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42426. }
  42427. m.SetOpenID(v)
  42428. return nil
  42429. case wxcarduser.FieldUnionID:
  42430. v, ok := value.(string)
  42431. if !ok {
  42432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42433. }
  42434. m.SetUnionID(v)
  42435. return nil
  42436. case wxcarduser.FieldSessionKey:
  42437. v, ok := value.(string)
  42438. if !ok {
  42439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42440. }
  42441. m.SetSessionKey(v)
  42442. return nil
  42443. case wxcarduser.FieldIsVip:
  42444. v, ok := value.(int)
  42445. if !ok {
  42446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42447. }
  42448. m.SetIsVip(v)
  42449. return nil
  42450. }
  42451. return fmt.Errorf("unknown WxCardUser field %s", name)
  42452. }
  42453. // AddedFields returns all numeric fields that were incremented/decremented during
  42454. // this mutation.
  42455. func (m *WxCardUserMutation) AddedFields() []string {
  42456. var fields []string
  42457. if m.addis_vip != nil {
  42458. fields = append(fields, wxcarduser.FieldIsVip)
  42459. }
  42460. return fields
  42461. }
  42462. // AddedField returns the numeric value that was incremented/decremented on a field
  42463. // with the given name. The second boolean return value indicates that this field
  42464. // was not set, or was not defined in the schema.
  42465. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  42466. switch name {
  42467. case wxcarduser.FieldIsVip:
  42468. return m.AddedIsVip()
  42469. }
  42470. return nil, false
  42471. }
  42472. // AddField adds the value to the field with the given name. It returns an error if
  42473. // the field is not defined in the schema, or if the type mismatched the field
  42474. // type.
  42475. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  42476. switch name {
  42477. case wxcarduser.FieldIsVip:
  42478. v, ok := value.(int)
  42479. if !ok {
  42480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42481. }
  42482. m.AddIsVip(v)
  42483. return nil
  42484. }
  42485. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  42486. }
  42487. // ClearedFields returns all nullable fields that were cleared during this
  42488. // mutation.
  42489. func (m *WxCardUserMutation) ClearedFields() []string {
  42490. var fields []string
  42491. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  42492. fields = append(fields, wxcarduser.FieldDeletedAt)
  42493. }
  42494. return fields
  42495. }
  42496. // FieldCleared returns a boolean indicating if a field with the given name was
  42497. // cleared in this mutation.
  42498. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  42499. _, ok := m.clearedFields[name]
  42500. return ok
  42501. }
  42502. // ClearField clears the value of the field with the given name. It returns an
  42503. // error if the field is not defined in the schema.
  42504. func (m *WxCardUserMutation) ClearField(name string) error {
  42505. switch name {
  42506. case wxcarduser.FieldDeletedAt:
  42507. m.ClearDeletedAt()
  42508. return nil
  42509. }
  42510. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  42511. }
  42512. // ResetField resets all changes in the mutation for the field with the given name.
  42513. // It returns an error if the field is not defined in the schema.
  42514. func (m *WxCardUserMutation) ResetField(name string) error {
  42515. switch name {
  42516. case wxcarduser.FieldCreatedAt:
  42517. m.ResetCreatedAt()
  42518. return nil
  42519. case wxcarduser.FieldUpdatedAt:
  42520. m.ResetUpdatedAt()
  42521. return nil
  42522. case wxcarduser.FieldDeletedAt:
  42523. m.ResetDeletedAt()
  42524. return nil
  42525. case wxcarduser.FieldWxid:
  42526. m.ResetWxid()
  42527. return nil
  42528. case wxcarduser.FieldAccount:
  42529. m.ResetAccount()
  42530. return nil
  42531. case wxcarduser.FieldAvatar:
  42532. m.ResetAvatar()
  42533. return nil
  42534. case wxcarduser.FieldNickname:
  42535. m.ResetNickname()
  42536. return nil
  42537. case wxcarduser.FieldRemark:
  42538. m.ResetRemark()
  42539. return nil
  42540. case wxcarduser.FieldPhone:
  42541. m.ResetPhone()
  42542. return nil
  42543. case wxcarduser.FieldOpenID:
  42544. m.ResetOpenID()
  42545. return nil
  42546. case wxcarduser.FieldUnionID:
  42547. m.ResetUnionID()
  42548. return nil
  42549. case wxcarduser.FieldSessionKey:
  42550. m.ResetSessionKey()
  42551. return nil
  42552. case wxcarduser.FieldIsVip:
  42553. m.ResetIsVip()
  42554. return nil
  42555. }
  42556. return fmt.Errorf("unknown WxCardUser field %s", name)
  42557. }
  42558. // AddedEdges returns all edge names that were set/added in this mutation.
  42559. func (m *WxCardUserMutation) AddedEdges() []string {
  42560. edges := make([]string, 0, 0)
  42561. return edges
  42562. }
  42563. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42564. // name in this mutation.
  42565. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  42566. return nil
  42567. }
  42568. // RemovedEdges returns all edge names that were removed in this mutation.
  42569. func (m *WxCardUserMutation) RemovedEdges() []string {
  42570. edges := make([]string, 0, 0)
  42571. return edges
  42572. }
  42573. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42574. // the given name in this mutation.
  42575. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  42576. return nil
  42577. }
  42578. // ClearedEdges returns all edge names that were cleared in this mutation.
  42579. func (m *WxCardUserMutation) ClearedEdges() []string {
  42580. edges := make([]string, 0, 0)
  42581. return edges
  42582. }
  42583. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42584. // was cleared in this mutation.
  42585. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  42586. return false
  42587. }
  42588. // ClearEdge clears the value of the edge with the given name. It returns an error
  42589. // if that edge is not defined in the schema.
  42590. func (m *WxCardUserMutation) ClearEdge(name string) error {
  42591. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  42592. }
  42593. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42594. // It returns an error if the edge is not defined in the schema.
  42595. func (m *WxCardUserMutation) ResetEdge(name string) error {
  42596. return fmt.Errorf("unknown WxCardUser edge %s", name)
  42597. }
  42598. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  42599. type WxCardVisitMutation struct {
  42600. config
  42601. op Op
  42602. typ string
  42603. id *uint64
  42604. created_at *time.Time
  42605. updated_at *time.Time
  42606. deleted_at *time.Time
  42607. user_id *uint64
  42608. adduser_id *int64
  42609. bot_id *uint64
  42610. addbot_id *int64
  42611. bot_type *uint8
  42612. addbot_type *int8
  42613. clearedFields map[string]struct{}
  42614. done bool
  42615. oldValue func(context.Context) (*WxCardVisit, error)
  42616. predicates []predicate.WxCardVisit
  42617. }
  42618. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  42619. // wxcardvisitOption allows management of the mutation configuration using functional options.
  42620. type wxcardvisitOption func(*WxCardVisitMutation)
  42621. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  42622. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  42623. m := &WxCardVisitMutation{
  42624. config: c,
  42625. op: op,
  42626. typ: TypeWxCardVisit,
  42627. clearedFields: make(map[string]struct{}),
  42628. }
  42629. for _, opt := range opts {
  42630. opt(m)
  42631. }
  42632. return m
  42633. }
  42634. // withWxCardVisitID sets the ID field of the mutation.
  42635. func withWxCardVisitID(id uint64) wxcardvisitOption {
  42636. return func(m *WxCardVisitMutation) {
  42637. var (
  42638. err error
  42639. once sync.Once
  42640. value *WxCardVisit
  42641. )
  42642. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  42643. once.Do(func() {
  42644. if m.done {
  42645. err = errors.New("querying old values post mutation is not allowed")
  42646. } else {
  42647. value, err = m.Client().WxCardVisit.Get(ctx, id)
  42648. }
  42649. })
  42650. return value, err
  42651. }
  42652. m.id = &id
  42653. }
  42654. }
  42655. // withWxCardVisit sets the old WxCardVisit of the mutation.
  42656. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  42657. return func(m *WxCardVisitMutation) {
  42658. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  42659. return node, nil
  42660. }
  42661. m.id = &node.ID
  42662. }
  42663. }
  42664. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42665. // executed in a transaction (ent.Tx), a transactional client is returned.
  42666. func (m WxCardVisitMutation) Client() *Client {
  42667. client := &Client{config: m.config}
  42668. client.init()
  42669. return client
  42670. }
  42671. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42672. // it returns an error otherwise.
  42673. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  42674. if _, ok := m.driver.(*txDriver); !ok {
  42675. return nil, errors.New("ent: mutation is not running in a transaction")
  42676. }
  42677. tx := &Tx{config: m.config}
  42678. tx.init()
  42679. return tx, nil
  42680. }
  42681. // SetID sets the value of the id field. Note that this
  42682. // operation is only accepted on creation of WxCardVisit entities.
  42683. func (m *WxCardVisitMutation) SetID(id uint64) {
  42684. m.id = &id
  42685. }
  42686. // ID returns the ID value in the mutation. Note that the ID is only available
  42687. // if it was provided to the builder or after it was returned from the database.
  42688. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  42689. if m.id == nil {
  42690. return
  42691. }
  42692. return *m.id, true
  42693. }
  42694. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42695. // That means, if the mutation is applied within a transaction with an isolation level such
  42696. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42697. // or updated by the mutation.
  42698. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  42699. switch {
  42700. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42701. id, exists := m.ID()
  42702. if exists {
  42703. return []uint64{id}, nil
  42704. }
  42705. fallthrough
  42706. case m.op.Is(OpUpdate | OpDelete):
  42707. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  42708. default:
  42709. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42710. }
  42711. }
  42712. // SetCreatedAt sets the "created_at" field.
  42713. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  42714. m.created_at = &t
  42715. }
  42716. // CreatedAt returns the value of the "created_at" field in the mutation.
  42717. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  42718. v := m.created_at
  42719. if v == nil {
  42720. return
  42721. }
  42722. return *v, true
  42723. }
  42724. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  42725. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42727. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42728. if !m.op.Is(OpUpdateOne) {
  42729. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42730. }
  42731. if m.id == nil || m.oldValue == nil {
  42732. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42733. }
  42734. oldValue, err := m.oldValue(ctx)
  42735. if err != nil {
  42736. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42737. }
  42738. return oldValue.CreatedAt, nil
  42739. }
  42740. // ResetCreatedAt resets all changes to the "created_at" field.
  42741. func (m *WxCardVisitMutation) ResetCreatedAt() {
  42742. m.created_at = nil
  42743. }
  42744. // SetUpdatedAt sets the "updated_at" field.
  42745. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  42746. m.updated_at = &t
  42747. }
  42748. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42749. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  42750. v := m.updated_at
  42751. if v == nil {
  42752. return
  42753. }
  42754. return *v, true
  42755. }
  42756. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  42757. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42759. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42760. if !m.op.Is(OpUpdateOne) {
  42761. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42762. }
  42763. if m.id == nil || m.oldValue == nil {
  42764. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42765. }
  42766. oldValue, err := m.oldValue(ctx)
  42767. if err != nil {
  42768. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42769. }
  42770. return oldValue.UpdatedAt, nil
  42771. }
  42772. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42773. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  42774. m.updated_at = nil
  42775. }
  42776. // SetDeletedAt sets the "deleted_at" field.
  42777. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  42778. m.deleted_at = &t
  42779. }
  42780. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42781. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  42782. v := m.deleted_at
  42783. if v == nil {
  42784. return
  42785. }
  42786. return *v, true
  42787. }
  42788. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  42789. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42791. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42792. if !m.op.Is(OpUpdateOne) {
  42793. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42794. }
  42795. if m.id == nil || m.oldValue == nil {
  42796. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42797. }
  42798. oldValue, err := m.oldValue(ctx)
  42799. if err != nil {
  42800. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42801. }
  42802. return oldValue.DeletedAt, nil
  42803. }
  42804. // ClearDeletedAt clears the value of the "deleted_at" field.
  42805. func (m *WxCardVisitMutation) ClearDeletedAt() {
  42806. m.deleted_at = nil
  42807. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  42808. }
  42809. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42810. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  42811. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  42812. return ok
  42813. }
  42814. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42815. func (m *WxCardVisitMutation) ResetDeletedAt() {
  42816. m.deleted_at = nil
  42817. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  42818. }
  42819. // SetUserID sets the "user_id" field.
  42820. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  42821. m.user_id = &u
  42822. m.adduser_id = nil
  42823. }
  42824. // UserID returns the value of the "user_id" field in the mutation.
  42825. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  42826. v := m.user_id
  42827. if v == nil {
  42828. return
  42829. }
  42830. return *v, true
  42831. }
  42832. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  42833. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42835. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  42836. if !m.op.Is(OpUpdateOne) {
  42837. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  42838. }
  42839. if m.id == nil || m.oldValue == nil {
  42840. return v, errors.New("OldUserID requires an ID field in the mutation")
  42841. }
  42842. oldValue, err := m.oldValue(ctx)
  42843. if err != nil {
  42844. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  42845. }
  42846. return oldValue.UserID, nil
  42847. }
  42848. // AddUserID adds u to the "user_id" field.
  42849. func (m *WxCardVisitMutation) AddUserID(u int64) {
  42850. if m.adduser_id != nil {
  42851. *m.adduser_id += u
  42852. } else {
  42853. m.adduser_id = &u
  42854. }
  42855. }
  42856. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  42857. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  42858. v := m.adduser_id
  42859. if v == nil {
  42860. return
  42861. }
  42862. return *v, true
  42863. }
  42864. // ClearUserID clears the value of the "user_id" field.
  42865. func (m *WxCardVisitMutation) ClearUserID() {
  42866. m.user_id = nil
  42867. m.adduser_id = nil
  42868. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  42869. }
  42870. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  42871. func (m *WxCardVisitMutation) UserIDCleared() bool {
  42872. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  42873. return ok
  42874. }
  42875. // ResetUserID resets all changes to the "user_id" field.
  42876. func (m *WxCardVisitMutation) ResetUserID() {
  42877. m.user_id = nil
  42878. m.adduser_id = nil
  42879. delete(m.clearedFields, wxcardvisit.FieldUserID)
  42880. }
  42881. // SetBotID sets the "bot_id" field.
  42882. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  42883. m.bot_id = &u
  42884. m.addbot_id = nil
  42885. }
  42886. // BotID returns the value of the "bot_id" field in the mutation.
  42887. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  42888. v := m.bot_id
  42889. if v == nil {
  42890. return
  42891. }
  42892. return *v, true
  42893. }
  42894. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  42895. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42897. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  42898. if !m.op.Is(OpUpdateOne) {
  42899. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  42900. }
  42901. if m.id == nil || m.oldValue == nil {
  42902. return v, errors.New("OldBotID requires an ID field in the mutation")
  42903. }
  42904. oldValue, err := m.oldValue(ctx)
  42905. if err != nil {
  42906. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  42907. }
  42908. return oldValue.BotID, nil
  42909. }
  42910. // AddBotID adds u to the "bot_id" field.
  42911. func (m *WxCardVisitMutation) AddBotID(u int64) {
  42912. if m.addbot_id != nil {
  42913. *m.addbot_id += u
  42914. } else {
  42915. m.addbot_id = &u
  42916. }
  42917. }
  42918. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  42919. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  42920. v := m.addbot_id
  42921. if v == nil {
  42922. return
  42923. }
  42924. return *v, true
  42925. }
  42926. // ResetBotID resets all changes to the "bot_id" field.
  42927. func (m *WxCardVisitMutation) ResetBotID() {
  42928. m.bot_id = nil
  42929. m.addbot_id = nil
  42930. }
  42931. // SetBotType sets the "bot_type" field.
  42932. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  42933. m.bot_type = &u
  42934. m.addbot_type = nil
  42935. }
  42936. // BotType returns the value of the "bot_type" field in the mutation.
  42937. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  42938. v := m.bot_type
  42939. if v == nil {
  42940. return
  42941. }
  42942. return *v, true
  42943. }
  42944. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  42945. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42947. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  42948. if !m.op.Is(OpUpdateOne) {
  42949. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  42950. }
  42951. if m.id == nil || m.oldValue == nil {
  42952. return v, errors.New("OldBotType requires an ID field in the mutation")
  42953. }
  42954. oldValue, err := m.oldValue(ctx)
  42955. if err != nil {
  42956. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  42957. }
  42958. return oldValue.BotType, nil
  42959. }
  42960. // AddBotType adds u to the "bot_type" field.
  42961. func (m *WxCardVisitMutation) AddBotType(u int8) {
  42962. if m.addbot_type != nil {
  42963. *m.addbot_type += u
  42964. } else {
  42965. m.addbot_type = &u
  42966. }
  42967. }
  42968. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  42969. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  42970. v := m.addbot_type
  42971. if v == nil {
  42972. return
  42973. }
  42974. return *v, true
  42975. }
  42976. // ResetBotType resets all changes to the "bot_type" field.
  42977. func (m *WxCardVisitMutation) ResetBotType() {
  42978. m.bot_type = nil
  42979. m.addbot_type = nil
  42980. }
  42981. // Where appends a list predicates to the WxCardVisitMutation builder.
  42982. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  42983. m.predicates = append(m.predicates, ps...)
  42984. }
  42985. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  42986. // users can use type-assertion to append predicates that do not depend on any generated package.
  42987. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  42988. p := make([]predicate.WxCardVisit, len(ps))
  42989. for i := range ps {
  42990. p[i] = ps[i]
  42991. }
  42992. m.Where(p...)
  42993. }
  42994. // Op returns the operation name.
  42995. func (m *WxCardVisitMutation) Op() Op {
  42996. return m.op
  42997. }
  42998. // SetOp allows setting the mutation operation.
  42999. func (m *WxCardVisitMutation) SetOp(op Op) {
  43000. m.op = op
  43001. }
  43002. // Type returns the node type of this mutation (WxCardVisit).
  43003. func (m *WxCardVisitMutation) Type() string {
  43004. return m.typ
  43005. }
  43006. // Fields returns all fields that were changed during this mutation. Note that in
  43007. // order to get all numeric fields that were incremented/decremented, call
  43008. // AddedFields().
  43009. func (m *WxCardVisitMutation) Fields() []string {
  43010. fields := make([]string, 0, 6)
  43011. if m.created_at != nil {
  43012. fields = append(fields, wxcardvisit.FieldCreatedAt)
  43013. }
  43014. if m.updated_at != nil {
  43015. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  43016. }
  43017. if m.deleted_at != nil {
  43018. fields = append(fields, wxcardvisit.FieldDeletedAt)
  43019. }
  43020. if m.user_id != nil {
  43021. fields = append(fields, wxcardvisit.FieldUserID)
  43022. }
  43023. if m.bot_id != nil {
  43024. fields = append(fields, wxcardvisit.FieldBotID)
  43025. }
  43026. if m.bot_type != nil {
  43027. fields = append(fields, wxcardvisit.FieldBotType)
  43028. }
  43029. return fields
  43030. }
  43031. // Field returns the value of a field with the given name. The second boolean
  43032. // return value indicates that this field was not set, or was not defined in the
  43033. // schema.
  43034. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  43035. switch name {
  43036. case wxcardvisit.FieldCreatedAt:
  43037. return m.CreatedAt()
  43038. case wxcardvisit.FieldUpdatedAt:
  43039. return m.UpdatedAt()
  43040. case wxcardvisit.FieldDeletedAt:
  43041. return m.DeletedAt()
  43042. case wxcardvisit.FieldUserID:
  43043. return m.UserID()
  43044. case wxcardvisit.FieldBotID:
  43045. return m.BotID()
  43046. case wxcardvisit.FieldBotType:
  43047. return m.BotType()
  43048. }
  43049. return nil, false
  43050. }
  43051. // OldField returns the old value of the field from the database. An error is
  43052. // returned if the mutation operation is not UpdateOne, or the query to the
  43053. // database failed.
  43054. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43055. switch name {
  43056. case wxcardvisit.FieldCreatedAt:
  43057. return m.OldCreatedAt(ctx)
  43058. case wxcardvisit.FieldUpdatedAt:
  43059. return m.OldUpdatedAt(ctx)
  43060. case wxcardvisit.FieldDeletedAt:
  43061. return m.OldDeletedAt(ctx)
  43062. case wxcardvisit.FieldUserID:
  43063. return m.OldUserID(ctx)
  43064. case wxcardvisit.FieldBotID:
  43065. return m.OldBotID(ctx)
  43066. case wxcardvisit.FieldBotType:
  43067. return m.OldBotType(ctx)
  43068. }
  43069. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  43070. }
  43071. // SetField sets the value of a field with the given name. It returns an error if
  43072. // the field is not defined in the schema, or if the type mismatched the field
  43073. // type.
  43074. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  43075. switch name {
  43076. case wxcardvisit.FieldCreatedAt:
  43077. v, ok := value.(time.Time)
  43078. if !ok {
  43079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43080. }
  43081. m.SetCreatedAt(v)
  43082. return nil
  43083. case wxcardvisit.FieldUpdatedAt:
  43084. v, ok := value.(time.Time)
  43085. if !ok {
  43086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43087. }
  43088. m.SetUpdatedAt(v)
  43089. return nil
  43090. case wxcardvisit.FieldDeletedAt:
  43091. v, ok := value.(time.Time)
  43092. if !ok {
  43093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43094. }
  43095. m.SetDeletedAt(v)
  43096. return nil
  43097. case wxcardvisit.FieldUserID:
  43098. v, ok := value.(uint64)
  43099. if !ok {
  43100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43101. }
  43102. m.SetUserID(v)
  43103. return nil
  43104. case wxcardvisit.FieldBotID:
  43105. v, ok := value.(uint64)
  43106. if !ok {
  43107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43108. }
  43109. m.SetBotID(v)
  43110. return nil
  43111. case wxcardvisit.FieldBotType:
  43112. v, ok := value.(uint8)
  43113. if !ok {
  43114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43115. }
  43116. m.SetBotType(v)
  43117. return nil
  43118. }
  43119. return fmt.Errorf("unknown WxCardVisit field %s", name)
  43120. }
  43121. // AddedFields returns all numeric fields that were incremented/decremented during
  43122. // this mutation.
  43123. func (m *WxCardVisitMutation) AddedFields() []string {
  43124. var fields []string
  43125. if m.adduser_id != nil {
  43126. fields = append(fields, wxcardvisit.FieldUserID)
  43127. }
  43128. if m.addbot_id != nil {
  43129. fields = append(fields, wxcardvisit.FieldBotID)
  43130. }
  43131. if m.addbot_type != nil {
  43132. fields = append(fields, wxcardvisit.FieldBotType)
  43133. }
  43134. return fields
  43135. }
  43136. // AddedField returns the numeric value that was incremented/decremented on a field
  43137. // with the given name. The second boolean return value indicates that this field
  43138. // was not set, or was not defined in the schema.
  43139. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  43140. switch name {
  43141. case wxcardvisit.FieldUserID:
  43142. return m.AddedUserID()
  43143. case wxcardvisit.FieldBotID:
  43144. return m.AddedBotID()
  43145. case wxcardvisit.FieldBotType:
  43146. return m.AddedBotType()
  43147. }
  43148. return nil, false
  43149. }
  43150. // AddField adds the value to the field with the given name. It returns an error if
  43151. // the field is not defined in the schema, or if the type mismatched the field
  43152. // type.
  43153. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  43154. switch name {
  43155. case wxcardvisit.FieldUserID:
  43156. v, ok := value.(int64)
  43157. if !ok {
  43158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43159. }
  43160. m.AddUserID(v)
  43161. return nil
  43162. case wxcardvisit.FieldBotID:
  43163. v, ok := value.(int64)
  43164. if !ok {
  43165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43166. }
  43167. m.AddBotID(v)
  43168. return nil
  43169. case wxcardvisit.FieldBotType:
  43170. v, ok := value.(int8)
  43171. if !ok {
  43172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43173. }
  43174. m.AddBotType(v)
  43175. return nil
  43176. }
  43177. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  43178. }
  43179. // ClearedFields returns all nullable fields that were cleared during this
  43180. // mutation.
  43181. func (m *WxCardVisitMutation) ClearedFields() []string {
  43182. var fields []string
  43183. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  43184. fields = append(fields, wxcardvisit.FieldDeletedAt)
  43185. }
  43186. if m.FieldCleared(wxcardvisit.FieldUserID) {
  43187. fields = append(fields, wxcardvisit.FieldUserID)
  43188. }
  43189. return fields
  43190. }
  43191. // FieldCleared returns a boolean indicating if a field with the given name was
  43192. // cleared in this mutation.
  43193. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  43194. _, ok := m.clearedFields[name]
  43195. return ok
  43196. }
  43197. // ClearField clears the value of the field with the given name. It returns an
  43198. // error if the field is not defined in the schema.
  43199. func (m *WxCardVisitMutation) ClearField(name string) error {
  43200. switch name {
  43201. case wxcardvisit.FieldDeletedAt:
  43202. m.ClearDeletedAt()
  43203. return nil
  43204. case wxcardvisit.FieldUserID:
  43205. m.ClearUserID()
  43206. return nil
  43207. }
  43208. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  43209. }
  43210. // ResetField resets all changes in the mutation for the field with the given name.
  43211. // It returns an error if the field is not defined in the schema.
  43212. func (m *WxCardVisitMutation) ResetField(name string) error {
  43213. switch name {
  43214. case wxcardvisit.FieldCreatedAt:
  43215. m.ResetCreatedAt()
  43216. return nil
  43217. case wxcardvisit.FieldUpdatedAt:
  43218. m.ResetUpdatedAt()
  43219. return nil
  43220. case wxcardvisit.FieldDeletedAt:
  43221. m.ResetDeletedAt()
  43222. return nil
  43223. case wxcardvisit.FieldUserID:
  43224. m.ResetUserID()
  43225. return nil
  43226. case wxcardvisit.FieldBotID:
  43227. m.ResetBotID()
  43228. return nil
  43229. case wxcardvisit.FieldBotType:
  43230. m.ResetBotType()
  43231. return nil
  43232. }
  43233. return fmt.Errorf("unknown WxCardVisit field %s", name)
  43234. }
  43235. // AddedEdges returns all edge names that were set/added in this mutation.
  43236. func (m *WxCardVisitMutation) AddedEdges() []string {
  43237. edges := make([]string, 0, 0)
  43238. return edges
  43239. }
  43240. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43241. // name in this mutation.
  43242. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  43243. return nil
  43244. }
  43245. // RemovedEdges returns all edge names that were removed in this mutation.
  43246. func (m *WxCardVisitMutation) RemovedEdges() []string {
  43247. edges := make([]string, 0, 0)
  43248. return edges
  43249. }
  43250. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43251. // the given name in this mutation.
  43252. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  43253. return nil
  43254. }
  43255. // ClearedEdges returns all edge names that were cleared in this mutation.
  43256. func (m *WxCardVisitMutation) ClearedEdges() []string {
  43257. edges := make([]string, 0, 0)
  43258. return edges
  43259. }
  43260. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43261. // was cleared in this mutation.
  43262. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  43263. return false
  43264. }
  43265. // ClearEdge clears the value of the edge with the given name. It returns an error
  43266. // if that edge is not defined in the schema.
  43267. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  43268. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  43269. }
  43270. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43271. // It returns an error if the edge is not defined in the schema.
  43272. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  43273. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  43274. }