mutation.go 1.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/batchmsg"
  14. "wechat-api/ent/category"
  15. "wechat-api/ent/chatrecords"
  16. "wechat-api/ent/chatsession"
  17. "wechat-api/ent/contact"
  18. "wechat-api/ent/creditbalance"
  19. "wechat-api/ent/creditusage"
  20. "wechat-api/ent/custom_types"
  21. "wechat-api/ent/employee"
  22. "wechat-api/ent/employeeconfig"
  23. "wechat-api/ent/label"
  24. "wechat-api/ent/labelrelationship"
  25. "wechat-api/ent/labeltagging"
  26. "wechat-api/ent/message"
  27. "wechat-api/ent/messagerecords"
  28. "wechat-api/ent/msg"
  29. "wechat-api/ent/payrecharge"
  30. "wechat-api/ent/predicate"
  31. "wechat-api/ent/server"
  32. "wechat-api/ent/sopnode"
  33. "wechat-api/ent/sopstage"
  34. "wechat-api/ent/soptask"
  35. "wechat-api/ent/token"
  36. "wechat-api/ent/tutorial"
  37. "wechat-api/ent/usagedetail"
  38. "wechat-api/ent/usagestatisticday"
  39. "wechat-api/ent/usagestatistichour"
  40. "wechat-api/ent/usagestatisticmonth"
  41. "wechat-api/ent/usagetotal"
  42. "wechat-api/ent/whatsapp"
  43. "wechat-api/ent/whatsappchannel"
  44. "wechat-api/ent/workexperience"
  45. "wechat-api/ent/wpchatroom"
  46. "wechat-api/ent/wpchatroommember"
  47. "wechat-api/ent/wx"
  48. "wechat-api/ent/wxcard"
  49. "wechat-api/ent/wxcarduser"
  50. "wechat-api/ent/wxcardvisit"
  51. "entgo.io/ent"
  52. "entgo.io/ent/dialect/sql"
  53. )
  54. const (
  55. // Operation types.
  56. OpCreate = ent.OpCreate
  57. OpDelete = ent.OpDelete
  58. OpDeleteOne = ent.OpDeleteOne
  59. OpUpdate = ent.OpUpdate
  60. OpUpdateOne = ent.OpUpdateOne
  61. // Node types.
  62. TypeAgent = "Agent"
  63. TypeAgentBase = "AgentBase"
  64. TypeAliyunAvatar = "AliyunAvatar"
  65. TypeAllocAgent = "AllocAgent"
  66. TypeBatchMsg = "BatchMsg"
  67. TypeCategory = "Category"
  68. TypeChatRecords = "ChatRecords"
  69. TypeChatSession = "ChatSession"
  70. TypeContact = "Contact"
  71. TypeCreditBalance = "CreditBalance"
  72. TypeCreditUsage = "CreditUsage"
  73. TypeEmployee = "Employee"
  74. TypeEmployeeConfig = "EmployeeConfig"
  75. TypeLabel = "Label"
  76. TypeLabelRelationship = "LabelRelationship"
  77. TypeLabelTagging = "LabelTagging"
  78. TypeMessage = "Message"
  79. TypeMessageRecords = "MessageRecords"
  80. TypeMsg = "Msg"
  81. TypePayRecharge = "PayRecharge"
  82. TypeServer = "Server"
  83. TypeSopNode = "SopNode"
  84. TypeSopStage = "SopStage"
  85. TypeSopTask = "SopTask"
  86. TypeToken = "Token"
  87. TypeTutorial = "Tutorial"
  88. TypeUsageDetail = "UsageDetail"
  89. TypeUsageStatisticDay = "UsageStatisticDay"
  90. TypeUsageStatisticHour = "UsageStatisticHour"
  91. TypeUsageStatisticMonth = "UsageStatisticMonth"
  92. TypeUsageTotal = "UsageTotal"
  93. TypeWhatsapp = "Whatsapp"
  94. TypeWhatsappChannel = "WhatsappChannel"
  95. TypeWorkExperience = "WorkExperience"
  96. TypeWpChatroom = "WpChatroom"
  97. TypeWpChatroomMember = "WpChatroomMember"
  98. TypeWx = "Wx"
  99. TypeWxCard = "WxCard"
  100. TypeWxCardUser = "WxCardUser"
  101. TypeWxCardVisit = "WxCardVisit"
  102. )
  103. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  104. type AgentMutation struct {
  105. config
  106. op Op
  107. typ string
  108. id *uint64
  109. created_at *time.Time
  110. updated_at *time.Time
  111. deleted_at *time.Time
  112. name *string
  113. role *string
  114. status *int
  115. addstatus *int
  116. background *string
  117. examples *string
  118. organization_id *uint64
  119. addorganization_id *int64
  120. dataset_id *string
  121. collection_id *string
  122. clearedFields map[string]struct{}
  123. wx_agent map[uint64]struct{}
  124. removedwx_agent map[uint64]struct{}
  125. clearedwx_agent bool
  126. token_agent map[uint64]struct{}
  127. removedtoken_agent map[uint64]struct{}
  128. clearedtoken_agent bool
  129. wa_agent map[uint64]struct{}
  130. removedwa_agent map[uint64]struct{}
  131. clearedwa_agent bool
  132. done bool
  133. oldValue func(context.Context) (*Agent, error)
  134. predicates []predicate.Agent
  135. }
  136. var _ ent.Mutation = (*AgentMutation)(nil)
  137. // agentOption allows management of the mutation configuration using functional options.
  138. type agentOption func(*AgentMutation)
  139. // newAgentMutation creates new mutation for the Agent entity.
  140. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  141. m := &AgentMutation{
  142. config: c,
  143. op: op,
  144. typ: TypeAgent,
  145. clearedFields: make(map[string]struct{}),
  146. }
  147. for _, opt := range opts {
  148. opt(m)
  149. }
  150. return m
  151. }
  152. // withAgentID sets the ID field of the mutation.
  153. func withAgentID(id uint64) agentOption {
  154. return func(m *AgentMutation) {
  155. var (
  156. err error
  157. once sync.Once
  158. value *Agent
  159. )
  160. m.oldValue = func(ctx context.Context) (*Agent, error) {
  161. once.Do(func() {
  162. if m.done {
  163. err = errors.New("querying old values post mutation is not allowed")
  164. } else {
  165. value, err = m.Client().Agent.Get(ctx, id)
  166. }
  167. })
  168. return value, err
  169. }
  170. m.id = &id
  171. }
  172. }
  173. // withAgent sets the old Agent of the mutation.
  174. func withAgent(node *Agent) agentOption {
  175. return func(m *AgentMutation) {
  176. m.oldValue = func(context.Context) (*Agent, error) {
  177. return node, nil
  178. }
  179. m.id = &node.ID
  180. }
  181. }
  182. // Client returns a new `ent.Client` from the mutation. If the mutation was
  183. // executed in a transaction (ent.Tx), a transactional client is returned.
  184. func (m AgentMutation) Client() *Client {
  185. client := &Client{config: m.config}
  186. client.init()
  187. return client
  188. }
  189. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  190. // it returns an error otherwise.
  191. func (m AgentMutation) Tx() (*Tx, error) {
  192. if _, ok := m.driver.(*txDriver); !ok {
  193. return nil, errors.New("ent: mutation is not running in a transaction")
  194. }
  195. tx := &Tx{config: m.config}
  196. tx.init()
  197. return tx, nil
  198. }
  199. // SetID sets the value of the id field. Note that this
  200. // operation is only accepted on creation of Agent entities.
  201. func (m *AgentMutation) SetID(id uint64) {
  202. m.id = &id
  203. }
  204. // ID returns the ID value in the mutation. Note that the ID is only available
  205. // if it was provided to the builder or after it was returned from the database.
  206. func (m *AgentMutation) ID() (id uint64, exists bool) {
  207. if m.id == nil {
  208. return
  209. }
  210. return *m.id, true
  211. }
  212. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  213. // That means, if the mutation is applied within a transaction with an isolation level such
  214. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  215. // or updated by the mutation.
  216. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  217. switch {
  218. case m.op.Is(OpUpdateOne | OpDeleteOne):
  219. id, exists := m.ID()
  220. if exists {
  221. return []uint64{id}, nil
  222. }
  223. fallthrough
  224. case m.op.Is(OpUpdate | OpDelete):
  225. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  226. default:
  227. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  228. }
  229. }
  230. // SetCreatedAt sets the "created_at" field.
  231. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  232. m.created_at = &t
  233. }
  234. // CreatedAt returns the value of the "created_at" field in the mutation.
  235. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  236. v := m.created_at
  237. if v == nil {
  238. return
  239. }
  240. return *v, true
  241. }
  242. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  243. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  245. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  246. if !m.op.Is(OpUpdateOne) {
  247. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  248. }
  249. if m.id == nil || m.oldValue == nil {
  250. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  251. }
  252. oldValue, err := m.oldValue(ctx)
  253. if err != nil {
  254. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  255. }
  256. return oldValue.CreatedAt, nil
  257. }
  258. // ResetCreatedAt resets all changes to the "created_at" field.
  259. func (m *AgentMutation) ResetCreatedAt() {
  260. m.created_at = nil
  261. }
  262. // SetUpdatedAt sets the "updated_at" field.
  263. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  264. m.updated_at = &t
  265. }
  266. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  267. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  268. v := m.updated_at
  269. if v == nil {
  270. return
  271. }
  272. return *v, true
  273. }
  274. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  275. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  277. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  278. if !m.op.Is(OpUpdateOne) {
  279. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  280. }
  281. if m.id == nil || m.oldValue == nil {
  282. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  283. }
  284. oldValue, err := m.oldValue(ctx)
  285. if err != nil {
  286. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  287. }
  288. return oldValue.UpdatedAt, nil
  289. }
  290. // ResetUpdatedAt resets all changes to the "updated_at" field.
  291. func (m *AgentMutation) ResetUpdatedAt() {
  292. m.updated_at = nil
  293. }
  294. // SetDeletedAt sets the "deleted_at" field.
  295. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  296. m.deleted_at = &t
  297. }
  298. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  299. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  300. v := m.deleted_at
  301. if v == nil {
  302. return
  303. }
  304. return *v, true
  305. }
  306. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  307. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  309. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  310. if !m.op.Is(OpUpdateOne) {
  311. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  312. }
  313. if m.id == nil || m.oldValue == nil {
  314. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  315. }
  316. oldValue, err := m.oldValue(ctx)
  317. if err != nil {
  318. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  319. }
  320. return oldValue.DeletedAt, nil
  321. }
  322. // ClearDeletedAt clears the value of the "deleted_at" field.
  323. func (m *AgentMutation) ClearDeletedAt() {
  324. m.deleted_at = nil
  325. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  326. }
  327. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  328. func (m *AgentMutation) DeletedAtCleared() bool {
  329. _, ok := m.clearedFields[agent.FieldDeletedAt]
  330. return ok
  331. }
  332. // ResetDeletedAt resets all changes to the "deleted_at" field.
  333. func (m *AgentMutation) ResetDeletedAt() {
  334. m.deleted_at = nil
  335. delete(m.clearedFields, agent.FieldDeletedAt)
  336. }
  337. // SetName sets the "name" field.
  338. func (m *AgentMutation) SetName(s string) {
  339. m.name = &s
  340. }
  341. // Name returns the value of the "name" field in the mutation.
  342. func (m *AgentMutation) Name() (r string, exists bool) {
  343. v := m.name
  344. if v == nil {
  345. return
  346. }
  347. return *v, true
  348. }
  349. // OldName returns the old "name" field's value of the Agent entity.
  350. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  352. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  353. if !m.op.Is(OpUpdateOne) {
  354. return v, errors.New("OldName is only allowed on UpdateOne operations")
  355. }
  356. if m.id == nil || m.oldValue == nil {
  357. return v, errors.New("OldName requires an ID field in the mutation")
  358. }
  359. oldValue, err := m.oldValue(ctx)
  360. if err != nil {
  361. return v, fmt.Errorf("querying old value for OldName: %w", err)
  362. }
  363. return oldValue.Name, nil
  364. }
  365. // ResetName resets all changes to the "name" field.
  366. func (m *AgentMutation) ResetName() {
  367. m.name = nil
  368. }
  369. // SetRole sets the "role" field.
  370. func (m *AgentMutation) SetRole(s string) {
  371. m.role = &s
  372. }
  373. // Role returns the value of the "role" field in the mutation.
  374. func (m *AgentMutation) Role() (r string, exists bool) {
  375. v := m.role
  376. if v == nil {
  377. return
  378. }
  379. return *v, true
  380. }
  381. // OldRole returns the old "role" field's value of the Agent entity.
  382. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  384. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  385. if !m.op.Is(OpUpdateOne) {
  386. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  387. }
  388. if m.id == nil || m.oldValue == nil {
  389. return v, errors.New("OldRole requires an ID field in the mutation")
  390. }
  391. oldValue, err := m.oldValue(ctx)
  392. if err != nil {
  393. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  394. }
  395. return oldValue.Role, nil
  396. }
  397. // ResetRole resets all changes to the "role" field.
  398. func (m *AgentMutation) ResetRole() {
  399. m.role = nil
  400. }
  401. // SetStatus sets the "status" field.
  402. func (m *AgentMutation) SetStatus(i int) {
  403. m.status = &i
  404. m.addstatus = nil
  405. }
  406. // Status returns the value of the "status" field in the mutation.
  407. func (m *AgentMutation) Status() (r int, exists bool) {
  408. v := m.status
  409. if v == nil {
  410. return
  411. }
  412. return *v, true
  413. }
  414. // OldStatus returns the old "status" field's value of the Agent entity.
  415. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  417. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  418. if !m.op.Is(OpUpdateOne) {
  419. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  420. }
  421. if m.id == nil || m.oldValue == nil {
  422. return v, errors.New("OldStatus requires an ID field in the mutation")
  423. }
  424. oldValue, err := m.oldValue(ctx)
  425. if err != nil {
  426. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  427. }
  428. return oldValue.Status, nil
  429. }
  430. // AddStatus adds i to the "status" field.
  431. func (m *AgentMutation) AddStatus(i int) {
  432. if m.addstatus != nil {
  433. *m.addstatus += i
  434. } else {
  435. m.addstatus = &i
  436. }
  437. }
  438. // AddedStatus returns the value that was added to the "status" field in this mutation.
  439. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  440. v := m.addstatus
  441. if v == nil {
  442. return
  443. }
  444. return *v, true
  445. }
  446. // ClearStatus clears the value of the "status" field.
  447. func (m *AgentMutation) ClearStatus() {
  448. m.status = nil
  449. m.addstatus = nil
  450. m.clearedFields[agent.FieldStatus] = struct{}{}
  451. }
  452. // StatusCleared returns if the "status" field was cleared in this mutation.
  453. func (m *AgentMutation) StatusCleared() bool {
  454. _, ok := m.clearedFields[agent.FieldStatus]
  455. return ok
  456. }
  457. // ResetStatus resets all changes to the "status" field.
  458. func (m *AgentMutation) ResetStatus() {
  459. m.status = nil
  460. m.addstatus = nil
  461. delete(m.clearedFields, agent.FieldStatus)
  462. }
  463. // SetBackground sets the "background" field.
  464. func (m *AgentMutation) SetBackground(s string) {
  465. m.background = &s
  466. }
  467. // Background returns the value of the "background" field in the mutation.
  468. func (m *AgentMutation) Background() (r string, exists bool) {
  469. v := m.background
  470. if v == nil {
  471. return
  472. }
  473. return *v, true
  474. }
  475. // OldBackground returns the old "background" field's value of the Agent entity.
  476. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  478. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  479. if !m.op.Is(OpUpdateOne) {
  480. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  481. }
  482. if m.id == nil || m.oldValue == nil {
  483. return v, errors.New("OldBackground requires an ID field in the mutation")
  484. }
  485. oldValue, err := m.oldValue(ctx)
  486. if err != nil {
  487. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  488. }
  489. return oldValue.Background, nil
  490. }
  491. // ClearBackground clears the value of the "background" field.
  492. func (m *AgentMutation) ClearBackground() {
  493. m.background = nil
  494. m.clearedFields[agent.FieldBackground] = struct{}{}
  495. }
  496. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  497. func (m *AgentMutation) BackgroundCleared() bool {
  498. _, ok := m.clearedFields[agent.FieldBackground]
  499. return ok
  500. }
  501. // ResetBackground resets all changes to the "background" field.
  502. func (m *AgentMutation) ResetBackground() {
  503. m.background = nil
  504. delete(m.clearedFields, agent.FieldBackground)
  505. }
  506. // SetExamples sets the "examples" field.
  507. func (m *AgentMutation) SetExamples(s string) {
  508. m.examples = &s
  509. }
  510. // Examples returns the value of the "examples" field in the mutation.
  511. func (m *AgentMutation) Examples() (r string, exists bool) {
  512. v := m.examples
  513. if v == nil {
  514. return
  515. }
  516. return *v, true
  517. }
  518. // OldExamples returns the old "examples" field's value of the Agent entity.
  519. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  521. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  522. if !m.op.Is(OpUpdateOne) {
  523. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  524. }
  525. if m.id == nil || m.oldValue == nil {
  526. return v, errors.New("OldExamples requires an ID field in the mutation")
  527. }
  528. oldValue, err := m.oldValue(ctx)
  529. if err != nil {
  530. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  531. }
  532. return oldValue.Examples, nil
  533. }
  534. // ClearExamples clears the value of the "examples" field.
  535. func (m *AgentMutation) ClearExamples() {
  536. m.examples = nil
  537. m.clearedFields[agent.FieldExamples] = struct{}{}
  538. }
  539. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  540. func (m *AgentMutation) ExamplesCleared() bool {
  541. _, ok := m.clearedFields[agent.FieldExamples]
  542. return ok
  543. }
  544. // ResetExamples resets all changes to the "examples" field.
  545. func (m *AgentMutation) ResetExamples() {
  546. m.examples = nil
  547. delete(m.clearedFields, agent.FieldExamples)
  548. }
  549. // SetOrganizationID sets the "organization_id" field.
  550. func (m *AgentMutation) SetOrganizationID(u uint64) {
  551. m.organization_id = &u
  552. m.addorganization_id = nil
  553. }
  554. // OrganizationID returns the value of the "organization_id" field in the mutation.
  555. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  556. v := m.organization_id
  557. if v == nil {
  558. return
  559. }
  560. return *v, true
  561. }
  562. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  563. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  565. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  566. if !m.op.Is(OpUpdateOne) {
  567. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  568. }
  569. if m.id == nil || m.oldValue == nil {
  570. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  571. }
  572. oldValue, err := m.oldValue(ctx)
  573. if err != nil {
  574. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  575. }
  576. return oldValue.OrganizationID, nil
  577. }
  578. // AddOrganizationID adds u to the "organization_id" field.
  579. func (m *AgentMutation) AddOrganizationID(u int64) {
  580. if m.addorganization_id != nil {
  581. *m.addorganization_id += u
  582. } else {
  583. m.addorganization_id = &u
  584. }
  585. }
  586. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  587. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  588. v := m.addorganization_id
  589. if v == nil {
  590. return
  591. }
  592. return *v, true
  593. }
  594. // ResetOrganizationID resets all changes to the "organization_id" field.
  595. func (m *AgentMutation) ResetOrganizationID() {
  596. m.organization_id = nil
  597. m.addorganization_id = nil
  598. }
  599. // SetDatasetID sets the "dataset_id" field.
  600. func (m *AgentMutation) SetDatasetID(s string) {
  601. m.dataset_id = &s
  602. }
  603. // DatasetID returns the value of the "dataset_id" field in the mutation.
  604. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  605. v := m.dataset_id
  606. if v == nil {
  607. return
  608. }
  609. return *v, true
  610. }
  611. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  612. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  614. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  615. if !m.op.Is(OpUpdateOne) {
  616. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  617. }
  618. if m.id == nil || m.oldValue == nil {
  619. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  620. }
  621. oldValue, err := m.oldValue(ctx)
  622. if err != nil {
  623. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  624. }
  625. return oldValue.DatasetID, nil
  626. }
  627. // ResetDatasetID resets all changes to the "dataset_id" field.
  628. func (m *AgentMutation) ResetDatasetID() {
  629. m.dataset_id = nil
  630. }
  631. // SetCollectionID sets the "collection_id" field.
  632. func (m *AgentMutation) SetCollectionID(s string) {
  633. m.collection_id = &s
  634. }
  635. // CollectionID returns the value of the "collection_id" field in the mutation.
  636. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  637. v := m.collection_id
  638. if v == nil {
  639. return
  640. }
  641. return *v, true
  642. }
  643. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  644. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  646. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  647. if !m.op.Is(OpUpdateOne) {
  648. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  649. }
  650. if m.id == nil || m.oldValue == nil {
  651. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  652. }
  653. oldValue, err := m.oldValue(ctx)
  654. if err != nil {
  655. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  656. }
  657. return oldValue.CollectionID, nil
  658. }
  659. // ResetCollectionID resets all changes to the "collection_id" field.
  660. func (m *AgentMutation) ResetCollectionID() {
  661. m.collection_id = nil
  662. }
  663. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  664. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  665. if m.wx_agent == nil {
  666. m.wx_agent = make(map[uint64]struct{})
  667. }
  668. for i := range ids {
  669. m.wx_agent[ids[i]] = struct{}{}
  670. }
  671. }
  672. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  673. func (m *AgentMutation) ClearWxAgent() {
  674. m.clearedwx_agent = true
  675. }
  676. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  677. func (m *AgentMutation) WxAgentCleared() bool {
  678. return m.clearedwx_agent
  679. }
  680. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  681. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  682. if m.removedwx_agent == nil {
  683. m.removedwx_agent = make(map[uint64]struct{})
  684. }
  685. for i := range ids {
  686. delete(m.wx_agent, ids[i])
  687. m.removedwx_agent[ids[i]] = struct{}{}
  688. }
  689. }
  690. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  691. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  692. for id := range m.removedwx_agent {
  693. ids = append(ids, id)
  694. }
  695. return
  696. }
  697. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  698. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  699. for id := range m.wx_agent {
  700. ids = append(ids, id)
  701. }
  702. return
  703. }
  704. // ResetWxAgent resets all changes to the "wx_agent" edge.
  705. func (m *AgentMutation) ResetWxAgent() {
  706. m.wx_agent = nil
  707. m.clearedwx_agent = false
  708. m.removedwx_agent = nil
  709. }
  710. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  711. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  712. if m.token_agent == nil {
  713. m.token_agent = make(map[uint64]struct{})
  714. }
  715. for i := range ids {
  716. m.token_agent[ids[i]] = struct{}{}
  717. }
  718. }
  719. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  720. func (m *AgentMutation) ClearTokenAgent() {
  721. m.clearedtoken_agent = true
  722. }
  723. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  724. func (m *AgentMutation) TokenAgentCleared() bool {
  725. return m.clearedtoken_agent
  726. }
  727. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  728. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  729. if m.removedtoken_agent == nil {
  730. m.removedtoken_agent = make(map[uint64]struct{})
  731. }
  732. for i := range ids {
  733. delete(m.token_agent, ids[i])
  734. m.removedtoken_agent[ids[i]] = struct{}{}
  735. }
  736. }
  737. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  738. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  739. for id := range m.removedtoken_agent {
  740. ids = append(ids, id)
  741. }
  742. return
  743. }
  744. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  745. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  746. for id := range m.token_agent {
  747. ids = append(ids, id)
  748. }
  749. return
  750. }
  751. // ResetTokenAgent resets all changes to the "token_agent" edge.
  752. func (m *AgentMutation) ResetTokenAgent() {
  753. m.token_agent = nil
  754. m.clearedtoken_agent = false
  755. m.removedtoken_agent = nil
  756. }
  757. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  758. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  759. if m.wa_agent == nil {
  760. m.wa_agent = make(map[uint64]struct{})
  761. }
  762. for i := range ids {
  763. m.wa_agent[ids[i]] = struct{}{}
  764. }
  765. }
  766. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  767. func (m *AgentMutation) ClearWaAgent() {
  768. m.clearedwa_agent = true
  769. }
  770. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  771. func (m *AgentMutation) WaAgentCleared() bool {
  772. return m.clearedwa_agent
  773. }
  774. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  775. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  776. if m.removedwa_agent == nil {
  777. m.removedwa_agent = make(map[uint64]struct{})
  778. }
  779. for i := range ids {
  780. delete(m.wa_agent, ids[i])
  781. m.removedwa_agent[ids[i]] = struct{}{}
  782. }
  783. }
  784. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  785. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  786. for id := range m.removedwa_agent {
  787. ids = append(ids, id)
  788. }
  789. return
  790. }
  791. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  792. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  793. for id := range m.wa_agent {
  794. ids = append(ids, id)
  795. }
  796. return
  797. }
  798. // ResetWaAgent resets all changes to the "wa_agent" edge.
  799. func (m *AgentMutation) ResetWaAgent() {
  800. m.wa_agent = nil
  801. m.clearedwa_agent = false
  802. m.removedwa_agent = nil
  803. }
  804. // Where appends a list predicates to the AgentMutation builder.
  805. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  806. m.predicates = append(m.predicates, ps...)
  807. }
  808. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  809. // users can use type-assertion to append predicates that do not depend on any generated package.
  810. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  811. p := make([]predicate.Agent, len(ps))
  812. for i := range ps {
  813. p[i] = ps[i]
  814. }
  815. m.Where(p...)
  816. }
  817. // Op returns the operation name.
  818. func (m *AgentMutation) Op() Op {
  819. return m.op
  820. }
  821. // SetOp allows setting the mutation operation.
  822. func (m *AgentMutation) SetOp(op Op) {
  823. m.op = op
  824. }
  825. // Type returns the node type of this mutation (Agent).
  826. func (m *AgentMutation) Type() string {
  827. return m.typ
  828. }
  829. // Fields returns all fields that were changed during this mutation. Note that in
  830. // order to get all numeric fields that were incremented/decremented, call
  831. // AddedFields().
  832. func (m *AgentMutation) Fields() []string {
  833. fields := make([]string, 0, 11)
  834. if m.created_at != nil {
  835. fields = append(fields, agent.FieldCreatedAt)
  836. }
  837. if m.updated_at != nil {
  838. fields = append(fields, agent.FieldUpdatedAt)
  839. }
  840. if m.deleted_at != nil {
  841. fields = append(fields, agent.FieldDeletedAt)
  842. }
  843. if m.name != nil {
  844. fields = append(fields, agent.FieldName)
  845. }
  846. if m.role != nil {
  847. fields = append(fields, agent.FieldRole)
  848. }
  849. if m.status != nil {
  850. fields = append(fields, agent.FieldStatus)
  851. }
  852. if m.background != nil {
  853. fields = append(fields, agent.FieldBackground)
  854. }
  855. if m.examples != nil {
  856. fields = append(fields, agent.FieldExamples)
  857. }
  858. if m.organization_id != nil {
  859. fields = append(fields, agent.FieldOrganizationID)
  860. }
  861. if m.dataset_id != nil {
  862. fields = append(fields, agent.FieldDatasetID)
  863. }
  864. if m.collection_id != nil {
  865. fields = append(fields, agent.FieldCollectionID)
  866. }
  867. return fields
  868. }
  869. // Field returns the value of a field with the given name. The second boolean
  870. // return value indicates that this field was not set, or was not defined in the
  871. // schema.
  872. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  873. switch name {
  874. case agent.FieldCreatedAt:
  875. return m.CreatedAt()
  876. case agent.FieldUpdatedAt:
  877. return m.UpdatedAt()
  878. case agent.FieldDeletedAt:
  879. return m.DeletedAt()
  880. case agent.FieldName:
  881. return m.Name()
  882. case agent.FieldRole:
  883. return m.Role()
  884. case agent.FieldStatus:
  885. return m.Status()
  886. case agent.FieldBackground:
  887. return m.Background()
  888. case agent.FieldExamples:
  889. return m.Examples()
  890. case agent.FieldOrganizationID:
  891. return m.OrganizationID()
  892. case agent.FieldDatasetID:
  893. return m.DatasetID()
  894. case agent.FieldCollectionID:
  895. return m.CollectionID()
  896. }
  897. return nil, false
  898. }
  899. // OldField returns the old value of the field from the database. An error is
  900. // returned if the mutation operation is not UpdateOne, or the query to the
  901. // database failed.
  902. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  903. switch name {
  904. case agent.FieldCreatedAt:
  905. return m.OldCreatedAt(ctx)
  906. case agent.FieldUpdatedAt:
  907. return m.OldUpdatedAt(ctx)
  908. case agent.FieldDeletedAt:
  909. return m.OldDeletedAt(ctx)
  910. case agent.FieldName:
  911. return m.OldName(ctx)
  912. case agent.FieldRole:
  913. return m.OldRole(ctx)
  914. case agent.FieldStatus:
  915. return m.OldStatus(ctx)
  916. case agent.FieldBackground:
  917. return m.OldBackground(ctx)
  918. case agent.FieldExamples:
  919. return m.OldExamples(ctx)
  920. case agent.FieldOrganizationID:
  921. return m.OldOrganizationID(ctx)
  922. case agent.FieldDatasetID:
  923. return m.OldDatasetID(ctx)
  924. case agent.FieldCollectionID:
  925. return m.OldCollectionID(ctx)
  926. }
  927. return nil, fmt.Errorf("unknown Agent field %s", name)
  928. }
  929. // SetField sets the value of a field with the given name. It returns an error if
  930. // the field is not defined in the schema, or if the type mismatched the field
  931. // type.
  932. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  933. switch name {
  934. case agent.FieldCreatedAt:
  935. v, ok := value.(time.Time)
  936. if !ok {
  937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  938. }
  939. m.SetCreatedAt(v)
  940. return nil
  941. case agent.FieldUpdatedAt:
  942. v, ok := value.(time.Time)
  943. if !ok {
  944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  945. }
  946. m.SetUpdatedAt(v)
  947. return nil
  948. case agent.FieldDeletedAt:
  949. v, ok := value.(time.Time)
  950. if !ok {
  951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  952. }
  953. m.SetDeletedAt(v)
  954. return nil
  955. case agent.FieldName:
  956. v, ok := value.(string)
  957. if !ok {
  958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  959. }
  960. m.SetName(v)
  961. return nil
  962. case agent.FieldRole:
  963. v, ok := value.(string)
  964. if !ok {
  965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  966. }
  967. m.SetRole(v)
  968. return nil
  969. case agent.FieldStatus:
  970. v, ok := value.(int)
  971. if !ok {
  972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  973. }
  974. m.SetStatus(v)
  975. return nil
  976. case agent.FieldBackground:
  977. v, ok := value.(string)
  978. if !ok {
  979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  980. }
  981. m.SetBackground(v)
  982. return nil
  983. case agent.FieldExamples:
  984. v, ok := value.(string)
  985. if !ok {
  986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  987. }
  988. m.SetExamples(v)
  989. return nil
  990. case agent.FieldOrganizationID:
  991. v, ok := value.(uint64)
  992. if !ok {
  993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  994. }
  995. m.SetOrganizationID(v)
  996. return nil
  997. case agent.FieldDatasetID:
  998. v, ok := value.(string)
  999. if !ok {
  1000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1001. }
  1002. m.SetDatasetID(v)
  1003. return nil
  1004. case agent.FieldCollectionID:
  1005. v, ok := value.(string)
  1006. if !ok {
  1007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1008. }
  1009. m.SetCollectionID(v)
  1010. return nil
  1011. }
  1012. return fmt.Errorf("unknown Agent field %s", name)
  1013. }
  1014. // AddedFields returns all numeric fields that were incremented/decremented during
  1015. // this mutation.
  1016. func (m *AgentMutation) AddedFields() []string {
  1017. var fields []string
  1018. if m.addstatus != nil {
  1019. fields = append(fields, agent.FieldStatus)
  1020. }
  1021. if m.addorganization_id != nil {
  1022. fields = append(fields, agent.FieldOrganizationID)
  1023. }
  1024. return fields
  1025. }
  1026. // AddedField returns the numeric value that was incremented/decremented on a field
  1027. // with the given name. The second boolean return value indicates that this field
  1028. // was not set, or was not defined in the schema.
  1029. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1030. switch name {
  1031. case agent.FieldStatus:
  1032. return m.AddedStatus()
  1033. case agent.FieldOrganizationID:
  1034. return m.AddedOrganizationID()
  1035. }
  1036. return nil, false
  1037. }
  1038. // AddField adds the value to the field with the given name. It returns an error if
  1039. // the field is not defined in the schema, or if the type mismatched the field
  1040. // type.
  1041. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1042. switch name {
  1043. case agent.FieldStatus:
  1044. v, ok := value.(int)
  1045. if !ok {
  1046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1047. }
  1048. m.AddStatus(v)
  1049. return nil
  1050. case agent.FieldOrganizationID:
  1051. v, ok := value.(int64)
  1052. if !ok {
  1053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1054. }
  1055. m.AddOrganizationID(v)
  1056. return nil
  1057. }
  1058. return fmt.Errorf("unknown Agent numeric field %s", name)
  1059. }
  1060. // ClearedFields returns all nullable fields that were cleared during this
  1061. // mutation.
  1062. func (m *AgentMutation) ClearedFields() []string {
  1063. var fields []string
  1064. if m.FieldCleared(agent.FieldDeletedAt) {
  1065. fields = append(fields, agent.FieldDeletedAt)
  1066. }
  1067. if m.FieldCleared(agent.FieldStatus) {
  1068. fields = append(fields, agent.FieldStatus)
  1069. }
  1070. if m.FieldCleared(agent.FieldBackground) {
  1071. fields = append(fields, agent.FieldBackground)
  1072. }
  1073. if m.FieldCleared(agent.FieldExamples) {
  1074. fields = append(fields, agent.FieldExamples)
  1075. }
  1076. return fields
  1077. }
  1078. // FieldCleared returns a boolean indicating if a field with the given name was
  1079. // cleared in this mutation.
  1080. func (m *AgentMutation) FieldCleared(name string) bool {
  1081. _, ok := m.clearedFields[name]
  1082. return ok
  1083. }
  1084. // ClearField clears the value of the field with the given name. It returns an
  1085. // error if the field is not defined in the schema.
  1086. func (m *AgentMutation) ClearField(name string) error {
  1087. switch name {
  1088. case agent.FieldDeletedAt:
  1089. m.ClearDeletedAt()
  1090. return nil
  1091. case agent.FieldStatus:
  1092. m.ClearStatus()
  1093. return nil
  1094. case agent.FieldBackground:
  1095. m.ClearBackground()
  1096. return nil
  1097. case agent.FieldExamples:
  1098. m.ClearExamples()
  1099. return nil
  1100. }
  1101. return fmt.Errorf("unknown Agent nullable field %s", name)
  1102. }
  1103. // ResetField resets all changes in the mutation for the field with the given name.
  1104. // It returns an error if the field is not defined in the schema.
  1105. func (m *AgentMutation) ResetField(name string) error {
  1106. switch name {
  1107. case agent.FieldCreatedAt:
  1108. m.ResetCreatedAt()
  1109. return nil
  1110. case agent.FieldUpdatedAt:
  1111. m.ResetUpdatedAt()
  1112. return nil
  1113. case agent.FieldDeletedAt:
  1114. m.ResetDeletedAt()
  1115. return nil
  1116. case agent.FieldName:
  1117. m.ResetName()
  1118. return nil
  1119. case agent.FieldRole:
  1120. m.ResetRole()
  1121. return nil
  1122. case agent.FieldStatus:
  1123. m.ResetStatus()
  1124. return nil
  1125. case agent.FieldBackground:
  1126. m.ResetBackground()
  1127. return nil
  1128. case agent.FieldExamples:
  1129. m.ResetExamples()
  1130. return nil
  1131. case agent.FieldOrganizationID:
  1132. m.ResetOrganizationID()
  1133. return nil
  1134. case agent.FieldDatasetID:
  1135. m.ResetDatasetID()
  1136. return nil
  1137. case agent.FieldCollectionID:
  1138. m.ResetCollectionID()
  1139. return nil
  1140. }
  1141. return fmt.Errorf("unknown Agent field %s", name)
  1142. }
  1143. // AddedEdges returns all edge names that were set/added in this mutation.
  1144. func (m *AgentMutation) AddedEdges() []string {
  1145. edges := make([]string, 0, 3)
  1146. if m.wx_agent != nil {
  1147. edges = append(edges, agent.EdgeWxAgent)
  1148. }
  1149. if m.token_agent != nil {
  1150. edges = append(edges, agent.EdgeTokenAgent)
  1151. }
  1152. if m.wa_agent != nil {
  1153. edges = append(edges, agent.EdgeWaAgent)
  1154. }
  1155. return edges
  1156. }
  1157. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1158. // name in this mutation.
  1159. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1160. switch name {
  1161. case agent.EdgeWxAgent:
  1162. ids := make([]ent.Value, 0, len(m.wx_agent))
  1163. for id := range m.wx_agent {
  1164. ids = append(ids, id)
  1165. }
  1166. return ids
  1167. case agent.EdgeTokenAgent:
  1168. ids := make([]ent.Value, 0, len(m.token_agent))
  1169. for id := range m.token_agent {
  1170. ids = append(ids, id)
  1171. }
  1172. return ids
  1173. case agent.EdgeWaAgent:
  1174. ids := make([]ent.Value, 0, len(m.wa_agent))
  1175. for id := range m.wa_agent {
  1176. ids = append(ids, id)
  1177. }
  1178. return ids
  1179. }
  1180. return nil
  1181. }
  1182. // RemovedEdges returns all edge names that were removed in this mutation.
  1183. func (m *AgentMutation) RemovedEdges() []string {
  1184. edges := make([]string, 0, 3)
  1185. if m.removedwx_agent != nil {
  1186. edges = append(edges, agent.EdgeWxAgent)
  1187. }
  1188. if m.removedtoken_agent != nil {
  1189. edges = append(edges, agent.EdgeTokenAgent)
  1190. }
  1191. if m.removedwa_agent != nil {
  1192. edges = append(edges, agent.EdgeWaAgent)
  1193. }
  1194. return edges
  1195. }
  1196. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1197. // the given name in this mutation.
  1198. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1199. switch name {
  1200. case agent.EdgeWxAgent:
  1201. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1202. for id := range m.removedwx_agent {
  1203. ids = append(ids, id)
  1204. }
  1205. return ids
  1206. case agent.EdgeTokenAgent:
  1207. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1208. for id := range m.removedtoken_agent {
  1209. ids = append(ids, id)
  1210. }
  1211. return ids
  1212. case agent.EdgeWaAgent:
  1213. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1214. for id := range m.removedwa_agent {
  1215. ids = append(ids, id)
  1216. }
  1217. return ids
  1218. }
  1219. return nil
  1220. }
  1221. // ClearedEdges returns all edge names that were cleared in this mutation.
  1222. func (m *AgentMutation) ClearedEdges() []string {
  1223. edges := make([]string, 0, 3)
  1224. if m.clearedwx_agent {
  1225. edges = append(edges, agent.EdgeWxAgent)
  1226. }
  1227. if m.clearedtoken_agent {
  1228. edges = append(edges, agent.EdgeTokenAgent)
  1229. }
  1230. if m.clearedwa_agent {
  1231. edges = append(edges, agent.EdgeWaAgent)
  1232. }
  1233. return edges
  1234. }
  1235. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1236. // was cleared in this mutation.
  1237. func (m *AgentMutation) EdgeCleared(name string) bool {
  1238. switch name {
  1239. case agent.EdgeWxAgent:
  1240. return m.clearedwx_agent
  1241. case agent.EdgeTokenAgent:
  1242. return m.clearedtoken_agent
  1243. case agent.EdgeWaAgent:
  1244. return m.clearedwa_agent
  1245. }
  1246. return false
  1247. }
  1248. // ClearEdge clears the value of the edge with the given name. It returns an error
  1249. // if that edge is not defined in the schema.
  1250. func (m *AgentMutation) ClearEdge(name string) error {
  1251. switch name {
  1252. }
  1253. return fmt.Errorf("unknown Agent unique edge %s", name)
  1254. }
  1255. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1256. // It returns an error if the edge is not defined in the schema.
  1257. func (m *AgentMutation) ResetEdge(name string) error {
  1258. switch name {
  1259. case agent.EdgeWxAgent:
  1260. m.ResetWxAgent()
  1261. return nil
  1262. case agent.EdgeTokenAgent:
  1263. m.ResetTokenAgent()
  1264. return nil
  1265. case agent.EdgeWaAgent:
  1266. m.ResetWaAgent()
  1267. return nil
  1268. }
  1269. return fmt.Errorf("unknown Agent edge %s", name)
  1270. }
  1271. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1272. type AgentBaseMutation struct {
  1273. config
  1274. op Op
  1275. typ string
  1276. id *string
  1277. q *string
  1278. a *string
  1279. chunk_index *uint64
  1280. addchunk_index *int64
  1281. indexes *[]string
  1282. appendindexes []string
  1283. dataset_id *string
  1284. collection_id *string
  1285. source_name *string
  1286. can_write *[]bool
  1287. appendcan_write []bool
  1288. is_owner *[]bool
  1289. appendis_owner []bool
  1290. clearedFields map[string]struct{}
  1291. wx_agent map[uint64]struct{}
  1292. removedwx_agent map[uint64]struct{}
  1293. clearedwx_agent bool
  1294. done bool
  1295. oldValue func(context.Context) (*AgentBase, error)
  1296. predicates []predicate.AgentBase
  1297. }
  1298. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1299. // agentbaseOption allows management of the mutation configuration using functional options.
  1300. type agentbaseOption func(*AgentBaseMutation)
  1301. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1302. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1303. m := &AgentBaseMutation{
  1304. config: c,
  1305. op: op,
  1306. typ: TypeAgentBase,
  1307. clearedFields: make(map[string]struct{}),
  1308. }
  1309. for _, opt := range opts {
  1310. opt(m)
  1311. }
  1312. return m
  1313. }
  1314. // withAgentBaseID sets the ID field of the mutation.
  1315. func withAgentBaseID(id string) agentbaseOption {
  1316. return func(m *AgentBaseMutation) {
  1317. var (
  1318. err error
  1319. once sync.Once
  1320. value *AgentBase
  1321. )
  1322. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1323. once.Do(func() {
  1324. if m.done {
  1325. err = errors.New("querying old values post mutation is not allowed")
  1326. } else {
  1327. value, err = m.Client().AgentBase.Get(ctx, id)
  1328. }
  1329. })
  1330. return value, err
  1331. }
  1332. m.id = &id
  1333. }
  1334. }
  1335. // withAgentBase sets the old AgentBase of the mutation.
  1336. func withAgentBase(node *AgentBase) agentbaseOption {
  1337. return func(m *AgentBaseMutation) {
  1338. m.oldValue = func(context.Context) (*AgentBase, error) {
  1339. return node, nil
  1340. }
  1341. m.id = &node.ID
  1342. }
  1343. }
  1344. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1345. // executed in a transaction (ent.Tx), a transactional client is returned.
  1346. func (m AgentBaseMutation) Client() *Client {
  1347. client := &Client{config: m.config}
  1348. client.init()
  1349. return client
  1350. }
  1351. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1352. // it returns an error otherwise.
  1353. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1354. if _, ok := m.driver.(*txDriver); !ok {
  1355. return nil, errors.New("ent: mutation is not running in a transaction")
  1356. }
  1357. tx := &Tx{config: m.config}
  1358. tx.init()
  1359. return tx, nil
  1360. }
  1361. // SetID sets the value of the id field. Note that this
  1362. // operation is only accepted on creation of AgentBase entities.
  1363. func (m *AgentBaseMutation) SetID(id string) {
  1364. m.id = &id
  1365. }
  1366. // ID returns the ID value in the mutation. Note that the ID is only available
  1367. // if it was provided to the builder or after it was returned from the database.
  1368. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1369. if m.id == nil {
  1370. return
  1371. }
  1372. return *m.id, true
  1373. }
  1374. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1375. // That means, if the mutation is applied within a transaction with an isolation level such
  1376. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1377. // or updated by the mutation.
  1378. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1379. switch {
  1380. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1381. id, exists := m.ID()
  1382. if exists {
  1383. return []string{id}, nil
  1384. }
  1385. fallthrough
  1386. case m.op.Is(OpUpdate | OpDelete):
  1387. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1388. default:
  1389. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1390. }
  1391. }
  1392. // SetQ sets the "q" field.
  1393. func (m *AgentBaseMutation) SetQ(s string) {
  1394. m.q = &s
  1395. }
  1396. // Q returns the value of the "q" field in the mutation.
  1397. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1398. v := m.q
  1399. if v == nil {
  1400. return
  1401. }
  1402. return *v, true
  1403. }
  1404. // OldQ returns the old "q" field's value of the AgentBase entity.
  1405. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1407. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1408. if !m.op.Is(OpUpdateOne) {
  1409. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1410. }
  1411. if m.id == nil || m.oldValue == nil {
  1412. return v, errors.New("OldQ requires an ID field in the mutation")
  1413. }
  1414. oldValue, err := m.oldValue(ctx)
  1415. if err != nil {
  1416. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1417. }
  1418. return oldValue.Q, nil
  1419. }
  1420. // ClearQ clears the value of the "q" field.
  1421. func (m *AgentBaseMutation) ClearQ() {
  1422. m.q = nil
  1423. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1424. }
  1425. // QCleared returns if the "q" field was cleared in this mutation.
  1426. func (m *AgentBaseMutation) QCleared() bool {
  1427. _, ok := m.clearedFields[agentbase.FieldQ]
  1428. return ok
  1429. }
  1430. // ResetQ resets all changes to the "q" field.
  1431. func (m *AgentBaseMutation) ResetQ() {
  1432. m.q = nil
  1433. delete(m.clearedFields, agentbase.FieldQ)
  1434. }
  1435. // SetA sets the "a" field.
  1436. func (m *AgentBaseMutation) SetA(s string) {
  1437. m.a = &s
  1438. }
  1439. // A returns the value of the "a" field in the mutation.
  1440. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1441. v := m.a
  1442. if v == nil {
  1443. return
  1444. }
  1445. return *v, true
  1446. }
  1447. // OldA returns the old "a" field's value of the AgentBase entity.
  1448. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1450. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1451. if !m.op.Is(OpUpdateOne) {
  1452. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1453. }
  1454. if m.id == nil || m.oldValue == nil {
  1455. return v, errors.New("OldA requires an ID field in the mutation")
  1456. }
  1457. oldValue, err := m.oldValue(ctx)
  1458. if err != nil {
  1459. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1460. }
  1461. return oldValue.A, nil
  1462. }
  1463. // ClearA clears the value of the "a" field.
  1464. func (m *AgentBaseMutation) ClearA() {
  1465. m.a = nil
  1466. m.clearedFields[agentbase.FieldA] = struct{}{}
  1467. }
  1468. // ACleared returns if the "a" field was cleared in this mutation.
  1469. func (m *AgentBaseMutation) ACleared() bool {
  1470. _, ok := m.clearedFields[agentbase.FieldA]
  1471. return ok
  1472. }
  1473. // ResetA resets all changes to the "a" field.
  1474. func (m *AgentBaseMutation) ResetA() {
  1475. m.a = nil
  1476. delete(m.clearedFields, agentbase.FieldA)
  1477. }
  1478. // SetChunkIndex sets the "chunk_index" field.
  1479. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1480. m.chunk_index = &u
  1481. m.addchunk_index = nil
  1482. }
  1483. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1484. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1485. v := m.chunk_index
  1486. if v == nil {
  1487. return
  1488. }
  1489. return *v, true
  1490. }
  1491. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1492. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1494. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1495. if !m.op.Is(OpUpdateOne) {
  1496. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1497. }
  1498. if m.id == nil || m.oldValue == nil {
  1499. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1500. }
  1501. oldValue, err := m.oldValue(ctx)
  1502. if err != nil {
  1503. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1504. }
  1505. return oldValue.ChunkIndex, nil
  1506. }
  1507. // AddChunkIndex adds u to the "chunk_index" field.
  1508. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1509. if m.addchunk_index != nil {
  1510. *m.addchunk_index += u
  1511. } else {
  1512. m.addchunk_index = &u
  1513. }
  1514. }
  1515. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1516. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1517. v := m.addchunk_index
  1518. if v == nil {
  1519. return
  1520. }
  1521. return *v, true
  1522. }
  1523. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1524. func (m *AgentBaseMutation) ResetChunkIndex() {
  1525. m.chunk_index = nil
  1526. m.addchunk_index = nil
  1527. }
  1528. // SetIndexes sets the "indexes" field.
  1529. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1530. m.indexes = &s
  1531. m.appendindexes = nil
  1532. }
  1533. // Indexes returns the value of the "indexes" field in the mutation.
  1534. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1535. v := m.indexes
  1536. if v == nil {
  1537. return
  1538. }
  1539. return *v, true
  1540. }
  1541. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1542. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1544. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1545. if !m.op.Is(OpUpdateOne) {
  1546. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1547. }
  1548. if m.id == nil || m.oldValue == nil {
  1549. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1550. }
  1551. oldValue, err := m.oldValue(ctx)
  1552. if err != nil {
  1553. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1554. }
  1555. return oldValue.Indexes, nil
  1556. }
  1557. // AppendIndexes adds s to the "indexes" field.
  1558. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1559. m.appendindexes = append(m.appendindexes, s...)
  1560. }
  1561. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1562. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1563. if len(m.appendindexes) == 0 {
  1564. return nil, false
  1565. }
  1566. return m.appendindexes, true
  1567. }
  1568. // ClearIndexes clears the value of the "indexes" field.
  1569. func (m *AgentBaseMutation) ClearIndexes() {
  1570. m.indexes = nil
  1571. m.appendindexes = nil
  1572. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1573. }
  1574. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1575. func (m *AgentBaseMutation) IndexesCleared() bool {
  1576. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1577. return ok
  1578. }
  1579. // ResetIndexes resets all changes to the "indexes" field.
  1580. func (m *AgentBaseMutation) ResetIndexes() {
  1581. m.indexes = nil
  1582. m.appendindexes = nil
  1583. delete(m.clearedFields, agentbase.FieldIndexes)
  1584. }
  1585. // SetDatasetID sets the "dataset_id" field.
  1586. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1587. m.dataset_id = &s
  1588. }
  1589. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1590. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1591. v := m.dataset_id
  1592. if v == nil {
  1593. return
  1594. }
  1595. return *v, true
  1596. }
  1597. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1598. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1600. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1601. if !m.op.Is(OpUpdateOne) {
  1602. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1603. }
  1604. if m.id == nil || m.oldValue == nil {
  1605. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1606. }
  1607. oldValue, err := m.oldValue(ctx)
  1608. if err != nil {
  1609. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1610. }
  1611. return oldValue.DatasetID, nil
  1612. }
  1613. // ClearDatasetID clears the value of the "dataset_id" field.
  1614. func (m *AgentBaseMutation) ClearDatasetID() {
  1615. m.dataset_id = nil
  1616. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1617. }
  1618. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1619. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1620. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1621. return ok
  1622. }
  1623. // ResetDatasetID resets all changes to the "dataset_id" field.
  1624. func (m *AgentBaseMutation) ResetDatasetID() {
  1625. m.dataset_id = nil
  1626. delete(m.clearedFields, agentbase.FieldDatasetID)
  1627. }
  1628. // SetCollectionID sets the "collection_id" field.
  1629. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1630. m.collection_id = &s
  1631. }
  1632. // CollectionID returns the value of the "collection_id" field in the mutation.
  1633. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1634. v := m.collection_id
  1635. if v == nil {
  1636. return
  1637. }
  1638. return *v, true
  1639. }
  1640. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1641. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1643. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1644. if !m.op.Is(OpUpdateOne) {
  1645. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1646. }
  1647. if m.id == nil || m.oldValue == nil {
  1648. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1649. }
  1650. oldValue, err := m.oldValue(ctx)
  1651. if err != nil {
  1652. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1653. }
  1654. return oldValue.CollectionID, nil
  1655. }
  1656. // ClearCollectionID clears the value of the "collection_id" field.
  1657. func (m *AgentBaseMutation) ClearCollectionID() {
  1658. m.collection_id = nil
  1659. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1660. }
  1661. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1662. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1663. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1664. return ok
  1665. }
  1666. // ResetCollectionID resets all changes to the "collection_id" field.
  1667. func (m *AgentBaseMutation) ResetCollectionID() {
  1668. m.collection_id = nil
  1669. delete(m.clearedFields, agentbase.FieldCollectionID)
  1670. }
  1671. // SetSourceName sets the "source_name" field.
  1672. func (m *AgentBaseMutation) SetSourceName(s string) {
  1673. m.source_name = &s
  1674. }
  1675. // SourceName returns the value of the "source_name" field in the mutation.
  1676. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1677. v := m.source_name
  1678. if v == nil {
  1679. return
  1680. }
  1681. return *v, true
  1682. }
  1683. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1684. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1686. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1687. if !m.op.Is(OpUpdateOne) {
  1688. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1689. }
  1690. if m.id == nil || m.oldValue == nil {
  1691. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1692. }
  1693. oldValue, err := m.oldValue(ctx)
  1694. if err != nil {
  1695. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1696. }
  1697. return oldValue.SourceName, nil
  1698. }
  1699. // ClearSourceName clears the value of the "source_name" field.
  1700. func (m *AgentBaseMutation) ClearSourceName() {
  1701. m.source_name = nil
  1702. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1703. }
  1704. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1705. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1706. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1707. return ok
  1708. }
  1709. // ResetSourceName resets all changes to the "source_name" field.
  1710. func (m *AgentBaseMutation) ResetSourceName() {
  1711. m.source_name = nil
  1712. delete(m.clearedFields, agentbase.FieldSourceName)
  1713. }
  1714. // SetCanWrite sets the "can_write" field.
  1715. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1716. m.can_write = &b
  1717. m.appendcan_write = nil
  1718. }
  1719. // CanWrite returns the value of the "can_write" field in the mutation.
  1720. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1721. v := m.can_write
  1722. if v == nil {
  1723. return
  1724. }
  1725. return *v, true
  1726. }
  1727. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1728. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1730. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1731. if !m.op.Is(OpUpdateOne) {
  1732. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1733. }
  1734. if m.id == nil || m.oldValue == nil {
  1735. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1736. }
  1737. oldValue, err := m.oldValue(ctx)
  1738. if err != nil {
  1739. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1740. }
  1741. return oldValue.CanWrite, nil
  1742. }
  1743. // AppendCanWrite adds b to the "can_write" field.
  1744. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1745. m.appendcan_write = append(m.appendcan_write, b...)
  1746. }
  1747. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1748. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1749. if len(m.appendcan_write) == 0 {
  1750. return nil, false
  1751. }
  1752. return m.appendcan_write, true
  1753. }
  1754. // ClearCanWrite clears the value of the "can_write" field.
  1755. func (m *AgentBaseMutation) ClearCanWrite() {
  1756. m.can_write = nil
  1757. m.appendcan_write = nil
  1758. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1759. }
  1760. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1761. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1762. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1763. return ok
  1764. }
  1765. // ResetCanWrite resets all changes to the "can_write" field.
  1766. func (m *AgentBaseMutation) ResetCanWrite() {
  1767. m.can_write = nil
  1768. m.appendcan_write = nil
  1769. delete(m.clearedFields, agentbase.FieldCanWrite)
  1770. }
  1771. // SetIsOwner sets the "is_owner" field.
  1772. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1773. m.is_owner = &b
  1774. m.appendis_owner = nil
  1775. }
  1776. // IsOwner returns the value of the "is_owner" field in the mutation.
  1777. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1778. v := m.is_owner
  1779. if v == nil {
  1780. return
  1781. }
  1782. return *v, true
  1783. }
  1784. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1785. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1787. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1788. if !m.op.Is(OpUpdateOne) {
  1789. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1790. }
  1791. if m.id == nil || m.oldValue == nil {
  1792. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1793. }
  1794. oldValue, err := m.oldValue(ctx)
  1795. if err != nil {
  1796. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1797. }
  1798. return oldValue.IsOwner, nil
  1799. }
  1800. // AppendIsOwner adds b to the "is_owner" field.
  1801. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1802. m.appendis_owner = append(m.appendis_owner, b...)
  1803. }
  1804. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1805. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1806. if len(m.appendis_owner) == 0 {
  1807. return nil, false
  1808. }
  1809. return m.appendis_owner, true
  1810. }
  1811. // ClearIsOwner clears the value of the "is_owner" field.
  1812. func (m *AgentBaseMutation) ClearIsOwner() {
  1813. m.is_owner = nil
  1814. m.appendis_owner = nil
  1815. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1816. }
  1817. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1818. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1819. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1820. return ok
  1821. }
  1822. // ResetIsOwner resets all changes to the "is_owner" field.
  1823. func (m *AgentBaseMutation) ResetIsOwner() {
  1824. m.is_owner = nil
  1825. m.appendis_owner = nil
  1826. delete(m.clearedFields, agentbase.FieldIsOwner)
  1827. }
  1828. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1829. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1830. if m.wx_agent == nil {
  1831. m.wx_agent = make(map[uint64]struct{})
  1832. }
  1833. for i := range ids {
  1834. m.wx_agent[ids[i]] = struct{}{}
  1835. }
  1836. }
  1837. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1838. func (m *AgentBaseMutation) ClearWxAgent() {
  1839. m.clearedwx_agent = true
  1840. }
  1841. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1842. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1843. return m.clearedwx_agent
  1844. }
  1845. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1846. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1847. if m.removedwx_agent == nil {
  1848. m.removedwx_agent = make(map[uint64]struct{})
  1849. }
  1850. for i := range ids {
  1851. delete(m.wx_agent, ids[i])
  1852. m.removedwx_agent[ids[i]] = struct{}{}
  1853. }
  1854. }
  1855. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1856. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1857. for id := range m.removedwx_agent {
  1858. ids = append(ids, id)
  1859. }
  1860. return
  1861. }
  1862. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1863. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1864. for id := range m.wx_agent {
  1865. ids = append(ids, id)
  1866. }
  1867. return
  1868. }
  1869. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1870. func (m *AgentBaseMutation) ResetWxAgent() {
  1871. m.wx_agent = nil
  1872. m.clearedwx_agent = false
  1873. m.removedwx_agent = nil
  1874. }
  1875. // Where appends a list predicates to the AgentBaseMutation builder.
  1876. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1877. m.predicates = append(m.predicates, ps...)
  1878. }
  1879. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1880. // users can use type-assertion to append predicates that do not depend on any generated package.
  1881. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1882. p := make([]predicate.AgentBase, len(ps))
  1883. for i := range ps {
  1884. p[i] = ps[i]
  1885. }
  1886. m.Where(p...)
  1887. }
  1888. // Op returns the operation name.
  1889. func (m *AgentBaseMutation) Op() Op {
  1890. return m.op
  1891. }
  1892. // SetOp allows setting the mutation operation.
  1893. func (m *AgentBaseMutation) SetOp(op Op) {
  1894. m.op = op
  1895. }
  1896. // Type returns the node type of this mutation (AgentBase).
  1897. func (m *AgentBaseMutation) Type() string {
  1898. return m.typ
  1899. }
  1900. // Fields returns all fields that were changed during this mutation. Note that in
  1901. // order to get all numeric fields that were incremented/decremented, call
  1902. // AddedFields().
  1903. func (m *AgentBaseMutation) Fields() []string {
  1904. fields := make([]string, 0, 9)
  1905. if m.q != nil {
  1906. fields = append(fields, agentbase.FieldQ)
  1907. }
  1908. if m.a != nil {
  1909. fields = append(fields, agentbase.FieldA)
  1910. }
  1911. if m.chunk_index != nil {
  1912. fields = append(fields, agentbase.FieldChunkIndex)
  1913. }
  1914. if m.indexes != nil {
  1915. fields = append(fields, agentbase.FieldIndexes)
  1916. }
  1917. if m.dataset_id != nil {
  1918. fields = append(fields, agentbase.FieldDatasetID)
  1919. }
  1920. if m.collection_id != nil {
  1921. fields = append(fields, agentbase.FieldCollectionID)
  1922. }
  1923. if m.source_name != nil {
  1924. fields = append(fields, agentbase.FieldSourceName)
  1925. }
  1926. if m.can_write != nil {
  1927. fields = append(fields, agentbase.FieldCanWrite)
  1928. }
  1929. if m.is_owner != nil {
  1930. fields = append(fields, agentbase.FieldIsOwner)
  1931. }
  1932. return fields
  1933. }
  1934. // Field returns the value of a field with the given name. The second boolean
  1935. // return value indicates that this field was not set, or was not defined in the
  1936. // schema.
  1937. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1938. switch name {
  1939. case agentbase.FieldQ:
  1940. return m.Q()
  1941. case agentbase.FieldA:
  1942. return m.A()
  1943. case agentbase.FieldChunkIndex:
  1944. return m.ChunkIndex()
  1945. case agentbase.FieldIndexes:
  1946. return m.Indexes()
  1947. case agentbase.FieldDatasetID:
  1948. return m.DatasetID()
  1949. case agentbase.FieldCollectionID:
  1950. return m.CollectionID()
  1951. case agentbase.FieldSourceName:
  1952. return m.SourceName()
  1953. case agentbase.FieldCanWrite:
  1954. return m.CanWrite()
  1955. case agentbase.FieldIsOwner:
  1956. return m.IsOwner()
  1957. }
  1958. return nil, false
  1959. }
  1960. // OldField returns the old value of the field from the database. An error is
  1961. // returned if the mutation operation is not UpdateOne, or the query to the
  1962. // database failed.
  1963. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1964. switch name {
  1965. case agentbase.FieldQ:
  1966. return m.OldQ(ctx)
  1967. case agentbase.FieldA:
  1968. return m.OldA(ctx)
  1969. case agentbase.FieldChunkIndex:
  1970. return m.OldChunkIndex(ctx)
  1971. case agentbase.FieldIndexes:
  1972. return m.OldIndexes(ctx)
  1973. case agentbase.FieldDatasetID:
  1974. return m.OldDatasetID(ctx)
  1975. case agentbase.FieldCollectionID:
  1976. return m.OldCollectionID(ctx)
  1977. case agentbase.FieldSourceName:
  1978. return m.OldSourceName(ctx)
  1979. case agentbase.FieldCanWrite:
  1980. return m.OldCanWrite(ctx)
  1981. case agentbase.FieldIsOwner:
  1982. return m.OldIsOwner(ctx)
  1983. }
  1984. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1985. }
  1986. // SetField sets the value of a field with the given name. It returns an error if
  1987. // the field is not defined in the schema, or if the type mismatched the field
  1988. // type.
  1989. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1990. switch name {
  1991. case agentbase.FieldQ:
  1992. v, ok := value.(string)
  1993. if !ok {
  1994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1995. }
  1996. m.SetQ(v)
  1997. return nil
  1998. case agentbase.FieldA:
  1999. v, ok := value.(string)
  2000. if !ok {
  2001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2002. }
  2003. m.SetA(v)
  2004. return nil
  2005. case agentbase.FieldChunkIndex:
  2006. v, ok := value.(uint64)
  2007. if !ok {
  2008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2009. }
  2010. m.SetChunkIndex(v)
  2011. return nil
  2012. case agentbase.FieldIndexes:
  2013. v, ok := value.([]string)
  2014. if !ok {
  2015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2016. }
  2017. m.SetIndexes(v)
  2018. return nil
  2019. case agentbase.FieldDatasetID:
  2020. v, ok := value.(string)
  2021. if !ok {
  2022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2023. }
  2024. m.SetDatasetID(v)
  2025. return nil
  2026. case agentbase.FieldCollectionID:
  2027. v, ok := value.(string)
  2028. if !ok {
  2029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2030. }
  2031. m.SetCollectionID(v)
  2032. return nil
  2033. case agentbase.FieldSourceName:
  2034. v, ok := value.(string)
  2035. if !ok {
  2036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2037. }
  2038. m.SetSourceName(v)
  2039. return nil
  2040. case agentbase.FieldCanWrite:
  2041. v, ok := value.([]bool)
  2042. if !ok {
  2043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2044. }
  2045. m.SetCanWrite(v)
  2046. return nil
  2047. case agentbase.FieldIsOwner:
  2048. v, ok := value.([]bool)
  2049. if !ok {
  2050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2051. }
  2052. m.SetIsOwner(v)
  2053. return nil
  2054. }
  2055. return fmt.Errorf("unknown AgentBase field %s", name)
  2056. }
  2057. // AddedFields returns all numeric fields that were incremented/decremented during
  2058. // this mutation.
  2059. func (m *AgentBaseMutation) AddedFields() []string {
  2060. var fields []string
  2061. if m.addchunk_index != nil {
  2062. fields = append(fields, agentbase.FieldChunkIndex)
  2063. }
  2064. return fields
  2065. }
  2066. // AddedField returns the numeric value that was incremented/decremented on a field
  2067. // with the given name. The second boolean return value indicates that this field
  2068. // was not set, or was not defined in the schema.
  2069. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2070. switch name {
  2071. case agentbase.FieldChunkIndex:
  2072. return m.AddedChunkIndex()
  2073. }
  2074. return nil, false
  2075. }
  2076. // AddField adds the value to the field with the given name. It returns an error if
  2077. // the field is not defined in the schema, or if the type mismatched the field
  2078. // type.
  2079. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2080. switch name {
  2081. case agentbase.FieldChunkIndex:
  2082. v, ok := value.(int64)
  2083. if !ok {
  2084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2085. }
  2086. m.AddChunkIndex(v)
  2087. return nil
  2088. }
  2089. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2090. }
  2091. // ClearedFields returns all nullable fields that were cleared during this
  2092. // mutation.
  2093. func (m *AgentBaseMutation) ClearedFields() []string {
  2094. var fields []string
  2095. if m.FieldCleared(agentbase.FieldQ) {
  2096. fields = append(fields, agentbase.FieldQ)
  2097. }
  2098. if m.FieldCleared(agentbase.FieldA) {
  2099. fields = append(fields, agentbase.FieldA)
  2100. }
  2101. if m.FieldCleared(agentbase.FieldIndexes) {
  2102. fields = append(fields, agentbase.FieldIndexes)
  2103. }
  2104. if m.FieldCleared(agentbase.FieldDatasetID) {
  2105. fields = append(fields, agentbase.FieldDatasetID)
  2106. }
  2107. if m.FieldCleared(agentbase.FieldCollectionID) {
  2108. fields = append(fields, agentbase.FieldCollectionID)
  2109. }
  2110. if m.FieldCleared(agentbase.FieldSourceName) {
  2111. fields = append(fields, agentbase.FieldSourceName)
  2112. }
  2113. if m.FieldCleared(agentbase.FieldCanWrite) {
  2114. fields = append(fields, agentbase.FieldCanWrite)
  2115. }
  2116. if m.FieldCleared(agentbase.FieldIsOwner) {
  2117. fields = append(fields, agentbase.FieldIsOwner)
  2118. }
  2119. return fields
  2120. }
  2121. // FieldCleared returns a boolean indicating if a field with the given name was
  2122. // cleared in this mutation.
  2123. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2124. _, ok := m.clearedFields[name]
  2125. return ok
  2126. }
  2127. // ClearField clears the value of the field with the given name. It returns an
  2128. // error if the field is not defined in the schema.
  2129. func (m *AgentBaseMutation) ClearField(name string) error {
  2130. switch name {
  2131. case agentbase.FieldQ:
  2132. m.ClearQ()
  2133. return nil
  2134. case agentbase.FieldA:
  2135. m.ClearA()
  2136. return nil
  2137. case agentbase.FieldIndexes:
  2138. m.ClearIndexes()
  2139. return nil
  2140. case agentbase.FieldDatasetID:
  2141. m.ClearDatasetID()
  2142. return nil
  2143. case agentbase.FieldCollectionID:
  2144. m.ClearCollectionID()
  2145. return nil
  2146. case agentbase.FieldSourceName:
  2147. m.ClearSourceName()
  2148. return nil
  2149. case agentbase.FieldCanWrite:
  2150. m.ClearCanWrite()
  2151. return nil
  2152. case agentbase.FieldIsOwner:
  2153. m.ClearIsOwner()
  2154. return nil
  2155. }
  2156. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2157. }
  2158. // ResetField resets all changes in the mutation for the field with the given name.
  2159. // It returns an error if the field is not defined in the schema.
  2160. func (m *AgentBaseMutation) ResetField(name string) error {
  2161. switch name {
  2162. case agentbase.FieldQ:
  2163. m.ResetQ()
  2164. return nil
  2165. case agentbase.FieldA:
  2166. m.ResetA()
  2167. return nil
  2168. case agentbase.FieldChunkIndex:
  2169. m.ResetChunkIndex()
  2170. return nil
  2171. case agentbase.FieldIndexes:
  2172. m.ResetIndexes()
  2173. return nil
  2174. case agentbase.FieldDatasetID:
  2175. m.ResetDatasetID()
  2176. return nil
  2177. case agentbase.FieldCollectionID:
  2178. m.ResetCollectionID()
  2179. return nil
  2180. case agentbase.FieldSourceName:
  2181. m.ResetSourceName()
  2182. return nil
  2183. case agentbase.FieldCanWrite:
  2184. m.ResetCanWrite()
  2185. return nil
  2186. case agentbase.FieldIsOwner:
  2187. m.ResetIsOwner()
  2188. return nil
  2189. }
  2190. return fmt.Errorf("unknown AgentBase field %s", name)
  2191. }
  2192. // AddedEdges returns all edge names that were set/added in this mutation.
  2193. func (m *AgentBaseMutation) AddedEdges() []string {
  2194. edges := make([]string, 0, 1)
  2195. if m.wx_agent != nil {
  2196. edges = append(edges, agentbase.EdgeWxAgent)
  2197. }
  2198. return edges
  2199. }
  2200. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2201. // name in this mutation.
  2202. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2203. switch name {
  2204. case agentbase.EdgeWxAgent:
  2205. ids := make([]ent.Value, 0, len(m.wx_agent))
  2206. for id := range m.wx_agent {
  2207. ids = append(ids, id)
  2208. }
  2209. return ids
  2210. }
  2211. return nil
  2212. }
  2213. // RemovedEdges returns all edge names that were removed in this mutation.
  2214. func (m *AgentBaseMutation) RemovedEdges() []string {
  2215. edges := make([]string, 0, 1)
  2216. if m.removedwx_agent != nil {
  2217. edges = append(edges, agentbase.EdgeWxAgent)
  2218. }
  2219. return edges
  2220. }
  2221. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2222. // the given name in this mutation.
  2223. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2224. switch name {
  2225. case agentbase.EdgeWxAgent:
  2226. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2227. for id := range m.removedwx_agent {
  2228. ids = append(ids, id)
  2229. }
  2230. return ids
  2231. }
  2232. return nil
  2233. }
  2234. // ClearedEdges returns all edge names that were cleared in this mutation.
  2235. func (m *AgentBaseMutation) ClearedEdges() []string {
  2236. edges := make([]string, 0, 1)
  2237. if m.clearedwx_agent {
  2238. edges = append(edges, agentbase.EdgeWxAgent)
  2239. }
  2240. return edges
  2241. }
  2242. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2243. // was cleared in this mutation.
  2244. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2245. switch name {
  2246. case agentbase.EdgeWxAgent:
  2247. return m.clearedwx_agent
  2248. }
  2249. return false
  2250. }
  2251. // ClearEdge clears the value of the edge with the given name. It returns an error
  2252. // if that edge is not defined in the schema.
  2253. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2254. switch name {
  2255. }
  2256. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2257. }
  2258. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2259. // It returns an error if the edge is not defined in the schema.
  2260. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2261. switch name {
  2262. case agentbase.EdgeWxAgent:
  2263. m.ResetWxAgent()
  2264. return nil
  2265. }
  2266. return fmt.Errorf("unknown AgentBase edge %s", name)
  2267. }
  2268. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2269. type AliyunAvatarMutation struct {
  2270. config
  2271. op Op
  2272. typ string
  2273. id *uint64
  2274. created_at *time.Time
  2275. updated_at *time.Time
  2276. deleted_at *time.Time
  2277. user_id *uint64
  2278. adduser_id *int64
  2279. biz_id *string
  2280. access_key_id *string
  2281. access_key_secret *string
  2282. app_id *string
  2283. tenant_id *uint64
  2284. addtenant_id *int64
  2285. response *string
  2286. token *string
  2287. session_id *string
  2288. clearedFields map[string]struct{}
  2289. done bool
  2290. oldValue func(context.Context) (*AliyunAvatar, error)
  2291. predicates []predicate.AliyunAvatar
  2292. }
  2293. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2294. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2295. type aliyunavatarOption func(*AliyunAvatarMutation)
  2296. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2297. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2298. m := &AliyunAvatarMutation{
  2299. config: c,
  2300. op: op,
  2301. typ: TypeAliyunAvatar,
  2302. clearedFields: make(map[string]struct{}),
  2303. }
  2304. for _, opt := range opts {
  2305. opt(m)
  2306. }
  2307. return m
  2308. }
  2309. // withAliyunAvatarID sets the ID field of the mutation.
  2310. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2311. return func(m *AliyunAvatarMutation) {
  2312. var (
  2313. err error
  2314. once sync.Once
  2315. value *AliyunAvatar
  2316. )
  2317. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2318. once.Do(func() {
  2319. if m.done {
  2320. err = errors.New("querying old values post mutation is not allowed")
  2321. } else {
  2322. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2323. }
  2324. })
  2325. return value, err
  2326. }
  2327. m.id = &id
  2328. }
  2329. }
  2330. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2331. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2332. return func(m *AliyunAvatarMutation) {
  2333. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2334. return node, nil
  2335. }
  2336. m.id = &node.ID
  2337. }
  2338. }
  2339. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2340. // executed in a transaction (ent.Tx), a transactional client is returned.
  2341. func (m AliyunAvatarMutation) Client() *Client {
  2342. client := &Client{config: m.config}
  2343. client.init()
  2344. return client
  2345. }
  2346. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2347. // it returns an error otherwise.
  2348. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2349. if _, ok := m.driver.(*txDriver); !ok {
  2350. return nil, errors.New("ent: mutation is not running in a transaction")
  2351. }
  2352. tx := &Tx{config: m.config}
  2353. tx.init()
  2354. return tx, nil
  2355. }
  2356. // SetID sets the value of the id field. Note that this
  2357. // operation is only accepted on creation of AliyunAvatar entities.
  2358. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2359. m.id = &id
  2360. }
  2361. // ID returns the ID value in the mutation. Note that the ID is only available
  2362. // if it was provided to the builder or after it was returned from the database.
  2363. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2364. if m.id == nil {
  2365. return
  2366. }
  2367. return *m.id, true
  2368. }
  2369. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2370. // That means, if the mutation is applied within a transaction with an isolation level such
  2371. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2372. // or updated by the mutation.
  2373. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2374. switch {
  2375. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2376. id, exists := m.ID()
  2377. if exists {
  2378. return []uint64{id}, nil
  2379. }
  2380. fallthrough
  2381. case m.op.Is(OpUpdate | OpDelete):
  2382. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2383. default:
  2384. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2385. }
  2386. }
  2387. // SetCreatedAt sets the "created_at" field.
  2388. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2389. m.created_at = &t
  2390. }
  2391. // CreatedAt returns the value of the "created_at" field in the mutation.
  2392. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2393. v := m.created_at
  2394. if v == nil {
  2395. return
  2396. }
  2397. return *v, true
  2398. }
  2399. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2400. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2402. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2403. if !m.op.Is(OpUpdateOne) {
  2404. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2405. }
  2406. if m.id == nil || m.oldValue == nil {
  2407. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2408. }
  2409. oldValue, err := m.oldValue(ctx)
  2410. if err != nil {
  2411. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2412. }
  2413. return oldValue.CreatedAt, nil
  2414. }
  2415. // ResetCreatedAt resets all changes to the "created_at" field.
  2416. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2417. m.created_at = nil
  2418. }
  2419. // SetUpdatedAt sets the "updated_at" field.
  2420. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2421. m.updated_at = &t
  2422. }
  2423. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2424. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2425. v := m.updated_at
  2426. if v == nil {
  2427. return
  2428. }
  2429. return *v, true
  2430. }
  2431. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2432. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2434. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2435. if !m.op.Is(OpUpdateOne) {
  2436. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2437. }
  2438. if m.id == nil || m.oldValue == nil {
  2439. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2440. }
  2441. oldValue, err := m.oldValue(ctx)
  2442. if err != nil {
  2443. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2444. }
  2445. return oldValue.UpdatedAt, nil
  2446. }
  2447. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2448. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2449. m.updated_at = nil
  2450. }
  2451. // SetDeletedAt sets the "deleted_at" field.
  2452. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2453. m.deleted_at = &t
  2454. }
  2455. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2456. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2457. v := m.deleted_at
  2458. if v == nil {
  2459. return
  2460. }
  2461. return *v, true
  2462. }
  2463. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2464. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2466. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2467. if !m.op.Is(OpUpdateOne) {
  2468. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2469. }
  2470. if m.id == nil || m.oldValue == nil {
  2471. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2472. }
  2473. oldValue, err := m.oldValue(ctx)
  2474. if err != nil {
  2475. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2476. }
  2477. return oldValue.DeletedAt, nil
  2478. }
  2479. // ClearDeletedAt clears the value of the "deleted_at" field.
  2480. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2481. m.deleted_at = nil
  2482. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2483. }
  2484. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2485. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2486. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2487. return ok
  2488. }
  2489. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2490. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2491. m.deleted_at = nil
  2492. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2493. }
  2494. // SetUserID sets the "user_id" field.
  2495. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2496. m.user_id = &u
  2497. m.adduser_id = nil
  2498. }
  2499. // UserID returns the value of the "user_id" field in the mutation.
  2500. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2501. v := m.user_id
  2502. if v == nil {
  2503. return
  2504. }
  2505. return *v, true
  2506. }
  2507. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2508. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2510. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2511. if !m.op.Is(OpUpdateOne) {
  2512. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2513. }
  2514. if m.id == nil || m.oldValue == nil {
  2515. return v, errors.New("OldUserID requires an ID field in the mutation")
  2516. }
  2517. oldValue, err := m.oldValue(ctx)
  2518. if err != nil {
  2519. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2520. }
  2521. return oldValue.UserID, nil
  2522. }
  2523. // AddUserID adds u to the "user_id" field.
  2524. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2525. if m.adduser_id != nil {
  2526. *m.adduser_id += u
  2527. } else {
  2528. m.adduser_id = &u
  2529. }
  2530. }
  2531. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2532. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2533. v := m.adduser_id
  2534. if v == nil {
  2535. return
  2536. }
  2537. return *v, true
  2538. }
  2539. // ResetUserID resets all changes to the "user_id" field.
  2540. func (m *AliyunAvatarMutation) ResetUserID() {
  2541. m.user_id = nil
  2542. m.adduser_id = nil
  2543. }
  2544. // SetBizID sets the "biz_id" field.
  2545. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2546. m.biz_id = &s
  2547. }
  2548. // BizID returns the value of the "biz_id" field in the mutation.
  2549. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2550. v := m.biz_id
  2551. if v == nil {
  2552. return
  2553. }
  2554. return *v, true
  2555. }
  2556. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2557. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2559. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2560. if !m.op.Is(OpUpdateOne) {
  2561. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2562. }
  2563. if m.id == nil || m.oldValue == nil {
  2564. return v, errors.New("OldBizID requires an ID field in the mutation")
  2565. }
  2566. oldValue, err := m.oldValue(ctx)
  2567. if err != nil {
  2568. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2569. }
  2570. return oldValue.BizID, nil
  2571. }
  2572. // ResetBizID resets all changes to the "biz_id" field.
  2573. func (m *AliyunAvatarMutation) ResetBizID() {
  2574. m.biz_id = nil
  2575. }
  2576. // SetAccessKeyID sets the "access_key_id" field.
  2577. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2578. m.access_key_id = &s
  2579. }
  2580. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2581. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2582. v := m.access_key_id
  2583. if v == nil {
  2584. return
  2585. }
  2586. return *v, true
  2587. }
  2588. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2589. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2591. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2592. if !m.op.Is(OpUpdateOne) {
  2593. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2594. }
  2595. if m.id == nil || m.oldValue == nil {
  2596. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2597. }
  2598. oldValue, err := m.oldValue(ctx)
  2599. if err != nil {
  2600. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2601. }
  2602. return oldValue.AccessKeyID, nil
  2603. }
  2604. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2605. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2606. m.access_key_id = nil
  2607. }
  2608. // SetAccessKeySecret sets the "access_key_secret" field.
  2609. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2610. m.access_key_secret = &s
  2611. }
  2612. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2613. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2614. v := m.access_key_secret
  2615. if v == nil {
  2616. return
  2617. }
  2618. return *v, true
  2619. }
  2620. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2621. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2623. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2624. if !m.op.Is(OpUpdateOne) {
  2625. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2626. }
  2627. if m.id == nil || m.oldValue == nil {
  2628. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2629. }
  2630. oldValue, err := m.oldValue(ctx)
  2631. if err != nil {
  2632. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2633. }
  2634. return oldValue.AccessKeySecret, nil
  2635. }
  2636. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2637. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2638. m.access_key_secret = nil
  2639. }
  2640. // SetAppID sets the "app_id" field.
  2641. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2642. m.app_id = &s
  2643. }
  2644. // AppID returns the value of the "app_id" field in the mutation.
  2645. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2646. v := m.app_id
  2647. if v == nil {
  2648. return
  2649. }
  2650. return *v, true
  2651. }
  2652. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2653. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2655. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2656. if !m.op.Is(OpUpdateOne) {
  2657. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2658. }
  2659. if m.id == nil || m.oldValue == nil {
  2660. return v, errors.New("OldAppID requires an ID field in the mutation")
  2661. }
  2662. oldValue, err := m.oldValue(ctx)
  2663. if err != nil {
  2664. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2665. }
  2666. return oldValue.AppID, nil
  2667. }
  2668. // ClearAppID clears the value of the "app_id" field.
  2669. func (m *AliyunAvatarMutation) ClearAppID() {
  2670. m.app_id = nil
  2671. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2672. }
  2673. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2674. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2675. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2676. return ok
  2677. }
  2678. // ResetAppID resets all changes to the "app_id" field.
  2679. func (m *AliyunAvatarMutation) ResetAppID() {
  2680. m.app_id = nil
  2681. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2682. }
  2683. // SetTenantID sets the "tenant_id" field.
  2684. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2685. m.tenant_id = &u
  2686. m.addtenant_id = nil
  2687. }
  2688. // TenantID returns the value of the "tenant_id" field in the mutation.
  2689. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2690. v := m.tenant_id
  2691. if v == nil {
  2692. return
  2693. }
  2694. return *v, true
  2695. }
  2696. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2697. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2699. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2700. if !m.op.Is(OpUpdateOne) {
  2701. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2702. }
  2703. if m.id == nil || m.oldValue == nil {
  2704. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2705. }
  2706. oldValue, err := m.oldValue(ctx)
  2707. if err != nil {
  2708. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2709. }
  2710. return oldValue.TenantID, nil
  2711. }
  2712. // AddTenantID adds u to the "tenant_id" field.
  2713. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2714. if m.addtenant_id != nil {
  2715. *m.addtenant_id += u
  2716. } else {
  2717. m.addtenant_id = &u
  2718. }
  2719. }
  2720. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2721. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2722. v := m.addtenant_id
  2723. if v == nil {
  2724. return
  2725. }
  2726. return *v, true
  2727. }
  2728. // ResetTenantID resets all changes to the "tenant_id" field.
  2729. func (m *AliyunAvatarMutation) ResetTenantID() {
  2730. m.tenant_id = nil
  2731. m.addtenant_id = nil
  2732. }
  2733. // SetResponse sets the "response" field.
  2734. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2735. m.response = &s
  2736. }
  2737. // Response returns the value of the "response" field in the mutation.
  2738. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2739. v := m.response
  2740. if v == nil {
  2741. return
  2742. }
  2743. return *v, true
  2744. }
  2745. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2746. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2748. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2749. if !m.op.Is(OpUpdateOne) {
  2750. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2751. }
  2752. if m.id == nil || m.oldValue == nil {
  2753. return v, errors.New("OldResponse requires an ID field in the mutation")
  2754. }
  2755. oldValue, err := m.oldValue(ctx)
  2756. if err != nil {
  2757. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2758. }
  2759. return oldValue.Response, nil
  2760. }
  2761. // ResetResponse resets all changes to the "response" field.
  2762. func (m *AliyunAvatarMutation) ResetResponse() {
  2763. m.response = nil
  2764. }
  2765. // SetToken sets the "token" field.
  2766. func (m *AliyunAvatarMutation) SetToken(s string) {
  2767. m.token = &s
  2768. }
  2769. // Token returns the value of the "token" field in the mutation.
  2770. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2771. v := m.token
  2772. if v == nil {
  2773. return
  2774. }
  2775. return *v, true
  2776. }
  2777. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2778. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2780. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2781. if !m.op.Is(OpUpdateOne) {
  2782. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2783. }
  2784. if m.id == nil || m.oldValue == nil {
  2785. return v, errors.New("OldToken requires an ID field in the mutation")
  2786. }
  2787. oldValue, err := m.oldValue(ctx)
  2788. if err != nil {
  2789. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2790. }
  2791. return oldValue.Token, nil
  2792. }
  2793. // ResetToken resets all changes to the "token" field.
  2794. func (m *AliyunAvatarMutation) ResetToken() {
  2795. m.token = nil
  2796. }
  2797. // SetSessionID sets the "session_id" field.
  2798. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2799. m.session_id = &s
  2800. }
  2801. // SessionID returns the value of the "session_id" field in the mutation.
  2802. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2803. v := m.session_id
  2804. if v == nil {
  2805. return
  2806. }
  2807. return *v, true
  2808. }
  2809. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2810. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2812. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2813. if !m.op.Is(OpUpdateOne) {
  2814. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2815. }
  2816. if m.id == nil || m.oldValue == nil {
  2817. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2818. }
  2819. oldValue, err := m.oldValue(ctx)
  2820. if err != nil {
  2821. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2822. }
  2823. return oldValue.SessionID, nil
  2824. }
  2825. // ResetSessionID resets all changes to the "session_id" field.
  2826. func (m *AliyunAvatarMutation) ResetSessionID() {
  2827. m.session_id = nil
  2828. }
  2829. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2830. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2831. m.predicates = append(m.predicates, ps...)
  2832. }
  2833. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2834. // users can use type-assertion to append predicates that do not depend on any generated package.
  2835. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2836. p := make([]predicate.AliyunAvatar, len(ps))
  2837. for i := range ps {
  2838. p[i] = ps[i]
  2839. }
  2840. m.Where(p...)
  2841. }
  2842. // Op returns the operation name.
  2843. func (m *AliyunAvatarMutation) Op() Op {
  2844. return m.op
  2845. }
  2846. // SetOp allows setting the mutation operation.
  2847. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2848. m.op = op
  2849. }
  2850. // Type returns the node type of this mutation (AliyunAvatar).
  2851. func (m *AliyunAvatarMutation) Type() string {
  2852. return m.typ
  2853. }
  2854. // Fields returns all fields that were changed during this mutation. Note that in
  2855. // order to get all numeric fields that were incremented/decremented, call
  2856. // AddedFields().
  2857. func (m *AliyunAvatarMutation) Fields() []string {
  2858. fields := make([]string, 0, 12)
  2859. if m.created_at != nil {
  2860. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2861. }
  2862. if m.updated_at != nil {
  2863. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2864. }
  2865. if m.deleted_at != nil {
  2866. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2867. }
  2868. if m.user_id != nil {
  2869. fields = append(fields, aliyunavatar.FieldUserID)
  2870. }
  2871. if m.biz_id != nil {
  2872. fields = append(fields, aliyunavatar.FieldBizID)
  2873. }
  2874. if m.access_key_id != nil {
  2875. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2876. }
  2877. if m.access_key_secret != nil {
  2878. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2879. }
  2880. if m.app_id != nil {
  2881. fields = append(fields, aliyunavatar.FieldAppID)
  2882. }
  2883. if m.tenant_id != nil {
  2884. fields = append(fields, aliyunavatar.FieldTenantID)
  2885. }
  2886. if m.response != nil {
  2887. fields = append(fields, aliyunavatar.FieldResponse)
  2888. }
  2889. if m.token != nil {
  2890. fields = append(fields, aliyunavatar.FieldToken)
  2891. }
  2892. if m.session_id != nil {
  2893. fields = append(fields, aliyunavatar.FieldSessionID)
  2894. }
  2895. return fields
  2896. }
  2897. // Field returns the value of a field with the given name. The second boolean
  2898. // return value indicates that this field was not set, or was not defined in the
  2899. // schema.
  2900. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2901. switch name {
  2902. case aliyunavatar.FieldCreatedAt:
  2903. return m.CreatedAt()
  2904. case aliyunavatar.FieldUpdatedAt:
  2905. return m.UpdatedAt()
  2906. case aliyunavatar.FieldDeletedAt:
  2907. return m.DeletedAt()
  2908. case aliyunavatar.FieldUserID:
  2909. return m.UserID()
  2910. case aliyunavatar.FieldBizID:
  2911. return m.BizID()
  2912. case aliyunavatar.FieldAccessKeyID:
  2913. return m.AccessKeyID()
  2914. case aliyunavatar.FieldAccessKeySecret:
  2915. return m.AccessKeySecret()
  2916. case aliyunavatar.FieldAppID:
  2917. return m.AppID()
  2918. case aliyunavatar.FieldTenantID:
  2919. return m.TenantID()
  2920. case aliyunavatar.FieldResponse:
  2921. return m.Response()
  2922. case aliyunavatar.FieldToken:
  2923. return m.Token()
  2924. case aliyunavatar.FieldSessionID:
  2925. return m.SessionID()
  2926. }
  2927. return nil, false
  2928. }
  2929. // OldField returns the old value of the field from the database. An error is
  2930. // returned if the mutation operation is not UpdateOne, or the query to the
  2931. // database failed.
  2932. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2933. switch name {
  2934. case aliyunavatar.FieldCreatedAt:
  2935. return m.OldCreatedAt(ctx)
  2936. case aliyunavatar.FieldUpdatedAt:
  2937. return m.OldUpdatedAt(ctx)
  2938. case aliyunavatar.FieldDeletedAt:
  2939. return m.OldDeletedAt(ctx)
  2940. case aliyunavatar.FieldUserID:
  2941. return m.OldUserID(ctx)
  2942. case aliyunavatar.FieldBizID:
  2943. return m.OldBizID(ctx)
  2944. case aliyunavatar.FieldAccessKeyID:
  2945. return m.OldAccessKeyID(ctx)
  2946. case aliyunavatar.FieldAccessKeySecret:
  2947. return m.OldAccessKeySecret(ctx)
  2948. case aliyunavatar.FieldAppID:
  2949. return m.OldAppID(ctx)
  2950. case aliyunavatar.FieldTenantID:
  2951. return m.OldTenantID(ctx)
  2952. case aliyunavatar.FieldResponse:
  2953. return m.OldResponse(ctx)
  2954. case aliyunavatar.FieldToken:
  2955. return m.OldToken(ctx)
  2956. case aliyunavatar.FieldSessionID:
  2957. return m.OldSessionID(ctx)
  2958. }
  2959. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2960. }
  2961. // SetField sets the value of a field with the given name. It returns an error if
  2962. // the field is not defined in the schema, or if the type mismatched the field
  2963. // type.
  2964. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2965. switch name {
  2966. case aliyunavatar.FieldCreatedAt:
  2967. v, ok := value.(time.Time)
  2968. if !ok {
  2969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2970. }
  2971. m.SetCreatedAt(v)
  2972. return nil
  2973. case aliyunavatar.FieldUpdatedAt:
  2974. v, ok := value.(time.Time)
  2975. if !ok {
  2976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2977. }
  2978. m.SetUpdatedAt(v)
  2979. return nil
  2980. case aliyunavatar.FieldDeletedAt:
  2981. v, ok := value.(time.Time)
  2982. if !ok {
  2983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2984. }
  2985. m.SetDeletedAt(v)
  2986. return nil
  2987. case aliyunavatar.FieldUserID:
  2988. v, ok := value.(uint64)
  2989. if !ok {
  2990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2991. }
  2992. m.SetUserID(v)
  2993. return nil
  2994. case aliyunavatar.FieldBizID:
  2995. v, ok := value.(string)
  2996. if !ok {
  2997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2998. }
  2999. m.SetBizID(v)
  3000. return nil
  3001. case aliyunavatar.FieldAccessKeyID:
  3002. v, ok := value.(string)
  3003. if !ok {
  3004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3005. }
  3006. m.SetAccessKeyID(v)
  3007. return nil
  3008. case aliyunavatar.FieldAccessKeySecret:
  3009. v, ok := value.(string)
  3010. if !ok {
  3011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3012. }
  3013. m.SetAccessKeySecret(v)
  3014. return nil
  3015. case aliyunavatar.FieldAppID:
  3016. v, ok := value.(string)
  3017. if !ok {
  3018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3019. }
  3020. m.SetAppID(v)
  3021. return nil
  3022. case aliyunavatar.FieldTenantID:
  3023. v, ok := value.(uint64)
  3024. if !ok {
  3025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3026. }
  3027. m.SetTenantID(v)
  3028. return nil
  3029. case aliyunavatar.FieldResponse:
  3030. v, ok := value.(string)
  3031. if !ok {
  3032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3033. }
  3034. m.SetResponse(v)
  3035. return nil
  3036. case aliyunavatar.FieldToken:
  3037. v, ok := value.(string)
  3038. if !ok {
  3039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3040. }
  3041. m.SetToken(v)
  3042. return nil
  3043. case aliyunavatar.FieldSessionID:
  3044. v, ok := value.(string)
  3045. if !ok {
  3046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3047. }
  3048. m.SetSessionID(v)
  3049. return nil
  3050. }
  3051. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3052. }
  3053. // AddedFields returns all numeric fields that were incremented/decremented during
  3054. // this mutation.
  3055. func (m *AliyunAvatarMutation) AddedFields() []string {
  3056. var fields []string
  3057. if m.adduser_id != nil {
  3058. fields = append(fields, aliyunavatar.FieldUserID)
  3059. }
  3060. if m.addtenant_id != nil {
  3061. fields = append(fields, aliyunavatar.FieldTenantID)
  3062. }
  3063. return fields
  3064. }
  3065. // AddedField returns the numeric value that was incremented/decremented on a field
  3066. // with the given name. The second boolean return value indicates that this field
  3067. // was not set, or was not defined in the schema.
  3068. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3069. switch name {
  3070. case aliyunavatar.FieldUserID:
  3071. return m.AddedUserID()
  3072. case aliyunavatar.FieldTenantID:
  3073. return m.AddedTenantID()
  3074. }
  3075. return nil, false
  3076. }
  3077. // AddField adds the value to the field with the given name. It returns an error if
  3078. // the field is not defined in the schema, or if the type mismatched the field
  3079. // type.
  3080. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3081. switch name {
  3082. case aliyunavatar.FieldUserID:
  3083. v, ok := value.(int64)
  3084. if !ok {
  3085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3086. }
  3087. m.AddUserID(v)
  3088. return nil
  3089. case aliyunavatar.FieldTenantID:
  3090. v, ok := value.(int64)
  3091. if !ok {
  3092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3093. }
  3094. m.AddTenantID(v)
  3095. return nil
  3096. }
  3097. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3098. }
  3099. // ClearedFields returns all nullable fields that were cleared during this
  3100. // mutation.
  3101. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3102. var fields []string
  3103. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3104. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3105. }
  3106. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3107. fields = append(fields, aliyunavatar.FieldAppID)
  3108. }
  3109. return fields
  3110. }
  3111. // FieldCleared returns a boolean indicating if a field with the given name was
  3112. // cleared in this mutation.
  3113. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3114. _, ok := m.clearedFields[name]
  3115. return ok
  3116. }
  3117. // ClearField clears the value of the field with the given name. It returns an
  3118. // error if the field is not defined in the schema.
  3119. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3120. switch name {
  3121. case aliyunavatar.FieldDeletedAt:
  3122. m.ClearDeletedAt()
  3123. return nil
  3124. case aliyunavatar.FieldAppID:
  3125. m.ClearAppID()
  3126. return nil
  3127. }
  3128. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3129. }
  3130. // ResetField resets all changes in the mutation for the field with the given name.
  3131. // It returns an error if the field is not defined in the schema.
  3132. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3133. switch name {
  3134. case aliyunavatar.FieldCreatedAt:
  3135. m.ResetCreatedAt()
  3136. return nil
  3137. case aliyunavatar.FieldUpdatedAt:
  3138. m.ResetUpdatedAt()
  3139. return nil
  3140. case aliyunavatar.FieldDeletedAt:
  3141. m.ResetDeletedAt()
  3142. return nil
  3143. case aliyunavatar.FieldUserID:
  3144. m.ResetUserID()
  3145. return nil
  3146. case aliyunavatar.FieldBizID:
  3147. m.ResetBizID()
  3148. return nil
  3149. case aliyunavatar.FieldAccessKeyID:
  3150. m.ResetAccessKeyID()
  3151. return nil
  3152. case aliyunavatar.FieldAccessKeySecret:
  3153. m.ResetAccessKeySecret()
  3154. return nil
  3155. case aliyunavatar.FieldAppID:
  3156. m.ResetAppID()
  3157. return nil
  3158. case aliyunavatar.FieldTenantID:
  3159. m.ResetTenantID()
  3160. return nil
  3161. case aliyunavatar.FieldResponse:
  3162. m.ResetResponse()
  3163. return nil
  3164. case aliyunavatar.FieldToken:
  3165. m.ResetToken()
  3166. return nil
  3167. case aliyunavatar.FieldSessionID:
  3168. m.ResetSessionID()
  3169. return nil
  3170. }
  3171. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3172. }
  3173. // AddedEdges returns all edge names that were set/added in this mutation.
  3174. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3175. edges := make([]string, 0, 0)
  3176. return edges
  3177. }
  3178. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3179. // name in this mutation.
  3180. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3181. return nil
  3182. }
  3183. // RemovedEdges returns all edge names that were removed in this mutation.
  3184. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3185. edges := make([]string, 0, 0)
  3186. return edges
  3187. }
  3188. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3189. // the given name in this mutation.
  3190. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3191. return nil
  3192. }
  3193. // ClearedEdges returns all edge names that were cleared in this mutation.
  3194. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3195. edges := make([]string, 0, 0)
  3196. return edges
  3197. }
  3198. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3199. // was cleared in this mutation.
  3200. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3201. return false
  3202. }
  3203. // ClearEdge clears the value of the edge with the given name. It returns an error
  3204. // if that edge is not defined in the schema.
  3205. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3206. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3207. }
  3208. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3209. // It returns an error if the edge is not defined in the schema.
  3210. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3211. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3212. }
  3213. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3214. type AllocAgentMutation struct {
  3215. config
  3216. op Op
  3217. typ string
  3218. id *uint64
  3219. created_at *time.Time
  3220. updated_at *time.Time
  3221. deleted_at *time.Time
  3222. user_id *string
  3223. organization_id *uint64
  3224. addorganization_id *int64
  3225. agents *[]uint64
  3226. appendagents []uint64
  3227. status *int
  3228. addstatus *int
  3229. clearedFields map[string]struct{}
  3230. done bool
  3231. oldValue func(context.Context) (*AllocAgent, error)
  3232. predicates []predicate.AllocAgent
  3233. }
  3234. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3235. // allocagentOption allows management of the mutation configuration using functional options.
  3236. type allocagentOption func(*AllocAgentMutation)
  3237. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3238. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3239. m := &AllocAgentMutation{
  3240. config: c,
  3241. op: op,
  3242. typ: TypeAllocAgent,
  3243. clearedFields: make(map[string]struct{}),
  3244. }
  3245. for _, opt := range opts {
  3246. opt(m)
  3247. }
  3248. return m
  3249. }
  3250. // withAllocAgentID sets the ID field of the mutation.
  3251. func withAllocAgentID(id uint64) allocagentOption {
  3252. return func(m *AllocAgentMutation) {
  3253. var (
  3254. err error
  3255. once sync.Once
  3256. value *AllocAgent
  3257. )
  3258. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3259. once.Do(func() {
  3260. if m.done {
  3261. err = errors.New("querying old values post mutation is not allowed")
  3262. } else {
  3263. value, err = m.Client().AllocAgent.Get(ctx, id)
  3264. }
  3265. })
  3266. return value, err
  3267. }
  3268. m.id = &id
  3269. }
  3270. }
  3271. // withAllocAgent sets the old AllocAgent of the mutation.
  3272. func withAllocAgent(node *AllocAgent) allocagentOption {
  3273. return func(m *AllocAgentMutation) {
  3274. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3275. return node, nil
  3276. }
  3277. m.id = &node.ID
  3278. }
  3279. }
  3280. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3281. // executed in a transaction (ent.Tx), a transactional client is returned.
  3282. func (m AllocAgentMutation) Client() *Client {
  3283. client := &Client{config: m.config}
  3284. client.init()
  3285. return client
  3286. }
  3287. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3288. // it returns an error otherwise.
  3289. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3290. if _, ok := m.driver.(*txDriver); !ok {
  3291. return nil, errors.New("ent: mutation is not running in a transaction")
  3292. }
  3293. tx := &Tx{config: m.config}
  3294. tx.init()
  3295. return tx, nil
  3296. }
  3297. // SetID sets the value of the id field. Note that this
  3298. // operation is only accepted on creation of AllocAgent entities.
  3299. func (m *AllocAgentMutation) SetID(id uint64) {
  3300. m.id = &id
  3301. }
  3302. // ID returns the ID value in the mutation. Note that the ID is only available
  3303. // if it was provided to the builder or after it was returned from the database.
  3304. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3305. if m.id == nil {
  3306. return
  3307. }
  3308. return *m.id, true
  3309. }
  3310. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3311. // That means, if the mutation is applied within a transaction with an isolation level such
  3312. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3313. // or updated by the mutation.
  3314. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3315. switch {
  3316. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3317. id, exists := m.ID()
  3318. if exists {
  3319. return []uint64{id}, nil
  3320. }
  3321. fallthrough
  3322. case m.op.Is(OpUpdate | OpDelete):
  3323. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3324. default:
  3325. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3326. }
  3327. }
  3328. // SetCreatedAt sets the "created_at" field.
  3329. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3330. m.created_at = &t
  3331. }
  3332. // CreatedAt returns the value of the "created_at" field in the mutation.
  3333. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3334. v := m.created_at
  3335. if v == nil {
  3336. return
  3337. }
  3338. return *v, true
  3339. }
  3340. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3341. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3343. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3344. if !m.op.Is(OpUpdateOne) {
  3345. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3346. }
  3347. if m.id == nil || m.oldValue == nil {
  3348. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3349. }
  3350. oldValue, err := m.oldValue(ctx)
  3351. if err != nil {
  3352. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3353. }
  3354. return oldValue.CreatedAt, nil
  3355. }
  3356. // ResetCreatedAt resets all changes to the "created_at" field.
  3357. func (m *AllocAgentMutation) ResetCreatedAt() {
  3358. m.created_at = nil
  3359. }
  3360. // SetUpdatedAt sets the "updated_at" field.
  3361. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3362. m.updated_at = &t
  3363. }
  3364. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3365. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3366. v := m.updated_at
  3367. if v == nil {
  3368. return
  3369. }
  3370. return *v, true
  3371. }
  3372. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3373. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3375. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3376. if !m.op.Is(OpUpdateOne) {
  3377. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3378. }
  3379. if m.id == nil || m.oldValue == nil {
  3380. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3381. }
  3382. oldValue, err := m.oldValue(ctx)
  3383. if err != nil {
  3384. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3385. }
  3386. return oldValue.UpdatedAt, nil
  3387. }
  3388. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3389. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3390. m.updated_at = nil
  3391. }
  3392. // SetDeletedAt sets the "deleted_at" field.
  3393. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3394. m.deleted_at = &t
  3395. }
  3396. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3397. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3398. v := m.deleted_at
  3399. if v == nil {
  3400. return
  3401. }
  3402. return *v, true
  3403. }
  3404. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3405. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3407. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3408. if !m.op.Is(OpUpdateOne) {
  3409. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3410. }
  3411. if m.id == nil || m.oldValue == nil {
  3412. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3413. }
  3414. oldValue, err := m.oldValue(ctx)
  3415. if err != nil {
  3416. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3417. }
  3418. return oldValue.DeletedAt, nil
  3419. }
  3420. // ClearDeletedAt clears the value of the "deleted_at" field.
  3421. func (m *AllocAgentMutation) ClearDeletedAt() {
  3422. m.deleted_at = nil
  3423. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3424. }
  3425. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3426. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3427. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3428. return ok
  3429. }
  3430. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3431. func (m *AllocAgentMutation) ResetDeletedAt() {
  3432. m.deleted_at = nil
  3433. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3434. }
  3435. // SetUserID sets the "user_id" field.
  3436. func (m *AllocAgentMutation) SetUserID(s string) {
  3437. m.user_id = &s
  3438. }
  3439. // UserID returns the value of the "user_id" field in the mutation.
  3440. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3441. v := m.user_id
  3442. if v == nil {
  3443. return
  3444. }
  3445. return *v, true
  3446. }
  3447. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3448. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3450. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3451. if !m.op.Is(OpUpdateOne) {
  3452. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3453. }
  3454. if m.id == nil || m.oldValue == nil {
  3455. return v, errors.New("OldUserID requires an ID field in the mutation")
  3456. }
  3457. oldValue, err := m.oldValue(ctx)
  3458. if err != nil {
  3459. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3460. }
  3461. return oldValue.UserID, nil
  3462. }
  3463. // ClearUserID clears the value of the "user_id" field.
  3464. func (m *AllocAgentMutation) ClearUserID() {
  3465. m.user_id = nil
  3466. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3467. }
  3468. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3469. func (m *AllocAgentMutation) UserIDCleared() bool {
  3470. _, ok := m.clearedFields[allocagent.FieldUserID]
  3471. return ok
  3472. }
  3473. // ResetUserID resets all changes to the "user_id" field.
  3474. func (m *AllocAgentMutation) ResetUserID() {
  3475. m.user_id = nil
  3476. delete(m.clearedFields, allocagent.FieldUserID)
  3477. }
  3478. // SetOrganizationID sets the "organization_id" field.
  3479. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3480. m.organization_id = &u
  3481. m.addorganization_id = nil
  3482. }
  3483. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3484. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3485. v := m.organization_id
  3486. if v == nil {
  3487. return
  3488. }
  3489. return *v, true
  3490. }
  3491. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3492. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3494. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3495. if !m.op.Is(OpUpdateOne) {
  3496. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3497. }
  3498. if m.id == nil || m.oldValue == nil {
  3499. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3500. }
  3501. oldValue, err := m.oldValue(ctx)
  3502. if err != nil {
  3503. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3504. }
  3505. return oldValue.OrganizationID, nil
  3506. }
  3507. // AddOrganizationID adds u to the "organization_id" field.
  3508. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3509. if m.addorganization_id != nil {
  3510. *m.addorganization_id += u
  3511. } else {
  3512. m.addorganization_id = &u
  3513. }
  3514. }
  3515. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3516. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3517. v := m.addorganization_id
  3518. if v == nil {
  3519. return
  3520. }
  3521. return *v, true
  3522. }
  3523. // ClearOrganizationID clears the value of the "organization_id" field.
  3524. func (m *AllocAgentMutation) ClearOrganizationID() {
  3525. m.organization_id = nil
  3526. m.addorganization_id = nil
  3527. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3528. }
  3529. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3530. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3531. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3532. return ok
  3533. }
  3534. // ResetOrganizationID resets all changes to the "organization_id" field.
  3535. func (m *AllocAgentMutation) ResetOrganizationID() {
  3536. m.organization_id = nil
  3537. m.addorganization_id = nil
  3538. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3539. }
  3540. // SetAgents sets the "agents" field.
  3541. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3542. m.agents = &u
  3543. m.appendagents = nil
  3544. }
  3545. // Agents returns the value of the "agents" field in the mutation.
  3546. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3547. v := m.agents
  3548. if v == nil {
  3549. return
  3550. }
  3551. return *v, true
  3552. }
  3553. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3554. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3556. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3557. if !m.op.Is(OpUpdateOne) {
  3558. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3559. }
  3560. if m.id == nil || m.oldValue == nil {
  3561. return v, errors.New("OldAgents requires an ID field in the mutation")
  3562. }
  3563. oldValue, err := m.oldValue(ctx)
  3564. if err != nil {
  3565. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3566. }
  3567. return oldValue.Agents, nil
  3568. }
  3569. // AppendAgents adds u to the "agents" field.
  3570. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3571. m.appendagents = append(m.appendagents, u...)
  3572. }
  3573. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3574. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3575. if len(m.appendagents) == 0 {
  3576. return nil, false
  3577. }
  3578. return m.appendagents, true
  3579. }
  3580. // ResetAgents resets all changes to the "agents" field.
  3581. func (m *AllocAgentMutation) ResetAgents() {
  3582. m.agents = nil
  3583. m.appendagents = nil
  3584. }
  3585. // SetStatus sets the "status" field.
  3586. func (m *AllocAgentMutation) SetStatus(i int) {
  3587. m.status = &i
  3588. m.addstatus = nil
  3589. }
  3590. // Status returns the value of the "status" field in the mutation.
  3591. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3592. v := m.status
  3593. if v == nil {
  3594. return
  3595. }
  3596. return *v, true
  3597. }
  3598. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3599. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3601. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3602. if !m.op.Is(OpUpdateOne) {
  3603. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3604. }
  3605. if m.id == nil || m.oldValue == nil {
  3606. return v, errors.New("OldStatus requires an ID field in the mutation")
  3607. }
  3608. oldValue, err := m.oldValue(ctx)
  3609. if err != nil {
  3610. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3611. }
  3612. return oldValue.Status, nil
  3613. }
  3614. // AddStatus adds i to the "status" field.
  3615. func (m *AllocAgentMutation) AddStatus(i int) {
  3616. if m.addstatus != nil {
  3617. *m.addstatus += i
  3618. } else {
  3619. m.addstatus = &i
  3620. }
  3621. }
  3622. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3623. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3624. v := m.addstatus
  3625. if v == nil {
  3626. return
  3627. }
  3628. return *v, true
  3629. }
  3630. // ClearStatus clears the value of the "status" field.
  3631. func (m *AllocAgentMutation) ClearStatus() {
  3632. m.status = nil
  3633. m.addstatus = nil
  3634. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3635. }
  3636. // StatusCleared returns if the "status" field was cleared in this mutation.
  3637. func (m *AllocAgentMutation) StatusCleared() bool {
  3638. _, ok := m.clearedFields[allocagent.FieldStatus]
  3639. return ok
  3640. }
  3641. // ResetStatus resets all changes to the "status" field.
  3642. func (m *AllocAgentMutation) ResetStatus() {
  3643. m.status = nil
  3644. m.addstatus = nil
  3645. delete(m.clearedFields, allocagent.FieldStatus)
  3646. }
  3647. // Where appends a list predicates to the AllocAgentMutation builder.
  3648. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3649. m.predicates = append(m.predicates, ps...)
  3650. }
  3651. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3652. // users can use type-assertion to append predicates that do not depend on any generated package.
  3653. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3654. p := make([]predicate.AllocAgent, len(ps))
  3655. for i := range ps {
  3656. p[i] = ps[i]
  3657. }
  3658. m.Where(p...)
  3659. }
  3660. // Op returns the operation name.
  3661. func (m *AllocAgentMutation) Op() Op {
  3662. return m.op
  3663. }
  3664. // SetOp allows setting the mutation operation.
  3665. func (m *AllocAgentMutation) SetOp(op Op) {
  3666. m.op = op
  3667. }
  3668. // Type returns the node type of this mutation (AllocAgent).
  3669. func (m *AllocAgentMutation) Type() string {
  3670. return m.typ
  3671. }
  3672. // Fields returns all fields that were changed during this mutation. Note that in
  3673. // order to get all numeric fields that were incremented/decremented, call
  3674. // AddedFields().
  3675. func (m *AllocAgentMutation) Fields() []string {
  3676. fields := make([]string, 0, 7)
  3677. if m.created_at != nil {
  3678. fields = append(fields, allocagent.FieldCreatedAt)
  3679. }
  3680. if m.updated_at != nil {
  3681. fields = append(fields, allocagent.FieldUpdatedAt)
  3682. }
  3683. if m.deleted_at != nil {
  3684. fields = append(fields, allocagent.FieldDeletedAt)
  3685. }
  3686. if m.user_id != nil {
  3687. fields = append(fields, allocagent.FieldUserID)
  3688. }
  3689. if m.organization_id != nil {
  3690. fields = append(fields, allocagent.FieldOrganizationID)
  3691. }
  3692. if m.agents != nil {
  3693. fields = append(fields, allocagent.FieldAgents)
  3694. }
  3695. if m.status != nil {
  3696. fields = append(fields, allocagent.FieldStatus)
  3697. }
  3698. return fields
  3699. }
  3700. // Field returns the value of a field with the given name. The second boolean
  3701. // return value indicates that this field was not set, or was not defined in the
  3702. // schema.
  3703. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3704. switch name {
  3705. case allocagent.FieldCreatedAt:
  3706. return m.CreatedAt()
  3707. case allocagent.FieldUpdatedAt:
  3708. return m.UpdatedAt()
  3709. case allocagent.FieldDeletedAt:
  3710. return m.DeletedAt()
  3711. case allocagent.FieldUserID:
  3712. return m.UserID()
  3713. case allocagent.FieldOrganizationID:
  3714. return m.OrganizationID()
  3715. case allocagent.FieldAgents:
  3716. return m.Agents()
  3717. case allocagent.FieldStatus:
  3718. return m.Status()
  3719. }
  3720. return nil, false
  3721. }
  3722. // OldField returns the old value of the field from the database. An error is
  3723. // returned if the mutation operation is not UpdateOne, or the query to the
  3724. // database failed.
  3725. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3726. switch name {
  3727. case allocagent.FieldCreatedAt:
  3728. return m.OldCreatedAt(ctx)
  3729. case allocagent.FieldUpdatedAt:
  3730. return m.OldUpdatedAt(ctx)
  3731. case allocagent.FieldDeletedAt:
  3732. return m.OldDeletedAt(ctx)
  3733. case allocagent.FieldUserID:
  3734. return m.OldUserID(ctx)
  3735. case allocagent.FieldOrganizationID:
  3736. return m.OldOrganizationID(ctx)
  3737. case allocagent.FieldAgents:
  3738. return m.OldAgents(ctx)
  3739. case allocagent.FieldStatus:
  3740. return m.OldStatus(ctx)
  3741. }
  3742. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3743. }
  3744. // SetField sets the value of a field with the given name. It returns an error if
  3745. // the field is not defined in the schema, or if the type mismatched the field
  3746. // type.
  3747. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3748. switch name {
  3749. case allocagent.FieldCreatedAt:
  3750. v, ok := value.(time.Time)
  3751. if !ok {
  3752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3753. }
  3754. m.SetCreatedAt(v)
  3755. return nil
  3756. case allocagent.FieldUpdatedAt:
  3757. v, ok := value.(time.Time)
  3758. if !ok {
  3759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3760. }
  3761. m.SetUpdatedAt(v)
  3762. return nil
  3763. case allocagent.FieldDeletedAt:
  3764. v, ok := value.(time.Time)
  3765. if !ok {
  3766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3767. }
  3768. m.SetDeletedAt(v)
  3769. return nil
  3770. case allocagent.FieldUserID:
  3771. v, ok := value.(string)
  3772. if !ok {
  3773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3774. }
  3775. m.SetUserID(v)
  3776. return nil
  3777. case allocagent.FieldOrganizationID:
  3778. v, ok := value.(uint64)
  3779. if !ok {
  3780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3781. }
  3782. m.SetOrganizationID(v)
  3783. return nil
  3784. case allocagent.FieldAgents:
  3785. v, ok := value.([]uint64)
  3786. if !ok {
  3787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3788. }
  3789. m.SetAgents(v)
  3790. return nil
  3791. case allocagent.FieldStatus:
  3792. v, ok := value.(int)
  3793. if !ok {
  3794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3795. }
  3796. m.SetStatus(v)
  3797. return nil
  3798. }
  3799. return fmt.Errorf("unknown AllocAgent field %s", name)
  3800. }
  3801. // AddedFields returns all numeric fields that were incremented/decremented during
  3802. // this mutation.
  3803. func (m *AllocAgentMutation) AddedFields() []string {
  3804. var fields []string
  3805. if m.addorganization_id != nil {
  3806. fields = append(fields, allocagent.FieldOrganizationID)
  3807. }
  3808. if m.addstatus != nil {
  3809. fields = append(fields, allocagent.FieldStatus)
  3810. }
  3811. return fields
  3812. }
  3813. // AddedField returns the numeric value that was incremented/decremented on a field
  3814. // with the given name. The second boolean return value indicates that this field
  3815. // was not set, or was not defined in the schema.
  3816. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3817. switch name {
  3818. case allocagent.FieldOrganizationID:
  3819. return m.AddedOrganizationID()
  3820. case allocagent.FieldStatus:
  3821. return m.AddedStatus()
  3822. }
  3823. return nil, false
  3824. }
  3825. // AddField adds the value to the field with the given name. It returns an error if
  3826. // the field is not defined in the schema, or if the type mismatched the field
  3827. // type.
  3828. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3829. switch name {
  3830. case allocagent.FieldOrganizationID:
  3831. v, ok := value.(int64)
  3832. if !ok {
  3833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3834. }
  3835. m.AddOrganizationID(v)
  3836. return nil
  3837. case allocagent.FieldStatus:
  3838. v, ok := value.(int)
  3839. if !ok {
  3840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3841. }
  3842. m.AddStatus(v)
  3843. return nil
  3844. }
  3845. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3846. }
  3847. // ClearedFields returns all nullable fields that were cleared during this
  3848. // mutation.
  3849. func (m *AllocAgentMutation) ClearedFields() []string {
  3850. var fields []string
  3851. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3852. fields = append(fields, allocagent.FieldDeletedAt)
  3853. }
  3854. if m.FieldCleared(allocagent.FieldUserID) {
  3855. fields = append(fields, allocagent.FieldUserID)
  3856. }
  3857. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3858. fields = append(fields, allocagent.FieldOrganizationID)
  3859. }
  3860. if m.FieldCleared(allocagent.FieldStatus) {
  3861. fields = append(fields, allocagent.FieldStatus)
  3862. }
  3863. return fields
  3864. }
  3865. // FieldCleared returns a boolean indicating if a field with the given name was
  3866. // cleared in this mutation.
  3867. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3868. _, ok := m.clearedFields[name]
  3869. return ok
  3870. }
  3871. // ClearField clears the value of the field with the given name. It returns an
  3872. // error if the field is not defined in the schema.
  3873. func (m *AllocAgentMutation) ClearField(name string) error {
  3874. switch name {
  3875. case allocagent.FieldDeletedAt:
  3876. m.ClearDeletedAt()
  3877. return nil
  3878. case allocagent.FieldUserID:
  3879. m.ClearUserID()
  3880. return nil
  3881. case allocagent.FieldOrganizationID:
  3882. m.ClearOrganizationID()
  3883. return nil
  3884. case allocagent.FieldStatus:
  3885. m.ClearStatus()
  3886. return nil
  3887. }
  3888. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3889. }
  3890. // ResetField resets all changes in the mutation for the field with the given name.
  3891. // It returns an error if the field is not defined in the schema.
  3892. func (m *AllocAgentMutation) ResetField(name string) error {
  3893. switch name {
  3894. case allocagent.FieldCreatedAt:
  3895. m.ResetCreatedAt()
  3896. return nil
  3897. case allocagent.FieldUpdatedAt:
  3898. m.ResetUpdatedAt()
  3899. return nil
  3900. case allocagent.FieldDeletedAt:
  3901. m.ResetDeletedAt()
  3902. return nil
  3903. case allocagent.FieldUserID:
  3904. m.ResetUserID()
  3905. return nil
  3906. case allocagent.FieldOrganizationID:
  3907. m.ResetOrganizationID()
  3908. return nil
  3909. case allocagent.FieldAgents:
  3910. m.ResetAgents()
  3911. return nil
  3912. case allocagent.FieldStatus:
  3913. m.ResetStatus()
  3914. return nil
  3915. }
  3916. return fmt.Errorf("unknown AllocAgent field %s", name)
  3917. }
  3918. // AddedEdges returns all edge names that were set/added in this mutation.
  3919. func (m *AllocAgentMutation) AddedEdges() []string {
  3920. edges := make([]string, 0, 0)
  3921. return edges
  3922. }
  3923. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3924. // name in this mutation.
  3925. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3926. return nil
  3927. }
  3928. // RemovedEdges returns all edge names that were removed in this mutation.
  3929. func (m *AllocAgentMutation) RemovedEdges() []string {
  3930. edges := make([]string, 0, 0)
  3931. return edges
  3932. }
  3933. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3934. // the given name in this mutation.
  3935. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3936. return nil
  3937. }
  3938. // ClearedEdges returns all edge names that were cleared in this mutation.
  3939. func (m *AllocAgentMutation) ClearedEdges() []string {
  3940. edges := make([]string, 0, 0)
  3941. return edges
  3942. }
  3943. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3944. // was cleared in this mutation.
  3945. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3946. return false
  3947. }
  3948. // ClearEdge clears the value of the edge with the given name. It returns an error
  3949. // if that edge is not defined in the schema.
  3950. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3951. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3952. }
  3953. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3954. // It returns an error if the edge is not defined in the schema.
  3955. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3956. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3957. }
  3958. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3959. type BatchMsgMutation struct {
  3960. config
  3961. op Op
  3962. typ string
  3963. id *uint64
  3964. created_at *time.Time
  3965. updated_at *time.Time
  3966. deleted_at *time.Time
  3967. status *uint8
  3968. addstatus *int8
  3969. batch_no *string
  3970. task_name *string
  3971. fromwxid *string
  3972. msg *string
  3973. tag *string
  3974. tagids *string
  3975. total *int32
  3976. addtotal *int32
  3977. success *int32
  3978. addsuccess *int32
  3979. fail *int32
  3980. addfail *int32
  3981. start_time *time.Time
  3982. stop_time *time.Time
  3983. send_time *time.Time
  3984. _type *int32
  3985. add_type *int32
  3986. organization_id *uint64
  3987. addorganization_id *int64
  3988. clearedFields map[string]struct{}
  3989. done bool
  3990. oldValue func(context.Context) (*BatchMsg, error)
  3991. predicates []predicate.BatchMsg
  3992. }
  3993. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3994. // batchmsgOption allows management of the mutation configuration using functional options.
  3995. type batchmsgOption func(*BatchMsgMutation)
  3996. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3997. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3998. m := &BatchMsgMutation{
  3999. config: c,
  4000. op: op,
  4001. typ: TypeBatchMsg,
  4002. clearedFields: make(map[string]struct{}),
  4003. }
  4004. for _, opt := range opts {
  4005. opt(m)
  4006. }
  4007. return m
  4008. }
  4009. // withBatchMsgID sets the ID field of the mutation.
  4010. func withBatchMsgID(id uint64) batchmsgOption {
  4011. return func(m *BatchMsgMutation) {
  4012. var (
  4013. err error
  4014. once sync.Once
  4015. value *BatchMsg
  4016. )
  4017. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  4018. once.Do(func() {
  4019. if m.done {
  4020. err = errors.New("querying old values post mutation is not allowed")
  4021. } else {
  4022. value, err = m.Client().BatchMsg.Get(ctx, id)
  4023. }
  4024. })
  4025. return value, err
  4026. }
  4027. m.id = &id
  4028. }
  4029. }
  4030. // withBatchMsg sets the old BatchMsg of the mutation.
  4031. func withBatchMsg(node *BatchMsg) batchmsgOption {
  4032. return func(m *BatchMsgMutation) {
  4033. m.oldValue = func(context.Context) (*BatchMsg, error) {
  4034. return node, nil
  4035. }
  4036. m.id = &node.ID
  4037. }
  4038. }
  4039. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4040. // executed in a transaction (ent.Tx), a transactional client is returned.
  4041. func (m BatchMsgMutation) Client() *Client {
  4042. client := &Client{config: m.config}
  4043. client.init()
  4044. return client
  4045. }
  4046. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4047. // it returns an error otherwise.
  4048. func (m BatchMsgMutation) Tx() (*Tx, error) {
  4049. if _, ok := m.driver.(*txDriver); !ok {
  4050. return nil, errors.New("ent: mutation is not running in a transaction")
  4051. }
  4052. tx := &Tx{config: m.config}
  4053. tx.init()
  4054. return tx, nil
  4055. }
  4056. // SetID sets the value of the id field. Note that this
  4057. // operation is only accepted on creation of BatchMsg entities.
  4058. func (m *BatchMsgMutation) SetID(id uint64) {
  4059. m.id = &id
  4060. }
  4061. // ID returns the ID value in the mutation. Note that the ID is only available
  4062. // if it was provided to the builder or after it was returned from the database.
  4063. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  4064. if m.id == nil {
  4065. return
  4066. }
  4067. return *m.id, true
  4068. }
  4069. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4070. // That means, if the mutation is applied within a transaction with an isolation level such
  4071. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4072. // or updated by the mutation.
  4073. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  4074. switch {
  4075. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4076. id, exists := m.ID()
  4077. if exists {
  4078. return []uint64{id}, nil
  4079. }
  4080. fallthrough
  4081. case m.op.Is(OpUpdate | OpDelete):
  4082. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4083. default:
  4084. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4085. }
  4086. }
  4087. // SetCreatedAt sets the "created_at" field.
  4088. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4089. m.created_at = &t
  4090. }
  4091. // CreatedAt returns the value of the "created_at" field in the mutation.
  4092. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4093. v := m.created_at
  4094. if v == nil {
  4095. return
  4096. }
  4097. return *v, true
  4098. }
  4099. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4100. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4102. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4103. if !m.op.Is(OpUpdateOne) {
  4104. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4105. }
  4106. if m.id == nil || m.oldValue == nil {
  4107. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4108. }
  4109. oldValue, err := m.oldValue(ctx)
  4110. if err != nil {
  4111. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4112. }
  4113. return oldValue.CreatedAt, nil
  4114. }
  4115. // ResetCreatedAt resets all changes to the "created_at" field.
  4116. func (m *BatchMsgMutation) ResetCreatedAt() {
  4117. m.created_at = nil
  4118. }
  4119. // SetUpdatedAt sets the "updated_at" field.
  4120. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4121. m.updated_at = &t
  4122. }
  4123. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4124. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4125. v := m.updated_at
  4126. if v == nil {
  4127. return
  4128. }
  4129. return *v, true
  4130. }
  4131. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4132. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4134. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4135. if !m.op.Is(OpUpdateOne) {
  4136. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4137. }
  4138. if m.id == nil || m.oldValue == nil {
  4139. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4140. }
  4141. oldValue, err := m.oldValue(ctx)
  4142. if err != nil {
  4143. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4144. }
  4145. return oldValue.UpdatedAt, nil
  4146. }
  4147. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4148. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4149. m.updated_at = nil
  4150. }
  4151. // SetDeletedAt sets the "deleted_at" field.
  4152. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4153. m.deleted_at = &t
  4154. }
  4155. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4156. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4157. v := m.deleted_at
  4158. if v == nil {
  4159. return
  4160. }
  4161. return *v, true
  4162. }
  4163. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4164. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4166. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4167. if !m.op.Is(OpUpdateOne) {
  4168. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4169. }
  4170. if m.id == nil || m.oldValue == nil {
  4171. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4172. }
  4173. oldValue, err := m.oldValue(ctx)
  4174. if err != nil {
  4175. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4176. }
  4177. return oldValue.DeletedAt, nil
  4178. }
  4179. // ClearDeletedAt clears the value of the "deleted_at" field.
  4180. func (m *BatchMsgMutation) ClearDeletedAt() {
  4181. m.deleted_at = nil
  4182. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4183. }
  4184. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4185. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4186. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4187. return ok
  4188. }
  4189. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4190. func (m *BatchMsgMutation) ResetDeletedAt() {
  4191. m.deleted_at = nil
  4192. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4193. }
  4194. // SetStatus sets the "status" field.
  4195. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4196. m.status = &u
  4197. m.addstatus = nil
  4198. }
  4199. // Status returns the value of the "status" field in the mutation.
  4200. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4201. v := m.status
  4202. if v == nil {
  4203. return
  4204. }
  4205. return *v, true
  4206. }
  4207. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4208. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4210. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4211. if !m.op.Is(OpUpdateOne) {
  4212. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4213. }
  4214. if m.id == nil || m.oldValue == nil {
  4215. return v, errors.New("OldStatus requires an ID field in the mutation")
  4216. }
  4217. oldValue, err := m.oldValue(ctx)
  4218. if err != nil {
  4219. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4220. }
  4221. return oldValue.Status, nil
  4222. }
  4223. // AddStatus adds u to the "status" field.
  4224. func (m *BatchMsgMutation) AddStatus(u int8) {
  4225. if m.addstatus != nil {
  4226. *m.addstatus += u
  4227. } else {
  4228. m.addstatus = &u
  4229. }
  4230. }
  4231. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4232. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4233. v := m.addstatus
  4234. if v == nil {
  4235. return
  4236. }
  4237. return *v, true
  4238. }
  4239. // ClearStatus clears the value of the "status" field.
  4240. func (m *BatchMsgMutation) ClearStatus() {
  4241. m.status = nil
  4242. m.addstatus = nil
  4243. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4244. }
  4245. // StatusCleared returns if the "status" field was cleared in this mutation.
  4246. func (m *BatchMsgMutation) StatusCleared() bool {
  4247. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4248. return ok
  4249. }
  4250. // ResetStatus resets all changes to the "status" field.
  4251. func (m *BatchMsgMutation) ResetStatus() {
  4252. m.status = nil
  4253. m.addstatus = nil
  4254. delete(m.clearedFields, batchmsg.FieldStatus)
  4255. }
  4256. // SetBatchNo sets the "batch_no" field.
  4257. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4258. m.batch_no = &s
  4259. }
  4260. // BatchNo returns the value of the "batch_no" field in the mutation.
  4261. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4262. v := m.batch_no
  4263. if v == nil {
  4264. return
  4265. }
  4266. return *v, true
  4267. }
  4268. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4269. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4271. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4272. if !m.op.Is(OpUpdateOne) {
  4273. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4274. }
  4275. if m.id == nil || m.oldValue == nil {
  4276. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4277. }
  4278. oldValue, err := m.oldValue(ctx)
  4279. if err != nil {
  4280. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4281. }
  4282. return oldValue.BatchNo, nil
  4283. }
  4284. // ClearBatchNo clears the value of the "batch_no" field.
  4285. func (m *BatchMsgMutation) ClearBatchNo() {
  4286. m.batch_no = nil
  4287. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4288. }
  4289. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4290. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4291. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4292. return ok
  4293. }
  4294. // ResetBatchNo resets all changes to the "batch_no" field.
  4295. func (m *BatchMsgMutation) ResetBatchNo() {
  4296. m.batch_no = nil
  4297. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4298. }
  4299. // SetTaskName sets the "task_name" field.
  4300. func (m *BatchMsgMutation) SetTaskName(s string) {
  4301. m.task_name = &s
  4302. }
  4303. // TaskName returns the value of the "task_name" field in the mutation.
  4304. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4305. v := m.task_name
  4306. if v == nil {
  4307. return
  4308. }
  4309. return *v, true
  4310. }
  4311. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4312. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4314. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4315. if !m.op.Is(OpUpdateOne) {
  4316. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4317. }
  4318. if m.id == nil || m.oldValue == nil {
  4319. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4320. }
  4321. oldValue, err := m.oldValue(ctx)
  4322. if err != nil {
  4323. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4324. }
  4325. return oldValue.TaskName, nil
  4326. }
  4327. // ClearTaskName clears the value of the "task_name" field.
  4328. func (m *BatchMsgMutation) ClearTaskName() {
  4329. m.task_name = nil
  4330. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4331. }
  4332. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4333. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4334. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4335. return ok
  4336. }
  4337. // ResetTaskName resets all changes to the "task_name" field.
  4338. func (m *BatchMsgMutation) ResetTaskName() {
  4339. m.task_name = nil
  4340. delete(m.clearedFields, batchmsg.FieldTaskName)
  4341. }
  4342. // SetFromwxid sets the "fromwxid" field.
  4343. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4344. m.fromwxid = &s
  4345. }
  4346. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4347. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4348. v := m.fromwxid
  4349. if v == nil {
  4350. return
  4351. }
  4352. return *v, true
  4353. }
  4354. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4355. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4357. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4358. if !m.op.Is(OpUpdateOne) {
  4359. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4360. }
  4361. if m.id == nil || m.oldValue == nil {
  4362. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4363. }
  4364. oldValue, err := m.oldValue(ctx)
  4365. if err != nil {
  4366. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4367. }
  4368. return oldValue.Fromwxid, nil
  4369. }
  4370. // ClearFromwxid clears the value of the "fromwxid" field.
  4371. func (m *BatchMsgMutation) ClearFromwxid() {
  4372. m.fromwxid = nil
  4373. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4374. }
  4375. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4376. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4377. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4378. return ok
  4379. }
  4380. // ResetFromwxid resets all changes to the "fromwxid" field.
  4381. func (m *BatchMsgMutation) ResetFromwxid() {
  4382. m.fromwxid = nil
  4383. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4384. }
  4385. // SetMsg sets the "msg" field.
  4386. func (m *BatchMsgMutation) SetMsg(s string) {
  4387. m.msg = &s
  4388. }
  4389. // Msg returns the value of the "msg" field in the mutation.
  4390. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4391. v := m.msg
  4392. if v == nil {
  4393. return
  4394. }
  4395. return *v, true
  4396. }
  4397. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4398. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4400. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4401. if !m.op.Is(OpUpdateOne) {
  4402. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4403. }
  4404. if m.id == nil || m.oldValue == nil {
  4405. return v, errors.New("OldMsg requires an ID field in the mutation")
  4406. }
  4407. oldValue, err := m.oldValue(ctx)
  4408. if err != nil {
  4409. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4410. }
  4411. return oldValue.Msg, nil
  4412. }
  4413. // ClearMsg clears the value of the "msg" field.
  4414. func (m *BatchMsgMutation) ClearMsg() {
  4415. m.msg = nil
  4416. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4417. }
  4418. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4419. func (m *BatchMsgMutation) MsgCleared() bool {
  4420. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4421. return ok
  4422. }
  4423. // ResetMsg resets all changes to the "msg" field.
  4424. func (m *BatchMsgMutation) ResetMsg() {
  4425. m.msg = nil
  4426. delete(m.clearedFields, batchmsg.FieldMsg)
  4427. }
  4428. // SetTag sets the "tag" field.
  4429. func (m *BatchMsgMutation) SetTag(s string) {
  4430. m.tag = &s
  4431. }
  4432. // Tag returns the value of the "tag" field in the mutation.
  4433. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4434. v := m.tag
  4435. if v == nil {
  4436. return
  4437. }
  4438. return *v, true
  4439. }
  4440. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4441. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4443. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4444. if !m.op.Is(OpUpdateOne) {
  4445. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4446. }
  4447. if m.id == nil || m.oldValue == nil {
  4448. return v, errors.New("OldTag requires an ID field in the mutation")
  4449. }
  4450. oldValue, err := m.oldValue(ctx)
  4451. if err != nil {
  4452. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4453. }
  4454. return oldValue.Tag, nil
  4455. }
  4456. // ClearTag clears the value of the "tag" field.
  4457. func (m *BatchMsgMutation) ClearTag() {
  4458. m.tag = nil
  4459. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4460. }
  4461. // TagCleared returns if the "tag" field was cleared in this mutation.
  4462. func (m *BatchMsgMutation) TagCleared() bool {
  4463. _, ok := m.clearedFields[batchmsg.FieldTag]
  4464. return ok
  4465. }
  4466. // ResetTag resets all changes to the "tag" field.
  4467. func (m *BatchMsgMutation) ResetTag() {
  4468. m.tag = nil
  4469. delete(m.clearedFields, batchmsg.FieldTag)
  4470. }
  4471. // SetTagids sets the "tagids" field.
  4472. func (m *BatchMsgMutation) SetTagids(s string) {
  4473. m.tagids = &s
  4474. }
  4475. // Tagids returns the value of the "tagids" field in the mutation.
  4476. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4477. v := m.tagids
  4478. if v == nil {
  4479. return
  4480. }
  4481. return *v, true
  4482. }
  4483. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4484. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4486. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4487. if !m.op.Is(OpUpdateOne) {
  4488. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4489. }
  4490. if m.id == nil || m.oldValue == nil {
  4491. return v, errors.New("OldTagids requires an ID field in the mutation")
  4492. }
  4493. oldValue, err := m.oldValue(ctx)
  4494. if err != nil {
  4495. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4496. }
  4497. return oldValue.Tagids, nil
  4498. }
  4499. // ClearTagids clears the value of the "tagids" field.
  4500. func (m *BatchMsgMutation) ClearTagids() {
  4501. m.tagids = nil
  4502. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4503. }
  4504. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4505. func (m *BatchMsgMutation) TagidsCleared() bool {
  4506. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4507. return ok
  4508. }
  4509. // ResetTagids resets all changes to the "tagids" field.
  4510. func (m *BatchMsgMutation) ResetTagids() {
  4511. m.tagids = nil
  4512. delete(m.clearedFields, batchmsg.FieldTagids)
  4513. }
  4514. // SetTotal sets the "total" field.
  4515. func (m *BatchMsgMutation) SetTotal(i int32) {
  4516. m.total = &i
  4517. m.addtotal = nil
  4518. }
  4519. // Total returns the value of the "total" field in the mutation.
  4520. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4521. v := m.total
  4522. if v == nil {
  4523. return
  4524. }
  4525. return *v, true
  4526. }
  4527. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4528. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4530. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4531. if !m.op.Is(OpUpdateOne) {
  4532. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4533. }
  4534. if m.id == nil || m.oldValue == nil {
  4535. return v, errors.New("OldTotal requires an ID field in the mutation")
  4536. }
  4537. oldValue, err := m.oldValue(ctx)
  4538. if err != nil {
  4539. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4540. }
  4541. return oldValue.Total, nil
  4542. }
  4543. // AddTotal adds i to the "total" field.
  4544. func (m *BatchMsgMutation) AddTotal(i int32) {
  4545. if m.addtotal != nil {
  4546. *m.addtotal += i
  4547. } else {
  4548. m.addtotal = &i
  4549. }
  4550. }
  4551. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4552. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4553. v := m.addtotal
  4554. if v == nil {
  4555. return
  4556. }
  4557. return *v, true
  4558. }
  4559. // ClearTotal clears the value of the "total" field.
  4560. func (m *BatchMsgMutation) ClearTotal() {
  4561. m.total = nil
  4562. m.addtotal = nil
  4563. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4564. }
  4565. // TotalCleared returns if the "total" field was cleared in this mutation.
  4566. func (m *BatchMsgMutation) TotalCleared() bool {
  4567. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4568. return ok
  4569. }
  4570. // ResetTotal resets all changes to the "total" field.
  4571. func (m *BatchMsgMutation) ResetTotal() {
  4572. m.total = nil
  4573. m.addtotal = nil
  4574. delete(m.clearedFields, batchmsg.FieldTotal)
  4575. }
  4576. // SetSuccess sets the "success" field.
  4577. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4578. m.success = &i
  4579. m.addsuccess = nil
  4580. }
  4581. // Success returns the value of the "success" field in the mutation.
  4582. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4583. v := m.success
  4584. if v == nil {
  4585. return
  4586. }
  4587. return *v, true
  4588. }
  4589. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4590. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4592. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4593. if !m.op.Is(OpUpdateOne) {
  4594. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4595. }
  4596. if m.id == nil || m.oldValue == nil {
  4597. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4598. }
  4599. oldValue, err := m.oldValue(ctx)
  4600. if err != nil {
  4601. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4602. }
  4603. return oldValue.Success, nil
  4604. }
  4605. // AddSuccess adds i to the "success" field.
  4606. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4607. if m.addsuccess != nil {
  4608. *m.addsuccess += i
  4609. } else {
  4610. m.addsuccess = &i
  4611. }
  4612. }
  4613. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4614. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4615. v := m.addsuccess
  4616. if v == nil {
  4617. return
  4618. }
  4619. return *v, true
  4620. }
  4621. // ClearSuccess clears the value of the "success" field.
  4622. func (m *BatchMsgMutation) ClearSuccess() {
  4623. m.success = nil
  4624. m.addsuccess = nil
  4625. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4626. }
  4627. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4628. func (m *BatchMsgMutation) SuccessCleared() bool {
  4629. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4630. return ok
  4631. }
  4632. // ResetSuccess resets all changes to the "success" field.
  4633. func (m *BatchMsgMutation) ResetSuccess() {
  4634. m.success = nil
  4635. m.addsuccess = nil
  4636. delete(m.clearedFields, batchmsg.FieldSuccess)
  4637. }
  4638. // SetFail sets the "fail" field.
  4639. func (m *BatchMsgMutation) SetFail(i int32) {
  4640. m.fail = &i
  4641. m.addfail = nil
  4642. }
  4643. // Fail returns the value of the "fail" field in the mutation.
  4644. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4645. v := m.fail
  4646. if v == nil {
  4647. return
  4648. }
  4649. return *v, true
  4650. }
  4651. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4652. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4654. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4655. if !m.op.Is(OpUpdateOne) {
  4656. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4657. }
  4658. if m.id == nil || m.oldValue == nil {
  4659. return v, errors.New("OldFail requires an ID field in the mutation")
  4660. }
  4661. oldValue, err := m.oldValue(ctx)
  4662. if err != nil {
  4663. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4664. }
  4665. return oldValue.Fail, nil
  4666. }
  4667. // AddFail adds i to the "fail" field.
  4668. func (m *BatchMsgMutation) AddFail(i int32) {
  4669. if m.addfail != nil {
  4670. *m.addfail += i
  4671. } else {
  4672. m.addfail = &i
  4673. }
  4674. }
  4675. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4676. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4677. v := m.addfail
  4678. if v == nil {
  4679. return
  4680. }
  4681. return *v, true
  4682. }
  4683. // ClearFail clears the value of the "fail" field.
  4684. func (m *BatchMsgMutation) ClearFail() {
  4685. m.fail = nil
  4686. m.addfail = nil
  4687. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4688. }
  4689. // FailCleared returns if the "fail" field was cleared in this mutation.
  4690. func (m *BatchMsgMutation) FailCleared() bool {
  4691. _, ok := m.clearedFields[batchmsg.FieldFail]
  4692. return ok
  4693. }
  4694. // ResetFail resets all changes to the "fail" field.
  4695. func (m *BatchMsgMutation) ResetFail() {
  4696. m.fail = nil
  4697. m.addfail = nil
  4698. delete(m.clearedFields, batchmsg.FieldFail)
  4699. }
  4700. // SetStartTime sets the "start_time" field.
  4701. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4702. m.start_time = &t
  4703. }
  4704. // StartTime returns the value of the "start_time" field in the mutation.
  4705. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4706. v := m.start_time
  4707. if v == nil {
  4708. return
  4709. }
  4710. return *v, true
  4711. }
  4712. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4713. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4715. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4716. if !m.op.Is(OpUpdateOne) {
  4717. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4718. }
  4719. if m.id == nil || m.oldValue == nil {
  4720. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4721. }
  4722. oldValue, err := m.oldValue(ctx)
  4723. if err != nil {
  4724. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4725. }
  4726. return oldValue.StartTime, nil
  4727. }
  4728. // ClearStartTime clears the value of the "start_time" field.
  4729. func (m *BatchMsgMutation) ClearStartTime() {
  4730. m.start_time = nil
  4731. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4732. }
  4733. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4734. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4735. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4736. return ok
  4737. }
  4738. // ResetStartTime resets all changes to the "start_time" field.
  4739. func (m *BatchMsgMutation) ResetStartTime() {
  4740. m.start_time = nil
  4741. delete(m.clearedFields, batchmsg.FieldStartTime)
  4742. }
  4743. // SetStopTime sets the "stop_time" field.
  4744. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4745. m.stop_time = &t
  4746. }
  4747. // StopTime returns the value of the "stop_time" field in the mutation.
  4748. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4749. v := m.stop_time
  4750. if v == nil {
  4751. return
  4752. }
  4753. return *v, true
  4754. }
  4755. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4756. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4758. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4759. if !m.op.Is(OpUpdateOne) {
  4760. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4761. }
  4762. if m.id == nil || m.oldValue == nil {
  4763. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4764. }
  4765. oldValue, err := m.oldValue(ctx)
  4766. if err != nil {
  4767. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4768. }
  4769. return oldValue.StopTime, nil
  4770. }
  4771. // ClearStopTime clears the value of the "stop_time" field.
  4772. func (m *BatchMsgMutation) ClearStopTime() {
  4773. m.stop_time = nil
  4774. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4775. }
  4776. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4777. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4778. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4779. return ok
  4780. }
  4781. // ResetStopTime resets all changes to the "stop_time" field.
  4782. func (m *BatchMsgMutation) ResetStopTime() {
  4783. m.stop_time = nil
  4784. delete(m.clearedFields, batchmsg.FieldStopTime)
  4785. }
  4786. // SetSendTime sets the "send_time" field.
  4787. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4788. m.send_time = &t
  4789. }
  4790. // SendTime returns the value of the "send_time" field in the mutation.
  4791. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4792. v := m.send_time
  4793. if v == nil {
  4794. return
  4795. }
  4796. return *v, true
  4797. }
  4798. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4799. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4801. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4802. if !m.op.Is(OpUpdateOne) {
  4803. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4804. }
  4805. if m.id == nil || m.oldValue == nil {
  4806. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4807. }
  4808. oldValue, err := m.oldValue(ctx)
  4809. if err != nil {
  4810. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4811. }
  4812. return oldValue.SendTime, nil
  4813. }
  4814. // ClearSendTime clears the value of the "send_time" field.
  4815. func (m *BatchMsgMutation) ClearSendTime() {
  4816. m.send_time = nil
  4817. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4818. }
  4819. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4820. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4821. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4822. return ok
  4823. }
  4824. // ResetSendTime resets all changes to the "send_time" field.
  4825. func (m *BatchMsgMutation) ResetSendTime() {
  4826. m.send_time = nil
  4827. delete(m.clearedFields, batchmsg.FieldSendTime)
  4828. }
  4829. // SetType sets the "type" field.
  4830. func (m *BatchMsgMutation) SetType(i int32) {
  4831. m._type = &i
  4832. m.add_type = nil
  4833. }
  4834. // GetType returns the value of the "type" field in the mutation.
  4835. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4836. v := m._type
  4837. if v == nil {
  4838. return
  4839. }
  4840. return *v, true
  4841. }
  4842. // OldType returns the old "type" field's value of the BatchMsg entity.
  4843. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4845. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4846. if !m.op.Is(OpUpdateOne) {
  4847. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4848. }
  4849. if m.id == nil || m.oldValue == nil {
  4850. return v, errors.New("OldType requires an ID field in the mutation")
  4851. }
  4852. oldValue, err := m.oldValue(ctx)
  4853. if err != nil {
  4854. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4855. }
  4856. return oldValue.Type, nil
  4857. }
  4858. // AddType adds i to the "type" field.
  4859. func (m *BatchMsgMutation) AddType(i int32) {
  4860. if m.add_type != nil {
  4861. *m.add_type += i
  4862. } else {
  4863. m.add_type = &i
  4864. }
  4865. }
  4866. // AddedType returns the value that was added to the "type" field in this mutation.
  4867. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4868. v := m.add_type
  4869. if v == nil {
  4870. return
  4871. }
  4872. return *v, true
  4873. }
  4874. // ClearType clears the value of the "type" field.
  4875. func (m *BatchMsgMutation) ClearType() {
  4876. m._type = nil
  4877. m.add_type = nil
  4878. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4879. }
  4880. // TypeCleared returns if the "type" field was cleared in this mutation.
  4881. func (m *BatchMsgMutation) TypeCleared() bool {
  4882. _, ok := m.clearedFields[batchmsg.FieldType]
  4883. return ok
  4884. }
  4885. // ResetType resets all changes to the "type" field.
  4886. func (m *BatchMsgMutation) ResetType() {
  4887. m._type = nil
  4888. m.add_type = nil
  4889. delete(m.clearedFields, batchmsg.FieldType)
  4890. }
  4891. // SetOrganizationID sets the "organization_id" field.
  4892. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4893. m.organization_id = &u
  4894. m.addorganization_id = nil
  4895. }
  4896. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4897. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4898. v := m.organization_id
  4899. if v == nil {
  4900. return
  4901. }
  4902. return *v, true
  4903. }
  4904. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4905. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4907. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4908. if !m.op.Is(OpUpdateOne) {
  4909. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4910. }
  4911. if m.id == nil || m.oldValue == nil {
  4912. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4913. }
  4914. oldValue, err := m.oldValue(ctx)
  4915. if err != nil {
  4916. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4917. }
  4918. return oldValue.OrganizationID, nil
  4919. }
  4920. // AddOrganizationID adds u to the "organization_id" field.
  4921. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4922. if m.addorganization_id != nil {
  4923. *m.addorganization_id += u
  4924. } else {
  4925. m.addorganization_id = &u
  4926. }
  4927. }
  4928. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4929. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4930. v := m.addorganization_id
  4931. if v == nil {
  4932. return
  4933. }
  4934. return *v, true
  4935. }
  4936. // ResetOrganizationID resets all changes to the "organization_id" field.
  4937. func (m *BatchMsgMutation) ResetOrganizationID() {
  4938. m.organization_id = nil
  4939. m.addorganization_id = nil
  4940. }
  4941. // Where appends a list predicates to the BatchMsgMutation builder.
  4942. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4943. m.predicates = append(m.predicates, ps...)
  4944. }
  4945. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4946. // users can use type-assertion to append predicates that do not depend on any generated package.
  4947. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4948. p := make([]predicate.BatchMsg, len(ps))
  4949. for i := range ps {
  4950. p[i] = ps[i]
  4951. }
  4952. m.Where(p...)
  4953. }
  4954. // Op returns the operation name.
  4955. func (m *BatchMsgMutation) Op() Op {
  4956. return m.op
  4957. }
  4958. // SetOp allows setting the mutation operation.
  4959. func (m *BatchMsgMutation) SetOp(op Op) {
  4960. m.op = op
  4961. }
  4962. // Type returns the node type of this mutation (BatchMsg).
  4963. func (m *BatchMsgMutation) Type() string {
  4964. return m.typ
  4965. }
  4966. // Fields returns all fields that were changed during this mutation. Note that in
  4967. // order to get all numeric fields that were incremented/decremented, call
  4968. // AddedFields().
  4969. func (m *BatchMsgMutation) Fields() []string {
  4970. fields := make([]string, 0, 18)
  4971. if m.created_at != nil {
  4972. fields = append(fields, batchmsg.FieldCreatedAt)
  4973. }
  4974. if m.updated_at != nil {
  4975. fields = append(fields, batchmsg.FieldUpdatedAt)
  4976. }
  4977. if m.deleted_at != nil {
  4978. fields = append(fields, batchmsg.FieldDeletedAt)
  4979. }
  4980. if m.status != nil {
  4981. fields = append(fields, batchmsg.FieldStatus)
  4982. }
  4983. if m.batch_no != nil {
  4984. fields = append(fields, batchmsg.FieldBatchNo)
  4985. }
  4986. if m.task_name != nil {
  4987. fields = append(fields, batchmsg.FieldTaskName)
  4988. }
  4989. if m.fromwxid != nil {
  4990. fields = append(fields, batchmsg.FieldFromwxid)
  4991. }
  4992. if m.msg != nil {
  4993. fields = append(fields, batchmsg.FieldMsg)
  4994. }
  4995. if m.tag != nil {
  4996. fields = append(fields, batchmsg.FieldTag)
  4997. }
  4998. if m.tagids != nil {
  4999. fields = append(fields, batchmsg.FieldTagids)
  5000. }
  5001. if m.total != nil {
  5002. fields = append(fields, batchmsg.FieldTotal)
  5003. }
  5004. if m.success != nil {
  5005. fields = append(fields, batchmsg.FieldSuccess)
  5006. }
  5007. if m.fail != nil {
  5008. fields = append(fields, batchmsg.FieldFail)
  5009. }
  5010. if m.start_time != nil {
  5011. fields = append(fields, batchmsg.FieldStartTime)
  5012. }
  5013. if m.stop_time != nil {
  5014. fields = append(fields, batchmsg.FieldStopTime)
  5015. }
  5016. if m.send_time != nil {
  5017. fields = append(fields, batchmsg.FieldSendTime)
  5018. }
  5019. if m._type != nil {
  5020. fields = append(fields, batchmsg.FieldType)
  5021. }
  5022. if m.organization_id != nil {
  5023. fields = append(fields, batchmsg.FieldOrganizationID)
  5024. }
  5025. return fields
  5026. }
  5027. // Field returns the value of a field with the given name. The second boolean
  5028. // return value indicates that this field was not set, or was not defined in the
  5029. // schema.
  5030. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  5031. switch name {
  5032. case batchmsg.FieldCreatedAt:
  5033. return m.CreatedAt()
  5034. case batchmsg.FieldUpdatedAt:
  5035. return m.UpdatedAt()
  5036. case batchmsg.FieldDeletedAt:
  5037. return m.DeletedAt()
  5038. case batchmsg.FieldStatus:
  5039. return m.Status()
  5040. case batchmsg.FieldBatchNo:
  5041. return m.BatchNo()
  5042. case batchmsg.FieldTaskName:
  5043. return m.TaskName()
  5044. case batchmsg.FieldFromwxid:
  5045. return m.Fromwxid()
  5046. case batchmsg.FieldMsg:
  5047. return m.Msg()
  5048. case batchmsg.FieldTag:
  5049. return m.Tag()
  5050. case batchmsg.FieldTagids:
  5051. return m.Tagids()
  5052. case batchmsg.FieldTotal:
  5053. return m.Total()
  5054. case batchmsg.FieldSuccess:
  5055. return m.Success()
  5056. case batchmsg.FieldFail:
  5057. return m.Fail()
  5058. case batchmsg.FieldStartTime:
  5059. return m.StartTime()
  5060. case batchmsg.FieldStopTime:
  5061. return m.StopTime()
  5062. case batchmsg.FieldSendTime:
  5063. return m.SendTime()
  5064. case batchmsg.FieldType:
  5065. return m.GetType()
  5066. case batchmsg.FieldOrganizationID:
  5067. return m.OrganizationID()
  5068. }
  5069. return nil, false
  5070. }
  5071. // OldField returns the old value of the field from the database. An error is
  5072. // returned if the mutation operation is not UpdateOne, or the query to the
  5073. // database failed.
  5074. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5075. switch name {
  5076. case batchmsg.FieldCreatedAt:
  5077. return m.OldCreatedAt(ctx)
  5078. case batchmsg.FieldUpdatedAt:
  5079. return m.OldUpdatedAt(ctx)
  5080. case batchmsg.FieldDeletedAt:
  5081. return m.OldDeletedAt(ctx)
  5082. case batchmsg.FieldStatus:
  5083. return m.OldStatus(ctx)
  5084. case batchmsg.FieldBatchNo:
  5085. return m.OldBatchNo(ctx)
  5086. case batchmsg.FieldTaskName:
  5087. return m.OldTaskName(ctx)
  5088. case batchmsg.FieldFromwxid:
  5089. return m.OldFromwxid(ctx)
  5090. case batchmsg.FieldMsg:
  5091. return m.OldMsg(ctx)
  5092. case batchmsg.FieldTag:
  5093. return m.OldTag(ctx)
  5094. case batchmsg.FieldTagids:
  5095. return m.OldTagids(ctx)
  5096. case batchmsg.FieldTotal:
  5097. return m.OldTotal(ctx)
  5098. case batchmsg.FieldSuccess:
  5099. return m.OldSuccess(ctx)
  5100. case batchmsg.FieldFail:
  5101. return m.OldFail(ctx)
  5102. case batchmsg.FieldStartTime:
  5103. return m.OldStartTime(ctx)
  5104. case batchmsg.FieldStopTime:
  5105. return m.OldStopTime(ctx)
  5106. case batchmsg.FieldSendTime:
  5107. return m.OldSendTime(ctx)
  5108. case batchmsg.FieldType:
  5109. return m.OldType(ctx)
  5110. case batchmsg.FieldOrganizationID:
  5111. return m.OldOrganizationID(ctx)
  5112. }
  5113. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5114. }
  5115. // SetField sets the value of a field with the given name. It returns an error if
  5116. // the field is not defined in the schema, or if the type mismatched the field
  5117. // type.
  5118. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5119. switch name {
  5120. case batchmsg.FieldCreatedAt:
  5121. v, ok := value.(time.Time)
  5122. if !ok {
  5123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5124. }
  5125. m.SetCreatedAt(v)
  5126. return nil
  5127. case batchmsg.FieldUpdatedAt:
  5128. v, ok := value.(time.Time)
  5129. if !ok {
  5130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5131. }
  5132. m.SetUpdatedAt(v)
  5133. return nil
  5134. case batchmsg.FieldDeletedAt:
  5135. v, ok := value.(time.Time)
  5136. if !ok {
  5137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5138. }
  5139. m.SetDeletedAt(v)
  5140. return nil
  5141. case batchmsg.FieldStatus:
  5142. v, ok := value.(uint8)
  5143. if !ok {
  5144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5145. }
  5146. m.SetStatus(v)
  5147. return nil
  5148. case batchmsg.FieldBatchNo:
  5149. v, ok := value.(string)
  5150. if !ok {
  5151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5152. }
  5153. m.SetBatchNo(v)
  5154. return nil
  5155. case batchmsg.FieldTaskName:
  5156. v, ok := value.(string)
  5157. if !ok {
  5158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5159. }
  5160. m.SetTaskName(v)
  5161. return nil
  5162. case batchmsg.FieldFromwxid:
  5163. v, ok := value.(string)
  5164. if !ok {
  5165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5166. }
  5167. m.SetFromwxid(v)
  5168. return nil
  5169. case batchmsg.FieldMsg:
  5170. v, ok := value.(string)
  5171. if !ok {
  5172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5173. }
  5174. m.SetMsg(v)
  5175. return nil
  5176. case batchmsg.FieldTag:
  5177. v, ok := value.(string)
  5178. if !ok {
  5179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5180. }
  5181. m.SetTag(v)
  5182. return nil
  5183. case batchmsg.FieldTagids:
  5184. v, ok := value.(string)
  5185. if !ok {
  5186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5187. }
  5188. m.SetTagids(v)
  5189. return nil
  5190. case batchmsg.FieldTotal:
  5191. v, ok := value.(int32)
  5192. if !ok {
  5193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5194. }
  5195. m.SetTotal(v)
  5196. return nil
  5197. case batchmsg.FieldSuccess:
  5198. v, ok := value.(int32)
  5199. if !ok {
  5200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5201. }
  5202. m.SetSuccess(v)
  5203. return nil
  5204. case batchmsg.FieldFail:
  5205. v, ok := value.(int32)
  5206. if !ok {
  5207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5208. }
  5209. m.SetFail(v)
  5210. return nil
  5211. case batchmsg.FieldStartTime:
  5212. v, ok := value.(time.Time)
  5213. if !ok {
  5214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5215. }
  5216. m.SetStartTime(v)
  5217. return nil
  5218. case batchmsg.FieldStopTime:
  5219. v, ok := value.(time.Time)
  5220. if !ok {
  5221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5222. }
  5223. m.SetStopTime(v)
  5224. return nil
  5225. case batchmsg.FieldSendTime:
  5226. v, ok := value.(time.Time)
  5227. if !ok {
  5228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5229. }
  5230. m.SetSendTime(v)
  5231. return nil
  5232. case batchmsg.FieldType:
  5233. v, ok := value.(int32)
  5234. if !ok {
  5235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5236. }
  5237. m.SetType(v)
  5238. return nil
  5239. case batchmsg.FieldOrganizationID:
  5240. v, ok := value.(uint64)
  5241. if !ok {
  5242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5243. }
  5244. m.SetOrganizationID(v)
  5245. return nil
  5246. }
  5247. return fmt.Errorf("unknown BatchMsg field %s", name)
  5248. }
  5249. // AddedFields returns all numeric fields that were incremented/decremented during
  5250. // this mutation.
  5251. func (m *BatchMsgMutation) AddedFields() []string {
  5252. var fields []string
  5253. if m.addstatus != nil {
  5254. fields = append(fields, batchmsg.FieldStatus)
  5255. }
  5256. if m.addtotal != nil {
  5257. fields = append(fields, batchmsg.FieldTotal)
  5258. }
  5259. if m.addsuccess != nil {
  5260. fields = append(fields, batchmsg.FieldSuccess)
  5261. }
  5262. if m.addfail != nil {
  5263. fields = append(fields, batchmsg.FieldFail)
  5264. }
  5265. if m.add_type != nil {
  5266. fields = append(fields, batchmsg.FieldType)
  5267. }
  5268. if m.addorganization_id != nil {
  5269. fields = append(fields, batchmsg.FieldOrganizationID)
  5270. }
  5271. return fields
  5272. }
  5273. // AddedField returns the numeric value that was incremented/decremented on a field
  5274. // with the given name. The second boolean return value indicates that this field
  5275. // was not set, or was not defined in the schema.
  5276. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5277. switch name {
  5278. case batchmsg.FieldStatus:
  5279. return m.AddedStatus()
  5280. case batchmsg.FieldTotal:
  5281. return m.AddedTotal()
  5282. case batchmsg.FieldSuccess:
  5283. return m.AddedSuccess()
  5284. case batchmsg.FieldFail:
  5285. return m.AddedFail()
  5286. case batchmsg.FieldType:
  5287. return m.AddedType()
  5288. case batchmsg.FieldOrganizationID:
  5289. return m.AddedOrganizationID()
  5290. }
  5291. return nil, false
  5292. }
  5293. // AddField adds the value to the field with the given name. It returns an error if
  5294. // the field is not defined in the schema, or if the type mismatched the field
  5295. // type.
  5296. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5297. switch name {
  5298. case batchmsg.FieldStatus:
  5299. v, ok := value.(int8)
  5300. if !ok {
  5301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5302. }
  5303. m.AddStatus(v)
  5304. return nil
  5305. case batchmsg.FieldTotal:
  5306. v, ok := value.(int32)
  5307. if !ok {
  5308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5309. }
  5310. m.AddTotal(v)
  5311. return nil
  5312. case batchmsg.FieldSuccess:
  5313. v, ok := value.(int32)
  5314. if !ok {
  5315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5316. }
  5317. m.AddSuccess(v)
  5318. return nil
  5319. case batchmsg.FieldFail:
  5320. v, ok := value.(int32)
  5321. if !ok {
  5322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5323. }
  5324. m.AddFail(v)
  5325. return nil
  5326. case batchmsg.FieldType:
  5327. v, ok := value.(int32)
  5328. if !ok {
  5329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5330. }
  5331. m.AddType(v)
  5332. return nil
  5333. case batchmsg.FieldOrganizationID:
  5334. v, ok := value.(int64)
  5335. if !ok {
  5336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5337. }
  5338. m.AddOrganizationID(v)
  5339. return nil
  5340. }
  5341. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5342. }
  5343. // ClearedFields returns all nullable fields that were cleared during this
  5344. // mutation.
  5345. func (m *BatchMsgMutation) ClearedFields() []string {
  5346. var fields []string
  5347. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5348. fields = append(fields, batchmsg.FieldDeletedAt)
  5349. }
  5350. if m.FieldCleared(batchmsg.FieldStatus) {
  5351. fields = append(fields, batchmsg.FieldStatus)
  5352. }
  5353. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5354. fields = append(fields, batchmsg.FieldBatchNo)
  5355. }
  5356. if m.FieldCleared(batchmsg.FieldTaskName) {
  5357. fields = append(fields, batchmsg.FieldTaskName)
  5358. }
  5359. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5360. fields = append(fields, batchmsg.FieldFromwxid)
  5361. }
  5362. if m.FieldCleared(batchmsg.FieldMsg) {
  5363. fields = append(fields, batchmsg.FieldMsg)
  5364. }
  5365. if m.FieldCleared(batchmsg.FieldTag) {
  5366. fields = append(fields, batchmsg.FieldTag)
  5367. }
  5368. if m.FieldCleared(batchmsg.FieldTagids) {
  5369. fields = append(fields, batchmsg.FieldTagids)
  5370. }
  5371. if m.FieldCleared(batchmsg.FieldTotal) {
  5372. fields = append(fields, batchmsg.FieldTotal)
  5373. }
  5374. if m.FieldCleared(batchmsg.FieldSuccess) {
  5375. fields = append(fields, batchmsg.FieldSuccess)
  5376. }
  5377. if m.FieldCleared(batchmsg.FieldFail) {
  5378. fields = append(fields, batchmsg.FieldFail)
  5379. }
  5380. if m.FieldCleared(batchmsg.FieldStartTime) {
  5381. fields = append(fields, batchmsg.FieldStartTime)
  5382. }
  5383. if m.FieldCleared(batchmsg.FieldStopTime) {
  5384. fields = append(fields, batchmsg.FieldStopTime)
  5385. }
  5386. if m.FieldCleared(batchmsg.FieldSendTime) {
  5387. fields = append(fields, batchmsg.FieldSendTime)
  5388. }
  5389. if m.FieldCleared(batchmsg.FieldType) {
  5390. fields = append(fields, batchmsg.FieldType)
  5391. }
  5392. return fields
  5393. }
  5394. // FieldCleared returns a boolean indicating if a field with the given name was
  5395. // cleared in this mutation.
  5396. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5397. _, ok := m.clearedFields[name]
  5398. return ok
  5399. }
  5400. // ClearField clears the value of the field with the given name. It returns an
  5401. // error if the field is not defined in the schema.
  5402. func (m *BatchMsgMutation) ClearField(name string) error {
  5403. switch name {
  5404. case batchmsg.FieldDeletedAt:
  5405. m.ClearDeletedAt()
  5406. return nil
  5407. case batchmsg.FieldStatus:
  5408. m.ClearStatus()
  5409. return nil
  5410. case batchmsg.FieldBatchNo:
  5411. m.ClearBatchNo()
  5412. return nil
  5413. case batchmsg.FieldTaskName:
  5414. m.ClearTaskName()
  5415. return nil
  5416. case batchmsg.FieldFromwxid:
  5417. m.ClearFromwxid()
  5418. return nil
  5419. case batchmsg.FieldMsg:
  5420. m.ClearMsg()
  5421. return nil
  5422. case batchmsg.FieldTag:
  5423. m.ClearTag()
  5424. return nil
  5425. case batchmsg.FieldTagids:
  5426. m.ClearTagids()
  5427. return nil
  5428. case batchmsg.FieldTotal:
  5429. m.ClearTotal()
  5430. return nil
  5431. case batchmsg.FieldSuccess:
  5432. m.ClearSuccess()
  5433. return nil
  5434. case batchmsg.FieldFail:
  5435. m.ClearFail()
  5436. return nil
  5437. case batchmsg.FieldStartTime:
  5438. m.ClearStartTime()
  5439. return nil
  5440. case batchmsg.FieldStopTime:
  5441. m.ClearStopTime()
  5442. return nil
  5443. case batchmsg.FieldSendTime:
  5444. m.ClearSendTime()
  5445. return nil
  5446. case batchmsg.FieldType:
  5447. m.ClearType()
  5448. return nil
  5449. }
  5450. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5451. }
  5452. // ResetField resets all changes in the mutation for the field with the given name.
  5453. // It returns an error if the field is not defined in the schema.
  5454. func (m *BatchMsgMutation) ResetField(name string) error {
  5455. switch name {
  5456. case batchmsg.FieldCreatedAt:
  5457. m.ResetCreatedAt()
  5458. return nil
  5459. case batchmsg.FieldUpdatedAt:
  5460. m.ResetUpdatedAt()
  5461. return nil
  5462. case batchmsg.FieldDeletedAt:
  5463. m.ResetDeletedAt()
  5464. return nil
  5465. case batchmsg.FieldStatus:
  5466. m.ResetStatus()
  5467. return nil
  5468. case batchmsg.FieldBatchNo:
  5469. m.ResetBatchNo()
  5470. return nil
  5471. case batchmsg.FieldTaskName:
  5472. m.ResetTaskName()
  5473. return nil
  5474. case batchmsg.FieldFromwxid:
  5475. m.ResetFromwxid()
  5476. return nil
  5477. case batchmsg.FieldMsg:
  5478. m.ResetMsg()
  5479. return nil
  5480. case batchmsg.FieldTag:
  5481. m.ResetTag()
  5482. return nil
  5483. case batchmsg.FieldTagids:
  5484. m.ResetTagids()
  5485. return nil
  5486. case batchmsg.FieldTotal:
  5487. m.ResetTotal()
  5488. return nil
  5489. case batchmsg.FieldSuccess:
  5490. m.ResetSuccess()
  5491. return nil
  5492. case batchmsg.FieldFail:
  5493. m.ResetFail()
  5494. return nil
  5495. case batchmsg.FieldStartTime:
  5496. m.ResetStartTime()
  5497. return nil
  5498. case batchmsg.FieldStopTime:
  5499. m.ResetStopTime()
  5500. return nil
  5501. case batchmsg.FieldSendTime:
  5502. m.ResetSendTime()
  5503. return nil
  5504. case batchmsg.FieldType:
  5505. m.ResetType()
  5506. return nil
  5507. case batchmsg.FieldOrganizationID:
  5508. m.ResetOrganizationID()
  5509. return nil
  5510. }
  5511. return fmt.Errorf("unknown BatchMsg field %s", name)
  5512. }
  5513. // AddedEdges returns all edge names that were set/added in this mutation.
  5514. func (m *BatchMsgMutation) AddedEdges() []string {
  5515. edges := make([]string, 0, 0)
  5516. return edges
  5517. }
  5518. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5519. // name in this mutation.
  5520. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5521. return nil
  5522. }
  5523. // RemovedEdges returns all edge names that were removed in this mutation.
  5524. func (m *BatchMsgMutation) RemovedEdges() []string {
  5525. edges := make([]string, 0, 0)
  5526. return edges
  5527. }
  5528. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5529. // the given name in this mutation.
  5530. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5531. return nil
  5532. }
  5533. // ClearedEdges returns all edge names that were cleared in this mutation.
  5534. func (m *BatchMsgMutation) ClearedEdges() []string {
  5535. edges := make([]string, 0, 0)
  5536. return edges
  5537. }
  5538. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5539. // was cleared in this mutation.
  5540. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5541. return false
  5542. }
  5543. // ClearEdge clears the value of the edge with the given name. It returns an error
  5544. // if that edge is not defined in the schema.
  5545. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5546. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5547. }
  5548. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5549. // It returns an error if the edge is not defined in the schema.
  5550. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5551. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5552. }
  5553. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5554. type CategoryMutation struct {
  5555. config
  5556. op Op
  5557. typ string
  5558. id *uint64
  5559. created_at *time.Time
  5560. updated_at *time.Time
  5561. deleted_at *time.Time
  5562. name *string
  5563. organization_id *uint64
  5564. addorganization_id *int64
  5565. clearedFields map[string]struct{}
  5566. done bool
  5567. oldValue func(context.Context) (*Category, error)
  5568. predicates []predicate.Category
  5569. }
  5570. var _ ent.Mutation = (*CategoryMutation)(nil)
  5571. // categoryOption allows management of the mutation configuration using functional options.
  5572. type categoryOption func(*CategoryMutation)
  5573. // newCategoryMutation creates new mutation for the Category entity.
  5574. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5575. m := &CategoryMutation{
  5576. config: c,
  5577. op: op,
  5578. typ: TypeCategory,
  5579. clearedFields: make(map[string]struct{}),
  5580. }
  5581. for _, opt := range opts {
  5582. opt(m)
  5583. }
  5584. return m
  5585. }
  5586. // withCategoryID sets the ID field of the mutation.
  5587. func withCategoryID(id uint64) categoryOption {
  5588. return func(m *CategoryMutation) {
  5589. var (
  5590. err error
  5591. once sync.Once
  5592. value *Category
  5593. )
  5594. m.oldValue = func(ctx context.Context) (*Category, error) {
  5595. once.Do(func() {
  5596. if m.done {
  5597. err = errors.New("querying old values post mutation is not allowed")
  5598. } else {
  5599. value, err = m.Client().Category.Get(ctx, id)
  5600. }
  5601. })
  5602. return value, err
  5603. }
  5604. m.id = &id
  5605. }
  5606. }
  5607. // withCategory sets the old Category of the mutation.
  5608. func withCategory(node *Category) categoryOption {
  5609. return func(m *CategoryMutation) {
  5610. m.oldValue = func(context.Context) (*Category, error) {
  5611. return node, nil
  5612. }
  5613. m.id = &node.ID
  5614. }
  5615. }
  5616. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5617. // executed in a transaction (ent.Tx), a transactional client is returned.
  5618. func (m CategoryMutation) Client() *Client {
  5619. client := &Client{config: m.config}
  5620. client.init()
  5621. return client
  5622. }
  5623. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5624. // it returns an error otherwise.
  5625. func (m CategoryMutation) Tx() (*Tx, error) {
  5626. if _, ok := m.driver.(*txDriver); !ok {
  5627. return nil, errors.New("ent: mutation is not running in a transaction")
  5628. }
  5629. tx := &Tx{config: m.config}
  5630. tx.init()
  5631. return tx, nil
  5632. }
  5633. // SetID sets the value of the id field. Note that this
  5634. // operation is only accepted on creation of Category entities.
  5635. func (m *CategoryMutation) SetID(id uint64) {
  5636. m.id = &id
  5637. }
  5638. // ID returns the ID value in the mutation. Note that the ID is only available
  5639. // if it was provided to the builder or after it was returned from the database.
  5640. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5641. if m.id == nil {
  5642. return
  5643. }
  5644. return *m.id, true
  5645. }
  5646. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5647. // That means, if the mutation is applied within a transaction with an isolation level such
  5648. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5649. // or updated by the mutation.
  5650. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5651. switch {
  5652. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5653. id, exists := m.ID()
  5654. if exists {
  5655. return []uint64{id}, nil
  5656. }
  5657. fallthrough
  5658. case m.op.Is(OpUpdate | OpDelete):
  5659. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5660. default:
  5661. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5662. }
  5663. }
  5664. // SetCreatedAt sets the "created_at" field.
  5665. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5666. m.created_at = &t
  5667. }
  5668. // CreatedAt returns the value of the "created_at" field in the mutation.
  5669. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5670. v := m.created_at
  5671. if v == nil {
  5672. return
  5673. }
  5674. return *v, true
  5675. }
  5676. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5677. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5679. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5680. if !m.op.Is(OpUpdateOne) {
  5681. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5682. }
  5683. if m.id == nil || m.oldValue == nil {
  5684. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5685. }
  5686. oldValue, err := m.oldValue(ctx)
  5687. if err != nil {
  5688. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5689. }
  5690. return oldValue.CreatedAt, nil
  5691. }
  5692. // ResetCreatedAt resets all changes to the "created_at" field.
  5693. func (m *CategoryMutation) ResetCreatedAt() {
  5694. m.created_at = nil
  5695. }
  5696. // SetUpdatedAt sets the "updated_at" field.
  5697. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5698. m.updated_at = &t
  5699. }
  5700. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5701. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5702. v := m.updated_at
  5703. if v == nil {
  5704. return
  5705. }
  5706. return *v, true
  5707. }
  5708. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5709. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5711. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5712. if !m.op.Is(OpUpdateOne) {
  5713. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5714. }
  5715. if m.id == nil || m.oldValue == nil {
  5716. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5717. }
  5718. oldValue, err := m.oldValue(ctx)
  5719. if err != nil {
  5720. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5721. }
  5722. return oldValue.UpdatedAt, nil
  5723. }
  5724. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5725. func (m *CategoryMutation) ResetUpdatedAt() {
  5726. m.updated_at = nil
  5727. }
  5728. // SetDeletedAt sets the "deleted_at" field.
  5729. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5730. m.deleted_at = &t
  5731. }
  5732. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5733. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5734. v := m.deleted_at
  5735. if v == nil {
  5736. return
  5737. }
  5738. return *v, true
  5739. }
  5740. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5741. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5743. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5744. if !m.op.Is(OpUpdateOne) {
  5745. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5746. }
  5747. if m.id == nil || m.oldValue == nil {
  5748. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5749. }
  5750. oldValue, err := m.oldValue(ctx)
  5751. if err != nil {
  5752. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5753. }
  5754. return oldValue.DeletedAt, nil
  5755. }
  5756. // ClearDeletedAt clears the value of the "deleted_at" field.
  5757. func (m *CategoryMutation) ClearDeletedAt() {
  5758. m.deleted_at = nil
  5759. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5760. }
  5761. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5762. func (m *CategoryMutation) DeletedAtCleared() bool {
  5763. _, ok := m.clearedFields[category.FieldDeletedAt]
  5764. return ok
  5765. }
  5766. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5767. func (m *CategoryMutation) ResetDeletedAt() {
  5768. m.deleted_at = nil
  5769. delete(m.clearedFields, category.FieldDeletedAt)
  5770. }
  5771. // SetName sets the "name" field.
  5772. func (m *CategoryMutation) SetName(s string) {
  5773. m.name = &s
  5774. }
  5775. // Name returns the value of the "name" field in the mutation.
  5776. func (m *CategoryMutation) Name() (r string, exists bool) {
  5777. v := m.name
  5778. if v == nil {
  5779. return
  5780. }
  5781. return *v, true
  5782. }
  5783. // OldName returns the old "name" field's value of the Category entity.
  5784. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5786. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5787. if !m.op.Is(OpUpdateOne) {
  5788. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5789. }
  5790. if m.id == nil || m.oldValue == nil {
  5791. return v, errors.New("OldName requires an ID field in the mutation")
  5792. }
  5793. oldValue, err := m.oldValue(ctx)
  5794. if err != nil {
  5795. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5796. }
  5797. return oldValue.Name, nil
  5798. }
  5799. // ResetName resets all changes to the "name" field.
  5800. func (m *CategoryMutation) ResetName() {
  5801. m.name = nil
  5802. }
  5803. // SetOrganizationID sets the "organization_id" field.
  5804. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5805. m.organization_id = &u
  5806. m.addorganization_id = nil
  5807. }
  5808. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5809. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5810. v := m.organization_id
  5811. if v == nil {
  5812. return
  5813. }
  5814. return *v, true
  5815. }
  5816. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  5817. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5819. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5820. if !m.op.Is(OpUpdateOne) {
  5821. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5822. }
  5823. if m.id == nil || m.oldValue == nil {
  5824. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5825. }
  5826. oldValue, err := m.oldValue(ctx)
  5827. if err != nil {
  5828. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5829. }
  5830. return oldValue.OrganizationID, nil
  5831. }
  5832. // AddOrganizationID adds u to the "organization_id" field.
  5833. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5834. if m.addorganization_id != nil {
  5835. *m.addorganization_id += u
  5836. } else {
  5837. m.addorganization_id = &u
  5838. }
  5839. }
  5840. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5841. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5842. v := m.addorganization_id
  5843. if v == nil {
  5844. return
  5845. }
  5846. return *v, true
  5847. }
  5848. // ResetOrganizationID resets all changes to the "organization_id" field.
  5849. func (m *CategoryMutation) ResetOrganizationID() {
  5850. m.organization_id = nil
  5851. m.addorganization_id = nil
  5852. }
  5853. // Where appends a list predicates to the CategoryMutation builder.
  5854. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5855. m.predicates = append(m.predicates, ps...)
  5856. }
  5857. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5858. // users can use type-assertion to append predicates that do not depend on any generated package.
  5859. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5860. p := make([]predicate.Category, len(ps))
  5861. for i := range ps {
  5862. p[i] = ps[i]
  5863. }
  5864. m.Where(p...)
  5865. }
  5866. // Op returns the operation name.
  5867. func (m *CategoryMutation) Op() Op {
  5868. return m.op
  5869. }
  5870. // SetOp allows setting the mutation operation.
  5871. func (m *CategoryMutation) SetOp(op Op) {
  5872. m.op = op
  5873. }
  5874. // Type returns the node type of this mutation (Category).
  5875. func (m *CategoryMutation) Type() string {
  5876. return m.typ
  5877. }
  5878. // Fields returns all fields that were changed during this mutation. Note that in
  5879. // order to get all numeric fields that were incremented/decremented, call
  5880. // AddedFields().
  5881. func (m *CategoryMutation) Fields() []string {
  5882. fields := make([]string, 0, 5)
  5883. if m.created_at != nil {
  5884. fields = append(fields, category.FieldCreatedAt)
  5885. }
  5886. if m.updated_at != nil {
  5887. fields = append(fields, category.FieldUpdatedAt)
  5888. }
  5889. if m.deleted_at != nil {
  5890. fields = append(fields, category.FieldDeletedAt)
  5891. }
  5892. if m.name != nil {
  5893. fields = append(fields, category.FieldName)
  5894. }
  5895. if m.organization_id != nil {
  5896. fields = append(fields, category.FieldOrganizationID)
  5897. }
  5898. return fields
  5899. }
  5900. // Field returns the value of a field with the given name. The second boolean
  5901. // return value indicates that this field was not set, or was not defined in the
  5902. // schema.
  5903. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5904. switch name {
  5905. case category.FieldCreatedAt:
  5906. return m.CreatedAt()
  5907. case category.FieldUpdatedAt:
  5908. return m.UpdatedAt()
  5909. case category.FieldDeletedAt:
  5910. return m.DeletedAt()
  5911. case category.FieldName:
  5912. return m.Name()
  5913. case category.FieldOrganizationID:
  5914. return m.OrganizationID()
  5915. }
  5916. return nil, false
  5917. }
  5918. // OldField returns the old value of the field from the database. An error is
  5919. // returned if the mutation operation is not UpdateOne, or the query to the
  5920. // database failed.
  5921. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5922. switch name {
  5923. case category.FieldCreatedAt:
  5924. return m.OldCreatedAt(ctx)
  5925. case category.FieldUpdatedAt:
  5926. return m.OldUpdatedAt(ctx)
  5927. case category.FieldDeletedAt:
  5928. return m.OldDeletedAt(ctx)
  5929. case category.FieldName:
  5930. return m.OldName(ctx)
  5931. case category.FieldOrganizationID:
  5932. return m.OldOrganizationID(ctx)
  5933. }
  5934. return nil, fmt.Errorf("unknown Category field %s", name)
  5935. }
  5936. // SetField sets the value of a field with the given name. It returns an error if
  5937. // the field is not defined in the schema, or if the type mismatched the field
  5938. // type.
  5939. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5940. switch name {
  5941. case category.FieldCreatedAt:
  5942. v, ok := value.(time.Time)
  5943. if !ok {
  5944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5945. }
  5946. m.SetCreatedAt(v)
  5947. return nil
  5948. case category.FieldUpdatedAt:
  5949. v, ok := value.(time.Time)
  5950. if !ok {
  5951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5952. }
  5953. m.SetUpdatedAt(v)
  5954. return nil
  5955. case category.FieldDeletedAt:
  5956. v, ok := value.(time.Time)
  5957. if !ok {
  5958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5959. }
  5960. m.SetDeletedAt(v)
  5961. return nil
  5962. case category.FieldName:
  5963. v, ok := value.(string)
  5964. if !ok {
  5965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5966. }
  5967. m.SetName(v)
  5968. return nil
  5969. case category.FieldOrganizationID:
  5970. v, ok := value.(uint64)
  5971. if !ok {
  5972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5973. }
  5974. m.SetOrganizationID(v)
  5975. return nil
  5976. }
  5977. return fmt.Errorf("unknown Category field %s", name)
  5978. }
  5979. // AddedFields returns all numeric fields that were incremented/decremented during
  5980. // this mutation.
  5981. func (m *CategoryMutation) AddedFields() []string {
  5982. var fields []string
  5983. if m.addorganization_id != nil {
  5984. fields = append(fields, category.FieldOrganizationID)
  5985. }
  5986. return fields
  5987. }
  5988. // AddedField returns the numeric value that was incremented/decremented on a field
  5989. // with the given name. The second boolean return value indicates that this field
  5990. // was not set, or was not defined in the schema.
  5991. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5992. switch name {
  5993. case category.FieldOrganizationID:
  5994. return m.AddedOrganizationID()
  5995. }
  5996. return nil, false
  5997. }
  5998. // AddField adds the value to the field with the given name. It returns an error if
  5999. // the field is not defined in the schema, or if the type mismatched the field
  6000. // type.
  6001. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  6002. switch name {
  6003. case category.FieldOrganizationID:
  6004. v, ok := value.(int64)
  6005. if !ok {
  6006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6007. }
  6008. m.AddOrganizationID(v)
  6009. return nil
  6010. }
  6011. return fmt.Errorf("unknown Category numeric field %s", name)
  6012. }
  6013. // ClearedFields returns all nullable fields that were cleared during this
  6014. // mutation.
  6015. func (m *CategoryMutation) ClearedFields() []string {
  6016. var fields []string
  6017. if m.FieldCleared(category.FieldDeletedAt) {
  6018. fields = append(fields, category.FieldDeletedAt)
  6019. }
  6020. return fields
  6021. }
  6022. // FieldCleared returns a boolean indicating if a field with the given name was
  6023. // cleared in this mutation.
  6024. func (m *CategoryMutation) FieldCleared(name string) bool {
  6025. _, ok := m.clearedFields[name]
  6026. return ok
  6027. }
  6028. // ClearField clears the value of the field with the given name. It returns an
  6029. // error if the field is not defined in the schema.
  6030. func (m *CategoryMutation) ClearField(name string) error {
  6031. switch name {
  6032. case category.FieldDeletedAt:
  6033. m.ClearDeletedAt()
  6034. return nil
  6035. }
  6036. return fmt.Errorf("unknown Category nullable field %s", name)
  6037. }
  6038. // ResetField resets all changes in the mutation for the field with the given name.
  6039. // It returns an error if the field is not defined in the schema.
  6040. func (m *CategoryMutation) ResetField(name string) error {
  6041. switch name {
  6042. case category.FieldCreatedAt:
  6043. m.ResetCreatedAt()
  6044. return nil
  6045. case category.FieldUpdatedAt:
  6046. m.ResetUpdatedAt()
  6047. return nil
  6048. case category.FieldDeletedAt:
  6049. m.ResetDeletedAt()
  6050. return nil
  6051. case category.FieldName:
  6052. m.ResetName()
  6053. return nil
  6054. case category.FieldOrganizationID:
  6055. m.ResetOrganizationID()
  6056. return nil
  6057. }
  6058. return fmt.Errorf("unknown Category field %s", name)
  6059. }
  6060. // AddedEdges returns all edge names that were set/added in this mutation.
  6061. func (m *CategoryMutation) AddedEdges() []string {
  6062. edges := make([]string, 0, 0)
  6063. return edges
  6064. }
  6065. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6066. // name in this mutation.
  6067. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  6068. return nil
  6069. }
  6070. // RemovedEdges returns all edge names that were removed in this mutation.
  6071. func (m *CategoryMutation) RemovedEdges() []string {
  6072. edges := make([]string, 0, 0)
  6073. return edges
  6074. }
  6075. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6076. // the given name in this mutation.
  6077. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  6078. return nil
  6079. }
  6080. // ClearedEdges returns all edge names that were cleared in this mutation.
  6081. func (m *CategoryMutation) ClearedEdges() []string {
  6082. edges := make([]string, 0, 0)
  6083. return edges
  6084. }
  6085. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6086. // was cleared in this mutation.
  6087. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6088. return false
  6089. }
  6090. // ClearEdge clears the value of the edge with the given name. It returns an error
  6091. // if that edge is not defined in the schema.
  6092. func (m *CategoryMutation) ClearEdge(name string) error {
  6093. return fmt.Errorf("unknown Category unique edge %s", name)
  6094. }
  6095. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6096. // It returns an error if the edge is not defined in the schema.
  6097. func (m *CategoryMutation) ResetEdge(name string) error {
  6098. return fmt.Errorf("unknown Category edge %s", name)
  6099. }
  6100. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6101. type ChatRecordsMutation struct {
  6102. config
  6103. op Op
  6104. typ string
  6105. id *uint64
  6106. created_at *time.Time
  6107. updated_at *time.Time
  6108. deleted_at *time.Time
  6109. content *string
  6110. content_type *uint8
  6111. addcontent_type *int8
  6112. session_id *uint64
  6113. addsession_id *int64
  6114. user_id *uint64
  6115. adduser_id *int64
  6116. bot_id *uint64
  6117. addbot_id *int64
  6118. bot_type *uint8
  6119. addbot_type *int8
  6120. clearedFields map[string]struct{}
  6121. done bool
  6122. oldValue func(context.Context) (*ChatRecords, error)
  6123. predicates []predicate.ChatRecords
  6124. }
  6125. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6126. // chatrecordsOption allows management of the mutation configuration using functional options.
  6127. type chatrecordsOption func(*ChatRecordsMutation)
  6128. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6129. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6130. m := &ChatRecordsMutation{
  6131. config: c,
  6132. op: op,
  6133. typ: TypeChatRecords,
  6134. clearedFields: make(map[string]struct{}),
  6135. }
  6136. for _, opt := range opts {
  6137. opt(m)
  6138. }
  6139. return m
  6140. }
  6141. // withChatRecordsID sets the ID field of the mutation.
  6142. func withChatRecordsID(id uint64) chatrecordsOption {
  6143. return func(m *ChatRecordsMutation) {
  6144. var (
  6145. err error
  6146. once sync.Once
  6147. value *ChatRecords
  6148. )
  6149. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6150. once.Do(func() {
  6151. if m.done {
  6152. err = errors.New("querying old values post mutation is not allowed")
  6153. } else {
  6154. value, err = m.Client().ChatRecords.Get(ctx, id)
  6155. }
  6156. })
  6157. return value, err
  6158. }
  6159. m.id = &id
  6160. }
  6161. }
  6162. // withChatRecords sets the old ChatRecords of the mutation.
  6163. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6164. return func(m *ChatRecordsMutation) {
  6165. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6166. return node, nil
  6167. }
  6168. m.id = &node.ID
  6169. }
  6170. }
  6171. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6172. // executed in a transaction (ent.Tx), a transactional client is returned.
  6173. func (m ChatRecordsMutation) Client() *Client {
  6174. client := &Client{config: m.config}
  6175. client.init()
  6176. return client
  6177. }
  6178. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6179. // it returns an error otherwise.
  6180. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6181. if _, ok := m.driver.(*txDriver); !ok {
  6182. return nil, errors.New("ent: mutation is not running in a transaction")
  6183. }
  6184. tx := &Tx{config: m.config}
  6185. tx.init()
  6186. return tx, nil
  6187. }
  6188. // SetID sets the value of the id field. Note that this
  6189. // operation is only accepted on creation of ChatRecords entities.
  6190. func (m *ChatRecordsMutation) SetID(id uint64) {
  6191. m.id = &id
  6192. }
  6193. // ID returns the ID value in the mutation. Note that the ID is only available
  6194. // if it was provided to the builder or after it was returned from the database.
  6195. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6196. if m.id == nil {
  6197. return
  6198. }
  6199. return *m.id, true
  6200. }
  6201. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6202. // That means, if the mutation is applied within a transaction with an isolation level such
  6203. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6204. // or updated by the mutation.
  6205. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6206. switch {
  6207. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6208. id, exists := m.ID()
  6209. if exists {
  6210. return []uint64{id}, nil
  6211. }
  6212. fallthrough
  6213. case m.op.Is(OpUpdate | OpDelete):
  6214. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6215. default:
  6216. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6217. }
  6218. }
  6219. // SetCreatedAt sets the "created_at" field.
  6220. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6221. m.created_at = &t
  6222. }
  6223. // CreatedAt returns the value of the "created_at" field in the mutation.
  6224. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6225. v := m.created_at
  6226. if v == nil {
  6227. return
  6228. }
  6229. return *v, true
  6230. }
  6231. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6232. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6234. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6235. if !m.op.Is(OpUpdateOne) {
  6236. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6237. }
  6238. if m.id == nil || m.oldValue == nil {
  6239. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6240. }
  6241. oldValue, err := m.oldValue(ctx)
  6242. if err != nil {
  6243. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6244. }
  6245. return oldValue.CreatedAt, nil
  6246. }
  6247. // ResetCreatedAt resets all changes to the "created_at" field.
  6248. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6249. m.created_at = nil
  6250. }
  6251. // SetUpdatedAt sets the "updated_at" field.
  6252. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6253. m.updated_at = &t
  6254. }
  6255. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6256. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6257. v := m.updated_at
  6258. if v == nil {
  6259. return
  6260. }
  6261. return *v, true
  6262. }
  6263. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6264. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6266. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6267. if !m.op.Is(OpUpdateOne) {
  6268. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6269. }
  6270. if m.id == nil || m.oldValue == nil {
  6271. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6272. }
  6273. oldValue, err := m.oldValue(ctx)
  6274. if err != nil {
  6275. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6276. }
  6277. return oldValue.UpdatedAt, nil
  6278. }
  6279. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6280. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6281. m.updated_at = nil
  6282. }
  6283. // SetDeletedAt sets the "deleted_at" field.
  6284. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6285. m.deleted_at = &t
  6286. }
  6287. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6288. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6289. v := m.deleted_at
  6290. if v == nil {
  6291. return
  6292. }
  6293. return *v, true
  6294. }
  6295. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6296. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6298. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6299. if !m.op.Is(OpUpdateOne) {
  6300. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6301. }
  6302. if m.id == nil || m.oldValue == nil {
  6303. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6304. }
  6305. oldValue, err := m.oldValue(ctx)
  6306. if err != nil {
  6307. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6308. }
  6309. return oldValue.DeletedAt, nil
  6310. }
  6311. // ClearDeletedAt clears the value of the "deleted_at" field.
  6312. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6313. m.deleted_at = nil
  6314. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6315. }
  6316. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6317. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6318. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6319. return ok
  6320. }
  6321. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6322. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6323. m.deleted_at = nil
  6324. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6325. }
  6326. // SetContent sets the "content" field.
  6327. func (m *ChatRecordsMutation) SetContent(s string) {
  6328. m.content = &s
  6329. }
  6330. // Content returns the value of the "content" field in the mutation.
  6331. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6332. v := m.content
  6333. if v == nil {
  6334. return
  6335. }
  6336. return *v, true
  6337. }
  6338. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6339. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6341. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6342. if !m.op.Is(OpUpdateOne) {
  6343. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6344. }
  6345. if m.id == nil || m.oldValue == nil {
  6346. return v, errors.New("OldContent requires an ID field in the mutation")
  6347. }
  6348. oldValue, err := m.oldValue(ctx)
  6349. if err != nil {
  6350. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6351. }
  6352. return oldValue.Content, nil
  6353. }
  6354. // ResetContent resets all changes to the "content" field.
  6355. func (m *ChatRecordsMutation) ResetContent() {
  6356. m.content = nil
  6357. }
  6358. // SetContentType sets the "content_type" field.
  6359. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6360. m.content_type = &u
  6361. m.addcontent_type = nil
  6362. }
  6363. // ContentType returns the value of the "content_type" field in the mutation.
  6364. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6365. v := m.content_type
  6366. if v == nil {
  6367. return
  6368. }
  6369. return *v, true
  6370. }
  6371. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6372. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6374. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6375. if !m.op.Is(OpUpdateOne) {
  6376. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6377. }
  6378. if m.id == nil || m.oldValue == nil {
  6379. return v, errors.New("OldContentType requires an ID field in the mutation")
  6380. }
  6381. oldValue, err := m.oldValue(ctx)
  6382. if err != nil {
  6383. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6384. }
  6385. return oldValue.ContentType, nil
  6386. }
  6387. // AddContentType adds u to the "content_type" field.
  6388. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6389. if m.addcontent_type != nil {
  6390. *m.addcontent_type += u
  6391. } else {
  6392. m.addcontent_type = &u
  6393. }
  6394. }
  6395. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6396. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6397. v := m.addcontent_type
  6398. if v == nil {
  6399. return
  6400. }
  6401. return *v, true
  6402. }
  6403. // ResetContentType resets all changes to the "content_type" field.
  6404. func (m *ChatRecordsMutation) ResetContentType() {
  6405. m.content_type = nil
  6406. m.addcontent_type = nil
  6407. }
  6408. // SetSessionID sets the "session_id" field.
  6409. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6410. m.session_id = &u
  6411. m.addsession_id = nil
  6412. }
  6413. // SessionID returns the value of the "session_id" field in the mutation.
  6414. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6415. v := m.session_id
  6416. if v == nil {
  6417. return
  6418. }
  6419. return *v, true
  6420. }
  6421. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6422. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6424. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6425. if !m.op.Is(OpUpdateOne) {
  6426. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6427. }
  6428. if m.id == nil || m.oldValue == nil {
  6429. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6430. }
  6431. oldValue, err := m.oldValue(ctx)
  6432. if err != nil {
  6433. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6434. }
  6435. return oldValue.SessionID, nil
  6436. }
  6437. // AddSessionID adds u to the "session_id" field.
  6438. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6439. if m.addsession_id != nil {
  6440. *m.addsession_id += u
  6441. } else {
  6442. m.addsession_id = &u
  6443. }
  6444. }
  6445. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6446. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6447. v := m.addsession_id
  6448. if v == nil {
  6449. return
  6450. }
  6451. return *v, true
  6452. }
  6453. // ResetSessionID resets all changes to the "session_id" field.
  6454. func (m *ChatRecordsMutation) ResetSessionID() {
  6455. m.session_id = nil
  6456. m.addsession_id = nil
  6457. }
  6458. // SetUserID sets the "user_id" field.
  6459. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6460. m.user_id = &u
  6461. m.adduser_id = nil
  6462. }
  6463. // UserID returns the value of the "user_id" field in the mutation.
  6464. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6465. v := m.user_id
  6466. if v == nil {
  6467. return
  6468. }
  6469. return *v, true
  6470. }
  6471. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6472. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6474. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6475. if !m.op.Is(OpUpdateOne) {
  6476. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6477. }
  6478. if m.id == nil || m.oldValue == nil {
  6479. return v, errors.New("OldUserID requires an ID field in the mutation")
  6480. }
  6481. oldValue, err := m.oldValue(ctx)
  6482. if err != nil {
  6483. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6484. }
  6485. return oldValue.UserID, nil
  6486. }
  6487. // AddUserID adds u to the "user_id" field.
  6488. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6489. if m.adduser_id != nil {
  6490. *m.adduser_id += u
  6491. } else {
  6492. m.adduser_id = &u
  6493. }
  6494. }
  6495. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6496. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6497. v := m.adduser_id
  6498. if v == nil {
  6499. return
  6500. }
  6501. return *v, true
  6502. }
  6503. // ResetUserID resets all changes to the "user_id" field.
  6504. func (m *ChatRecordsMutation) ResetUserID() {
  6505. m.user_id = nil
  6506. m.adduser_id = nil
  6507. }
  6508. // SetBotID sets the "bot_id" field.
  6509. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6510. m.bot_id = &u
  6511. m.addbot_id = nil
  6512. }
  6513. // BotID returns the value of the "bot_id" field in the mutation.
  6514. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6515. v := m.bot_id
  6516. if v == nil {
  6517. return
  6518. }
  6519. return *v, true
  6520. }
  6521. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6522. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6524. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6525. if !m.op.Is(OpUpdateOne) {
  6526. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6527. }
  6528. if m.id == nil || m.oldValue == nil {
  6529. return v, errors.New("OldBotID requires an ID field in the mutation")
  6530. }
  6531. oldValue, err := m.oldValue(ctx)
  6532. if err != nil {
  6533. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6534. }
  6535. return oldValue.BotID, nil
  6536. }
  6537. // AddBotID adds u to the "bot_id" field.
  6538. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6539. if m.addbot_id != nil {
  6540. *m.addbot_id += u
  6541. } else {
  6542. m.addbot_id = &u
  6543. }
  6544. }
  6545. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6546. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6547. v := m.addbot_id
  6548. if v == nil {
  6549. return
  6550. }
  6551. return *v, true
  6552. }
  6553. // ResetBotID resets all changes to the "bot_id" field.
  6554. func (m *ChatRecordsMutation) ResetBotID() {
  6555. m.bot_id = nil
  6556. m.addbot_id = nil
  6557. }
  6558. // SetBotType sets the "bot_type" field.
  6559. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6560. m.bot_type = &u
  6561. m.addbot_type = nil
  6562. }
  6563. // BotType returns the value of the "bot_type" field in the mutation.
  6564. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6565. v := m.bot_type
  6566. if v == nil {
  6567. return
  6568. }
  6569. return *v, true
  6570. }
  6571. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6572. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6574. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6575. if !m.op.Is(OpUpdateOne) {
  6576. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6577. }
  6578. if m.id == nil || m.oldValue == nil {
  6579. return v, errors.New("OldBotType requires an ID field in the mutation")
  6580. }
  6581. oldValue, err := m.oldValue(ctx)
  6582. if err != nil {
  6583. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6584. }
  6585. return oldValue.BotType, nil
  6586. }
  6587. // AddBotType adds u to the "bot_type" field.
  6588. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6589. if m.addbot_type != nil {
  6590. *m.addbot_type += u
  6591. } else {
  6592. m.addbot_type = &u
  6593. }
  6594. }
  6595. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6596. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6597. v := m.addbot_type
  6598. if v == nil {
  6599. return
  6600. }
  6601. return *v, true
  6602. }
  6603. // ResetBotType resets all changes to the "bot_type" field.
  6604. func (m *ChatRecordsMutation) ResetBotType() {
  6605. m.bot_type = nil
  6606. m.addbot_type = nil
  6607. }
  6608. // Where appends a list predicates to the ChatRecordsMutation builder.
  6609. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6610. m.predicates = append(m.predicates, ps...)
  6611. }
  6612. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6613. // users can use type-assertion to append predicates that do not depend on any generated package.
  6614. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6615. p := make([]predicate.ChatRecords, len(ps))
  6616. for i := range ps {
  6617. p[i] = ps[i]
  6618. }
  6619. m.Where(p...)
  6620. }
  6621. // Op returns the operation name.
  6622. func (m *ChatRecordsMutation) Op() Op {
  6623. return m.op
  6624. }
  6625. // SetOp allows setting the mutation operation.
  6626. func (m *ChatRecordsMutation) SetOp(op Op) {
  6627. m.op = op
  6628. }
  6629. // Type returns the node type of this mutation (ChatRecords).
  6630. func (m *ChatRecordsMutation) Type() string {
  6631. return m.typ
  6632. }
  6633. // Fields returns all fields that were changed during this mutation. Note that in
  6634. // order to get all numeric fields that were incremented/decremented, call
  6635. // AddedFields().
  6636. func (m *ChatRecordsMutation) Fields() []string {
  6637. fields := make([]string, 0, 9)
  6638. if m.created_at != nil {
  6639. fields = append(fields, chatrecords.FieldCreatedAt)
  6640. }
  6641. if m.updated_at != nil {
  6642. fields = append(fields, chatrecords.FieldUpdatedAt)
  6643. }
  6644. if m.deleted_at != nil {
  6645. fields = append(fields, chatrecords.FieldDeletedAt)
  6646. }
  6647. if m.content != nil {
  6648. fields = append(fields, chatrecords.FieldContent)
  6649. }
  6650. if m.content_type != nil {
  6651. fields = append(fields, chatrecords.FieldContentType)
  6652. }
  6653. if m.session_id != nil {
  6654. fields = append(fields, chatrecords.FieldSessionID)
  6655. }
  6656. if m.user_id != nil {
  6657. fields = append(fields, chatrecords.FieldUserID)
  6658. }
  6659. if m.bot_id != nil {
  6660. fields = append(fields, chatrecords.FieldBotID)
  6661. }
  6662. if m.bot_type != nil {
  6663. fields = append(fields, chatrecords.FieldBotType)
  6664. }
  6665. return fields
  6666. }
  6667. // Field returns the value of a field with the given name. The second boolean
  6668. // return value indicates that this field was not set, or was not defined in the
  6669. // schema.
  6670. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6671. switch name {
  6672. case chatrecords.FieldCreatedAt:
  6673. return m.CreatedAt()
  6674. case chatrecords.FieldUpdatedAt:
  6675. return m.UpdatedAt()
  6676. case chatrecords.FieldDeletedAt:
  6677. return m.DeletedAt()
  6678. case chatrecords.FieldContent:
  6679. return m.Content()
  6680. case chatrecords.FieldContentType:
  6681. return m.ContentType()
  6682. case chatrecords.FieldSessionID:
  6683. return m.SessionID()
  6684. case chatrecords.FieldUserID:
  6685. return m.UserID()
  6686. case chatrecords.FieldBotID:
  6687. return m.BotID()
  6688. case chatrecords.FieldBotType:
  6689. return m.BotType()
  6690. }
  6691. return nil, false
  6692. }
  6693. // OldField returns the old value of the field from the database. An error is
  6694. // returned if the mutation operation is not UpdateOne, or the query to the
  6695. // database failed.
  6696. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6697. switch name {
  6698. case chatrecords.FieldCreatedAt:
  6699. return m.OldCreatedAt(ctx)
  6700. case chatrecords.FieldUpdatedAt:
  6701. return m.OldUpdatedAt(ctx)
  6702. case chatrecords.FieldDeletedAt:
  6703. return m.OldDeletedAt(ctx)
  6704. case chatrecords.FieldContent:
  6705. return m.OldContent(ctx)
  6706. case chatrecords.FieldContentType:
  6707. return m.OldContentType(ctx)
  6708. case chatrecords.FieldSessionID:
  6709. return m.OldSessionID(ctx)
  6710. case chatrecords.FieldUserID:
  6711. return m.OldUserID(ctx)
  6712. case chatrecords.FieldBotID:
  6713. return m.OldBotID(ctx)
  6714. case chatrecords.FieldBotType:
  6715. return m.OldBotType(ctx)
  6716. }
  6717. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6718. }
  6719. // SetField sets the value of a field with the given name. It returns an error if
  6720. // the field is not defined in the schema, or if the type mismatched the field
  6721. // type.
  6722. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6723. switch name {
  6724. case chatrecords.FieldCreatedAt:
  6725. v, ok := value.(time.Time)
  6726. if !ok {
  6727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6728. }
  6729. m.SetCreatedAt(v)
  6730. return nil
  6731. case chatrecords.FieldUpdatedAt:
  6732. v, ok := value.(time.Time)
  6733. if !ok {
  6734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6735. }
  6736. m.SetUpdatedAt(v)
  6737. return nil
  6738. case chatrecords.FieldDeletedAt:
  6739. v, ok := value.(time.Time)
  6740. if !ok {
  6741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6742. }
  6743. m.SetDeletedAt(v)
  6744. return nil
  6745. case chatrecords.FieldContent:
  6746. v, ok := value.(string)
  6747. if !ok {
  6748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6749. }
  6750. m.SetContent(v)
  6751. return nil
  6752. case chatrecords.FieldContentType:
  6753. v, ok := value.(uint8)
  6754. if !ok {
  6755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6756. }
  6757. m.SetContentType(v)
  6758. return nil
  6759. case chatrecords.FieldSessionID:
  6760. v, ok := value.(uint64)
  6761. if !ok {
  6762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6763. }
  6764. m.SetSessionID(v)
  6765. return nil
  6766. case chatrecords.FieldUserID:
  6767. v, ok := value.(uint64)
  6768. if !ok {
  6769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6770. }
  6771. m.SetUserID(v)
  6772. return nil
  6773. case chatrecords.FieldBotID:
  6774. v, ok := value.(uint64)
  6775. if !ok {
  6776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6777. }
  6778. m.SetBotID(v)
  6779. return nil
  6780. case chatrecords.FieldBotType:
  6781. v, ok := value.(uint8)
  6782. if !ok {
  6783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6784. }
  6785. m.SetBotType(v)
  6786. return nil
  6787. }
  6788. return fmt.Errorf("unknown ChatRecords field %s", name)
  6789. }
  6790. // AddedFields returns all numeric fields that were incremented/decremented during
  6791. // this mutation.
  6792. func (m *ChatRecordsMutation) AddedFields() []string {
  6793. var fields []string
  6794. if m.addcontent_type != nil {
  6795. fields = append(fields, chatrecords.FieldContentType)
  6796. }
  6797. if m.addsession_id != nil {
  6798. fields = append(fields, chatrecords.FieldSessionID)
  6799. }
  6800. if m.adduser_id != nil {
  6801. fields = append(fields, chatrecords.FieldUserID)
  6802. }
  6803. if m.addbot_id != nil {
  6804. fields = append(fields, chatrecords.FieldBotID)
  6805. }
  6806. if m.addbot_type != nil {
  6807. fields = append(fields, chatrecords.FieldBotType)
  6808. }
  6809. return fields
  6810. }
  6811. // AddedField returns the numeric value that was incremented/decremented on a field
  6812. // with the given name. The second boolean return value indicates that this field
  6813. // was not set, or was not defined in the schema.
  6814. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6815. switch name {
  6816. case chatrecords.FieldContentType:
  6817. return m.AddedContentType()
  6818. case chatrecords.FieldSessionID:
  6819. return m.AddedSessionID()
  6820. case chatrecords.FieldUserID:
  6821. return m.AddedUserID()
  6822. case chatrecords.FieldBotID:
  6823. return m.AddedBotID()
  6824. case chatrecords.FieldBotType:
  6825. return m.AddedBotType()
  6826. }
  6827. return nil, false
  6828. }
  6829. // AddField adds the value to the field with the given name. It returns an error if
  6830. // the field is not defined in the schema, or if the type mismatched the field
  6831. // type.
  6832. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6833. switch name {
  6834. case chatrecords.FieldContentType:
  6835. v, ok := value.(int8)
  6836. if !ok {
  6837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6838. }
  6839. m.AddContentType(v)
  6840. return nil
  6841. case chatrecords.FieldSessionID:
  6842. v, ok := value.(int64)
  6843. if !ok {
  6844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6845. }
  6846. m.AddSessionID(v)
  6847. return nil
  6848. case chatrecords.FieldUserID:
  6849. v, ok := value.(int64)
  6850. if !ok {
  6851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6852. }
  6853. m.AddUserID(v)
  6854. return nil
  6855. case chatrecords.FieldBotID:
  6856. v, ok := value.(int64)
  6857. if !ok {
  6858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6859. }
  6860. m.AddBotID(v)
  6861. return nil
  6862. case chatrecords.FieldBotType:
  6863. v, ok := value.(int8)
  6864. if !ok {
  6865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6866. }
  6867. m.AddBotType(v)
  6868. return nil
  6869. }
  6870. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6871. }
  6872. // ClearedFields returns all nullable fields that were cleared during this
  6873. // mutation.
  6874. func (m *ChatRecordsMutation) ClearedFields() []string {
  6875. var fields []string
  6876. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6877. fields = append(fields, chatrecords.FieldDeletedAt)
  6878. }
  6879. return fields
  6880. }
  6881. // FieldCleared returns a boolean indicating if a field with the given name was
  6882. // cleared in this mutation.
  6883. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6884. _, ok := m.clearedFields[name]
  6885. return ok
  6886. }
  6887. // ClearField clears the value of the field with the given name. It returns an
  6888. // error if the field is not defined in the schema.
  6889. func (m *ChatRecordsMutation) ClearField(name string) error {
  6890. switch name {
  6891. case chatrecords.FieldDeletedAt:
  6892. m.ClearDeletedAt()
  6893. return nil
  6894. }
  6895. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6896. }
  6897. // ResetField resets all changes in the mutation for the field with the given name.
  6898. // It returns an error if the field is not defined in the schema.
  6899. func (m *ChatRecordsMutation) ResetField(name string) error {
  6900. switch name {
  6901. case chatrecords.FieldCreatedAt:
  6902. m.ResetCreatedAt()
  6903. return nil
  6904. case chatrecords.FieldUpdatedAt:
  6905. m.ResetUpdatedAt()
  6906. return nil
  6907. case chatrecords.FieldDeletedAt:
  6908. m.ResetDeletedAt()
  6909. return nil
  6910. case chatrecords.FieldContent:
  6911. m.ResetContent()
  6912. return nil
  6913. case chatrecords.FieldContentType:
  6914. m.ResetContentType()
  6915. return nil
  6916. case chatrecords.FieldSessionID:
  6917. m.ResetSessionID()
  6918. return nil
  6919. case chatrecords.FieldUserID:
  6920. m.ResetUserID()
  6921. return nil
  6922. case chatrecords.FieldBotID:
  6923. m.ResetBotID()
  6924. return nil
  6925. case chatrecords.FieldBotType:
  6926. m.ResetBotType()
  6927. return nil
  6928. }
  6929. return fmt.Errorf("unknown ChatRecords field %s", name)
  6930. }
  6931. // AddedEdges returns all edge names that were set/added in this mutation.
  6932. func (m *ChatRecordsMutation) AddedEdges() []string {
  6933. edges := make([]string, 0, 0)
  6934. return edges
  6935. }
  6936. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6937. // name in this mutation.
  6938. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6939. return nil
  6940. }
  6941. // RemovedEdges returns all edge names that were removed in this mutation.
  6942. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6943. edges := make([]string, 0, 0)
  6944. return edges
  6945. }
  6946. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6947. // the given name in this mutation.
  6948. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6949. return nil
  6950. }
  6951. // ClearedEdges returns all edge names that were cleared in this mutation.
  6952. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6953. edges := make([]string, 0, 0)
  6954. return edges
  6955. }
  6956. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6957. // was cleared in this mutation.
  6958. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6959. return false
  6960. }
  6961. // ClearEdge clears the value of the edge with the given name. It returns an error
  6962. // if that edge is not defined in the schema.
  6963. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6964. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6965. }
  6966. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6967. // It returns an error if the edge is not defined in the schema.
  6968. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6969. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6970. }
  6971. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6972. type ChatSessionMutation struct {
  6973. config
  6974. op Op
  6975. typ string
  6976. id *uint64
  6977. created_at *time.Time
  6978. updated_at *time.Time
  6979. deleted_at *time.Time
  6980. name *string
  6981. user_id *uint64
  6982. adduser_id *int64
  6983. bot_id *uint64
  6984. addbot_id *int64
  6985. bot_type *uint8
  6986. addbot_type *int8
  6987. clearedFields map[string]struct{}
  6988. done bool
  6989. oldValue func(context.Context) (*ChatSession, error)
  6990. predicates []predicate.ChatSession
  6991. }
  6992. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6993. // chatsessionOption allows management of the mutation configuration using functional options.
  6994. type chatsessionOption func(*ChatSessionMutation)
  6995. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6996. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6997. m := &ChatSessionMutation{
  6998. config: c,
  6999. op: op,
  7000. typ: TypeChatSession,
  7001. clearedFields: make(map[string]struct{}),
  7002. }
  7003. for _, opt := range opts {
  7004. opt(m)
  7005. }
  7006. return m
  7007. }
  7008. // withChatSessionID sets the ID field of the mutation.
  7009. func withChatSessionID(id uint64) chatsessionOption {
  7010. return func(m *ChatSessionMutation) {
  7011. var (
  7012. err error
  7013. once sync.Once
  7014. value *ChatSession
  7015. )
  7016. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  7017. once.Do(func() {
  7018. if m.done {
  7019. err = errors.New("querying old values post mutation is not allowed")
  7020. } else {
  7021. value, err = m.Client().ChatSession.Get(ctx, id)
  7022. }
  7023. })
  7024. return value, err
  7025. }
  7026. m.id = &id
  7027. }
  7028. }
  7029. // withChatSession sets the old ChatSession of the mutation.
  7030. func withChatSession(node *ChatSession) chatsessionOption {
  7031. return func(m *ChatSessionMutation) {
  7032. m.oldValue = func(context.Context) (*ChatSession, error) {
  7033. return node, nil
  7034. }
  7035. m.id = &node.ID
  7036. }
  7037. }
  7038. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7039. // executed in a transaction (ent.Tx), a transactional client is returned.
  7040. func (m ChatSessionMutation) Client() *Client {
  7041. client := &Client{config: m.config}
  7042. client.init()
  7043. return client
  7044. }
  7045. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7046. // it returns an error otherwise.
  7047. func (m ChatSessionMutation) Tx() (*Tx, error) {
  7048. if _, ok := m.driver.(*txDriver); !ok {
  7049. return nil, errors.New("ent: mutation is not running in a transaction")
  7050. }
  7051. tx := &Tx{config: m.config}
  7052. tx.init()
  7053. return tx, nil
  7054. }
  7055. // SetID sets the value of the id field. Note that this
  7056. // operation is only accepted on creation of ChatSession entities.
  7057. func (m *ChatSessionMutation) SetID(id uint64) {
  7058. m.id = &id
  7059. }
  7060. // ID returns the ID value in the mutation. Note that the ID is only available
  7061. // if it was provided to the builder or after it was returned from the database.
  7062. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  7063. if m.id == nil {
  7064. return
  7065. }
  7066. return *m.id, true
  7067. }
  7068. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7069. // That means, if the mutation is applied within a transaction with an isolation level such
  7070. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7071. // or updated by the mutation.
  7072. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  7073. switch {
  7074. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7075. id, exists := m.ID()
  7076. if exists {
  7077. return []uint64{id}, nil
  7078. }
  7079. fallthrough
  7080. case m.op.Is(OpUpdate | OpDelete):
  7081. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7082. default:
  7083. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7084. }
  7085. }
  7086. // SetCreatedAt sets the "created_at" field.
  7087. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7088. m.created_at = &t
  7089. }
  7090. // CreatedAt returns the value of the "created_at" field in the mutation.
  7091. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7092. v := m.created_at
  7093. if v == nil {
  7094. return
  7095. }
  7096. return *v, true
  7097. }
  7098. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7099. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7101. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7102. if !m.op.Is(OpUpdateOne) {
  7103. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7104. }
  7105. if m.id == nil || m.oldValue == nil {
  7106. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7107. }
  7108. oldValue, err := m.oldValue(ctx)
  7109. if err != nil {
  7110. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7111. }
  7112. return oldValue.CreatedAt, nil
  7113. }
  7114. // ResetCreatedAt resets all changes to the "created_at" field.
  7115. func (m *ChatSessionMutation) ResetCreatedAt() {
  7116. m.created_at = nil
  7117. }
  7118. // SetUpdatedAt sets the "updated_at" field.
  7119. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7120. m.updated_at = &t
  7121. }
  7122. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7123. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7124. v := m.updated_at
  7125. if v == nil {
  7126. return
  7127. }
  7128. return *v, true
  7129. }
  7130. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7131. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7133. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7134. if !m.op.Is(OpUpdateOne) {
  7135. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7136. }
  7137. if m.id == nil || m.oldValue == nil {
  7138. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7139. }
  7140. oldValue, err := m.oldValue(ctx)
  7141. if err != nil {
  7142. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7143. }
  7144. return oldValue.UpdatedAt, nil
  7145. }
  7146. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7147. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7148. m.updated_at = nil
  7149. }
  7150. // SetDeletedAt sets the "deleted_at" field.
  7151. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7152. m.deleted_at = &t
  7153. }
  7154. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7155. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7156. v := m.deleted_at
  7157. if v == nil {
  7158. return
  7159. }
  7160. return *v, true
  7161. }
  7162. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7163. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7165. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7166. if !m.op.Is(OpUpdateOne) {
  7167. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7168. }
  7169. if m.id == nil || m.oldValue == nil {
  7170. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7171. }
  7172. oldValue, err := m.oldValue(ctx)
  7173. if err != nil {
  7174. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7175. }
  7176. return oldValue.DeletedAt, nil
  7177. }
  7178. // ClearDeletedAt clears the value of the "deleted_at" field.
  7179. func (m *ChatSessionMutation) ClearDeletedAt() {
  7180. m.deleted_at = nil
  7181. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7182. }
  7183. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7184. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7185. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7186. return ok
  7187. }
  7188. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7189. func (m *ChatSessionMutation) ResetDeletedAt() {
  7190. m.deleted_at = nil
  7191. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7192. }
  7193. // SetName sets the "name" field.
  7194. func (m *ChatSessionMutation) SetName(s string) {
  7195. m.name = &s
  7196. }
  7197. // Name returns the value of the "name" field in the mutation.
  7198. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7199. v := m.name
  7200. if v == nil {
  7201. return
  7202. }
  7203. return *v, true
  7204. }
  7205. // OldName returns the old "name" field's value of the ChatSession entity.
  7206. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7208. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7209. if !m.op.Is(OpUpdateOne) {
  7210. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7211. }
  7212. if m.id == nil || m.oldValue == nil {
  7213. return v, errors.New("OldName requires an ID field in the mutation")
  7214. }
  7215. oldValue, err := m.oldValue(ctx)
  7216. if err != nil {
  7217. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7218. }
  7219. return oldValue.Name, nil
  7220. }
  7221. // ResetName resets all changes to the "name" field.
  7222. func (m *ChatSessionMutation) ResetName() {
  7223. m.name = nil
  7224. }
  7225. // SetUserID sets the "user_id" field.
  7226. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7227. m.user_id = &u
  7228. m.adduser_id = nil
  7229. }
  7230. // UserID returns the value of the "user_id" field in the mutation.
  7231. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7232. v := m.user_id
  7233. if v == nil {
  7234. return
  7235. }
  7236. return *v, true
  7237. }
  7238. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7239. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7241. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7242. if !m.op.Is(OpUpdateOne) {
  7243. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7244. }
  7245. if m.id == nil || m.oldValue == nil {
  7246. return v, errors.New("OldUserID requires an ID field in the mutation")
  7247. }
  7248. oldValue, err := m.oldValue(ctx)
  7249. if err != nil {
  7250. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7251. }
  7252. return oldValue.UserID, nil
  7253. }
  7254. // AddUserID adds u to the "user_id" field.
  7255. func (m *ChatSessionMutation) AddUserID(u int64) {
  7256. if m.adduser_id != nil {
  7257. *m.adduser_id += u
  7258. } else {
  7259. m.adduser_id = &u
  7260. }
  7261. }
  7262. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7263. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7264. v := m.adduser_id
  7265. if v == nil {
  7266. return
  7267. }
  7268. return *v, true
  7269. }
  7270. // ResetUserID resets all changes to the "user_id" field.
  7271. func (m *ChatSessionMutation) ResetUserID() {
  7272. m.user_id = nil
  7273. m.adduser_id = nil
  7274. }
  7275. // SetBotID sets the "bot_id" field.
  7276. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7277. m.bot_id = &u
  7278. m.addbot_id = nil
  7279. }
  7280. // BotID returns the value of the "bot_id" field in the mutation.
  7281. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7282. v := m.bot_id
  7283. if v == nil {
  7284. return
  7285. }
  7286. return *v, true
  7287. }
  7288. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7289. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7291. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7292. if !m.op.Is(OpUpdateOne) {
  7293. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7294. }
  7295. if m.id == nil || m.oldValue == nil {
  7296. return v, errors.New("OldBotID requires an ID field in the mutation")
  7297. }
  7298. oldValue, err := m.oldValue(ctx)
  7299. if err != nil {
  7300. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7301. }
  7302. return oldValue.BotID, nil
  7303. }
  7304. // AddBotID adds u to the "bot_id" field.
  7305. func (m *ChatSessionMutation) AddBotID(u int64) {
  7306. if m.addbot_id != nil {
  7307. *m.addbot_id += u
  7308. } else {
  7309. m.addbot_id = &u
  7310. }
  7311. }
  7312. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7313. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7314. v := m.addbot_id
  7315. if v == nil {
  7316. return
  7317. }
  7318. return *v, true
  7319. }
  7320. // ResetBotID resets all changes to the "bot_id" field.
  7321. func (m *ChatSessionMutation) ResetBotID() {
  7322. m.bot_id = nil
  7323. m.addbot_id = nil
  7324. }
  7325. // SetBotType sets the "bot_type" field.
  7326. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7327. m.bot_type = &u
  7328. m.addbot_type = nil
  7329. }
  7330. // BotType returns the value of the "bot_type" field in the mutation.
  7331. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7332. v := m.bot_type
  7333. if v == nil {
  7334. return
  7335. }
  7336. return *v, true
  7337. }
  7338. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7339. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7341. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7342. if !m.op.Is(OpUpdateOne) {
  7343. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7344. }
  7345. if m.id == nil || m.oldValue == nil {
  7346. return v, errors.New("OldBotType requires an ID field in the mutation")
  7347. }
  7348. oldValue, err := m.oldValue(ctx)
  7349. if err != nil {
  7350. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7351. }
  7352. return oldValue.BotType, nil
  7353. }
  7354. // AddBotType adds u to the "bot_type" field.
  7355. func (m *ChatSessionMutation) AddBotType(u int8) {
  7356. if m.addbot_type != nil {
  7357. *m.addbot_type += u
  7358. } else {
  7359. m.addbot_type = &u
  7360. }
  7361. }
  7362. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7363. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7364. v := m.addbot_type
  7365. if v == nil {
  7366. return
  7367. }
  7368. return *v, true
  7369. }
  7370. // ResetBotType resets all changes to the "bot_type" field.
  7371. func (m *ChatSessionMutation) ResetBotType() {
  7372. m.bot_type = nil
  7373. m.addbot_type = nil
  7374. }
  7375. // Where appends a list predicates to the ChatSessionMutation builder.
  7376. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7377. m.predicates = append(m.predicates, ps...)
  7378. }
  7379. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7380. // users can use type-assertion to append predicates that do not depend on any generated package.
  7381. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7382. p := make([]predicate.ChatSession, len(ps))
  7383. for i := range ps {
  7384. p[i] = ps[i]
  7385. }
  7386. m.Where(p...)
  7387. }
  7388. // Op returns the operation name.
  7389. func (m *ChatSessionMutation) Op() Op {
  7390. return m.op
  7391. }
  7392. // SetOp allows setting the mutation operation.
  7393. func (m *ChatSessionMutation) SetOp(op Op) {
  7394. m.op = op
  7395. }
  7396. // Type returns the node type of this mutation (ChatSession).
  7397. func (m *ChatSessionMutation) Type() string {
  7398. return m.typ
  7399. }
  7400. // Fields returns all fields that were changed during this mutation. Note that in
  7401. // order to get all numeric fields that were incremented/decremented, call
  7402. // AddedFields().
  7403. func (m *ChatSessionMutation) Fields() []string {
  7404. fields := make([]string, 0, 7)
  7405. if m.created_at != nil {
  7406. fields = append(fields, chatsession.FieldCreatedAt)
  7407. }
  7408. if m.updated_at != nil {
  7409. fields = append(fields, chatsession.FieldUpdatedAt)
  7410. }
  7411. if m.deleted_at != nil {
  7412. fields = append(fields, chatsession.FieldDeletedAt)
  7413. }
  7414. if m.name != nil {
  7415. fields = append(fields, chatsession.FieldName)
  7416. }
  7417. if m.user_id != nil {
  7418. fields = append(fields, chatsession.FieldUserID)
  7419. }
  7420. if m.bot_id != nil {
  7421. fields = append(fields, chatsession.FieldBotID)
  7422. }
  7423. if m.bot_type != nil {
  7424. fields = append(fields, chatsession.FieldBotType)
  7425. }
  7426. return fields
  7427. }
  7428. // Field returns the value of a field with the given name. The second boolean
  7429. // return value indicates that this field was not set, or was not defined in the
  7430. // schema.
  7431. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7432. switch name {
  7433. case chatsession.FieldCreatedAt:
  7434. return m.CreatedAt()
  7435. case chatsession.FieldUpdatedAt:
  7436. return m.UpdatedAt()
  7437. case chatsession.FieldDeletedAt:
  7438. return m.DeletedAt()
  7439. case chatsession.FieldName:
  7440. return m.Name()
  7441. case chatsession.FieldUserID:
  7442. return m.UserID()
  7443. case chatsession.FieldBotID:
  7444. return m.BotID()
  7445. case chatsession.FieldBotType:
  7446. return m.BotType()
  7447. }
  7448. return nil, false
  7449. }
  7450. // OldField returns the old value of the field from the database. An error is
  7451. // returned if the mutation operation is not UpdateOne, or the query to the
  7452. // database failed.
  7453. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7454. switch name {
  7455. case chatsession.FieldCreatedAt:
  7456. return m.OldCreatedAt(ctx)
  7457. case chatsession.FieldUpdatedAt:
  7458. return m.OldUpdatedAt(ctx)
  7459. case chatsession.FieldDeletedAt:
  7460. return m.OldDeletedAt(ctx)
  7461. case chatsession.FieldName:
  7462. return m.OldName(ctx)
  7463. case chatsession.FieldUserID:
  7464. return m.OldUserID(ctx)
  7465. case chatsession.FieldBotID:
  7466. return m.OldBotID(ctx)
  7467. case chatsession.FieldBotType:
  7468. return m.OldBotType(ctx)
  7469. }
  7470. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7471. }
  7472. // SetField sets the value of a field with the given name. It returns an error if
  7473. // the field is not defined in the schema, or if the type mismatched the field
  7474. // type.
  7475. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7476. switch name {
  7477. case chatsession.FieldCreatedAt:
  7478. v, ok := value.(time.Time)
  7479. if !ok {
  7480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7481. }
  7482. m.SetCreatedAt(v)
  7483. return nil
  7484. case chatsession.FieldUpdatedAt:
  7485. v, ok := value.(time.Time)
  7486. if !ok {
  7487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7488. }
  7489. m.SetUpdatedAt(v)
  7490. return nil
  7491. case chatsession.FieldDeletedAt:
  7492. v, ok := value.(time.Time)
  7493. if !ok {
  7494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7495. }
  7496. m.SetDeletedAt(v)
  7497. return nil
  7498. case chatsession.FieldName:
  7499. v, ok := value.(string)
  7500. if !ok {
  7501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7502. }
  7503. m.SetName(v)
  7504. return nil
  7505. case chatsession.FieldUserID:
  7506. v, ok := value.(uint64)
  7507. if !ok {
  7508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7509. }
  7510. m.SetUserID(v)
  7511. return nil
  7512. case chatsession.FieldBotID:
  7513. v, ok := value.(uint64)
  7514. if !ok {
  7515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7516. }
  7517. m.SetBotID(v)
  7518. return nil
  7519. case chatsession.FieldBotType:
  7520. v, ok := value.(uint8)
  7521. if !ok {
  7522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7523. }
  7524. m.SetBotType(v)
  7525. return nil
  7526. }
  7527. return fmt.Errorf("unknown ChatSession field %s", name)
  7528. }
  7529. // AddedFields returns all numeric fields that were incremented/decremented during
  7530. // this mutation.
  7531. func (m *ChatSessionMutation) AddedFields() []string {
  7532. var fields []string
  7533. if m.adduser_id != nil {
  7534. fields = append(fields, chatsession.FieldUserID)
  7535. }
  7536. if m.addbot_id != nil {
  7537. fields = append(fields, chatsession.FieldBotID)
  7538. }
  7539. if m.addbot_type != nil {
  7540. fields = append(fields, chatsession.FieldBotType)
  7541. }
  7542. return fields
  7543. }
  7544. // AddedField returns the numeric value that was incremented/decremented on a field
  7545. // with the given name. The second boolean return value indicates that this field
  7546. // was not set, or was not defined in the schema.
  7547. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7548. switch name {
  7549. case chatsession.FieldUserID:
  7550. return m.AddedUserID()
  7551. case chatsession.FieldBotID:
  7552. return m.AddedBotID()
  7553. case chatsession.FieldBotType:
  7554. return m.AddedBotType()
  7555. }
  7556. return nil, false
  7557. }
  7558. // AddField adds the value to the field with the given name. It returns an error if
  7559. // the field is not defined in the schema, or if the type mismatched the field
  7560. // type.
  7561. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7562. switch name {
  7563. case chatsession.FieldUserID:
  7564. v, ok := value.(int64)
  7565. if !ok {
  7566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7567. }
  7568. m.AddUserID(v)
  7569. return nil
  7570. case chatsession.FieldBotID:
  7571. v, ok := value.(int64)
  7572. if !ok {
  7573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7574. }
  7575. m.AddBotID(v)
  7576. return nil
  7577. case chatsession.FieldBotType:
  7578. v, ok := value.(int8)
  7579. if !ok {
  7580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7581. }
  7582. m.AddBotType(v)
  7583. return nil
  7584. }
  7585. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7586. }
  7587. // ClearedFields returns all nullable fields that were cleared during this
  7588. // mutation.
  7589. func (m *ChatSessionMutation) ClearedFields() []string {
  7590. var fields []string
  7591. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7592. fields = append(fields, chatsession.FieldDeletedAt)
  7593. }
  7594. return fields
  7595. }
  7596. // FieldCleared returns a boolean indicating if a field with the given name was
  7597. // cleared in this mutation.
  7598. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7599. _, ok := m.clearedFields[name]
  7600. return ok
  7601. }
  7602. // ClearField clears the value of the field with the given name. It returns an
  7603. // error if the field is not defined in the schema.
  7604. func (m *ChatSessionMutation) ClearField(name string) error {
  7605. switch name {
  7606. case chatsession.FieldDeletedAt:
  7607. m.ClearDeletedAt()
  7608. return nil
  7609. }
  7610. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7611. }
  7612. // ResetField resets all changes in the mutation for the field with the given name.
  7613. // It returns an error if the field is not defined in the schema.
  7614. func (m *ChatSessionMutation) ResetField(name string) error {
  7615. switch name {
  7616. case chatsession.FieldCreatedAt:
  7617. m.ResetCreatedAt()
  7618. return nil
  7619. case chatsession.FieldUpdatedAt:
  7620. m.ResetUpdatedAt()
  7621. return nil
  7622. case chatsession.FieldDeletedAt:
  7623. m.ResetDeletedAt()
  7624. return nil
  7625. case chatsession.FieldName:
  7626. m.ResetName()
  7627. return nil
  7628. case chatsession.FieldUserID:
  7629. m.ResetUserID()
  7630. return nil
  7631. case chatsession.FieldBotID:
  7632. m.ResetBotID()
  7633. return nil
  7634. case chatsession.FieldBotType:
  7635. m.ResetBotType()
  7636. return nil
  7637. }
  7638. return fmt.Errorf("unknown ChatSession field %s", name)
  7639. }
  7640. // AddedEdges returns all edge names that were set/added in this mutation.
  7641. func (m *ChatSessionMutation) AddedEdges() []string {
  7642. edges := make([]string, 0, 0)
  7643. return edges
  7644. }
  7645. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7646. // name in this mutation.
  7647. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7648. return nil
  7649. }
  7650. // RemovedEdges returns all edge names that were removed in this mutation.
  7651. func (m *ChatSessionMutation) RemovedEdges() []string {
  7652. edges := make([]string, 0, 0)
  7653. return edges
  7654. }
  7655. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7656. // the given name in this mutation.
  7657. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7658. return nil
  7659. }
  7660. // ClearedEdges returns all edge names that were cleared in this mutation.
  7661. func (m *ChatSessionMutation) ClearedEdges() []string {
  7662. edges := make([]string, 0, 0)
  7663. return edges
  7664. }
  7665. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7666. // was cleared in this mutation.
  7667. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7668. return false
  7669. }
  7670. // ClearEdge clears the value of the edge with the given name. It returns an error
  7671. // if that edge is not defined in the schema.
  7672. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7673. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7674. }
  7675. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7676. // It returns an error if the edge is not defined in the schema.
  7677. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7678. return fmt.Errorf("unknown ChatSession edge %s", name)
  7679. }
  7680. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7681. type ContactMutation struct {
  7682. config
  7683. op Op
  7684. typ string
  7685. id *uint64
  7686. created_at *time.Time
  7687. updated_at *time.Time
  7688. status *uint8
  7689. addstatus *int8
  7690. deleted_at *time.Time
  7691. wx_wxid *string
  7692. _type *int
  7693. add_type *int
  7694. wxid *string
  7695. account *string
  7696. nickname *string
  7697. markname *string
  7698. headimg *string
  7699. sex *int
  7700. addsex *int
  7701. starrole *string
  7702. dontseeit *int
  7703. adddontseeit *int
  7704. dontseeme *int
  7705. adddontseeme *int
  7706. lag *string
  7707. gid *string
  7708. gname *string
  7709. v3 *string
  7710. organization_id *uint64
  7711. addorganization_id *int64
  7712. clearedFields map[string]struct{}
  7713. contact_relationships map[uint64]struct{}
  7714. removedcontact_relationships map[uint64]struct{}
  7715. clearedcontact_relationships bool
  7716. contact_messages map[uint64]struct{}
  7717. removedcontact_messages map[uint64]struct{}
  7718. clearedcontact_messages bool
  7719. done bool
  7720. oldValue func(context.Context) (*Contact, error)
  7721. predicates []predicate.Contact
  7722. }
  7723. var _ ent.Mutation = (*ContactMutation)(nil)
  7724. // contactOption allows management of the mutation configuration using functional options.
  7725. type contactOption func(*ContactMutation)
  7726. // newContactMutation creates new mutation for the Contact entity.
  7727. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7728. m := &ContactMutation{
  7729. config: c,
  7730. op: op,
  7731. typ: TypeContact,
  7732. clearedFields: make(map[string]struct{}),
  7733. }
  7734. for _, opt := range opts {
  7735. opt(m)
  7736. }
  7737. return m
  7738. }
  7739. // withContactID sets the ID field of the mutation.
  7740. func withContactID(id uint64) contactOption {
  7741. return func(m *ContactMutation) {
  7742. var (
  7743. err error
  7744. once sync.Once
  7745. value *Contact
  7746. )
  7747. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7748. once.Do(func() {
  7749. if m.done {
  7750. err = errors.New("querying old values post mutation is not allowed")
  7751. } else {
  7752. value, err = m.Client().Contact.Get(ctx, id)
  7753. }
  7754. })
  7755. return value, err
  7756. }
  7757. m.id = &id
  7758. }
  7759. }
  7760. // withContact sets the old Contact of the mutation.
  7761. func withContact(node *Contact) contactOption {
  7762. return func(m *ContactMutation) {
  7763. m.oldValue = func(context.Context) (*Contact, error) {
  7764. return node, nil
  7765. }
  7766. m.id = &node.ID
  7767. }
  7768. }
  7769. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7770. // executed in a transaction (ent.Tx), a transactional client is returned.
  7771. func (m ContactMutation) Client() *Client {
  7772. client := &Client{config: m.config}
  7773. client.init()
  7774. return client
  7775. }
  7776. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7777. // it returns an error otherwise.
  7778. func (m ContactMutation) Tx() (*Tx, error) {
  7779. if _, ok := m.driver.(*txDriver); !ok {
  7780. return nil, errors.New("ent: mutation is not running in a transaction")
  7781. }
  7782. tx := &Tx{config: m.config}
  7783. tx.init()
  7784. return tx, nil
  7785. }
  7786. // SetID sets the value of the id field. Note that this
  7787. // operation is only accepted on creation of Contact entities.
  7788. func (m *ContactMutation) SetID(id uint64) {
  7789. m.id = &id
  7790. }
  7791. // ID returns the ID value in the mutation. Note that the ID is only available
  7792. // if it was provided to the builder or after it was returned from the database.
  7793. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7794. if m.id == nil {
  7795. return
  7796. }
  7797. return *m.id, true
  7798. }
  7799. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7800. // That means, if the mutation is applied within a transaction with an isolation level such
  7801. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7802. // or updated by the mutation.
  7803. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7804. switch {
  7805. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7806. id, exists := m.ID()
  7807. if exists {
  7808. return []uint64{id}, nil
  7809. }
  7810. fallthrough
  7811. case m.op.Is(OpUpdate | OpDelete):
  7812. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7813. default:
  7814. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7815. }
  7816. }
  7817. // SetCreatedAt sets the "created_at" field.
  7818. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7819. m.created_at = &t
  7820. }
  7821. // CreatedAt returns the value of the "created_at" field in the mutation.
  7822. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7823. v := m.created_at
  7824. if v == nil {
  7825. return
  7826. }
  7827. return *v, true
  7828. }
  7829. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7830. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7832. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7833. if !m.op.Is(OpUpdateOne) {
  7834. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7835. }
  7836. if m.id == nil || m.oldValue == nil {
  7837. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7838. }
  7839. oldValue, err := m.oldValue(ctx)
  7840. if err != nil {
  7841. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7842. }
  7843. return oldValue.CreatedAt, nil
  7844. }
  7845. // ResetCreatedAt resets all changes to the "created_at" field.
  7846. func (m *ContactMutation) ResetCreatedAt() {
  7847. m.created_at = nil
  7848. }
  7849. // SetUpdatedAt sets the "updated_at" field.
  7850. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7851. m.updated_at = &t
  7852. }
  7853. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7854. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7855. v := m.updated_at
  7856. if v == nil {
  7857. return
  7858. }
  7859. return *v, true
  7860. }
  7861. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7862. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7864. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7865. if !m.op.Is(OpUpdateOne) {
  7866. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7867. }
  7868. if m.id == nil || m.oldValue == nil {
  7869. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7870. }
  7871. oldValue, err := m.oldValue(ctx)
  7872. if err != nil {
  7873. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7874. }
  7875. return oldValue.UpdatedAt, nil
  7876. }
  7877. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7878. func (m *ContactMutation) ResetUpdatedAt() {
  7879. m.updated_at = nil
  7880. }
  7881. // SetStatus sets the "status" field.
  7882. func (m *ContactMutation) SetStatus(u uint8) {
  7883. m.status = &u
  7884. m.addstatus = nil
  7885. }
  7886. // Status returns the value of the "status" field in the mutation.
  7887. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7888. v := m.status
  7889. if v == nil {
  7890. return
  7891. }
  7892. return *v, true
  7893. }
  7894. // OldStatus returns the old "status" field's value of the Contact entity.
  7895. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7897. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7898. if !m.op.Is(OpUpdateOne) {
  7899. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7900. }
  7901. if m.id == nil || m.oldValue == nil {
  7902. return v, errors.New("OldStatus requires an ID field in the mutation")
  7903. }
  7904. oldValue, err := m.oldValue(ctx)
  7905. if err != nil {
  7906. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7907. }
  7908. return oldValue.Status, nil
  7909. }
  7910. // AddStatus adds u to the "status" field.
  7911. func (m *ContactMutation) AddStatus(u int8) {
  7912. if m.addstatus != nil {
  7913. *m.addstatus += u
  7914. } else {
  7915. m.addstatus = &u
  7916. }
  7917. }
  7918. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7919. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7920. v := m.addstatus
  7921. if v == nil {
  7922. return
  7923. }
  7924. return *v, true
  7925. }
  7926. // ClearStatus clears the value of the "status" field.
  7927. func (m *ContactMutation) ClearStatus() {
  7928. m.status = nil
  7929. m.addstatus = nil
  7930. m.clearedFields[contact.FieldStatus] = struct{}{}
  7931. }
  7932. // StatusCleared returns if the "status" field was cleared in this mutation.
  7933. func (m *ContactMutation) StatusCleared() bool {
  7934. _, ok := m.clearedFields[contact.FieldStatus]
  7935. return ok
  7936. }
  7937. // ResetStatus resets all changes to the "status" field.
  7938. func (m *ContactMutation) ResetStatus() {
  7939. m.status = nil
  7940. m.addstatus = nil
  7941. delete(m.clearedFields, contact.FieldStatus)
  7942. }
  7943. // SetDeletedAt sets the "deleted_at" field.
  7944. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7945. m.deleted_at = &t
  7946. }
  7947. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7948. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7949. v := m.deleted_at
  7950. if v == nil {
  7951. return
  7952. }
  7953. return *v, true
  7954. }
  7955. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7956. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7958. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7959. if !m.op.Is(OpUpdateOne) {
  7960. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7961. }
  7962. if m.id == nil || m.oldValue == nil {
  7963. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7964. }
  7965. oldValue, err := m.oldValue(ctx)
  7966. if err != nil {
  7967. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7968. }
  7969. return oldValue.DeletedAt, nil
  7970. }
  7971. // ClearDeletedAt clears the value of the "deleted_at" field.
  7972. func (m *ContactMutation) ClearDeletedAt() {
  7973. m.deleted_at = nil
  7974. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7975. }
  7976. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7977. func (m *ContactMutation) DeletedAtCleared() bool {
  7978. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7979. return ok
  7980. }
  7981. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7982. func (m *ContactMutation) ResetDeletedAt() {
  7983. m.deleted_at = nil
  7984. delete(m.clearedFields, contact.FieldDeletedAt)
  7985. }
  7986. // SetWxWxid sets the "wx_wxid" field.
  7987. func (m *ContactMutation) SetWxWxid(s string) {
  7988. m.wx_wxid = &s
  7989. }
  7990. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7991. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7992. v := m.wx_wxid
  7993. if v == nil {
  7994. return
  7995. }
  7996. return *v, true
  7997. }
  7998. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7999. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8001. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8002. if !m.op.Is(OpUpdateOne) {
  8003. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8004. }
  8005. if m.id == nil || m.oldValue == nil {
  8006. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8007. }
  8008. oldValue, err := m.oldValue(ctx)
  8009. if err != nil {
  8010. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8011. }
  8012. return oldValue.WxWxid, nil
  8013. }
  8014. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8015. func (m *ContactMutation) ResetWxWxid() {
  8016. m.wx_wxid = nil
  8017. }
  8018. // SetType sets the "type" field.
  8019. func (m *ContactMutation) SetType(i int) {
  8020. m._type = &i
  8021. m.add_type = nil
  8022. }
  8023. // GetType returns the value of the "type" field in the mutation.
  8024. func (m *ContactMutation) GetType() (r int, exists bool) {
  8025. v := m._type
  8026. if v == nil {
  8027. return
  8028. }
  8029. return *v, true
  8030. }
  8031. // OldType returns the old "type" field's value of the Contact entity.
  8032. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8034. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  8035. if !m.op.Is(OpUpdateOne) {
  8036. return v, errors.New("OldType is only allowed on UpdateOne operations")
  8037. }
  8038. if m.id == nil || m.oldValue == nil {
  8039. return v, errors.New("OldType requires an ID field in the mutation")
  8040. }
  8041. oldValue, err := m.oldValue(ctx)
  8042. if err != nil {
  8043. return v, fmt.Errorf("querying old value for OldType: %w", err)
  8044. }
  8045. return oldValue.Type, nil
  8046. }
  8047. // AddType adds i to the "type" field.
  8048. func (m *ContactMutation) AddType(i int) {
  8049. if m.add_type != nil {
  8050. *m.add_type += i
  8051. } else {
  8052. m.add_type = &i
  8053. }
  8054. }
  8055. // AddedType returns the value that was added to the "type" field in this mutation.
  8056. func (m *ContactMutation) AddedType() (r int, exists bool) {
  8057. v := m.add_type
  8058. if v == nil {
  8059. return
  8060. }
  8061. return *v, true
  8062. }
  8063. // ClearType clears the value of the "type" field.
  8064. func (m *ContactMutation) ClearType() {
  8065. m._type = nil
  8066. m.add_type = nil
  8067. m.clearedFields[contact.FieldType] = struct{}{}
  8068. }
  8069. // TypeCleared returns if the "type" field was cleared in this mutation.
  8070. func (m *ContactMutation) TypeCleared() bool {
  8071. _, ok := m.clearedFields[contact.FieldType]
  8072. return ok
  8073. }
  8074. // ResetType resets all changes to the "type" field.
  8075. func (m *ContactMutation) ResetType() {
  8076. m._type = nil
  8077. m.add_type = nil
  8078. delete(m.clearedFields, contact.FieldType)
  8079. }
  8080. // SetWxid sets the "wxid" field.
  8081. func (m *ContactMutation) SetWxid(s string) {
  8082. m.wxid = &s
  8083. }
  8084. // Wxid returns the value of the "wxid" field in the mutation.
  8085. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8086. v := m.wxid
  8087. if v == nil {
  8088. return
  8089. }
  8090. return *v, true
  8091. }
  8092. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8093. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8095. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8096. if !m.op.Is(OpUpdateOne) {
  8097. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8098. }
  8099. if m.id == nil || m.oldValue == nil {
  8100. return v, errors.New("OldWxid requires an ID field in the mutation")
  8101. }
  8102. oldValue, err := m.oldValue(ctx)
  8103. if err != nil {
  8104. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8105. }
  8106. return oldValue.Wxid, nil
  8107. }
  8108. // ResetWxid resets all changes to the "wxid" field.
  8109. func (m *ContactMutation) ResetWxid() {
  8110. m.wxid = nil
  8111. }
  8112. // SetAccount sets the "account" field.
  8113. func (m *ContactMutation) SetAccount(s string) {
  8114. m.account = &s
  8115. }
  8116. // Account returns the value of the "account" field in the mutation.
  8117. func (m *ContactMutation) Account() (r string, exists bool) {
  8118. v := m.account
  8119. if v == nil {
  8120. return
  8121. }
  8122. return *v, true
  8123. }
  8124. // OldAccount returns the old "account" field's value of the Contact entity.
  8125. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8127. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8128. if !m.op.Is(OpUpdateOne) {
  8129. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8130. }
  8131. if m.id == nil || m.oldValue == nil {
  8132. return v, errors.New("OldAccount requires an ID field in the mutation")
  8133. }
  8134. oldValue, err := m.oldValue(ctx)
  8135. if err != nil {
  8136. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8137. }
  8138. return oldValue.Account, nil
  8139. }
  8140. // ResetAccount resets all changes to the "account" field.
  8141. func (m *ContactMutation) ResetAccount() {
  8142. m.account = nil
  8143. }
  8144. // SetNickname sets the "nickname" field.
  8145. func (m *ContactMutation) SetNickname(s string) {
  8146. m.nickname = &s
  8147. }
  8148. // Nickname returns the value of the "nickname" field in the mutation.
  8149. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8150. v := m.nickname
  8151. if v == nil {
  8152. return
  8153. }
  8154. return *v, true
  8155. }
  8156. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8157. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8159. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8160. if !m.op.Is(OpUpdateOne) {
  8161. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8162. }
  8163. if m.id == nil || m.oldValue == nil {
  8164. return v, errors.New("OldNickname requires an ID field in the mutation")
  8165. }
  8166. oldValue, err := m.oldValue(ctx)
  8167. if err != nil {
  8168. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8169. }
  8170. return oldValue.Nickname, nil
  8171. }
  8172. // ResetNickname resets all changes to the "nickname" field.
  8173. func (m *ContactMutation) ResetNickname() {
  8174. m.nickname = nil
  8175. }
  8176. // SetMarkname sets the "markname" field.
  8177. func (m *ContactMutation) SetMarkname(s string) {
  8178. m.markname = &s
  8179. }
  8180. // Markname returns the value of the "markname" field in the mutation.
  8181. func (m *ContactMutation) Markname() (r string, exists bool) {
  8182. v := m.markname
  8183. if v == nil {
  8184. return
  8185. }
  8186. return *v, true
  8187. }
  8188. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8189. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8191. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8192. if !m.op.Is(OpUpdateOne) {
  8193. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8194. }
  8195. if m.id == nil || m.oldValue == nil {
  8196. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8197. }
  8198. oldValue, err := m.oldValue(ctx)
  8199. if err != nil {
  8200. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8201. }
  8202. return oldValue.Markname, nil
  8203. }
  8204. // ResetMarkname resets all changes to the "markname" field.
  8205. func (m *ContactMutation) ResetMarkname() {
  8206. m.markname = nil
  8207. }
  8208. // SetHeadimg sets the "headimg" field.
  8209. func (m *ContactMutation) SetHeadimg(s string) {
  8210. m.headimg = &s
  8211. }
  8212. // Headimg returns the value of the "headimg" field in the mutation.
  8213. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8214. v := m.headimg
  8215. if v == nil {
  8216. return
  8217. }
  8218. return *v, true
  8219. }
  8220. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8221. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8223. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8224. if !m.op.Is(OpUpdateOne) {
  8225. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8226. }
  8227. if m.id == nil || m.oldValue == nil {
  8228. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8229. }
  8230. oldValue, err := m.oldValue(ctx)
  8231. if err != nil {
  8232. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8233. }
  8234. return oldValue.Headimg, nil
  8235. }
  8236. // ResetHeadimg resets all changes to the "headimg" field.
  8237. func (m *ContactMutation) ResetHeadimg() {
  8238. m.headimg = nil
  8239. }
  8240. // SetSex sets the "sex" field.
  8241. func (m *ContactMutation) SetSex(i int) {
  8242. m.sex = &i
  8243. m.addsex = nil
  8244. }
  8245. // Sex returns the value of the "sex" field in the mutation.
  8246. func (m *ContactMutation) Sex() (r int, exists bool) {
  8247. v := m.sex
  8248. if v == nil {
  8249. return
  8250. }
  8251. return *v, true
  8252. }
  8253. // OldSex returns the old "sex" field's value of the Contact entity.
  8254. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8256. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8257. if !m.op.Is(OpUpdateOne) {
  8258. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8259. }
  8260. if m.id == nil || m.oldValue == nil {
  8261. return v, errors.New("OldSex requires an ID field in the mutation")
  8262. }
  8263. oldValue, err := m.oldValue(ctx)
  8264. if err != nil {
  8265. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8266. }
  8267. return oldValue.Sex, nil
  8268. }
  8269. // AddSex adds i to the "sex" field.
  8270. func (m *ContactMutation) AddSex(i int) {
  8271. if m.addsex != nil {
  8272. *m.addsex += i
  8273. } else {
  8274. m.addsex = &i
  8275. }
  8276. }
  8277. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8278. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8279. v := m.addsex
  8280. if v == nil {
  8281. return
  8282. }
  8283. return *v, true
  8284. }
  8285. // ResetSex resets all changes to the "sex" field.
  8286. func (m *ContactMutation) ResetSex() {
  8287. m.sex = nil
  8288. m.addsex = nil
  8289. }
  8290. // SetStarrole sets the "starrole" field.
  8291. func (m *ContactMutation) SetStarrole(s string) {
  8292. m.starrole = &s
  8293. }
  8294. // Starrole returns the value of the "starrole" field in the mutation.
  8295. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8296. v := m.starrole
  8297. if v == nil {
  8298. return
  8299. }
  8300. return *v, true
  8301. }
  8302. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8303. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8305. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8306. if !m.op.Is(OpUpdateOne) {
  8307. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8308. }
  8309. if m.id == nil || m.oldValue == nil {
  8310. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8311. }
  8312. oldValue, err := m.oldValue(ctx)
  8313. if err != nil {
  8314. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8315. }
  8316. return oldValue.Starrole, nil
  8317. }
  8318. // ResetStarrole resets all changes to the "starrole" field.
  8319. func (m *ContactMutation) ResetStarrole() {
  8320. m.starrole = nil
  8321. }
  8322. // SetDontseeit sets the "dontseeit" field.
  8323. func (m *ContactMutation) SetDontseeit(i int) {
  8324. m.dontseeit = &i
  8325. m.adddontseeit = nil
  8326. }
  8327. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8328. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8329. v := m.dontseeit
  8330. if v == nil {
  8331. return
  8332. }
  8333. return *v, true
  8334. }
  8335. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8336. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8338. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8339. if !m.op.Is(OpUpdateOne) {
  8340. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8341. }
  8342. if m.id == nil || m.oldValue == nil {
  8343. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8344. }
  8345. oldValue, err := m.oldValue(ctx)
  8346. if err != nil {
  8347. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8348. }
  8349. return oldValue.Dontseeit, nil
  8350. }
  8351. // AddDontseeit adds i to the "dontseeit" field.
  8352. func (m *ContactMutation) AddDontseeit(i int) {
  8353. if m.adddontseeit != nil {
  8354. *m.adddontseeit += i
  8355. } else {
  8356. m.adddontseeit = &i
  8357. }
  8358. }
  8359. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8360. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8361. v := m.adddontseeit
  8362. if v == nil {
  8363. return
  8364. }
  8365. return *v, true
  8366. }
  8367. // ResetDontseeit resets all changes to the "dontseeit" field.
  8368. func (m *ContactMutation) ResetDontseeit() {
  8369. m.dontseeit = nil
  8370. m.adddontseeit = nil
  8371. }
  8372. // SetDontseeme sets the "dontseeme" field.
  8373. func (m *ContactMutation) SetDontseeme(i int) {
  8374. m.dontseeme = &i
  8375. m.adddontseeme = nil
  8376. }
  8377. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8378. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8379. v := m.dontseeme
  8380. if v == nil {
  8381. return
  8382. }
  8383. return *v, true
  8384. }
  8385. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8386. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8388. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8389. if !m.op.Is(OpUpdateOne) {
  8390. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8391. }
  8392. if m.id == nil || m.oldValue == nil {
  8393. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8394. }
  8395. oldValue, err := m.oldValue(ctx)
  8396. if err != nil {
  8397. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8398. }
  8399. return oldValue.Dontseeme, nil
  8400. }
  8401. // AddDontseeme adds i to the "dontseeme" field.
  8402. func (m *ContactMutation) AddDontseeme(i int) {
  8403. if m.adddontseeme != nil {
  8404. *m.adddontseeme += i
  8405. } else {
  8406. m.adddontseeme = &i
  8407. }
  8408. }
  8409. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8410. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8411. v := m.adddontseeme
  8412. if v == nil {
  8413. return
  8414. }
  8415. return *v, true
  8416. }
  8417. // ResetDontseeme resets all changes to the "dontseeme" field.
  8418. func (m *ContactMutation) ResetDontseeme() {
  8419. m.dontseeme = nil
  8420. m.adddontseeme = nil
  8421. }
  8422. // SetLag sets the "lag" field.
  8423. func (m *ContactMutation) SetLag(s string) {
  8424. m.lag = &s
  8425. }
  8426. // Lag returns the value of the "lag" field in the mutation.
  8427. func (m *ContactMutation) Lag() (r string, exists bool) {
  8428. v := m.lag
  8429. if v == nil {
  8430. return
  8431. }
  8432. return *v, true
  8433. }
  8434. // OldLag returns the old "lag" field's value of the Contact entity.
  8435. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8437. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8438. if !m.op.Is(OpUpdateOne) {
  8439. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8440. }
  8441. if m.id == nil || m.oldValue == nil {
  8442. return v, errors.New("OldLag requires an ID field in the mutation")
  8443. }
  8444. oldValue, err := m.oldValue(ctx)
  8445. if err != nil {
  8446. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8447. }
  8448. return oldValue.Lag, nil
  8449. }
  8450. // ResetLag resets all changes to the "lag" field.
  8451. func (m *ContactMutation) ResetLag() {
  8452. m.lag = nil
  8453. }
  8454. // SetGid sets the "gid" field.
  8455. func (m *ContactMutation) SetGid(s string) {
  8456. m.gid = &s
  8457. }
  8458. // Gid returns the value of the "gid" field in the mutation.
  8459. func (m *ContactMutation) Gid() (r string, exists bool) {
  8460. v := m.gid
  8461. if v == nil {
  8462. return
  8463. }
  8464. return *v, true
  8465. }
  8466. // OldGid returns the old "gid" field's value of the Contact entity.
  8467. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8469. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8470. if !m.op.Is(OpUpdateOne) {
  8471. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8472. }
  8473. if m.id == nil || m.oldValue == nil {
  8474. return v, errors.New("OldGid requires an ID field in the mutation")
  8475. }
  8476. oldValue, err := m.oldValue(ctx)
  8477. if err != nil {
  8478. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8479. }
  8480. return oldValue.Gid, nil
  8481. }
  8482. // ResetGid resets all changes to the "gid" field.
  8483. func (m *ContactMutation) ResetGid() {
  8484. m.gid = nil
  8485. }
  8486. // SetGname sets the "gname" field.
  8487. func (m *ContactMutation) SetGname(s string) {
  8488. m.gname = &s
  8489. }
  8490. // Gname returns the value of the "gname" field in the mutation.
  8491. func (m *ContactMutation) Gname() (r string, exists bool) {
  8492. v := m.gname
  8493. if v == nil {
  8494. return
  8495. }
  8496. return *v, true
  8497. }
  8498. // OldGname returns the old "gname" field's value of the Contact entity.
  8499. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8501. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8502. if !m.op.Is(OpUpdateOne) {
  8503. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8504. }
  8505. if m.id == nil || m.oldValue == nil {
  8506. return v, errors.New("OldGname requires an ID field in the mutation")
  8507. }
  8508. oldValue, err := m.oldValue(ctx)
  8509. if err != nil {
  8510. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8511. }
  8512. return oldValue.Gname, nil
  8513. }
  8514. // ResetGname resets all changes to the "gname" field.
  8515. func (m *ContactMutation) ResetGname() {
  8516. m.gname = nil
  8517. }
  8518. // SetV3 sets the "v3" field.
  8519. func (m *ContactMutation) SetV3(s string) {
  8520. m.v3 = &s
  8521. }
  8522. // V3 returns the value of the "v3" field in the mutation.
  8523. func (m *ContactMutation) V3() (r string, exists bool) {
  8524. v := m.v3
  8525. if v == nil {
  8526. return
  8527. }
  8528. return *v, true
  8529. }
  8530. // OldV3 returns the old "v3" field's value of the Contact entity.
  8531. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8533. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8534. if !m.op.Is(OpUpdateOne) {
  8535. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8536. }
  8537. if m.id == nil || m.oldValue == nil {
  8538. return v, errors.New("OldV3 requires an ID field in the mutation")
  8539. }
  8540. oldValue, err := m.oldValue(ctx)
  8541. if err != nil {
  8542. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8543. }
  8544. return oldValue.V3, nil
  8545. }
  8546. // ResetV3 resets all changes to the "v3" field.
  8547. func (m *ContactMutation) ResetV3() {
  8548. m.v3 = nil
  8549. }
  8550. // SetOrganizationID sets the "organization_id" field.
  8551. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8552. m.organization_id = &u
  8553. m.addorganization_id = nil
  8554. }
  8555. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8556. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8557. v := m.organization_id
  8558. if v == nil {
  8559. return
  8560. }
  8561. return *v, true
  8562. }
  8563. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8564. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8566. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8567. if !m.op.Is(OpUpdateOne) {
  8568. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8569. }
  8570. if m.id == nil || m.oldValue == nil {
  8571. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8572. }
  8573. oldValue, err := m.oldValue(ctx)
  8574. if err != nil {
  8575. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8576. }
  8577. return oldValue.OrganizationID, nil
  8578. }
  8579. // AddOrganizationID adds u to the "organization_id" field.
  8580. func (m *ContactMutation) AddOrganizationID(u int64) {
  8581. if m.addorganization_id != nil {
  8582. *m.addorganization_id += u
  8583. } else {
  8584. m.addorganization_id = &u
  8585. }
  8586. }
  8587. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8588. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8589. v := m.addorganization_id
  8590. if v == nil {
  8591. return
  8592. }
  8593. return *v, true
  8594. }
  8595. // ClearOrganizationID clears the value of the "organization_id" field.
  8596. func (m *ContactMutation) ClearOrganizationID() {
  8597. m.organization_id = nil
  8598. m.addorganization_id = nil
  8599. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8600. }
  8601. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8602. func (m *ContactMutation) OrganizationIDCleared() bool {
  8603. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8604. return ok
  8605. }
  8606. // ResetOrganizationID resets all changes to the "organization_id" field.
  8607. func (m *ContactMutation) ResetOrganizationID() {
  8608. m.organization_id = nil
  8609. m.addorganization_id = nil
  8610. delete(m.clearedFields, contact.FieldOrganizationID)
  8611. }
  8612. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8613. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8614. if m.contact_relationships == nil {
  8615. m.contact_relationships = make(map[uint64]struct{})
  8616. }
  8617. for i := range ids {
  8618. m.contact_relationships[ids[i]] = struct{}{}
  8619. }
  8620. }
  8621. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8622. func (m *ContactMutation) ClearContactRelationships() {
  8623. m.clearedcontact_relationships = true
  8624. }
  8625. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8626. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8627. return m.clearedcontact_relationships
  8628. }
  8629. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8630. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8631. if m.removedcontact_relationships == nil {
  8632. m.removedcontact_relationships = make(map[uint64]struct{})
  8633. }
  8634. for i := range ids {
  8635. delete(m.contact_relationships, ids[i])
  8636. m.removedcontact_relationships[ids[i]] = struct{}{}
  8637. }
  8638. }
  8639. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8640. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8641. for id := range m.removedcontact_relationships {
  8642. ids = append(ids, id)
  8643. }
  8644. return
  8645. }
  8646. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8647. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8648. for id := range m.contact_relationships {
  8649. ids = append(ids, id)
  8650. }
  8651. return
  8652. }
  8653. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8654. func (m *ContactMutation) ResetContactRelationships() {
  8655. m.contact_relationships = nil
  8656. m.clearedcontact_relationships = false
  8657. m.removedcontact_relationships = nil
  8658. }
  8659. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8660. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8661. if m.contact_messages == nil {
  8662. m.contact_messages = make(map[uint64]struct{})
  8663. }
  8664. for i := range ids {
  8665. m.contact_messages[ids[i]] = struct{}{}
  8666. }
  8667. }
  8668. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8669. func (m *ContactMutation) ClearContactMessages() {
  8670. m.clearedcontact_messages = true
  8671. }
  8672. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8673. func (m *ContactMutation) ContactMessagesCleared() bool {
  8674. return m.clearedcontact_messages
  8675. }
  8676. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8677. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8678. if m.removedcontact_messages == nil {
  8679. m.removedcontact_messages = make(map[uint64]struct{})
  8680. }
  8681. for i := range ids {
  8682. delete(m.contact_messages, ids[i])
  8683. m.removedcontact_messages[ids[i]] = struct{}{}
  8684. }
  8685. }
  8686. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8687. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8688. for id := range m.removedcontact_messages {
  8689. ids = append(ids, id)
  8690. }
  8691. return
  8692. }
  8693. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8694. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8695. for id := range m.contact_messages {
  8696. ids = append(ids, id)
  8697. }
  8698. return
  8699. }
  8700. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8701. func (m *ContactMutation) ResetContactMessages() {
  8702. m.contact_messages = nil
  8703. m.clearedcontact_messages = false
  8704. m.removedcontact_messages = nil
  8705. }
  8706. // Where appends a list predicates to the ContactMutation builder.
  8707. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8708. m.predicates = append(m.predicates, ps...)
  8709. }
  8710. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8711. // users can use type-assertion to append predicates that do not depend on any generated package.
  8712. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8713. p := make([]predicate.Contact, len(ps))
  8714. for i := range ps {
  8715. p[i] = ps[i]
  8716. }
  8717. m.Where(p...)
  8718. }
  8719. // Op returns the operation name.
  8720. func (m *ContactMutation) Op() Op {
  8721. return m.op
  8722. }
  8723. // SetOp allows setting the mutation operation.
  8724. func (m *ContactMutation) SetOp(op Op) {
  8725. m.op = op
  8726. }
  8727. // Type returns the node type of this mutation (Contact).
  8728. func (m *ContactMutation) Type() string {
  8729. return m.typ
  8730. }
  8731. // Fields returns all fields that were changed during this mutation. Note that in
  8732. // order to get all numeric fields that were incremented/decremented, call
  8733. // AddedFields().
  8734. func (m *ContactMutation) Fields() []string {
  8735. fields := make([]string, 0, 20)
  8736. if m.created_at != nil {
  8737. fields = append(fields, contact.FieldCreatedAt)
  8738. }
  8739. if m.updated_at != nil {
  8740. fields = append(fields, contact.FieldUpdatedAt)
  8741. }
  8742. if m.status != nil {
  8743. fields = append(fields, contact.FieldStatus)
  8744. }
  8745. if m.deleted_at != nil {
  8746. fields = append(fields, contact.FieldDeletedAt)
  8747. }
  8748. if m.wx_wxid != nil {
  8749. fields = append(fields, contact.FieldWxWxid)
  8750. }
  8751. if m._type != nil {
  8752. fields = append(fields, contact.FieldType)
  8753. }
  8754. if m.wxid != nil {
  8755. fields = append(fields, contact.FieldWxid)
  8756. }
  8757. if m.account != nil {
  8758. fields = append(fields, contact.FieldAccount)
  8759. }
  8760. if m.nickname != nil {
  8761. fields = append(fields, contact.FieldNickname)
  8762. }
  8763. if m.markname != nil {
  8764. fields = append(fields, contact.FieldMarkname)
  8765. }
  8766. if m.headimg != nil {
  8767. fields = append(fields, contact.FieldHeadimg)
  8768. }
  8769. if m.sex != nil {
  8770. fields = append(fields, contact.FieldSex)
  8771. }
  8772. if m.starrole != nil {
  8773. fields = append(fields, contact.FieldStarrole)
  8774. }
  8775. if m.dontseeit != nil {
  8776. fields = append(fields, contact.FieldDontseeit)
  8777. }
  8778. if m.dontseeme != nil {
  8779. fields = append(fields, contact.FieldDontseeme)
  8780. }
  8781. if m.lag != nil {
  8782. fields = append(fields, contact.FieldLag)
  8783. }
  8784. if m.gid != nil {
  8785. fields = append(fields, contact.FieldGid)
  8786. }
  8787. if m.gname != nil {
  8788. fields = append(fields, contact.FieldGname)
  8789. }
  8790. if m.v3 != nil {
  8791. fields = append(fields, contact.FieldV3)
  8792. }
  8793. if m.organization_id != nil {
  8794. fields = append(fields, contact.FieldOrganizationID)
  8795. }
  8796. return fields
  8797. }
  8798. // Field returns the value of a field with the given name. The second boolean
  8799. // return value indicates that this field was not set, or was not defined in the
  8800. // schema.
  8801. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8802. switch name {
  8803. case contact.FieldCreatedAt:
  8804. return m.CreatedAt()
  8805. case contact.FieldUpdatedAt:
  8806. return m.UpdatedAt()
  8807. case contact.FieldStatus:
  8808. return m.Status()
  8809. case contact.FieldDeletedAt:
  8810. return m.DeletedAt()
  8811. case contact.FieldWxWxid:
  8812. return m.WxWxid()
  8813. case contact.FieldType:
  8814. return m.GetType()
  8815. case contact.FieldWxid:
  8816. return m.Wxid()
  8817. case contact.FieldAccount:
  8818. return m.Account()
  8819. case contact.FieldNickname:
  8820. return m.Nickname()
  8821. case contact.FieldMarkname:
  8822. return m.Markname()
  8823. case contact.FieldHeadimg:
  8824. return m.Headimg()
  8825. case contact.FieldSex:
  8826. return m.Sex()
  8827. case contact.FieldStarrole:
  8828. return m.Starrole()
  8829. case contact.FieldDontseeit:
  8830. return m.Dontseeit()
  8831. case contact.FieldDontseeme:
  8832. return m.Dontseeme()
  8833. case contact.FieldLag:
  8834. return m.Lag()
  8835. case contact.FieldGid:
  8836. return m.Gid()
  8837. case contact.FieldGname:
  8838. return m.Gname()
  8839. case contact.FieldV3:
  8840. return m.V3()
  8841. case contact.FieldOrganizationID:
  8842. return m.OrganizationID()
  8843. }
  8844. return nil, false
  8845. }
  8846. // OldField returns the old value of the field from the database. An error is
  8847. // returned if the mutation operation is not UpdateOne, or the query to the
  8848. // database failed.
  8849. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8850. switch name {
  8851. case contact.FieldCreatedAt:
  8852. return m.OldCreatedAt(ctx)
  8853. case contact.FieldUpdatedAt:
  8854. return m.OldUpdatedAt(ctx)
  8855. case contact.FieldStatus:
  8856. return m.OldStatus(ctx)
  8857. case contact.FieldDeletedAt:
  8858. return m.OldDeletedAt(ctx)
  8859. case contact.FieldWxWxid:
  8860. return m.OldWxWxid(ctx)
  8861. case contact.FieldType:
  8862. return m.OldType(ctx)
  8863. case contact.FieldWxid:
  8864. return m.OldWxid(ctx)
  8865. case contact.FieldAccount:
  8866. return m.OldAccount(ctx)
  8867. case contact.FieldNickname:
  8868. return m.OldNickname(ctx)
  8869. case contact.FieldMarkname:
  8870. return m.OldMarkname(ctx)
  8871. case contact.FieldHeadimg:
  8872. return m.OldHeadimg(ctx)
  8873. case contact.FieldSex:
  8874. return m.OldSex(ctx)
  8875. case contact.FieldStarrole:
  8876. return m.OldStarrole(ctx)
  8877. case contact.FieldDontseeit:
  8878. return m.OldDontseeit(ctx)
  8879. case contact.FieldDontseeme:
  8880. return m.OldDontseeme(ctx)
  8881. case contact.FieldLag:
  8882. return m.OldLag(ctx)
  8883. case contact.FieldGid:
  8884. return m.OldGid(ctx)
  8885. case contact.FieldGname:
  8886. return m.OldGname(ctx)
  8887. case contact.FieldV3:
  8888. return m.OldV3(ctx)
  8889. case contact.FieldOrganizationID:
  8890. return m.OldOrganizationID(ctx)
  8891. }
  8892. return nil, fmt.Errorf("unknown Contact field %s", name)
  8893. }
  8894. // SetField sets the value of a field with the given name. It returns an error if
  8895. // the field is not defined in the schema, or if the type mismatched the field
  8896. // type.
  8897. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8898. switch name {
  8899. case contact.FieldCreatedAt:
  8900. v, ok := value.(time.Time)
  8901. if !ok {
  8902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8903. }
  8904. m.SetCreatedAt(v)
  8905. return nil
  8906. case contact.FieldUpdatedAt:
  8907. v, ok := value.(time.Time)
  8908. if !ok {
  8909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8910. }
  8911. m.SetUpdatedAt(v)
  8912. return nil
  8913. case contact.FieldStatus:
  8914. v, ok := value.(uint8)
  8915. if !ok {
  8916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8917. }
  8918. m.SetStatus(v)
  8919. return nil
  8920. case contact.FieldDeletedAt:
  8921. v, ok := value.(time.Time)
  8922. if !ok {
  8923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8924. }
  8925. m.SetDeletedAt(v)
  8926. return nil
  8927. case contact.FieldWxWxid:
  8928. v, ok := value.(string)
  8929. if !ok {
  8930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8931. }
  8932. m.SetWxWxid(v)
  8933. return nil
  8934. case contact.FieldType:
  8935. v, ok := value.(int)
  8936. if !ok {
  8937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8938. }
  8939. m.SetType(v)
  8940. return nil
  8941. case contact.FieldWxid:
  8942. v, ok := value.(string)
  8943. if !ok {
  8944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8945. }
  8946. m.SetWxid(v)
  8947. return nil
  8948. case contact.FieldAccount:
  8949. v, ok := value.(string)
  8950. if !ok {
  8951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8952. }
  8953. m.SetAccount(v)
  8954. return nil
  8955. case contact.FieldNickname:
  8956. v, ok := value.(string)
  8957. if !ok {
  8958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8959. }
  8960. m.SetNickname(v)
  8961. return nil
  8962. case contact.FieldMarkname:
  8963. v, ok := value.(string)
  8964. if !ok {
  8965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8966. }
  8967. m.SetMarkname(v)
  8968. return nil
  8969. case contact.FieldHeadimg:
  8970. v, ok := value.(string)
  8971. if !ok {
  8972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8973. }
  8974. m.SetHeadimg(v)
  8975. return nil
  8976. case contact.FieldSex:
  8977. v, ok := value.(int)
  8978. if !ok {
  8979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8980. }
  8981. m.SetSex(v)
  8982. return nil
  8983. case contact.FieldStarrole:
  8984. v, ok := value.(string)
  8985. if !ok {
  8986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8987. }
  8988. m.SetStarrole(v)
  8989. return nil
  8990. case contact.FieldDontseeit:
  8991. v, ok := value.(int)
  8992. if !ok {
  8993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8994. }
  8995. m.SetDontseeit(v)
  8996. return nil
  8997. case contact.FieldDontseeme:
  8998. v, ok := value.(int)
  8999. if !ok {
  9000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9001. }
  9002. m.SetDontseeme(v)
  9003. return nil
  9004. case contact.FieldLag:
  9005. v, ok := value.(string)
  9006. if !ok {
  9007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9008. }
  9009. m.SetLag(v)
  9010. return nil
  9011. case contact.FieldGid:
  9012. v, ok := value.(string)
  9013. if !ok {
  9014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9015. }
  9016. m.SetGid(v)
  9017. return nil
  9018. case contact.FieldGname:
  9019. v, ok := value.(string)
  9020. if !ok {
  9021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9022. }
  9023. m.SetGname(v)
  9024. return nil
  9025. case contact.FieldV3:
  9026. v, ok := value.(string)
  9027. if !ok {
  9028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9029. }
  9030. m.SetV3(v)
  9031. return nil
  9032. case contact.FieldOrganizationID:
  9033. v, ok := value.(uint64)
  9034. if !ok {
  9035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9036. }
  9037. m.SetOrganizationID(v)
  9038. return nil
  9039. }
  9040. return fmt.Errorf("unknown Contact field %s", name)
  9041. }
  9042. // AddedFields returns all numeric fields that were incremented/decremented during
  9043. // this mutation.
  9044. func (m *ContactMutation) AddedFields() []string {
  9045. var fields []string
  9046. if m.addstatus != nil {
  9047. fields = append(fields, contact.FieldStatus)
  9048. }
  9049. if m.add_type != nil {
  9050. fields = append(fields, contact.FieldType)
  9051. }
  9052. if m.addsex != nil {
  9053. fields = append(fields, contact.FieldSex)
  9054. }
  9055. if m.adddontseeit != nil {
  9056. fields = append(fields, contact.FieldDontseeit)
  9057. }
  9058. if m.adddontseeme != nil {
  9059. fields = append(fields, contact.FieldDontseeme)
  9060. }
  9061. if m.addorganization_id != nil {
  9062. fields = append(fields, contact.FieldOrganizationID)
  9063. }
  9064. return fields
  9065. }
  9066. // AddedField returns the numeric value that was incremented/decremented on a field
  9067. // with the given name. The second boolean return value indicates that this field
  9068. // was not set, or was not defined in the schema.
  9069. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  9070. switch name {
  9071. case contact.FieldStatus:
  9072. return m.AddedStatus()
  9073. case contact.FieldType:
  9074. return m.AddedType()
  9075. case contact.FieldSex:
  9076. return m.AddedSex()
  9077. case contact.FieldDontseeit:
  9078. return m.AddedDontseeit()
  9079. case contact.FieldDontseeme:
  9080. return m.AddedDontseeme()
  9081. case contact.FieldOrganizationID:
  9082. return m.AddedOrganizationID()
  9083. }
  9084. return nil, false
  9085. }
  9086. // AddField adds the value to the field with the given name. It returns an error if
  9087. // the field is not defined in the schema, or if the type mismatched the field
  9088. // type.
  9089. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9090. switch name {
  9091. case contact.FieldStatus:
  9092. v, ok := value.(int8)
  9093. if !ok {
  9094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9095. }
  9096. m.AddStatus(v)
  9097. return nil
  9098. case contact.FieldType:
  9099. v, ok := value.(int)
  9100. if !ok {
  9101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9102. }
  9103. m.AddType(v)
  9104. return nil
  9105. case contact.FieldSex:
  9106. v, ok := value.(int)
  9107. if !ok {
  9108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9109. }
  9110. m.AddSex(v)
  9111. return nil
  9112. case contact.FieldDontseeit:
  9113. v, ok := value.(int)
  9114. if !ok {
  9115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9116. }
  9117. m.AddDontseeit(v)
  9118. return nil
  9119. case contact.FieldDontseeme:
  9120. v, ok := value.(int)
  9121. if !ok {
  9122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9123. }
  9124. m.AddDontseeme(v)
  9125. return nil
  9126. case contact.FieldOrganizationID:
  9127. v, ok := value.(int64)
  9128. if !ok {
  9129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9130. }
  9131. m.AddOrganizationID(v)
  9132. return nil
  9133. }
  9134. return fmt.Errorf("unknown Contact numeric field %s", name)
  9135. }
  9136. // ClearedFields returns all nullable fields that were cleared during this
  9137. // mutation.
  9138. func (m *ContactMutation) ClearedFields() []string {
  9139. var fields []string
  9140. if m.FieldCleared(contact.FieldStatus) {
  9141. fields = append(fields, contact.FieldStatus)
  9142. }
  9143. if m.FieldCleared(contact.FieldDeletedAt) {
  9144. fields = append(fields, contact.FieldDeletedAt)
  9145. }
  9146. if m.FieldCleared(contact.FieldType) {
  9147. fields = append(fields, contact.FieldType)
  9148. }
  9149. if m.FieldCleared(contact.FieldOrganizationID) {
  9150. fields = append(fields, contact.FieldOrganizationID)
  9151. }
  9152. return fields
  9153. }
  9154. // FieldCleared returns a boolean indicating if a field with the given name was
  9155. // cleared in this mutation.
  9156. func (m *ContactMutation) FieldCleared(name string) bool {
  9157. _, ok := m.clearedFields[name]
  9158. return ok
  9159. }
  9160. // ClearField clears the value of the field with the given name. It returns an
  9161. // error if the field is not defined in the schema.
  9162. func (m *ContactMutation) ClearField(name string) error {
  9163. switch name {
  9164. case contact.FieldStatus:
  9165. m.ClearStatus()
  9166. return nil
  9167. case contact.FieldDeletedAt:
  9168. m.ClearDeletedAt()
  9169. return nil
  9170. case contact.FieldType:
  9171. m.ClearType()
  9172. return nil
  9173. case contact.FieldOrganizationID:
  9174. m.ClearOrganizationID()
  9175. return nil
  9176. }
  9177. return fmt.Errorf("unknown Contact nullable field %s", name)
  9178. }
  9179. // ResetField resets all changes in the mutation for the field with the given name.
  9180. // It returns an error if the field is not defined in the schema.
  9181. func (m *ContactMutation) ResetField(name string) error {
  9182. switch name {
  9183. case contact.FieldCreatedAt:
  9184. m.ResetCreatedAt()
  9185. return nil
  9186. case contact.FieldUpdatedAt:
  9187. m.ResetUpdatedAt()
  9188. return nil
  9189. case contact.FieldStatus:
  9190. m.ResetStatus()
  9191. return nil
  9192. case contact.FieldDeletedAt:
  9193. m.ResetDeletedAt()
  9194. return nil
  9195. case contact.FieldWxWxid:
  9196. m.ResetWxWxid()
  9197. return nil
  9198. case contact.FieldType:
  9199. m.ResetType()
  9200. return nil
  9201. case contact.FieldWxid:
  9202. m.ResetWxid()
  9203. return nil
  9204. case contact.FieldAccount:
  9205. m.ResetAccount()
  9206. return nil
  9207. case contact.FieldNickname:
  9208. m.ResetNickname()
  9209. return nil
  9210. case contact.FieldMarkname:
  9211. m.ResetMarkname()
  9212. return nil
  9213. case contact.FieldHeadimg:
  9214. m.ResetHeadimg()
  9215. return nil
  9216. case contact.FieldSex:
  9217. m.ResetSex()
  9218. return nil
  9219. case contact.FieldStarrole:
  9220. m.ResetStarrole()
  9221. return nil
  9222. case contact.FieldDontseeit:
  9223. m.ResetDontseeit()
  9224. return nil
  9225. case contact.FieldDontseeme:
  9226. m.ResetDontseeme()
  9227. return nil
  9228. case contact.FieldLag:
  9229. m.ResetLag()
  9230. return nil
  9231. case contact.FieldGid:
  9232. m.ResetGid()
  9233. return nil
  9234. case contact.FieldGname:
  9235. m.ResetGname()
  9236. return nil
  9237. case contact.FieldV3:
  9238. m.ResetV3()
  9239. return nil
  9240. case contact.FieldOrganizationID:
  9241. m.ResetOrganizationID()
  9242. return nil
  9243. }
  9244. return fmt.Errorf("unknown Contact field %s", name)
  9245. }
  9246. // AddedEdges returns all edge names that were set/added in this mutation.
  9247. func (m *ContactMutation) AddedEdges() []string {
  9248. edges := make([]string, 0, 2)
  9249. if m.contact_relationships != nil {
  9250. edges = append(edges, contact.EdgeContactRelationships)
  9251. }
  9252. if m.contact_messages != nil {
  9253. edges = append(edges, contact.EdgeContactMessages)
  9254. }
  9255. return edges
  9256. }
  9257. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9258. // name in this mutation.
  9259. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9260. switch name {
  9261. case contact.EdgeContactRelationships:
  9262. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9263. for id := range m.contact_relationships {
  9264. ids = append(ids, id)
  9265. }
  9266. return ids
  9267. case contact.EdgeContactMessages:
  9268. ids := make([]ent.Value, 0, len(m.contact_messages))
  9269. for id := range m.contact_messages {
  9270. ids = append(ids, id)
  9271. }
  9272. return ids
  9273. }
  9274. return nil
  9275. }
  9276. // RemovedEdges returns all edge names that were removed in this mutation.
  9277. func (m *ContactMutation) RemovedEdges() []string {
  9278. edges := make([]string, 0, 2)
  9279. if m.removedcontact_relationships != nil {
  9280. edges = append(edges, contact.EdgeContactRelationships)
  9281. }
  9282. if m.removedcontact_messages != nil {
  9283. edges = append(edges, contact.EdgeContactMessages)
  9284. }
  9285. return edges
  9286. }
  9287. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9288. // the given name in this mutation.
  9289. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9290. switch name {
  9291. case contact.EdgeContactRelationships:
  9292. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9293. for id := range m.removedcontact_relationships {
  9294. ids = append(ids, id)
  9295. }
  9296. return ids
  9297. case contact.EdgeContactMessages:
  9298. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9299. for id := range m.removedcontact_messages {
  9300. ids = append(ids, id)
  9301. }
  9302. return ids
  9303. }
  9304. return nil
  9305. }
  9306. // ClearedEdges returns all edge names that were cleared in this mutation.
  9307. func (m *ContactMutation) ClearedEdges() []string {
  9308. edges := make([]string, 0, 2)
  9309. if m.clearedcontact_relationships {
  9310. edges = append(edges, contact.EdgeContactRelationships)
  9311. }
  9312. if m.clearedcontact_messages {
  9313. edges = append(edges, contact.EdgeContactMessages)
  9314. }
  9315. return edges
  9316. }
  9317. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9318. // was cleared in this mutation.
  9319. func (m *ContactMutation) EdgeCleared(name string) bool {
  9320. switch name {
  9321. case contact.EdgeContactRelationships:
  9322. return m.clearedcontact_relationships
  9323. case contact.EdgeContactMessages:
  9324. return m.clearedcontact_messages
  9325. }
  9326. return false
  9327. }
  9328. // ClearEdge clears the value of the edge with the given name. It returns an error
  9329. // if that edge is not defined in the schema.
  9330. func (m *ContactMutation) ClearEdge(name string) error {
  9331. switch name {
  9332. }
  9333. return fmt.Errorf("unknown Contact unique edge %s", name)
  9334. }
  9335. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9336. // It returns an error if the edge is not defined in the schema.
  9337. func (m *ContactMutation) ResetEdge(name string) error {
  9338. switch name {
  9339. case contact.EdgeContactRelationships:
  9340. m.ResetContactRelationships()
  9341. return nil
  9342. case contact.EdgeContactMessages:
  9343. m.ResetContactMessages()
  9344. return nil
  9345. }
  9346. return fmt.Errorf("unknown Contact edge %s", name)
  9347. }
  9348. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  9349. type CreditBalanceMutation struct {
  9350. config
  9351. op Op
  9352. typ string
  9353. id *uint64
  9354. created_at *time.Time
  9355. updated_at *time.Time
  9356. deleted_at *time.Time
  9357. user_id *string
  9358. balance *float32
  9359. addbalance *float32
  9360. status *int
  9361. addstatus *int
  9362. organization_id *uint64
  9363. addorganization_id *int64
  9364. clearedFields map[string]struct{}
  9365. done bool
  9366. oldValue func(context.Context) (*CreditBalance, error)
  9367. predicates []predicate.CreditBalance
  9368. }
  9369. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  9370. // creditbalanceOption allows management of the mutation configuration using functional options.
  9371. type creditbalanceOption func(*CreditBalanceMutation)
  9372. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  9373. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  9374. m := &CreditBalanceMutation{
  9375. config: c,
  9376. op: op,
  9377. typ: TypeCreditBalance,
  9378. clearedFields: make(map[string]struct{}),
  9379. }
  9380. for _, opt := range opts {
  9381. opt(m)
  9382. }
  9383. return m
  9384. }
  9385. // withCreditBalanceID sets the ID field of the mutation.
  9386. func withCreditBalanceID(id uint64) creditbalanceOption {
  9387. return func(m *CreditBalanceMutation) {
  9388. var (
  9389. err error
  9390. once sync.Once
  9391. value *CreditBalance
  9392. )
  9393. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  9394. once.Do(func() {
  9395. if m.done {
  9396. err = errors.New("querying old values post mutation is not allowed")
  9397. } else {
  9398. value, err = m.Client().CreditBalance.Get(ctx, id)
  9399. }
  9400. })
  9401. return value, err
  9402. }
  9403. m.id = &id
  9404. }
  9405. }
  9406. // withCreditBalance sets the old CreditBalance of the mutation.
  9407. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  9408. return func(m *CreditBalanceMutation) {
  9409. m.oldValue = func(context.Context) (*CreditBalance, error) {
  9410. return node, nil
  9411. }
  9412. m.id = &node.ID
  9413. }
  9414. }
  9415. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9416. // executed in a transaction (ent.Tx), a transactional client is returned.
  9417. func (m CreditBalanceMutation) Client() *Client {
  9418. client := &Client{config: m.config}
  9419. client.init()
  9420. return client
  9421. }
  9422. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9423. // it returns an error otherwise.
  9424. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  9425. if _, ok := m.driver.(*txDriver); !ok {
  9426. return nil, errors.New("ent: mutation is not running in a transaction")
  9427. }
  9428. tx := &Tx{config: m.config}
  9429. tx.init()
  9430. return tx, nil
  9431. }
  9432. // SetID sets the value of the id field. Note that this
  9433. // operation is only accepted on creation of CreditBalance entities.
  9434. func (m *CreditBalanceMutation) SetID(id uint64) {
  9435. m.id = &id
  9436. }
  9437. // ID returns the ID value in the mutation. Note that the ID is only available
  9438. // if it was provided to the builder or after it was returned from the database.
  9439. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  9440. if m.id == nil {
  9441. return
  9442. }
  9443. return *m.id, true
  9444. }
  9445. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9446. // That means, if the mutation is applied within a transaction with an isolation level such
  9447. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9448. // or updated by the mutation.
  9449. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  9450. switch {
  9451. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9452. id, exists := m.ID()
  9453. if exists {
  9454. return []uint64{id}, nil
  9455. }
  9456. fallthrough
  9457. case m.op.Is(OpUpdate | OpDelete):
  9458. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  9459. default:
  9460. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9461. }
  9462. }
  9463. // SetCreatedAt sets the "created_at" field.
  9464. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  9465. m.created_at = &t
  9466. }
  9467. // CreatedAt returns the value of the "created_at" field in the mutation.
  9468. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  9469. v := m.created_at
  9470. if v == nil {
  9471. return
  9472. }
  9473. return *v, true
  9474. }
  9475. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  9476. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9478. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9479. if !m.op.Is(OpUpdateOne) {
  9480. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9481. }
  9482. if m.id == nil || m.oldValue == nil {
  9483. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9484. }
  9485. oldValue, err := m.oldValue(ctx)
  9486. if err != nil {
  9487. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9488. }
  9489. return oldValue.CreatedAt, nil
  9490. }
  9491. // ResetCreatedAt resets all changes to the "created_at" field.
  9492. func (m *CreditBalanceMutation) ResetCreatedAt() {
  9493. m.created_at = nil
  9494. }
  9495. // SetUpdatedAt sets the "updated_at" field.
  9496. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  9497. m.updated_at = &t
  9498. }
  9499. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9500. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  9501. v := m.updated_at
  9502. if v == nil {
  9503. return
  9504. }
  9505. return *v, true
  9506. }
  9507. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  9508. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9510. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9511. if !m.op.Is(OpUpdateOne) {
  9512. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9513. }
  9514. if m.id == nil || m.oldValue == nil {
  9515. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9516. }
  9517. oldValue, err := m.oldValue(ctx)
  9518. if err != nil {
  9519. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9520. }
  9521. return oldValue.UpdatedAt, nil
  9522. }
  9523. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9524. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  9525. m.updated_at = nil
  9526. }
  9527. // SetDeletedAt sets the "deleted_at" field.
  9528. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  9529. m.deleted_at = &t
  9530. }
  9531. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9532. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  9533. v := m.deleted_at
  9534. if v == nil {
  9535. return
  9536. }
  9537. return *v, true
  9538. }
  9539. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  9540. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9542. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9543. if !m.op.Is(OpUpdateOne) {
  9544. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9545. }
  9546. if m.id == nil || m.oldValue == nil {
  9547. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9548. }
  9549. oldValue, err := m.oldValue(ctx)
  9550. if err != nil {
  9551. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9552. }
  9553. return oldValue.DeletedAt, nil
  9554. }
  9555. // ClearDeletedAt clears the value of the "deleted_at" field.
  9556. func (m *CreditBalanceMutation) ClearDeletedAt() {
  9557. m.deleted_at = nil
  9558. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  9559. }
  9560. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9561. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  9562. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  9563. return ok
  9564. }
  9565. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9566. func (m *CreditBalanceMutation) ResetDeletedAt() {
  9567. m.deleted_at = nil
  9568. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  9569. }
  9570. // SetUserID sets the "user_id" field.
  9571. func (m *CreditBalanceMutation) SetUserID(s string) {
  9572. m.user_id = &s
  9573. }
  9574. // UserID returns the value of the "user_id" field in the mutation.
  9575. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  9576. v := m.user_id
  9577. if v == nil {
  9578. return
  9579. }
  9580. return *v, true
  9581. }
  9582. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  9583. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9585. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  9586. if !m.op.Is(OpUpdateOne) {
  9587. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9588. }
  9589. if m.id == nil || m.oldValue == nil {
  9590. return v, errors.New("OldUserID requires an ID field in the mutation")
  9591. }
  9592. oldValue, err := m.oldValue(ctx)
  9593. if err != nil {
  9594. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9595. }
  9596. return oldValue.UserID, nil
  9597. }
  9598. // ClearUserID clears the value of the "user_id" field.
  9599. func (m *CreditBalanceMutation) ClearUserID() {
  9600. m.user_id = nil
  9601. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  9602. }
  9603. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  9604. func (m *CreditBalanceMutation) UserIDCleared() bool {
  9605. _, ok := m.clearedFields[creditbalance.FieldUserID]
  9606. return ok
  9607. }
  9608. // ResetUserID resets all changes to the "user_id" field.
  9609. func (m *CreditBalanceMutation) ResetUserID() {
  9610. m.user_id = nil
  9611. delete(m.clearedFields, creditbalance.FieldUserID)
  9612. }
  9613. // SetBalance sets the "balance" field.
  9614. func (m *CreditBalanceMutation) SetBalance(f float32) {
  9615. m.balance = &f
  9616. m.addbalance = nil
  9617. }
  9618. // Balance returns the value of the "balance" field in the mutation.
  9619. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  9620. v := m.balance
  9621. if v == nil {
  9622. return
  9623. }
  9624. return *v, true
  9625. }
  9626. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  9627. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9629. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  9630. if !m.op.Is(OpUpdateOne) {
  9631. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  9632. }
  9633. if m.id == nil || m.oldValue == nil {
  9634. return v, errors.New("OldBalance requires an ID field in the mutation")
  9635. }
  9636. oldValue, err := m.oldValue(ctx)
  9637. if err != nil {
  9638. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  9639. }
  9640. return oldValue.Balance, nil
  9641. }
  9642. // AddBalance adds f to the "balance" field.
  9643. func (m *CreditBalanceMutation) AddBalance(f float32) {
  9644. if m.addbalance != nil {
  9645. *m.addbalance += f
  9646. } else {
  9647. m.addbalance = &f
  9648. }
  9649. }
  9650. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  9651. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  9652. v := m.addbalance
  9653. if v == nil {
  9654. return
  9655. }
  9656. return *v, true
  9657. }
  9658. // ResetBalance resets all changes to the "balance" field.
  9659. func (m *CreditBalanceMutation) ResetBalance() {
  9660. m.balance = nil
  9661. m.addbalance = nil
  9662. }
  9663. // SetStatus sets the "status" field.
  9664. func (m *CreditBalanceMutation) SetStatus(i int) {
  9665. m.status = &i
  9666. m.addstatus = nil
  9667. }
  9668. // Status returns the value of the "status" field in the mutation.
  9669. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  9670. v := m.status
  9671. if v == nil {
  9672. return
  9673. }
  9674. return *v, true
  9675. }
  9676. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  9677. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9679. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  9680. if !m.op.Is(OpUpdateOne) {
  9681. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9682. }
  9683. if m.id == nil || m.oldValue == nil {
  9684. return v, errors.New("OldStatus requires an ID field in the mutation")
  9685. }
  9686. oldValue, err := m.oldValue(ctx)
  9687. if err != nil {
  9688. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9689. }
  9690. return oldValue.Status, nil
  9691. }
  9692. // AddStatus adds i to the "status" field.
  9693. func (m *CreditBalanceMutation) AddStatus(i int) {
  9694. if m.addstatus != nil {
  9695. *m.addstatus += i
  9696. } else {
  9697. m.addstatus = &i
  9698. }
  9699. }
  9700. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9701. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  9702. v := m.addstatus
  9703. if v == nil {
  9704. return
  9705. }
  9706. return *v, true
  9707. }
  9708. // ClearStatus clears the value of the "status" field.
  9709. func (m *CreditBalanceMutation) ClearStatus() {
  9710. m.status = nil
  9711. m.addstatus = nil
  9712. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  9713. }
  9714. // StatusCleared returns if the "status" field was cleared in this mutation.
  9715. func (m *CreditBalanceMutation) StatusCleared() bool {
  9716. _, ok := m.clearedFields[creditbalance.FieldStatus]
  9717. return ok
  9718. }
  9719. // ResetStatus resets all changes to the "status" field.
  9720. func (m *CreditBalanceMutation) ResetStatus() {
  9721. m.status = nil
  9722. m.addstatus = nil
  9723. delete(m.clearedFields, creditbalance.FieldStatus)
  9724. }
  9725. // SetOrganizationID sets the "organization_id" field.
  9726. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  9727. m.organization_id = &u
  9728. m.addorganization_id = nil
  9729. }
  9730. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9731. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  9732. v := m.organization_id
  9733. if v == nil {
  9734. return
  9735. }
  9736. return *v, true
  9737. }
  9738. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  9739. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9741. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9742. if !m.op.Is(OpUpdateOne) {
  9743. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9744. }
  9745. if m.id == nil || m.oldValue == nil {
  9746. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9747. }
  9748. oldValue, err := m.oldValue(ctx)
  9749. if err != nil {
  9750. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9751. }
  9752. return oldValue.OrganizationID, nil
  9753. }
  9754. // AddOrganizationID adds u to the "organization_id" field.
  9755. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  9756. if m.addorganization_id != nil {
  9757. *m.addorganization_id += u
  9758. } else {
  9759. m.addorganization_id = &u
  9760. }
  9761. }
  9762. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9763. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  9764. v := m.addorganization_id
  9765. if v == nil {
  9766. return
  9767. }
  9768. return *v, true
  9769. }
  9770. // ClearOrganizationID clears the value of the "organization_id" field.
  9771. func (m *CreditBalanceMutation) ClearOrganizationID() {
  9772. m.organization_id = nil
  9773. m.addorganization_id = nil
  9774. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  9775. }
  9776. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9777. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  9778. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  9779. return ok
  9780. }
  9781. // ResetOrganizationID resets all changes to the "organization_id" field.
  9782. func (m *CreditBalanceMutation) ResetOrganizationID() {
  9783. m.organization_id = nil
  9784. m.addorganization_id = nil
  9785. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  9786. }
  9787. // Where appends a list predicates to the CreditBalanceMutation builder.
  9788. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  9789. m.predicates = append(m.predicates, ps...)
  9790. }
  9791. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  9792. // users can use type-assertion to append predicates that do not depend on any generated package.
  9793. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  9794. p := make([]predicate.CreditBalance, len(ps))
  9795. for i := range ps {
  9796. p[i] = ps[i]
  9797. }
  9798. m.Where(p...)
  9799. }
  9800. // Op returns the operation name.
  9801. func (m *CreditBalanceMutation) Op() Op {
  9802. return m.op
  9803. }
  9804. // SetOp allows setting the mutation operation.
  9805. func (m *CreditBalanceMutation) SetOp(op Op) {
  9806. m.op = op
  9807. }
  9808. // Type returns the node type of this mutation (CreditBalance).
  9809. func (m *CreditBalanceMutation) Type() string {
  9810. return m.typ
  9811. }
  9812. // Fields returns all fields that were changed during this mutation. Note that in
  9813. // order to get all numeric fields that were incremented/decremented, call
  9814. // AddedFields().
  9815. func (m *CreditBalanceMutation) Fields() []string {
  9816. fields := make([]string, 0, 7)
  9817. if m.created_at != nil {
  9818. fields = append(fields, creditbalance.FieldCreatedAt)
  9819. }
  9820. if m.updated_at != nil {
  9821. fields = append(fields, creditbalance.FieldUpdatedAt)
  9822. }
  9823. if m.deleted_at != nil {
  9824. fields = append(fields, creditbalance.FieldDeletedAt)
  9825. }
  9826. if m.user_id != nil {
  9827. fields = append(fields, creditbalance.FieldUserID)
  9828. }
  9829. if m.balance != nil {
  9830. fields = append(fields, creditbalance.FieldBalance)
  9831. }
  9832. if m.status != nil {
  9833. fields = append(fields, creditbalance.FieldStatus)
  9834. }
  9835. if m.organization_id != nil {
  9836. fields = append(fields, creditbalance.FieldOrganizationID)
  9837. }
  9838. return fields
  9839. }
  9840. // Field returns the value of a field with the given name. The second boolean
  9841. // return value indicates that this field was not set, or was not defined in the
  9842. // schema.
  9843. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  9844. switch name {
  9845. case creditbalance.FieldCreatedAt:
  9846. return m.CreatedAt()
  9847. case creditbalance.FieldUpdatedAt:
  9848. return m.UpdatedAt()
  9849. case creditbalance.FieldDeletedAt:
  9850. return m.DeletedAt()
  9851. case creditbalance.FieldUserID:
  9852. return m.UserID()
  9853. case creditbalance.FieldBalance:
  9854. return m.Balance()
  9855. case creditbalance.FieldStatus:
  9856. return m.Status()
  9857. case creditbalance.FieldOrganizationID:
  9858. return m.OrganizationID()
  9859. }
  9860. return nil, false
  9861. }
  9862. // OldField returns the old value of the field from the database. An error is
  9863. // returned if the mutation operation is not UpdateOne, or the query to the
  9864. // database failed.
  9865. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9866. switch name {
  9867. case creditbalance.FieldCreatedAt:
  9868. return m.OldCreatedAt(ctx)
  9869. case creditbalance.FieldUpdatedAt:
  9870. return m.OldUpdatedAt(ctx)
  9871. case creditbalance.FieldDeletedAt:
  9872. return m.OldDeletedAt(ctx)
  9873. case creditbalance.FieldUserID:
  9874. return m.OldUserID(ctx)
  9875. case creditbalance.FieldBalance:
  9876. return m.OldBalance(ctx)
  9877. case creditbalance.FieldStatus:
  9878. return m.OldStatus(ctx)
  9879. case creditbalance.FieldOrganizationID:
  9880. return m.OldOrganizationID(ctx)
  9881. }
  9882. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  9883. }
  9884. // SetField sets the value of a field with the given name. It returns an error if
  9885. // the field is not defined in the schema, or if the type mismatched the field
  9886. // type.
  9887. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  9888. switch name {
  9889. case creditbalance.FieldCreatedAt:
  9890. v, ok := value.(time.Time)
  9891. if !ok {
  9892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9893. }
  9894. m.SetCreatedAt(v)
  9895. return nil
  9896. case creditbalance.FieldUpdatedAt:
  9897. v, ok := value.(time.Time)
  9898. if !ok {
  9899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9900. }
  9901. m.SetUpdatedAt(v)
  9902. return nil
  9903. case creditbalance.FieldDeletedAt:
  9904. v, ok := value.(time.Time)
  9905. if !ok {
  9906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9907. }
  9908. m.SetDeletedAt(v)
  9909. return nil
  9910. case creditbalance.FieldUserID:
  9911. v, ok := value.(string)
  9912. if !ok {
  9913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9914. }
  9915. m.SetUserID(v)
  9916. return nil
  9917. case creditbalance.FieldBalance:
  9918. v, ok := value.(float32)
  9919. if !ok {
  9920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9921. }
  9922. m.SetBalance(v)
  9923. return nil
  9924. case creditbalance.FieldStatus:
  9925. v, ok := value.(int)
  9926. if !ok {
  9927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9928. }
  9929. m.SetStatus(v)
  9930. return nil
  9931. case creditbalance.FieldOrganizationID:
  9932. v, ok := value.(uint64)
  9933. if !ok {
  9934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9935. }
  9936. m.SetOrganizationID(v)
  9937. return nil
  9938. }
  9939. return fmt.Errorf("unknown CreditBalance field %s", name)
  9940. }
  9941. // AddedFields returns all numeric fields that were incremented/decremented during
  9942. // this mutation.
  9943. func (m *CreditBalanceMutation) AddedFields() []string {
  9944. var fields []string
  9945. if m.addbalance != nil {
  9946. fields = append(fields, creditbalance.FieldBalance)
  9947. }
  9948. if m.addstatus != nil {
  9949. fields = append(fields, creditbalance.FieldStatus)
  9950. }
  9951. if m.addorganization_id != nil {
  9952. fields = append(fields, creditbalance.FieldOrganizationID)
  9953. }
  9954. return fields
  9955. }
  9956. // AddedField returns the numeric value that was incremented/decremented on a field
  9957. // with the given name. The second boolean return value indicates that this field
  9958. // was not set, or was not defined in the schema.
  9959. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  9960. switch name {
  9961. case creditbalance.FieldBalance:
  9962. return m.AddedBalance()
  9963. case creditbalance.FieldStatus:
  9964. return m.AddedStatus()
  9965. case creditbalance.FieldOrganizationID:
  9966. return m.AddedOrganizationID()
  9967. }
  9968. return nil, false
  9969. }
  9970. // AddField adds the value to the field with the given name. It returns an error if
  9971. // the field is not defined in the schema, or if the type mismatched the field
  9972. // type.
  9973. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  9974. switch name {
  9975. case creditbalance.FieldBalance:
  9976. v, ok := value.(float32)
  9977. if !ok {
  9978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9979. }
  9980. m.AddBalance(v)
  9981. return nil
  9982. case creditbalance.FieldStatus:
  9983. v, ok := value.(int)
  9984. if !ok {
  9985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9986. }
  9987. m.AddStatus(v)
  9988. return nil
  9989. case creditbalance.FieldOrganizationID:
  9990. v, ok := value.(int64)
  9991. if !ok {
  9992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9993. }
  9994. m.AddOrganizationID(v)
  9995. return nil
  9996. }
  9997. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  9998. }
  9999. // ClearedFields returns all nullable fields that were cleared during this
  10000. // mutation.
  10001. func (m *CreditBalanceMutation) ClearedFields() []string {
  10002. var fields []string
  10003. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  10004. fields = append(fields, creditbalance.FieldDeletedAt)
  10005. }
  10006. if m.FieldCleared(creditbalance.FieldUserID) {
  10007. fields = append(fields, creditbalance.FieldUserID)
  10008. }
  10009. if m.FieldCleared(creditbalance.FieldStatus) {
  10010. fields = append(fields, creditbalance.FieldStatus)
  10011. }
  10012. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  10013. fields = append(fields, creditbalance.FieldOrganizationID)
  10014. }
  10015. return fields
  10016. }
  10017. // FieldCleared returns a boolean indicating if a field with the given name was
  10018. // cleared in this mutation.
  10019. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  10020. _, ok := m.clearedFields[name]
  10021. return ok
  10022. }
  10023. // ClearField clears the value of the field with the given name. It returns an
  10024. // error if the field is not defined in the schema.
  10025. func (m *CreditBalanceMutation) ClearField(name string) error {
  10026. switch name {
  10027. case creditbalance.FieldDeletedAt:
  10028. m.ClearDeletedAt()
  10029. return nil
  10030. case creditbalance.FieldUserID:
  10031. m.ClearUserID()
  10032. return nil
  10033. case creditbalance.FieldStatus:
  10034. m.ClearStatus()
  10035. return nil
  10036. case creditbalance.FieldOrganizationID:
  10037. m.ClearOrganizationID()
  10038. return nil
  10039. }
  10040. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  10041. }
  10042. // ResetField resets all changes in the mutation for the field with the given name.
  10043. // It returns an error if the field is not defined in the schema.
  10044. func (m *CreditBalanceMutation) ResetField(name string) error {
  10045. switch name {
  10046. case creditbalance.FieldCreatedAt:
  10047. m.ResetCreatedAt()
  10048. return nil
  10049. case creditbalance.FieldUpdatedAt:
  10050. m.ResetUpdatedAt()
  10051. return nil
  10052. case creditbalance.FieldDeletedAt:
  10053. m.ResetDeletedAt()
  10054. return nil
  10055. case creditbalance.FieldUserID:
  10056. m.ResetUserID()
  10057. return nil
  10058. case creditbalance.FieldBalance:
  10059. m.ResetBalance()
  10060. return nil
  10061. case creditbalance.FieldStatus:
  10062. m.ResetStatus()
  10063. return nil
  10064. case creditbalance.FieldOrganizationID:
  10065. m.ResetOrganizationID()
  10066. return nil
  10067. }
  10068. return fmt.Errorf("unknown CreditBalance field %s", name)
  10069. }
  10070. // AddedEdges returns all edge names that were set/added in this mutation.
  10071. func (m *CreditBalanceMutation) AddedEdges() []string {
  10072. edges := make([]string, 0, 0)
  10073. return edges
  10074. }
  10075. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10076. // name in this mutation.
  10077. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  10078. return nil
  10079. }
  10080. // RemovedEdges returns all edge names that were removed in this mutation.
  10081. func (m *CreditBalanceMutation) RemovedEdges() []string {
  10082. edges := make([]string, 0, 0)
  10083. return edges
  10084. }
  10085. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10086. // the given name in this mutation.
  10087. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  10088. return nil
  10089. }
  10090. // ClearedEdges returns all edge names that were cleared in this mutation.
  10091. func (m *CreditBalanceMutation) ClearedEdges() []string {
  10092. edges := make([]string, 0, 0)
  10093. return edges
  10094. }
  10095. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10096. // was cleared in this mutation.
  10097. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  10098. return false
  10099. }
  10100. // ClearEdge clears the value of the edge with the given name. It returns an error
  10101. // if that edge is not defined in the schema.
  10102. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  10103. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  10104. }
  10105. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10106. // It returns an error if the edge is not defined in the schema.
  10107. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  10108. return fmt.Errorf("unknown CreditBalance edge %s", name)
  10109. }
  10110. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  10111. type CreditUsageMutation struct {
  10112. config
  10113. op Op
  10114. typ string
  10115. id *uint64
  10116. created_at *time.Time
  10117. updated_at *time.Time
  10118. deleted_at *time.Time
  10119. user_id *string
  10120. number *float32
  10121. addnumber *float32
  10122. status *int
  10123. addstatus *int
  10124. ntype *int
  10125. addntype *int
  10126. table *string
  10127. organization_id *uint64
  10128. addorganization_id *int64
  10129. nid *uint64
  10130. addnid *int64
  10131. reason *string
  10132. operator *string
  10133. clearedFields map[string]struct{}
  10134. done bool
  10135. oldValue func(context.Context) (*CreditUsage, error)
  10136. predicates []predicate.CreditUsage
  10137. }
  10138. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  10139. // creditusageOption allows management of the mutation configuration using functional options.
  10140. type creditusageOption func(*CreditUsageMutation)
  10141. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  10142. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  10143. m := &CreditUsageMutation{
  10144. config: c,
  10145. op: op,
  10146. typ: TypeCreditUsage,
  10147. clearedFields: make(map[string]struct{}),
  10148. }
  10149. for _, opt := range opts {
  10150. opt(m)
  10151. }
  10152. return m
  10153. }
  10154. // withCreditUsageID sets the ID field of the mutation.
  10155. func withCreditUsageID(id uint64) creditusageOption {
  10156. return func(m *CreditUsageMutation) {
  10157. var (
  10158. err error
  10159. once sync.Once
  10160. value *CreditUsage
  10161. )
  10162. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  10163. once.Do(func() {
  10164. if m.done {
  10165. err = errors.New("querying old values post mutation is not allowed")
  10166. } else {
  10167. value, err = m.Client().CreditUsage.Get(ctx, id)
  10168. }
  10169. })
  10170. return value, err
  10171. }
  10172. m.id = &id
  10173. }
  10174. }
  10175. // withCreditUsage sets the old CreditUsage of the mutation.
  10176. func withCreditUsage(node *CreditUsage) creditusageOption {
  10177. return func(m *CreditUsageMutation) {
  10178. m.oldValue = func(context.Context) (*CreditUsage, error) {
  10179. return node, nil
  10180. }
  10181. m.id = &node.ID
  10182. }
  10183. }
  10184. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10185. // executed in a transaction (ent.Tx), a transactional client is returned.
  10186. func (m CreditUsageMutation) Client() *Client {
  10187. client := &Client{config: m.config}
  10188. client.init()
  10189. return client
  10190. }
  10191. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10192. // it returns an error otherwise.
  10193. func (m CreditUsageMutation) Tx() (*Tx, error) {
  10194. if _, ok := m.driver.(*txDriver); !ok {
  10195. return nil, errors.New("ent: mutation is not running in a transaction")
  10196. }
  10197. tx := &Tx{config: m.config}
  10198. tx.init()
  10199. return tx, nil
  10200. }
  10201. // SetID sets the value of the id field. Note that this
  10202. // operation is only accepted on creation of CreditUsage entities.
  10203. func (m *CreditUsageMutation) SetID(id uint64) {
  10204. m.id = &id
  10205. }
  10206. // ID returns the ID value in the mutation. Note that the ID is only available
  10207. // if it was provided to the builder or after it was returned from the database.
  10208. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  10209. if m.id == nil {
  10210. return
  10211. }
  10212. return *m.id, true
  10213. }
  10214. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10215. // That means, if the mutation is applied within a transaction with an isolation level such
  10216. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10217. // or updated by the mutation.
  10218. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10219. switch {
  10220. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10221. id, exists := m.ID()
  10222. if exists {
  10223. return []uint64{id}, nil
  10224. }
  10225. fallthrough
  10226. case m.op.Is(OpUpdate | OpDelete):
  10227. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  10228. default:
  10229. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10230. }
  10231. }
  10232. // SetCreatedAt sets the "created_at" field.
  10233. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  10234. m.created_at = &t
  10235. }
  10236. // CreatedAt returns the value of the "created_at" field in the mutation.
  10237. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  10238. v := m.created_at
  10239. if v == nil {
  10240. return
  10241. }
  10242. return *v, true
  10243. }
  10244. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  10245. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10247. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10248. if !m.op.Is(OpUpdateOne) {
  10249. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10250. }
  10251. if m.id == nil || m.oldValue == nil {
  10252. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10253. }
  10254. oldValue, err := m.oldValue(ctx)
  10255. if err != nil {
  10256. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10257. }
  10258. return oldValue.CreatedAt, nil
  10259. }
  10260. // ResetCreatedAt resets all changes to the "created_at" field.
  10261. func (m *CreditUsageMutation) ResetCreatedAt() {
  10262. m.created_at = nil
  10263. }
  10264. // SetUpdatedAt sets the "updated_at" field.
  10265. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  10266. m.updated_at = &t
  10267. }
  10268. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10269. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  10270. v := m.updated_at
  10271. if v == nil {
  10272. return
  10273. }
  10274. return *v, true
  10275. }
  10276. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  10277. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10279. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10280. if !m.op.Is(OpUpdateOne) {
  10281. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10282. }
  10283. if m.id == nil || m.oldValue == nil {
  10284. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10285. }
  10286. oldValue, err := m.oldValue(ctx)
  10287. if err != nil {
  10288. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10289. }
  10290. return oldValue.UpdatedAt, nil
  10291. }
  10292. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10293. func (m *CreditUsageMutation) ResetUpdatedAt() {
  10294. m.updated_at = nil
  10295. }
  10296. // SetDeletedAt sets the "deleted_at" field.
  10297. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  10298. m.deleted_at = &t
  10299. }
  10300. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10301. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  10302. v := m.deleted_at
  10303. if v == nil {
  10304. return
  10305. }
  10306. return *v, true
  10307. }
  10308. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  10309. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10311. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10312. if !m.op.Is(OpUpdateOne) {
  10313. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10314. }
  10315. if m.id == nil || m.oldValue == nil {
  10316. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10317. }
  10318. oldValue, err := m.oldValue(ctx)
  10319. if err != nil {
  10320. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10321. }
  10322. return oldValue.DeletedAt, nil
  10323. }
  10324. // ClearDeletedAt clears the value of the "deleted_at" field.
  10325. func (m *CreditUsageMutation) ClearDeletedAt() {
  10326. m.deleted_at = nil
  10327. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  10328. }
  10329. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10330. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  10331. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  10332. return ok
  10333. }
  10334. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10335. func (m *CreditUsageMutation) ResetDeletedAt() {
  10336. m.deleted_at = nil
  10337. delete(m.clearedFields, creditusage.FieldDeletedAt)
  10338. }
  10339. // SetUserID sets the "user_id" field.
  10340. func (m *CreditUsageMutation) SetUserID(s string) {
  10341. m.user_id = &s
  10342. }
  10343. // UserID returns the value of the "user_id" field in the mutation.
  10344. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  10345. v := m.user_id
  10346. if v == nil {
  10347. return
  10348. }
  10349. return *v, true
  10350. }
  10351. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  10352. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10354. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  10355. if !m.op.Is(OpUpdateOne) {
  10356. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10357. }
  10358. if m.id == nil || m.oldValue == nil {
  10359. return v, errors.New("OldUserID requires an ID field in the mutation")
  10360. }
  10361. oldValue, err := m.oldValue(ctx)
  10362. if err != nil {
  10363. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10364. }
  10365. return oldValue.UserID, nil
  10366. }
  10367. // ResetUserID resets all changes to the "user_id" field.
  10368. func (m *CreditUsageMutation) ResetUserID() {
  10369. m.user_id = nil
  10370. }
  10371. // SetNumber sets the "number" field.
  10372. func (m *CreditUsageMutation) SetNumber(f float32) {
  10373. m.number = &f
  10374. m.addnumber = nil
  10375. }
  10376. // Number returns the value of the "number" field in the mutation.
  10377. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  10378. v := m.number
  10379. if v == nil {
  10380. return
  10381. }
  10382. return *v, true
  10383. }
  10384. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  10385. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10387. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  10388. if !m.op.Is(OpUpdateOne) {
  10389. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  10390. }
  10391. if m.id == nil || m.oldValue == nil {
  10392. return v, errors.New("OldNumber requires an ID field in the mutation")
  10393. }
  10394. oldValue, err := m.oldValue(ctx)
  10395. if err != nil {
  10396. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  10397. }
  10398. return oldValue.Number, nil
  10399. }
  10400. // AddNumber adds f to the "number" field.
  10401. func (m *CreditUsageMutation) AddNumber(f float32) {
  10402. if m.addnumber != nil {
  10403. *m.addnumber += f
  10404. } else {
  10405. m.addnumber = &f
  10406. }
  10407. }
  10408. // AddedNumber returns the value that was added to the "number" field in this mutation.
  10409. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  10410. v := m.addnumber
  10411. if v == nil {
  10412. return
  10413. }
  10414. return *v, true
  10415. }
  10416. // ResetNumber resets all changes to the "number" field.
  10417. func (m *CreditUsageMutation) ResetNumber() {
  10418. m.number = nil
  10419. m.addnumber = nil
  10420. }
  10421. // SetStatus sets the "status" field.
  10422. func (m *CreditUsageMutation) SetStatus(i int) {
  10423. m.status = &i
  10424. m.addstatus = nil
  10425. }
  10426. // Status returns the value of the "status" field in the mutation.
  10427. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  10428. v := m.status
  10429. if v == nil {
  10430. return
  10431. }
  10432. return *v, true
  10433. }
  10434. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  10435. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10437. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  10438. if !m.op.Is(OpUpdateOne) {
  10439. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10440. }
  10441. if m.id == nil || m.oldValue == nil {
  10442. return v, errors.New("OldStatus requires an ID field in the mutation")
  10443. }
  10444. oldValue, err := m.oldValue(ctx)
  10445. if err != nil {
  10446. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10447. }
  10448. return oldValue.Status, nil
  10449. }
  10450. // AddStatus adds i to the "status" field.
  10451. func (m *CreditUsageMutation) AddStatus(i int) {
  10452. if m.addstatus != nil {
  10453. *m.addstatus += i
  10454. } else {
  10455. m.addstatus = &i
  10456. }
  10457. }
  10458. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10459. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  10460. v := m.addstatus
  10461. if v == nil {
  10462. return
  10463. }
  10464. return *v, true
  10465. }
  10466. // ClearStatus clears the value of the "status" field.
  10467. func (m *CreditUsageMutation) ClearStatus() {
  10468. m.status = nil
  10469. m.addstatus = nil
  10470. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  10471. }
  10472. // StatusCleared returns if the "status" field was cleared in this mutation.
  10473. func (m *CreditUsageMutation) StatusCleared() bool {
  10474. _, ok := m.clearedFields[creditusage.FieldStatus]
  10475. return ok
  10476. }
  10477. // ResetStatus resets all changes to the "status" field.
  10478. func (m *CreditUsageMutation) ResetStatus() {
  10479. m.status = nil
  10480. m.addstatus = nil
  10481. delete(m.clearedFields, creditusage.FieldStatus)
  10482. }
  10483. // SetNtype sets the "ntype" field.
  10484. func (m *CreditUsageMutation) SetNtype(i int) {
  10485. m.ntype = &i
  10486. m.addntype = nil
  10487. }
  10488. // Ntype returns the value of the "ntype" field in the mutation.
  10489. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  10490. v := m.ntype
  10491. if v == nil {
  10492. return
  10493. }
  10494. return *v, true
  10495. }
  10496. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  10497. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10499. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  10500. if !m.op.Is(OpUpdateOne) {
  10501. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  10502. }
  10503. if m.id == nil || m.oldValue == nil {
  10504. return v, errors.New("OldNtype requires an ID field in the mutation")
  10505. }
  10506. oldValue, err := m.oldValue(ctx)
  10507. if err != nil {
  10508. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  10509. }
  10510. return oldValue.Ntype, nil
  10511. }
  10512. // AddNtype adds i to the "ntype" field.
  10513. func (m *CreditUsageMutation) AddNtype(i int) {
  10514. if m.addntype != nil {
  10515. *m.addntype += i
  10516. } else {
  10517. m.addntype = &i
  10518. }
  10519. }
  10520. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  10521. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  10522. v := m.addntype
  10523. if v == nil {
  10524. return
  10525. }
  10526. return *v, true
  10527. }
  10528. // ResetNtype resets all changes to the "ntype" field.
  10529. func (m *CreditUsageMutation) ResetNtype() {
  10530. m.ntype = nil
  10531. m.addntype = nil
  10532. }
  10533. // SetTable sets the "table" field.
  10534. func (m *CreditUsageMutation) SetTable(s string) {
  10535. m.table = &s
  10536. }
  10537. // Table returns the value of the "table" field in the mutation.
  10538. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  10539. v := m.table
  10540. if v == nil {
  10541. return
  10542. }
  10543. return *v, true
  10544. }
  10545. // OldTable returns the old "table" field's value of the CreditUsage entity.
  10546. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10548. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  10549. if !m.op.Is(OpUpdateOne) {
  10550. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  10551. }
  10552. if m.id == nil || m.oldValue == nil {
  10553. return v, errors.New("OldTable requires an ID field in the mutation")
  10554. }
  10555. oldValue, err := m.oldValue(ctx)
  10556. if err != nil {
  10557. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  10558. }
  10559. return oldValue.Table, nil
  10560. }
  10561. // ResetTable resets all changes to the "table" field.
  10562. func (m *CreditUsageMutation) ResetTable() {
  10563. m.table = nil
  10564. }
  10565. // SetOrganizationID sets the "organization_id" field.
  10566. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  10567. m.organization_id = &u
  10568. m.addorganization_id = nil
  10569. }
  10570. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10571. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  10572. v := m.organization_id
  10573. if v == nil {
  10574. return
  10575. }
  10576. return *v, true
  10577. }
  10578. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  10579. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10581. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10582. if !m.op.Is(OpUpdateOne) {
  10583. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10584. }
  10585. if m.id == nil || m.oldValue == nil {
  10586. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10587. }
  10588. oldValue, err := m.oldValue(ctx)
  10589. if err != nil {
  10590. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10591. }
  10592. return oldValue.OrganizationID, nil
  10593. }
  10594. // AddOrganizationID adds u to the "organization_id" field.
  10595. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  10596. if m.addorganization_id != nil {
  10597. *m.addorganization_id += u
  10598. } else {
  10599. m.addorganization_id = &u
  10600. }
  10601. }
  10602. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10603. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  10604. v := m.addorganization_id
  10605. if v == nil {
  10606. return
  10607. }
  10608. return *v, true
  10609. }
  10610. // ClearOrganizationID clears the value of the "organization_id" field.
  10611. func (m *CreditUsageMutation) ClearOrganizationID() {
  10612. m.organization_id = nil
  10613. m.addorganization_id = nil
  10614. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  10615. }
  10616. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10617. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  10618. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  10619. return ok
  10620. }
  10621. // ResetOrganizationID resets all changes to the "organization_id" field.
  10622. func (m *CreditUsageMutation) ResetOrganizationID() {
  10623. m.organization_id = nil
  10624. m.addorganization_id = nil
  10625. delete(m.clearedFields, creditusage.FieldOrganizationID)
  10626. }
  10627. // SetNid sets the "nid" field.
  10628. func (m *CreditUsageMutation) SetNid(u uint64) {
  10629. m.nid = &u
  10630. m.addnid = nil
  10631. }
  10632. // Nid returns the value of the "nid" field in the mutation.
  10633. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  10634. v := m.nid
  10635. if v == nil {
  10636. return
  10637. }
  10638. return *v, true
  10639. }
  10640. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  10641. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10643. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  10644. if !m.op.Is(OpUpdateOne) {
  10645. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  10646. }
  10647. if m.id == nil || m.oldValue == nil {
  10648. return v, errors.New("OldNid requires an ID field in the mutation")
  10649. }
  10650. oldValue, err := m.oldValue(ctx)
  10651. if err != nil {
  10652. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  10653. }
  10654. return oldValue.Nid, nil
  10655. }
  10656. // AddNid adds u to the "nid" field.
  10657. func (m *CreditUsageMutation) AddNid(u int64) {
  10658. if m.addnid != nil {
  10659. *m.addnid += u
  10660. } else {
  10661. m.addnid = &u
  10662. }
  10663. }
  10664. // AddedNid returns the value that was added to the "nid" field in this mutation.
  10665. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  10666. v := m.addnid
  10667. if v == nil {
  10668. return
  10669. }
  10670. return *v, true
  10671. }
  10672. // ResetNid resets all changes to the "nid" field.
  10673. func (m *CreditUsageMutation) ResetNid() {
  10674. m.nid = nil
  10675. m.addnid = nil
  10676. }
  10677. // SetReason sets the "reason" field.
  10678. func (m *CreditUsageMutation) SetReason(s string) {
  10679. m.reason = &s
  10680. }
  10681. // Reason returns the value of the "reason" field in the mutation.
  10682. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  10683. v := m.reason
  10684. if v == nil {
  10685. return
  10686. }
  10687. return *v, true
  10688. }
  10689. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  10690. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10692. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  10693. if !m.op.Is(OpUpdateOne) {
  10694. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  10695. }
  10696. if m.id == nil || m.oldValue == nil {
  10697. return v, errors.New("OldReason requires an ID field in the mutation")
  10698. }
  10699. oldValue, err := m.oldValue(ctx)
  10700. if err != nil {
  10701. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  10702. }
  10703. return oldValue.Reason, nil
  10704. }
  10705. // ResetReason resets all changes to the "reason" field.
  10706. func (m *CreditUsageMutation) ResetReason() {
  10707. m.reason = nil
  10708. }
  10709. // SetOperator sets the "operator" field.
  10710. func (m *CreditUsageMutation) SetOperator(s string) {
  10711. m.operator = &s
  10712. }
  10713. // Operator returns the value of the "operator" field in the mutation.
  10714. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  10715. v := m.operator
  10716. if v == nil {
  10717. return
  10718. }
  10719. return *v, true
  10720. }
  10721. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  10722. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10724. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  10725. if !m.op.Is(OpUpdateOne) {
  10726. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  10727. }
  10728. if m.id == nil || m.oldValue == nil {
  10729. return v, errors.New("OldOperator requires an ID field in the mutation")
  10730. }
  10731. oldValue, err := m.oldValue(ctx)
  10732. if err != nil {
  10733. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  10734. }
  10735. return oldValue.Operator, nil
  10736. }
  10737. // ResetOperator resets all changes to the "operator" field.
  10738. func (m *CreditUsageMutation) ResetOperator() {
  10739. m.operator = nil
  10740. }
  10741. // Where appends a list predicates to the CreditUsageMutation builder.
  10742. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  10743. m.predicates = append(m.predicates, ps...)
  10744. }
  10745. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  10746. // users can use type-assertion to append predicates that do not depend on any generated package.
  10747. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  10748. p := make([]predicate.CreditUsage, len(ps))
  10749. for i := range ps {
  10750. p[i] = ps[i]
  10751. }
  10752. m.Where(p...)
  10753. }
  10754. // Op returns the operation name.
  10755. func (m *CreditUsageMutation) Op() Op {
  10756. return m.op
  10757. }
  10758. // SetOp allows setting the mutation operation.
  10759. func (m *CreditUsageMutation) SetOp(op Op) {
  10760. m.op = op
  10761. }
  10762. // Type returns the node type of this mutation (CreditUsage).
  10763. func (m *CreditUsageMutation) Type() string {
  10764. return m.typ
  10765. }
  10766. // Fields returns all fields that were changed during this mutation. Note that in
  10767. // order to get all numeric fields that were incremented/decremented, call
  10768. // AddedFields().
  10769. func (m *CreditUsageMutation) Fields() []string {
  10770. fields := make([]string, 0, 12)
  10771. if m.created_at != nil {
  10772. fields = append(fields, creditusage.FieldCreatedAt)
  10773. }
  10774. if m.updated_at != nil {
  10775. fields = append(fields, creditusage.FieldUpdatedAt)
  10776. }
  10777. if m.deleted_at != nil {
  10778. fields = append(fields, creditusage.FieldDeletedAt)
  10779. }
  10780. if m.user_id != nil {
  10781. fields = append(fields, creditusage.FieldUserID)
  10782. }
  10783. if m.number != nil {
  10784. fields = append(fields, creditusage.FieldNumber)
  10785. }
  10786. if m.status != nil {
  10787. fields = append(fields, creditusage.FieldStatus)
  10788. }
  10789. if m.ntype != nil {
  10790. fields = append(fields, creditusage.FieldNtype)
  10791. }
  10792. if m.table != nil {
  10793. fields = append(fields, creditusage.FieldTable)
  10794. }
  10795. if m.organization_id != nil {
  10796. fields = append(fields, creditusage.FieldOrganizationID)
  10797. }
  10798. if m.nid != nil {
  10799. fields = append(fields, creditusage.FieldNid)
  10800. }
  10801. if m.reason != nil {
  10802. fields = append(fields, creditusage.FieldReason)
  10803. }
  10804. if m.operator != nil {
  10805. fields = append(fields, creditusage.FieldOperator)
  10806. }
  10807. return fields
  10808. }
  10809. // Field returns the value of a field with the given name. The second boolean
  10810. // return value indicates that this field was not set, or was not defined in the
  10811. // schema.
  10812. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  10813. switch name {
  10814. case creditusage.FieldCreatedAt:
  10815. return m.CreatedAt()
  10816. case creditusage.FieldUpdatedAt:
  10817. return m.UpdatedAt()
  10818. case creditusage.FieldDeletedAt:
  10819. return m.DeletedAt()
  10820. case creditusage.FieldUserID:
  10821. return m.UserID()
  10822. case creditusage.FieldNumber:
  10823. return m.Number()
  10824. case creditusage.FieldStatus:
  10825. return m.Status()
  10826. case creditusage.FieldNtype:
  10827. return m.Ntype()
  10828. case creditusage.FieldTable:
  10829. return m.Table()
  10830. case creditusage.FieldOrganizationID:
  10831. return m.OrganizationID()
  10832. case creditusage.FieldNid:
  10833. return m.Nid()
  10834. case creditusage.FieldReason:
  10835. return m.Reason()
  10836. case creditusage.FieldOperator:
  10837. return m.Operator()
  10838. }
  10839. return nil, false
  10840. }
  10841. // OldField returns the old value of the field from the database. An error is
  10842. // returned if the mutation operation is not UpdateOne, or the query to the
  10843. // database failed.
  10844. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10845. switch name {
  10846. case creditusage.FieldCreatedAt:
  10847. return m.OldCreatedAt(ctx)
  10848. case creditusage.FieldUpdatedAt:
  10849. return m.OldUpdatedAt(ctx)
  10850. case creditusage.FieldDeletedAt:
  10851. return m.OldDeletedAt(ctx)
  10852. case creditusage.FieldUserID:
  10853. return m.OldUserID(ctx)
  10854. case creditusage.FieldNumber:
  10855. return m.OldNumber(ctx)
  10856. case creditusage.FieldStatus:
  10857. return m.OldStatus(ctx)
  10858. case creditusage.FieldNtype:
  10859. return m.OldNtype(ctx)
  10860. case creditusage.FieldTable:
  10861. return m.OldTable(ctx)
  10862. case creditusage.FieldOrganizationID:
  10863. return m.OldOrganizationID(ctx)
  10864. case creditusage.FieldNid:
  10865. return m.OldNid(ctx)
  10866. case creditusage.FieldReason:
  10867. return m.OldReason(ctx)
  10868. case creditusage.FieldOperator:
  10869. return m.OldOperator(ctx)
  10870. }
  10871. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  10872. }
  10873. // SetField sets the value of a field with the given name. It returns an error if
  10874. // the field is not defined in the schema, or if the type mismatched the field
  10875. // type.
  10876. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  10877. switch name {
  10878. case creditusage.FieldCreatedAt:
  10879. v, ok := value.(time.Time)
  10880. if !ok {
  10881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10882. }
  10883. m.SetCreatedAt(v)
  10884. return nil
  10885. case creditusage.FieldUpdatedAt:
  10886. v, ok := value.(time.Time)
  10887. if !ok {
  10888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10889. }
  10890. m.SetUpdatedAt(v)
  10891. return nil
  10892. case creditusage.FieldDeletedAt:
  10893. v, ok := value.(time.Time)
  10894. if !ok {
  10895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10896. }
  10897. m.SetDeletedAt(v)
  10898. return nil
  10899. case creditusage.FieldUserID:
  10900. v, ok := value.(string)
  10901. if !ok {
  10902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10903. }
  10904. m.SetUserID(v)
  10905. return nil
  10906. case creditusage.FieldNumber:
  10907. v, ok := value.(float32)
  10908. if !ok {
  10909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10910. }
  10911. m.SetNumber(v)
  10912. return nil
  10913. case creditusage.FieldStatus:
  10914. v, ok := value.(int)
  10915. if !ok {
  10916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10917. }
  10918. m.SetStatus(v)
  10919. return nil
  10920. case creditusage.FieldNtype:
  10921. v, ok := value.(int)
  10922. if !ok {
  10923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10924. }
  10925. m.SetNtype(v)
  10926. return nil
  10927. case creditusage.FieldTable:
  10928. v, ok := value.(string)
  10929. if !ok {
  10930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10931. }
  10932. m.SetTable(v)
  10933. return nil
  10934. case creditusage.FieldOrganizationID:
  10935. v, ok := value.(uint64)
  10936. if !ok {
  10937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10938. }
  10939. m.SetOrganizationID(v)
  10940. return nil
  10941. case creditusage.FieldNid:
  10942. v, ok := value.(uint64)
  10943. if !ok {
  10944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10945. }
  10946. m.SetNid(v)
  10947. return nil
  10948. case creditusage.FieldReason:
  10949. v, ok := value.(string)
  10950. if !ok {
  10951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10952. }
  10953. m.SetReason(v)
  10954. return nil
  10955. case creditusage.FieldOperator:
  10956. v, ok := value.(string)
  10957. if !ok {
  10958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10959. }
  10960. m.SetOperator(v)
  10961. return nil
  10962. }
  10963. return fmt.Errorf("unknown CreditUsage field %s", name)
  10964. }
  10965. // AddedFields returns all numeric fields that were incremented/decremented during
  10966. // this mutation.
  10967. func (m *CreditUsageMutation) AddedFields() []string {
  10968. var fields []string
  10969. if m.addnumber != nil {
  10970. fields = append(fields, creditusage.FieldNumber)
  10971. }
  10972. if m.addstatus != nil {
  10973. fields = append(fields, creditusage.FieldStatus)
  10974. }
  10975. if m.addntype != nil {
  10976. fields = append(fields, creditusage.FieldNtype)
  10977. }
  10978. if m.addorganization_id != nil {
  10979. fields = append(fields, creditusage.FieldOrganizationID)
  10980. }
  10981. if m.addnid != nil {
  10982. fields = append(fields, creditusage.FieldNid)
  10983. }
  10984. return fields
  10985. }
  10986. // AddedField returns the numeric value that was incremented/decremented on a field
  10987. // with the given name. The second boolean return value indicates that this field
  10988. // was not set, or was not defined in the schema.
  10989. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  10990. switch name {
  10991. case creditusage.FieldNumber:
  10992. return m.AddedNumber()
  10993. case creditusage.FieldStatus:
  10994. return m.AddedStatus()
  10995. case creditusage.FieldNtype:
  10996. return m.AddedNtype()
  10997. case creditusage.FieldOrganizationID:
  10998. return m.AddedOrganizationID()
  10999. case creditusage.FieldNid:
  11000. return m.AddedNid()
  11001. }
  11002. return nil, false
  11003. }
  11004. // AddField adds the value to the field with the given name. It returns an error if
  11005. // the field is not defined in the schema, or if the type mismatched the field
  11006. // type.
  11007. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  11008. switch name {
  11009. case creditusage.FieldNumber:
  11010. v, ok := value.(float32)
  11011. if !ok {
  11012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11013. }
  11014. m.AddNumber(v)
  11015. return nil
  11016. case creditusage.FieldStatus:
  11017. v, ok := value.(int)
  11018. if !ok {
  11019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11020. }
  11021. m.AddStatus(v)
  11022. return nil
  11023. case creditusage.FieldNtype:
  11024. v, ok := value.(int)
  11025. if !ok {
  11026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11027. }
  11028. m.AddNtype(v)
  11029. return nil
  11030. case creditusage.FieldOrganizationID:
  11031. v, ok := value.(int64)
  11032. if !ok {
  11033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11034. }
  11035. m.AddOrganizationID(v)
  11036. return nil
  11037. case creditusage.FieldNid:
  11038. v, ok := value.(int64)
  11039. if !ok {
  11040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11041. }
  11042. m.AddNid(v)
  11043. return nil
  11044. }
  11045. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  11046. }
  11047. // ClearedFields returns all nullable fields that were cleared during this
  11048. // mutation.
  11049. func (m *CreditUsageMutation) ClearedFields() []string {
  11050. var fields []string
  11051. if m.FieldCleared(creditusage.FieldDeletedAt) {
  11052. fields = append(fields, creditusage.FieldDeletedAt)
  11053. }
  11054. if m.FieldCleared(creditusage.FieldStatus) {
  11055. fields = append(fields, creditusage.FieldStatus)
  11056. }
  11057. if m.FieldCleared(creditusage.FieldOrganizationID) {
  11058. fields = append(fields, creditusage.FieldOrganizationID)
  11059. }
  11060. return fields
  11061. }
  11062. // FieldCleared returns a boolean indicating if a field with the given name was
  11063. // cleared in this mutation.
  11064. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  11065. _, ok := m.clearedFields[name]
  11066. return ok
  11067. }
  11068. // ClearField clears the value of the field with the given name. It returns an
  11069. // error if the field is not defined in the schema.
  11070. func (m *CreditUsageMutation) ClearField(name string) error {
  11071. switch name {
  11072. case creditusage.FieldDeletedAt:
  11073. m.ClearDeletedAt()
  11074. return nil
  11075. case creditusage.FieldStatus:
  11076. m.ClearStatus()
  11077. return nil
  11078. case creditusage.FieldOrganizationID:
  11079. m.ClearOrganizationID()
  11080. return nil
  11081. }
  11082. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  11083. }
  11084. // ResetField resets all changes in the mutation for the field with the given name.
  11085. // It returns an error if the field is not defined in the schema.
  11086. func (m *CreditUsageMutation) ResetField(name string) error {
  11087. switch name {
  11088. case creditusage.FieldCreatedAt:
  11089. m.ResetCreatedAt()
  11090. return nil
  11091. case creditusage.FieldUpdatedAt:
  11092. m.ResetUpdatedAt()
  11093. return nil
  11094. case creditusage.FieldDeletedAt:
  11095. m.ResetDeletedAt()
  11096. return nil
  11097. case creditusage.FieldUserID:
  11098. m.ResetUserID()
  11099. return nil
  11100. case creditusage.FieldNumber:
  11101. m.ResetNumber()
  11102. return nil
  11103. case creditusage.FieldStatus:
  11104. m.ResetStatus()
  11105. return nil
  11106. case creditusage.FieldNtype:
  11107. m.ResetNtype()
  11108. return nil
  11109. case creditusage.FieldTable:
  11110. m.ResetTable()
  11111. return nil
  11112. case creditusage.FieldOrganizationID:
  11113. m.ResetOrganizationID()
  11114. return nil
  11115. case creditusage.FieldNid:
  11116. m.ResetNid()
  11117. return nil
  11118. case creditusage.FieldReason:
  11119. m.ResetReason()
  11120. return nil
  11121. case creditusage.FieldOperator:
  11122. m.ResetOperator()
  11123. return nil
  11124. }
  11125. return fmt.Errorf("unknown CreditUsage field %s", name)
  11126. }
  11127. // AddedEdges returns all edge names that were set/added in this mutation.
  11128. func (m *CreditUsageMutation) AddedEdges() []string {
  11129. edges := make([]string, 0, 0)
  11130. return edges
  11131. }
  11132. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11133. // name in this mutation.
  11134. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  11135. return nil
  11136. }
  11137. // RemovedEdges returns all edge names that were removed in this mutation.
  11138. func (m *CreditUsageMutation) RemovedEdges() []string {
  11139. edges := make([]string, 0, 0)
  11140. return edges
  11141. }
  11142. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11143. // the given name in this mutation.
  11144. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  11145. return nil
  11146. }
  11147. // ClearedEdges returns all edge names that were cleared in this mutation.
  11148. func (m *CreditUsageMutation) ClearedEdges() []string {
  11149. edges := make([]string, 0, 0)
  11150. return edges
  11151. }
  11152. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11153. // was cleared in this mutation.
  11154. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  11155. return false
  11156. }
  11157. // ClearEdge clears the value of the edge with the given name. It returns an error
  11158. // if that edge is not defined in the schema.
  11159. func (m *CreditUsageMutation) ClearEdge(name string) error {
  11160. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  11161. }
  11162. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11163. // It returns an error if the edge is not defined in the schema.
  11164. func (m *CreditUsageMutation) ResetEdge(name string) error {
  11165. return fmt.Errorf("unknown CreditUsage edge %s", name)
  11166. }
  11167. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  11168. type EmployeeMutation struct {
  11169. config
  11170. op Op
  11171. typ string
  11172. id *uint64
  11173. created_at *time.Time
  11174. updated_at *time.Time
  11175. deleted_at *time.Time
  11176. title *string
  11177. avatar *string
  11178. tags *string
  11179. hire_count *int
  11180. addhire_count *int
  11181. service_count *int
  11182. addservice_count *int
  11183. achievement_count *int
  11184. addachievement_count *int
  11185. intro *string
  11186. estimate *string
  11187. skill *string
  11188. ability_type *string
  11189. scene *string
  11190. switch_in *string
  11191. video_url *string
  11192. organization_id *uint64
  11193. addorganization_id *int64
  11194. category_id *uint64
  11195. addcategory_id *int64
  11196. api_base *string
  11197. api_key *string
  11198. ai_info *string
  11199. is_vip *int
  11200. addis_vip *int
  11201. chat_url *string
  11202. clearedFields map[string]struct{}
  11203. em_work_experiences map[uint64]struct{}
  11204. removedem_work_experiences map[uint64]struct{}
  11205. clearedem_work_experiences bool
  11206. em_tutorial map[uint64]struct{}
  11207. removedem_tutorial map[uint64]struct{}
  11208. clearedem_tutorial bool
  11209. done bool
  11210. oldValue func(context.Context) (*Employee, error)
  11211. predicates []predicate.Employee
  11212. }
  11213. var _ ent.Mutation = (*EmployeeMutation)(nil)
  11214. // employeeOption allows management of the mutation configuration using functional options.
  11215. type employeeOption func(*EmployeeMutation)
  11216. // newEmployeeMutation creates new mutation for the Employee entity.
  11217. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  11218. m := &EmployeeMutation{
  11219. config: c,
  11220. op: op,
  11221. typ: TypeEmployee,
  11222. clearedFields: make(map[string]struct{}),
  11223. }
  11224. for _, opt := range opts {
  11225. opt(m)
  11226. }
  11227. return m
  11228. }
  11229. // withEmployeeID sets the ID field of the mutation.
  11230. func withEmployeeID(id uint64) employeeOption {
  11231. return func(m *EmployeeMutation) {
  11232. var (
  11233. err error
  11234. once sync.Once
  11235. value *Employee
  11236. )
  11237. m.oldValue = func(ctx context.Context) (*Employee, error) {
  11238. once.Do(func() {
  11239. if m.done {
  11240. err = errors.New("querying old values post mutation is not allowed")
  11241. } else {
  11242. value, err = m.Client().Employee.Get(ctx, id)
  11243. }
  11244. })
  11245. return value, err
  11246. }
  11247. m.id = &id
  11248. }
  11249. }
  11250. // withEmployee sets the old Employee of the mutation.
  11251. func withEmployee(node *Employee) employeeOption {
  11252. return func(m *EmployeeMutation) {
  11253. m.oldValue = func(context.Context) (*Employee, error) {
  11254. return node, nil
  11255. }
  11256. m.id = &node.ID
  11257. }
  11258. }
  11259. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11260. // executed in a transaction (ent.Tx), a transactional client is returned.
  11261. func (m EmployeeMutation) Client() *Client {
  11262. client := &Client{config: m.config}
  11263. client.init()
  11264. return client
  11265. }
  11266. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11267. // it returns an error otherwise.
  11268. func (m EmployeeMutation) Tx() (*Tx, error) {
  11269. if _, ok := m.driver.(*txDriver); !ok {
  11270. return nil, errors.New("ent: mutation is not running in a transaction")
  11271. }
  11272. tx := &Tx{config: m.config}
  11273. tx.init()
  11274. return tx, nil
  11275. }
  11276. // SetID sets the value of the id field. Note that this
  11277. // operation is only accepted on creation of Employee entities.
  11278. func (m *EmployeeMutation) SetID(id uint64) {
  11279. m.id = &id
  11280. }
  11281. // ID returns the ID value in the mutation. Note that the ID is only available
  11282. // if it was provided to the builder or after it was returned from the database.
  11283. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  11284. if m.id == nil {
  11285. return
  11286. }
  11287. return *m.id, true
  11288. }
  11289. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11290. // That means, if the mutation is applied within a transaction with an isolation level such
  11291. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11292. // or updated by the mutation.
  11293. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11294. switch {
  11295. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11296. id, exists := m.ID()
  11297. if exists {
  11298. return []uint64{id}, nil
  11299. }
  11300. fallthrough
  11301. case m.op.Is(OpUpdate | OpDelete):
  11302. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  11303. default:
  11304. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11305. }
  11306. }
  11307. // SetCreatedAt sets the "created_at" field.
  11308. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  11309. m.created_at = &t
  11310. }
  11311. // CreatedAt returns the value of the "created_at" field in the mutation.
  11312. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  11313. v := m.created_at
  11314. if v == nil {
  11315. return
  11316. }
  11317. return *v, true
  11318. }
  11319. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  11320. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11322. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11323. if !m.op.Is(OpUpdateOne) {
  11324. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11325. }
  11326. if m.id == nil || m.oldValue == nil {
  11327. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11328. }
  11329. oldValue, err := m.oldValue(ctx)
  11330. if err != nil {
  11331. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11332. }
  11333. return oldValue.CreatedAt, nil
  11334. }
  11335. // ResetCreatedAt resets all changes to the "created_at" field.
  11336. func (m *EmployeeMutation) ResetCreatedAt() {
  11337. m.created_at = nil
  11338. }
  11339. // SetUpdatedAt sets the "updated_at" field.
  11340. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  11341. m.updated_at = &t
  11342. }
  11343. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11344. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  11345. v := m.updated_at
  11346. if v == nil {
  11347. return
  11348. }
  11349. return *v, true
  11350. }
  11351. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  11352. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11354. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11355. if !m.op.Is(OpUpdateOne) {
  11356. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11357. }
  11358. if m.id == nil || m.oldValue == nil {
  11359. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11360. }
  11361. oldValue, err := m.oldValue(ctx)
  11362. if err != nil {
  11363. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11364. }
  11365. return oldValue.UpdatedAt, nil
  11366. }
  11367. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11368. func (m *EmployeeMutation) ResetUpdatedAt() {
  11369. m.updated_at = nil
  11370. }
  11371. // SetDeletedAt sets the "deleted_at" field.
  11372. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  11373. m.deleted_at = &t
  11374. }
  11375. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11376. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  11377. v := m.deleted_at
  11378. if v == nil {
  11379. return
  11380. }
  11381. return *v, true
  11382. }
  11383. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  11384. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11386. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11387. if !m.op.Is(OpUpdateOne) {
  11388. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11389. }
  11390. if m.id == nil || m.oldValue == nil {
  11391. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11392. }
  11393. oldValue, err := m.oldValue(ctx)
  11394. if err != nil {
  11395. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11396. }
  11397. return oldValue.DeletedAt, nil
  11398. }
  11399. // ClearDeletedAt clears the value of the "deleted_at" field.
  11400. func (m *EmployeeMutation) ClearDeletedAt() {
  11401. m.deleted_at = nil
  11402. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  11403. }
  11404. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11405. func (m *EmployeeMutation) DeletedAtCleared() bool {
  11406. _, ok := m.clearedFields[employee.FieldDeletedAt]
  11407. return ok
  11408. }
  11409. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11410. func (m *EmployeeMutation) ResetDeletedAt() {
  11411. m.deleted_at = nil
  11412. delete(m.clearedFields, employee.FieldDeletedAt)
  11413. }
  11414. // SetTitle sets the "title" field.
  11415. func (m *EmployeeMutation) SetTitle(s string) {
  11416. m.title = &s
  11417. }
  11418. // Title returns the value of the "title" field in the mutation.
  11419. func (m *EmployeeMutation) Title() (r string, exists bool) {
  11420. v := m.title
  11421. if v == nil {
  11422. return
  11423. }
  11424. return *v, true
  11425. }
  11426. // OldTitle returns the old "title" field's value of the Employee entity.
  11427. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11429. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  11430. if !m.op.Is(OpUpdateOne) {
  11431. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11432. }
  11433. if m.id == nil || m.oldValue == nil {
  11434. return v, errors.New("OldTitle requires an ID field in the mutation")
  11435. }
  11436. oldValue, err := m.oldValue(ctx)
  11437. if err != nil {
  11438. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11439. }
  11440. return oldValue.Title, nil
  11441. }
  11442. // ResetTitle resets all changes to the "title" field.
  11443. func (m *EmployeeMutation) ResetTitle() {
  11444. m.title = nil
  11445. }
  11446. // SetAvatar sets the "avatar" field.
  11447. func (m *EmployeeMutation) SetAvatar(s string) {
  11448. m.avatar = &s
  11449. }
  11450. // Avatar returns the value of the "avatar" field in the mutation.
  11451. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  11452. v := m.avatar
  11453. if v == nil {
  11454. return
  11455. }
  11456. return *v, true
  11457. }
  11458. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  11459. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11461. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  11462. if !m.op.Is(OpUpdateOne) {
  11463. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  11464. }
  11465. if m.id == nil || m.oldValue == nil {
  11466. return v, errors.New("OldAvatar requires an ID field in the mutation")
  11467. }
  11468. oldValue, err := m.oldValue(ctx)
  11469. if err != nil {
  11470. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  11471. }
  11472. return oldValue.Avatar, nil
  11473. }
  11474. // ResetAvatar resets all changes to the "avatar" field.
  11475. func (m *EmployeeMutation) ResetAvatar() {
  11476. m.avatar = nil
  11477. }
  11478. // SetTags sets the "tags" field.
  11479. func (m *EmployeeMutation) SetTags(s string) {
  11480. m.tags = &s
  11481. }
  11482. // Tags returns the value of the "tags" field in the mutation.
  11483. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  11484. v := m.tags
  11485. if v == nil {
  11486. return
  11487. }
  11488. return *v, true
  11489. }
  11490. // OldTags returns the old "tags" field's value of the Employee entity.
  11491. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11493. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  11494. if !m.op.Is(OpUpdateOne) {
  11495. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  11496. }
  11497. if m.id == nil || m.oldValue == nil {
  11498. return v, errors.New("OldTags requires an ID field in the mutation")
  11499. }
  11500. oldValue, err := m.oldValue(ctx)
  11501. if err != nil {
  11502. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  11503. }
  11504. return oldValue.Tags, nil
  11505. }
  11506. // ResetTags resets all changes to the "tags" field.
  11507. func (m *EmployeeMutation) ResetTags() {
  11508. m.tags = nil
  11509. }
  11510. // SetHireCount sets the "hire_count" field.
  11511. func (m *EmployeeMutation) SetHireCount(i int) {
  11512. m.hire_count = &i
  11513. m.addhire_count = nil
  11514. }
  11515. // HireCount returns the value of the "hire_count" field in the mutation.
  11516. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  11517. v := m.hire_count
  11518. if v == nil {
  11519. return
  11520. }
  11521. return *v, true
  11522. }
  11523. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  11524. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11526. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  11527. if !m.op.Is(OpUpdateOne) {
  11528. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  11529. }
  11530. if m.id == nil || m.oldValue == nil {
  11531. return v, errors.New("OldHireCount requires an ID field in the mutation")
  11532. }
  11533. oldValue, err := m.oldValue(ctx)
  11534. if err != nil {
  11535. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  11536. }
  11537. return oldValue.HireCount, nil
  11538. }
  11539. // AddHireCount adds i to the "hire_count" field.
  11540. func (m *EmployeeMutation) AddHireCount(i int) {
  11541. if m.addhire_count != nil {
  11542. *m.addhire_count += i
  11543. } else {
  11544. m.addhire_count = &i
  11545. }
  11546. }
  11547. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  11548. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  11549. v := m.addhire_count
  11550. if v == nil {
  11551. return
  11552. }
  11553. return *v, true
  11554. }
  11555. // ResetHireCount resets all changes to the "hire_count" field.
  11556. func (m *EmployeeMutation) ResetHireCount() {
  11557. m.hire_count = nil
  11558. m.addhire_count = nil
  11559. }
  11560. // SetServiceCount sets the "service_count" field.
  11561. func (m *EmployeeMutation) SetServiceCount(i int) {
  11562. m.service_count = &i
  11563. m.addservice_count = nil
  11564. }
  11565. // ServiceCount returns the value of the "service_count" field in the mutation.
  11566. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  11567. v := m.service_count
  11568. if v == nil {
  11569. return
  11570. }
  11571. return *v, true
  11572. }
  11573. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  11574. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11576. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  11577. if !m.op.Is(OpUpdateOne) {
  11578. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  11579. }
  11580. if m.id == nil || m.oldValue == nil {
  11581. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  11582. }
  11583. oldValue, err := m.oldValue(ctx)
  11584. if err != nil {
  11585. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  11586. }
  11587. return oldValue.ServiceCount, nil
  11588. }
  11589. // AddServiceCount adds i to the "service_count" field.
  11590. func (m *EmployeeMutation) AddServiceCount(i int) {
  11591. if m.addservice_count != nil {
  11592. *m.addservice_count += i
  11593. } else {
  11594. m.addservice_count = &i
  11595. }
  11596. }
  11597. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  11598. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  11599. v := m.addservice_count
  11600. if v == nil {
  11601. return
  11602. }
  11603. return *v, true
  11604. }
  11605. // ResetServiceCount resets all changes to the "service_count" field.
  11606. func (m *EmployeeMutation) ResetServiceCount() {
  11607. m.service_count = nil
  11608. m.addservice_count = nil
  11609. }
  11610. // SetAchievementCount sets the "achievement_count" field.
  11611. func (m *EmployeeMutation) SetAchievementCount(i int) {
  11612. m.achievement_count = &i
  11613. m.addachievement_count = nil
  11614. }
  11615. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  11616. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  11617. v := m.achievement_count
  11618. if v == nil {
  11619. return
  11620. }
  11621. return *v, true
  11622. }
  11623. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  11624. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11626. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  11627. if !m.op.Is(OpUpdateOne) {
  11628. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  11629. }
  11630. if m.id == nil || m.oldValue == nil {
  11631. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  11632. }
  11633. oldValue, err := m.oldValue(ctx)
  11634. if err != nil {
  11635. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  11636. }
  11637. return oldValue.AchievementCount, nil
  11638. }
  11639. // AddAchievementCount adds i to the "achievement_count" field.
  11640. func (m *EmployeeMutation) AddAchievementCount(i int) {
  11641. if m.addachievement_count != nil {
  11642. *m.addachievement_count += i
  11643. } else {
  11644. m.addachievement_count = &i
  11645. }
  11646. }
  11647. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  11648. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  11649. v := m.addachievement_count
  11650. if v == nil {
  11651. return
  11652. }
  11653. return *v, true
  11654. }
  11655. // ResetAchievementCount resets all changes to the "achievement_count" field.
  11656. func (m *EmployeeMutation) ResetAchievementCount() {
  11657. m.achievement_count = nil
  11658. m.addachievement_count = nil
  11659. }
  11660. // SetIntro sets the "intro" field.
  11661. func (m *EmployeeMutation) SetIntro(s string) {
  11662. m.intro = &s
  11663. }
  11664. // Intro returns the value of the "intro" field in the mutation.
  11665. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  11666. v := m.intro
  11667. if v == nil {
  11668. return
  11669. }
  11670. return *v, true
  11671. }
  11672. // OldIntro returns the old "intro" field's value of the Employee entity.
  11673. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11675. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  11676. if !m.op.Is(OpUpdateOne) {
  11677. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  11678. }
  11679. if m.id == nil || m.oldValue == nil {
  11680. return v, errors.New("OldIntro requires an ID field in the mutation")
  11681. }
  11682. oldValue, err := m.oldValue(ctx)
  11683. if err != nil {
  11684. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  11685. }
  11686. return oldValue.Intro, nil
  11687. }
  11688. // ResetIntro resets all changes to the "intro" field.
  11689. func (m *EmployeeMutation) ResetIntro() {
  11690. m.intro = nil
  11691. }
  11692. // SetEstimate sets the "estimate" field.
  11693. func (m *EmployeeMutation) SetEstimate(s string) {
  11694. m.estimate = &s
  11695. }
  11696. // Estimate returns the value of the "estimate" field in the mutation.
  11697. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  11698. v := m.estimate
  11699. if v == nil {
  11700. return
  11701. }
  11702. return *v, true
  11703. }
  11704. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  11705. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11707. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  11708. if !m.op.Is(OpUpdateOne) {
  11709. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  11710. }
  11711. if m.id == nil || m.oldValue == nil {
  11712. return v, errors.New("OldEstimate requires an ID field in the mutation")
  11713. }
  11714. oldValue, err := m.oldValue(ctx)
  11715. if err != nil {
  11716. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  11717. }
  11718. return oldValue.Estimate, nil
  11719. }
  11720. // ResetEstimate resets all changes to the "estimate" field.
  11721. func (m *EmployeeMutation) ResetEstimate() {
  11722. m.estimate = nil
  11723. }
  11724. // SetSkill sets the "skill" field.
  11725. func (m *EmployeeMutation) SetSkill(s string) {
  11726. m.skill = &s
  11727. }
  11728. // Skill returns the value of the "skill" field in the mutation.
  11729. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  11730. v := m.skill
  11731. if v == nil {
  11732. return
  11733. }
  11734. return *v, true
  11735. }
  11736. // OldSkill returns the old "skill" field's value of the Employee entity.
  11737. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11739. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  11740. if !m.op.Is(OpUpdateOne) {
  11741. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  11742. }
  11743. if m.id == nil || m.oldValue == nil {
  11744. return v, errors.New("OldSkill requires an ID field in the mutation")
  11745. }
  11746. oldValue, err := m.oldValue(ctx)
  11747. if err != nil {
  11748. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  11749. }
  11750. return oldValue.Skill, nil
  11751. }
  11752. // ResetSkill resets all changes to the "skill" field.
  11753. func (m *EmployeeMutation) ResetSkill() {
  11754. m.skill = nil
  11755. }
  11756. // SetAbilityType sets the "ability_type" field.
  11757. func (m *EmployeeMutation) SetAbilityType(s string) {
  11758. m.ability_type = &s
  11759. }
  11760. // AbilityType returns the value of the "ability_type" field in the mutation.
  11761. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  11762. v := m.ability_type
  11763. if v == nil {
  11764. return
  11765. }
  11766. return *v, true
  11767. }
  11768. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  11769. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11771. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  11772. if !m.op.Is(OpUpdateOne) {
  11773. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  11774. }
  11775. if m.id == nil || m.oldValue == nil {
  11776. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  11777. }
  11778. oldValue, err := m.oldValue(ctx)
  11779. if err != nil {
  11780. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  11781. }
  11782. return oldValue.AbilityType, nil
  11783. }
  11784. // ResetAbilityType resets all changes to the "ability_type" field.
  11785. func (m *EmployeeMutation) ResetAbilityType() {
  11786. m.ability_type = nil
  11787. }
  11788. // SetScene sets the "scene" field.
  11789. func (m *EmployeeMutation) SetScene(s string) {
  11790. m.scene = &s
  11791. }
  11792. // Scene returns the value of the "scene" field in the mutation.
  11793. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  11794. v := m.scene
  11795. if v == nil {
  11796. return
  11797. }
  11798. return *v, true
  11799. }
  11800. // OldScene returns the old "scene" field's value of the Employee entity.
  11801. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11803. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  11804. if !m.op.Is(OpUpdateOne) {
  11805. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  11806. }
  11807. if m.id == nil || m.oldValue == nil {
  11808. return v, errors.New("OldScene requires an ID field in the mutation")
  11809. }
  11810. oldValue, err := m.oldValue(ctx)
  11811. if err != nil {
  11812. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  11813. }
  11814. return oldValue.Scene, nil
  11815. }
  11816. // ResetScene resets all changes to the "scene" field.
  11817. func (m *EmployeeMutation) ResetScene() {
  11818. m.scene = nil
  11819. }
  11820. // SetSwitchIn sets the "switch_in" field.
  11821. func (m *EmployeeMutation) SetSwitchIn(s string) {
  11822. m.switch_in = &s
  11823. }
  11824. // SwitchIn returns the value of the "switch_in" field in the mutation.
  11825. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  11826. v := m.switch_in
  11827. if v == nil {
  11828. return
  11829. }
  11830. return *v, true
  11831. }
  11832. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  11833. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11835. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  11836. if !m.op.Is(OpUpdateOne) {
  11837. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  11838. }
  11839. if m.id == nil || m.oldValue == nil {
  11840. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  11841. }
  11842. oldValue, err := m.oldValue(ctx)
  11843. if err != nil {
  11844. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  11845. }
  11846. return oldValue.SwitchIn, nil
  11847. }
  11848. // ResetSwitchIn resets all changes to the "switch_in" field.
  11849. func (m *EmployeeMutation) ResetSwitchIn() {
  11850. m.switch_in = nil
  11851. }
  11852. // SetVideoURL sets the "video_url" field.
  11853. func (m *EmployeeMutation) SetVideoURL(s string) {
  11854. m.video_url = &s
  11855. }
  11856. // VideoURL returns the value of the "video_url" field in the mutation.
  11857. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  11858. v := m.video_url
  11859. if v == nil {
  11860. return
  11861. }
  11862. return *v, true
  11863. }
  11864. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  11865. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11867. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  11868. if !m.op.Is(OpUpdateOne) {
  11869. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  11870. }
  11871. if m.id == nil || m.oldValue == nil {
  11872. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  11873. }
  11874. oldValue, err := m.oldValue(ctx)
  11875. if err != nil {
  11876. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  11877. }
  11878. return oldValue.VideoURL, nil
  11879. }
  11880. // ResetVideoURL resets all changes to the "video_url" field.
  11881. func (m *EmployeeMutation) ResetVideoURL() {
  11882. m.video_url = nil
  11883. }
  11884. // SetOrganizationID sets the "organization_id" field.
  11885. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  11886. m.organization_id = &u
  11887. m.addorganization_id = nil
  11888. }
  11889. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11890. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  11891. v := m.organization_id
  11892. if v == nil {
  11893. return
  11894. }
  11895. return *v, true
  11896. }
  11897. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  11898. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11900. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11901. if !m.op.Is(OpUpdateOne) {
  11902. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11903. }
  11904. if m.id == nil || m.oldValue == nil {
  11905. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11906. }
  11907. oldValue, err := m.oldValue(ctx)
  11908. if err != nil {
  11909. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11910. }
  11911. return oldValue.OrganizationID, nil
  11912. }
  11913. // AddOrganizationID adds u to the "organization_id" field.
  11914. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  11915. if m.addorganization_id != nil {
  11916. *m.addorganization_id += u
  11917. } else {
  11918. m.addorganization_id = &u
  11919. }
  11920. }
  11921. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11922. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  11923. v := m.addorganization_id
  11924. if v == nil {
  11925. return
  11926. }
  11927. return *v, true
  11928. }
  11929. // ResetOrganizationID resets all changes to the "organization_id" field.
  11930. func (m *EmployeeMutation) ResetOrganizationID() {
  11931. m.organization_id = nil
  11932. m.addorganization_id = nil
  11933. }
  11934. // SetCategoryID sets the "category_id" field.
  11935. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  11936. m.category_id = &u
  11937. m.addcategory_id = nil
  11938. }
  11939. // CategoryID returns the value of the "category_id" field in the mutation.
  11940. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  11941. v := m.category_id
  11942. if v == nil {
  11943. return
  11944. }
  11945. return *v, true
  11946. }
  11947. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  11948. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11950. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  11951. if !m.op.Is(OpUpdateOne) {
  11952. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  11953. }
  11954. if m.id == nil || m.oldValue == nil {
  11955. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  11956. }
  11957. oldValue, err := m.oldValue(ctx)
  11958. if err != nil {
  11959. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  11960. }
  11961. return oldValue.CategoryID, nil
  11962. }
  11963. // AddCategoryID adds u to the "category_id" field.
  11964. func (m *EmployeeMutation) AddCategoryID(u int64) {
  11965. if m.addcategory_id != nil {
  11966. *m.addcategory_id += u
  11967. } else {
  11968. m.addcategory_id = &u
  11969. }
  11970. }
  11971. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  11972. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  11973. v := m.addcategory_id
  11974. if v == nil {
  11975. return
  11976. }
  11977. return *v, true
  11978. }
  11979. // ResetCategoryID resets all changes to the "category_id" field.
  11980. func (m *EmployeeMutation) ResetCategoryID() {
  11981. m.category_id = nil
  11982. m.addcategory_id = nil
  11983. }
  11984. // SetAPIBase sets the "api_base" field.
  11985. func (m *EmployeeMutation) SetAPIBase(s string) {
  11986. m.api_base = &s
  11987. }
  11988. // APIBase returns the value of the "api_base" field in the mutation.
  11989. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  11990. v := m.api_base
  11991. if v == nil {
  11992. return
  11993. }
  11994. return *v, true
  11995. }
  11996. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  11997. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11999. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  12000. if !m.op.Is(OpUpdateOne) {
  12001. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  12002. }
  12003. if m.id == nil || m.oldValue == nil {
  12004. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  12005. }
  12006. oldValue, err := m.oldValue(ctx)
  12007. if err != nil {
  12008. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  12009. }
  12010. return oldValue.APIBase, nil
  12011. }
  12012. // ResetAPIBase resets all changes to the "api_base" field.
  12013. func (m *EmployeeMutation) ResetAPIBase() {
  12014. m.api_base = nil
  12015. }
  12016. // SetAPIKey sets the "api_key" field.
  12017. func (m *EmployeeMutation) SetAPIKey(s string) {
  12018. m.api_key = &s
  12019. }
  12020. // APIKey returns the value of the "api_key" field in the mutation.
  12021. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  12022. v := m.api_key
  12023. if v == nil {
  12024. return
  12025. }
  12026. return *v, true
  12027. }
  12028. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  12029. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12031. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  12032. if !m.op.Is(OpUpdateOne) {
  12033. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  12034. }
  12035. if m.id == nil || m.oldValue == nil {
  12036. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  12037. }
  12038. oldValue, err := m.oldValue(ctx)
  12039. if err != nil {
  12040. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  12041. }
  12042. return oldValue.APIKey, nil
  12043. }
  12044. // ResetAPIKey resets all changes to the "api_key" field.
  12045. func (m *EmployeeMutation) ResetAPIKey() {
  12046. m.api_key = nil
  12047. }
  12048. // SetAiInfo sets the "ai_info" field.
  12049. func (m *EmployeeMutation) SetAiInfo(s string) {
  12050. m.ai_info = &s
  12051. }
  12052. // AiInfo returns the value of the "ai_info" field in the mutation.
  12053. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  12054. v := m.ai_info
  12055. if v == nil {
  12056. return
  12057. }
  12058. return *v, true
  12059. }
  12060. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  12061. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12063. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  12064. if !m.op.Is(OpUpdateOne) {
  12065. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  12066. }
  12067. if m.id == nil || m.oldValue == nil {
  12068. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  12069. }
  12070. oldValue, err := m.oldValue(ctx)
  12071. if err != nil {
  12072. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  12073. }
  12074. return oldValue.AiInfo, nil
  12075. }
  12076. // ClearAiInfo clears the value of the "ai_info" field.
  12077. func (m *EmployeeMutation) ClearAiInfo() {
  12078. m.ai_info = nil
  12079. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  12080. }
  12081. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  12082. func (m *EmployeeMutation) AiInfoCleared() bool {
  12083. _, ok := m.clearedFields[employee.FieldAiInfo]
  12084. return ok
  12085. }
  12086. // ResetAiInfo resets all changes to the "ai_info" field.
  12087. func (m *EmployeeMutation) ResetAiInfo() {
  12088. m.ai_info = nil
  12089. delete(m.clearedFields, employee.FieldAiInfo)
  12090. }
  12091. // SetIsVip sets the "is_vip" field.
  12092. func (m *EmployeeMutation) SetIsVip(i int) {
  12093. m.is_vip = &i
  12094. m.addis_vip = nil
  12095. }
  12096. // IsVip returns the value of the "is_vip" field in the mutation.
  12097. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  12098. v := m.is_vip
  12099. if v == nil {
  12100. return
  12101. }
  12102. return *v, true
  12103. }
  12104. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  12105. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12107. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  12108. if !m.op.Is(OpUpdateOne) {
  12109. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  12110. }
  12111. if m.id == nil || m.oldValue == nil {
  12112. return v, errors.New("OldIsVip requires an ID field in the mutation")
  12113. }
  12114. oldValue, err := m.oldValue(ctx)
  12115. if err != nil {
  12116. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  12117. }
  12118. return oldValue.IsVip, nil
  12119. }
  12120. // AddIsVip adds i to the "is_vip" field.
  12121. func (m *EmployeeMutation) AddIsVip(i int) {
  12122. if m.addis_vip != nil {
  12123. *m.addis_vip += i
  12124. } else {
  12125. m.addis_vip = &i
  12126. }
  12127. }
  12128. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  12129. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  12130. v := m.addis_vip
  12131. if v == nil {
  12132. return
  12133. }
  12134. return *v, true
  12135. }
  12136. // ResetIsVip resets all changes to the "is_vip" field.
  12137. func (m *EmployeeMutation) ResetIsVip() {
  12138. m.is_vip = nil
  12139. m.addis_vip = nil
  12140. }
  12141. // SetChatURL sets the "chat_url" field.
  12142. func (m *EmployeeMutation) SetChatURL(s string) {
  12143. m.chat_url = &s
  12144. }
  12145. // ChatURL returns the value of the "chat_url" field in the mutation.
  12146. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  12147. v := m.chat_url
  12148. if v == nil {
  12149. return
  12150. }
  12151. return *v, true
  12152. }
  12153. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  12154. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12156. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  12157. if !m.op.Is(OpUpdateOne) {
  12158. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  12159. }
  12160. if m.id == nil || m.oldValue == nil {
  12161. return v, errors.New("OldChatURL requires an ID field in the mutation")
  12162. }
  12163. oldValue, err := m.oldValue(ctx)
  12164. if err != nil {
  12165. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  12166. }
  12167. return oldValue.ChatURL, nil
  12168. }
  12169. // ResetChatURL resets all changes to the "chat_url" field.
  12170. func (m *EmployeeMutation) ResetChatURL() {
  12171. m.chat_url = nil
  12172. }
  12173. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  12174. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  12175. if m.em_work_experiences == nil {
  12176. m.em_work_experiences = make(map[uint64]struct{})
  12177. }
  12178. for i := range ids {
  12179. m.em_work_experiences[ids[i]] = struct{}{}
  12180. }
  12181. }
  12182. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  12183. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  12184. m.clearedem_work_experiences = true
  12185. }
  12186. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  12187. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  12188. return m.clearedem_work_experiences
  12189. }
  12190. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  12191. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  12192. if m.removedem_work_experiences == nil {
  12193. m.removedem_work_experiences = make(map[uint64]struct{})
  12194. }
  12195. for i := range ids {
  12196. delete(m.em_work_experiences, ids[i])
  12197. m.removedem_work_experiences[ids[i]] = struct{}{}
  12198. }
  12199. }
  12200. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  12201. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  12202. for id := range m.removedem_work_experiences {
  12203. ids = append(ids, id)
  12204. }
  12205. return
  12206. }
  12207. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  12208. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  12209. for id := range m.em_work_experiences {
  12210. ids = append(ids, id)
  12211. }
  12212. return
  12213. }
  12214. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  12215. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  12216. m.em_work_experiences = nil
  12217. m.clearedem_work_experiences = false
  12218. m.removedem_work_experiences = nil
  12219. }
  12220. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  12221. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  12222. if m.em_tutorial == nil {
  12223. m.em_tutorial = make(map[uint64]struct{})
  12224. }
  12225. for i := range ids {
  12226. m.em_tutorial[ids[i]] = struct{}{}
  12227. }
  12228. }
  12229. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  12230. func (m *EmployeeMutation) ClearEmTutorial() {
  12231. m.clearedem_tutorial = true
  12232. }
  12233. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  12234. func (m *EmployeeMutation) EmTutorialCleared() bool {
  12235. return m.clearedem_tutorial
  12236. }
  12237. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  12238. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  12239. if m.removedem_tutorial == nil {
  12240. m.removedem_tutorial = make(map[uint64]struct{})
  12241. }
  12242. for i := range ids {
  12243. delete(m.em_tutorial, ids[i])
  12244. m.removedem_tutorial[ids[i]] = struct{}{}
  12245. }
  12246. }
  12247. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  12248. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  12249. for id := range m.removedem_tutorial {
  12250. ids = append(ids, id)
  12251. }
  12252. return
  12253. }
  12254. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  12255. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  12256. for id := range m.em_tutorial {
  12257. ids = append(ids, id)
  12258. }
  12259. return
  12260. }
  12261. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  12262. func (m *EmployeeMutation) ResetEmTutorial() {
  12263. m.em_tutorial = nil
  12264. m.clearedem_tutorial = false
  12265. m.removedem_tutorial = nil
  12266. }
  12267. // Where appends a list predicates to the EmployeeMutation builder.
  12268. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  12269. m.predicates = append(m.predicates, ps...)
  12270. }
  12271. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  12272. // users can use type-assertion to append predicates that do not depend on any generated package.
  12273. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  12274. p := make([]predicate.Employee, len(ps))
  12275. for i := range ps {
  12276. p[i] = ps[i]
  12277. }
  12278. m.Where(p...)
  12279. }
  12280. // Op returns the operation name.
  12281. func (m *EmployeeMutation) Op() Op {
  12282. return m.op
  12283. }
  12284. // SetOp allows setting the mutation operation.
  12285. func (m *EmployeeMutation) SetOp(op Op) {
  12286. m.op = op
  12287. }
  12288. // Type returns the node type of this mutation (Employee).
  12289. func (m *EmployeeMutation) Type() string {
  12290. return m.typ
  12291. }
  12292. // Fields returns all fields that were changed during this mutation. Note that in
  12293. // order to get all numeric fields that were incremented/decremented, call
  12294. // AddedFields().
  12295. func (m *EmployeeMutation) Fields() []string {
  12296. fields := make([]string, 0, 23)
  12297. if m.created_at != nil {
  12298. fields = append(fields, employee.FieldCreatedAt)
  12299. }
  12300. if m.updated_at != nil {
  12301. fields = append(fields, employee.FieldUpdatedAt)
  12302. }
  12303. if m.deleted_at != nil {
  12304. fields = append(fields, employee.FieldDeletedAt)
  12305. }
  12306. if m.title != nil {
  12307. fields = append(fields, employee.FieldTitle)
  12308. }
  12309. if m.avatar != nil {
  12310. fields = append(fields, employee.FieldAvatar)
  12311. }
  12312. if m.tags != nil {
  12313. fields = append(fields, employee.FieldTags)
  12314. }
  12315. if m.hire_count != nil {
  12316. fields = append(fields, employee.FieldHireCount)
  12317. }
  12318. if m.service_count != nil {
  12319. fields = append(fields, employee.FieldServiceCount)
  12320. }
  12321. if m.achievement_count != nil {
  12322. fields = append(fields, employee.FieldAchievementCount)
  12323. }
  12324. if m.intro != nil {
  12325. fields = append(fields, employee.FieldIntro)
  12326. }
  12327. if m.estimate != nil {
  12328. fields = append(fields, employee.FieldEstimate)
  12329. }
  12330. if m.skill != nil {
  12331. fields = append(fields, employee.FieldSkill)
  12332. }
  12333. if m.ability_type != nil {
  12334. fields = append(fields, employee.FieldAbilityType)
  12335. }
  12336. if m.scene != nil {
  12337. fields = append(fields, employee.FieldScene)
  12338. }
  12339. if m.switch_in != nil {
  12340. fields = append(fields, employee.FieldSwitchIn)
  12341. }
  12342. if m.video_url != nil {
  12343. fields = append(fields, employee.FieldVideoURL)
  12344. }
  12345. if m.organization_id != nil {
  12346. fields = append(fields, employee.FieldOrganizationID)
  12347. }
  12348. if m.category_id != nil {
  12349. fields = append(fields, employee.FieldCategoryID)
  12350. }
  12351. if m.api_base != nil {
  12352. fields = append(fields, employee.FieldAPIBase)
  12353. }
  12354. if m.api_key != nil {
  12355. fields = append(fields, employee.FieldAPIKey)
  12356. }
  12357. if m.ai_info != nil {
  12358. fields = append(fields, employee.FieldAiInfo)
  12359. }
  12360. if m.is_vip != nil {
  12361. fields = append(fields, employee.FieldIsVip)
  12362. }
  12363. if m.chat_url != nil {
  12364. fields = append(fields, employee.FieldChatURL)
  12365. }
  12366. return fields
  12367. }
  12368. // Field returns the value of a field with the given name. The second boolean
  12369. // return value indicates that this field was not set, or was not defined in the
  12370. // schema.
  12371. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  12372. switch name {
  12373. case employee.FieldCreatedAt:
  12374. return m.CreatedAt()
  12375. case employee.FieldUpdatedAt:
  12376. return m.UpdatedAt()
  12377. case employee.FieldDeletedAt:
  12378. return m.DeletedAt()
  12379. case employee.FieldTitle:
  12380. return m.Title()
  12381. case employee.FieldAvatar:
  12382. return m.Avatar()
  12383. case employee.FieldTags:
  12384. return m.Tags()
  12385. case employee.FieldHireCount:
  12386. return m.HireCount()
  12387. case employee.FieldServiceCount:
  12388. return m.ServiceCount()
  12389. case employee.FieldAchievementCount:
  12390. return m.AchievementCount()
  12391. case employee.FieldIntro:
  12392. return m.Intro()
  12393. case employee.FieldEstimate:
  12394. return m.Estimate()
  12395. case employee.FieldSkill:
  12396. return m.Skill()
  12397. case employee.FieldAbilityType:
  12398. return m.AbilityType()
  12399. case employee.FieldScene:
  12400. return m.Scene()
  12401. case employee.FieldSwitchIn:
  12402. return m.SwitchIn()
  12403. case employee.FieldVideoURL:
  12404. return m.VideoURL()
  12405. case employee.FieldOrganizationID:
  12406. return m.OrganizationID()
  12407. case employee.FieldCategoryID:
  12408. return m.CategoryID()
  12409. case employee.FieldAPIBase:
  12410. return m.APIBase()
  12411. case employee.FieldAPIKey:
  12412. return m.APIKey()
  12413. case employee.FieldAiInfo:
  12414. return m.AiInfo()
  12415. case employee.FieldIsVip:
  12416. return m.IsVip()
  12417. case employee.FieldChatURL:
  12418. return m.ChatURL()
  12419. }
  12420. return nil, false
  12421. }
  12422. // OldField returns the old value of the field from the database. An error is
  12423. // returned if the mutation operation is not UpdateOne, or the query to the
  12424. // database failed.
  12425. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12426. switch name {
  12427. case employee.FieldCreatedAt:
  12428. return m.OldCreatedAt(ctx)
  12429. case employee.FieldUpdatedAt:
  12430. return m.OldUpdatedAt(ctx)
  12431. case employee.FieldDeletedAt:
  12432. return m.OldDeletedAt(ctx)
  12433. case employee.FieldTitle:
  12434. return m.OldTitle(ctx)
  12435. case employee.FieldAvatar:
  12436. return m.OldAvatar(ctx)
  12437. case employee.FieldTags:
  12438. return m.OldTags(ctx)
  12439. case employee.FieldHireCount:
  12440. return m.OldHireCount(ctx)
  12441. case employee.FieldServiceCount:
  12442. return m.OldServiceCount(ctx)
  12443. case employee.FieldAchievementCount:
  12444. return m.OldAchievementCount(ctx)
  12445. case employee.FieldIntro:
  12446. return m.OldIntro(ctx)
  12447. case employee.FieldEstimate:
  12448. return m.OldEstimate(ctx)
  12449. case employee.FieldSkill:
  12450. return m.OldSkill(ctx)
  12451. case employee.FieldAbilityType:
  12452. return m.OldAbilityType(ctx)
  12453. case employee.FieldScene:
  12454. return m.OldScene(ctx)
  12455. case employee.FieldSwitchIn:
  12456. return m.OldSwitchIn(ctx)
  12457. case employee.FieldVideoURL:
  12458. return m.OldVideoURL(ctx)
  12459. case employee.FieldOrganizationID:
  12460. return m.OldOrganizationID(ctx)
  12461. case employee.FieldCategoryID:
  12462. return m.OldCategoryID(ctx)
  12463. case employee.FieldAPIBase:
  12464. return m.OldAPIBase(ctx)
  12465. case employee.FieldAPIKey:
  12466. return m.OldAPIKey(ctx)
  12467. case employee.FieldAiInfo:
  12468. return m.OldAiInfo(ctx)
  12469. case employee.FieldIsVip:
  12470. return m.OldIsVip(ctx)
  12471. case employee.FieldChatURL:
  12472. return m.OldChatURL(ctx)
  12473. }
  12474. return nil, fmt.Errorf("unknown Employee field %s", name)
  12475. }
  12476. // SetField sets the value of a field with the given name. It returns an error if
  12477. // the field is not defined in the schema, or if the type mismatched the field
  12478. // type.
  12479. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  12480. switch name {
  12481. case employee.FieldCreatedAt:
  12482. v, ok := value.(time.Time)
  12483. if !ok {
  12484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12485. }
  12486. m.SetCreatedAt(v)
  12487. return nil
  12488. case employee.FieldUpdatedAt:
  12489. v, ok := value.(time.Time)
  12490. if !ok {
  12491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12492. }
  12493. m.SetUpdatedAt(v)
  12494. return nil
  12495. case employee.FieldDeletedAt:
  12496. v, ok := value.(time.Time)
  12497. if !ok {
  12498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12499. }
  12500. m.SetDeletedAt(v)
  12501. return nil
  12502. case employee.FieldTitle:
  12503. v, ok := value.(string)
  12504. if !ok {
  12505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12506. }
  12507. m.SetTitle(v)
  12508. return nil
  12509. case employee.FieldAvatar:
  12510. v, ok := value.(string)
  12511. if !ok {
  12512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12513. }
  12514. m.SetAvatar(v)
  12515. return nil
  12516. case employee.FieldTags:
  12517. v, ok := value.(string)
  12518. if !ok {
  12519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12520. }
  12521. m.SetTags(v)
  12522. return nil
  12523. case employee.FieldHireCount:
  12524. v, ok := value.(int)
  12525. if !ok {
  12526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12527. }
  12528. m.SetHireCount(v)
  12529. return nil
  12530. case employee.FieldServiceCount:
  12531. v, ok := value.(int)
  12532. if !ok {
  12533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12534. }
  12535. m.SetServiceCount(v)
  12536. return nil
  12537. case employee.FieldAchievementCount:
  12538. v, ok := value.(int)
  12539. if !ok {
  12540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12541. }
  12542. m.SetAchievementCount(v)
  12543. return nil
  12544. case employee.FieldIntro:
  12545. v, ok := value.(string)
  12546. if !ok {
  12547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12548. }
  12549. m.SetIntro(v)
  12550. return nil
  12551. case employee.FieldEstimate:
  12552. v, ok := value.(string)
  12553. if !ok {
  12554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12555. }
  12556. m.SetEstimate(v)
  12557. return nil
  12558. case employee.FieldSkill:
  12559. v, ok := value.(string)
  12560. if !ok {
  12561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12562. }
  12563. m.SetSkill(v)
  12564. return nil
  12565. case employee.FieldAbilityType:
  12566. v, ok := value.(string)
  12567. if !ok {
  12568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12569. }
  12570. m.SetAbilityType(v)
  12571. return nil
  12572. case employee.FieldScene:
  12573. v, ok := value.(string)
  12574. if !ok {
  12575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12576. }
  12577. m.SetScene(v)
  12578. return nil
  12579. case employee.FieldSwitchIn:
  12580. v, ok := value.(string)
  12581. if !ok {
  12582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12583. }
  12584. m.SetSwitchIn(v)
  12585. return nil
  12586. case employee.FieldVideoURL:
  12587. v, ok := value.(string)
  12588. if !ok {
  12589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12590. }
  12591. m.SetVideoURL(v)
  12592. return nil
  12593. case employee.FieldOrganizationID:
  12594. v, ok := value.(uint64)
  12595. if !ok {
  12596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12597. }
  12598. m.SetOrganizationID(v)
  12599. return nil
  12600. case employee.FieldCategoryID:
  12601. v, ok := value.(uint64)
  12602. if !ok {
  12603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12604. }
  12605. m.SetCategoryID(v)
  12606. return nil
  12607. case employee.FieldAPIBase:
  12608. v, ok := value.(string)
  12609. if !ok {
  12610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12611. }
  12612. m.SetAPIBase(v)
  12613. return nil
  12614. case employee.FieldAPIKey:
  12615. v, ok := value.(string)
  12616. if !ok {
  12617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12618. }
  12619. m.SetAPIKey(v)
  12620. return nil
  12621. case employee.FieldAiInfo:
  12622. v, ok := value.(string)
  12623. if !ok {
  12624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12625. }
  12626. m.SetAiInfo(v)
  12627. return nil
  12628. case employee.FieldIsVip:
  12629. v, ok := value.(int)
  12630. if !ok {
  12631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12632. }
  12633. m.SetIsVip(v)
  12634. return nil
  12635. case employee.FieldChatURL:
  12636. v, ok := value.(string)
  12637. if !ok {
  12638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12639. }
  12640. m.SetChatURL(v)
  12641. return nil
  12642. }
  12643. return fmt.Errorf("unknown Employee field %s", name)
  12644. }
  12645. // AddedFields returns all numeric fields that were incremented/decremented during
  12646. // this mutation.
  12647. func (m *EmployeeMutation) AddedFields() []string {
  12648. var fields []string
  12649. if m.addhire_count != nil {
  12650. fields = append(fields, employee.FieldHireCount)
  12651. }
  12652. if m.addservice_count != nil {
  12653. fields = append(fields, employee.FieldServiceCount)
  12654. }
  12655. if m.addachievement_count != nil {
  12656. fields = append(fields, employee.FieldAchievementCount)
  12657. }
  12658. if m.addorganization_id != nil {
  12659. fields = append(fields, employee.FieldOrganizationID)
  12660. }
  12661. if m.addcategory_id != nil {
  12662. fields = append(fields, employee.FieldCategoryID)
  12663. }
  12664. if m.addis_vip != nil {
  12665. fields = append(fields, employee.FieldIsVip)
  12666. }
  12667. return fields
  12668. }
  12669. // AddedField returns the numeric value that was incremented/decremented on a field
  12670. // with the given name. The second boolean return value indicates that this field
  12671. // was not set, or was not defined in the schema.
  12672. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  12673. switch name {
  12674. case employee.FieldHireCount:
  12675. return m.AddedHireCount()
  12676. case employee.FieldServiceCount:
  12677. return m.AddedServiceCount()
  12678. case employee.FieldAchievementCount:
  12679. return m.AddedAchievementCount()
  12680. case employee.FieldOrganizationID:
  12681. return m.AddedOrganizationID()
  12682. case employee.FieldCategoryID:
  12683. return m.AddedCategoryID()
  12684. case employee.FieldIsVip:
  12685. return m.AddedIsVip()
  12686. }
  12687. return nil, false
  12688. }
  12689. // AddField adds the value to the field with the given name. It returns an error if
  12690. // the field is not defined in the schema, or if the type mismatched the field
  12691. // type.
  12692. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  12693. switch name {
  12694. case employee.FieldHireCount:
  12695. v, ok := value.(int)
  12696. if !ok {
  12697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12698. }
  12699. m.AddHireCount(v)
  12700. return nil
  12701. case employee.FieldServiceCount:
  12702. v, ok := value.(int)
  12703. if !ok {
  12704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12705. }
  12706. m.AddServiceCount(v)
  12707. return nil
  12708. case employee.FieldAchievementCount:
  12709. v, ok := value.(int)
  12710. if !ok {
  12711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12712. }
  12713. m.AddAchievementCount(v)
  12714. return nil
  12715. case employee.FieldOrganizationID:
  12716. v, ok := value.(int64)
  12717. if !ok {
  12718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12719. }
  12720. m.AddOrganizationID(v)
  12721. return nil
  12722. case employee.FieldCategoryID:
  12723. v, ok := value.(int64)
  12724. if !ok {
  12725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12726. }
  12727. m.AddCategoryID(v)
  12728. return nil
  12729. case employee.FieldIsVip:
  12730. v, ok := value.(int)
  12731. if !ok {
  12732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12733. }
  12734. m.AddIsVip(v)
  12735. return nil
  12736. }
  12737. return fmt.Errorf("unknown Employee numeric field %s", name)
  12738. }
  12739. // ClearedFields returns all nullable fields that were cleared during this
  12740. // mutation.
  12741. func (m *EmployeeMutation) ClearedFields() []string {
  12742. var fields []string
  12743. if m.FieldCleared(employee.FieldDeletedAt) {
  12744. fields = append(fields, employee.FieldDeletedAt)
  12745. }
  12746. if m.FieldCleared(employee.FieldAiInfo) {
  12747. fields = append(fields, employee.FieldAiInfo)
  12748. }
  12749. return fields
  12750. }
  12751. // FieldCleared returns a boolean indicating if a field with the given name was
  12752. // cleared in this mutation.
  12753. func (m *EmployeeMutation) FieldCleared(name string) bool {
  12754. _, ok := m.clearedFields[name]
  12755. return ok
  12756. }
  12757. // ClearField clears the value of the field with the given name. It returns an
  12758. // error if the field is not defined in the schema.
  12759. func (m *EmployeeMutation) ClearField(name string) error {
  12760. switch name {
  12761. case employee.FieldDeletedAt:
  12762. m.ClearDeletedAt()
  12763. return nil
  12764. case employee.FieldAiInfo:
  12765. m.ClearAiInfo()
  12766. return nil
  12767. }
  12768. return fmt.Errorf("unknown Employee nullable field %s", name)
  12769. }
  12770. // ResetField resets all changes in the mutation for the field with the given name.
  12771. // It returns an error if the field is not defined in the schema.
  12772. func (m *EmployeeMutation) ResetField(name string) error {
  12773. switch name {
  12774. case employee.FieldCreatedAt:
  12775. m.ResetCreatedAt()
  12776. return nil
  12777. case employee.FieldUpdatedAt:
  12778. m.ResetUpdatedAt()
  12779. return nil
  12780. case employee.FieldDeletedAt:
  12781. m.ResetDeletedAt()
  12782. return nil
  12783. case employee.FieldTitle:
  12784. m.ResetTitle()
  12785. return nil
  12786. case employee.FieldAvatar:
  12787. m.ResetAvatar()
  12788. return nil
  12789. case employee.FieldTags:
  12790. m.ResetTags()
  12791. return nil
  12792. case employee.FieldHireCount:
  12793. m.ResetHireCount()
  12794. return nil
  12795. case employee.FieldServiceCount:
  12796. m.ResetServiceCount()
  12797. return nil
  12798. case employee.FieldAchievementCount:
  12799. m.ResetAchievementCount()
  12800. return nil
  12801. case employee.FieldIntro:
  12802. m.ResetIntro()
  12803. return nil
  12804. case employee.FieldEstimate:
  12805. m.ResetEstimate()
  12806. return nil
  12807. case employee.FieldSkill:
  12808. m.ResetSkill()
  12809. return nil
  12810. case employee.FieldAbilityType:
  12811. m.ResetAbilityType()
  12812. return nil
  12813. case employee.FieldScene:
  12814. m.ResetScene()
  12815. return nil
  12816. case employee.FieldSwitchIn:
  12817. m.ResetSwitchIn()
  12818. return nil
  12819. case employee.FieldVideoURL:
  12820. m.ResetVideoURL()
  12821. return nil
  12822. case employee.FieldOrganizationID:
  12823. m.ResetOrganizationID()
  12824. return nil
  12825. case employee.FieldCategoryID:
  12826. m.ResetCategoryID()
  12827. return nil
  12828. case employee.FieldAPIBase:
  12829. m.ResetAPIBase()
  12830. return nil
  12831. case employee.FieldAPIKey:
  12832. m.ResetAPIKey()
  12833. return nil
  12834. case employee.FieldAiInfo:
  12835. m.ResetAiInfo()
  12836. return nil
  12837. case employee.FieldIsVip:
  12838. m.ResetIsVip()
  12839. return nil
  12840. case employee.FieldChatURL:
  12841. m.ResetChatURL()
  12842. return nil
  12843. }
  12844. return fmt.Errorf("unknown Employee field %s", name)
  12845. }
  12846. // AddedEdges returns all edge names that were set/added in this mutation.
  12847. func (m *EmployeeMutation) AddedEdges() []string {
  12848. edges := make([]string, 0, 2)
  12849. if m.em_work_experiences != nil {
  12850. edges = append(edges, employee.EdgeEmWorkExperiences)
  12851. }
  12852. if m.em_tutorial != nil {
  12853. edges = append(edges, employee.EdgeEmTutorial)
  12854. }
  12855. return edges
  12856. }
  12857. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12858. // name in this mutation.
  12859. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  12860. switch name {
  12861. case employee.EdgeEmWorkExperiences:
  12862. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  12863. for id := range m.em_work_experiences {
  12864. ids = append(ids, id)
  12865. }
  12866. return ids
  12867. case employee.EdgeEmTutorial:
  12868. ids := make([]ent.Value, 0, len(m.em_tutorial))
  12869. for id := range m.em_tutorial {
  12870. ids = append(ids, id)
  12871. }
  12872. return ids
  12873. }
  12874. return nil
  12875. }
  12876. // RemovedEdges returns all edge names that were removed in this mutation.
  12877. func (m *EmployeeMutation) RemovedEdges() []string {
  12878. edges := make([]string, 0, 2)
  12879. if m.removedem_work_experiences != nil {
  12880. edges = append(edges, employee.EdgeEmWorkExperiences)
  12881. }
  12882. if m.removedem_tutorial != nil {
  12883. edges = append(edges, employee.EdgeEmTutorial)
  12884. }
  12885. return edges
  12886. }
  12887. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12888. // the given name in this mutation.
  12889. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  12890. switch name {
  12891. case employee.EdgeEmWorkExperiences:
  12892. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  12893. for id := range m.removedem_work_experiences {
  12894. ids = append(ids, id)
  12895. }
  12896. return ids
  12897. case employee.EdgeEmTutorial:
  12898. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  12899. for id := range m.removedem_tutorial {
  12900. ids = append(ids, id)
  12901. }
  12902. return ids
  12903. }
  12904. return nil
  12905. }
  12906. // ClearedEdges returns all edge names that were cleared in this mutation.
  12907. func (m *EmployeeMutation) ClearedEdges() []string {
  12908. edges := make([]string, 0, 2)
  12909. if m.clearedem_work_experiences {
  12910. edges = append(edges, employee.EdgeEmWorkExperiences)
  12911. }
  12912. if m.clearedem_tutorial {
  12913. edges = append(edges, employee.EdgeEmTutorial)
  12914. }
  12915. return edges
  12916. }
  12917. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12918. // was cleared in this mutation.
  12919. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  12920. switch name {
  12921. case employee.EdgeEmWorkExperiences:
  12922. return m.clearedem_work_experiences
  12923. case employee.EdgeEmTutorial:
  12924. return m.clearedem_tutorial
  12925. }
  12926. return false
  12927. }
  12928. // ClearEdge clears the value of the edge with the given name. It returns an error
  12929. // if that edge is not defined in the schema.
  12930. func (m *EmployeeMutation) ClearEdge(name string) error {
  12931. switch name {
  12932. }
  12933. return fmt.Errorf("unknown Employee unique edge %s", name)
  12934. }
  12935. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12936. // It returns an error if the edge is not defined in the schema.
  12937. func (m *EmployeeMutation) ResetEdge(name string) error {
  12938. switch name {
  12939. case employee.EdgeEmWorkExperiences:
  12940. m.ResetEmWorkExperiences()
  12941. return nil
  12942. case employee.EdgeEmTutorial:
  12943. m.ResetEmTutorial()
  12944. return nil
  12945. }
  12946. return fmt.Errorf("unknown Employee edge %s", name)
  12947. }
  12948. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  12949. type EmployeeConfigMutation struct {
  12950. config
  12951. op Op
  12952. typ string
  12953. id *uint64
  12954. created_at *time.Time
  12955. updated_at *time.Time
  12956. deleted_at *time.Time
  12957. stype *string
  12958. title *string
  12959. photo *string
  12960. organization_id *uint64
  12961. addorganization_id *int64
  12962. clearedFields map[string]struct{}
  12963. done bool
  12964. oldValue func(context.Context) (*EmployeeConfig, error)
  12965. predicates []predicate.EmployeeConfig
  12966. }
  12967. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  12968. // employeeconfigOption allows management of the mutation configuration using functional options.
  12969. type employeeconfigOption func(*EmployeeConfigMutation)
  12970. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  12971. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  12972. m := &EmployeeConfigMutation{
  12973. config: c,
  12974. op: op,
  12975. typ: TypeEmployeeConfig,
  12976. clearedFields: make(map[string]struct{}),
  12977. }
  12978. for _, opt := range opts {
  12979. opt(m)
  12980. }
  12981. return m
  12982. }
  12983. // withEmployeeConfigID sets the ID field of the mutation.
  12984. func withEmployeeConfigID(id uint64) employeeconfigOption {
  12985. return func(m *EmployeeConfigMutation) {
  12986. var (
  12987. err error
  12988. once sync.Once
  12989. value *EmployeeConfig
  12990. )
  12991. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  12992. once.Do(func() {
  12993. if m.done {
  12994. err = errors.New("querying old values post mutation is not allowed")
  12995. } else {
  12996. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  12997. }
  12998. })
  12999. return value, err
  13000. }
  13001. m.id = &id
  13002. }
  13003. }
  13004. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  13005. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  13006. return func(m *EmployeeConfigMutation) {
  13007. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  13008. return node, nil
  13009. }
  13010. m.id = &node.ID
  13011. }
  13012. }
  13013. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13014. // executed in a transaction (ent.Tx), a transactional client is returned.
  13015. func (m EmployeeConfigMutation) Client() *Client {
  13016. client := &Client{config: m.config}
  13017. client.init()
  13018. return client
  13019. }
  13020. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13021. // it returns an error otherwise.
  13022. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  13023. if _, ok := m.driver.(*txDriver); !ok {
  13024. return nil, errors.New("ent: mutation is not running in a transaction")
  13025. }
  13026. tx := &Tx{config: m.config}
  13027. tx.init()
  13028. return tx, nil
  13029. }
  13030. // SetID sets the value of the id field. Note that this
  13031. // operation is only accepted on creation of EmployeeConfig entities.
  13032. func (m *EmployeeConfigMutation) SetID(id uint64) {
  13033. m.id = &id
  13034. }
  13035. // ID returns the ID value in the mutation. Note that the ID is only available
  13036. // if it was provided to the builder or after it was returned from the database.
  13037. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  13038. if m.id == nil {
  13039. return
  13040. }
  13041. return *m.id, true
  13042. }
  13043. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13044. // That means, if the mutation is applied within a transaction with an isolation level such
  13045. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13046. // or updated by the mutation.
  13047. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  13048. switch {
  13049. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13050. id, exists := m.ID()
  13051. if exists {
  13052. return []uint64{id}, nil
  13053. }
  13054. fallthrough
  13055. case m.op.Is(OpUpdate | OpDelete):
  13056. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  13057. default:
  13058. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13059. }
  13060. }
  13061. // SetCreatedAt sets the "created_at" field.
  13062. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  13063. m.created_at = &t
  13064. }
  13065. // CreatedAt returns the value of the "created_at" field in the mutation.
  13066. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  13067. v := m.created_at
  13068. if v == nil {
  13069. return
  13070. }
  13071. return *v, true
  13072. }
  13073. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  13074. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13076. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13077. if !m.op.Is(OpUpdateOne) {
  13078. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13079. }
  13080. if m.id == nil || m.oldValue == nil {
  13081. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13082. }
  13083. oldValue, err := m.oldValue(ctx)
  13084. if err != nil {
  13085. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13086. }
  13087. return oldValue.CreatedAt, nil
  13088. }
  13089. // ResetCreatedAt resets all changes to the "created_at" field.
  13090. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  13091. m.created_at = nil
  13092. }
  13093. // SetUpdatedAt sets the "updated_at" field.
  13094. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  13095. m.updated_at = &t
  13096. }
  13097. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13098. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  13099. v := m.updated_at
  13100. if v == nil {
  13101. return
  13102. }
  13103. return *v, true
  13104. }
  13105. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  13106. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13108. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13109. if !m.op.Is(OpUpdateOne) {
  13110. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13111. }
  13112. if m.id == nil || m.oldValue == nil {
  13113. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13114. }
  13115. oldValue, err := m.oldValue(ctx)
  13116. if err != nil {
  13117. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13118. }
  13119. return oldValue.UpdatedAt, nil
  13120. }
  13121. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13122. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  13123. m.updated_at = nil
  13124. }
  13125. // SetDeletedAt sets the "deleted_at" field.
  13126. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  13127. m.deleted_at = &t
  13128. }
  13129. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13130. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  13131. v := m.deleted_at
  13132. if v == nil {
  13133. return
  13134. }
  13135. return *v, true
  13136. }
  13137. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  13138. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13140. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13141. if !m.op.Is(OpUpdateOne) {
  13142. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13143. }
  13144. if m.id == nil || m.oldValue == nil {
  13145. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13146. }
  13147. oldValue, err := m.oldValue(ctx)
  13148. if err != nil {
  13149. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13150. }
  13151. return oldValue.DeletedAt, nil
  13152. }
  13153. // ClearDeletedAt clears the value of the "deleted_at" field.
  13154. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  13155. m.deleted_at = nil
  13156. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  13157. }
  13158. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13159. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  13160. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  13161. return ok
  13162. }
  13163. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13164. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  13165. m.deleted_at = nil
  13166. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  13167. }
  13168. // SetStype sets the "stype" field.
  13169. func (m *EmployeeConfigMutation) SetStype(s string) {
  13170. m.stype = &s
  13171. }
  13172. // Stype returns the value of the "stype" field in the mutation.
  13173. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  13174. v := m.stype
  13175. if v == nil {
  13176. return
  13177. }
  13178. return *v, true
  13179. }
  13180. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  13181. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13183. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  13184. if !m.op.Is(OpUpdateOne) {
  13185. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  13186. }
  13187. if m.id == nil || m.oldValue == nil {
  13188. return v, errors.New("OldStype requires an ID field in the mutation")
  13189. }
  13190. oldValue, err := m.oldValue(ctx)
  13191. if err != nil {
  13192. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  13193. }
  13194. return oldValue.Stype, nil
  13195. }
  13196. // ResetStype resets all changes to the "stype" field.
  13197. func (m *EmployeeConfigMutation) ResetStype() {
  13198. m.stype = nil
  13199. }
  13200. // SetTitle sets the "title" field.
  13201. func (m *EmployeeConfigMutation) SetTitle(s string) {
  13202. m.title = &s
  13203. }
  13204. // Title returns the value of the "title" field in the mutation.
  13205. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  13206. v := m.title
  13207. if v == nil {
  13208. return
  13209. }
  13210. return *v, true
  13211. }
  13212. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  13213. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13215. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  13216. if !m.op.Is(OpUpdateOne) {
  13217. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13218. }
  13219. if m.id == nil || m.oldValue == nil {
  13220. return v, errors.New("OldTitle requires an ID field in the mutation")
  13221. }
  13222. oldValue, err := m.oldValue(ctx)
  13223. if err != nil {
  13224. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13225. }
  13226. return oldValue.Title, nil
  13227. }
  13228. // ResetTitle resets all changes to the "title" field.
  13229. func (m *EmployeeConfigMutation) ResetTitle() {
  13230. m.title = nil
  13231. }
  13232. // SetPhoto sets the "photo" field.
  13233. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  13234. m.photo = &s
  13235. }
  13236. // Photo returns the value of the "photo" field in the mutation.
  13237. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  13238. v := m.photo
  13239. if v == nil {
  13240. return
  13241. }
  13242. return *v, true
  13243. }
  13244. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  13245. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13247. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  13248. if !m.op.Is(OpUpdateOne) {
  13249. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  13250. }
  13251. if m.id == nil || m.oldValue == nil {
  13252. return v, errors.New("OldPhoto requires an ID field in the mutation")
  13253. }
  13254. oldValue, err := m.oldValue(ctx)
  13255. if err != nil {
  13256. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  13257. }
  13258. return oldValue.Photo, nil
  13259. }
  13260. // ResetPhoto resets all changes to the "photo" field.
  13261. func (m *EmployeeConfigMutation) ResetPhoto() {
  13262. m.photo = nil
  13263. }
  13264. // SetOrganizationID sets the "organization_id" field.
  13265. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  13266. m.organization_id = &u
  13267. m.addorganization_id = nil
  13268. }
  13269. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13270. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  13271. v := m.organization_id
  13272. if v == nil {
  13273. return
  13274. }
  13275. return *v, true
  13276. }
  13277. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  13278. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13280. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13281. if !m.op.Is(OpUpdateOne) {
  13282. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13283. }
  13284. if m.id == nil || m.oldValue == nil {
  13285. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13286. }
  13287. oldValue, err := m.oldValue(ctx)
  13288. if err != nil {
  13289. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13290. }
  13291. return oldValue.OrganizationID, nil
  13292. }
  13293. // AddOrganizationID adds u to the "organization_id" field.
  13294. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  13295. if m.addorganization_id != nil {
  13296. *m.addorganization_id += u
  13297. } else {
  13298. m.addorganization_id = &u
  13299. }
  13300. }
  13301. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13302. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  13303. v := m.addorganization_id
  13304. if v == nil {
  13305. return
  13306. }
  13307. return *v, true
  13308. }
  13309. // ClearOrganizationID clears the value of the "organization_id" field.
  13310. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  13311. m.organization_id = nil
  13312. m.addorganization_id = nil
  13313. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  13314. }
  13315. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13316. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  13317. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  13318. return ok
  13319. }
  13320. // ResetOrganizationID resets all changes to the "organization_id" field.
  13321. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  13322. m.organization_id = nil
  13323. m.addorganization_id = nil
  13324. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  13325. }
  13326. // Where appends a list predicates to the EmployeeConfigMutation builder.
  13327. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  13328. m.predicates = append(m.predicates, ps...)
  13329. }
  13330. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  13331. // users can use type-assertion to append predicates that do not depend on any generated package.
  13332. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  13333. p := make([]predicate.EmployeeConfig, len(ps))
  13334. for i := range ps {
  13335. p[i] = ps[i]
  13336. }
  13337. m.Where(p...)
  13338. }
  13339. // Op returns the operation name.
  13340. func (m *EmployeeConfigMutation) Op() Op {
  13341. return m.op
  13342. }
  13343. // SetOp allows setting the mutation operation.
  13344. func (m *EmployeeConfigMutation) SetOp(op Op) {
  13345. m.op = op
  13346. }
  13347. // Type returns the node type of this mutation (EmployeeConfig).
  13348. func (m *EmployeeConfigMutation) Type() string {
  13349. return m.typ
  13350. }
  13351. // Fields returns all fields that were changed during this mutation. Note that in
  13352. // order to get all numeric fields that were incremented/decremented, call
  13353. // AddedFields().
  13354. func (m *EmployeeConfigMutation) Fields() []string {
  13355. fields := make([]string, 0, 7)
  13356. if m.created_at != nil {
  13357. fields = append(fields, employeeconfig.FieldCreatedAt)
  13358. }
  13359. if m.updated_at != nil {
  13360. fields = append(fields, employeeconfig.FieldUpdatedAt)
  13361. }
  13362. if m.deleted_at != nil {
  13363. fields = append(fields, employeeconfig.FieldDeletedAt)
  13364. }
  13365. if m.stype != nil {
  13366. fields = append(fields, employeeconfig.FieldStype)
  13367. }
  13368. if m.title != nil {
  13369. fields = append(fields, employeeconfig.FieldTitle)
  13370. }
  13371. if m.photo != nil {
  13372. fields = append(fields, employeeconfig.FieldPhoto)
  13373. }
  13374. if m.organization_id != nil {
  13375. fields = append(fields, employeeconfig.FieldOrganizationID)
  13376. }
  13377. return fields
  13378. }
  13379. // Field returns the value of a field with the given name. The second boolean
  13380. // return value indicates that this field was not set, or was not defined in the
  13381. // schema.
  13382. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  13383. switch name {
  13384. case employeeconfig.FieldCreatedAt:
  13385. return m.CreatedAt()
  13386. case employeeconfig.FieldUpdatedAt:
  13387. return m.UpdatedAt()
  13388. case employeeconfig.FieldDeletedAt:
  13389. return m.DeletedAt()
  13390. case employeeconfig.FieldStype:
  13391. return m.Stype()
  13392. case employeeconfig.FieldTitle:
  13393. return m.Title()
  13394. case employeeconfig.FieldPhoto:
  13395. return m.Photo()
  13396. case employeeconfig.FieldOrganizationID:
  13397. return m.OrganizationID()
  13398. }
  13399. return nil, false
  13400. }
  13401. // OldField returns the old value of the field from the database. An error is
  13402. // returned if the mutation operation is not UpdateOne, or the query to the
  13403. // database failed.
  13404. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13405. switch name {
  13406. case employeeconfig.FieldCreatedAt:
  13407. return m.OldCreatedAt(ctx)
  13408. case employeeconfig.FieldUpdatedAt:
  13409. return m.OldUpdatedAt(ctx)
  13410. case employeeconfig.FieldDeletedAt:
  13411. return m.OldDeletedAt(ctx)
  13412. case employeeconfig.FieldStype:
  13413. return m.OldStype(ctx)
  13414. case employeeconfig.FieldTitle:
  13415. return m.OldTitle(ctx)
  13416. case employeeconfig.FieldPhoto:
  13417. return m.OldPhoto(ctx)
  13418. case employeeconfig.FieldOrganizationID:
  13419. return m.OldOrganizationID(ctx)
  13420. }
  13421. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  13422. }
  13423. // SetField sets the value of a field with the given name. It returns an error if
  13424. // the field is not defined in the schema, or if the type mismatched the field
  13425. // type.
  13426. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  13427. switch name {
  13428. case employeeconfig.FieldCreatedAt:
  13429. v, ok := value.(time.Time)
  13430. if !ok {
  13431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13432. }
  13433. m.SetCreatedAt(v)
  13434. return nil
  13435. case employeeconfig.FieldUpdatedAt:
  13436. v, ok := value.(time.Time)
  13437. if !ok {
  13438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13439. }
  13440. m.SetUpdatedAt(v)
  13441. return nil
  13442. case employeeconfig.FieldDeletedAt:
  13443. v, ok := value.(time.Time)
  13444. if !ok {
  13445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13446. }
  13447. m.SetDeletedAt(v)
  13448. return nil
  13449. case employeeconfig.FieldStype:
  13450. v, ok := value.(string)
  13451. if !ok {
  13452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13453. }
  13454. m.SetStype(v)
  13455. return nil
  13456. case employeeconfig.FieldTitle:
  13457. v, ok := value.(string)
  13458. if !ok {
  13459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13460. }
  13461. m.SetTitle(v)
  13462. return nil
  13463. case employeeconfig.FieldPhoto:
  13464. v, ok := value.(string)
  13465. if !ok {
  13466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13467. }
  13468. m.SetPhoto(v)
  13469. return nil
  13470. case employeeconfig.FieldOrganizationID:
  13471. v, ok := value.(uint64)
  13472. if !ok {
  13473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13474. }
  13475. m.SetOrganizationID(v)
  13476. return nil
  13477. }
  13478. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13479. }
  13480. // AddedFields returns all numeric fields that were incremented/decremented during
  13481. // this mutation.
  13482. func (m *EmployeeConfigMutation) AddedFields() []string {
  13483. var fields []string
  13484. if m.addorganization_id != nil {
  13485. fields = append(fields, employeeconfig.FieldOrganizationID)
  13486. }
  13487. return fields
  13488. }
  13489. // AddedField returns the numeric value that was incremented/decremented on a field
  13490. // with the given name. The second boolean return value indicates that this field
  13491. // was not set, or was not defined in the schema.
  13492. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  13493. switch name {
  13494. case employeeconfig.FieldOrganizationID:
  13495. return m.AddedOrganizationID()
  13496. }
  13497. return nil, false
  13498. }
  13499. // AddField adds the value to the field with the given name. It returns an error if
  13500. // the field is not defined in the schema, or if the type mismatched the field
  13501. // type.
  13502. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  13503. switch name {
  13504. case employeeconfig.FieldOrganizationID:
  13505. v, ok := value.(int64)
  13506. if !ok {
  13507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13508. }
  13509. m.AddOrganizationID(v)
  13510. return nil
  13511. }
  13512. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  13513. }
  13514. // ClearedFields returns all nullable fields that were cleared during this
  13515. // mutation.
  13516. func (m *EmployeeConfigMutation) ClearedFields() []string {
  13517. var fields []string
  13518. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  13519. fields = append(fields, employeeconfig.FieldDeletedAt)
  13520. }
  13521. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  13522. fields = append(fields, employeeconfig.FieldOrganizationID)
  13523. }
  13524. return fields
  13525. }
  13526. // FieldCleared returns a boolean indicating if a field with the given name was
  13527. // cleared in this mutation.
  13528. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  13529. _, ok := m.clearedFields[name]
  13530. return ok
  13531. }
  13532. // ClearField clears the value of the field with the given name. It returns an
  13533. // error if the field is not defined in the schema.
  13534. func (m *EmployeeConfigMutation) ClearField(name string) error {
  13535. switch name {
  13536. case employeeconfig.FieldDeletedAt:
  13537. m.ClearDeletedAt()
  13538. return nil
  13539. case employeeconfig.FieldOrganizationID:
  13540. m.ClearOrganizationID()
  13541. return nil
  13542. }
  13543. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  13544. }
  13545. // ResetField resets all changes in the mutation for the field with the given name.
  13546. // It returns an error if the field is not defined in the schema.
  13547. func (m *EmployeeConfigMutation) ResetField(name string) error {
  13548. switch name {
  13549. case employeeconfig.FieldCreatedAt:
  13550. m.ResetCreatedAt()
  13551. return nil
  13552. case employeeconfig.FieldUpdatedAt:
  13553. m.ResetUpdatedAt()
  13554. return nil
  13555. case employeeconfig.FieldDeletedAt:
  13556. m.ResetDeletedAt()
  13557. return nil
  13558. case employeeconfig.FieldStype:
  13559. m.ResetStype()
  13560. return nil
  13561. case employeeconfig.FieldTitle:
  13562. m.ResetTitle()
  13563. return nil
  13564. case employeeconfig.FieldPhoto:
  13565. m.ResetPhoto()
  13566. return nil
  13567. case employeeconfig.FieldOrganizationID:
  13568. m.ResetOrganizationID()
  13569. return nil
  13570. }
  13571. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13572. }
  13573. // AddedEdges returns all edge names that were set/added in this mutation.
  13574. func (m *EmployeeConfigMutation) AddedEdges() []string {
  13575. edges := make([]string, 0, 0)
  13576. return edges
  13577. }
  13578. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13579. // name in this mutation.
  13580. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  13581. return nil
  13582. }
  13583. // RemovedEdges returns all edge names that were removed in this mutation.
  13584. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  13585. edges := make([]string, 0, 0)
  13586. return edges
  13587. }
  13588. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13589. // the given name in this mutation.
  13590. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  13591. return nil
  13592. }
  13593. // ClearedEdges returns all edge names that were cleared in this mutation.
  13594. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  13595. edges := make([]string, 0, 0)
  13596. return edges
  13597. }
  13598. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13599. // was cleared in this mutation.
  13600. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  13601. return false
  13602. }
  13603. // ClearEdge clears the value of the edge with the given name. It returns an error
  13604. // if that edge is not defined in the schema.
  13605. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  13606. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  13607. }
  13608. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13609. // It returns an error if the edge is not defined in the schema.
  13610. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  13611. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  13612. }
  13613. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  13614. type LabelMutation struct {
  13615. config
  13616. op Op
  13617. typ string
  13618. id *uint64
  13619. created_at *time.Time
  13620. updated_at *time.Time
  13621. status *uint8
  13622. addstatus *int8
  13623. _type *int
  13624. add_type *int
  13625. name *string
  13626. from *int
  13627. addfrom *int
  13628. mode *int
  13629. addmode *int
  13630. conditions *string
  13631. organization_id *uint64
  13632. addorganization_id *int64
  13633. clearedFields map[string]struct{}
  13634. label_relationships map[uint64]struct{}
  13635. removedlabel_relationships map[uint64]struct{}
  13636. clearedlabel_relationships bool
  13637. done bool
  13638. oldValue func(context.Context) (*Label, error)
  13639. predicates []predicate.Label
  13640. }
  13641. var _ ent.Mutation = (*LabelMutation)(nil)
  13642. // labelOption allows management of the mutation configuration using functional options.
  13643. type labelOption func(*LabelMutation)
  13644. // newLabelMutation creates new mutation for the Label entity.
  13645. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  13646. m := &LabelMutation{
  13647. config: c,
  13648. op: op,
  13649. typ: TypeLabel,
  13650. clearedFields: make(map[string]struct{}),
  13651. }
  13652. for _, opt := range opts {
  13653. opt(m)
  13654. }
  13655. return m
  13656. }
  13657. // withLabelID sets the ID field of the mutation.
  13658. func withLabelID(id uint64) labelOption {
  13659. return func(m *LabelMutation) {
  13660. var (
  13661. err error
  13662. once sync.Once
  13663. value *Label
  13664. )
  13665. m.oldValue = func(ctx context.Context) (*Label, error) {
  13666. once.Do(func() {
  13667. if m.done {
  13668. err = errors.New("querying old values post mutation is not allowed")
  13669. } else {
  13670. value, err = m.Client().Label.Get(ctx, id)
  13671. }
  13672. })
  13673. return value, err
  13674. }
  13675. m.id = &id
  13676. }
  13677. }
  13678. // withLabel sets the old Label of the mutation.
  13679. func withLabel(node *Label) labelOption {
  13680. return func(m *LabelMutation) {
  13681. m.oldValue = func(context.Context) (*Label, error) {
  13682. return node, nil
  13683. }
  13684. m.id = &node.ID
  13685. }
  13686. }
  13687. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13688. // executed in a transaction (ent.Tx), a transactional client is returned.
  13689. func (m LabelMutation) Client() *Client {
  13690. client := &Client{config: m.config}
  13691. client.init()
  13692. return client
  13693. }
  13694. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13695. // it returns an error otherwise.
  13696. func (m LabelMutation) Tx() (*Tx, error) {
  13697. if _, ok := m.driver.(*txDriver); !ok {
  13698. return nil, errors.New("ent: mutation is not running in a transaction")
  13699. }
  13700. tx := &Tx{config: m.config}
  13701. tx.init()
  13702. return tx, nil
  13703. }
  13704. // SetID sets the value of the id field. Note that this
  13705. // operation is only accepted on creation of Label entities.
  13706. func (m *LabelMutation) SetID(id uint64) {
  13707. m.id = &id
  13708. }
  13709. // ID returns the ID value in the mutation. Note that the ID is only available
  13710. // if it was provided to the builder or after it was returned from the database.
  13711. func (m *LabelMutation) ID() (id uint64, exists bool) {
  13712. if m.id == nil {
  13713. return
  13714. }
  13715. return *m.id, true
  13716. }
  13717. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13718. // That means, if the mutation is applied within a transaction with an isolation level such
  13719. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13720. // or updated by the mutation.
  13721. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  13722. switch {
  13723. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13724. id, exists := m.ID()
  13725. if exists {
  13726. return []uint64{id}, nil
  13727. }
  13728. fallthrough
  13729. case m.op.Is(OpUpdate | OpDelete):
  13730. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  13731. default:
  13732. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13733. }
  13734. }
  13735. // SetCreatedAt sets the "created_at" field.
  13736. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  13737. m.created_at = &t
  13738. }
  13739. // CreatedAt returns the value of the "created_at" field in the mutation.
  13740. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  13741. v := m.created_at
  13742. if v == nil {
  13743. return
  13744. }
  13745. return *v, true
  13746. }
  13747. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  13748. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13750. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13751. if !m.op.Is(OpUpdateOne) {
  13752. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13753. }
  13754. if m.id == nil || m.oldValue == nil {
  13755. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13756. }
  13757. oldValue, err := m.oldValue(ctx)
  13758. if err != nil {
  13759. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13760. }
  13761. return oldValue.CreatedAt, nil
  13762. }
  13763. // ResetCreatedAt resets all changes to the "created_at" field.
  13764. func (m *LabelMutation) ResetCreatedAt() {
  13765. m.created_at = nil
  13766. }
  13767. // SetUpdatedAt sets the "updated_at" field.
  13768. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  13769. m.updated_at = &t
  13770. }
  13771. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13772. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  13773. v := m.updated_at
  13774. if v == nil {
  13775. return
  13776. }
  13777. return *v, true
  13778. }
  13779. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  13780. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13782. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13783. if !m.op.Is(OpUpdateOne) {
  13784. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13785. }
  13786. if m.id == nil || m.oldValue == nil {
  13787. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13788. }
  13789. oldValue, err := m.oldValue(ctx)
  13790. if err != nil {
  13791. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13792. }
  13793. return oldValue.UpdatedAt, nil
  13794. }
  13795. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13796. func (m *LabelMutation) ResetUpdatedAt() {
  13797. m.updated_at = nil
  13798. }
  13799. // SetStatus sets the "status" field.
  13800. func (m *LabelMutation) SetStatus(u uint8) {
  13801. m.status = &u
  13802. m.addstatus = nil
  13803. }
  13804. // Status returns the value of the "status" field in the mutation.
  13805. func (m *LabelMutation) Status() (r uint8, exists bool) {
  13806. v := m.status
  13807. if v == nil {
  13808. return
  13809. }
  13810. return *v, true
  13811. }
  13812. // OldStatus returns the old "status" field's value of the Label entity.
  13813. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13815. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13816. if !m.op.Is(OpUpdateOne) {
  13817. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13818. }
  13819. if m.id == nil || m.oldValue == nil {
  13820. return v, errors.New("OldStatus requires an ID field in the mutation")
  13821. }
  13822. oldValue, err := m.oldValue(ctx)
  13823. if err != nil {
  13824. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13825. }
  13826. return oldValue.Status, nil
  13827. }
  13828. // AddStatus adds u to the "status" field.
  13829. func (m *LabelMutation) AddStatus(u int8) {
  13830. if m.addstatus != nil {
  13831. *m.addstatus += u
  13832. } else {
  13833. m.addstatus = &u
  13834. }
  13835. }
  13836. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13837. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  13838. v := m.addstatus
  13839. if v == nil {
  13840. return
  13841. }
  13842. return *v, true
  13843. }
  13844. // ClearStatus clears the value of the "status" field.
  13845. func (m *LabelMutation) ClearStatus() {
  13846. m.status = nil
  13847. m.addstatus = nil
  13848. m.clearedFields[label.FieldStatus] = struct{}{}
  13849. }
  13850. // StatusCleared returns if the "status" field was cleared in this mutation.
  13851. func (m *LabelMutation) StatusCleared() bool {
  13852. _, ok := m.clearedFields[label.FieldStatus]
  13853. return ok
  13854. }
  13855. // ResetStatus resets all changes to the "status" field.
  13856. func (m *LabelMutation) ResetStatus() {
  13857. m.status = nil
  13858. m.addstatus = nil
  13859. delete(m.clearedFields, label.FieldStatus)
  13860. }
  13861. // SetType sets the "type" field.
  13862. func (m *LabelMutation) SetType(i int) {
  13863. m._type = &i
  13864. m.add_type = nil
  13865. }
  13866. // GetType returns the value of the "type" field in the mutation.
  13867. func (m *LabelMutation) GetType() (r int, exists bool) {
  13868. v := m._type
  13869. if v == nil {
  13870. return
  13871. }
  13872. return *v, true
  13873. }
  13874. // OldType returns the old "type" field's value of the Label entity.
  13875. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13877. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  13878. if !m.op.Is(OpUpdateOne) {
  13879. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13880. }
  13881. if m.id == nil || m.oldValue == nil {
  13882. return v, errors.New("OldType requires an ID field in the mutation")
  13883. }
  13884. oldValue, err := m.oldValue(ctx)
  13885. if err != nil {
  13886. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13887. }
  13888. return oldValue.Type, nil
  13889. }
  13890. // AddType adds i to the "type" field.
  13891. func (m *LabelMutation) AddType(i int) {
  13892. if m.add_type != nil {
  13893. *m.add_type += i
  13894. } else {
  13895. m.add_type = &i
  13896. }
  13897. }
  13898. // AddedType returns the value that was added to the "type" field in this mutation.
  13899. func (m *LabelMutation) AddedType() (r int, exists bool) {
  13900. v := m.add_type
  13901. if v == nil {
  13902. return
  13903. }
  13904. return *v, true
  13905. }
  13906. // ResetType resets all changes to the "type" field.
  13907. func (m *LabelMutation) ResetType() {
  13908. m._type = nil
  13909. m.add_type = nil
  13910. }
  13911. // SetName sets the "name" field.
  13912. func (m *LabelMutation) SetName(s string) {
  13913. m.name = &s
  13914. }
  13915. // Name returns the value of the "name" field in the mutation.
  13916. func (m *LabelMutation) Name() (r string, exists bool) {
  13917. v := m.name
  13918. if v == nil {
  13919. return
  13920. }
  13921. return *v, true
  13922. }
  13923. // OldName returns the old "name" field's value of the Label entity.
  13924. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13926. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  13927. if !m.op.Is(OpUpdateOne) {
  13928. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13929. }
  13930. if m.id == nil || m.oldValue == nil {
  13931. return v, errors.New("OldName requires an ID field in the mutation")
  13932. }
  13933. oldValue, err := m.oldValue(ctx)
  13934. if err != nil {
  13935. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13936. }
  13937. return oldValue.Name, nil
  13938. }
  13939. // ResetName resets all changes to the "name" field.
  13940. func (m *LabelMutation) ResetName() {
  13941. m.name = nil
  13942. }
  13943. // SetFrom sets the "from" field.
  13944. func (m *LabelMutation) SetFrom(i int) {
  13945. m.from = &i
  13946. m.addfrom = nil
  13947. }
  13948. // From returns the value of the "from" field in the mutation.
  13949. func (m *LabelMutation) From() (r int, exists bool) {
  13950. v := m.from
  13951. if v == nil {
  13952. return
  13953. }
  13954. return *v, true
  13955. }
  13956. // OldFrom returns the old "from" field's value of the Label entity.
  13957. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13959. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  13960. if !m.op.Is(OpUpdateOne) {
  13961. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  13962. }
  13963. if m.id == nil || m.oldValue == nil {
  13964. return v, errors.New("OldFrom requires an ID field in the mutation")
  13965. }
  13966. oldValue, err := m.oldValue(ctx)
  13967. if err != nil {
  13968. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  13969. }
  13970. return oldValue.From, nil
  13971. }
  13972. // AddFrom adds i to the "from" field.
  13973. func (m *LabelMutation) AddFrom(i int) {
  13974. if m.addfrom != nil {
  13975. *m.addfrom += i
  13976. } else {
  13977. m.addfrom = &i
  13978. }
  13979. }
  13980. // AddedFrom returns the value that was added to the "from" field in this mutation.
  13981. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  13982. v := m.addfrom
  13983. if v == nil {
  13984. return
  13985. }
  13986. return *v, true
  13987. }
  13988. // ResetFrom resets all changes to the "from" field.
  13989. func (m *LabelMutation) ResetFrom() {
  13990. m.from = nil
  13991. m.addfrom = nil
  13992. }
  13993. // SetMode sets the "mode" field.
  13994. func (m *LabelMutation) SetMode(i int) {
  13995. m.mode = &i
  13996. m.addmode = nil
  13997. }
  13998. // Mode returns the value of the "mode" field in the mutation.
  13999. func (m *LabelMutation) Mode() (r int, exists bool) {
  14000. v := m.mode
  14001. if v == nil {
  14002. return
  14003. }
  14004. return *v, true
  14005. }
  14006. // OldMode returns the old "mode" field's value of the Label entity.
  14007. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14009. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  14010. if !m.op.Is(OpUpdateOne) {
  14011. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  14012. }
  14013. if m.id == nil || m.oldValue == nil {
  14014. return v, errors.New("OldMode requires an ID field in the mutation")
  14015. }
  14016. oldValue, err := m.oldValue(ctx)
  14017. if err != nil {
  14018. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  14019. }
  14020. return oldValue.Mode, nil
  14021. }
  14022. // AddMode adds i to the "mode" field.
  14023. func (m *LabelMutation) AddMode(i int) {
  14024. if m.addmode != nil {
  14025. *m.addmode += i
  14026. } else {
  14027. m.addmode = &i
  14028. }
  14029. }
  14030. // AddedMode returns the value that was added to the "mode" field in this mutation.
  14031. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  14032. v := m.addmode
  14033. if v == nil {
  14034. return
  14035. }
  14036. return *v, true
  14037. }
  14038. // ResetMode resets all changes to the "mode" field.
  14039. func (m *LabelMutation) ResetMode() {
  14040. m.mode = nil
  14041. m.addmode = nil
  14042. }
  14043. // SetConditions sets the "conditions" field.
  14044. func (m *LabelMutation) SetConditions(s string) {
  14045. m.conditions = &s
  14046. }
  14047. // Conditions returns the value of the "conditions" field in the mutation.
  14048. func (m *LabelMutation) Conditions() (r string, exists bool) {
  14049. v := m.conditions
  14050. if v == nil {
  14051. return
  14052. }
  14053. return *v, true
  14054. }
  14055. // OldConditions returns the old "conditions" field's value of the Label entity.
  14056. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14058. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  14059. if !m.op.Is(OpUpdateOne) {
  14060. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  14061. }
  14062. if m.id == nil || m.oldValue == nil {
  14063. return v, errors.New("OldConditions requires an ID field in the mutation")
  14064. }
  14065. oldValue, err := m.oldValue(ctx)
  14066. if err != nil {
  14067. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  14068. }
  14069. return oldValue.Conditions, nil
  14070. }
  14071. // ClearConditions clears the value of the "conditions" field.
  14072. func (m *LabelMutation) ClearConditions() {
  14073. m.conditions = nil
  14074. m.clearedFields[label.FieldConditions] = struct{}{}
  14075. }
  14076. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  14077. func (m *LabelMutation) ConditionsCleared() bool {
  14078. _, ok := m.clearedFields[label.FieldConditions]
  14079. return ok
  14080. }
  14081. // ResetConditions resets all changes to the "conditions" field.
  14082. func (m *LabelMutation) ResetConditions() {
  14083. m.conditions = nil
  14084. delete(m.clearedFields, label.FieldConditions)
  14085. }
  14086. // SetOrganizationID sets the "organization_id" field.
  14087. func (m *LabelMutation) SetOrganizationID(u uint64) {
  14088. m.organization_id = &u
  14089. m.addorganization_id = nil
  14090. }
  14091. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14092. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  14093. v := m.organization_id
  14094. if v == nil {
  14095. return
  14096. }
  14097. return *v, true
  14098. }
  14099. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  14100. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14102. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14103. if !m.op.Is(OpUpdateOne) {
  14104. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14105. }
  14106. if m.id == nil || m.oldValue == nil {
  14107. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14108. }
  14109. oldValue, err := m.oldValue(ctx)
  14110. if err != nil {
  14111. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14112. }
  14113. return oldValue.OrganizationID, nil
  14114. }
  14115. // AddOrganizationID adds u to the "organization_id" field.
  14116. func (m *LabelMutation) AddOrganizationID(u int64) {
  14117. if m.addorganization_id != nil {
  14118. *m.addorganization_id += u
  14119. } else {
  14120. m.addorganization_id = &u
  14121. }
  14122. }
  14123. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14124. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  14125. v := m.addorganization_id
  14126. if v == nil {
  14127. return
  14128. }
  14129. return *v, true
  14130. }
  14131. // ClearOrganizationID clears the value of the "organization_id" field.
  14132. func (m *LabelMutation) ClearOrganizationID() {
  14133. m.organization_id = nil
  14134. m.addorganization_id = nil
  14135. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  14136. }
  14137. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14138. func (m *LabelMutation) OrganizationIDCleared() bool {
  14139. _, ok := m.clearedFields[label.FieldOrganizationID]
  14140. return ok
  14141. }
  14142. // ResetOrganizationID resets all changes to the "organization_id" field.
  14143. func (m *LabelMutation) ResetOrganizationID() {
  14144. m.organization_id = nil
  14145. m.addorganization_id = nil
  14146. delete(m.clearedFields, label.FieldOrganizationID)
  14147. }
  14148. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  14149. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  14150. if m.label_relationships == nil {
  14151. m.label_relationships = make(map[uint64]struct{})
  14152. }
  14153. for i := range ids {
  14154. m.label_relationships[ids[i]] = struct{}{}
  14155. }
  14156. }
  14157. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  14158. func (m *LabelMutation) ClearLabelRelationships() {
  14159. m.clearedlabel_relationships = true
  14160. }
  14161. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  14162. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  14163. return m.clearedlabel_relationships
  14164. }
  14165. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  14166. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  14167. if m.removedlabel_relationships == nil {
  14168. m.removedlabel_relationships = make(map[uint64]struct{})
  14169. }
  14170. for i := range ids {
  14171. delete(m.label_relationships, ids[i])
  14172. m.removedlabel_relationships[ids[i]] = struct{}{}
  14173. }
  14174. }
  14175. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  14176. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  14177. for id := range m.removedlabel_relationships {
  14178. ids = append(ids, id)
  14179. }
  14180. return
  14181. }
  14182. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  14183. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  14184. for id := range m.label_relationships {
  14185. ids = append(ids, id)
  14186. }
  14187. return
  14188. }
  14189. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  14190. func (m *LabelMutation) ResetLabelRelationships() {
  14191. m.label_relationships = nil
  14192. m.clearedlabel_relationships = false
  14193. m.removedlabel_relationships = nil
  14194. }
  14195. // Where appends a list predicates to the LabelMutation builder.
  14196. func (m *LabelMutation) Where(ps ...predicate.Label) {
  14197. m.predicates = append(m.predicates, ps...)
  14198. }
  14199. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  14200. // users can use type-assertion to append predicates that do not depend on any generated package.
  14201. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  14202. p := make([]predicate.Label, len(ps))
  14203. for i := range ps {
  14204. p[i] = ps[i]
  14205. }
  14206. m.Where(p...)
  14207. }
  14208. // Op returns the operation name.
  14209. func (m *LabelMutation) Op() Op {
  14210. return m.op
  14211. }
  14212. // SetOp allows setting the mutation operation.
  14213. func (m *LabelMutation) SetOp(op Op) {
  14214. m.op = op
  14215. }
  14216. // Type returns the node type of this mutation (Label).
  14217. func (m *LabelMutation) Type() string {
  14218. return m.typ
  14219. }
  14220. // Fields returns all fields that were changed during this mutation. Note that in
  14221. // order to get all numeric fields that were incremented/decremented, call
  14222. // AddedFields().
  14223. func (m *LabelMutation) Fields() []string {
  14224. fields := make([]string, 0, 9)
  14225. if m.created_at != nil {
  14226. fields = append(fields, label.FieldCreatedAt)
  14227. }
  14228. if m.updated_at != nil {
  14229. fields = append(fields, label.FieldUpdatedAt)
  14230. }
  14231. if m.status != nil {
  14232. fields = append(fields, label.FieldStatus)
  14233. }
  14234. if m._type != nil {
  14235. fields = append(fields, label.FieldType)
  14236. }
  14237. if m.name != nil {
  14238. fields = append(fields, label.FieldName)
  14239. }
  14240. if m.from != nil {
  14241. fields = append(fields, label.FieldFrom)
  14242. }
  14243. if m.mode != nil {
  14244. fields = append(fields, label.FieldMode)
  14245. }
  14246. if m.conditions != nil {
  14247. fields = append(fields, label.FieldConditions)
  14248. }
  14249. if m.organization_id != nil {
  14250. fields = append(fields, label.FieldOrganizationID)
  14251. }
  14252. return fields
  14253. }
  14254. // Field returns the value of a field with the given name. The second boolean
  14255. // return value indicates that this field was not set, or was not defined in the
  14256. // schema.
  14257. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  14258. switch name {
  14259. case label.FieldCreatedAt:
  14260. return m.CreatedAt()
  14261. case label.FieldUpdatedAt:
  14262. return m.UpdatedAt()
  14263. case label.FieldStatus:
  14264. return m.Status()
  14265. case label.FieldType:
  14266. return m.GetType()
  14267. case label.FieldName:
  14268. return m.Name()
  14269. case label.FieldFrom:
  14270. return m.From()
  14271. case label.FieldMode:
  14272. return m.Mode()
  14273. case label.FieldConditions:
  14274. return m.Conditions()
  14275. case label.FieldOrganizationID:
  14276. return m.OrganizationID()
  14277. }
  14278. return nil, false
  14279. }
  14280. // OldField returns the old value of the field from the database. An error is
  14281. // returned if the mutation operation is not UpdateOne, or the query to the
  14282. // database failed.
  14283. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14284. switch name {
  14285. case label.FieldCreatedAt:
  14286. return m.OldCreatedAt(ctx)
  14287. case label.FieldUpdatedAt:
  14288. return m.OldUpdatedAt(ctx)
  14289. case label.FieldStatus:
  14290. return m.OldStatus(ctx)
  14291. case label.FieldType:
  14292. return m.OldType(ctx)
  14293. case label.FieldName:
  14294. return m.OldName(ctx)
  14295. case label.FieldFrom:
  14296. return m.OldFrom(ctx)
  14297. case label.FieldMode:
  14298. return m.OldMode(ctx)
  14299. case label.FieldConditions:
  14300. return m.OldConditions(ctx)
  14301. case label.FieldOrganizationID:
  14302. return m.OldOrganizationID(ctx)
  14303. }
  14304. return nil, fmt.Errorf("unknown Label field %s", name)
  14305. }
  14306. // SetField sets the value of a field with the given name. It returns an error if
  14307. // the field is not defined in the schema, or if the type mismatched the field
  14308. // type.
  14309. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  14310. switch name {
  14311. case label.FieldCreatedAt:
  14312. v, ok := value.(time.Time)
  14313. if !ok {
  14314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14315. }
  14316. m.SetCreatedAt(v)
  14317. return nil
  14318. case label.FieldUpdatedAt:
  14319. v, ok := value.(time.Time)
  14320. if !ok {
  14321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14322. }
  14323. m.SetUpdatedAt(v)
  14324. return nil
  14325. case label.FieldStatus:
  14326. v, ok := value.(uint8)
  14327. if !ok {
  14328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14329. }
  14330. m.SetStatus(v)
  14331. return nil
  14332. case label.FieldType:
  14333. v, ok := value.(int)
  14334. if !ok {
  14335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14336. }
  14337. m.SetType(v)
  14338. return nil
  14339. case label.FieldName:
  14340. v, ok := value.(string)
  14341. if !ok {
  14342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14343. }
  14344. m.SetName(v)
  14345. return nil
  14346. case label.FieldFrom:
  14347. v, ok := value.(int)
  14348. if !ok {
  14349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14350. }
  14351. m.SetFrom(v)
  14352. return nil
  14353. case label.FieldMode:
  14354. v, ok := value.(int)
  14355. if !ok {
  14356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14357. }
  14358. m.SetMode(v)
  14359. return nil
  14360. case label.FieldConditions:
  14361. v, ok := value.(string)
  14362. if !ok {
  14363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14364. }
  14365. m.SetConditions(v)
  14366. return nil
  14367. case label.FieldOrganizationID:
  14368. v, ok := value.(uint64)
  14369. if !ok {
  14370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14371. }
  14372. m.SetOrganizationID(v)
  14373. return nil
  14374. }
  14375. return fmt.Errorf("unknown Label field %s", name)
  14376. }
  14377. // AddedFields returns all numeric fields that were incremented/decremented during
  14378. // this mutation.
  14379. func (m *LabelMutation) AddedFields() []string {
  14380. var fields []string
  14381. if m.addstatus != nil {
  14382. fields = append(fields, label.FieldStatus)
  14383. }
  14384. if m.add_type != nil {
  14385. fields = append(fields, label.FieldType)
  14386. }
  14387. if m.addfrom != nil {
  14388. fields = append(fields, label.FieldFrom)
  14389. }
  14390. if m.addmode != nil {
  14391. fields = append(fields, label.FieldMode)
  14392. }
  14393. if m.addorganization_id != nil {
  14394. fields = append(fields, label.FieldOrganizationID)
  14395. }
  14396. return fields
  14397. }
  14398. // AddedField returns the numeric value that was incremented/decremented on a field
  14399. // with the given name. The second boolean return value indicates that this field
  14400. // was not set, or was not defined in the schema.
  14401. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  14402. switch name {
  14403. case label.FieldStatus:
  14404. return m.AddedStatus()
  14405. case label.FieldType:
  14406. return m.AddedType()
  14407. case label.FieldFrom:
  14408. return m.AddedFrom()
  14409. case label.FieldMode:
  14410. return m.AddedMode()
  14411. case label.FieldOrganizationID:
  14412. return m.AddedOrganizationID()
  14413. }
  14414. return nil, false
  14415. }
  14416. // AddField adds the value to the field with the given name. It returns an error if
  14417. // the field is not defined in the schema, or if the type mismatched the field
  14418. // type.
  14419. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  14420. switch name {
  14421. case label.FieldStatus:
  14422. v, ok := value.(int8)
  14423. if !ok {
  14424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14425. }
  14426. m.AddStatus(v)
  14427. return nil
  14428. case label.FieldType:
  14429. v, ok := value.(int)
  14430. if !ok {
  14431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14432. }
  14433. m.AddType(v)
  14434. return nil
  14435. case label.FieldFrom:
  14436. v, ok := value.(int)
  14437. if !ok {
  14438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14439. }
  14440. m.AddFrom(v)
  14441. return nil
  14442. case label.FieldMode:
  14443. v, ok := value.(int)
  14444. if !ok {
  14445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14446. }
  14447. m.AddMode(v)
  14448. return nil
  14449. case label.FieldOrganizationID:
  14450. v, ok := value.(int64)
  14451. if !ok {
  14452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14453. }
  14454. m.AddOrganizationID(v)
  14455. return nil
  14456. }
  14457. return fmt.Errorf("unknown Label numeric field %s", name)
  14458. }
  14459. // ClearedFields returns all nullable fields that were cleared during this
  14460. // mutation.
  14461. func (m *LabelMutation) ClearedFields() []string {
  14462. var fields []string
  14463. if m.FieldCleared(label.FieldStatus) {
  14464. fields = append(fields, label.FieldStatus)
  14465. }
  14466. if m.FieldCleared(label.FieldConditions) {
  14467. fields = append(fields, label.FieldConditions)
  14468. }
  14469. if m.FieldCleared(label.FieldOrganizationID) {
  14470. fields = append(fields, label.FieldOrganizationID)
  14471. }
  14472. return fields
  14473. }
  14474. // FieldCleared returns a boolean indicating if a field with the given name was
  14475. // cleared in this mutation.
  14476. func (m *LabelMutation) FieldCleared(name string) bool {
  14477. _, ok := m.clearedFields[name]
  14478. return ok
  14479. }
  14480. // ClearField clears the value of the field with the given name. It returns an
  14481. // error if the field is not defined in the schema.
  14482. func (m *LabelMutation) ClearField(name string) error {
  14483. switch name {
  14484. case label.FieldStatus:
  14485. m.ClearStatus()
  14486. return nil
  14487. case label.FieldConditions:
  14488. m.ClearConditions()
  14489. return nil
  14490. case label.FieldOrganizationID:
  14491. m.ClearOrganizationID()
  14492. return nil
  14493. }
  14494. return fmt.Errorf("unknown Label nullable field %s", name)
  14495. }
  14496. // ResetField resets all changes in the mutation for the field with the given name.
  14497. // It returns an error if the field is not defined in the schema.
  14498. func (m *LabelMutation) ResetField(name string) error {
  14499. switch name {
  14500. case label.FieldCreatedAt:
  14501. m.ResetCreatedAt()
  14502. return nil
  14503. case label.FieldUpdatedAt:
  14504. m.ResetUpdatedAt()
  14505. return nil
  14506. case label.FieldStatus:
  14507. m.ResetStatus()
  14508. return nil
  14509. case label.FieldType:
  14510. m.ResetType()
  14511. return nil
  14512. case label.FieldName:
  14513. m.ResetName()
  14514. return nil
  14515. case label.FieldFrom:
  14516. m.ResetFrom()
  14517. return nil
  14518. case label.FieldMode:
  14519. m.ResetMode()
  14520. return nil
  14521. case label.FieldConditions:
  14522. m.ResetConditions()
  14523. return nil
  14524. case label.FieldOrganizationID:
  14525. m.ResetOrganizationID()
  14526. return nil
  14527. }
  14528. return fmt.Errorf("unknown Label field %s", name)
  14529. }
  14530. // AddedEdges returns all edge names that were set/added in this mutation.
  14531. func (m *LabelMutation) AddedEdges() []string {
  14532. edges := make([]string, 0, 1)
  14533. if m.label_relationships != nil {
  14534. edges = append(edges, label.EdgeLabelRelationships)
  14535. }
  14536. return edges
  14537. }
  14538. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14539. // name in this mutation.
  14540. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  14541. switch name {
  14542. case label.EdgeLabelRelationships:
  14543. ids := make([]ent.Value, 0, len(m.label_relationships))
  14544. for id := range m.label_relationships {
  14545. ids = append(ids, id)
  14546. }
  14547. return ids
  14548. }
  14549. return nil
  14550. }
  14551. // RemovedEdges returns all edge names that were removed in this mutation.
  14552. func (m *LabelMutation) RemovedEdges() []string {
  14553. edges := make([]string, 0, 1)
  14554. if m.removedlabel_relationships != nil {
  14555. edges = append(edges, label.EdgeLabelRelationships)
  14556. }
  14557. return edges
  14558. }
  14559. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14560. // the given name in this mutation.
  14561. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  14562. switch name {
  14563. case label.EdgeLabelRelationships:
  14564. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  14565. for id := range m.removedlabel_relationships {
  14566. ids = append(ids, id)
  14567. }
  14568. return ids
  14569. }
  14570. return nil
  14571. }
  14572. // ClearedEdges returns all edge names that were cleared in this mutation.
  14573. func (m *LabelMutation) ClearedEdges() []string {
  14574. edges := make([]string, 0, 1)
  14575. if m.clearedlabel_relationships {
  14576. edges = append(edges, label.EdgeLabelRelationships)
  14577. }
  14578. return edges
  14579. }
  14580. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14581. // was cleared in this mutation.
  14582. func (m *LabelMutation) EdgeCleared(name string) bool {
  14583. switch name {
  14584. case label.EdgeLabelRelationships:
  14585. return m.clearedlabel_relationships
  14586. }
  14587. return false
  14588. }
  14589. // ClearEdge clears the value of the edge with the given name. It returns an error
  14590. // if that edge is not defined in the schema.
  14591. func (m *LabelMutation) ClearEdge(name string) error {
  14592. switch name {
  14593. }
  14594. return fmt.Errorf("unknown Label unique edge %s", name)
  14595. }
  14596. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14597. // It returns an error if the edge is not defined in the schema.
  14598. func (m *LabelMutation) ResetEdge(name string) error {
  14599. switch name {
  14600. case label.EdgeLabelRelationships:
  14601. m.ResetLabelRelationships()
  14602. return nil
  14603. }
  14604. return fmt.Errorf("unknown Label edge %s", name)
  14605. }
  14606. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  14607. type LabelRelationshipMutation struct {
  14608. config
  14609. op Op
  14610. typ string
  14611. id *uint64
  14612. created_at *time.Time
  14613. updated_at *time.Time
  14614. status *uint8
  14615. addstatus *int8
  14616. organization_id *uint64
  14617. addorganization_id *int64
  14618. clearedFields map[string]struct{}
  14619. contacts *uint64
  14620. clearedcontacts bool
  14621. labels *uint64
  14622. clearedlabels bool
  14623. done bool
  14624. oldValue func(context.Context) (*LabelRelationship, error)
  14625. predicates []predicate.LabelRelationship
  14626. }
  14627. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  14628. // labelrelationshipOption allows management of the mutation configuration using functional options.
  14629. type labelrelationshipOption func(*LabelRelationshipMutation)
  14630. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  14631. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  14632. m := &LabelRelationshipMutation{
  14633. config: c,
  14634. op: op,
  14635. typ: TypeLabelRelationship,
  14636. clearedFields: make(map[string]struct{}),
  14637. }
  14638. for _, opt := range opts {
  14639. opt(m)
  14640. }
  14641. return m
  14642. }
  14643. // withLabelRelationshipID sets the ID field of the mutation.
  14644. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  14645. return func(m *LabelRelationshipMutation) {
  14646. var (
  14647. err error
  14648. once sync.Once
  14649. value *LabelRelationship
  14650. )
  14651. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  14652. once.Do(func() {
  14653. if m.done {
  14654. err = errors.New("querying old values post mutation is not allowed")
  14655. } else {
  14656. value, err = m.Client().LabelRelationship.Get(ctx, id)
  14657. }
  14658. })
  14659. return value, err
  14660. }
  14661. m.id = &id
  14662. }
  14663. }
  14664. // withLabelRelationship sets the old LabelRelationship of the mutation.
  14665. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  14666. return func(m *LabelRelationshipMutation) {
  14667. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  14668. return node, nil
  14669. }
  14670. m.id = &node.ID
  14671. }
  14672. }
  14673. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14674. // executed in a transaction (ent.Tx), a transactional client is returned.
  14675. func (m LabelRelationshipMutation) Client() *Client {
  14676. client := &Client{config: m.config}
  14677. client.init()
  14678. return client
  14679. }
  14680. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14681. // it returns an error otherwise.
  14682. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  14683. if _, ok := m.driver.(*txDriver); !ok {
  14684. return nil, errors.New("ent: mutation is not running in a transaction")
  14685. }
  14686. tx := &Tx{config: m.config}
  14687. tx.init()
  14688. return tx, nil
  14689. }
  14690. // SetID sets the value of the id field. Note that this
  14691. // operation is only accepted on creation of LabelRelationship entities.
  14692. func (m *LabelRelationshipMutation) SetID(id uint64) {
  14693. m.id = &id
  14694. }
  14695. // ID returns the ID value in the mutation. Note that the ID is only available
  14696. // if it was provided to the builder or after it was returned from the database.
  14697. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  14698. if m.id == nil {
  14699. return
  14700. }
  14701. return *m.id, true
  14702. }
  14703. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14704. // That means, if the mutation is applied within a transaction with an isolation level such
  14705. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14706. // or updated by the mutation.
  14707. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  14708. switch {
  14709. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14710. id, exists := m.ID()
  14711. if exists {
  14712. return []uint64{id}, nil
  14713. }
  14714. fallthrough
  14715. case m.op.Is(OpUpdate | OpDelete):
  14716. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  14717. default:
  14718. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14719. }
  14720. }
  14721. // SetCreatedAt sets the "created_at" field.
  14722. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  14723. m.created_at = &t
  14724. }
  14725. // CreatedAt returns the value of the "created_at" field in the mutation.
  14726. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  14727. v := m.created_at
  14728. if v == nil {
  14729. return
  14730. }
  14731. return *v, true
  14732. }
  14733. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  14734. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14736. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14737. if !m.op.Is(OpUpdateOne) {
  14738. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14739. }
  14740. if m.id == nil || m.oldValue == nil {
  14741. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14742. }
  14743. oldValue, err := m.oldValue(ctx)
  14744. if err != nil {
  14745. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14746. }
  14747. return oldValue.CreatedAt, nil
  14748. }
  14749. // ResetCreatedAt resets all changes to the "created_at" field.
  14750. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  14751. m.created_at = nil
  14752. }
  14753. // SetUpdatedAt sets the "updated_at" field.
  14754. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  14755. m.updated_at = &t
  14756. }
  14757. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14758. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  14759. v := m.updated_at
  14760. if v == nil {
  14761. return
  14762. }
  14763. return *v, true
  14764. }
  14765. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  14766. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14768. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14769. if !m.op.Is(OpUpdateOne) {
  14770. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14771. }
  14772. if m.id == nil || m.oldValue == nil {
  14773. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14774. }
  14775. oldValue, err := m.oldValue(ctx)
  14776. if err != nil {
  14777. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14778. }
  14779. return oldValue.UpdatedAt, nil
  14780. }
  14781. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14782. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  14783. m.updated_at = nil
  14784. }
  14785. // SetStatus sets the "status" field.
  14786. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  14787. m.status = &u
  14788. m.addstatus = nil
  14789. }
  14790. // Status returns the value of the "status" field in the mutation.
  14791. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  14792. v := m.status
  14793. if v == nil {
  14794. return
  14795. }
  14796. return *v, true
  14797. }
  14798. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  14799. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14801. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14802. if !m.op.Is(OpUpdateOne) {
  14803. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14804. }
  14805. if m.id == nil || m.oldValue == nil {
  14806. return v, errors.New("OldStatus requires an ID field in the mutation")
  14807. }
  14808. oldValue, err := m.oldValue(ctx)
  14809. if err != nil {
  14810. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14811. }
  14812. return oldValue.Status, nil
  14813. }
  14814. // AddStatus adds u to the "status" field.
  14815. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  14816. if m.addstatus != nil {
  14817. *m.addstatus += u
  14818. } else {
  14819. m.addstatus = &u
  14820. }
  14821. }
  14822. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14823. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  14824. v := m.addstatus
  14825. if v == nil {
  14826. return
  14827. }
  14828. return *v, true
  14829. }
  14830. // ClearStatus clears the value of the "status" field.
  14831. func (m *LabelRelationshipMutation) ClearStatus() {
  14832. m.status = nil
  14833. m.addstatus = nil
  14834. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  14835. }
  14836. // StatusCleared returns if the "status" field was cleared in this mutation.
  14837. func (m *LabelRelationshipMutation) StatusCleared() bool {
  14838. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  14839. return ok
  14840. }
  14841. // ResetStatus resets all changes to the "status" field.
  14842. func (m *LabelRelationshipMutation) ResetStatus() {
  14843. m.status = nil
  14844. m.addstatus = nil
  14845. delete(m.clearedFields, labelrelationship.FieldStatus)
  14846. }
  14847. // SetLabelID sets the "label_id" field.
  14848. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  14849. m.labels = &u
  14850. }
  14851. // LabelID returns the value of the "label_id" field in the mutation.
  14852. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  14853. v := m.labels
  14854. if v == nil {
  14855. return
  14856. }
  14857. return *v, true
  14858. }
  14859. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  14860. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14862. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  14863. if !m.op.Is(OpUpdateOne) {
  14864. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  14865. }
  14866. if m.id == nil || m.oldValue == nil {
  14867. return v, errors.New("OldLabelID requires an ID field in the mutation")
  14868. }
  14869. oldValue, err := m.oldValue(ctx)
  14870. if err != nil {
  14871. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  14872. }
  14873. return oldValue.LabelID, nil
  14874. }
  14875. // ResetLabelID resets all changes to the "label_id" field.
  14876. func (m *LabelRelationshipMutation) ResetLabelID() {
  14877. m.labels = nil
  14878. }
  14879. // SetContactID sets the "contact_id" field.
  14880. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  14881. m.contacts = &u
  14882. }
  14883. // ContactID returns the value of the "contact_id" field in the mutation.
  14884. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  14885. v := m.contacts
  14886. if v == nil {
  14887. return
  14888. }
  14889. return *v, true
  14890. }
  14891. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  14892. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14894. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14895. if !m.op.Is(OpUpdateOne) {
  14896. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14897. }
  14898. if m.id == nil || m.oldValue == nil {
  14899. return v, errors.New("OldContactID requires an ID field in the mutation")
  14900. }
  14901. oldValue, err := m.oldValue(ctx)
  14902. if err != nil {
  14903. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14904. }
  14905. return oldValue.ContactID, nil
  14906. }
  14907. // ResetContactID resets all changes to the "contact_id" field.
  14908. func (m *LabelRelationshipMutation) ResetContactID() {
  14909. m.contacts = nil
  14910. }
  14911. // SetOrganizationID sets the "organization_id" field.
  14912. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  14913. m.organization_id = &u
  14914. m.addorganization_id = nil
  14915. }
  14916. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14917. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  14918. v := m.organization_id
  14919. if v == nil {
  14920. return
  14921. }
  14922. return *v, true
  14923. }
  14924. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  14925. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14927. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14928. if !m.op.Is(OpUpdateOne) {
  14929. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14930. }
  14931. if m.id == nil || m.oldValue == nil {
  14932. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14933. }
  14934. oldValue, err := m.oldValue(ctx)
  14935. if err != nil {
  14936. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14937. }
  14938. return oldValue.OrganizationID, nil
  14939. }
  14940. // AddOrganizationID adds u to the "organization_id" field.
  14941. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  14942. if m.addorganization_id != nil {
  14943. *m.addorganization_id += u
  14944. } else {
  14945. m.addorganization_id = &u
  14946. }
  14947. }
  14948. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14949. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  14950. v := m.addorganization_id
  14951. if v == nil {
  14952. return
  14953. }
  14954. return *v, true
  14955. }
  14956. // ClearOrganizationID clears the value of the "organization_id" field.
  14957. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  14958. m.organization_id = nil
  14959. m.addorganization_id = nil
  14960. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  14961. }
  14962. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14963. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  14964. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  14965. return ok
  14966. }
  14967. // ResetOrganizationID resets all changes to the "organization_id" field.
  14968. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  14969. m.organization_id = nil
  14970. m.addorganization_id = nil
  14971. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  14972. }
  14973. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  14974. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  14975. m.contacts = &id
  14976. }
  14977. // ClearContacts clears the "contacts" edge to the Contact entity.
  14978. func (m *LabelRelationshipMutation) ClearContacts() {
  14979. m.clearedcontacts = true
  14980. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  14981. }
  14982. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  14983. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  14984. return m.clearedcontacts
  14985. }
  14986. // ContactsID returns the "contacts" edge ID in the mutation.
  14987. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  14988. if m.contacts != nil {
  14989. return *m.contacts, true
  14990. }
  14991. return
  14992. }
  14993. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  14994. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14995. // ContactsID instead. It exists only for internal usage by the builders.
  14996. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  14997. if id := m.contacts; id != nil {
  14998. ids = append(ids, *id)
  14999. }
  15000. return
  15001. }
  15002. // ResetContacts resets all changes to the "contacts" edge.
  15003. func (m *LabelRelationshipMutation) ResetContacts() {
  15004. m.contacts = nil
  15005. m.clearedcontacts = false
  15006. }
  15007. // SetLabelsID sets the "labels" edge to the Label entity by id.
  15008. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  15009. m.labels = &id
  15010. }
  15011. // ClearLabels clears the "labels" edge to the Label entity.
  15012. func (m *LabelRelationshipMutation) ClearLabels() {
  15013. m.clearedlabels = true
  15014. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  15015. }
  15016. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  15017. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  15018. return m.clearedlabels
  15019. }
  15020. // LabelsID returns the "labels" edge ID in the mutation.
  15021. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  15022. if m.labels != nil {
  15023. return *m.labels, true
  15024. }
  15025. return
  15026. }
  15027. // LabelsIDs returns the "labels" edge IDs in the mutation.
  15028. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15029. // LabelsID instead. It exists only for internal usage by the builders.
  15030. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  15031. if id := m.labels; id != nil {
  15032. ids = append(ids, *id)
  15033. }
  15034. return
  15035. }
  15036. // ResetLabels resets all changes to the "labels" edge.
  15037. func (m *LabelRelationshipMutation) ResetLabels() {
  15038. m.labels = nil
  15039. m.clearedlabels = false
  15040. }
  15041. // Where appends a list predicates to the LabelRelationshipMutation builder.
  15042. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  15043. m.predicates = append(m.predicates, ps...)
  15044. }
  15045. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  15046. // users can use type-assertion to append predicates that do not depend on any generated package.
  15047. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  15048. p := make([]predicate.LabelRelationship, len(ps))
  15049. for i := range ps {
  15050. p[i] = ps[i]
  15051. }
  15052. m.Where(p...)
  15053. }
  15054. // Op returns the operation name.
  15055. func (m *LabelRelationshipMutation) Op() Op {
  15056. return m.op
  15057. }
  15058. // SetOp allows setting the mutation operation.
  15059. func (m *LabelRelationshipMutation) SetOp(op Op) {
  15060. m.op = op
  15061. }
  15062. // Type returns the node type of this mutation (LabelRelationship).
  15063. func (m *LabelRelationshipMutation) Type() string {
  15064. return m.typ
  15065. }
  15066. // Fields returns all fields that were changed during this mutation. Note that in
  15067. // order to get all numeric fields that were incremented/decremented, call
  15068. // AddedFields().
  15069. func (m *LabelRelationshipMutation) Fields() []string {
  15070. fields := make([]string, 0, 6)
  15071. if m.created_at != nil {
  15072. fields = append(fields, labelrelationship.FieldCreatedAt)
  15073. }
  15074. if m.updated_at != nil {
  15075. fields = append(fields, labelrelationship.FieldUpdatedAt)
  15076. }
  15077. if m.status != nil {
  15078. fields = append(fields, labelrelationship.FieldStatus)
  15079. }
  15080. if m.labels != nil {
  15081. fields = append(fields, labelrelationship.FieldLabelID)
  15082. }
  15083. if m.contacts != nil {
  15084. fields = append(fields, labelrelationship.FieldContactID)
  15085. }
  15086. if m.organization_id != nil {
  15087. fields = append(fields, labelrelationship.FieldOrganizationID)
  15088. }
  15089. return fields
  15090. }
  15091. // Field returns the value of a field with the given name. The second boolean
  15092. // return value indicates that this field was not set, or was not defined in the
  15093. // schema.
  15094. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  15095. switch name {
  15096. case labelrelationship.FieldCreatedAt:
  15097. return m.CreatedAt()
  15098. case labelrelationship.FieldUpdatedAt:
  15099. return m.UpdatedAt()
  15100. case labelrelationship.FieldStatus:
  15101. return m.Status()
  15102. case labelrelationship.FieldLabelID:
  15103. return m.LabelID()
  15104. case labelrelationship.FieldContactID:
  15105. return m.ContactID()
  15106. case labelrelationship.FieldOrganizationID:
  15107. return m.OrganizationID()
  15108. }
  15109. return nil, false
  15110. }
  15111. // OldField returns the old value of the field from the database. An error is
  15112. // returned if the mutation operation is not UpdateOne, or the query to the
  15113. // database failed.
  15114. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15115. switch name {
  15116. case labelrelationship.FieldCreatedAt:
  15117. return m.OldCreatedAt(ctx)
  15118. case labelrelationship.FieldUpdatedAt:
  15119. return m.OldUpdatedAt(ctx)
  15120. case labelrelationship.FieldStatus:
  15121. return m.OldStatus(ctx)
  15122. case labelrelationship.FieldLabelID:
  15123. return m.OldLabelID(ctx)
  15124. case labelrelationship.FieldContactID:
  15125. return m.OldContactID(ctx)
  15126. case labelrelationship.FieldOrganizationID:
  15127. return m.OldOrganizationID(ctx)
  15128. }
  15129. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  15130. }
  15131. // SetField sets the value of a field with the given name. It returns an error if
  15132. // the field is not defined in the schema, or if the type mismatched the field
  15133. // type.
  15134. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  15135. switch name {
  15136. case labelrelationship.FieldCreatedAt:
  15137. v, ok := value.(time.Time)
  15138. if !ok {
  15139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15140. }
  15141. m.SetCreatedAt(v)
  15142. return nil
  15143. case labelrelationship.FieldUpdatedAt:
  15144. v, ok := value.(time.Time)
  15145. if !ok {
  15146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15147. }
  15148. m.SetUpdatedAt(v)
  15149. return nil
  15150. case labelrelationship.FieldStatus:
  15151. v, ok := value.(uint8)
  15152. if !ok {
  15153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15154. }
  15155. m.SetStatus(v)
  15156. return nil
  15157. case labelrelationship.FieldLabelID:
  15158. v, ok := value.(uint64)
  15159. if !ok {
  15160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15161. }
  15162. m.SetLabelID(v)
  15163. return nil
  15164. case labelrelationship.FieldContactID:
  15165. v, ok := value.(uint64)
  15166. if !ok {
  15167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15168. }
  15169. m.SetContactID(v)
  15170. return nil
  15171. case labelrelationship.FieldOrganizationID:
  15172. v, ok := value.(uint64)
  15173. if !ok {
  15174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15175. }
  15176. m.SetOrganizationID(v)
  15177. return nil
  15178. }
  15179. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15180. }
  15181. // AddedFields returns all numeric fields that were incremented/decremented during
  15182. // this mutation.
  15183. func (m *LabelRelationshipMutation) AddedFields() []string {
  15184. var fields []string
  15185. if m.addstatus != nil {
  15186. fields = append(fields, labelrelationship.FieldStatus)
  15187. }
  15188. if m.addorganization_id != nil {
  15189. fields = append(fields, labelrelationship.FieldOrganizationID)
  15190. }
  15191. return fields
  15192. }
  15193. // AddedField returns the numeric value that was incremented/decremented on a field
  15194. // with the given name. The second boolean return value indicates that this field
  15195. // was not set, or was not defined in the schema.
  15196. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  15197. switch name {
  15198. case labelrelationship.FieldStatus:
  15199. return m.AddedStatus()
  15200. case labelrelationship.FieldOrganizationID:
  15201. return m.AddedOrganizationID()
  15202. }
  15203. return nil, false
  15204. }
  15205. // AddField adds the value to the field with the given name. It returns an error if
  15206. // the field is not defined in the schema, or if the type mismatched the field
  15207. // type.
  15208. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  15209. switch name {
  15210. case labelrelationship.FieldStatus:
  15211. v, ok := value.(int8)
  15212. if !ok {
  15213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15214. }
  15215. m.AddStatus(v)
  15216. return nil
  15217. case labelrelationship.FieldOrganizationID:
  15218. v, ok := value.(int64)
  15219. if !ok {
  15220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15221. }
  15222. m.AddOrganizationID(v)
  15223. return nil
  15224. }
  15225. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  15226. }
  15227. // ClearedFields returns all nullable fields that were cleared during this
  15228. // mutation.
  15229. func (m *LabelRelationshipMutation) ClearedFields() []string {
  15230. var fields []string
  15231. if m.FieldCleared(labelrelationship.FieldStatus) {
  15232. fields = append(fields, labelrelationship.FieldStatus)
  15233. }
  15234. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  15235. fields = append(fields, labelrelationship.FieldOrganizationID)
  15236. }
  15237. return fields
  15238. }
  15239. // FieldCleared returns a boolean indicating if a field with the given name was
  15240. // cleared in this mutation.
  15241. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  15242. _, ok := m.clearedFields[name]
  15243. return ok
  15244. }
  15245. // ClearField clears the value of the field with the given name. It returns an
  15246. // error if the field is not defined in the schema.
  15247. func (m *LabelRelationshipMutation) ClearField(name string) error {
  15248. switch name {
  15249. case labelrelationship.FieldStatus:
  15250. m.ClearStatus()
  15251. return nil
  15252. case labelrelationship.FieldOrganizationID:
  15253. m.ClearOrganizationID()
  15254. return nil
  15255. }
  15256. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  15257. }
  15258. // ResetField resets all changes in the mutation for the field with the given name.
  15259. // It returns an error if the field is not defined in the schema.
  15260. func (m *LabelRelationshipMutation) ResetField(name string) error {
  15261. switch name {
  15262. case labelrelationship.FieldCreatedAt:
  15263. m.ResetCreatedAt()
  15264. return nil
  15265. case labelrelationship.FieldUpdatedAt:
  15266. m.ResetUpdatedAt()
  15267. return nil
  15268. case labelrelationship.FieldStatus:
  15269. m.ResetStatus()
  15270. return nil
  15271. case labelrelationship.FieldLabelID:
  15272. m.ResetLabelID()
  15273. return nil
  15274. case labelrelationship.FieldContactID:
  15275. m.ResetContactID()
  15276. return nil
  15277. case labelrelationship.FieldOrganizationID:
  15278. m.ResetOrganizationID()
  15279. return nil
  15280. }
  15281. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15282. }
  15283. // AddedEdges returns all edge names that were set/added in this mutation.
  15284. func (m *LabelRelationshipMutation) AddedEdges() []string {
  15285. edges := make([]string, 0, 2)
  15286. if m.contacts != nil {
  15287. edges = append(edges, labelrelationship.EdgeContacts)
  15288. }
  15289. if m.labels != nil {
  15290. edges = append(edges, labelrelationship.EdgeLabels)
  15291. }
  15292. return edges
  15293. }
  15294. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15295. // name in this mutation.
  15296. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  15297. switch name {
  15298. case labelrelationship.EdgeContacts:
  15299. if id := m.contacts; id != nil {
  15300. return []ent.Value{*id}
  15301. }
  15302. case labelrelationship.EdgeLabels:
  15303. if id := m.labels; id != nil {
  15304. return []ent.Value{*id}
  15305. }
  15306. }
  15307. return nil
  15308. }
  15309. // RemovedEdges returns all edge names that were removed in this mutation.
  15310. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  15311. edges := make([]string, 0, 2)
  15312. return edges
  15313. }
  15314. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15315. // the given name in this mutation.
  15316. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  15317. return nil
  15318. }
  15319. // ClearedEdges returns all edge names that were cleared in this mutation.
  15320. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  15321. edges := make([]string, 0, 2)
  15322. if m.clearedcontacts {
  15323. edges = append(edges, labelrelationship.EdgeContacts)
  15324. }
  15325. if m.clearedlabels {
  15326. edges = append(edges, labelrelationship.EdgeLabels)
  15327. }
  15328. return edges
  15329. }
  15330. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15331. // was cleared in this mutation.
  15332. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  15333. switch name {
  15334. case labelrelationship.EdgeContacts:
  15335. return m.clearedcontacts
  15336. case labelrelationship.EdgeLabels:
  15337. return m.clearedlabels
  15338. }
  15339. return false
  15340. }
  15341. // ClearEdge clears the value of the edge with the given name. It returns an error
  15342. // if that edge is not defined in the schema.
  15343. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  15344. switch name {
  15345. case labelrelationship.EdgeContacts:
  15346. m.ClearContacts()
  15347. return nil
  15348. case labelrelationship.EdgeLabels:
  15349. m.ClearLabels()
  15350. return nil
  15351. }
  15352. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  15353. }
  15354. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15355. // It returns an error if the edge is not defined in the schema.
  15356. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  15357. switch name {
  15358. case labelrelationship.EdgeContacts:
  15359. m.ResetContacts()
  15360. return nil
  15361. case labelrelationship.EdgeLabels:
  15362. m.ResetLabels()
  15363. return nil
  15364. }
  15365. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  15366. }
  15367. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  15368. type LabelTaggingMutation struct {
  15369. config
  15370. op Op
  15371. typ string
  15372. id *uint64
  15373. created_at *time.Time
  15374. updated_at *time.Time
  15375. status *uint8
  15376. addstatus *int8
  15377. deleted_at *time.Time
  15378. organization_id *uint64
  15379. addorganization_id *int64
  15380. _type *int
  15381. add_type *int
  15382. conditions *string
  15383. action_label_add *[]uint64
  15384. appendaction_label_add []uint64
  15385. action_label_del *[]uint64
  15386. appendaction_label_del []uint64
  15387. clearedFields map[string]struct{}
  15388. done bool
  15389. oldValue func(context.Context) (*LabelTagging, error)
  15390. predicates []predicate.LabelTagging
  15391. }
  15392. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  15393. // labeltaggingOption allows management of the mutation configuration using functional options.
  15394. type labeltaggingOption func(*LabelTaggingMutation)
  15395. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  15396. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  15397. m := &LabelTaggingMutation{
  15398. config: c,
  15399. op: op,
  15400. typ: TypeLabelTagging,
  15401. clearedFields: make(map[string]struct{}),
  15402. }
  15403. for _, opt := range opts {
  15404. opt(m)
  15405. }
  15406. return m
  15407. }
  15408. // withLabelTaggingID sets the ID field of the mutation.
  15409. func withLabelTaggingID(id uint64) labeltaggingOption {
  15410. return func(m *LabelTaggingMutation) {
  15411. var (
  15412. err error
  15413. once sync.Once
  15414. value *LabelTagging
  15415. )
  15416. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  15417. once.Do(func() {
  15418. if m.done {
  15419. err = errors.New("querying old values post mutation is not allowed")
  15420. } else {
  15421. value, err = m.Client().LabelTagging.Get(ctx, id)
  15422. }
  15423. })
  15424. return value, err
  15425. }
  15426. m.id = &id
  15427. }
  15428. }
  15429. // withLabelTagging sets the old LabelTagging of the mutation.
  15430. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  15431. return func(m *LabelTaggingMutation) {
  15432. m.oldValue = func(context.Context) (*LabelTagging, error) {
  15433. return node, nil
  15434. }
  15435. m.id = &node.ID
  15436. }
  15437. }
  15438. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15439. // executed in a transaction (ent.Tx), a transactional client is returned.
  15440. func (m LabelTaggingMutation) Client() *Client {
  15441. client := &Client{config: m.config}
  15442. client.init()
  15443. return client
  15444. }
  15445. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15446. // it returns an error otherwise.
  15447. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  15448. if _, ok := m.driver.(*txDriver); !ok {
  15449. return nil, errors.New("ent: mutation is not running in a transaction")
  15450. }
  15451. tx := &Tx{config: m.config}
  15452. tx.init()
  15453. return tx, nil
  15454. }
  15455. // SetID sets the value of the id field. Note that this
  15456. // operation is only accepted on creation of LabelTagging entities.
  15457. func (m *LabelTaggingMutation) SetID(id uint64) {
  15458. m.id = &id
  15459. }
  15460. // ID returns the ID value in the mutation. Note that the ID is only available
  15461. // if it was provided to the builder or after it was returned from the database.
  15462. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  15463. if m.id == nil {
  15464. return
  15465. }
  15466. return *m.id, true
  15467. }
  15468. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15469. // That means, if the mutation is applied within a transaction with an isolation level such
  15470. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15471. // or updated by the mutation.
  15472. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  15473. switch {
  15474. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15475. id, exists := m.ID()
  15476. if exists {
  15477. return []uint64{id}, nil
  15478. }
  15479. fallthrough
  15480. case m.op.Is(OpUpdate | OpDelete):
  15481. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  15482. default:
  15483. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15484. }
  15485. }
  15486. // SetCreatedAt sets the "created_at" field.
  15487. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  15488. m.created_at = &t
  15489. }
  15490. // CreatedAt returns the value of the "created_at" field in the mutation.
  15491. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  15492. v := m.created_at
  15493. if v == nil {
  15494. return
  15495. }
  15496. return *v, true
  15497. }
  15498. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  15499. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15501. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15502. if !m.op.Is(OpUpdateOne) {
  15503. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15504. }
  15505. if m.id == nil || m.oldValue == nil {
  15506. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15507. }
  15508. oldValue, err := m.oldValue(ctx)
  15509. if err != nil {
  15510. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15511. }
  15512. return oldValue.CreatedAt, nil
  15513. }
  15514. // ResetCreatedAt resets all changes to the "created_at" field.
  15515. func (m *LabelTaggingMutation) ResetCreatedAt() {
  15516. m.created_at = nil
  15517. }
  15518. // SetUpdatedAt sets the "updated_at" field.
  15519. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  15520. m.updated_at = &t
  15521. }
  15522. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15523. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  15524. v := m.updated_at
  15525. if v == nil {
  15526. return
  15527. }
  15528. return *v, true
  15529. }
  15530. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  15531. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15533. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15534. if !m.op.Is(OpUpdateOne) {
  15535. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15536. }
  15537. if m.id == nil || m.oldValue == nil {
  15538. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15539. }
  15540. oldValue, err := m.oldValue(ctx)
  15541. if err != nil {
  15542. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15543. }
  15544. return oldValue.UpdatedAt, nil
  15545. }
  15546. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15547. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  15548. m.updated_at = nil
  15549. }
  15550. // SetStatus sets the "status" field.
  15551. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  15552. m.status = &u
  15553. m.addstatus = nil
  15554. }
  15555. // Status returns the value of the "status" field in the mutation.
  15556. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  15557. v := m.status
  15558. if v == nil {
  15559. return
  15560. }
  15561. return *v, true
  15562. }
  15563. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  15564. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15566. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15567. if !m.op.Is(OpUpdateOne) {
  15568. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15569. }
  15570. if m.id == nil || m.oldValue == nil {
  15571. return v, errors.New("OldStatus requires an ID field in the mutation")
  15572. }
  15573. oldValue, err := m.oldValue(ctx)
  15574. if err != nil {
  15575. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15576. }
  15577. return oldValue.Status, nil
  15578. }
  15579. // AddStatus adds u to the "status" field.
  15580. func (m *LabelTaggingMutation) AddStatus(u int8) {
  15581. if m.addstatus != nil {
  15582. *m.addstatus += u
  15583. } else {
  15584. m.addstatus = &u
  15585. }
  15586. }
  15587. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15588. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  15589. v := m.addstatus
  15590. if v == nil {
  15591. return
  15592. }
  15593. return *v, true
  15594. }
  15595. // ClearStatus clears the value of the "status" field.
  15596. func (m *LabelTaggingMutation) ClearStatus() {
  15597. m.status = nil
  15598. m.addstatus = nil
  15599. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  15600. }
  15601. // StatusCleared returns if the "status" field was cleared in this mutation.
  15602. func (m *LabelTaggingMutation) StatusCleared() bool {
  15603. _, ok := m.clearedFields[labeltagging.FieldStatus]
  15604. return ok
  15605. }
  15606. // ResetStatus resets all changes to the "status" field.
  15607. func (m *LabelTaggingMutation) ResetStatus() {
  15608. m.status = nil
  15609. m.addstatus = nil
  15610. delete(m.clearedFields, labeltagging.FieldStatus)
  15611. }
  15612. // SetDeletedAt sets the "deleted_at" field.
  15613. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  15614. m.deleted_at = &t
  15615. }
  15616. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15617. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  15618. v := m.deleted_at
  15619. if v == nil {
  15620. return
  15621. }
  15622. return *v, true
  15623. }
  15624. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  15625. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15627. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15628. if !m.op.Is(OpUpdateOne) {
  15629. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15630. }
  15631. if m.id == nil || m.oldValue == nil {
  15632. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15633. }
  15634. oldValue, err := m.oldValue(ctx)
  15635. if err != nil {
  15636. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15637. }
  15638. return oldValue.DeletedAt, nil
  15639. }
  15640. // ClearDeletedAt clears the value of the "deleted_at" field.
  15641. func (m *LabelTaggingMutation) ClearDeletedAt() {
  15642. m.deleted_at = nil
  15643. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  15644. }
  15645. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15646. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  15647. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  15648. return ok
  15649. }
  15650. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15651. func (m *LabelTaggingMutation) ResetDeletedAt() {
  15652. m.deleted_at = nil
  15653. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  15654. }
  15655. // SetOrganizationID sets the "organization_id" field.
  15656. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  15657. m.organization_id = &u
  15658. m.addorganization_id = nil
  15659. }
  15660. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15661. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  15662. v := m.organization_id
  15663. if v == nil {
  15664. return
  15665. }
  15666. return *v, true
  15667. }
  15668. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  15669. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15671. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15672. if !m.op.Is(OpUpdateOne) {
  15673. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15674. }
  15675. if m.id == nil || m.oldValue == nil {
  15676. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15677. }
  15678. oldValue, err := m.oldValue(ctx)
  15679. if err != nil {
  15680. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15681. }
  15682. return oldValue.OrganizationID, nil
  15683. }
  15684. // AddOrganizationID adds u to the "organization_id" field.
  15685. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  15686. if m.addorganization_id != nil {
  15687. *m.addorganization_id += u
  15688. } else {
  15689. m.addorganization_id = &u
  15690. }
  15691. }
  15692. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15693. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  15694. v := m.addorganization_id
  15695. if v == nil {
  15696. return
  15697. }
  15698. return *v, true
  15699. }
  15700. // ResetOrganizationID resets all changes to the "organization_id" field.
  15701. func (m *LabelTaggingMutation) ResetOrganizationID() {
  15702. m.organization_id = nil
  15703. m.addorganization_id = nil
  15704. }
  15705. // SetType sets the "type" field.
  15706. func (m *LabelTaggingMutation) SetType(i int) {
  15707. m._type = &i
  15708. m.add_type = nil
  15709. }
  15710. // GetType returns the value of the "type" field in the mutation.
  15711. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  15712. v := m._type
  15713. if v == nil {
  15714. return
  15715. }
  15716. return *v, true
  15717. }
  15718. // OldType returns the old "type" field's value of the LabelTagging entity.
  15719. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15721. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  15722. if !m.op.Is(OpUpdateOne) {
  15723. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15724. }
  15725. if m.id == nil || m.oldValue == nil {
  15726. return v, errors.New("OldType requires an ID field in the mutation")
  15727. }
  15728. oldValue, err := m.oldValue(ctx)
  15729. if err != nil {
  15730. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15731. }
  15732. return oldValue.Type, nil
  15733. }
  15734. // AddType adds i to the "type" field.
  15735. func (m *LabelTaggingMutation) AddType(i int) {
  15736. if m.add_type != nil {
  15737. *m.add_type += i
  15738. } else {
  15739. m.add_type = &i
  15740. }
  15741. }
  15742. // AddedType returns the value that was added to the "type" field in this mutation.
  15743. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  15744. v := m.add_type
  15745. if v == nil {
  15746. return
  15747. }
  15748. return *v, true
  15749. }
  15750. // ResetType resets all changes to the "type" field.
  15751. func (m *LabelTaggingMutation) ResetType() {
  15752. m._type = nil
  15753. m.add_type = nil
  15754. }
  15755. // SetConditions sets the "conditions" field.
  15756. func (m *LabelTaggingMutation) SetConditions(s string) {
  15757. m.conditions = &s
  15758. }
  15759. // Conditions returns the value of the "conditions" field in the mutation.
  15760. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  15761. v := m.conditions
  15762. if v == nil {
  15763. return
  15764. }
  15765. return *v, true
  15766. }
  15767. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  15768. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15770. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  15771. if !m.op.Is(OpUpdateOne) {
  15772. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15773. }
  15774. if m.id == nil || m.oldValue == nil {
  15775. return v, errors.New("OldConditions requires an ID field in the mutation")
  15776. }
  15777. oldValue, err := m.oldValue(ctx)
  15778. if err != nil {
  15779. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15780. }
  15781. return oldValue.Conditions, nil
  15782. }
  15783. // ResetConditions resets all changes to the "conditions" field.
  15784. func (m *LabelTaggingMutation) ResetConditions() {
  15785. m.conditions = nil
  15786. }
  15787. // SetActionLabelAdd sets the "action_label_add" field.
  15788. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  15789. m.action_label_add = &u
  15790. m.appendaction_label_add = nil
  15791. }
  15792. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  15793. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  15794. v := m.action_label_add
  15795. if v == nil {
  15796. return
  15797. }
  15798. return *v, true
  15799. }
  15800. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  15801. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15803. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  15804. if !m.op.Is(OpUpdateOne) {
  15805. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  15806. }
  15807. if m.id == nil || m.oldValue == nil {
  15808. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  15809. }
  15810. oldValue, err := m.oldValue(ctx)
  15811. if err != nil {
  15812. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  15813. }
  15814. return oldValue.ActionLabelAdd, nil
  15815. }
  15816. // AppendActionLabelAdd adds u to the "action_label_add" field.
  15817. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  15818. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  15819. }
  15820. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  15821. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  15822. if len(m.appendaction_label_add) == 0 {
  15823. return nil, false
  15824. }
  15825. return m.appendaction_label_add, true
  15826. }
  15827. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  15828. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  15829. m.action_label_add = nil
  15830. m.appendaction_label_add = nil
  15831. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  15832. }
  15833. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  15834. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  15835. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  15836. return ok
  15837. }
  15838. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  15839. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  15840. m.action_label_add = nil
  15841. m.appendaction_label_add = nil
  15842. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  15843. }
  15844. // SetActionLabelDel sets the "action_label_del" field.
  15845. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  15846. m.action_label_del = &u
  15847. m.appendaction_label_del = nil
  15848. }
  15849. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  15850. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  15851. v := m.action_label_del
  15852. if v == nil {
  15853. return
  15854. }
  15855. return *v, true
  15856. }
  15857. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  15858. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15860. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  15861. if !m.op.Is(OpUpdateOne) {
  15862. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  15863. }
  15864. if m.id == nil || m.oldValue == nil {
  15865. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  15866. }
  15867. oldValue, err := m.oldValue(ctx)
  15868. if err != nil {
  15869. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  15870. }
  15871. return oldValue.ActionLabelDel, nil
  15872. }
  15873. // AppendActionLabelDel adds u to the "action_label_del" field.
  15874. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  15875. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  15876. }
  15877. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  15878. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  15879. if len(m.appendaction_label_del) == 0 {
  15880. return nil, false
  15881. }
  15882. return m.appendaction_label_del, true
  15883. }
  15884. // ClearActionLabelDel clears the value of the "action_label_del" field.
  15885. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  15886. m.action_label_del = nil
  15887. m.appendaction_label_del = nil
  15888. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  15889. }
  15890. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  15891. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  15892. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  15893. return ok
  15894. }
  15895. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  15896. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  15897. m.action_label_del = nil
  15898. m.appendaction_label_del = nil
  15899. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  15900. }
  15901. // Where appends a list predicates to the LabelTaggingMutation builder.
  15902. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  15903. m.predicates = append(m.predicates, ps...)
  15904. }
  15905. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  15906. // users can use type-assertion to append predicates that do not depend on any generated package.
  15907. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  15908. p := make([]predicate.LabelTagging, len(ps))
  15909. for i := range ps {
  15910. p[i] = ps[i]
  15911. }
  15912. m.Where(p...)
  15913. }
  15914. // Op returns the operation name.
  15915. func (m *LabelTaggingMutation) Op() Op {
  15916. return m.op
  15917. }
  15918. // SetOp allows setting the mutation operation.
  15919. func (m *LabelTaggingMutation) SetOp(op Op) {
  15920. m.op = op
  15921. }
  15922. // Type returns the node type of this mutation (LabelTagging).
  15923. func (m *LabelTaggingMutation) Type() string {
  15924. return m.typ
  15925. }
  15926. // Fields returns all fields that were changed during this mutation. Note that in
  15927. // order to get all numeric fields that were incremented/decremented, call
  15928. // AddedFields().
  15929. func (m *LabelTaggingMutation) Fields() []string {
  15930. fields := make([]string, 0, 9)
  15931. if m.created_at != nil {
  15932. fields = append(fields, labeltagging.FieldCreatedAt)
  15933. }
  15934. if m.updated_at != nil {
  15935. fields = append(fields, labeltagging.FieldUpdatedAt)
  15936. }
  15937. if m.status != nil {
  15938. fields = append(fields, labeltagging.FieldStatus)
  15939. }
  15940. if m.deleted_at != nil {
  15941. fields = append(fields, labeltagging.FieldDeletedAt)
  15942. }
  15943. if m.organization_id != nil {
  15944. fields = append(fields, labeltagging.FieldOrganizationID)
  15945. }
  15946. if m._type != nil {
  15947. fields = append(fields, labeltagging.FieldType)
  15948. }
  15949. if m.conditions != nil {
  15950. fields = append(fields, labeltagging.FieldConditions)
  15951. }
  15952. if m.action_label_add != nil {
  15953. fields = append(fields, labeltagging.FieldActionLabelAdd)
  15954. }
  15955. if m.action_label_del != nil {
  15956. fields = append(fields, labeltagging.FieldActionLabelDel)
  15957. }
  15958. return fields
  15959. }
  15960. // Field returns the value of a field with the given name. The second boolean
  15961. // return value indicates that this field was not set, or was not defined in the
  15962. // schema.
  15963. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  15964. switch name {
  15965. case labeltagging.FieldCreatedAt:
  15966. return m.CreatedAt()
  15967. case labeltagging.FieldUpdatedAt:
  15968. return m.UpdatedAt()
  15969. case labeltagging.FieldStatus:
  15970. return m.Status()
  15971. case labeltagging.FieldDeletedAt:
  15972. return m.DeletedAt()
  15973. case labeltagging.FieldOrganizationID:
  15974. return m.OrganizationID()
  15975. case labeltagging.FieldType:
  15976. return m.GetType()
  15977. case labeltagging.FieldConditions:
  15978. return m.Conditions()
  15979. case labeltagging.FieldActionLabelAdd:
  15980. return m.ActionLabelAdd()
  15981. case labeltagging.FieldActionLabelDel:
  15982. return m.ActionLabelDel()
  15983. }
  15984. return nil, false
  15985. }
  15986. // OldField returns the old value of the field from the database. An error is
  15987. // returned if the mutation operation is not UpdateOne, or the query to the
  15988. // database failed.
  15989. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15990. switch name {
  15991. case labeltagging.FieldCreatedAt:
  15992. return m.OldCreatedAt(ctx)
  15993. case labeltagging.FieldUpdatedAt:
  15994. return m.OldUpdatedAt(ctx)
  15995. case labeltagging.FieldStatus:
  15996. return m.OldStatus(ctx)
  15997. case labeltagging.FieldDeletedAt:
  15998. return m.OldDeletedAt(ctx)
  15999. case labeltagging.FieldOrganizationID:
  16000. return m.OldOrganizationID(ctx)
  16001. case labeltagging.FieldType:
  16002. return m.OldType(ctx)
  16003. case labeltagging.FieldConditions:
  16004. return m.OldConditions(ctx)
  16005. case labeltagging.FieldActionLabelAdd:
  16006. return m.OldActionLabelAdd(ctx)
  16007. case labeltagging.FieldActionLabelDel:
  16008. return m.OldActionLabelDel(ctx)
  16009. }
  16010. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  16011. }
  16012. // SetField sets the value of a field with the given name. It returns an error if
  16013. // the field is not defined in the schema, or if the type mismatched the field
  16014. // type.
  16015. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  16016. switch name {
  16017. case labeltagging.FieldCreatedAt:
  16018. v, ok := value.(time.Time)
  16019. if !ok {
  16020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16021. }
  16022. m.SetCreatedAt(v)
  16023. return nil
  16024. case labeltagging.FieldUpdatedAt:
  16025. v, ok := value.(time.Time)
  16026. if !ok {
  16027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16028. }
  16029. m.SetUpdatedAt(v)
  16030. return nil
  16031. case labeltagging.FieldStatus:
  16032. v, ok := value.(uint8)
  16033. if !ok {
  16034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16035. }
  16036. m.SetStatus(v)
  16037. return nil
  16038. case labeltagging.FieldDeletedAt:
  16039. v, ok := value.(time.Time)
  16040. if !ok {
  16041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16042. }
  16043. m.SetDeletedAt(v)
  16044. return nil
  16045. case labeltagging.FieldOrganizationID:
  16046. v, ok := value.(uint64)
  16047. if !ok {
  16048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16049. }
  16050. m.SetOrganizationID(v)
  16051. return nil
  16052. case labeltagging.FieldType:
  16053. v, ok := value.(int)
  16054. if !ok {
  16055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16056. }
  16057. m.SetType(v)
  16058. return nil
  16059. case labeltagging.FieldConditions:
  16060. v, ok := value.(string)
  16061. if !ok {
  16062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16063. }
  16064. m.SetConditions(v)
  16065. return nil
  16066. case labeltagging.FieldActionLabelAdd:
  16067. v, ok := value.([]uint64)
  16068. if !ok {
  16069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16070. }
  16071. m.SetActionLabelAdd(v)
  16072. return nil
  16073. case labeltagging.FieldActionLabelDel:
  16074. v, ok := value.([]uint64)
  16075. if !ok {
  16076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16077. }
  16078. m.SetActionLabelDel(v)
  16079. return nil
  16080. }
  16081. return fmt.Errorf("unknown LabelTagging field %s", name)
  16082. }
  16083. // AddedFields returns all numeric fields that were incremented/decremented during
  16084. // this mutation.
  16085. func (m *LabelTaggingMutation) AddedFields() []string {
  16086. var fields []string
  16087. if m.addstatus != nil {
  16088. fields = append(fields, labeltagging.FieldStatus)
  16089. }
  16090. if m.addorganization_id != nil {
  16091. fields = append(fields, labeltagging.FieldOrganizationID)
  16092. }
  16093. if m.add_type != nil {
  16094. fields = append(fields, labeltagging.FieldType)
  16095. }
  16096. return fields
  16097. }
  16098. // AddedField returns the numeric value that was incremented/decremented on a field
  16099. // with the given name. The second boolean return value indicates that this field
  16100. // was not set, or was not defined in the schema.
  16101. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  16102. switch name {
  16103. case labeltagging.FieldStatus:
  16104. return m.AddedStatus()
  16105. case labeltagging.FieldOrganizationID:
  16106. return m.AddedOrganizationID()
  16107. case labeltagging.FieldType:
  16108. return m.AddedType()
  16109. }
  16110. return nil, false
  16111. }
  16112. // AddField adds the value to the field with the given name. It returns an error if
  16113. // the field is not defined in the schema, or if the type mismatched the field
  16114. // type.
  16115. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  16116. switch name {
  16117. case labeltagging.FieldStatus:
  16118. v, ok := value.(int8)
  16119. if !ok {
  16120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16121. }
  16122. m.AddStatus(v)
  16123. return nil
  16124. case labeltagging.FieldOrganizationID:
  16125. v, ok := value.(int64)
  16126. if !ok {
  16127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16128. }
  16129. m.AddOrganizationID(v)
  16130. return nil
  16131. case labeltagging.FieldType:
  16132. v, ok := value.(int)
  16133. if !ok {
  16134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16135. }
  16136. m.AddType(v)
  16137. return nil
  16138. }
  16139. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  16140. }
  16141. // ClearedFields returns all nullable fields that were cleared during this
  16142. // mutation.
  16143. func (m *LabelTaggingMutation) ClearedFields() []string {
  16144. var fields []string
  16145. if m.FieldCleared(labeltagging.FieldStatus) {
  16146. fields = append(fields, labeltagging.FieldStatus)
  16147. }
  16148. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  16149. fields = append(fields, labeltagging.FieldDeletedAt)
  16150. }
  16151. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  16152. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16153. }
  16154. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  16155. fields = append(fields, labeltagging.FieldActionLabelDel)
  16156. }
  16157. return fields
  16158. }
  16159. // FieldCleared returns a boolean indicating if a field with the given name was
  16160. // cleared in this mutation.
  16161. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  16162. _, ok := m.clearedFields[name]
  16163. return ok
  16164. }
  16165. // ClearField clears the value of the field with the given name. It returns an
  16166. // error if the field is not defined in the schema.
  16167. func (m *LabelTaggingMutation) ClearField(name string) error {
  16168. switch name {
  16169. case labeltagging.FieldStatus:
  16170. m.ClearStatus()
  16171. return nil
  16172. case labeltagging.FieldDeletedAt:
  16173. m.ClearDeletedAt()
  16174. return nil
  16175. case labeltagging.FieldActionLabelAdd:
  16176. m.ClearActionLabelAdd()
  16177. return nil
  16178. case labeltagging.FieldActionLabelDel:
  16179. m.ClearActionLabelDel()
  16180. return nil
  16181. }
  16182. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  16183. }
  16184. // ResetField resets all changes in the mutation for the field with the given name.
  16185. // It returns an error if the field is not defined in the schema.
  16186. func (m *LabelTaggingMutation) ResetField(name string) error {
  16187. switch name {
  16188. case labeltagging.FieldCreatedAt:
  16189. m.ResetCreatedAt()
  16190. return nil
  16191. case labeltagging.FieldUpdatedAt:
  16192. m.ResetUpdatedAt()
  16193. return nil
  16194. case labeltagging.FieldStatus:
  16195. m.ResetStatus()
  16196. return nil
  16197. case labeltagging.FieldDeletedAt:
  16198. m.ResetDeletedAt()
  16199. return nil
  16200. case labeltagging.FieldOrganizationID:
  16201. m.ResetOrganizationID()
  16202. return nil
  16203. case labeltagging.FieldType:
  16204. m.ResetType()
  16205. return nil
  16206. case labeltagging.FieldConditions:
  16207. m.ResetConditions()
  16208. return nil
  16209. case labeltagging.FieldActionLabelAdd:
  16210. m.ResetActionLabelAdd()
  16211. return nil
  16212. case labeltagging.FieldActionLabelDel:
  16213. m.ResetActionLabelDel()
  16214. return nil
  16215. }
  16216. return fmt.Errorf("unknown LabelTagging field %s", name)
  16217. }
  16218. // AddedEdges returns all edge names that were set/added in this mutation.
  16219. func (m *LabelTaggingMutation) AddedEdges() []string {
  16220. edges := make([]string, 0, 0)
  16221. return edges
  16222. }
  16223. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16224. // name in this mutation.
  16225. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  16226. return nil
  16227. }
  16228. // RemovedEdges returns all edge names that were removed in this mutation.
  16229. func (m *LabelTaggingMutation) RemovedEdges() []string {
  16230. edges := make([]string, 0, 0)
  16231. return edges
  16232. }
  16233. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16234. // the given name in this mutation.
  16235. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  16236. return nil
  16237. }
  16238. // ClearedEdges returns all edge names that were cleared in this mutation.
  16239. func (m *LabelTaggingMutation) ClearedEdges() []string {
  16240. edges := make([]string, 0, 0)
  16241. return edges
  16242. }
  16243. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16244. // was cleared in this mutation.
  16245. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  16246. return false
  16247. }
  16248. // ClearEdge clears the value of the edge with the given name. It returns an error
  16249. // if that edge is not defined in the schema.
  16250. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  16251. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  16252. }
  16253. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16254. // It returns an error if the edge is not defined in the schema.
  16255. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  16256. return fmt.Errorf("unknown LabelTagging edge %s", name)
  16257. }
  16258. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  16259. type MessageMutation struct {
  16260. config
  16261. op Op
  16262. typ string
  16263. id *int
  16264. wx_wxid *string
  16265. wxid *string
  16266. content *string
  16267. clearedFields map[string]struct{}
  16268. done bool
  16269. oldValue func(context.Context) (*Message, error)
  16270. predicates []predicate.Message
  16271. }
  16272. var _ ent.Mutation = (*MessageMutation)(nil)
  16273. // messageOption allows management of the mutation configuration using functional options.
  16274. type messageOption func(*MessageMutation)
  16275. // newMessageMutation creates new mutation for the Message entity.
  16276. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  16277. m := &MessageMutation{
  16278. config: c,
  16279. op: op,
  16280. typ: TypeMessage,
  16281. clearedFields: make(map[string]struct{}),
  16282. }
  16283. for _, opt := range opts {
  16284. opt(m)
  16285. }
  16286. return m
  16287. }
  16288. // withMessageID sets the ID field of the mutation.
  16289. func withMessageID(id int) messageOption {
  16290. return func(m *MessageMutation) {
  16291. var (
  16292. err error
  16293. once sync.Once
  16294. value *Message
  16295. )
  16296. m.oldValue = func(ctx context.Context) (*Message, error) {
  16297. once.Do(func() {
  16298. if m.done {
  16299. err = errors.New("querying old values post mutation is not allowed")
  16300. } else {
  16301. value, err = m.Client().Message.Get(ctx, id)
  16302. }
  16303. })
  16304. return value, err
  16305. }
  16306. m.id = &id
  16307. }
  16308. }
  16309. // withMessage sets the old Message of the mutation.
  16310. func withMessage(node *Message) messageOption {
  16311. return func(m *MessageMutation) {
  16312. m.oldValue = func(context.Context) (*Message, error) {
  16313. return node, nil
  16314. }
  16315. m.id = &node.ID
  16316. }
  16317. }
  16318. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16319. // executed in a transaction (ent.Tx), a transactional client is returned.
  16320. func (m MessageMutation) Client() *Client {
  16321. client := &Client{config: m.config}
  16322. client.init()
  16323. return client
  16324. }
  16325. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16326. // it returns an error otherwise.
  16327. func (m MessageMutation) Tx() (*Tx, error) {
  16328. if _, ok := m.driver.(*txDriver); !ok {
  16329. return nil, errors.New("ent: mutation is not running in a transaction")
  16330. }
  16331. tx := &Tx{config: m.config}
  16332. tx.init()
  16333. return tx, nil
  16334. }
  16335. // ID returns the ID value in the mutation. Note that the ID is only available
  16336. // if it was provided to the builder or after it was returned from the database.
  16337. func (m *MessageMutation) ID() (id int, exists bool) {
  16338. if m.id == nil {
  16339. return
  16340. }
  16341. return *m.id, true
  16342. }
  16343. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16344. // That means, if the mutation is applied within a transaction with an isolation level such
  16345. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16346. // or updated by the mutation.
  16347. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  16348. switch {
  16349. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16350. id, exists := m.ID()
  16351. if exists {
  16352. return []int{id}, nil
  16353. }
  16354. fallthrough
  16355. case m.op.Is(OpUpdate | OpDelete):
  16356. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  16357. default:
  16358. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16359. }
  16360. }
  16361. // SetWxWxid sets the "wx_wxid" field.
  16362. func (m *MessageMutation) SetWxWxid(s string) {
  16363. m.wx_wxid = &s
  16364. }
  16365. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  16366. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  16367. v := m.wx_wxid
  16368. if v == nil {
  16369. return
  16370. }
  16371. return *v, true
  16372. }
  16373. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  16374. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16376. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  16377. if !m.op.Is(OpUpdateOne) {
  16378. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  16379. }
  16380. if m.id == nil || m.oldValue == nil {
  16381. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  16382. }
  16383. oldValue, err := m.oldValue(ctx)
  16384. if err != nil {
  16385. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  16386. }
  16387. return oldValue.WxWxid, nil
  16388. }
  16389. // ClearWxWxid clears the value of the "wx_wxid" field.
  16390. func (m *MessageMutation) ClearWxWxid() {
  16391. m.wx_wxid = nil
  16392. m.clearedFields[message.FieldWxWxid] = struct{}{}
  16393. }
  16394. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  16395. func (m *MessageMutation) WxWxidCleared() bool {
  16396. _, ok := m.clearedFields[message.FieldWxWxid]
  16397. return ok
  16398. }
  16399. // ResetWxWxid resets all changes to the "wx_wxid" field.
  16400. func (m *MessageMutation) ResetWxWxid() {
  16401. m.wx_wxid = nil
  16402. delete(m.clearedFields, message.FieldWxWxid)
  16403. }
  16404. // SetWxid sets the "wxid" field.
  16405. func (m *MessageMutation) SetWxid(s string) {
  16406. m.wxid = &s
  16407. }
  16408. // Wxid returns the value of the "wxid" field in the mutation.
  16409. func (m *MessageMutation) Wxid() (r string, exists bool) {
  16410. v := m.wxid
  16411. if v == nil {
  16412. return
  16413. }
  16414. return *v, true
  16415. }
  16416. // OldWxid returns the old "wxid" field's value of the Message entity.
  16417. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16419. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  16420. if !m.op.Is(OpUpdateOne) {
  16421. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  16422. }
  16423. if m.id == nil || m.oldValue == nil {
  16424. return v, errors.New("OldWxid requires an ID field in the mutation")
  16425. }
  16426. oldValue, err := m.oldValue(ctx)
  16427. if err != nil {
  16428. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  16429. }
  16430. return oldValue.Wxid, nil
  16431. }
  16432. // ResetWxid resets all changes to the "wxid" field.
  16433. func (m *MessageMutation) ResetWxid() {
  16434. m.wxid = nil
  16435. }
  16436. // SetContent sets the "content" field.
  16437. func (m *MessageMutation) SetContent(s string) {
  16438. m.content = &s
  16439. }
  16440. // Content returns the value of the "content" field in the mutation.
  16441. func (m *MessageMutation) Content() (r string, exists bool) {
  16442. v := m.content
  16443. if v == nil {
  16444. return
  16445. }
  16446. return *v, true
  16447. }
  16448. // OldContent returns the old "content" field's value of the Message entity.
  16449. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16451. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  16452. if !m.op.Is(OpUpdateOne) {
  16453. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16454. }
  16455. if m.id == nil || m.oldValue == nil {
  16456. return v, errors.New("OldContent requires an ID field in the mutation")
  16457. }
  16458. oldValue, err := m.oldValue(ctx)
  16459. if err != nil {
  16460. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16461. }
  16462. return oldValue.Content, nil
  16463. }
  16464. // ResetContent resets all changes to the "content" field.
  16465. func (m *MessageMutation) ResetContent() {
  16466. m.content = nil
  16467. }
  16468. // Where appends a list predicates to the MessageMutation builder.
  16469. func (m *MessageMutation) Where(ps ...predicate.Message) {
  16470. m.predicates = append(m.predicates, ps...)
  16471. }
  16472. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  16473. // users can use type-assertion to append predicates that do not depend on any generated package.
  16474. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  16475. p := make([]predicate.Message, len(ps))
  16476. for i := range ps {
  16477. p[i] = ps[i]
  16478. }
  16479. m.Where(p...)
  16480. }
  16481. // Op returns the operation name.
  16482. func (m *MessageMutation) Op() Op {
  16483. return m.op
  16484. }
  16485. // SetOp allows setting the mutation operation.
  16486. func (m *MessageMutation) SetOp(op Op) {
  16487. m.op = op
  16488. }
  16489. // Type returns the node type of this mutation (Message).
  16490. func (m *MessageMutation) Type() string {
  16491. return m.typ
  16492. }
  16493. // Fields returns all fields that were changed during this mutation. Note that in
  16494. // order to get all numeric fields that were incremented/decremented, call
  16495. // AddedFields().
  16496. func (m *MessageMutation) Fields() []string {
  16497. fields := make([]string, 0, 3)
  16498. if m.wx_wxid != nil {
  16499. fields = append(fields, message.FieldWxWxid)
  16500. }
  16501. if m.wxid != nil {
  16502. fields = append(fields, message.FieldWxid)
  16503. }
  16504. if m.content != nil {
  16505. fields = append(fields, message.FieldContent)
  16506. }
  16507. return fields
  16508. }
  16509. // Field returns the value of a field with the given name. The second boolean
  16510. // return value indicates that this field was not set, or was not defined in the
  16511. // schema.
  16512. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  16513. switch name {
  16514. case message.FieldWxWxid:
  16515. return m.WxWxid()
  16516. case message.FieldWxid:
  16517. return m.Wxid()
  16518. case message.FieldContent:
  16519. return m.Content()
  16520. }
  16521. return nil, false
  16522. }
  16523. // OldField returns the old value of the field from the database. An error is
  16524. // returned if the mutation operation is not UpdateOne, or the query to the
  16525. // database failed.
  16526. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16527. switch name {
  16528. case message.FieldWxWxid:
  16529. return m.OldWxWxid(ctx)
  16530. case message.FieldWxid:
  16531. return m.OldWxid(ctx)
  16532. case message.FieldContent:
  16533. return m.OldContent(ctx)
  16534. }
  16535. return nil, fmt.Errorf("unknown Message field %s", name)
  16536. }
  16537. // SetField sets the value of a field with the given name. It returns an error if
  16538. // the field is not defined in the schema, or if the type mismatched the field
  16539. // type.
  16540. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  16541. switch name {
  16542. case message.FieldWxWxid:
  16543. v, ok := value.(string)
  16544. if !ok {
  16545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16546. }
  16547. m.SetWxWxid(v)
  16548. return nil
  16549. case message.FieldWxid:
  16550. v, ok := value.(string)
  16551. if !ok {
  16552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16553. }
  16554. m.SetWxid(v)
  16555. return nil
  16556. case message.FieldContent:
  16557. v, ok := value.(string)
  16558. if !ok {
  16559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16560. }
  16561. m.SetContent(v)
  16562. return nil
  16563. }
  16564. return fmt.Errorf("unknown Message field %s", name)
  16565. }
  16566. // AddedFields returns all numeric fields that were incremented/decremented during
  16567. // this mutation.
  16568. func (m *MessageMutation) AddedFields() []string {
  16569. return nil
  16570. }
  16571. // AddedField returns the numeric value that was incremented/decremented on a field
  16572. // with the given name. The second boolean return value indicates that this field
  16573. // was not set, or was not defined in the schema.
  16574. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  16575. return nil, false
  16576. }
  16577. // AddField adds the value to the field with the given name. It returns an error if
  16578. // the field is not defined in the schema, or if the type mismatched the field
  16579. // type.
  16580. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  16581. switch name {
  16582. }
  16583. return fmt.Errorf("unknown Message numeric field %s", name)
  16584. }
  16585. // ClearedFields returns all nullable fields that were cleared during this
  16586. // mutation.
  16587. func (m *MessageMutation) ClearedFields() []string {
  16588. var fields []string
  16589. if m.FieldCleared(message.FieldWxWxid) {
  16590. fields = append(fields, message.FieldWxWxid)
  16591. }
  16592. return fields
  16593. }
  16594. // FieldCleared returns a boolean indicating if a field with the given name was
  16595. // cleared in this mutation.
  16596. func (m *MessageMutation) FieldCleared(name string) bool {
  16597. _, ok := m.clearedFields[name]
  16598. return ok
  16599. }
  16600. // ClearField clears the value of the field with the given name. It returns an
  16601. // error if the field is not defined in the schema.
  16602. func (m *MessageMutation) ClearField(name string) error {
  16603. switch name {
  16604. case message.FieldWxWxid:
  16605. m.ClearWxWxid()
  16606. return nil
  16607. }
  16608. return fmt.Errorf("unknown Message nullable field %s", name)
  16609. }
  16610. // ResetField resets all changes in the mutation for the field with the given name.
  16611. // It returns an error if the field is not defined in the schema.
  16612. func (m *MessageMutation) ResetField(name string) error {
  16613. switch name {
  16614. case message.FieldWxWxid:
  16615. m.ResetWxWxid()
  16616. return nil
  16617. case message.FieldWxid:
  16618. m.ResetWxid()
  16619. return nil
  16620. case message.FieldContent:
  16621. m.ResetContent()
  16622. return nil
  16623. }
  16624. return fmt.Errorf("unknown Message field %s", name)
  16625. }
  16626. // AddedEdges returns all edge names that were set/added in this mutation.
  16627. func (m *MessageMutation) AddedEdges() []string {
  16628. edges := make([]string, 0, 0)
  16629. return edges
  16630. }
  16631. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16632. // name in this mutation.
  16633. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  16634. return nil
  16635. }
  16636. // RemovedEdges returns all edge names that were removed in this mutation.
  16637. func (m *MessageMutation) RemovedEdges() []string {
  16638. edges := make([]string, 0, 0)
  16639. return edges
  16640. }
  16641. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16642. // the given name in this mutation.
  16643. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  16644. return nil
  16645. }
  16646. // ClearedEdges returns all edge names that were cleared in this mutation.
  16647. func (m *MessageMutation) ClearedEdges() []string {
  16648. edges := make([]string, 0, 0)
  16649. return edges
  16650. }
  16651. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16652. // was cleared in this mutation.
  16653. func (m *MessageMutation) EdgeCleared(name string) bool {
  16654. return false
  16655. }
  16656. // ClearEdge clears the value of the edge with the given name. It returns an error
  16657. // if that edge is not defined in the schema.
  16658. func (m *MessageMutation) ClearEdge(name string) error {
  16659. return fmt.Errorf("unknown Message unique edge %s", name)
  16660. }
  16661. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16662. // It returns an error if the edge is not defined in the schema.
  16663. func (m *MessageMutation) ResetEdge(name string) error {
  16664. return fmt.Errorf("unknown Message edge %s", name)
  16665. }
  16666. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  16667. type MessageRecordsMutation struct {
  16668. config
  16669. op Op
  16670. typ string
  16671. id *uint64
  16672. created_at *time.Time
  16673. updated_at *time.Time
  16674. status *uint8
  16675. addstatus *int8
  16676. bot_wxid *string
  16677. contact_type *int
  16678. addcontact_type *int
  16679. contact_wxid *string
  16680. content_type *int
  16681. addcontent_type *int
  16682. content *string
  16683. meta *custom_types.Meta
  16684. error_detail *string
  16685. send_time *time.Time
  16686. source_type *int
  16687. addsource_type *int
  16688. organization_id *uint64
  16689. addorganization_id *int64
  16690. clearedFields map[string]struct{}
  16691. sop_stage *uint64
  16692. clearedsop_stage bool
  16693. sop_node *uint64
  16694. clearedsop_node bool
  16695. message_contact *uint64
  16696. clearedmessage_contact bool
  16697. done bool
  16698. oldValue func(context.Context) (*MessageRecords, error)
  16699. predicates []predicate.MessageRecords
  16700. }
  16701. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  16702. // messagerecordsOption allows management of the mutation configuration using functional options.
  16703. type messagerecordsOption func(*MessageRecordsMutation)
  16704. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  16705. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  16706. m := &MessageRecordsMutation{
  16707. config: c,
  16708. op: op,
  16709. typ: TypeMessageRecords,
  16710. clearedFields: make(map[string]struct{}),
  16711. }
  16712. for _, opt := range opts {
  16713. opt(m)
  16714. }
  16715. return m
  16716. }
  16717. // withMessageRecordsID sets the ID field of the mutation.
  16718. func withMessageRecordsID(id uint64) messagerecordsOption {
  16719. return func(m *MessageRecordsMutation) {
  16720. var (
  16721. err error
  16722. once sync.Once
  16723. value *MessageRecords
  16724. )
  16725. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  16726. once.Do(func() {
  16727. if m.done {
  16728. err = errors.New("querying old values post mutation is not allowed")
  16729. } else {
  16730. value, err = m.Client().MessageRecords.Get(ctx, id)
  16731. }
  16732. })
  16733. return value, err
  16734. }
  16735. m.id = &id
  16736. }
  16737. }
  16738. // withMessageRecords sets the old MessageRecords of the mutation.
  16739. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  16740. return func(m *MessageRecordsMutation) {
  16741. m.oldValue = func(context.Context) (*MessageRecords, error) {
  16742. return node, nil
  16743. }
  16744. m.id = &node.ID
  16745. }
  16746. }
  16747. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16748. // executed in a transaction (ent.Tx), a transactional client is returned.
  16749. func (m MessageRecordsMutation) Client() *Client {
  16750. client := &Client{config: m.config}
  16751. client.init()
  16752. return client
  16753. }
  16754. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16755. // it returns an error otherwise.
  16756. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  16757. if _, ok := m.driver.(*txDriver); !ok {
  16758. return nil, errors.New("ent: mutation is not running in a transaction")
  16759. }
  16760. tx := &Tx{config: m.config}
  16761. tx.init()
  16762. return tx, nil
  16763. }
  16764. // SetID sets the value of the id field. Note that this
  16765. // operation is only accepted on creation of MessageRecords entities.
  16766. func (m *MessageRecordsMutation) SetID(id uint64) {
  16767. m.id = &id
  16768. }
  16769. // ID returns the ID value in the mutation. Note that the ID is only available
  16770. // if it was provided to the builder or after it was returned from the database.
  16771. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  16772. if m.id == nil {
  16773. return
  16774. }
  16775. return *m.id, true
  16776. }
  16777. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16778. // That means, if the mutation is applied within a transaction with an isolation level such
  16779. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16780. // or updated by the mutation.
  16781. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  16782. switch {
  16783. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16784. id, exists := m.ID()
  16785. if exists {
  16786. return []uint64{id}, nil
  16787. }
  16788. fallthrough
  16789. case m.op.Is(OpUpdate | OpDelete):
  16790. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  16791. default:
  16792. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16793. }
  16794. }
  16795. // SetCreatedAt sets the "created_at" field.
  16796. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  16797. m.created_at = &t
  16798. }
  16799. // CreatedAt returns the value of the "created_at" field in the mutation.
  16800. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  16801. v := m.created_at
  16802. if v == nil {
  16803. return
  16804. }
  16805. return *v, true
  16806. }
  16807. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  16808. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16810. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16811. if !m.op.Is(OpUpdateOne) {
  16812. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16813. }
  16814. if m.id == nil || m.oldValue == nil {
  16815. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16816. }
  16817. oldValue, err := m.oldValue(ctx)
  16818. if err != nil {
  16819. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16820. }
  16821. return oldValue.CreatedAt, nil
  16822. }
  16823. // ResetCreatedAt resets all changes to the "created_at" field.
  16824. func (m *MessageRecordsMutation) ResetCreatedAt() {
  16825. m.created_at = nil
  16826. }
  16827. // SetUpdatedAt sets the "updated_at" field.
  16828. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  16829. m.updated_at = &t
  16830. }
  16831. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16832. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  16833. v := m.updated_at
  16834. if v == nil {
  16835. return
  16836. }
  16837. return *v, true
  16838. }
  16839. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  16840. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16842. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16843. if !m.op.Is(OpUpdateOne) {
  16844. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16845. }
  16846. if m.id == nil || m.oldValue == nil {
  16847. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16848. }
  16849. oldValue, err := m.oldValue(ctx)
  16850. if err != nil {
  16851. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16852. }
  16853. return oldValue.UpdatedAt, nil
  16854. }
  16855. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16856. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  16857. m.updated_at = nil
  16858. }
  16859. // SetStatus sets the "status" field.
  16860. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  16861. m.status = &u
  16862. m.addstatus = nil
  16863. }
  16864. // Status returns the value of the "status" field in the mutation.
  16865. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  16866. v := m.status
  16867. if v == nil {
  16868. return
  16869. }
  16870. return *v, true
  16871. }
  16872. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  16873. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16875. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16876. if !m.op.Is(OpUpdateOne) {
  16877. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16878. }
  16879. if m.id == nil || m.oldValue == nil {
  16880. return v, errors.New("OldStatus requires an ID field in the mutation")
  16881. }
  16882. oldValue, err := m.oldValue(ctx)
  16883. if err != nil {
  16884. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16885. }
  16886. return oldValue.Status, nil
  16887. }
  16888. // AddStatus adds u to the "status" field.
  16889. func (m *MessageRecordsMutation) AddStatus(u int8) {
  16890. if m.addstatus != nil {
  16891. *m.addstatus += u
  16892. } else {
  16893. m.addstatus = &u
  16894. }
  16895. }
  16896. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16897. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  16898. v := m.addstatus
  16899. if v == nil {
  16900. return
  16901. }
  16902. return *v, true
  16903. }
  16904. // ClearStatus clears the value of the "status" field.
  16905. func (m *MessageRecordsMutation) ClearStatus() {
  16906. m.status = nil
  16907. m.addstatus = nil
  16908. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  16909. }
  16910. // StatusCleared returns if the "status" field was cleared in this mutation.
  16911. func (m *MessageRecordsMutation) StatusCleared() bool {
  16912. _, ok := m.clearedFields[messagerecords.FieldStatus]
  16913. return ok
  16914. }
  16915. // ResetStatus resets all changes to the "status" field.
  16916. func (m *MessageRecordsMutation) ResetStatus() {
  16917. m.status = nil
  16918. m.addstatus = nil
  16919. delete(m.clearedFields, messagerecords.FieldStatus)
  16920. }
  16921. // SetBotWxid sets the "bot_wxid" field.
  16922. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  16923. m.bot_wxid = &s
  16924. }
  16925. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  16926. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  16927. v := m.bot_wxid
  16928. if v == nil {
  16929. return
  16930. }
  16931. return *v, true
  16932. }
  16933. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  16934. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16936. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  16937. if !m.op.Is(OpUpdateOne) {
  16938. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  16939. }
  16940. if m.id == nil || m.oldValue == nil {
  16941. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  16942. }
  16943. oldValue, err := m.oldValue(ctx)
  16944. if err != nil {
  16945. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  16946. }
  16947. return oldValue.BotWxid, nil
  16948. }
  16949. // ResetBotWxid resets all changes to the "bot_wxid" field.
  16950. func (m *MessageRecordsMutation) ResetBotWxid() {
  16951. m.bot_wxid = nil
  16952. }
  16953. // SetContactID sets the "contact_id" field.
  16954. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  16955. m.message_contact = &u
  16956. }
  16957. // ContactID returns the value of the "contact_id" field in the mutation.
  16958. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  16959. v := m.message_contact
  16960. if v == nil {
  16961. return
  16962. }
  16963. return *v, true
  16964. }
  16965. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  16966. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16968. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  16969. if !m.op.Is(OpUpdateOne) {
  16970. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  16971. }
  16972. if m.id == nil || m.oldValue == nil {
  16973. return v, errors.New("OldContactID requires an ID field in the mutation")
  16974. }
  16975. oldValue, err := m.oldValue(ctx)
  16976. if err != nil {
  16977. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  16978. }
  16979. return oldValue.ContactID, nil
  16980. }
  16981. // ClearContactID clears the value of the "contact_id" field.
  16982. func (m *MessageRecordsMutation) ClearContactID() {
  16983. m.message_contact = nil
  16984. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  16985. }
  16986. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  16987. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  16988. _, ok := m.clearedFields[messagerecords.FieldContactID]
  16989. return ok
  16990. }
  16991. // ResetContactID resets all changes to the "contact_id" field.
  16992. func (m *MessageRecordsMutation) ResetContactID() {
  16993. m.message_contact = nil
  16994. delete(m.clearedFields, messagerecords.FieldContactID)
  16995. }
  16996. // SetContactType sets the "contact_type" field.
  16997. func (m *MessageRecordsMutation) SetContactType(i int) {
  16998. m.contact_type = &i
  16999. m.addcontact_type = nil
  17000. }
  17001. // ContactType returns the value of the "contact_type" field in the mutation.
  17002. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  17003. v := m.contact_type
  17004. if v == nil {
  17005. return
  17006. }
  17007. return *v, true
  17008. }
  17009. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  17010. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17012. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  17013. if !m.op.Is(OpUpdateOne) {
  17014. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  17015. }
  17016. if m.id == nil || m.oldValue == nil {
  17017. return v, errors.New("OldContactType requires an ID field in the mutation")
  17018. }
  17019. oldValue, err := m.oldValue(ctx)
  17020. if err != nil {
  17021. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  17022. }
  17023. return oldValue.ContactType, nil
  17024. }
  17025. // AddContactType adds i to the "contact_type" field.
  17026. func (m *MessageRecordsMutation) AddContactType(i int) {
  17027. if m.addcontact_type != nil {
  17028. *m.addcontact_type += i
  17029. } else {
  17030. m.addcontact_type = &i
  17031. }
  17032. }
  17033. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  17034. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  17035. v := m.addcontact_type
  17036. if v == nil {
  17037. return
  17038. }
  17039. return *v, true
  17040. }
  17041. // ResetContactType resets all changes to the "contact_type" field.
  17042. func (m *MessageRecordsMutation) ResetContactType() {
  17043. m.contact_type = nil
  17044. m.addcontact_type = nil
  17045. }
  17046. // SetContactWxid sets the "contact_wxid" field.
  17047. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  17048. m.contact_wxid = &s
  17049. }
  17050. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  17051. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  17052. v := m.contact_wxid
  17053. if v == nil {
  17054. return
  17055. }
  17056. return *v, true
  17057. }
  17058. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  17059. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17061. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  17062. if !m.op.Is(OpUpdateOne) {
  17063. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  17064. }
  17065. if m.id == nil || m.oldValue == nil {
  17066. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  17067. }
  17068. oldValue, err := m.oldValue(ctx)
  17069. if err != nil {
  17070. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  17071. }
  17072. return oldValue.ContactWxid, nil
  17073. }
  17074. // ResetContactWxid resets all changes to the "contact_wxid" field.
  17075. func (m *MessageRecordsMutation) ResetContactWxid() {
  17076. m.contact_wxid = nil
  17077. }
  17078. // SetContentType sets the "content_type" field.
  17079. func (m *MessageRecordsMutation) SetContentType(i int) {
  17080. m.content_type = &i
  17081. m.addcontent_type = nil
  17082. }
  17083. // ContentType returns the value of the "content_type" field in the mutation.
  17084. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  17085. v := m.content_type
  17086. if v == nil {
  17087. return
  17088. }
  17089. return *v, true
  17090. }
  17091. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  17092. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17094. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  17095. if !m.op.Is(OpUpdateOne) {
  17096. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  17097. }
  17098. if m.id == nil || m.oldValue == nil {
  17099. return v, errors.New("OldContentType requires an ID field in the mutation")
  17100. }
  17101. oldValue, err := m.oldValue(ctx)
  17102. if err != nil {
  17103. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  17104. }
  17105. return oldValue.ContentType, nil
  17106. }
  17107. // AddContentType adds i to the "content_type" field.
  17108. func (m *MessageRecordsMutation) AddContentType(i int) {
  17109. if m.addcontent_type != nil {
  17110. *m.addcontent_type += i
  17111. } else {
  17112. m.addcontent_type = &i
  17113. }
  17114. }
  17115. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  17116. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  17117. v := m.addcontent_type
  17118. if v == nil {
  17119. return
  17120. }
  17121. return *v, true
  17122. }
  17123. // ResetContentType resets all changes to the "content_type" field.
  17124. func (m *MessageRecordsMutation) ResetContentType() {
  17125. m.content_type = nil
  17126. m.addcontent_type = nil
  17127. }
  17128. // SetContent sets the "content" field.
  17129. func (m *MessageRecordsMutation) SetContent(s string) {
  17130. m.content = &s
  17131. }
  17132. // Content returns the value of the "content" field in the mutation.
  17133. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  17134. v := m.content
  17135. if v == nil {
  17136. return
  17137. }
  17138. return *v, true
  17139. }
  17140. // OldContent returns the old "content" field's value of the MessageRecords entity.
  17141. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17143. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  17144. if !m.op.Is(OpUpdateOne) {
  17145. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17146. }
  17147. if m.id == nil || m.oldValue == nil {
  17148. return v, errors.New("OldContent requires an ID field in the mutation")
  17149. }
  17150. oldValue, err := m.oldValue(ctx)
  17151. if err != nil {
  17152. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17153. }
  17154. return oldValue.Content, nil
  17155. }
  17156. // ResetContent resets all changes to the "content" field.
  17157. func (m *MessageRecordsMutation) ResetContent() {
  17158. m.content = nil
  17159. }
  17160. // SetMeta sets the "meta" field.
  17161. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  17162. m.meta = &ct
  17163. }
  17164. // Meta returns the value of the "meta" field in the mutation.
  17165. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  17166. v := m.meta
  17167. if v == nil {
  17168. return
  17169. }
  17170. return *v, true
  17171. }
  17172. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  17173. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17175. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  17176. if !m.op.Is(OpUpdateOne) {
  17177. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  17178. }
  17179. if m.id == nil || m.oldValue == nil {
  17180. return v, errors.New("OldMeta requires an ID field in the mutation")
  17181. }
  17182. oldValue, err := m.oldValue(ctx)
  17183. if err != nil {
  17184. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  17185. }
  17186. return oldValue.Meta, nil
  17187. }
  17188. // ClearMeta clears the value of the "meta" field.
  17189. func (m *MessageRecordsMutation) ClearMeta() {
  17190. m.meta = nil
  17191. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  17192. }
  17193. // MetaCleared returns if the "meta" field was cleared in this mutation.
  17194. func (m *MessageRecordsMutation) MetaCleared() bool {
  17195. _, ok := m.clearedFields[messagerecords.FieldMeta]
  17196. return ok
  17197. }
  17198. // ResetMeta resets all changes to the "meta" field.
  17199. func (m *MessageRecordsMutation) ResetMeta() {
  17200. m.meta = nil
  17201. delete(m.clearedFields, messagerecords.FieldMeta)
  17202. }
  17203. // SetErrorDetail sets the "error_detail" field.
  17204. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  17205. m.error_detail = &s
  17206. }
  17207. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  17208. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  17209. v := m.error_detail
  17210. if v == nil {
  17211. return
  17212. }
  17213. return *v, true
  17214. }
  17215. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  17216. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17218. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  17219. if !m.op.Is(OpUpdateOne) {
  17220. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  17221. }
  17222. if m.id == nil || m.oldValue == nil {
  17223. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  17224. }
  17225. oldValue, err := m.oldValue(ctx)
  17226. if err != nil {
  17227. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  17228. }
  17229. return oldValue.ErrorDetail, nil
  17230. }
  17231. // ResetErrorDetail resets all changes to the "error_detail" field.
  17232. func (m *MessageRecordsMutation) ResetErrorDetail() {
  17233. m.error_detail = nil
  17234. }
  17235. // SetSendTime sets the "send_time" field.
  17236. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  17237. m.send_time = &t
  17238. }
  17239. // SendTime returns the value of the "send_time" field in the mutation.
  17240. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  17241. v := m.send_time
  17242. if v == nil {
  17243. return
  17244. }
  17245. return *v, true
  17246. }
  17247. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  17248. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17250. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  17251. if !m.op.Is(OpUpdateOne) {
  17252. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  17253. }
  17254. if m.id == nil || m.oldValue == nil {
  17255. return v, errors.New("OldSendTime requires an ID field in the mutation")
  17256. }
  17257. oldValue, err := m.oldValue(ctx)
  17258. if err != nil {
  17259. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  17260. }
  17261. return oldValue.SendTime, nil
  17262. }
  17263. // ClearSendTime clears the value of the "send_time" field.
  17264. func (m *MessageRecordsMutation) ClearSendTime() {
  17265. m.send_time = nil
  17266. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  17267. }
  17268. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  17269. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  17270. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  17271. return ok
  17272. }
  17273. // ResetSendTime resets all changes to the "send_time" field.
  17274. func (m *MessageRecordsMutation) ResetSendTime() {
  17275. m.send_time = nil
  17276. delete(m.clearedFields, messagerecords.FieldSendTime)
  17277. }
  17278. // SetSourceType sets the "source_type" field.
  17279. func (m *MessageRecordsMutation) SetSourceType(i int) {
  17280. m.source_type = &i
  17281. m.addsource_type = nil
  17282. }
  17283. // SourceType returns the value of the "source_type" field in the mutation.
  17284. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  17285. v := m.source_type
  17286. if v == nil {
  17287. return
  17288. }
  17289. return *v, true
  17290. }
  17291. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  17292. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17294. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  17295. if !m.op.Is(OpUpdateOne) {
  17296. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  17297. }
  17298. if m.id == nil || m.oldValue == nil {
  17299. return v, errors.New("OldSourceType requires an ID field in the mutation")
  17300. }
  17301. oldValue, err := m.oldValue(ctx)
  17302. if err != nil {
  17303. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  17304. }
  17305. return oldValue.SourceType, nil
  17306. }
  17307. // AddSourceType adds i to the "source_type" field.
  17308. func (m *MessageRecordsMutation) AddSourceType(i int) {
  17309. if m.addsource_type != nil {
  17310. *m.addsource_type += i
  17311. } else {
  17312. m.addsource_type = &i
  17313. }
  17314. }
  17315. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  17316. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  17317. v := m.addsource_type
  17318. if v == nil {
  17319. return
  17320. }
  17321. return *v, true
  17322. }
  17323. // ResetSourceType resets all changes to the "source_type" field.
  17324. func (m *MessageRecordsMutation) ResetSourceType() {
  17325. m.source_type = nil
  17326. m.addsource_type = nil
  17327. }
  17328. // SetSourceID sets the "source_id" field.
  17329. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  17330. m.sop_stage = &u
  17331. }
  17332. // SourceID returns the value of the "source_id" field in the mutation.
  17333. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  17334. v := m.sop_stage
  17335. if v == nil {
  17336. return
  17337. }
  17338. return *v, true
  17339. }
  17340. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  17341. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17343. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  17344. if !m.op.Is(OpUpdateOne) {
  17345. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  17346. }
  17347. if m.id == nil || m.oldValue == nil {
  17348. return v, errors.New("OldSourceID requires an ID field in the mutation")
  17349. }
  17350. oldValue, err := m.oldValue(ctx)
  17351. if err != nil {
  17352. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  17353. }
  17354. return oldValue.SourceID, nil
  17355. }
  17356. // ClearSourceID clears the value of the "source_id" field.
  17357. func (m *MessageRecordsMutation) ClearSourceID() {
  17358. m.sop_stage = nil
  17359. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17360. }
  17361. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  17362. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  17363. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  17364. return ok
  17365. }
  17366. // ResetSourceID resets all changes to the "source_id" field.
  17367. func (m *MessageRecordsMutation) ResetSourceID() {
  17368. m.sop_stage = nil
  17369. delete(m.clearedFields, messagerecords.FieldSourceID)
  17370. }
  17371. // SetSubSourceID sets the "sub_source_id" field.
  17372. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  17373. m.sop_node = &u
  17374. }
  17375. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  17376. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  17377. v := m.sop_node
  17378. if v == nil {
  17379. return
  17380. }
  17381. return *v, true
  17382. }
  17383. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  17384. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17386. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  17387. if !m.op.Is(OpUpdateOne) {
  17388. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  17389. }
  17390. if m.id == nil || m.oldValue == nil {
  17391. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  17392. }
  17393. oldValue, err := m.oldValue(ctx)
  17394. if err != nil {
  17395. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  17396. }
  17397. return oldValue.SubSourceID, nil
  17398. }
  17399. // ClearSubSourceID clears the value of the "sub_source_id" field.
  17400. func (m *MessageRecordsMutation) ClearSubSourceID() {
  17401. m.sop_node = nil
  17402. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17403. }
  17404. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  17405. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  17406. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  17407. return ok
  17408. }
  17409. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  17410. func (m *MessageRecordsMutation) ResetSubSourceID() {
  17411. m.sop_node = nil
  17412. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  17413. }
  17414. // SetOrganizationID sets the "organization_id" field.
  17415. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  17416. m.organization_id = &u
  17417. m.addorganization_id = nil
  17418. }
  17419. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17420. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  17421. v := m.organization_id
  17422. if v == nil {
  17423. return
  17424. }
  17425. return *v, true
  17426. }
  17427. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  17428. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17430. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17431. if !m.op.Is(OpUpdateOne) {
  17432. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17433. }
  17434. if m.id == nil || m.oldValue == nil {
  17435. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17436. }
  17437. oldValue, err := m.oldValue(ctx)
  17438. if err != nil {
  17439. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17440. }
  17441. return oldValue.OrganizationID, nil
  17442. }
  17443. // AddOrganizationID adds u to the "organization_id" field.
  17444. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  17445. if m.addorganization_id != nil {
  17446. *m.addorganization_id += u
  17447. } else {
  17448. m.addorganization_id = &u
  17449. }
  17450. }
  17451. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17452. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  17453. v := m.addorganization_id
  17454. if v == nil {
  17455. return
  17456. }
  17457. return *v, true
  17458. }
  17459. // ClearOrganizationID clears the value of the "organization_id" field.
  17460. func (m *MessageRecordsMutation) ClearOrganizationID() {
  17461. m.organization_id = nil
  17462. m.addorganization_id = nil
  17463. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  17464. }
  17465. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17466. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  17467. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  17468. return ok
  17469. }
  17470. // ResetOrganizationID resets all changes to the "organization_id" field.
  17471. func (m *MessageRecordsMutation) ResetOrganizationID() {
  17472. m.organization_id = nil
  17473. m.addorganization_id = nil
  17474. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  17475. }
  17476. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17477. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  17478. m.sop_stage = &id
  17479. }
  17480. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17481. func (m *MessageRecordsMutation) ClearSopStage() {
  17482. m.clearedsop_stage = true
  17483. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17484. }
  17485. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17486. func (m *MessageRecordsMutation) SopStageCleared() bool {
  17487. return m.SourceIDCleared() || m.clearedsop_stage
  17488. }
  17489. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17490. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  17491. if m.sop_stage != nil {
  17492. return *m.sop_stage, true
  17493. }
  17494. return
  17495. }
  17496. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17497. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17498. // SopStageID instead. It exists only for internal usage by the builders.
  17499. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  17500. if id := m.sop_stage; id != nil {
  17501. ids = append(ids, *id)
  17502. }
  17503. return
  17504. }
  17505. // ResetSopStage resets all changes to the "sop_stage" edge.
  17506. func (m *MessageRecordsMutation) ResetSopStage() {
  17507. m.sop_stage = nil
  17508. m.clearedsop_stage = false
  17509. }
  17510. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  17511. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  17512. m.sop_node = &id
  17513. }
  17514. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  17515. func (m *MessageRecordsMutation) ClearSopNode() {
  17516. m.clearedsop_node = true
  17517. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17518. }
  17519. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  17520. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  17521. return m.SubSourceIDCleared() || m.clearedsop_node
  17522. }
  17523. // SopNodeID returns the "sop_node" edge ID in the mutation.
  17524. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  17525. if m.sop_node != nil {
  17526. return *m.sop_node, true
  17527. }
  17528. return
  17529. }
  17530. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  17531. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17532. // SopNodeID instead. It exists only for internal usage by the builders.
  17533. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  17534. if id := m.sop_node; id != nil {
  17535. ids = append(ids, *id)
  17536. }
  17537. return
  17538. }
  17539. // ResetSopNode resets all changes to the "sop_node" edge.
  17540. func (m *MessageRecordsMutation) ResetSopNode() {
  17541. m.sop_node = nil
  17542. m.clearedsop_node = false
  17543. }
  17544. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  17545. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  17546. m.message_contact = &id
  17547. }
  17548. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  17549. func (m *MessageRecordsMutation) ClearMessageContact() {
  17550. m.clearedmessage_contact = true
  17551. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17552. }
  17553. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  17554. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  17555. return m.ContactIDCleared() || m.clearedmessage_contact
  17556. }
  17557. // MessageContactID returns the "message_contact" edge ID in the mutation.
  17558. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  17559. if m.message_contact != nil {
  17560. return *m.message_contact, true
  17561. }
  17562. return
  17563. }
  17564. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  17565. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17566. // MessageContactID instead. It exists only for internal usage by the builders.
  17567. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  17568. if id := m.message_contact; id != nil {
  17569. ids = append(ids, *id)
  17570. }
  17571. return
  17572. }
  17573. // ResetMessageContact resets all changes to the "message_contact" edge.
  17574. func (m *MessageRecordsMutation) ResetMessageContact() {
  17575. m.message_contact = nil
  17576. m.clearedmessage_contact = false
  17577. }
  17578. // Where appends a list predicates to the MessageRecordsMutation builder.
  17579. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  17580. m.predicates = append(m.predicates, ps...)
  17581. }
  17582. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  17583. // users can use type-assertion to append predicates that do not depend on any generated package.
  17584. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  17585. p := make([]predicate.MessageRecords, len(ps))
  17586. for i := range ps {
  17587. p[i] = ps[i]
  17588. }
  17589. m.Where(p...)
  17590. }
  17591. // Op returns the operation name.
  17592. func (m *MessageRecordsMutation) Op() Op {
  17593. return m.op
  17594. }
  17595. // SetOp allows setting the mutation operation.
  17596. func (m *MessageRecordsMutation) SetOp(op Op) {
  17597. m.op = op
  17598. }
  17599. // Type returns the node type of this mutation (MessageRecords).
  17600. func (m *MessageRecordsMutation) Type() string {
  17601. return m.typ
  17602. }
  17603. // Fields returns all fields that were changed during this mutation. Note that in
  17604. // order to get all numeric fields that were incremented/decremented, call
  17605. // AddedFields().
  17606. func (m *MessageRecordsMutation) Fields() []string {
  17607. fields := make([]string, 0, 16)
  17608. if m.created_at != nil {
  17609. fields = append(fields, messagerecords.FieldCreatedAt)
  17610. }
  17611. if m.updated_at != nil {
  17612. fields = append(fields, messagerecords.FieldUpdatedAt)
  17613. }
  17614. if m.status != nil {
  17615. fields = append(fields, messagerecords.FieldStatus)
  17616. }
  17617. if m.bot_wxid != nil {
  17618. fields = append(fields, messagerecords.FieldBotWxid)
  17619. }
  17620. if m.message_contact != nil {
  17621. fields = append(fields, messagerecords.FieldContactID)
  17622. }
  17623. if m.contact_type != nil {
  17624. fields = append(fields, messagerecords.FieldContactType)
  17625. }
  17626. if m.contact_wxid != nil {
  17627. fields = append(fields, messagerecords.FieldContactWxid)
  17628. }
  17629. if m.content_type != nil {
  17630. fields = append(fields, messagerecords.FieldContentType)
  17631. }
  17632. if m.content != nil {
  17633. fields = append(fields, messagerecords.FieldContent)
  17634. }
  17635. if m.meta != nil {
  17636. fields = append(fields, messagerecords.FieldMeta)
  17637. }
  17638. if m.error_detail != nil {
  17639. fields = append(fields, messagerecords.FieldErrorDetail)
  17640. }
  17641. if m.send_time != nil {
  17642. fields = append(fields, messagerecords.FieldSendTime)
  17643. }
  17644. if m.source_type != nil {
  17645. fields = append(fields, messagerecords.FieldSourceType)
  17646. }
  17647. if m.sop_stage != nil {
  17648. fields = append(fields, messagerecords.FieldSourceID)
  17649. }
  17650. if m.sop_node != nil {
  17651. fields = append(fields, messagerecords.FieldSubSourceID)
  17652. }
  17653. if m.organization_id != nil {
  17654. fields = append(fields, messagerecords.FieldOrganizationID)
  17655. }
  17656. return fields
  17657. }
  17658. // Field returns the value of a field with the given name. The second boolean
  17659. // return value indicates that this field was not set, or was not defined in the
  17660. // schema.
  17661. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  17662. switch name {
  17663. case messagerecords.FieldCreatedAt:
  17664. return m.CreatedAt()
  17665. case messagerecords.FieldUpdatedAt:
  17666. return m.UpdatedAt()
  17667. case messagerecords.FieldStatus:
  17668. return m.Status()
  17669. case messagerecords.FieldBotWxid:
  17670. return m.BotWxid()
  17671. case messagerecords.FieldContactID:
  17672. return m.ContactID()
  17673. case messagerecords.FieldContactType:
  17674. return m.ContactType()
  17675. case messagerecords.FieldContactWxid:
  17676. return m.ContactWxid()
  17677. case messagerecords.FieldContentType:
  17678. return m.ContentType()
  17679. case messagerecords.FieldContent:
  17680. return m.Content()
  17681. case messagerecords.FieldMeta:
  17682. return m.Meta()
  17683. case messagerecords.FieldErrorDetail:
  17684. return m.ErrorDetail()
  17685. case messagerecords.FieldSendTime:
  17686. return m.SendTime()
  17687. case messagerecords.FieldSourceType:
  17688. return m.SourceType()
  17689. case messagerecords.FieldSourceID:
  17690. return m.SourceID()
  17691. case messagerecords.FieldSubSourceID:
  17692. return m.SubSourceID()
  17693. case messagerecords.FieldOrganizationID:
  17694. return m.OrganizationID()
  17695. }
  17696. return nil, false
  17697. }
  17698. // OldField returns the old value of the field from the database. An error is
  17699. // returned if the mutation operation is not UpdateOne, or the query to the
  17700. // database failed.
  17701. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17702. switch name {
  17703. case messagerecords.FieldCreatedAt:
  17704. return m.OldCreatedAt(ctx)
  17705. case messagerecords.FieldUpdatedAt:
  17706. return m.OldUpdatedAt(ctx)
  17707. case messagerecords.FieldStatus:
  17708. return m.OldStatus(ctx)
  17709. case messagerecords.FieldBotWxid:
  17710. return m.OldBotWxid(ctx)
  17711. case messagerecords.FieldContactID:
  17712. return m.OldContactID(ctx)
  17713. case messagerecords.FieldContactType:
  17714. return m.OldContactType(ctx)
  17715. case messagerecords.FieldContactWxid:
  17716. return m.OldContactWxid(ctx)
  17717. case messagerecords.FieldContentType:
  17718. return m.OldContentType(ctx)
  17719. case messagerecords.FieldContent:
  17720. return m.OldContent(ctx)
  17721. case messagerecords.FieldMeta:
  17722. return m.OldMeta(ctx)
  17723. case messagerecords.FieldErrorDetail:
  17724. return m.OldErrorDetail(ctx)
  17725. case messagerecords.FieldSendTime:
  17726. return m.OldSendTime(ctx)
  17727. case messagerecords.FieldSourceType:
  17728. return m.OldSourceType(ctx)
  17729. case messagerecords.FieldSourceID:
  17730. return m.OldSourceID(ctx)
  17731. case messagerecords.FieldSubSourceID:
  17732. return m.OldSubSourceID(ctx)
  17733. case messagerecords.FieldOrganizationID:
  17734. return m.OldOrganizationID(ctx)
  17735. }
  17736. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  17737. }
  17738. // SetField sets the value of a field with the given name. It returns an error if
  17739. // the field is not defined in the schema, or if the type mismatched the field
  17740. // type.
  17741. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  17742. switch name {
  17743. case messagerecords.FieldCreatedAt:
  17744. v, ok := value.(time.Time)
  17745. if !ok {
  17746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17747. }
  17748. m.SetCreatedAt(v)
  17749. return nil
  17750. case messagerecords.FieldUpdatedAt:
  17751. v, ok := value.(time.Time)
  17752. if !ok {
  17753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17754. }
  17755. m.SetUpdatedAt(v)
  17756. return nil
  17757. case messagerecords.FieldStatus:
  17758. v, ok := value.(uint8)
  17759. if !ok {
  17760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17761. }
  17762. m.SetStatus(v)
  17763. return nil
  17764. case messagerecords.FieldBotWxid:
  17765. v, ok := value.(string)
  17766. if !ok {
  17767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17768. }
  17769. m.SetBotWxid(v)
  17770. return nil
  17771. case messagerecords.FieldContactID:
  17772. v, ok := value.(uint64)
  17773. if !ok {
  17774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17775. }
  17776. m.SetContactID(v)
  17777. return nil
  17778. case messagerecords.FieldContactType:
  17779. v, ok := value.(int)
  17780. if !ok {
  17781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17782. }
  17783. m.SetContactType(v)
  17784. return nil
  17785. case messagerecords.FieldContactWxid:
  17786. v, ok := value.(string)
  17787. if !ok {
  17788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17789. }
  17790. m.SetContactWxid(v)
  17791. return nil
  17792. case messagerecords.FieldContentType:
  17793. v, ok := value.(int)
  17794. if !ok {
  17795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17796. }
  17797. m.SetContentType(v)
  17798. return nil
  17799. case messagerecords.FieldContent:
  17800. v, ok := value.(string)
  17801. if !ok {
  17802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17803. }
  17804. m.SetContent(v)
  17805. return nil
  17806. case messagerecords.FieldMeta:
  17807. v, ok := value.(custom_types.Meta)
  17808. if !ok {
  17809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17810. }
  17811. m.SetMeta(v)
  17812. return nil
  17813. case messagerecords.FieldErrorDetail:
  17814. v, ok := value.(string)
  17815. if !ok {
  17816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17817. }
  17818. m.SetErrorDetail(v)
  17819. return nil
  17820. case messagerecords.FieldSendTime:
  17821. v, ok := value.(time.Time)
  17822. if !ok {
  17823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17824. }
  17825. m.SetSendTime(v)
  17826. return nil
  17827. case messagerecords.FieldSourceType:
  17828. v, ok := value.(int)
  17829. if !ok {
  17830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17831. }
  17832. m.SetSourceType(v)
  17833. return nil
  17834. case messagerecords.FieldSourceID:
  17835. v, ok := value.(uint64)
  17836. if !ok {
  17837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17838. }
  17839. m.SetSourceID(v)
  17840. return nil
  17841. case messagerecords.FieldSubSourceID:
  17842. v, ok := value.(uint64)
  17843. if !ok {
  17844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17845. }
  17846. m.SetSubSourceID(v)
  17847. return nil
  17848. case messagerecords.FieldOrganizationID:
  17849. v, ok := value.(uint64)
  17850. if !ok {
  17851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17852. }
  17853. m.SetOrganizationID(v)
  17854. return nil
  17855. }
  17856. return fmt.Errorf("unknown MessageRecords field %s", name)
  17857. }
  17858. // AddedFields returns all numeric fields that were incremented/decremented during
  17859. // this mutation.
  17860. func (m *MessageRecordsMutation) AddedFields() []string {
  17861. var fields []string
  17862. if m.addstatus != nil {
  17863. fields = append(fields, messagerecords.FieldStatus)
  17864. }
  17865. if m.addcontact_type != nil {
  17866. fields = append(fields, messagerecords.FieldContactType)
  17867. }
  17868. if m.addcontent_type != nil {
  17869. fields = append(fields, messagerecords.FieldContentType)
  17870. }
  17871. if m.addsource_type != nil {
  17872. fields = append(fields, messagerecords.FieldSourceType)
  17873. }
  17874. if m.addorganization_id != nil {
  17875. fields = append(fields, messagerecords.FieldOrganizationID)
  17876. }
  17877. return fields
  17878. }
  17879. // AddedField returns the numeric value that was incremented/decremented on a field
  17880. // with the given name. The second boolean return value indicates that this field
  17881. // was not set, or was not defined in the schema.
  17882. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  17883. switch name {
  17884. case messagerecords.FieldStatus:
  17885. return m.AddedStatus()
  17886. case messagerecords.FieldContactType:
  17887. return m.AddedContactType()
  17888. case messagerecords.FieldContentType:
  17889. return m.AddedContentType()
  17890. case messagerecords.FieldSourceType:
  17891. return m.AddedSourceType()
  17892. case messagerecords.FieldOrganizationID:
  17893. return m.AddedOrganizationID()
  17894. }
  17895. return nil, false
  17896. }
  17897. // AddField adds the value to the field with the given name. It returns an error if
  17898. // the field is not defined in the schema, or if the type mismatched the field
  17899. // type.
  17900. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  17901. switch name {
  17902. case messagerecords.FieldStatus:
  17903. v, ok := value.(int8)
  17904. if !ok {
  17905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17906. }
  17907. m.AddStatus(v)
  17908. return nil
  17909. case messagerecords.FieldContactType:
  17910. v, ok := value.(int)
  17911. if !ok {
  17912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17913. }
  17914. m.AddContactType(v)
  17915. return nil
  17916. case messagerecords.FieldContentType:
  17917. v, ok := value.(int)
  17918. if !ok {
  17919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17920. }
  17921. m.AddContentType(v)
  17922. return nil
  17923. case messagerecords.FieldSourceType:
  17924. v, ok := value.(int)
  17925. if !ok {
  17926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17927. }
  17928. m.AddSourceType(v)
  17929. return nil
  17930. case messagerecords.FieldOrganizationID:
  17931. v, ok := value.(int64)
  17932. if !ok {
  17933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17934. }
  17935. m.AddOrganizationID(v)
  17936. return nil
  17937. }
  17938. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  17939. }
  17940. // ClearedFields returns all nullable fields that were cleared during this
  17941. // mutation.
  17942. func (m *MessageRecordsMutation) ClearedFields() []string {
  17943. var fields []string
  17944. if m.FieldCleared(messagerecords.FieldStatus) {
  17945. fields = append(fields, messagerecords.FieldStatus)
  17946. }
  17947. if m.FieldCleared(messagerecords.FieldContactID) {
  17948. fields = append(fields, messagerecords.FieldContactID)
  17949. }
  17950. if m.FieldCleared(messagerecords.FieldMeta) {
  17951. fields = append(fields, messagerecords.FieldMeta)
  17952. }
  17953. if m.FieldCleared(messagerecords.FieldSendTime) {
  17954. fields = append(fields, messagerecords.FieldSendTime)
  17955. }
  17956. if m.FieldCleared(messagerecords.FieldSourceID) {
  17957. fields = append(fields, messagerecords.FieldSourceID)
  17958. }
  17959. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  17960. fields = append(fields, messagerecords.FieldSubSourceID)
  17961. }
  17962. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  17963. fields = append(fields, messagerecords.FieldOrganizationID)
  17964. }
  17965. return fields
  17966. }
  17967. // FieldCleared returns a boolean indicating if a field with the given name was
  17968. // cleared in this mutation.
  17969. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  17970. _, ok := m.clearedFields[name]
  17971. return ok
  17972. }
  17973. // ClearField clears the value of the field with the given name. It returns an
  17974. // error if the field is not defined in the schema.
  17975. func (m *MessageRecordsMutation) ClearField(name string) error {
  17976. switch name {
  17977. case messagerecords.FieldStatus:
  17978. m.ClearStatus()
  17979. return nil
  17980. case messagerecords.FieldContactID:
  17981. m.ClearContactID()
  17982. return nil
  17983. case messagerecords.FieldMeta:
  17984. m.ClearMeta()
  17985. return nil
  17986. case messagerecords.FieldSendTime:
  17987. m.ClearSendTime()
  17988. return nil
  17989. case messagerecords.FieldSourceID:
  17990. m.ClearSourceID()
  17991. return nil
  17992. case messagerecords.FieldSubSourceID:
  17993. m.ClearSubSourceID()
  17994. return nil
  17995. case messagerecords.FieldOrganizationID:
  17996. m.ClearOrganizationID()
  17997. return nil
  17998. }
  17999. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  18000. }
  18001. // ResetField resets all changes in the mutation for the field with the given name.
  18002. // It returns an error if the field is not defined in the schema.
  18003. func (m *MessageRecordsMutation) ResetField(name string) error {
  18004. switch name {
  18005. case messagerecords.FieldCreatedAt:
  18006. m.ResetCreatedAt()
  18007. return nil
  18008. case messagerecords.FieldUpdatedAt:
  18009. m.ResetUpdatedAt()
  18010. return nil
  18011. case messagerecords.FieldStatus:
  18012. m.ResetStatus()
  18013. return nil
  18014. case messagerecords.FieldBotWxid:
  18015. m.ResetBotWxid()
  18016. return nil
  18017. case messagerecords.FieldContactID:
  18018. m.ResetContactID()
  18019. return nil
  18020. case messagerecords.FieldContactType:
  18021. m.ResetContactType()
  18022. return nil
  18023. case messagerecords.FieldContactWxid:
  18024. m.ResetContactWxid()
  18025. return nil
  18026. case messagerecords.FieldContentType:
  18027. m.ResetContentType()
  18028. return nil
  18029. case messagerecords.FieldContent:
  18030. m.ResetContent()
  18031. return nil
  18032. case messagerecords.FieldMeta:
  18033. m.ResetMeta()
  18034. return nil
  18035. case messagerecords.FieldErrorDetail:
  18036. m.ResetErrorDetail()
  18037. return nil
  18038. case messagerecords.FieldSendTime:
  18039. m.ResetSendTime()
  18040. return nil
  18041. case messagerecords.FieldSourceType:
  18042. m.ResetSourceType()
  18043. return nil
  18044. case messagerecords.FieldSourceID:
  18045. m.ResetSourceID()
  18046. return nil
  18047. case messagerecords.FieldSubSourceID:
  18048. m.ResetSubSourceID()
  18049. return nil
  18050. case messagerecords.FieldOrganizationID:
  18051. m.ResetOrganizationID()
  18052. return nil
  18053. }
  18054. return fmt.Errorf("unknown MessageRecords field %s", name)
  18055. }
  18056. // AddedEdges returns all edge names that were set/added in this mutation.
  18057. func (m *MessageRecordsMutation) AddedEdges() []string {
  18058. edges := make([]string, 0, 3)
  18059. if m.sop_stage != nil {
  18060. edges = append(edges, messagerecords.EdgeSopStage)
  18061. }
  18062. if m.sop_node != nil {
  18063. edges = append(edges, messagerecords.EdgeSopNode)
  18064. }
  18065. if m.message_contact != nil {
  18066. edges = append(edges, messagerecords.EdgeMessageContact)
  18067. }
  18068. return edges
  18069. }
  18070. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18071. // name in this mutation.
  18072. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  18073. switch name {
  18074. case messagerecords.EdgeSopStage:
  18075. if id := m.sop_stage; id != nil {
  18076. return []ent.Value{*id}
  18077. }
  18078. case messagerecords.EdgeSopNode:
  18079. if id := m.sop_node; id != nil {
  18080. return []ent.Value{*id}
  18081. }
  18082. case messagerecords.EdgeMessageContact:
  18083. if id := m.message_contact; id != nil {
  18084. return []ent.Value{*id}
  18085. }
  18086. }
  18087. return nil
  18088. }
  18089. // RemovedEdges returns all edge names that were removed in this mutation.
  18090. func (m *MessageRecordsMutation) RemovedEdges() []string {
  18091. edges := make([]string, 0, 3)
  18092. return edges
  18093. }
  18094. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18095. // the given name in this mutation.
  18096. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  18097. return nil
  18098. }
  18099. // ClearedEdges returns all edge names that were cleared in this mutation.
  18100. func (m *MessageRecordsMutation) ClearedEdges() []string {
  18101. edges := make([]string, 0, 3)
  18102. if m.clearedsop_stage {
  18103. edges = append(edges, messagerecords.EdgeSopStage)
  18104. }
  18105. if m.clearedsop_node {
  18106. edges = append(edges, messagerecords.EdgeSopNode)
  18107. }
  18108. if m.clearedmessage_contact {
  18109. edges = append(edges, messagerecords.EdgeMessageContact)
  18110. }
  18111. return edges
  18112. }
  18113. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18114. // was cleared in this mutation.
  18115. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  18116. switch name {
  18117. case messagerecords.EdgeSopStage:
  18118. return m.clearedsop_stage
  18119. case messagerecords.EdgeSopNode:
  18120. return m.clearedsop_node
  18121. case messagerecords.EdgeMessageContact:
  18122. return m.clearedmessage_contact
  18123. }
  18124. return false
  18125. }
  18126. // ClearEdge clears the value of the edge with the given name. It returns an error
  18127. // if that edge is not defined in the schema.
  18128. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  18129. switch name {
  18130. case messagerecords.EdgeSopStage:
  18131. m.ClearSopStage()
  18132. return nil
  18133. case messagerecords.EdgeSopNode:
  18134. m.ClearSopNode()
  18135. return nil
  18136. case messagerecords.EdgeMessageContact:
  18137. m.ClearMessageContact()
  18138. return nil
  18139. }
  18140. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  18141. }
  18142. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18143. // It returns an error if the edge is not defined in the schema.
  18144. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  18145. switch name {
  18146. case messagerecords.EdgeSopStage:
  18147. m.ResetSopStage()
  18148. return nil
  18149. case messagerecords.EdgeSopNode:
  18150. m.ResetSopNode()
  18151. return nil
  18152. case messagerecords.EdgeMessageContact:
  18153. m.ResetMessageContact()
  18154. return nil
  18155. }
  18156. return fmt.Errorf("unknown MessageRecords edge %s", name)
  18157. }
  18158. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  18159. type MsgMutation struct {
  18160. config
  18161. op Op
  18162. typ string
  18163. id *uint64
  18164. created_at *time.Time
  18165. updated_at *time.Time
  18166. deleted_at *time.Time
  18167. status *uint8
  18168. addstatus *int8
  18169. fromwxid *string
  18170. toid *string
  18171. msgtype *int32
  18172. addmsgtype *int32
  18173. msg *string
  18174. batch_no *string
  18175. clearedFields map[string]struct{}
  18176. done bool
  18177. oldValue func(context.Context) (*Msg, error)
  18178. predicates []predicate.Msg
  18179. }
  18180. var _ ent.Mutation = (*MsgMutation)(nil)
  18181. // msgOption allows management of the mutation configuration using functional options.
  18182. type msgOption func(*MsgMutation)
  18183. // newMsgMutation creates new mutation for the Msg entity.
  18184. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  18185. m := &MsgMutation{
  18186. config: c,
  18187. op: op,
  18188. typ: TypeMsg,
  18189. clearedFields: make(map[string]struct{}),
  18190. }
  18191. for _, opt := range opts {
  18192. opt(m)
  18193. }
  18194. return m
  18195. }
  18196. // withMsgID sets the ID field of the mutation.
  18197. func withMsgID(id uint64) msgOption {
  18198. return func(m *MsgMutation) {
  18199. var (
  18200. err error
  18201. once sync.Once
  18202. value *Msg
  18203. )
  18204. m.oldValue = func(ctx context.Context) (*Msg, error) {
  18205. once.Do(func() {
  18206. if m.done {
  18207. err = errors.New("querying old values post mutation is not allowed")
  18208. } else {
  18209. value, err = m.Client().Msg.Get(ctx, id)
  18210. }
  18211. })
  18212. return value, err
  18213. }
  18214. m.id = &id
  18215. }
  18216. }
  18217. // withMsg sets the old Msg of the mutation.
  18218. func withMsg(node *Msg) msgOption {
  18219. return func(m *MsgMutation) {
  18220. m.oldValue = func(context.Context) (*Msg, error) {
  18221. return node, nil
  18222. }
  18223. m.id = &node.ID
  18224. }
  18225. }
  18226. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18227. // executed in a transaction (ent.Tx), a transactional client is returned.
  18228. func (m MsgMutation) Client() *Client {
  18229. client := &Client{config: m.config}
  18230. client.init()
  18231. return client
  18232. }
  18233. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18234. // it returns an error otherwise.
  18235. func (m MsgMutation) Tx() (*Tx, error) {
  18236. if _, ok := m.driver.(*txDriver); !ok {
  18237. return nil, errors.New("ent: mutation is not running in a transaction")
  18238. }
  18239. tx := &Tx{config: m.config}
  18240. tx.init()
  18241. return tx, nil
  18242. }
  18243. // SetID sets the value of the id field. Note that this
  18244. // operation is only accepted on creation of Msg entities.
  18245. func (m *MsgMutation) SetID(id uint64) {
  18246. m.id = &id
  18247. }
  18248. // ID returns the ID value in the mutation. Note that the ID is only available
  18249. // if it was provided to the builder or after it was returned from the database.
  18250. func (m *MsgMutation) ID() (id uint64, exists bool) {
  18251. if m.id == nil {
  18252. return
  18253. }
  18254. return *m.id, true
  18255. }
  18256. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18257. // That means, if the mutation is applied within a transaction with an isolation level such
  18258. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18259. // or updated by the mutation.
  18260. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  18261. switch {
  18262. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18263. id, exists := m.ID()
  18264. if exists {
  18265. return []uint64{id}, nil
  18266. }
  18267. fallthrough
  18268. case m.op.Is(OpUpdate | OpDelete):
  18269. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  18270. default:
  18271. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18272. }
  18273. }
  18274. // SetCreatedAt sets the "created_at" field.
  18275. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  18276. m.created_at = &t
  18277. }
  18278. // CreatedAt returns the value of the "created_at" field in the mutation.
  18279. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  18280. v := m.created_at
  18281. if v == nil {
  18282. return
  18283. }
  18284. return *v, true
  18285. }
  18286. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  18287. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18289. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18290. if !m.op.Is(OpUpdateOne) {
  18291. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18292. }
  18293. if m.id == nil || m.oldValue == nil {
  18294. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18295. }
  18296. oldValue, err := m.oldValue(ctx)
  18297. if err != nil {
  18298. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18299. }
  18300. return oldValue.CreatedAt, nil
  18301. }
  18302. // ResetCreatedAt resets all changes to the "created_at" field.
  18303. func (m *MsgMutation) ResetCreatedAt() {
  18304. m.created_at = nil
  18305. }
  18306. // SetUpdatedAt sets the "updated_at" field.
  18307. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  18308. m.updated_at = &t
  18309. }
  18310. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18311. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  18312. v := m.updated_at
  18313. if v == nil {
  18314. return
  18315. }
  18316. return *v, true
  18317. }
  18318. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  18319. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18321. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18322. if !m.op.Is(OpUpdateOne) {
  18323. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18324. }
  18325. if m.id == nil || m.oldValue == nil {
  18326. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18327. }
  18328. oldValue, err := m.oldValue(ctx)
  18329. if err != nil {
  18330. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18331. }
  18332. return oldValue.UpdatedAt, nil
  18333. }
  18334. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18335. func (m *MsgMutation) ResetUpdatedAt() {
  18336. m.updated_at = nil
  18337. }
  18338. // SetDeletedAt sets the "deleted_at" field.
  18339. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  18340. m.deleted_at = &t
  18341. }
  18342. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18343. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  18344. v := m.deleted_at
  18345. if v == nil {
  18346. return
  18347. }
  18348. return *v, true
  18349. }
  18350. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  18351. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18353. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18354. if !m.op.Is(OpUpdateOne) {
  18355. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18356. }
  18357. if m.id == nil || m.oldValue == nil {
  18358. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18359. }
  18360. oldValue, err := m.oldValue(ctx)
  18361. if err != nil {
  18362. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18363. }
  18364. return oldValue.DeletedAt, nil
  18365. }
  18366. // ClearDeletedAt clears the value of the "deleted_at" field.
  18367. func (m *MsgMutation) ClearDeletedAt() {
  18368. m.deleted_at = nil
  18369. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  18370. }
  18371. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18372. func (m *MsgMutation) DeletedAtCleared() bool {
  18373. _, ok := m.clearedFields[msg.FieldDeletedAt]
  18374. return ok
  18375. }
  18376. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18377. func (m *MsgMutation) ResetDeletedAt() {
  18378. m.deleted_at = nil
  18379. delete(m.clearedFields, msg.FieldDeletedAt)
  18380. }
  18381. // SetStatus sets the "status" field.
  18382. func (m *MsgMutation) SetStatus(u uint8) {
  18383. m.status = &u
  18384. m.addstatus = nil
  18385. }
  18386. // Status returns the value of the "status" field in the mutation.
  18387. func (m *MsgMutation) Status() (r uint8, exists bool) {
  18388. v := m.status
  18389. if v == nil {
  18390. return
  18391. }
  18392. return *v, true
  18393. }
  18394. // OldStatus returns the old "status" field's value of the Msg entity.
  18395. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18397. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18398. if !m.op.Is(OpUpdateOne) {
  18399. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18400. }
  18401. if m.id == nil || m.oldValue == nil {
  18402. return v, errors.New("OldStatus requires an ID field in the mutation")
  18403. }
  18404. oldValue, err := m.oldValue(ctx)
  18405. if err != nil {
  18406. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18407. }
  18408. return oldValue.Status, nil
  18409. }
  18410. // AddStatus adds u to the "status" field.
  18411. func (m *MsgMutation) AddStatus(u int8) {
  18412. if m.addstatus != nil {
  18413. *m.addstatus += u
  18414. } else {
  18415. m.addstatus = &u
  18416. }
  18417. }
  18418. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18419. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  18420. v := m.addstatus
  18421. if v == nil {
  18422. return
  18423. }
  18424. return *v, true
  18425. }
  18426. // ClearStatus clears the value of the "status" field.
  18427. func (m *MsgMutation) ClearStatus() {
  18428. m.status = nil
  18429. m.addstatus = nil
  18430. m.clearedFields[msg.FieldStatus] = struct{}{}
  18431. }
  18432. // StatusCleared returns if the "status" field was cleared in this mutation.
  18433. func (m *MsgMutation) StatusCleared() bool {
  18434. _, ok := m.clearedFields[msg.FieldStatus]
  18435. return ok
  18436. }
  18437. // ResetStatus resets all changes to the "status" field.
  18438. func (m *MsgMutation) ResetStatus() {
  18439. m.status = nil
  18440. m.addstatus = nil
  18441. delete(m.clearedFields, msg.FieldStatus)
  18442. }
  18443. // SetFromwxid sets the "fromwxid" field.
  18444. func (m *MsgMutation) SetFromwxid(s string) {
  18445. m.fromwxid = &s
  18446. }
  18447. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  18448. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  18449. v := m.fromwxid
  18450. if v == nil {
  18451. return
  18452. }
  18453. return *v, true
  18454. }
  18455. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  18456. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18458. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  18459. if !m.op.Is(OpUpdateOne) {
  18460. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  18461. }
  18462. if m.id == nil || m.oldValue == nil {
  18463. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  18464. }
  18465. oldValue, err := m.oldValue(ctx)
  18466. if err != nil {
  18467. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  18468. }
  18469. return oldValue.Fromwxid, nil
  18470. }
  18471. // ClearFromwxid clears the value of the "fromwxid" field.
  18472. func (m *MsgMutation) ClearFromwxid() {
  18473. m.fromwxid = nil
  18474. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  18475. }
  18476. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  18477. func (m *MsgMutation) FromwxidCleared() bool {
  18478. _, ok := m.clearedFields[msg.FieldFromwxid]
  18479. return ok
  18480. }
  18481. // ResetFromwxid resets all changes to the "fromwxid" field.
  18482. func (m *MsgMutation) ResetFromwxid() {
  18483. m.fromwxid = nil
  18484. delete(m.clearedFields, msg.FieldFromwxid)
  18485. }
  18486. // SetToid sets the "toid" field.
  18487. func (m *MsgMutation) SetToid(s string) {
  18488. m.toid = &s
  18489. }
  18490. // Toid returns the value of the "toid" field in the mutation.
  18491. func (m *MsgMutation) Toid() (r string, exists bool) {
  18492. v := m.toid
  18493. if v == nil {
  18494. return
  18495. }
  18496. return *v, true
  18497. }
  18498. // OldToid returns the old "toid" field's value of the Msg entity.
  18499. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18501. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  18502. if !m.op.Is(OpUpdateOne) {
  18503. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  18504. }
  18505. if m.id == nil || m.oldValue == nil {
  18506. return v, errors.New("OldToid requires an ID field in the mutation")
  18507. }
  18508. oldValue, err := m.oldValue(ctx)
  18509. if err != nil {
  18510. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  18511. }
  18512. return oldValue.Toid, nil
  18513. }
  18514. // ClearToid clears the value of the "toid" field.
  18515. func (m *MsgMutation) ClearToid() {
  18516. m.toid = nil
  18517. m.clearedFields[msg.FieldToid] = struct{}{}
  18518. }
  18519. // ToidCleared returns if the "toid" field was cleared in this mutation.
  18520. func (m *MsgMutation) ToidCleared() bool {
  18521. _, ok := m.clearedFields[msg.FieldToid]
  18522. return ok
  18523. }
  18524. // ResetToid resets all changes to the "toid" field.
  18525. func (m *MsgMutation) ResetToid() {
  18526. m.toid = nil
  18527. delete(m.clearedFields, msg.FieldToid)
  18528. }
  18529. // SetMsgtype sets the "msgtype" field.
  18530. func (m *MsgMutation) SetMsgtype(i int32) {
  18531. m.msgtype = &i
  18532. m.addmsgtype = nil
  18533. }
  18534. // Msgtype returns the value of the "msgtype" field in the mutation.
  18535. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  18536. v := m.msgtype
  18537. if v == nil {
  18538. return
  18539. }
  18540. return *v, true
  18541. }
  18542. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  18543. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18545. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  18546. if !m.op.Is(OpUpdateOne) {
  18547. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  18548. }
  18549. if m.id == nil || m.oldValue == nil {
  18550. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  18551. }
  18552. oldValue, err := m.oldValue(ctx)
  18553. if err != nil {
  18554. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  18555. }
  18556. return oldValue.Msgtype, nil
  18557. }
  18558. // AddMsgtype adds i to the "msgtype" field.
  18559. func (m *MsgMutation) AddMsgtype(i int32) {
  18560. if m.addmsgtype != nil {
  18561. *m.addmsgtype += i
  18562. } else {
  18563. m.addmsgtype = &i
  18564. }
  18565. }
  18566. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  18567. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  18568. v := m.addmsgtype
  18569. if v == nil {
  18570. return
  18571. }
  18572. return *v, true
  18573. }
  18574. // ClearMsgtype clears the value of the "msgtype" field.
  18575. func (m *MsgMutation) ClearMsgtype() {
  18576. m.msgtype = nil
  18577. m.addmsgtype = nil
  18578. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  18579. }
  18580. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  18581. func (m *MsgMutation) MsgtypeCleared() bool {
  18582. _, ok := m.clearedFields[msg.FieldMsgtype]
  18583. return ok
  18584. }
  18585. // ResetMsgtype resets all changes to the "msgtype" field.
  18586. func (m *MsgMutation) ResetMsgtype() {
  18587. m.msgtype = nil
  18588. m.addmsgtype = nil
  18589. delete(m.clearedFields, msg.FieldMsgtype)
  18590. }
  18591. // SetMsg sets the "msg" field.
  18592. func (m *MsgMutation) SetMsg(s string) {
  18593. m.msg = &s
  18594. }
  18595. // Msg returns the value of the "msg" field in the mutation.
  18596. func (m *MsgMutation) Msg() (r string, exists bool) {
  18597. v := m.msg
  18598. if v == nil {
  18599. return
  18600. }
  18601. return *v, true
  18602. }
  18603. // OldMsg returns the old "msg" field's value of the Msg entity.
  18604. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18606. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  18607. if !m.op.Is(OpUpdateOne) {
  18608. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  18609. }
  18610. if m.id == nil || m.oldValue == nil {
  18611. return v, errors.New("OldMsg requires an ID field in the mutation")
  18612. }
  18613. oldValue, err := m.oldValue(ctx)
  18614. if err != nil {
  18615. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  18616. }
  18617. return oldValue.Msg, nil
  18618. }
  18619. // ClearMsg clears the value of the "msg" field.
  18620. func (m *MsgMutation) ClearMsg() {
  18621. m.msg = nil
  18622. m.clearedFields[msg.FieldMsg] = struct{}{}
  18623. }
  18624. // MsgCleared returns if the "msg" field was cleared in this mutation.
  18625. func (m *MsgMutation) MsgCleared() bool {
  18626. _, ok := m.clearedFields[msg.FieldMsg]
  18627. return ok
  18628. }
  18629. // ResetMsg resets all changes to the "msg" field.
  18630. func (m *MsgMutation) ResetMsg() {
  18631. m.msg = nil
  18632. delete(m.clearedFields, msg.FieldMsg)
  18633. }
  18634. // SetBatchNo sets the "batch_no" field.
  18635. func (m *MsgMutation) SetBatchNo(s string) {
  18636. m.batch_no = &s
  18637. }
  18638. // BatchNo returns the value of the "batch_no" field in the mutation.
  18639. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  18640. v := m.batch_no
  18641. if v == nil {
  18642. return
  18643. }
  18644. return *v, true
  18645. }
  18646. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  18647. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18649. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  18650. if !m.op.Is(OpUpdateOne) {
  18651. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  18652. }
  18653. if m.id == nil || m.oldValue == nil {
  18654. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  18655. }
  18656. oldValue, err := m.oldValue(ctx)
  18657. if err != nil {
  18658. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  18659. }
  18660. return oldValue.BatchNo, nil
  18661. }
  18662. // ClearBatchNo clears the value of the "batch_no" field.
  18663. func (m *MsgMutation) ClearBatchNo() {
  18664. m.batch_no = nil
  18665. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  18666. }
  18667. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  18668. func (m *MsgMutation) BatchNoCleared() bool {
  18669. _, ok := m.clearedFields[msg.FieldBatchNo]
  18670. return ok
  18671. }
  18672. // ResetBatchNo resets all changes to the "batch_no" field.
  18673. func (m *MsgMutation) ResetBatchNo() {
  18674. m.batch_no = nil
  18675. delete(m.clearedFields, msg.FieldBatchNo)
  18676. }
  18677. // Where appends a list predicates to the MsgMutation builder.
  18678. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  18679. m.predicates = append(m.predicates, ps...)
  18680. }
  18681. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  18682. // users can use type-assertion to append predicates that do not depend on any generated package.
  18683. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  18684. p := make([]predicate.Msg, len(ps))
  18685. for i := range ps {
  18686. p[i] = ps[i]
  18687. }
  18688. m.Where(p...)
  18689. }
  18690. // Op returns the operation name.
  18691. func (m *MsgMutation) Op() Op {
  18692. return m.op
  18693. }
  18694. // SetOp allows setting the mutation operation.
  18695. func (m *MsgMutation) SetOp(op Op) {
  18696. m.op = op
  18697. }
  18698. // Type returns the node type of this mutation (Msg).
  18699. func (m *MsgMutation) Type() string {
  18700. return m.typ
  18701. }
  18702. // Fields returns all fields that were changed during this mutation. Note that in
  18703. // order to get all numeric fields that were incremented/decremented, call
  18704. // AddedFields().
  18705. func (m *MsgMutation) Fields() []string {
  18706. fields := make([]string, 0, 9)
  18707. if m.created_at != nil {
  18708. fields = append(fields, msg.FieldCreatedAt)
  18709. }
  18710. if m.updated_at != nil {
  18711. fields = append(fields, msg.FieldUpdatedAt)
  18712. }
  18713. if m.deleted_at != nil {
  18714. fields = append(fields, msg.FieldDeletedAt)
  18715. }
  18716. if m.status != nil {
  18717. fields = append(fields, msg.FieldStatus)
  18718. }
  18719. if m.fromwxid != nil {
  18720. fields = append(fields, msg.FieldFromwxid)
  18721. }
  18722. if m.toid != nil {
  18723. fields = append(fields, msg.FieldToid)
  18724. }
  18725. if m.msgtype != nil {
  18726. fields = append(fields, msg.FieldMsgtype)
  18727. }
  18728. if m.msg != nil {
  18729. fields = append(fields, msg.FieldMsg)
  18730. }
  18731. if m.batch_no != nil {
  18732. fields = append(fields, msg.FieldBatchNo)
  18733. }
  18734. return fields
  18735. }
  18736. // Field returns the value of a field with the given name. The second boolean
  18737. // return value indicates that this field was not set, or was not defined in the
  18738. // schema.
  18739. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  18740. switch name {
  18741. case msg.FieldCreatedAt:
  18742. return m.CreatedAt()
  18743. case msg.FieldUpdatedAt:
  18744. return m.UpdatedAt()
  18745. case msg.FieldDeletedAt:
  18746. return m.DeletedAt()
  18747. case msg.FieldStatus:
  18748. return m.Status()
  18749. case msg.FieldFromwxid:
  18750. return m.Fromwxid()
  18751. case msg.FieldToid:
  18752. return m.Toid()
  18753. case msg.FieldMsgtype:
  18754. return m.Msgtype()
  18755. case msg.FieldMsg:
  18756. return m.Msg()
  18757. case msg.FieldBatchNo:
  18758. return m.BatchNo()
  18759. }
  18760. return nil, false
  18761. }
  18762. // OldField returns the old value of the field from the database. An error is
  18763. // returned if the mutation operation is not UpdateOne, or the query to the
  18764. // database failed.
  18765. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18766. switch name {
  18767. case msg.FieldCreatedAt:
  18768. return m.OldCreatedAt(ctx)
  18769. case msg.FieldUpdatedAt:
  18770. return m.OldUpdatedAt(ctx)
  18771. case msg.FieldDeletedAt:
  18772. return m.OldDeletedAt(ctx)
  18773. case msg.FieldStatus:
  18774. return m.OldStatus(ctx)
  18775. case msg.FieldFromwxid:
  18776. return m.OldFromwxid(ctx)
  18777. case msg.FieldToid:
  18778. return m.OldToid(ctx)
  18779. case msg.FieldMsgtype:
  18780. return m.OldMsgtype(ctx)
  18781. case msg.FieldMsg:
  18782. return m.OldMsg(ctx)
  18783. case msg.FieldBatchNo:
  18784. return m.OldBatchNo(ctx)
  18785. }
  18786. return nil, fmt.Errorf("unknown Msg field %s", name)
  18787. }
  18788. // SetField sets the value of a field with the given name. It returns an error if
  18789. // the field is not defined in the schema, or if the type mismatched the field
  18790. // type.
  18791. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  18792. switch name {
  18793. case msg.FieldCreatedAt:
  18794. v, ok := value.(time.Time)
  18795. if !ok {
  18796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18797. }
  18798. m.SetCreatedAt(v)
  18799. return nil
  18800. case msg.FieldUpdatedAt:
  18801. v, ok := value.(time.Time)
  18802. if !ok {
  18803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18804. }
  18805. m.SetUpdatedAt(v)
  18806. return nil
  18807. case msg.FieldDeletedAt:
  18808. v, ok := value.(time.Time)
  18809. if !ok {
  18810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18811. }
  18812. m.SetDeletedAt(v)
  18813. return nil
  18814. case msg.FieldStatus:
  18815. v, ok := value.(uint8)
  18816. if !ok {
  18817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18818. }
  18819. m.SetStatus(v)
  18820. return nil
  18821. case msg.FieldFromwxid:
  18822. v, ok := value.(string)
  18823. if !ok {
  18824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18825. }
  18826. m.SetFromwxid(v)
  18827. return nil
  18828. case msg.FieldToid:
  18829. v, ok := value.(string)
  18830. if !ok {
  18831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18832. }
  18833. m.SetToid(v)
  18834. return nil
  18835. case msg.FieldMsgtype:
  18836. v, ok := value.(int32)
  18837. if !ok {
  18838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18839. }
  18840. m.SetMsgtype(v)
  18841. return nil
  18842. case msg.FieldMsg:
  18843. v, ok := value.(string)
  18844. if !ok {
  18845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18846. }
  18847. m.SetMsg(v)
  18848. return nil
  18849. case msg.FieldBatchNo:
  18850. v, ok := value.(string)
  18851. if !ok {
  18852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18853. }
  18854. m.SetBatchNo(v)
  18855. return nil
  18856. }
  18857. return fmt.Errorf("unknown Msg field %s", name)
  18858. }
  18859. // AddedFields returns all numeric fields that were incremented/decremented during
  18860. // this mutation.
  18861. func (m *MsgMutation) AddedFields() []string {
  18862. var fields []string
  18863. if m.addstatus != nil {
  18864. fields = append(fields, msg.FieldStatus)
  18865. }
  18866. if m.addmsgtype != nil {
  18867. fields = append(fields, msg.FieldMsgtype)
  18868. }
  18869. return fields
  18870. }
  18871. // AddedField returns the numeric value that was incremented/decremented on a field
  18872. // with the given name. The second boolean return value indicates that this field
  18873. // was not set, or was not defined in the schema.
  18874. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  18875. switch name {
  18876. case msg.FieldStatus:
  18877. return m.AddedStatus()
  18878. case msg.FieldMsgtype:
  18879. return m.AddedMsgtype()
  18880. }
  18881. return nil, false
  18882. }
  18883. // AddField adds the value to the field with the given name. It returns an error if
  18884. // the field is not defined in the schema, or if the type mismatched the field
  18885. // type.
  18886. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  18887. switch name {
  18888. case msg.FieldStatus:
  18889. v, ok := value.(int8)
  18890. if !ok {
  18891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18892. }
  18893. m.AddStatus(v)
  18894. return nil
  18895. case msg.FieldMsgtype:
  18896. v, ok := value.(int32)
  18897. if !ok {
  18898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18899. }
  18900. m.AddMsgtype(v)
  18901. return nil
  18902. }
  18903. return fmt.Errorf("unknown Msg numeric field %s", name)
  18904. }
  18905. // ClearedFields returns all nullable fields that were cleared during this
  18906. // mutation.
  18907. func (m *MsgMutation) ClearedFields() []string {
  18908. var fields []string
  18909. if m.FieldCleared(msg.FieldDeletedAt) {
  18910. fields = append(fields, msg.FieldDeletedAt)
  18911. }
  18912. if m.FieldCleared(msg.FieldStatus) {
  18913. fields = append(fields, msg.FieldStatus)
  18914. }
  18915. if m.FieldCleared(msg.FieldFromwxid) {
  18916. fields = append(fields, msg.FieldFromwxid)
  18917. }
  18918. if m.FieldCleared(msg.FieldToid) {
  18919. fields = append(fields, msg.FieldToid)
  18920. }
  18921. if m.FieldCleared(msg.FieldMsgtype) {
  18922. fields = append(fields, msg.FieldMsgtype)
  18923. }
  18924. if m.FieldCleared(msg.FieldMsg) {
  18925. fields = append(fields, msg.FieldMsg)
  18926. }
  18927. if m.FieldCleared(msg.FieldBatchNo) {
  18928. fields = append(fields, msg.FieldBatchNo)
  18929. }
  18930. return fields
  18931. }
  18932. // FieldCleared returns a boolean indicating if a field with the given name was
  18933. // cleared in this mutation.
  18934. func (m *MsgMutation) FieldCleared(name string) bool {
  18935. _, ok := m.clearedFields[name]
  18936. return ok
  18937. }
  18938. // ClearField clears the value of the field with the given name. It returns an
  18939. // error if the field is not defined in the schema.
  18940. func (m *MsgMutation) ClearField(name string) error {
  18941. switch name {
  18942. case msg.FieldDeletedAt:
  18943. m.ClearDeletedAt()
  18944. return nil
  18945. case msg.FieldStatus:
  18946. m.ClearStatus()
  18947. return nil
  18948. case msg.FieldFromwxid:
  18949. m.ClearFromwxid()
  18950. return nil
  18951. case msg.FieldToid:
  18952. m.ClearToid()
  18953. return nil
  18954. case msg.FieldMsgtype:
  18955. m.ClearMsgtype()
  18956. return nil
  18957. case msg.FieldMsg:
  18958. m.ClearMsg()
  18959. return nil
  18960. case msg.FieldBatchNo:
  18961. m.ClearBatchNo()
  18962. return nil
  18963. }
  18964. return fmt.Errorf("unknown Msg nullable field %s", name)
  18965. }
  18966. // ResetField resets all changes in the mutation for the field with the given name.
  18967. // It returns an error if the field is not defined in the schema.
  18968. func (m *MsgMutation) ResetField(name string) error {
  18969. switch name {
  18970. case msg.FieldCreatedAt:
  18971. m.ResetCreatedAt()
  18972. return nil
  18973. case msg.FieldUpdatedAt:
  18974. m.ResetUpdatedAt()
  18975. return nil
  18976. case msg.FieldDeletedAt:
  18977. m.ResetDeletedAt()
  18978. return nil
  18979. case msg.FieldStatus:
  18980. m.ResetStatus()
  18981. return nil
  18982. case msg.FieldFromwxid:
  18983. m.ResetFromwxid()
  18984. return nil
  18985. case msg.FieldToid:
  18986. m.ResetToid()
  18987. return nil
  18988. case msg.FieldMsgtype:
  18989. m.ResetMsgtype()
  18990. return nil
  18991. case msg.FieldMsg:
  18992. m.ResetMsg()
  18993. return nil
  18994. case msg.FieldBatchNo:
  18995. m.ResetBatchNo()
  18996. return nil
  18997. }
  18998. return fmt.Errorf("unknown Msg field %s", name)
  18999. }
  19000. // AddedEdges returns all edge names that were set/added in this mutation.
  19001. func (m *MsgMutation) AddedEdges() []string {
  19002. edges := make([]string, 0, 0)
  19003. return edges
  19004. }
  19005. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19006. // name in this mutation.
  19007. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  19008. return nil
  19009. }
  19010. // RemovedEdges returns all edge names that were removed in this mutation.
  19011. func (m *MsgMutation) RemovedEdges() []string {
  19012. edges := make([]string, 0, 0)
  19013. return edges
  19014. }
  19015. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19016. // the given name in this mutation.
  19017. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  19018. return nil
  19019. }
  19020. // ClearedEdges returns all edge names that were cleared in this mutation.
  19021. func (m *MsgMutation) ClearedEdges() []string {
  19022. edges := make([]string, 0, 0)
  19023. return edges
  19024. }
  19025. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19026. // was cleared in this mutation.
  19027. func (m *MsgMutation) EdgeCleared(name string) bool {
  19028. return false
  19029. }
  19030. // ClearEdge clears the value of the edge with the given name. It returns an error
  19031. // if that edge is not defined in the schema.
  19032. func (m *MsgMutation) ClearEdge(name string) error {
  19033. return fmt.Errorf("unknown Msg unique edge %s", name)
  19034. }
  19035. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19036. // It returns an error if the edge is not defined in the schema.
  19037. func (m *MsgMutation) ResetEdge(name string) error {
  19038. return fmt.Errorf("unknown Msg edge %s", name)
  19039. }
  19040. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  19041. type PayRechargeMutation struct {
  19042. config
  19043. op Op
  19044. typ string
  19045. id *uint64
  19046. created_at *time.Time
  19047. updated_at *time.Time
  19048. deleted_at *time.Time
  19049. user_id *string
  19050. number *float32
  19051. addnumber *float32
  19052. status *int
  19053. addstatus *int
  19054. money *float32
  19055. addmoney *float32
  19056. out_trade_no *string
  19057. organization_id *uint64
  19058. addorganization_id *int64
  19059. clearedFields map[string]struct{}
  19060. done bool
  19061. oldValue func(context.Context) (*PayRecharge, error)
  19062. predicates []predicate.PayRecharge
  19063. }
  19064. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  19065. // payrechargeOption allows management of the mutation configuration using functional options.
  19066. type payrechargeOption func(*PayRechargeMutation)
  19067. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  19068. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  19069. m := &PayRechargeMutation{
  19070. config: c,
  19071. op: op,
  19072. typ: TypePayRecharge,
  19073. clearedFields: make(map[string]struct{}),
  19074. }
  19075. for _, opt := range opts {
  19076. opt(m)
  19077. }
  19078. return m
  19079. }
  19080. // withPayRechargeID sets the ID field of the mutation.
  19081. func withPayRechargeID(id uint64) payrechargeOption {
  19082. return func(m *PayRechargeMutation) {
  19083. var (
  19084. err error
  19085. once sync.Once
  19086. value *PayRecharge
  19087. )
  19088. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  19089. once.Do(func() {
  19090. if m.done {
  19091. err = errors.New("querying old values post mutation is not allowed")
  19092. } else {
  19093. value, err = m.Client().PayRecharge.Get(ctx, id)
  19094. }
  19095. })
  19096. return value, err
  19097. }
  19098. m.id = &id
  19099. }
  19100. }
  19101. // withPayRecharge sets the old PayRecharge of the mutation.
  19102. func withPayRecharge(node *PayRecharge) payrechargeOption {
  19103. return func(m *PayRechargeMutation) {
  19104. m.oldValue = func(context.Context) (*PayRecharge, error) {
  19105. return node, nil
  19106. }
  19107. m.id = &node.ID
  19108. }
  19109. }
  19110. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19111. // executed in a transaction (ent.Tx), a transactional client is returned.
  19112. func (m PayRechargeMutation) Client() *Client {
  19113. client := &Client{config: m.config}
  19114. client.init()
  19115. return client
  19116. }
  19117. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19118. // it returns an error otherwise.
  19119. func (m PayRechargeMutation) Tx() (*Tx, error) {
  19120. if _, ok := m.driver.(*txDriver); !ok {
  19121. return nil, errors.New("ent: mutation is not running in a transaction")
  19122. }
  19123. tx := &Tx{config: m.config}
  19124. tx.init()
  19125. return tx, nil
  19126. }
  19127. // SetID sets the value of the id field. Note that this
  19128. // operation is only accepted on creation of PayRecharge entities.
  19129. func (m *PayRechargeMutation) SetID(id uint64) {
  19130. m.id = &id
  19131. }
  19132. // ID returns the ID value in the mutation. Note that the ID is only available
  19133. // if it was provided to the builder or after it was returned from the database.
  19134. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  19135. if m.id == nil {
  19136. return
  19137. }
  19138. return *m.id, true
  19139. }
  19140. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19141. // That means, if the mutation is applied within a transaction with an isolation level such
  19142. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19143. // or updated by the mutation.
  19144. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  19145. switch {
  19146. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19147. id, exists := m.ID()
  19148. if exists {
  19149. return []uint64{id}, nil
  19150. }
  19151. fallthrough
  19152. case m.op.Is(OpUpdate | OpDelete):
  19153. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  19154. default:
  19155. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19156. }
  19157. }
  19158. // SetCreatedAt sets the "created_at" field.
  19159. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  19160. m.created_at = &t
  19161. }
  19162. // CreatedAt returns the value of the "created_at" field in the mutation.
  19163. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  19164. v := m.created_at
  19165. if v == nil {
  19166. return
  19167. }
  19168. return *v, true
  19169. }
  19170. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  19171. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19173. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19174. if !m.op.Is(OpUpdateOne) {
  19175. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19176. }
  19177. if m.id == nil || m.oldValue == nil {
  19178. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19179. }
  19180. oldValue, err := m.oldValue(ctx)
  19181. if err != nil {
  19182. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19183. }
  19184. return oldValue.CreatedAt, nil
  19185. }
  19186. // ResetCreatedAt resets all changes to the "created_at" field.
  19187. func (m *PayRechargeMutation) ResetCreatedAt() {
  19188. m.created_at = nil
  19189. }
  19190. // SetUpdatedAt sets the "updated_at" field.
  19191. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  19192. m.updated_at = &t
  19193. }
  19194. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19195. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  19196. v := m.updated_at
  19197. if v == nil {
  19198. return
  19199. }
  19200. return *v, true
  19201. }
  19202. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  19203. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19205. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19206. if !m.op.Is(OpUpdateOne) {
  19207. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19208. }
  19209. if m.id == nil || m.oldValue == nil {
  19210. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19211. }
  19212. oldValue, err := m.oldValue(ctx)
  19213. if err != nil {
  19214. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19215. }
  19216. return oldValue.UpdatedAt, nil
  19217. }
  19218. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19219. func (m *PayRechargeMutation) ResetUpdatedAt() {
  19220. m.updated_at = nil
  19221. }
  19222. // SetDeletedAt sets the "deleted_at" field.
  19223. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  19224. m.deleted_at = &t
  19225. }
  19226. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19227. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  19228. v := m.deleted_at
  19229. if v == nil {
  19230. return
  19231. }
  19232. return *v, true
  19233. }
  19234. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  19235. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19237. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19238. if !m.op.Is(OpUpdateOne) {
  19239. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19240. }
  19241. if m.id == nil || m.oldValue == nil {
  19242. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19243. }
  19244. oldValue, err := m.oldValue(ctx)
  19245. if err != nil {
  19246. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19247. }
  19248. return oldValue.DeletedAt, nil
  19249. }
  19250. // ClearDeletedAt clears the value of the "deleted_at" field.
  19251. func (m *PayRechargeMutation) ClearDeletedAt() {
  19252. m.deleted_at = nil
  19253. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  19254. }
  19255. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19256. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  19257. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  19258. return ok
  19259. }
  19260. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19261. func (m *PayRechargeMutation) ResetDeletedAt() {
  19262. m.deleted_at = nil
  19263. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  19264. }
  19265. // SetUserID sets the "user_id" field.
  19266. func (m *PayRechargeMutation) SetUserID(s string) {
  19267. m.user_id = &s
  19268. }
  19269. // UserID returns the value of the "user_id" field in the mutation.
  19270. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  19271. v := m.user_id
  19272. if v == nil {
  19273. return
  19274. }
  19275. return *v, true
  19276. }
  19277. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  19278. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19280. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  19281. if !m.op.Is(OpUpdateOne) {
  19282. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  19283. }
  19284. if m.id == nil || m.oldValue == nil {
  19285. return v, errors.New("OldUserID requires an ID field in the mutation")
  19286. }
  19287. oldValue, err := m.oldValue(ctx)
  19288. if err != nil {
  19289. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  19290. }
  19291. return oldValue.UserID, nil
  19292. }
  19293. // ResetUserID resets all changes to the "user_id" field.
  19294. func (m *PayRechargeMutation) ResetUserID() {
  19295. m.user_id = nil
  19296. }
  19297. // SetNumber sets the "number" field.
  19298. func (m *PayRechargeMutation) SetNumber(f float32) {
  19299. m.number = &f
  19300. m.addnumber = nil
  19301. }
  19302. // Number returns the value of the "number" field in the mutation.
  19303. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  19304. v := m.number
  19305. if v == nil {
  19306. return
  19307. }
  19308. return *v, true
  19309. }
  19310. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  19311. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19313. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  19314. if !m.op.Is(OpUpdateOne) {
  19315. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  19316. }
  19317. if m.id == nil || m.oldValue == nil {
  19318. return v, errors.New("OldNumber requires an ID field in the mutation")
  19319. }
  19320. oldValue, err := m.oldValue(ctx)
  19321. if err != nil {
  19322. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  19323. }
  19324. return oldValue.Number, nil
  19325. }
  19326. // AddNumber adds f to the "number" field.
  19327. func (m *PayRechargeMutation) AddNumber(f float32) {
  19328. if m.addnumber != nil {
  19329. *m.addnumber += f
  19330. } else {
  19331. m.addnumber = &f
  19332. }
  19333. }
  19334. // AddedNumber returns the value that was added to the "number" field in this mutation.
  19335. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  19336. v := m.addnumber
  19337. if v == nil {
  19338. return
  19339. }
  19340. return *v, true
  19341. }
  19342. // ResetNumber resets all changes to the "number" field.
  19343. func (m *PayRechargeMutation) ResetNumber() {
  19344. m.number = nil
  19345. m.addnumber = nil
  19346. }
  19347. // SetStatus sets the "status" field.
  19348. func (m *PayRechargeMutation) SetStatus(i int) {
  19349. m.status = &i
  19350. m.addstatus = nil
  19351. }
  19352. // Status returns the value of the "status" field in the mutation.
  19353. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  19354. v := m.status
  19355. if v == nil {
  19356. return
  19357. }
  19358. return *v, true
  19359. }
  19360. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  19361. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19363. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  19364. if !m.op.Is(OpUpdateOne) {
  19365. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19366. }
  19367. if m.id == nil || m.oldValue == nil {
  19368. return v, errors.New("OldStatus requires an ID field in the mutation")
  19369. }
  19370. oldValue, err := m.oldValue(ctx)
  19371. if err != nil {
  19372. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19373. }
  19374. return oldValue.Status, nil
  19375. }
  19376. // AddStatus adds i to the "status" field.
  19377. func (m *PayRechargeMutation) AddStatus(i int) {
  19378. if m.addstatus != nil {
  19379. *m.addstatus += i
  19380. } else {
  19381. m.addstatus = &i
  19382. }
  19383. }
  19384. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19385. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  19386. v := m.addstatus
  19387. if v == nil {
  19388. return
  19389. }
  19390. return *v, true
  19391. }
  19392. // ClearStatus clears the value of the "status" field.
  19393. func (m *PayRechargeMutation) ClearStatus() {
  19394. m.status = nil
  19395. m.addstatus = nil
  19396. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  19397. }
  19398. // StatusCleared returns if the "status" field was cleared in this mutation.
  19399. func (m *PayRechargeMutation) StatusCleared() bool {
  19400. _, ok := m.clearedFields[payrecharge.FieldStatus]
  19401. return ok
  19402. }
  19403. // ResetStatus resets all changes to the "status" field.
  19404. func (m *PayRechargeMutation) ResetStatus() {
  19405. m.status = nil
  19406. m.addstatus = nil
  19407. delete(m.clearedFields, payrecharge.FieldStatus)
  19408. }
  19409. // SetMoney sets the "money" field.
  19410. func (m *PayRechargeMutation) SetMoney(f float32) {
  19411. m.money = &f
  19412. m.addmoney = nil
  19413. }
  19414. // Money returns the value of the "money" field in the mutation.
  19415. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  19416. v := m.money
  19417. if v == nil {
  19418. return
  19419. }
  19420. return *v, true
  19421. }
  19422. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  19423. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19425. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  19426. if !m.op.Is(OpUpdateOne) {
  19427. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  19428. }
  19429. if m.id == nil || m.oldValue == nil {
  19430. return v, errors.New("OldMoney requires an ID field in the mutation")
  19431. }
  19432. oldValue, err := m.oldValue(ctx)
  19433. if err != nil {
  19434. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  19435. }
  19436. return oldValue.Money, nil
  19437. }
  19438. // AddMoney adds f to the "money" field.
  19439. func (m *PayRechargeMutation) AddMoney(f float32) {
  19440. if m.addmoney != nil {
  19441. *m.addmoney += f
  19442. } else {
  19443. m.addmoney = &f
  19444. }
  19445. }
  19446. // AddedMoney returns the value that was added to the "money" field in this mutation.
  19447. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  19448. v := m.addmoney
  19449. if v == nil {
  19450. return
  19451. }
  19452. return *v, true
  19453. }
  19454. // ClearMoney clears the value of the "money" field.
  19455. func (m *PayRechargeMutation) ClearMoney() {
  19456. m.money = nil
  19457. m.addmoney = nil
  19458. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  19459. }
  19460. // MoneyCleared returns if the "money" field was cleared in this mutation.
  19461. func (m *PayRechargeMutation) MoneyCleared() bool {
  19462. _, ok := m.clearedFields[payrecharge.FieldMoney]
  19463. return ok
  19464. }
  19465. // ResetMoney resets all changes to the "money" field.
  19466. func (m *PayRechargeMutation) ResetMoney() {
  19467. m.money = nil
  19468. m.addmoney = nil
  19469. delete(m.clearedFields, payrecharge.FieldMoney)
  19470. }
  19471. // SetOutTradeNo sets the "out_trade_no" field.
  19472. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  19473. m.out_trade_no = &s
  19474. }
  19475. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  19476. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  19477. v := m.out_trade_no
  19478. if v == nil {
  19479. return
  19480. }
  19481. return *v, true
  19482. }
  19483. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  19484. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19486. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  19487. if !m.op.Is(OpUpdateOne) {
  19488. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  19489. }
  19490. if m.id == nil || m.oldValue == nil {
  19491. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  19492. }
  19493. oldValue, err := m.oldValue(ctx)
  19494. if err != nil {
  19495. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  19496. }
  19497. return oldValue.OutTradeNo, nil
  19498. }
  19499. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  19500. func (m *PayRechargeMutation) ClearOutTradeNo() {
  19501. m.out_trade_no = nil
  19502. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  19503. }
  19504. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  19505. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  19506. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  19507. return ok
  19508. }
  19509. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  19510. func (m *PayRechargeMutation) ResetOutTradeNo() {
  19511. m.out_trade_no = nil
  19512. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  19513. }
  19514. // SetOrganizationID sets the "organization_id" field.
  19515. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  19516. m.organization_id = &u
  19517. m.addorganization_id = nil
  19518. }
  19519. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19520. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  19521. v := m.organization_id
  19522. if v == nil {
  19523. return
  19524. }
  19525. return *v, true
  19526. }
  19527. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  19528. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19530. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19531. if !m.op.Is(OpUpdateOne) {
  19532. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19533. }
  19534. if m.id == nil || m.oldValue == nil {
  19535. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19536. }
  19537. oldValue, err := m.oldValue(ctx)
  19538. if err != nil {
  19539. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19540. }
  19541. return oldValue.OrganizationID, nil
  19542. }
  19543. // AddOrganizationID adds u to the "organization_id" field.
  19544. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  19545. if m.addorganization_id != nil {
  19546. *m.addorganization_id += u
  19547. } else {
  19548. m.addorganization_id = &u
  19549. }
  19550. }
  19551. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19552. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  19553. v := m.addorganization_id
  19554. if v == nil {
  19555. return
  19556. }
  19557. return *v, true
  19558. }
  19559. // ResetOrganizationID resets all changes to the "organization_id" field.
  19560. func (m *PayRechargeMutation) ResetOrganizationID() {
  19561. m.organization_id = nil
  19562. m.addorganization_id = nil
  19563. }
  19564. // Where appends a list predicates to the PayRechargeMutation builder.
  19565. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  19566. m.predicates = append(m.predicates, ps...)
  19567. }
  19568. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  19569. // users can use type-assertion to append predicates that do not depend on any generated package.
  19570. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  19571. p := make([]predicate.PayRecharge, len(ps))
  19572. for i := range ps {
  19573. p[i] = ps[i]
  19574. }
  19575. m.Where(p...)
  19576. }
  19577. // Op returns the operation name.
  19578. func (m *PayRechargeMutation) Op() Op {
  19579. return m.op
  19580. }
  19581. // SetOp allows setting the mutation operation.
  19582. func (m *PayRechargeMutation) SetOp(op Op) {
  19583. m.op = op
  19584. }
  19585. // Type returns the node type of this mutation (PayRecharge).
  19586. func (m *PayRechargeMutation) Type() string {
  19587. return m.typ
  19588. }
  19589. // Fields returns all fields that were changed during this mutation. Note that in
  19590. // order to get all numeric fields that were incremented/decremented, call
  19591. // AddedFields().
  19592. func (m *PayRechargeMutation) Fields() []string {
  19593. fields := make([]string, 0, 9)
  19594. if m.created_at != nil {
  19595. fields = append(fields, payrecharge.FieldCreatedAt)
  19596. }
  19597. if m.updated_at != nil {
  19598. fields = append(fields, payrecharge.FieldUpdatedAt)
  19599. }
  19600. if m.deleted_at != nil {
  19601. fields = append(fields, payrecharge.FieldDeletedAt)
  19602. }
  19603. if m.user_id != nil {
  19604. fields = append(fields, payrecharge.FieldUserID)
  19605. }
  19606. if m.number != nil {
  19607. fields = append(fields, payrecharge.FieldNumber)
  19608. }
  19609. if m.status != nil {
  19610. fields = append(fields, payrecharge.FieldStatus)
  19611. }
  19612. if m.money != nil {
  19613. fields = append(fields, payrecharge.FieldMoney)
  19614. }
  19615. if m.out_trade_no != nil {
  19616. fields = append(fields, payrecharge.FieldOutTradeNo)
  19617. }
  19618. if m.organization_id != nil {
  19619. fields = append(fields, payrecharge.FieldOrganizationID)
  19620. }
  19621. return fields
  19622. }
  19623. // Field returns the value of a field with the given name. The second boolean
  19624. // return value indicates that this field was not set, or was not defined in the
  19625. // schema.
  19626. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  19627. switch name {
  19628. case payrecharge.FieldCreatedAt:
  19629. return m.CreatedAt()
  19630. case payrecharge.FieldUpdatedAt:
  19631. return m.UpdatedAt()
  19632. case payrecharge.FieldDeletedAt:
  19633. return m.DeletedAt()
  19634. case payrecharge.FieldUserID:
  19635. return m.UserID()
  19636. case payrecharge.FieldNumber:
  19637. return m.Number()
  19638. case payrecharge.FieldStatus:
  19639. return m.Status()
  19640. case payrecharge.FieldMoney:
  19641. return m.Money()
  19642. case payrecharge.FieldOutTradeNo:
  19643. return m.OutTradeNo()
  19644. case payrecharge.FieldOrganizationID:
  19645. return m.OrganizationID()
  19646. }
  19647. return nil, false
  19648. }
  19649. // OldField returns the old value of the field from the database. An error is
  19650. // returned if the mutation operation is not UpdateOne, or the query to the
  19651. // database failed.
  19652. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19653. switch name {
  19654. case payrecharge.FieldCreatedAt:
  19655. return m.OldCreatedAt(ctx)
  19656. case payrecharge.FieldUpdatedAt:
  19657. return m.OldUpdatedAt(ctx)
  19658. case payrecharge.FieldDeletedAt:
  19659. return m.OldDeletedAt(ctx)
  19660. case payrecharge.FieldUserID:
  19661. return m.OldUserID(ctx)
  19662. case payrecharge.FieldNumber:
  19663. return m.OldNumber(ctx)
  19664. case payrecharge.FieldStatus:
  19665. return m.OldStatus(ctx)
  19666. case payrecharge.FieldMoney:
  19667. return m.OldMoney(ctx)
  19668. case payrecharge.FieldOutTradeNo:
  19669. return m.OldOutTradeNo(ctx)
  19670. case payrecharge.FieldOrganizationID:
  19671. return m.OldOrganizationID(ctx)
  19672. }
  19673. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  19674. }
  19675. // SetField sets the value of a field with the given name. It returns an error if
  19676. // the field is not defined in the schema, or if the type mismatched the field
  19677. // type.
  19678. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  19679. switch name {
  19680. case payrecharge.FieldCreatedAt:
  19681. v, ok := value.(time.Time)
  19682. if !ok {
  19683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19684. }
  19685. m.SetCreatedAt(v)
  19686. return nil
  19687. case payrecharge.FieldUpdatedAt:
  19688. v, ok := value.(time.Time)
  19689. if !ok {
  19690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19691. }
  19692. m.SetUpdatedAt(v)
  19693. return nil
  19694. case payrecharge.FieldDeletedAt:
  19695. v, ok := value.(time.Time)
  19696. if !ok {
  19697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19698. }
  19699. m.SetDeletedAt(v)
  19700. return nil
  19701. case payrecharge.FieldUserID:
  19702. v, ok := value.(string)
  19703. if !ok {
  19704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19705. }
  19706. m.SetUserID(v)
  19707. return nil
  19708. case payrecharge.FieldNumber:
  19709. v, ok := value.(float32)
  19710. if !ok {
  19711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19712. }
  19713. m.SetNumber(v)
  19714. return nil
  19715. case payrecharge.FieldStatus:
  19716. v, ok := value.(int)
  19717. if !ok {
  19718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19719. }
  19720. m.SetStatus(v)
  19721. return nil
  19722. case payrecharge.FieldMoney:
  19723. v, ok := value.(float32)
  19724. if !ok {
  19725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19726. }
  19727. m.SetMoney(v)
  19728. return nil
  19729. case payrecharge.FieldOutTradeNo:
  19730. v, ok := value.(string)
  19731. if !ok {
  19732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19733. }
  19734. m.SetOutTradeNo(v)
  19735. return nil
  19736. case payrecharge.FieldOrganizationID:
  19737. v, ok := value.(uint64)
  19738. if !ok {
  19739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19740. }
  19741. m.SetOrganizationID(v)
  19742. return nil
  19743. }
  19744. return fmt.Errorf("unknown PayRecharge field %s", name)
  19745. }
  19746. // AddedFields returns all numeric fields that were incremented/decremented during
  19747. // this mutation.
  19748. func (m *PayRechargeMutation) AddedFields() []string {
  19749. var fields []string
  19750. if m.addnumber != nil {
  19751. fields = append(fields, payrecharge.FieldNumber)
  19752. }
  19753. if m.addstatus != nil {
  19754. fields = append(fields, payrecharge.FieldStatus)
  19755. }
  19756. if m.addmoney != nil {
  19757. fields = append(fields, payrecharge.FieldMoney)
  19758. }
  19759. if m.addorganization_id != nil {
  19760. fields = append(fields, payrecharge.FieldOrganizationID)
  19761. }
  19762. return fields
  19763. }
  19764. // AddedField returns the numeric value that was incremented/decremented on a field
  19765. // with the given name. The second boolean return value indicates that this field
  19766. // was not set, or was not defined in the schema.
  19767. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  19768. switch name {
  19769. case payrecharge.FieldNumber:
  19770. return m.AddedNumber()
  19771. case payrecharge.FieldStatus:
  19772. return m.AddedStatus()
  19773. case payrecharge.FieldMoney:
  19774. return m.AddedMoney()
  19775. case payrecharge.FieldOrganizationID:
  19776. return m.AddedOrganizationID()
  19777. }
  19778. return nil, false
  19779. }
  19780. // AddField adds the value to the field with the given name. It returns an error if
  19781. // the field is not defined in the schema, or if the type mismatched the field
  19782. // type.
  19783. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  19784. switch name {
  19785. case payrecharge.FieldNumber:
  19786. v, ok := value.(float32)
  19787. if !ok {
  19788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19789. }
  19790. m.AddNumber(v)
  19791. return nil
  19792. case payrecharge.FieldStatus:
  19793. v, ok := value.(int)
  19794. if !ok {
  19795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19796. }
  19797. m.AddStatus(v)
  19798. return nil
  19799. case payrecharge.FieldMoney:
  19800. v, ok := value.(float32)
  19801. if !ok {
  19802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19803. }
  19804. m.AddMoney(v)
  19805. return nil
  19806. case payrecharge.FieldOrganizationID:
  19807. v, ok := value.(int64)
  19808. if !ok {
  19809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19810. }
  19811. m.AddOrganizationID(v)
  19812. return nil
  19813. }
  19814. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  19815. }
  19816. // ClearedFields returns all nullable fields that were cleared during this
  19817. // mutation.
  19818. func (m *PayRechargeMutation) ClearedFields() []string {
  19819. var fields []string
  19820. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  19821. fields = append(fields, payrecharge.FieldDeletedAt)
  19822. }
  19823. if m.FieldCleared(payrecharge.FieldStatus) {
  19824. fields = append(fields, payrecharge.FieldStatus)
  19825. }
  19826. if m.FieldCleared(payrecharge.FieldMoney) {
  19827. fields = append(fields, payrecharge.FieldMoney)
  19828. }
  19829. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  19830. fields = append(fields, payrecharge.FieldOutTradeNo)
  19831. }
  19832. return fields
  19833. }
  19834. // FieldCleared returns a boolean indicating if a field with the given name was
  19835. // cleared in this mutation.
  19836. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  19837. _, ok := m.clearedFields[name]
  19838. return ok
  19839. }
  19840. // ClearField clears the value of the field with the given name. It returns an
  19841. // error if the field is not defined in the schema.
  19842. func (m *PayRechargeMutation) ClearField(name string) error {
  19843. switch name {
  19844. case payrecharge.FieldDeletedAt:
  19845. m.ClearDeletedAt()
  19846. return nil
  19847. case payrecharge.FieldStatus:
  19848. m.ClearStatus()
  19849. return nil
  19850. case payrecharge.FieldMoney:
  19851. m.ClearMoney()
  19852. return nil
  19853. case payrecharge.FieldOutTradeNo:
  19854. m.ClearOutTradeNo()
  19855. return nil
  19856. }
  19857. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  19858. }
  19859. // ResetField resets all changes in the mutation for the field with the given name.
  19860. // It returns an error if the field is not defined in the schema.
  19861. func (m *PayRechargeMutation) ResetField(name string) error {
  19862. switch name {
  19863. case payrecharge.FieldCreatedAt:
  19864. m.ResetCreatedAt()
  19865. return nil
  19866. case payrecharge.FieldUpdatedAt:
  19867. m.ResetUpdatedAt()
  19868. return nil
  19869. case payrecharge.FieldDeletedAt:
  19870. m.ResetDeletedAt()
  19871. return nil
  19872. case payrecharge.FieldUserID:
  19873. m.ResetUserID()
  19874. return nil
  19875. case payrecharge.FieldNumber:
  19876. m.ResetNumber()
  19877. return nil
  19878. case payrecharge.FieldStatus:
  19879. m.ResetStatus()
  19880. return nil
  19881. case payrecharge.FieldMoney:
  19882. m.ResetMoney()
  19883. return nil
  19884. case payrecharge.FieldOutTradeNo:
  19885. m.ResetOutTradeNo()
  19886. return nil
  19887. case payrecharge.FieldOrganizationID:
  19888. m.ResetOrganizationID()
  19889. return nil
  19890. }
  19891. return fmt.Errorf("unknown PayRecharge field %s", name)
  19892. }
  19893. // AddedEdges returns all edge names that were set/added in this mutation.
  19894. func (m *PayRechargeMutation) AddedEdges() []string {
  19895. edges := make([]string, 0, 0)
  19896. return edges
  19897. }
  19898. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19899. // name in this mutation.
  19900. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  19901. return nil
  19902. }
  19903. // RemovedEdges returns all edge names that were removed in this mutation.
  19904. func (m *PayRechargeMutation) RemovedEdges() []string {
  19905. edges := make([]string, 0, 0)
  19906. return edges
  19907. }
  19908. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19909. // the given name in this mutation.
  19910. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  19911. return nil
  19912. }
  19913. // ClearedEdges returns all edge names that were cleared in this mutation.
  19914. func (m *PayRechargeMutation) ClearedEdges() []string {
  19915. edges := make([]string, 0, 0)
  19916. return edges
  19917. }
  19918. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19919. // was cleared in this mutation.
  19920. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  19921. return false
  19922. }
  19923. // ClearEdge clears the value of the edge with the given name. It returns an error
  19924. // if that edge is not defined in the schema.
  19925. func (m *PayRechargeMutation) ClearEdge(name string) error {
  19926. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  19927. }
  19928. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19929. // It returns an error if the edge is not defined in the schema.
  19930. func (m *PayRechargeMutation) ResetEdge(name string) error {
  19931. return fmt.Errorf("unknown PayRecharge edge %s", name)
  19932. }
  19933. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  19934. type ServerMutation struct {
  19935. config
  19936. op Op
  19937. typ string
  19938. id *uint64
  19939. created_at *time.Time
  19940. updated_at *time.Time
  19941. status *uint8
  19942. addstatus *int8
  19943. deleted_at *time.Time
  19944. name *string
  19945. public_ip *string
  19946. private_ip *string
  19947. admin_port *string
  19948. clearedFields map[string]struct{}
  19949. wxs map[uint64]struct{}
  19950. removedwxs map[uint64]struct{}
  19951. clearedwxs bool
  19952. done bool
  19953. oldValue func(context.Context) (*Server, error)
  19954. predicates []predicate.Server
  19955. }
  19956. var _ ent.Mutation = (*ServerMutation)(nil)
  19957. // serverOption allows management of the mutation configuration using functional options.
  19958. type serverOption func(*ServerMutation)
  19959. // newServerMutation creates new mutation for the Server entity.
  19960. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  19961. m := &ServerMutation{
  19962. config: c,
  19963. op: op,
  19964. typ: TypeServer,
  19965. clearedFields: make(map[string]struct{}),
  19966. }
  19967. for _, opt := range opts {
  19968. opt(m)
  19969. }
  19970. return m
  19971. }
  19972. // withServerID sets the ID field of the mutation.
  19973. func withServerID(id uint64) serverOption {
  19974. return func(m *ServerMutation) {
  19975. var (
  19976. err error
  19977. once sync.Once
  19978. value *Server
  19979. )
  19980. m.oldValue = func(ctx context.Context) (*Server, error) {
  19981. once.Do(func() {
  19982. if m.done {
  19983. err = errors.New("querying old values post mutation is not allowed")
  19984. } else {
  19985. value, err = m.Client().Server.Get(ctx, id)
  19986. }
  19987. })
  19988. return value, err
  19989. }
  19990. m.id = &id
  19991. }
  19992. }
  19993. // withServer sets the old Server of the mutation.
  19994. func withServer(node *Server) serverOption {
  19995. return func(m *ServerMutation) {
  19996. m.oldValue = func(context.Context) (*Server, error) {
  19997. return node, nil
  19998. }
  19999. m.id = &node.ID
  20000. }
  20001. }
  20002. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20003. // executed in a transaction (ent.Tx), a transactional client is returned.
  20004. func (m ServerMutation) Client() *Client {
  20005. client := &Client{config: m.config}
  20006. client.init()
  20007. return client
  20008. }
  20009. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20010. // it returns an error otherwise.
  20011. func (m ServerMutation) Tx() (*Tx, error) {
  20012. if _, ok := m.driver.(*txDriver); !ok {
  20013. return nil, errors.New("ent: mutation is not running in a transaction")
  20014. }
  20015. tx := &Tx{config: m.config}
  20016. tx.init()
  20017. return tx, nil
  20018. }
  20019. // SetID sets the value of the id field. Note that this
  20020. // operation is only accepted on creation of Server entities.
  20021. func (m *ServerMutation) SetID(id uint64) {
  20022. m.id = &id
  20023. }
  20024. // ID returns the ID value in the mutation. Note that the ID is only available
  20025. // if it was provided to the builder or after it was returned from the database.
  20026. func (m *ServerMutation) ID() (id uint64, exists bool) {
  20027. if m.id == nil {
  20028. return
  20029. }
  20030. return *m.id, true
  20031. }
  20032. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20033. // That means, if the mutation is applied within a transaction with an isolation level such
  20034. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20035. // or updated by the mutation.
  20036. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  20037. switch {
  20038. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20039. id, exists := m.ID()
  20040. if exists {
  20041. return []uint64{id}, nil
  20042. }
  20043. fallthrough
  20044. case m.op.Is(OpUpdate | OpDelete):
  20045. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  20046. default:
  20047. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20048. }
  20049. }
  20050. // SetCreatedAt sets the "created_at" field.
  20051. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  20052. m.created_at = &t
  20053. }
  20054. // CreatedAt returns the value of the "created_at" field in the mutation.
  20055. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  20056. v := m.created_at
  20057. if v == nil {
  20058. return
  20059. }
  20060. return *v, true
  20061. }
  20062. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  20063. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20065. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20066. if !m.op.Is(OpUpdateOne) {
  20067. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20068. }
  20069. if m.id == nil || m.oldValue == nil {
  20070. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20071. }
  20072. oldValue, err := m.oldValue(ctx)
  20073. if err != nil {
  20074. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20075. }
  20076. return oldValue.CreatedAt, nil
  20077. }
  20078. // ResetCreatedAt resets all changes to the "created_at" field.
  20079. func (m *ServerMutation) ResetCreatedAt() {
  20080. m.created_at = nil
  20081. }
  20082. // SetUpdatedAt sets the "updated_at" field.
  20083. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  20084. m.updated_at = &t
  20085. }
  20086. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20087. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  20088. v := m.updated_at
  20089. if v == nil {
  20090. return
  20091. }
  20092. return *v, true
  20093. }
  20094. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  20095. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20096. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20097. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20098. if !m.op.Is(OpUpdateOne) {
  20099. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20100. }
  20101. if m.id == nil || m.oldValue == nil {
  20102. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20103. }
  20104. oldValue, err := m.oldValue(ctx)
  20105. if err != nil {
  20106. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20107. }
  20108. return oldValue.UpdatedAt, nil
  20109. }
  20110. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20111. func (m *ServerMutation) ResetUpdatedAt() {
  20112. m.updated_at = nil
  20113. }
  20114. // SetStatus sets the "status" field.
  20115. func (m *ServerMutation) SetStatus(u uint8) {
  20116. m.status = &u
  20117. m.addstatus = nil
  20118. }
  20119. // Status returns the value of the "status" field in the mutation.
  20120. func (m *ServerMutation) Status() (r uint8, exists bool) {
  20121. v := m.status
  20122. if v == nil {
  20123. return
  20124. }
  20125. return *v, true
  20126. }
  20127. // OldStatus returns the old "status" field's value of the Server entity.
  20128. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20130. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20131. if !m.op.Is(OpUpdateOne) {
  20132. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20133. }
  20134. if m.id == nil || m.oldValue == nil {
  20135. return v, errors.New("OldStatus requires an ID field in the mutation")
  20136. }
  20137. oldValue, err := m.oldValue(ctx)
  20138. if err != nil {
  20139. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20140. }
  20141. return oldValue.Status, nil
  20142. }
  20143. // AddStatus adds u to the "status" field.
  20144. func (m *ServerMutation) AddStatus(u int8) {
  20145. if m.addstatus != nil {
  20146. *m.addstatus += u
  20147. } else {
  20148. m.addstatus = &u
  20149. }
  20150. }
  20151. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20152. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  20153. v := m.addstatus
  20154. if v == nil {
  20155. return
  20156. }
  20157. return *v, true
  20158. }
  20159. // ClearStatus clears the value of the "status" field.
  20160. func (m *ServerMutation) ClearStatus() {
  20161. m.status = nil
  20162. m.addstatus = nil
  20163. m.clearedFields[server.FieldStatus] = struct{}{}
  20164. }
  20165. // StatusCleared returns if the "status" field was cleared in this mutation.
  20166. func (m *ServerMutation) StatusCleared() bool {
  20167. _, ok := m.clearedFields[server.FieldStatus]
  20168. return ok
  20169. }
  20170. // ResetStatus resets all changes to the "status" field.
  20171. func (m *ServerMutation) ResetStatus() {
  20172. m.status = nil
  20173. m.addstatus = nil
  20174. delete(m.clearedFields, server.FieldStatus)
  20175. }
  20176. // SetDeletedAt sets the "deleted_at" field.
  20177. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  20178. m.deleted_at = &t
  20179. }
  20180. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20181. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  20182. v := m.deleted_at
  20183. if v == nil {
  20184. return
  20185. }
  20186. return *v, true
  20187. }
  20188. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  20189. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20191. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20192. if !m.op.Is(OpUpdateOne) {
  20193. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20194. }
  20195. if m.id == nil || m.oldValue == nil {
  20196. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20197. }
  20198. oldValue, err := m.oldValue(ctx)
  20199. if err != nil {
  20200. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20201. }
  20202. return oldValue.DeletedAt, nil
  20203. }
  20204. // ClearDeletedAt clears the value of the "deleted_at" field.
  20205. func (m *ServerMutation) ClearDeletedAt() {
  20206. m.deleted_at = nil
  20207. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  20208. }
  20209. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20210. func (m *ServerMutation) DeletedAtCleared() bool {
  20211. _, ok := m.clearedFields[server.FieldDeletedAt]
  20212. return ok
  20213. }
  20214. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20215. func (m *ServerMutation) ResetDeletedAt() {
  20216. m.deleted_at = nil
  20217. delete(m.clearedFields, server.FieldDeletedAt)
  20218. }
  20219. // SetName sets the "name" field.
  20220. func (m *ServerMutation) SetName(s string) {
  20221. m.name = &s
  20222. }
  20223. // Name returns the value of the "name" field in the mutation.
  20224. func (m *ServerMutation) Name() (r string, exists bool) {
  20225. v := m.name
  20226. if v == nil {
  20227. return
  20228. }
  20229. return *v, true
  20230. }
  20231. // OldName returns the old "name" field's value of the Server entity.
  20232. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20234. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  20235. if !m.op.Is(OpUpdateOne) {
  20236. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20237. }
  20238. if m.id == nil || m.oldValue == nil {
  20239. return v, errors.New("OldName requires an ID field in the mutation")
  20240. }
  20241. oldValue, err := m.oldValue(ctx)
  20242. if err != nil {
  20243. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20244. }
  20245. return oldValue.Name, nil
  20246. }
  20247. // ResetName resets all changes to the "name" field.
  20248. func (m *ServerMutation) ResetName() {
  20249. m.name = nil
  20250. }
  20251. // SetPublicIP sets the "public_ip" field.
  20252. func (m *ServerMutation) SetPublicIP(s string) {
  20253. m.public_ip = &s
  20254. }
  20255. // PublicIP returns the value of the "public_ip" field in the mutation.
  20256. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  20257. v := m.public_ip
  20258. if v == nil {
  20259. return
  20260. }
  20261. return *v, true
  20262. }
  20263. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  20264. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20266. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  20267. if !m.op.Is(OpUpdateOne) {
  20268. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  20269. }
  20270. if m.id == nil || m.oldValue == nil {
  20271. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  20272. }
  20273. oldValue, err := m.oldValue(ctx)
  20274. if err != nil {
  20275. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  20276. }
  20277. return oldValue.PublicIP, nil
  20278. }
  20279. // ResetPublicIP resets all changes to the "public_ip" field.
  20280. func (m *ServerMutation) ResetPublicIP() {
  20281. m.public_ip = nil
  20282. }
  20283. // SetPrivateIP sets the "private_ip" field.
  20284. func (m *ServerMutation) SetPrivateIP(s string) {
  20285. m.private_ip = &s
  20286. }
  20287. // PrivateIP returns the value of the "private_ip" field in the mutation.
  20288. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  20289. v := m.private_ip
  20290. if v == nil {
  20291. return
  20292. }
  20293. return *v, true
  20294. }
  20295. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  20296. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20298. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  20299. if !m.op.Is(OpUpdateOne) {
  20300. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  20301. }
  20302. if m.id == nil || m.oldValue == nil {
  20303. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  20304. }
  20305. oldValue, err := m.oldValue(ctx)
  20306. if err != nil {
  20307. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  20308. }
  20309. return oldValue.PrivateIP, nil
  20310. }
  20311. // ResetPrivateIP resets all changes to the "private_ip" field.
  20312. func (m *ServerMutation) ResetPrivateIP() {
  20313. m.private_ip = nil
  20314. }
  20315. // SetAdminPort sets the "admin_port" field.
  20316. func (m *ServerMutation) SetAdminPort(s string) {
  20317. m.admin_port = &s
  20318. }
  20319. // AdminPort returns the value of the "admin_port" field in the mutation.
  20320. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  20321. v := m.admin_port
  20322. if v == nil {
  20323. return
  20324. }
  20325. return *v, true
  20326. }
  20327. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  20328. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20330. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  20331. if !m.op.Is(OpUpdateOne) {
  20332. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  20333. }
  20334. if m.id == nil || m.oldValue == nil {
  20335. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  20336. }
  20337. oldValue, err := m.oldValue(ctx)
  20338. if err != nil {
  20339. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  20340. }
  20341. return oldValue.AdminPort, nil
  20342. }
  20343. // ResetAdminPort resets all changes to the "admin_port" field.
  20344. func (m *ServerMutation) ResetAdminPort() {
  20345. m.admin_port = nil
  20346. }
  20347. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  20348. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  20349. if m.wxs == nil {
  20350. m.wxs = make(map[uint64]struct{})
  20351. }
  20352. for i := range ids {
  20353. m.wxs[ids[i]] = struct{}{}
  20354. }
  20355. }
  20356. // ClearWxs clears the "wxs" edge to the Wx entity.
  20357. func (m *ServerMutation) ClearWxs() {
  20358. m.clearedwxs = true
  20359. }
  20360. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  20361. func (m *ServerMutation) WxsCleared() bool {
  20362. return m.clearedwxs
  20363. }
  20364. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  20365. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  20366. if m.removedwxs == nil {
  20367. m.removedwxs = make(map[uint64]struct{})
  20368. }
  20369. for i := range ids {
  20370. delete(m.wxs, ids[i])
  20371. m.removedwxs[ids[i]] = struct{}{}
  20372. }
  20373. }
  20374. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  20375. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  20376. for id := range m.removedwxs {
  20377. ids = append(ids, id)
  20378. }
  20379. return
  20380. }
  20381. // WxsIDs returns the "wxs" edge IDs in the mutation.
  20382. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  20383. for id := range m.wxs {
  20384. ids = append(ids, id)
  20385. }
  20386. return
  20387. }
  20388. // ResetWxs resets all changes to the "wxs" edge.
  20389. func (m *ServerMutation) ResetWxs() {
  20390. m.wxs = nil
  20391. m.clearedwxs = false
  20392. m.removedwxs = nil
  20393. }
  20394. // Where appends a list predicates to the ServerMutation builder.
  20395. func (m *ServerMutation) Where(ps ...predicate.Server) {
  20396. m.predicates = append(m.predicates, ps...)
  20397. }
  20398. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  20399. // users can use type-assertion to append predicates that do not depend on any generated package.
  20400. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  20401. p := make([]predicate.Server, len(ps))
  20402. for i := range ps {
  20403. p[i] = ps[i]
  20404. }
  20405. m.Where(p...)
  20406. }
  20407. // Op returns the operation name.
  20408. func (m *ServerMutation) Op() Op {
  20409. return m.op
  20410. }
  20411. // SetOp allows setting the mutation operation.
  20412. func (m *ServerMutation) SetOp(op Op) {
  20413. m.op = op
  20414. }
  20415. // Type returns the node type of this mutation (Server).
  20416. func (m *ServerMutation) Type() string {
  20417. return m.typ
  20418. }
  20419. // Fields returns all fields that were changed during this mutation. Note that in
  20420. // order to get all numeric fields that were incremented/decremented, call
  20421. // AddedFields().
  20422. func (m *ServerMutation) Fields() []string {
  20423. fields := make([]string, 0, 8)
  20424. if m.created_at != nil {
  20425. fields = append(fields, server.FieldCreatedAt)
  20426. }
  20427. if m.updated_at != nil {
  20428. fields = append(fields, server.FieldUpdatedAt)
  20429. }
  20430. if m.status != nil {
  20431. fields = append(fields, server.FieldStatus)
  20432. }
  20433. if m.deleted_at != nil {
  20434. fields = append(fields, server.FieldDeletedAt)
  20435. }
  20436. if m.name != nil {
  20437. fields = append(fields, server.FieldName)
  20438. }
  20439. if m.public_ip != nil {
  20440. fields = append(fields, server.FieldPublicIP)
  20441. }
  20442. if m.private_ip != nil {
  20443. fields = append(fields, server.FieldPrivateIP)
  20444. }
  20445. if m.admin_port != nil {
  20446. fields = append(fields, server.FieldAdminPort)
  20447. }
  20448. return fields
  20449. }
  20450. // Field returns the value of a field with the given name. The second boolean
  20451. // return value indicates that this field was not set, or was not defined in the
  20452. // schema.
  20453. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  20454. switch name {
  20455. case server.FieldCreatedAt:
  20456. return m.CreatedAt()
  20457. case server.FieldUpdatedAt:
  20458. return m.UpdatedAt()
  20459. case server.FieldStatus:
  20460. return m.Status()
  20461. case server.FieldDeletedAt:
  20462. return m.DeletedAt()
  20463. case server.FieldName:
  20464. return m.Name()
  20465. case server.FieldPublicIP:
  20466. return m.PublicIP()
  20467. case server.FieldPrivateIP:
  20468. return m.PrivateIP()
  20469. case server.FieldAdminPort:
  20470. return m.AdminPort()
  20471. }
  20472. return nil, false
  20473. }
  20474. // OldField returns the old value of the field from the database. An error is
  20475. // returned if the mutation operation is not UpdateOne, or the query to the
  20476. // database failed.
  20477. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20478. switch name {
  20479. case server.FieldCreatedAt:
  20480. return m.OldCreatedAt(ctx)
  20481. case server.FieldUpdatedAt:
  20482. return m.OldUpdatedAt(ctx)
  20483. case server.FieldStatus:
  20484. return m.OldStatus(ctx)
  20485. case server.FieldDeletedAt:
  20486. return m.OldDeletedAt(ctx)
  20487. case server.FieldName:
  20488. return m.OldName(ctx)
  20489. case server.FieldPublicIP:
  20490. return m.OldPublicIP(ctx)
  20491. case server.FieldPrivateIP:
  20492. return m.OldPrivateIP(ctx)
  20493. case server.FieldAdminPort:
  20494. return m.OldAdminPort(ctx)
  20495. }
  20496. return nil, fmt.Errorf("unknown Server field %s", name)
  20497. }
  20498. // SetField sets the value of a field with the given name. It returns an error if
  20499. // the field is not defined in the schema, or if the type mismatched the field
  20500. // type.
  20501. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  20502. switch name {
  20503. case server.FieldCreatedAt:
  20504. v, ok := value.(time.Time)
  20505. if !ok {
  20506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20507. }
  20508. m.SetCreatedAt(v)
  20509. return nil
  20510. case server.FieldUpdatedAt:
  20511. v, ok := value.(time.Time)
  20512. if !ok {
  20513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20514. }
  20515. m.SetUpdatedAt(v)
  20516. return nil
  20517. case server.FieldStatus:
  20518. v, ok := value.(uint8)
  20519. if !ok {
  20520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20521. }
  20522. m.SetStatus(v)
  20523. return nil
  20524. case server.FieldDeletedAt:
  20525. v, ok := value.(time.Time)
  20526. if !ok {
  20527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20528. }
  20529. m.SetDeletedAt(v)
  20530. return nil
  20531. case server.FieldName:
  20532. v, ok := value.(string)
  20533. if !ok {
  20534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20535. }
  20536. m.SetName(v)
  20537. return nil
  20538. case server.FieldPublicIP:
  20539. v, ok := value.(string)
  20540. if !ok {
  20541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20542. }
  20543. m.SetPublicIP(v)
  20544. return nil
  20545. case server.FieldPrivateIP:
  20546. v, ok := value.(string)
  20547. if !ok {
  20548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20549. }
  20550. m.SetPrivateIP(v)
  20551. return nil
  20552. case server.FieldAdminPort:
  20553. v, ok := value.(string)
  20554. if !ok {
  20555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20556. }
  20557. m.SetAdminPort(v)
  20558. return nil
  20559. }
  20560. return fmt.Errorf("unknown Server field %s", name)
  20561. }
  20562. // AddedFields returns all numeric fields that were incremented/decremented during
  20563. // this mutation.
  20564. func (m *ServerMutation) AddedFields() []string {
  20565. var fields []string
  20566. if m.addstatus != nil {
  20567. fields = append(fields, server.FieldStatus)
  20568. }
  20569. return fields
  20570. }
  20571. // AddedField returns the numeric value that was incremented/decremented on a field
  20572. // with the given name. The second boolean return value indicates that this field
  20573. // was not set, or was not defined in the schema.
  20574. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  20575. switch name {
  20576. case server.FieldStatus:
  20577. return m.AddedStatus()
  20578. }
  20579. return nil, false
  20580. }
  20581. // AddField adds the value to the field with the given name. It returns an error if
  20582. // the field is not defined in the schema, or if the type mismatched the field
  20583. // type.
  20584. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  20585. switch name {
  20586. case server.FieldStatus:
  20587. v, ok := value.(int8)
  20588. if !ok {
  20589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20590. }
  20591. m.AddStatus(v)
  20592. return nil
  20593. }
  20594. return fmt.Errorf("unknown Server numeric field %s", name)
  20595. }
  20596. // ClearedFields returns all nullable fields that were cleared during this
  20597. // mutation.
  20598. func (m *ServerMutation) ClearedFields() []string {
  20599. var fields []string
  20600. if m.FieldCleared(server.FieldStatus) {
  20601. fields = append(fields, server.FieldStatus)
  20602. }
  20603. if m.FieldCleared(server.FieldDeletedAt) {
  20604. fields = append(fields, server.FieldDeletedAt)
  20605. }
  20606. return fields
  20607. }
  20608. // FieldCleared returns a boolean indicating if a field with the given name was
  20609. // cleared in this mutation.
  20610. func (m *ServerMutation) FieldCleared(name string) bool {
  20611. _, ok := m.clearedFields[name]
  20612. return ok
  20613. }
  20614. // ClearField clears the value of the field with the given name. It returns an
  20615. // error if the field is not defined in the schema.
  20616. func (m *ServerMutation) ClearField(name string) error {
  20617. switch name {
  20618. case server.FieldStatus:
  20619. m.ClearStatus()
  20620. return nil
  20621. case server.FieldDeletedAt:
  20622. m.ClearDeletedAt()
  20623. return nil
  20624. }
  20625. return fmt.Errorf("unknown Server nullable field %s", name)
  20626. }
  20627. // ResetField resets all changes in the mutation for the field with the given name.
  20628. // It returns an error if the field is not defined in the schema.
  20629. func (m *ServerMutation) ResetField(name string) error {
  20630. switch name {
  20631. case server.FieldCreatedAt:
  20632. m.ResetCreatedAt()
  20633. return nil
  20634. case server.FieldUpdatedAt:
  20635. m.ResetUpdatedAt()
  20636. return nil
  20637. case server.FieldStatus:
  20638. m.ResetStatus()
  20639. return nil
  20640. case server.FieldDeletedAt:
  20641. m.ResetDeletedAt()
  20642. return nil
  20643. case server.FieldName:
  20644. m.ResetName()
  20645. return nil
  20646. case server.FieldPublicIP:
  20647. m.ResetPublicIP()
  20648. return nil
  20649. case server.FieldPrivateIP:
  20650. m.ResetPrivateIP()
  20651. return nil
  20652. case server.FieldAdminPort:
  20653. m.ResetAdminPort()
  20654. return nil
  20655. }
  20656. return fmt.Errorf("unknown Server field %s", name)
  20657. }
  20658. // AddedEdges returns all edge names that were set/added in this mutation.
  20659. func (m *ServerMutation) AddedEdges() []string {
  20660. edges := make([]string, 0, 1)
  20661. if m.wxs != nil {
  20662. edges = append(edges, server.EdgeWxs)
  20663. }
  20664. return edges
  20665. }
  20666. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20667. // name in this mutation.
  20668. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  20669. switch name {
  20670. case server.EdgeWxs:
  20671. ids := make([]ent.Value, 0, len(m.wxs))
  20672. for id := range m.wxs {
  20673. ids = append(ids, id)
  20674. }
  20675. return ids
  20676. }
  20677. return nil
  20678. }
  20679. // RemovedEdges returns all edge names that were removed in this mutation.
  20680. func (m *ServerMutation) RemovedEdges() []string {
  20681. edges := make([]string, 0, 1)
  20682. if m.removedwxs != nil {
  20683. edges = append(edges, server.EdgeWxs)
  20684. }
  20685. return edges
  20686. }
  20687. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20688. // the given name in this mutation.
  20689. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  20690. switch name {
  20691. case server.EdgeWxs:
  20692. ids := make([]ent.Value, 0, len(m.removedwxs))
  20693. for id := range m.removedwxs {
  20694. ids = append(ids, id)
  20695. }
  20696. return ids
  20697. }
  20698. return nil
  20699. }
  20700. // ClearedEdges returns all edge names that were cleared in this mutation.
  20701. func (m *ServerMutation) ClearedEdges() []string {
  20702. edges := make([]string, 0, 1)
  20703. if m.clearedwxs {
  20704. edges = append(edges, server.EdgeWxs)
  20705. }
  20706. return edges
  20707. }
  20708. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20709. // was cleared in this mutation.
  20710. func (m *ServerMutation) EdgeCleared(name string) bool {
  20711. switch name {
  20712. case server.EdgeWxs:
  20713. return m.clearedwxs
  20714. }
  20715. return false
  20716. }
  20717. // ClearEdge clears the value of the edge with the given name. It returns an error
  20718. // if that edge is not defined in the schema.
  20719. func (m *ServerMutation) ClearEdge(name string) error {
  20720. switch name {
  20721. }
  20722. return fmt.Errorf("unknown Server unique edge %s", name)
  20723. }
  20724. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20725. // It returns an error if the edge is not defined in the schema.
  20726. func (m *ServerMutation) ResetEdge(name string) error {
  20727. switch name {
  20728. case server.EdgeWxs:
  20729. m.ResetWxs()
  20730. return nil
  20731. }
  20732. return fmt.Errorf("unknown Server edge %s", name)
  20733. }
  20734. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  20735. type SopNodeMutation struct {
  20736. config
  20737. op Op
  20738. typ string
  20739. id *uint64
  20740. created_at *time.Time
  20741. updated_at *time.Time
  20742. status *uint8
  20743. addstatus *int8
  20744. deleted_at *time.Time
  20745. parent_id *uint64
  20746. addparent_id *int64
  20747. name *string
  20748. condition_type *int
  20749. addcondition_type *int
  20750. condition_list *[]string
  20751. appendcondition_list []string
  20752. no_reply_condition *uint64
  20753. addno_reply_condition *int64
  20754. no_reply_unit *string
  20755. action_message *[]custom_types.Action
  20756. appendaction_message []custom_types.Action
  20757. action_label_add *[]uint64
  20758. appendaction_label_add []uint64
  20759. action_label_del *[]uint64
  20760. appendaction_label_del []uint64
  20761. action_forward **custom_types.ActionForward
  20762. clearedFields map[string]struct{}
  20763. sop_stage *uint64
  20764. clearedsop_stage bool
  20765. node_messages map[uint64]struct{}
  20766. removednode_messages map[uint64]struct{}
  20767. clearednode_messages bool
  20768. done bool
  20769. oldValue func(context.Context) (*SopNode, error)
  20770. predicates []predicate.SopNode
  20771. }
  20772. var _ ent.Mutation = (*SopNodeMutation)(nil)
  20773. // sopnodeOption allows management of the mutation configuration using functional options.
  20774. type sopnodeOption func(*SopNodeMutation)
  20775. // newSopNodeMutation creates new mutation for the SopNode entity.
  20776. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  20777. m := &SopNodeMutation{
  20778. config: c,
  20779. op: op,
  20780. typ: TypeSopNode,
  20781. clearedFields: make(map[string]struct{}),
  20782. }
  20783. for _, opt := range opts {
  20784. opt(m)
  20785. }
  20786. return m
  20787. }
  20788. // withSopNodeID sets the ID field of the mutation.
  20789. func withSopNodeID(id uint64) sopnodeOption {
  20790. return func(m *SopNodeMutation) {
  20791. var (
  20792. err error
  20793. once sync.Once
  20794. value *SopNode
  20795. )
  20796. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  20797. once.Do(func() {
  20798. if m.done {
  20799. err = errors.New("querying old values post mutation is not allowed")
  20800. } else {
  20801. value, err = m.Client().SopNode.Get(ctx, id)
  20802. }
  20803. })
  20804. return value, err
  20805. }
  20806. m.id = &id
  20807. }
  20808. }
  20809. // withSopNode sets the old SopNode of the mutation.
  20810. func withSopNode(node *SopNode) sopnodeOption {
  20811. return func(m *SopNodeMutation) {
  20812. m.oldValue = func(context.Context) (*SopNode, error) {
  20813. return node, nil
  20814. }
  20815. m.id = &node.ID
  20816. }
  20817. }
  20818. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20819. // executed in a transaction (ent.Tx), a transactional client is returned.
  20820. func (m SopNodeMutation) Client() *Client {
  20821. client := &Client{config: m.config}
  20822. client.init()
  20823. return client
  20824. }
  20825. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20826. // it returns an error otherwise.
  20827. func (m SopNodeMutation) Tx() (*Tx, error) {
  20828. if _, ok := m.driver.(*txDriver); !ok {
  20829. return nil, errors.New("ent: mutation is not running in a transaction")
  20830. }
  20831. tx := &Tx{config: m.config}
  20832. tx.init()
  20833. return tx, nil
  20834. }
  20835. // SetID sets the value of the id field. Note that this
  20836. // operation is only accepted on creation of SopNode entities.
  20837. func (m *SopNodeMutation) SetID(id uint64) {
  20838. m.id = &id
  20839. }
  20840. // ID returns the ID value in the mutation. Note that the ID is only available
  20841. // if it was provided to the builder or after it was returned from the database.
  20842. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  20843. if m.id == nil {
  20844. return
  20845. }
  20846. return *m.id, true
  20847. }
  20848. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20849. // That means, if the mutation is applied within a transaction with an isolation level such
  20850. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20851. // or updated by the mutation.
  20852. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20853. switch {
  20854. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20855. id, exists := m.ID()
  20856. if exists {
  20857. return []uint64{id}, nil
  20858. }
  20859. fallthrough
  20860. case m.op.Is(OpUpdate | OpDelete):
  20861. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  20862. default:
  20863. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20864. }
  20865. }
  20866. // SetCreatedAt sets the "created_at" field.
  20867. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  20868. m.created_at = &t
  20869. }
  20870. // CreatedAt returns the value of the "created_at" field in the mutation.
  20871. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  20872. v := m.created_at
  20873. if v == nil {
  20874. return
  20875. }
  20876. return *v, true
  20877. }
  20878. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  20879. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20881. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20882. if !m.op.Is(OpUpdateOne) {
  20883. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20884. }
  20885. if m.id == nil || m.oldValue == nil {
  20886. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20887. }
  20888. oldValue, err := m.oldValue(ctx)
  20889. if err != nil {
  20890. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20891. }
  20892. return oldValue.CreatedAt, nil
  20893. }
  20894. // ResetCreatedAt resets all changes to the "created_at" field.
  20895. func (m *SopNodeMutation) ResetCreatedAt() {
  20896. m.created_at = nil
  20897. }
  20898. // SetUpdatedAt sets the "updated_at" field.
  20899. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  20900. m.updated_at = &t
  20901. }
  20902. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20903. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  20904. v := m.updated_at
  20905. if v == nil {
  20906. return
  20907. }
  20908. return *v, true
  20909. }
  20910. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  20911. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20913. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20914. if !m.op.Is(OpUpdateOne) {
  20915. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20916. }
  20917. if m.id == nil || m.oldValue == nil {
  20918. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20919. }
  20920. oldValue, err := m.oldValue(ctx)
  20921. if err != nil {
  20922. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20923. }
  20924. return oldValue.UpdatedAt, nil
  20925. }
  20926. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20927. func (m *SopNodeMutation) ResetUpdatedAt() {
  20928. m.updated_at = nil
  20929. }
  20930. // SetStatus sets the "status" field.
  20931. func (m *SopNodeMutation) SetStatus(u uint8) {
  20932. m.status = &u
  20933. m.addstatus = nil
  20934. }
  20935. // Status returns the value of the "status" field in the mutation.
  20936. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  20937. v := m.status
  20938. if v == nil {
  20939. return
  20940. }
  20941. return *v, true
  20942. }
  20943. // OldStatus returns the old "status" field's value of the SopNode entity.
  20944. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20946. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20947. if !m.op.Is(OpUpdateOne) {
  20948. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20949. }
  20950. if m.id == nil || m.oldValue == nil {
  20951. return v, errors.New("OldStatus requires an ID field in the mutation")
  20952. }
  20953. oldValue, err := m.oldValue(ctx)
  20954. if err != nil {
  20955. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20956. }
  20957. return oldValue.Status, nil
  20958. }
  20959. // AddStatus adds u to the "status" field.
  20960. func (m *SopNodeMutation) AddStatus(u int8) {
  20961. if m.addstatus != nil {
  20962. *m.addstatus += u
  20963. } else {
  20964. m.addstatus = &u
  20965. }
  20966. }
  20967. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20968. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  20969. v := m.addstatus
  20970. if v == nil {
  20971. return
  20972. }
  20973. return *v, true
  20974. }
  20975. // ClearStatus clears the value of the "status" field.
  20976. func (m *SopNodeMutation) ClearStatus() {
  20977. m.status = nil
  20978. m.addstatus = nil
  20979. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  20980. }
  20981. // StatusCleared returns if the "status" field was cleared in this mutation.
  20982. func (m *SopNodeMutation) StatusCleared() bool {
  20983. _, ok := m.clearedFields[sopnode.FieldStatus]
  20984. return ok
  20985. }
  20986. // ResetStatus resets all changes to the "status" field.
  20987. func (m *SopNodeMutation) ResetStatus() {
  20988. m.status = nil
  20989. m.addstatus = nil
  20990. delete(m.clearedFields, sopnode.FieldStatus)
  20991. }
  20992. // SetDeletedAt sets the "deleted_at" field.
  20993. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  20994. m.deleted_at = &t
  20995. }
  20996. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20997. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  20998. v := m.deleted_at
  20999. if v == nil {
  21000. return
  21001. }
  21002. return *v, true
  21003. }
  21004. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  21005. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21007. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21008. if !m.op.Is(OpUpdateOne) {
  21009. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21010. }
  21011. if m.id == nil || m.oldValue == nil {
  21012. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21013. }
  21014. oldValue, err := m.oldValue(ctx)
  21015. if err != nil {
  21016. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21017. }
  21018. return oldValue.DeletedAt, nil
  21019. }
  21020. // ClearDeletedAt clears the value of the "deleted_at" field.
  21021. func (m *SopNodeMutation) ClearDeletedAt() {
  21022. m.deleted_at = nil
  21023. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  21024. }
  21025. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21026. func (m *SopNodeMutation) DeletedAtCleared() bool {
  21027. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  21028. return ok
  21029. }
  21030. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21031. func (m *SopNodeMutation) ResetDeletedAt() {
  21032. m.deleted_at = nil
  21033. delete(m.clearedFields, sopnode.FieldDeletedAt)
  21034. }
  21035. // SetStageID sets the "stage_id" field.
  21036. func (m *SopNodeMutation) SetStageID(u uint64) {
  21037. m.sop_stage = &u
  21038. }
  21039. // StageID returns the value of the "stage_id" field in the mutation.
  21040. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  21041. v := m.sop_stage
  21042. if v == nil {
  21043. return
  21044. }
  21045. return *v, true
  21046. }
  21047. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  21048. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21050. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  21051. if !m.op.Is(OpUpdateOne) {
  21052. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  21053. }
  21054. if m.id == nil || m.oldValue == nil {
  21055. return v, errors.New("OldStageID requires an ID field in the mutation")
  21056. }
  21057. oldValue, err := m.oldValue(ctx)
  21058. if err != nil {
  21059. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  21060. }
  21061. return oldValue.StageID, nil
  21062. }
  21063. // ResetStageID resets all changes to the "stage_id" field.
  21064. func (m *SopNodeMutation) ResetStageID() {
  21065. m.sop_stage = nil
  21066. }
  21067. // SetParentID sets the "parent_id" field.
  21068. func (m *SopNodeMutation) SetParentID(u uint64) {
  21069. m.parent_id = &u
  21070. m.addparent_id = nil
  21071. }
  21072. // ParentID returns the value of the "parent_id" field in the mutation.
  21073. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  21074. v := m.parent_id
  21075. if v == nil {
  21076. return
  21077. }
  21078. return *v, true
  21079. }
  21080. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  21081. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21083. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  21084. if !m.op.Is(OpUpdateOne) {
  21085. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  21086. }
  21087. if m.id == nil || m.oldValue == nil {
  21088. return v, errors.New("OldParentID requires an ID field in the mutation")
  21089. }
  21090. oldValue, err := m.oldValue(ctx)
  21091. if err != nil {
  21092. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  21093. }
  21094. return oldValue.ParentID, nil
  21095. }
  21096. // AddParentID adds u to the "parent_id" field.
  21097. func (m *SopNodeMutation) AddParentID(u int64) {
  21098. if m.addparent_id != nil {
  21099. *m.addparent_id += u
  21100. } else {
  21101. m.addparent_id = &u
  21102. }
  21103. }
  21104. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  21105. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  21106. v := m.addparent_id
  21107. if v == nil {
  21108. return
  21109. }
  21110. return *v, true
  21111. }
  21112. // ResetParentID resets all changes to the "parent_id" field.
  21113. func (m *SopNodeMutation) ResetParentID() {
  21114. m.parent_id = nil
  21115. m.addparent_id = nil
  21116. }
  21117. // SetName sets the "name" field.
  21118. func (m *SopNodeMutation) SetName(s string) {
  21119. m.name = &s
  21120. }
  21121. // Name returns the value of the "name" field in the mutation.
  21122. func (m *SopNodeMutation) Name() (r string, exists bool) {
  21123. v := m.name
  21124. if v == nil {
  21125. return
  21126. }
  21127. return *v, true
  21128. }
  21129. // OldName returns the old "name" field's value of the SopNode entity.
  21130. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21132. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  21133. if !m.op.Is(OpUpdateOne) {
  21134. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21135. }
  21136. if m.id == nil || m.oldValue == nil {
  21137. return v, errors.New("OldName requires an ID field in the mutation")
  21138. }
  21139. oldValue, err := m.oldValue(ctx)
  21140. if err != nil {
  21141. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21142. }
  21143. return oldValue.Name, nil
  21144. }
  21145. // ResetName resets all changes to the "name" field.
  21146. func (m *SopNodeMutation) ResetName() {
  21147. m.name = nil
  21148. }
  21149. // SetConditionType sets the "condition_type" field.
  21150. func (m *SopNodeMutation) SetConditionType(i int) {
  21151. m.condition_type = &i
  21152. m.addcondition_type = nil
  21153. }
  21154. // ConditionType returns the value of the "condition_type" field in the mutation.
  21155. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  21156. v := m.condition_type
  21157. if v == nil {
  21158. return
  21159. }
  21160. return *v, true
  21161. }
  21162. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  21163. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21165. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  21166. if !m.op.Is(OpUpdateOne) {
  21167. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  21168. }
  21169. if m.id == nil || m.oldValue == nil {
  21170. return v, errors.New("OldConditionType requires an ID field in the mutation")
  21171. }
  21172. oldValue, err := m.oldValue(ctx)
  21173. if err != nil {
  21174. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  21175. }
  21176. return oldValue.ConditionType, nil
  21177. }
  21178. // AddConditionType adds i to the "condition_type" field.
  21179. func (m *SopNodeMutation) AddConditionType(i int) {
  21180. if m.addcondition_type != nil {
  21181. *m.addcondition_type += i
  21182. } else {
  21183. m.addcondition_type = &i
  21184. }
  21185. }
  21186. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  21187. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  21188. v := m.addcondition_type
  21189. if v == nil {
  21190. return
  21191. }
  21192. return *v, true
  21193. }
  21194. // ResetConditionType resets all changes to the "condition_type" field.
  21195. func (m *SopNodeMutation) ResetConditionType() {
  21196. m.condition_type = nil
  21197. m.addcondition_type = nil
  21198. }
  21199. // SetConditionList sets the "condition_list" field.
  21200. func (m *SopNodeMutation) SetConditionList(s []string) {
  21201. m.condition_list = &s
  21202. m.appendcondition_list = nil
  21203. }
  21204. // ConditionList returns the value of the "condition_list" field in the mutation.
  21205. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  21206. v := m.condition_list
  21207. if v == nil {
  21208. return
  21209. }
  21210. return *v, true
  21211. }
  21212. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  21213. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21215. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  21216. if !m.op.Is(OpUpdateOne) {
  21217. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  21218. }
  21219. if m.id == nil || m.oldValue == nil {
  21220. return v, errors.New("OldConditionList requires an ID field in the mutation")
  21221. }
  21222. oldValue, err := m.oldValue(ctx)
  21223. if err != nil {
  21224. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  21225. }
  21226. return oldValue.ConditionList, nil
  21227. }
  21228. // AppendConditionList adds s to the "condition_list" field.
  21229. func (m *SopNodeMutation) AppendConditionList(s []string) {
  21230. m.appendcondition_list = append(m.appendcondition_list, s...)
  21231. }
  21232. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  21233. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  21234. if len(m.appendcondition_list) == 0 {
  21235. return nil, false
  21236. }
  21237. return m.appendcondition_list, true
  21238. }
  21239. // ClearConditionList clears the value of the "condition_list" field.
  21240. func (m *SopNodeMutation) ClearConditionList() {
  21241. m.condition_list = nil
  21242. m.appendcondition_list = nil
  21243. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  21244. }
  21245. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  21246. func (m *SopNodeMutation) ConditionListCleared() bool {
  21247. _, ok := m.clearedFields[sopnode.FieldConditionList]
  21248. return ok
  21249. }
  21250. // ResetConditionList resets all changes to the "condition_list" field.
  21251. func (m *SopNodeMutation) ResetConditionList() {
  21252. m.condition_list = nil
  21253. m.appendcondition_list = nil
  21254. delete(m.clearedFields, sopnode.FieldConditionList)
  21255. }
  21256. // SetNoReplyCondition sets the "no_reply_condition" field.
  21257. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  21258. m.no_reply_condition = &u
  21259. m.addno_reply_condition = nil
  21260. }
  21261. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  21262. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  21263. v := m.no_reply_condition
  21264. if v == nil {
  21265. return
  21266. }
  21267. return *v, true
  21268. }
  21269. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  21270. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21272. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  21273. if !m.op.Is(OpUpdateOne) {
  21274. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  21275. }
  21276. if m.id == nil || m.oldValue == nil {
  21277. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  21278. }
  21279. oldValue, err := m.oldValue(ctx)
  21280. if err != nil {
  21281. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  21282. }
  21283. return oldValue.NoReplyCondition, nil
  21284. }
  21285. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  21286. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  21287. if m.addno_reply_condition != nil {
  21288. *m.addno_reply_condition += u
  21289. } else {
  21290. m.addno_reply_condition = &u
  21291. }
  21292. }
  21293. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  21294. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  21295. v := m.addno_reply_condition
  21296. if v == nil {
  21297. return
  21298. }
  21299. return *v, true
  21300. }
  21301. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  21302. func (m *SopNodeMutation) ResetNoReplyCondition() {
  21303. m.no_reply_condition = nil
  21304. m.addno_reply_condition = nil
  21305. }
  21306. // SetNoReplyUnit sets the "no_reply_unit" field.
  21307. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  21308. m.no_reply_unit = &s
  21309. }
  21310. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  21311. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  21312. v := m.no_reply_unit
  21313. if v == nil {
  21314. return
  21315. }
  21316. return *v, true
  21317. }
  21318. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  21319. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21321. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  21322. if !m.op.Is(OpUpdateOne) {
  21323. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  21324. }
  21325. if m.id == nil || m.oldValue == nil {
  21326. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  21327. }
  21328. oldValue, err := m.oldValue(ctx)
  21329. if err != nil {
  21330. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  21331. }
  21332. return oldValue.NoReplyUnit, nil
  21333. }
  21334. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  21335. func (m *SopNodeMutation) ResetNoReplyUnit() {
  21336. m.no_reply_unit = nil
  21337. }
  21338. // SetActionMessage sets the "action_message" field.
  21339. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  21340. m.action_message = &ct
  21341. m.appendaction_message = nil
  21342. }
  21343. // ActionMessage returns the value of the "action_message" field in the mutation.
  21344. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  21345. v := m.action_message
  21346. if v == nil {
  21347. return
  21348. }
  21349. return *v, true
  21350. }
  21351. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  21352. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21354. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  21355. if !m.op.Is(OpUpdateOne) {
  21356. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  21357. }
  21358. if m.id == nil || m.oldValue == nil {
  21359. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  21360. }
  21361. oldValue, err := m.oldValue(ctx)
  21362. if err != nil {
  21363. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  21364. }
  21365. return oldValue.ActionMessage, nil
  21366. }
  21367. // AppendActionMessage adds ct to the "action_message" field.
  21368. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  21369. m.appendaction_message = append(m.appendaction_message, ct...)
  21370. }
  21371. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  21372. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  21373. if len(m.appendaction_message) == 0 {
  21374. return nil, false
  21375. }
  21376. return m.appendaction_message, true
  21377. }
  21378. // ClearActionMessage clears the value of the "action_message" field.
  21379. func (m *SopNodeMutation) ClearActionMessage() {
  21380. m.action_message = nil
  21381. m.appendaction_message = nil
  21382. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  21383. }
  21384. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  21385. func (m *SopNodeMutation) ActionMessageCleared() bool {
  21386. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  21387. return ok
  21388. }
  21389. // ResetActionMessage resets all changes to the "action_message" field.
  21390. func (m *SopNodeMutation) ResetActionMessage() {
  21391. m.action_message = nil
  21392. m.appendaction_message = nil
  21393. delete(m.clearedFields, sopnode.FieldActionMessage)
  21394. }
  21395. // SetActionLabelAdd sets the "action_label_add" field.
  21396. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  21397. m.action_label_add = &u
  21398. m.appendaction_label_add = nil
  21399. }
  21400. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21401. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21402. v := m.action_label_add
  21403. if v == nil {
  21404. return
  21405. }
  21406. return *v, true
  21407. }
  21408. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  21409. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21411. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21412. if !m.op.Is(OpUpdateOne) {
  21413. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21414. }
  21415. if m.id == nil || m.oldValue == nil {
  21416. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21417. }
  21418. oldValue, err := m.oldValue(ctx)
  21419. if err != nil {
  21420. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21421. }
  21422. return oldValue.ActionLabelAdd, nil
  21423. }
  21424. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21425. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  21426. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21427. }
  21428. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21429. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21430. if len(m.appendaction_label_add) == 0 {
  21431. return nil, false
  21432. }
  21433. return m.appendaction_label_add, true
  21434. }
  21435. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21436. func (m *SopNodeMutation) ClearActionLabelAdd() {
  21437. m.action_label_add = nil
  21438. m.appendaction_label_add = nil
  21439. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  21440. }
  21441. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21442. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  21443. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  21444. return ok
  21445. }
  21446. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21447. func (m *SopNodeMutation) ResetActionLabelAdd() {
  21448. m.action_label_add = nil
  21449. m.appendaction_label_add = nil
  21450. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  21451. }
  21452. // SetActionLabelDel sets the "action_label_del" field.
  21453. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  21454. m.action_label_del = &u
  21455. m.appendaction_label_del = nil
  21456. }
  21457. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21458. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  21459. v := m.action_label_del
  21460. if v == nil {
  21461. return
  21462. }
  21463. return *v, true
  21464. }
  21465. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  21466. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21468. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21469. if !m.op.Is(OpUpdateOne) {
  21470. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21471. }
  21472. if m.id == nil || m.oldValue == nil {
  21473. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21474. }
  21475. oldValue, err := m.oldValue(ctx)
  21476. if err != nil {
  21477. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21478. }
  21479. return oldValue.ActionLabelDel, nil
  21480. }
  21481. // AppendActionLabelDel adds u to the "action_label_del" field.
  21482. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  21483. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21484. }
  21485. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21486. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21487. if len(m.appendaction_label_del) == 0 {
  21488. return nil, false
  21489. }
  21490. return m.appendaction_label_del, true
  21491. }
  21492. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21493. func (m *SopNodeMutation) ClearActionLabelDel() {
  21494. m.action_label_del = nil
  21495. m.appendaction_label_del = nil
  21496. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  21497. }
  21498. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21499. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  21500. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  21501. return ok
  21502. }
  21503. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21504. func (m *SopNodeMutation) ResetActionLabelDel() {
  21505. m.action_label_del = nil
  21506. m.appendaction_label_del = nil
  21507. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  21508. }
  21509. // SetActionForward sets the "action_forward" field.
  21510. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  21511. m.action_forward = &ctf
  21512. }
  21513. // ActionForward returns the value of the "action_forward" field in the mutation.
  21514. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  21515. v := m.action_forward
  21516. if v == nil {
  21517. return
  21518. }
  21519. return *v, true
  21520. }
  21521. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  21522. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21524. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  21525. if !m.op.Is(OpUpdateOne) {
  21526. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  21527. }
  21528. if m.id == nil || m.oldValue == nil {
  21529. return v, errors.New("OldActionForward requires an ID field in the mutation")
  21530. }
  21531. oldValue, err := m.oldValue(ctx)
  21532. if err != nil {
  21533. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  21534. }
  21535. return oldValue.ActionForward, nil
  21536. }
  21537. // ClearActionForward clears the value of the "action_forward" field.
  21538. func (m *SopNodeMutation) ClearActionForward() {
  21539. m.action_forward = nil
  21540. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  21541. }
  21542. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  21543. func (m *SopNodeMutation) ActionForwardCleared() bool {
  21544. _, ok := m.clearedFields[sopnode.FieldActionForward]
  21545. return ok
  21546. }
  21547. // ResetActionForward resets all changes to the "action_forward" field.
  21548. func (m *SopNodeMutation) ResetActionForward() {
  21549. m.action_forward = nil
  21550. delete(m.clearedFields, sopnode.FieldActionForward)
  21551. }
  21552. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21553. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  21554. m.sop_stage = &id
  21555. }
  21556. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21557. func (m *SopNodeMutation) ClearSopStage() {
  21558. m.clearedsop_stage = true
  21559. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  21560. }
  21561. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21562. func (m *SopNodeMutation) SopStageCleared() bool {
  21563. return m.clearedsop_stage
  21564. }
  21565. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21566. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  21567. if m.sop_stage != nil {
  21568. return *m.sop_stage, true
  21569. }
  21570. return
  21571. }
  21572. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21573. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21574. // SopStageID instead. It exists only for internal usage by the builders.
  21575. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  21576. if id := m.sop_stage; id != nil {
  21577. ids = append(ids, *id)
  21578. }
  21579. return
  21580. }
  21581. // ResetSopStage resets all changes to the "sop_stage" edge.
  21582. func (m *SopNodeMutation) ResetSopStage() {
  21583. m.sop_stage = nil
  21584. m.clearedsop_stage = false
  21585. }
  21586. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  21587. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  21588. if m.node_messages == nil {
  21589. m.node_messages = make(map[uint64]struct{})
  21590. }
  21591. for i := range ids {
  21592. m.node_messages[ids[i]] = struct{}{}
  21593. }
  21594. }
  21595. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  21596. func (m *SopNodeMutation) ClearNodeMessages() {
  21597. m.clearednode_messages = true
  21598. }
  21599. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  21600. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  21601. return m.clearednode_messages
  21602. }
  21603. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  21604. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  21605. if m.removednode_messages == nil {
  21606. m.removednode_messages = make(map[uint64]struct{})
  21607. }
  21608. for i := range ids {
  21609. delete(m.node_messages, ids[i])
  21610. m.removednode_messages[ids[i]] = struct{}{}
  21611. }
  21612. }
  21613. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  21614. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  21615. for id := range m.removednode_messages {
  21616. ids = append(ids, id)
  21617. }
  21618. return
  21619. }
  21620. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  21621. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  21622. for id := range m.node_messages {
  21623. ids = append(ids, id)
  21624. }
  21625. return
  21626. }
  21627. // ResetNodeMessages resets all changes to the "node_messages" edge.
  21628. func (m *SopNodeMutation) ResetNodeMessages() {
  21629. m.node_messages = nil
  21630. m.clearednode_messages = false
  21631. m.removednode_messages = nil
  21632. }
  21633. // Where appends a list predicates to the SopNodeMutation builder.
  21634. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  21635. m.predicates = append(m.predicates, ps...)
  21636. }
  21637. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  21638. // users can use type-assertion to append predicates that do not depend on any generated package.
  21639. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  21640. p := make([]predicate.SopNode, len(ps))
  21641. for i := range ps {
  21642. p[i] = ps[i]
  21643. }
  21644. m.Where(p...)
  21645. }
  21646. // Op returns the operation name.
  21647. func (m *SopNodeMutation) Op() Op {
  21648. return m.op
  21649. }
  21650. // SetOp allows setting the mutation operation.
  21651. func (m *SopNodeMutation) SetOp(op Op) {
  21652. m.op = op
  21653. }
  21654. // Type returns the node type of this mutation (SopNode).
  21655. func (m *SopNodeMutation) Type() string {
  21656. return m.typ
  21657. }
  21658. // Fields returns all fields that were changed during this mutation. Note that in
  21659. // order to get all numeric fields that were incremented/decremented, call
  21660. // AddedFields().
  21661. func (m *SopNodeMutation) Fields() []string {
  21662. fields := make([]string, 0, 15)
  21663. if m.created_at != nil {
  21664. fields = append(fields, sopnode.FieldCreatedAt)
  21665. }
  21666. if m.updated_at != nil {
  21667. fields = append(fields, sopnode.FieldUpdatedAt)
  21668. }
  21669. if m.status != nil {
  21670. fields = append(fields, sopnode.FieldStatus)
  21671. }
  21672. if m.deleted_at != nil {
  21673. fields = append(fields, sopnode.FieldDeletedAt)
  21674. }
  21675. if m.sop_stage != nil {
  21676. fields = append(fields, sopnode.FieldStageID)
  21677. }
  21678. if m.parent_id != nil {
  21679. fields = append(fields, sopnode.FieldParentID)
  21680. }
  21681. if m.name != nil {
  21682. fields = append(fields, sopnode.FieldName)
  21683. }
  21684. if m.condition_type != nil {
  21685. fields = append(fields, sopnode.FieldConditionType)
  21686. }
  21687. if m.condition_list != nil {
  21688. fields = append(fields, sopnode.FieldConditionList)
  21689. }
  21690. if m.no_reply_condition != nil {
  21691. fields = append(fields, sopnode.FieldNoReplyCondition)
  21692. }
  21693. if m.no_reply_unit != nil {
  21694. fields = append(fields, sopnode.FieldNoReplyUnit)
  21695. }
  21696. if m.action_message != nil {
  21697. fields = append(fields, sopnode.FieldActionMessage)
  21698. }
  21699. if m.action_label_add != nil {
  21700. fields = append(fields, sopnode.FieldActionLabelAdd)
  21701. }
  21702. if m.action_label_del != nil {
  21703. fields = append(fields, sopnode.FieldActionLabelDel)
  21704. }
  21705. if m.action_forward != nil {
  21706. fields = append(fields, sopnode.FieldActionForward)
  21707. }
  21708. return fields
  21709. }
  21710. // Field returns the value of a field with the given name. The second boolean
  21711. // return value indicates that this field was not set, or was not defined in the
  21712. // schema.
  21713. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  21714. switch name {
  21715. case sopnode.FieldCreatedAt:
  21716. return m.CreatedAt()
  21717. case sopnode.FieldUpdatedAt:
  21718. return m.UpdatedAt()
  21719. case sopnode.FieldStatus:
  21720. return m.Status()
  21721. case sopnode.FieldDeletedAt:
  21722. return m.DeletedAt()
  21723. case sopnode.FieldStageID:
  21724. return m.StageID()
  21725. case sopnode.FieldParentID:
  21726. return m.ParentID()
  21727. case sopnode.FieldName:
  21728. return m.Name()
  21729. case sopnode.FieldConditionType:
  21730. return m.ConditionType()
  21731. case sopnode.FieldConditionList:
  21732. return m.ConditionList()
  21733. case sopnode.FieldNoReplyCondition:
  21734. return m.NoReplyCondition()
  21735. case sopnode.FieldNoReplyUnit:
  21736. return m.NoReplyUnit()
  21737. case sopnode.FieldActionMessage:
  21738. return m.ActionMessage()
  21739. case sopnode.FieldActionLabelAdd:
  21740. return m.ActionLabelAdd()
  21741. case sopnode.FieldActionLabelDel:
  21742. return m.ActionLabelDel()
  21743. case sopnode.FieldActionForward:
  21744. return m.ActionForward()
  21745. }
  21746. return nil, false
  21747. }
  21748. // OldField returns the old value of the field from the database. An error is
  21749. // returned if the mutation operation is not UpdateOne, or the query to the
  21750. // database failed.
  21751. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21752. switch name {
  21753. case sopnode.FieldCreatedAt:
  21754. return m.OldCreatedAt(ctx)
  21755. case sopnode.FieldUpdatedAt:
  21756. return m.OldUpdatedAt(ctx)
  21757. case sopnode.FieldStatus:
  21758. return m.OldStatus(ctx)
  21759. case sopnode.FieldDeletedAt:
  21760. return m.OldDeletedAt(ctx)
  21761. case sopnode.FieldStageID:
  21762. return m.OldStageID(ctx)
  21763. case sopnode.FieldParentID:
  21764. return m.OldParentID(ctx)
  21765. case sopnode.FieldName:
  21766. return m.OldName(ctx)
  21767. case sopnode.FieldConditionType:
  21768. return m.OldConditionType(ctx)
  21769. case sopnode.FieldConditionList:
  21770. return m.OldConditionList(ctx)
  21771. case sopnode.FieldNoReplyCondition:
  21772. return m.OldNoReplyCondition(ctx)
  21773. case sopnode.FieldNoReplyUnit:
  21774. return m.OldNoReplyUnit(ctx)
  21775. case sopnode.FieldActionMessage:
  21776. return m.OldActionMessage(ctx)
  21777. case sopnode.FieldActionLabelAdd:
  21778. return m.OldActionLabelAdd(ctx)
  21779. case sopnode.FieldActionLabelDel:
  21780. return m.OldActionLabelDel(ctx)
  21781. case sopnode.FieldActionForward:
  21782. return m.OldActionForward(ctx)
  21783. }
  21784. return nil, fmt.Errorf("unknown SopNode field %s", name)
  21785. }
  21786. // SetField sets the value of a field with the given name. It returns an error if
  21787. // the field is not defined in the schema, or if the type mismatched the field
  21788. // type.
  21789. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  21790. switch name {
  21791. case sopnode.FieldCreatedAt:
  21792. v, ok := value.(time.Time)
  21793. if !ok {
  21794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21795. }
  21796. m.SetCreatedAt(v)
  21797. return nil
  21798. case sopnode.FieldUpdatedAt:
  21799. v, ok := value.(time.Time)
  21800. if !ok {
  21801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21802. }
  21803. m.SetUpdatedAt(v)
  21804. return nil
  21805. case sopnode.FieldStatus:
  21806. v, ok := value.(uint8)
  21807. if !ok {
  21808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21809. }
  21810. m.SetStatus(v)
  21811. return nil
  21812. case sopnode.FieldDeletedAt:
  21813. v, ok := value.(time.Time)
  21814. if !ok {
  21815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21816. }
  21817. m.SetDeletedAt(v)
  21818. return nil
  21819. case sopnode.FieldStageID:
  21820. v, ok := value.(uint64)
  21821. if !ok {
  21822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21823. }
  21824. m.SetStageID(v)
  21825. return nil
  21826. case sopnode.FieldParentID:
  21827. v, ok := value.(uint64)
  21828. if !ok {
  21829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21830. }
  21831. m.SetParentID(v)
  21832. return nil
  21833. case sopnode.FieldName:
  21834. v, ok := value.(string)
  21835. if !ok {
  21836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21837. }
  21838. m.SetName(v)
  21839. return nil
  21840. case sopnode.FieldConditionType:
  21841. v, ok := value.(int)
  21842. if !ok {
  21843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21844. }
  21845. m.SetConditionType(v)
  21846. return nil
  21847. case sopnode.FieldConditionList:
  21848. v, ok := value.([]string)
  21849. if !ok {
  21850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21851. }
  21852. m.SetConditionList(v)
  21853. return nil
  21854. case sopnode.FieldNoReplyCondition:
  21855. v, ok := value.(uint64)
  21856. if !ok {
  21857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21858. }
  21859. m.SetNoReplyCondition(v)
  21860. return nil
  21861. case sopnode.FieldNoReplyUnit:
  21862. v, ok := value.(string)
  21863. if !ok {
  21864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21865. }
  21866. m.SetNoReplyUnit(v)
  21867. return nil
  21868. case sopnode.FieldActionMessage:
  21869. v, ok := value.([]custom_types.Action)
  21870. if !ok {
  21871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21872. }
  21873. m.SetActionMessage(v)
  21874. return nil
  21875. case sopnode.FieldActionLabelAdd:
  21876. v, ok := value.([]uint64)
  21877. if !ok {
  21878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21879. }
  21880. m.SetActionLabelAdd(v)
  21881. return nil
  21882. case sopnode.FieldActionLabelDel:
  21883. v, ok := value.([]uint64)
  21884. if !ok {
  21885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21886. }
  21887. m.SetActionLabelDel(v)
  21888. return nil
  21889. case sopnode.FieldActionForward:
  21890. v, ok := value.(*custom_types.ActionForward)
  21891. if !ok {
  21892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21893. }
  21894. m.SetActionForward(v)
  21895. return nil
  21896. }
  21897. return fmt.Errorf("unknown SopNode field %s", name)
  21898. }
  21899. // AddedFields returns all numeric fields that were incremented/decremented during
  21900. // this mutation.
  21901. func (m *SopNodeMutation) AddedFields() []string {
  21902. var fields []string
  21903. if m.addstatus != nil {
  21904. fields = append(fields, sopnode.FieldStatus)
  21905. }
  21906. if m.addparent_id != nil {
  21907. fields = append(fields, sopnode.FieldParentID)
  21908. }
  21909. if m.addcondition_type != nil {
  21910. fields = append(fields, sopnode.FieldConditionType)
  21911. }
  21912. if m.addno_reply_condition != nil {
  21913. fields = append(fields, sopnode.FieldNoReplyCondition)
  21914. }
  21915. return fields
  21916. }
  21917. // AddedField returns the numeric value that was incremented/decremented on a field
  21918. // with the given name. The second boolean return value indicates that this field
  21919. // was not set, or was not defined in the schema.
  21920. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  21921. switch name {
  21922. case sopnode.FieldStatus:
  21923. return m.AddedStatus()
  21924. case sopnode.FieldParentID:
  21925. return m.AddedParentID()
  21926. case sopnode.FieldConditionType:
  21927. return m.AddedConditionType()
  21928. case sopnode.FieldNoReplyCondition:
  21929. return m.AddedNoReplyCondition()
  21930. }
  21931. return nil, false
  21932. }
  21933. // AddField adds the value to the field with the given name. It returns an error if
  21934. // the field is not defined in the schema, or if the type mismatched the field
  21935. // type.
  21936. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  21937. switch name {
  21938. case sopnode.FieldStatus:
  21939. v, ok := value.(int8)
  21940. if !ok {
  21941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21942. }
  21943. m.AddStatus(v)
  21944. return nil
  21945. case sopnode.FieldParentID:
  21946. v, ok := value.(int64)
  21947. if !ok {
  21948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21949. }
  21950. m.AddParentID(v)
  21951. return nil
  21952. case sopnode.FieldConditionType:
  21953. v, ok := value.(int)
  21954. if !ok {
  21955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21956. }
  21957. m.AddConditionType(v)
  21958. return nil
  21959. case sopnode.FieldNoReplyCondition:
  21960. v, ok := value.(int64)
  21961. if !ok {
  21962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21963. }
  21964. m.AddNoReplyCondition(v)
  21965. return nil
  21966. }
  21967. return fmt.Errorf("unknown SopNode numeric field %s", name)
  21968. }
  21969. // ClearedFields returns all nullable fields that were cleared during this
  21970. // mutation.
  21971. func (m *SopNodeMutation) ClearedFields() []string {
  21972. var fields []string
  21973. if m.FieldCleared(sopnode.FieldStatus) {
  21974. fields = append(fields, sopnode.FieldStatus)
  21975. }
  21976. if m.FieldCleared(sopnode.FieldDeletedAt) {
  21977. fields = append(fields, sopnode.FieldDeletedAt)
  21978. }
  21979. if m.FieldCleared(sopnode.FieldConditionList) {
  21980. fields = append(fields, sopnode.FieldConditionList)
  21981. }
  21982. if m.FieldCleared(sopnode.FieldActionMessage) {
  21983. fields = append(fields, sopnode.FieldActionMessage)
  21984. }
  21985. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  21986. fields = append(fields, sopnode.FieldActionLabelAdd)
  21987. }
  21988. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  21989. fields = append(fields, sopnode.FieldActionLabelDel)
  21990. }
  21991. if m.FieldCleared(sopnode.FieldActionForward) {
  21992. fields = append(fields, sopnode.FieldActionForward)
  21993. }
  21994. return fields
  21995. }
  21996. // FieldCleared returns a boolean indicating if a field with the given name was
  21997. // cleared in this mutation.
  21998. func (m *SopNodeMutation) FieldCleared(name string) bool {
  21999. _, ok := m.clearedFields[name]
  22000. return ok
  22001. }
  22002. // ClearField clears the value of the field with the given name. It returns an
  22003. // error if the field is not defined in the schema.
  22004. func (m *SopNodeMutation) ClearField(name string) error {
  22005. switch name {
  22006. case sopnode.FieldStatus:
  22007. m.ClearStatus()
  22008. return nil
  22009. case sopnode.FieldDeletedAt:
  22010. m.ClearDeletedAt()
  22011. return nil
  22012. case sopnode.FieldConditionList:
  22013. m.ClearConditionList()
  22014. return nil
  22015. case sopnode.FieldActionMessage:
  22016. m.ClearActionMessage()
  22017. return nil
  22018. case sopnode.FieldActionLabelAdd:
  22019. m.ClearActionLabelAdd()
  22020. return nil
  22021. case sopnode.FieldActionLabelDel:
  22022. m.ClearActionLabelDel()
  22023. return nil
  22024. case sopnode.FieldActionForward:
  22025. m.ClearActionForward()
  22026. return nil
  22027. }
  22028. return fmt.Errorf("unknown SopNode nullable field %s", name)
  22029. }
  22030. // ResetField resets all changes in the mutation for the field with the given name.
  22031. // It returns an error if the field is not defined in the schema.
  22032. func (m *SopNodeMutation) ResetField(name string) error {
  22033. switch name {
  22034. case sopnode.FieldCreatedAt:
  22035. m.ResetCreatedAt()
  22036. return nil
  22037. case sopnode.FieldUpdatedAt:
  22038. m.ResetUpdatedAt()
  22039. return nil
  22040. case sopnode.FieldStatus:
  22041. m.ResetStatus()
  22042. return nil
  22043. case sopnode.FieldDeletedAt:
  22044. m.ResetDeletedAt()
  22045. return nil
  22046. case sopnode.FieldStageID:
  22047. m.ResetStageID()
  22048. return nil
  22049. case sopnode.FieldParentID:
  22050. m.ResetParentID()
  22051. return nil
  22052. case sopnode.FieldName:
  22053. m.ResetName()
  22054. return nil
  22055. case sopnode.FieldConditionType:
  22056. m.ResetConditionType()
  22057. return nil
  22058. case sopnode.FieldConditionList:
  22059. m.ResetConditionList()
  22060. return nil
  22061. case sopnode.FieldNoReplyCondition:
  22062. m.ResetNoReplyCondition()
  22063. return nil
  22064. case sopnode.FieldNoReplyUnit:
  22065. m.ResetNoReplyUnit()
  22066. return nil
  22067. case sopnode.FieldActionMessage:
  22068. m.ResetActionMessage()
  22069. return nil
  22070. case sopnode.FieldActionLabelAdd:
  22071. m.ResetActionLabelAdd()
  22072. return nil
  22073. case sopnode.FieldActionLabelDel:
  22074. m.ResetActionLabelDel()
  22075. return nil
  22076. case sopnode.FieldActionForward:
  22077. m.ResetActionForward()
  22078. return nil
  22079. }
  22080. return fmt.Errorf("unknown SopNode field %s", name)
  22081. }
  22082. // AddedEdges returns all edge names that were set/added in this mutation.
  22083. func (m *SopNodeMutation) AddedEdges() []string {
  22084. edges := make([]string, 0, 2)
  22085. if m.sop_stage != nil {
  22086. edges = append(edges, sopnode.EdgeSopStage)
  22087. }
  22088. if m.node_messages != nil {
  22089. edges = append(edges, sopnode.EdgeNodeMessages)
  22090. }
  22091. return edges
  22092. }
  22093. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22094. // name in this mutation.
  22095. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  22096. switch name {
  22097. case sopnode.EdgeSopStage:
  22098. if id := m.sop_stage; id != nil {
  22099. return []ent.Value{*id}
  22100. }
  22101. case sopnode.EdgeNodeMessages:
  22102. ids := make([]ent.Value, 0, len(m.node_messages))
  22103. for id := range m.node_messages {
  22104. ids = append(ids, id)
  22105. }
  22106. return ids
  22107. }
  22108. return nil
  22109. }
  22110. // RemovedEdges returns all edge names that were removed in this mutation.
  22111. func (m *SopNodeMutation) RemovedEdges() []string {
  22112. edges := make([]string, 0, 2)
  22113. if m.removednode_messages != nil {
  22114. edges = append(edges, sopnode.EdgeNodeMessages)
  22115. }
  22116. return edges
  22117. }
  22118. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22119. // the given name in this mutation.
  22120. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  22121. switch name {
  22122. case sopnode.EdgeNodeMessages:
  22123. ids := make([]ent.Value, 0, len(m.removednode_messages))
  22124. for id := range m.removednode_messages {
  22125. ids = append(ids, id)
  22126. }
  22127. return ids
  22128. }
  22129. return nil
  22130. }
  22131. // ClearedEdges returns all edge names that were cleared in this mutation.
  22132. func (m *SopNodeMutation) ClearedEdges() []string {
  22133. edges := make([]string, 0, 2)
  22134. if m.clearedsop_stage {
  22135. edges = append(edges, sopnode.EdgeSopStage)
  22136. }
  22137. if m.clearednode_messages {
  22138. edges = append(edges, sopnode.EdgeNodeMessages)
  22139. }
  22140. return edges
  22141. }
  22142. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22143. // was cleared in this mutation.
  22144. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  22145. switch name {
  22146. case sopnode.EdgeSopStage:
  22147. return m.clearedsop_stage
  22148. case sopnode.EdgeNodeMessages:
  22149. return m.clearednode_messages
  22150. }
  22151. return false
  22152. }
  22153. // ClearEdge clears the value of the edge with the given name. It returns an error
  22154. // if that edge is not defined in the schema.
  22155. func (m *SopNodeMutation) ClearEdge(name string) error {
  22156. switch name {
  22157. case sopnode.EdgeSopStage:
  22158. m.ClearSopStage()
  22159. return nil
  22160. }
  22161. return fmt.Errorf("unknown SopNode unique edge %s", name)
  22162. }
  22163. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22164. // It returns an error if the edge is not defined in the schema.
  22165. func (m *SopNodeMutation) ResetEdge(name string) error {
  22166. switch name {
  22167. case sopnode.EdgeSopStage:
  22168. m.ResetSopStage()
  22169. return nil
  22170. case sopnode.EdgeNodeMessages:
  22171. m.ResetNodeMessages()
  22172. return nil
  22173. }
  22174. return fmt.Errorf("unknown SopNode edge %s", name)
  22175. }
  22176. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  22177. type SopStageMutation struct {
  22178. config
  22179. op Op
  22180. typ string
  22181. id *uint64
  22182. created_at *time.Time
  22183. updated_at *time.Time
  22184. status *uint8
  22185. addstatus *int8
  22186. deleted_at *time.Time
  22187. name *string
  22188. condition_type *int
  22189. addcondition_type *int
  22190. condition_operator *int
  22191. addcondition_operator *int
  22192. condition_list *[]custom_types.Condition
  22193. appendcondition_list []custom_types.Condition
  22194. action_message *[]custom_types.Action
  22195. appendaction_message []custom_types.Action
  22196. action_label_add *[]uint64
  22197. appendaction_label_add []uint64
  22198. action_label_del *[]uint64
  22199. appendaction_label_del []uint64
  22200. action_forward **custom_types.ActionForward
  22201. index_sort *int
  22202. addindex_sort *int
  22203. clearedFields map[string]struct{}
  22204. sop_task *uint64
  22205. clearedsop_task bool
  22206. stage_nodes map[uint64]struct{}
  22207. removedstage_nodes map[uint64]struct{}
  22208. clearedstage_nodes bool
  22209. stage_messages map[uint64]struct{}
  22210. removedstage_messages map[uint64]struct{}
  22211. clearedstage_messages bool
  22212. done bool
  22213. oldValue func(context.Context) (*SopStage, error)
  22214. predicates []predicate.SopStage
  22215. }
  22216. var _ ent.Mutation = (*SopStageMutation)(nil)
  22217. // sopstageOption allows management of the mutation configuration using functional options.
  22218. type sopstageOption func(*SopStageMutation)
  22219. // newSopStageMutation creates new mutation for the SopStage entity.
  22220. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  22221. m := &SopStageMutation{
  22222. config: c,
  22223. op: op,
  22224. typ: TypeSopStage,
  22225. clearedFields: make(map[string]struct{}),
  22226. }
  22227. for _, opt := range opts {
  22228. opt(m)
  22229. }
  22230. return m
  22231. }
  22232. // withSopStageID sets the ID field of the mutation.
  22233. func withSopStageID(id uint64) sopstageOption {
  22234. return func(m *SopStageMutation) {
  22235. var (
  22236. err error
  22237. once sync.Once
  22238. value *SopStage
  22239. )
  22240. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  22241. once.Do(func() {
  22242. if m.done {
  22243. err = errors.New("querying old values post mutation is not allowed")
  22244. } else {
  22245. value, err = m.Client().SopStage.Get(ctx, id)
  22246. }
  22247. })
  22248. return value, err
  22249. }
  22250. m.id = &id
  22251. }
  22252. }
  22253. // withSopStage sets the old SopStage of the mutation.
  22254. func withSopStage(node *SopStage) sopstageOption {
  22255. return func(m *SopStageMutation) {
  22256. m.oldValue = func(context.Context) (*SopStage, error) {
  22257. return node, nil
  22258. }
  22259. m.id = &node.ID
  22260. }
  22261. }
  22262. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22263. // executed in a transaction (ent.Tx), a transactional client is returned.
  22264. func (m SopStageMutation) Client() *Client {
  22265. client := &Client{config: m.config}
  22266. client.init()
  22267. return client
  22268. }
  22269. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22270. // it returns an error otherwise.
  22271. func (m SopStageMutation) Tx() (*Tx, error) {
  22272. if _, ok := m.driver.(*txDriver); !ok {
  22273. return nil, errors.New("ent: mutation is not running in a transaction")
  22274. }
  22275. tx := &Tx{config: m.config}
  22276. tx.init()
  22277. return tx, nil
  22278. }
  22279. // SetID sets the value of the id field. Note that this
  22280. // operation is only accepted on creation of SopStage entities.
  22281. func (m *SopStageMutation) SetID(id uint64) {
  22282. m.id = &id
  22283. }
  22284. // ID returns the ID value in the mutation. Note that the ID is only available
  22285. // if it was provided to the builder or after it was returned from the database.
  22286. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  22287. if m.id == nil {
  22288. return
  22289. }
  22290. return *m.id, true
  22291. }
  22292. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22293. // That means, if the mutation is applied within a transaction with an isolation level such
  22294. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22295. // or updated by the mutation.
  22296. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  22297. switch {
  22298. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22299. id, exists := m.ID()
  22300. if exists {
  22301. return []uint64{id}, nil
  22302. }
  22303. fallthrough
  22304. case m.op.Is(OpUpdate | OpDelete):
  22305. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  22306. default:
  22307. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22308. }
  22309. }
  22310. // SetCreatedAt sets the "created_at" field.
  22311. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  22312. m.created_at = &t
  22313. }
  22314. // CreatedAt returns the value of the "created_at" field in the mutation.
  22315. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  22316. v := m.created_at
  22317. if v == nil {
  22318. return
  22319. }
  22320. return *v, true
  22321. }
  22322. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  22323. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22325. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22326. if !m.op.Is(OpUpdateOne) {
  22327. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22328. }
  22329. if m.id == nil || m.oldValue == nil {
  22330. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22331. }
  22332. oldValue, err := m.oldValue(ctx)
  22333. if err != nil {
  22334. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22335. }
  22336. return oldValue.CreatedAt, nil
  22337. }
  22338. // ResetCreatedAt resets all changes to the "created_at" field.
  22339. func (m *SopStageMutation) ResetCreatedAt() {
  22340. m.created_at = nil
  22341. }
  22342. // SetUpdatedAt sets the "updated_at" field.
  22343. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  22344. m.updated_at = &t
  22345. }
  22346. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22347. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  22348. v := m.updated_at
  22349. if v == nil {
  22350. return
  22351. }
  22352. return *v, true
  22353. }
  22354. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  22355. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22357. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22358. if !m.op.Is(OpUpdateOne) {
  22359. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22360. }
  22361. if m.id == nil || m.oldValue == nil {
  22362. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22363. }
  22364. oldValue, err := m.oldValue(ctx)
  22365. if err != nil {
  22366. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22367. }
  22368. return oldValue.UpdatedAt, nil
  22369. }
  22370. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22371. func (m *SopStageMutation) ResetUpdatedAt() {
  22372. m.updated_at = nil
  22373. }
  22374. // SetStatus sets the "status" field.
  22375. func (m *SopStageMutation) SetStatus(u uint8) {
  22376. m.status = &u
  22377. m.addstatus = nil
  22378. }
  22379. // Status returns the value of the "status" field in the mutation.
  22380. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  22381. v := m.status
  22382. if v == nil {
  22383. return
  22384. }
  22385. return *v, true
  22386. }
  22387. // OldStatus returns the old "status" field's value of the SopStage entity.
  22388. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22390. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22391. if !m.op.Is(OpUpdateOne) {
  22392. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22393. }
  22394. if m.id == nil || m.oldValue == nil {
  22395. return v, errors.New("OldStatus requires an ID field in the mutation")
  22396. }
  22397. oldValue, err := m.oldValue(ctx)
  22398. if err != nil {
  22399. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22400. }
  22401. return oldValue.Status, nil
  22402. }
  22403. // AddStatus adds u to the "status" field.
  22404. func (m *SopStageMutation) AddStatus(u int8) {
  22405. if m.addstatus != nil {
  22406. *m.addstatus += u
  22407. } else {
  22408. m.addstatus = &u
  22409. }
  22410. }
  22411. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22412. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  22413. v := m.addstatus
  22414. if v == nil {
  22415. return
  22416. }
  22417. return *v, true
  22418. }
  22419. // ClearStatus clears the value of the "status" field.
  22420. func (m *SopStageMutation) ClearStatus() {
  22421. m.status = nil
  22422. m.addstatus = nil
  22423. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  22424. }
  22425. // StatusCleared returns if the "status" field was cleared in this mutation.
  22426. func (m *SopStageMutation) StatusCleared() bool {
  22427. _, ok := m.clearedFields[sopstage.FieldStatus]
  22428. return ok
  22429. }
  22430. // ResetStatus resets all changes to the "status" field.
  22431. func (m *SopStageMutation) ResetStatus() {
  22432. m.status = nil
  22433. m.addstatus = nil
  22434. delete(m.clearedFields, sopstage.FieldStatus)
  22435. }
  22436. // SetDeletedAt sets the "deleted_at" field.
  22437. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  22438. m.deleted_at = &t
  22439. }
  22440. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22441. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  22442. v := m.deleted_at
  22443. if v == nil {
  22444. return
  22445. }
  22446. return *v, true
  22447. }
  22448. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  22449. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22451. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22452. if !m.op.Is(OpUpdateOne) {
  22453. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22454. }
  22455. if m.id == nil || m.oldValue == nil {
  22456. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22457. }
  22458. oldValue, err := m.oldValue(ctx)
  22459. if err != nil {
  22460. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22461. }
  22462. return oldValue.DeletedAt, nil
  22463. }
  22464. // ClearDeletedAt clears the value of the "deleted_at" field.
  22465. func (m *SopStageMutation) ClearDeletedAt() {
  22466. m.deleted_at = nil
  22467. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  22468. }
  22469. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22470. func (m *SopStageMutation) DeletedAtCleared() bool {
  22471. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  22472. return ok
  22473. }
  22474. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22475. func (m *SopStageMutation) ResetDeletedAt() {
  22476. m.deleted_at = nil
  22477. delete(m.clearedFields, sopstage.FieldDeletedAt)
  22478. }
  22479. // SetTaskID sets the "task_id" field.
  22480. func (m *SopStageMutation) SetTaskID(u uint64) {
  22481. m.sop_task = &u
  22482. }
  22483. // TaskID returns the value of the "task_id" field in the mutation.
  22484. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  22485. v := m.sop_task
  22486. if v == nil {
  22487. return
  22488. }
  22489. return *v, true
  22490. }
  22491. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  22492. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22494. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  22495. if !m.op.Is(OpUpdateOne) {
  22496. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  22497. }
  22498. if m.id == nil || m.oldValue == nil {
  22499. return v, errors.New("OldTaskID requires an ID field in the mutation")
  22500. }
  22501. oldValue, err := m.oldValue(ctx)
  22502. if err != nil {
  22503. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  22504. }
  22505. return oldValue.TaskID, nil
  22506. }
  22507. // ResetTaskID resets all changes to the "task_id" field.
  22508. func (m *SopStageMutation) ResetTaskID() {
  22509. m.sop_task = nil
  22510. }
  22511. // SetName sets the "name" field.
  22512. func (m *SopStageMutation) SetName(s string) {
  22513. m.name = &s
  22514. }
  22515. // Name returns the value of the "name" field in the mutation.
  22516. func (m *SopStageMutation) Name() (r string, exists bool) {
  22517. v := m.name
  22518. if v == nil {
  22519. return
  22520. }
  22521. return *v, true
  22522. }
  22523. // OldName returns the old "name" field's value of the SopStage entity.
  22524. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22526. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  22527. if !m.op.Is(OpUpdateOne) {
  22528. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22529. }
  22530. if m.id == nil || m.oldValue == nil {
  22531. return v, errors.New("OldName requires an ID field in the mutation")
  22532. }
  22533. oldValue, err := m.oldValue(ctx)
  22534. if err != nil {
  22535. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22536. }
  22537. return oldValue.Name, nil
  22538. }
  22539. // ResetName resets all changes to the "name" field.
  22540. func (m *SopStageMutation) ResetName() {
  22541. m.name = nil
  22542. }
  22543. // SetConditionType sets the "condition_type" field.
  22544. func (m *SopStageMutation) SetConditionType(i int) {
  22545. m.condition_type = &i
  22546. m.addcondition_type = nil
  22547. }
  22548. // ConditionType returns the value of the "condition_type" field in the mutation.
  22549. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  22550. v := m.condition_type
  22551. if v == nil {
  22552. return
  22553. }
  22554. return *v, true
  22555. }
  22556. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  22557. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22559. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22560. if !m.op.Is(OpUpdateOne) {
  22561. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22562. }
  22563. if m.id == nil || m.oldValue == nil {
  22564. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22565. }
  22566. oldValue, err := m.oldValue(ctx)
  22567. if err != nil {
  22568. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22569. }
  22570. return oldValue.ConditionType, nil
  22571. }
  22572. // AddConditionType adds i to the "condition_type" field.
  22573. func (m *SopStageMutation) AddConditionType(i int) {
  22574. if m.addcondition_type != nil {
  22575. *m.addcondition_type += i
  22576. } else {
  22577. m.addcondition_type = &i
  22578. }
  22579. }
  22580. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22581. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  22582. v := m.addcondition_type
  22583. if v == nil {
  22584. return
  22585. }
  22586. return *v, true
  22587. }
  22588. // ResetConditionType resets all changes to the "condition_type" field.
  22589. func (m *SopStageMutation) ResetConditionType() {
  22590. m.condition_type = nil
  22591. m.addcondition_type = nil
  22592. }
  22593. // SetConditionOperator sets the "condition_operator" field.
  22594. func (m *SopStageMutation) SetConditionOperator(i int) {
  22595. m.condition_operator = &i
  22596. m.addcondition_operator = nil
  22597. }
  22598. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  22599. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  22600. v := m.condition_operator
  22601. if v == nil {
  22602. return
  22603. }
  22604. return *v, true
  22605. }
  22606. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  22607. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22609. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  22610. if !m.op.Is(OpUpdateOne) {
  22611. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  22612. }
  22613. if m.id == nil || m.oldValue == nil {
  22614. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  22615. }
  22616. oldValue, err := m.oldValue(ctx)
  22617. if err != nil {
  22618. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  22619. }
  22620. return oldValue.ConditionOperator, nil
  22621. }
  22622. // AddConditionOperator adds i to the "condition_operator" field.
  22623. func (m *SopStageMutation) AddConditionOperator(i int) {
  22624. if m.addcondition_operator != nil {
  22625. *m.addcondition_operator += i
  22626. } else {
  22627. m.addcondition_operator = &i
  22628. }
  22629. }
  22630. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  22631. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  22632. v := m.addcondition_operator
  22633. if v == nil {
  22634. return
  22635. }
  22636. return *v, true
  22637. }
  22638. // ResetConditionOperator resets all changes to the "condition_operator" field.
  22639. func (m *SopStageMutation) ResetConditionOperator() {
  22640. m.condition_operator = nil
  22641. m.addcondition_operator = nil
  22642. }
  22643. // SetConditionList sets the "condition_list" field.
  22644. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  22645. m.condition_list = &ct
  22646. m.appendcondition_list = nil
  22647. }
  22648. // ConditionList returns the value of the "condition_list" field in the mutation.
  22649. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  22650. v := m.condition_list
  22651. if v == nil {
  22652. return
  22653. }
  22654. return *v, true
  22655. }
  22656. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  22657. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22659. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  22660. if !m.op.Is(OpUpdateOne) {
  22661. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22662. }
  22663. if m.id == nil || m.oldValue == nil {
  22664. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22665. }
  22666. oldValue, err := m.oldValue(ctx)
  22667. if err != nil {
  22668. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22669. }
  22670. return oldValue.ConditionList, nil
  22671. }
  22672. // AppendConditionList adds ct to the "condition_list" field.
  22673. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  22674. m.appendcondition_list = append(m.appendcondition_list, ct...)
  22675. }
  22676. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22677. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  22678. if len(m.appendcondition_list) == 0 {
  22679. return nil, false
  22680. }
  22681. return m.appendcondition_list, true
  22682. }
  22683. // ResetConditionList resets all changes to the "condition_list" field.
  22684. func (m *SopStageMutation) ResetConditionList() {
  22685. m.condition_list = nil
  22686. m.appendcondition_list = nil
  22687. }
  22688. // SetActionMessage sets the "action_message" field.
  22689. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  22690. m.action_message = &ct
  22691. m.appendaction_message = nil
  22692. }
  22693. // ActionMessage returns the value of the "action_message" field in the mutation.
  22694. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22695. v := m.action_message
  22696. if v == nil {
  22697. return
  22698. }
  22699. return *v, true
  22700. }
  22701. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  22702. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22704. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22705. if !m.op.Is(OpUpdateOne) {
  22706. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22707. }
  22708. if m.id == nil || m.oldValue == nil {
  22709. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22710. }
  22711. oldValue, err := m.oldValue(ctx)
  22712. if err != nil {
  22713. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22714. }
  22715. return oldValue.ActionMessage, nil
  22716. }
  22717. // AppendActionMessage adds ct to the "action_message" field.
  22718. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  22719. m.appendaction_message = append(m.appendaction_message, ct...)
  22720. }
  22721. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22722. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22723. if len(m.appendaction_message) == 0 {
  22724. return nil, false
  22725. }
  22726. return m.appendaction_message, true
  22727. }
  22728. // ClearActionMessage clears the value of the "action_message" field.
  22729. func (m *SopStageMutation) ClearActionMessage() {
  22730. m.action_message = nil
  22731. m.appendaction_message = nil
  22732. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  22733. }
  22734. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22735. func (m *SopStageMutation) ActionMessageCleared() bool {
  22736. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  22737. return ok
  22738. }
  22739. // ResetActionMessage resets all changes to the "action_message" field.
  22740. func (m *SopStageMutation) ResetActionMessage() {
  22741. m.action_message = nil
  22742. m.appendaction_message = nil
  22743. delete(m.clearedFields, sopstage.FieldActionMessage)
  22744. }
  22745. // SetActionLabelAdd sets the "action_label_add" field.
  22746. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  22747. m.action_label_add = &u
  22748. m.appendaction_label_add = nil
  22749. }
  22750. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22751. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22752. v := m.action_label_add
  22753. if v == nil {
  22754. return
  22755. }
  22756. return *v, true
  22757. }
  22758. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  22759. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22761. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22762. if !m.op.Is(OpUpdateOne) {
  22763. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22764. }
  22765. if m.id == nil || m.oldValue == nil {
  22766. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22767. }
  22768. oldValue, err := m.oldValue(ctx)
  22769. if err != nil {
  22770. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22771. }
  22772. return oldValue.ActionLabelAdd, nil
  22773. }
  22774. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22775. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  22776. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22777. }
  22778. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22779. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22780. if len(m.appendaction_label_add) == 0 {
  22781. return nil, false
  22782. }
  22783. return m.appendaction_label_add, true
  22784. }
  22785. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22786. func (m *SopStageMutation) ClearActionLabelAdd() {
  22787. m.action_label_add = nil
  22788. m.appendaction_label_add = nil
  22789. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  22790. }
  22791. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22792. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  22793. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  22794. return ok
  22795. }
  22796. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22797. func (m *SopStageMutation) ResetActionLabelAdd() {
  22798. m.action_label_add = nil
  22799. m.appendaction_label_add = nil
  22800. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  22801. }
  22802. // SetActionLabelDel sets the "action_label_del" field.
  22803. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  22804. m.action_label_del = &u
  22805. m.appendaction_label_del = nil
  22806. }
  22807. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22808. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  22809. v := m.action_label_del
  22810. if v == nil {
  22811. return
  22812. }
  22813. return *v, true
  22814. }
  22815. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  22816. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22818. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22819. if !m.op.Is(OpUpdateOne) {
  22820. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22821. }
  22822. if m.id == nil || m.oldValue == nil {
  22823. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22824. }
  22825. oldValue, err := m.oldValue(ctx)
  22826. if err != nil {
  22827. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22828. }
  22829. return oldValue.ActionLabelDel, nil
  22830. }
  22831. // AppendActionLabelDel adds u to the "action_label_del" field.
  22832. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  22833. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22834. }
  22835. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22836. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22837. if len(m.appendaction_label_del) == 0 {
  22838. return nil, false
  22839. }
  22840. return m.appendaction_label_del, true
  22841. }
  22842. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22843. func (m *SopStageMutation) ClearActionLabelDel() {
  22844. m.action_label_del = nil
  22845. m.appendaction_label_del = nil
  22846. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  22847. }
  22848. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22849. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  22850. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  22851. return ok
  22852. }
  22853. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22854. func (m *SopStageMutation) ResetActionLabelDel() {
  22855. m.action_label_del = nil
  22856. m.appendaction_label_del = nil
  22857. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  22858. }
  22859. // SetActionForward sets the "action_forward" field.
  22860. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22861. m.action_forward = &ctf
  22862. }
  22863. // ActionForward returns the value of the "action_forward" field in the mutation.
  22864. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22865. v := m.action_forward
  22866. if v == nil {
  22867. return
  22868. }
  22869. return *v, true
  22870. }
  22871. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  22872. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22874. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22875. if !m.op.Is(OpUpdateOne) {
  22876. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22877. }
  22878. if m.id == nil || m.oldValue == nil {
  22879. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22880. }
  22881. oldValue, err := m.oldValue(ctx)
  22882. if err != nil {
  22883. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22884. }
  22885. return oldValue.ActionForward, nil
  22886. }
  22887. // ClearActionForward clears the value of the "action_forward" field.
  22888. func (m *SopStageMutation) ClearActionForward() {
  22889. m.action_forward = nil
  22890. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  22891. }
  22892. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22893. func (m *SopStageMutation) ActionForwardCleared() bool {
  22894. _, ok := m.clearedFields[sopstage.FieldActionForward]
  22895. return ok
  22896. }
  22897. // ResetActionForward resets all changes to the "action_forward" field.
  22898. func (m *SopStageMutation) ResetActionForward() {
  22899. m.action_forward = nil
  22900. delete(m.clearedFields, sopstage.FieldActionForward)
  22901. }
  22902. // SetIndexSort sets the "index_sort" field.
  22903. func (m *SopStageMutation) SetIndexSort(i int) {
  22904. m.index_sort = &i
  22905. m.addindex_sort = nil
  22906. }
  22907. // IndexSort returns the value of the "index_sort" field in the mutation.
  22908. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  22909. v := m.index_sort
  22910. if v == nil {
  22911. return
  22912. }
  22913. return *v, true
  22914. }
  22915. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  22916. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22918. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  22919. if !m.op.Is(OpUpdateOne) {
  22920. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  22921. }
  22922. if m.id == nil || m.oldValue == nil {
  22923. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  22924. }
  22925. oldValue, err := m.oldValue(ctx)
  22926. if err != nil {
  22927. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  22928. }
  22929. return oldValue.IndexSort, nil
  22930. }
  22931. // AddIndexSort adds i to the "index_sort" field.
  22932. func (m *SopStageMutation) AddIndexSort(i int) {
  22933. if m.addindex_sort != nil {
  22934. *m.addindex_sort += i
  22935. } else {
  22936. m.addindex_sort = &i
  22937. }
  22938. }
  22939. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  22940. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  22941. v := m.addindex_sort
  22942. if v == nil {
  22943. return
  22944. }
  22945. return *v, true
  22946. }
  22947. // ClearIndexSort clears the value of the "index_sort" field.
  22948. func (m *SopStageMutation) ClearIndexSort() {
  22949. m.index_sort = nil
  22950. m.addindex_sort = nil
  22951. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  22952. }
  22953. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  22954. func (m *SopStageMutation) IndexSortCleared() bool {
  22955. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  22956. return ok
  22957. }
  22958. // ResetIndexSort resets all changes to the "index_sort" field.
  22959. func (m *SopStageMutation) ResetIndexSort() {
  22960. m.index_sort = nil
  22961. m.addindex_sort = nil
  22962. delete(m.clearedFields, sopstage.FieldIndexSort)
  22963. }
  22964. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  22965. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  22966. m.sop_task = &id
  22967. }
  22968. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  22969. func (m *SopStageMutation) ClearSopTask() {
  22970. m.clearedsop_task = true
  22971. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  22972. }
  22973. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  22974. func (m *SopStageMutation) SopTaskCleared() bool {
  22975. return m.clearedsop_task
  22976. }
  22977. // SopTaskID returns the "sop_task" edge ID in the mutation.
  22978. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  22979. if m.sop_task != nil {
  22980. return *m.sop_task, true
  22981. }
  22982. return
  22983. }
  22984. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  22985. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22986. // SopTaskID instead. It exists only for internal usage by the builders.
  22987. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  22988. if id := m.sop_task; id != nil {
  22989. ids = append(ids, *id)
  22990. }
  22991. return
  22992. }
  22993. // ResetSopTask resets all changes to the "sop_task" edge.
  22994. func (m *SopStageMutation) ResetSopTask() {
  22995. m.sop_task = nil
  22996. m.clearedsop_task = false
  22997. }
  22998. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  22999. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  23000. if m.stage_nodes == nil {
  23001. m.stage_nodes = make(map[uint64]struct{})
  23002. }
  23003. for i := range ids {
  23004. m.stage_nodes[ids[i]] = struct{}{}
  23005. }
  23006. }
  23007. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  23008. func (m *SopStageMutation) ClearStageNodes() {
  23009. m.clearedstage_nodes = true
  23010. }
  23011. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  23012. func (m *SopStageMutation) StageNodesCleared() bool {
  23013. return m.clearedstage_nodes
  23014. }
  23015. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  23016. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  23017. if m.removedstage_nodes == nil {
  23018. m.removedstage_nodes = make(map[uint64]struct{})
  23019. }
  23020. for i := range ids {
  23021. delete(m.stage_nodes, ids[i])
  23022. m.removedstage_nodes[ids[i]] = struct{}{}
  23023. }
  23024. }
  23025. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  23026. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  23027. for id := range m.removedstage_nodes {
  23028. ids = append(ids, id)
  23029. }
  23030. return
  23031. }
  23032. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  23033. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  23034. for id := range m.stage_nodes {
  23035. ids = append(ids, id)
  23036. }
  23037. return
  23038. }
  23039. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  23040. func (m *SopStageMutation) ResetStageNodes() {
  23041. m.stage_nodes = nil
  23042. m.clearedstage_nodes = false
  23043. m.removedstage_nodes = nil
  23044. }
  23045. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  23046. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  23047. if m.stage_messages == nil {
  23048. m.stage_messages = make(map[uint64]struct{})
  23049. }
  23050. for i := range ids {
  23051. m.stage_messages[ids[i]] = struct{}{}
  23052. }
  23053. }
  23054. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  23055. func (m *SopStageMutation) ClearStageMessages() {
  23056. m.clearedstage_messages = true
  23057. }
  23058. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  23059. func (m *SopStageMutation) StageMessagesCleared() bool {
  23060. return m.clearedstage_messages
  23061. }
  23062. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  23063. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  23064. if m.removedstage_messages == nil {
  23065. m.removedstage_messages = make(map[uint64]struct{})
  23066. }
  23067. for i := range ids {
  23068. delete(m.stage_messages, ids[i])
  23069. m.removedstage_messages[ids[i]] = struct{}{}
  23070. }
  23071. }
  23072. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  23073. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  23074. for id := range m.removedstage_messages {
  23075. ids = append(ids, id)
  23076. }
  23077. return
  23078. }
  23079. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  23080. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  23081. for id := range m.stage_messages {
  23082. ids = append(ids, id)
  23083. }
  23084. return
  23085. }
  23086. // ResetStageMessages resets all changes to the "stage_messages" edge.
  23087. func (m *SopStageMutation) ResetStageMessages() {
  23088. m.stage_messages = nil
  23089. m.clearedstage_messages = false
  23090. m.removedstage_messages = nil
  23091. }
  23092. // Where appends a list predicates to the SopStageMutation builder.
  23093. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  23094. m.predicates = append(m.predicates, ps...)
  23095. }
  23096. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  23097. // users can use type-assertion to append predicates that do not depend on any generated package.
  23098. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  23099. p := make([]predicate.SopStage, len(ps))
  23100. for i := range ps {
  23101. p[i] = ps[i]
  23102. }
  23103. m.Where(p...)
  23104. }
  23105. // Op returns the operation name.
  23106. func (m *SopStageMutation) Op() Op {
  23107. return m.op
  23108. }
  23109. // SetOp allows setting the mutation operation.
  23110. func (m *SopStageMutation) SetOp(op Op) {
  23111. m.op = op
  23112. }
  23113. // Type returns the node type of this mutation (SopStage).
  23114. func (m *SopStageMutation) Type() string {
  23115. return m.typ
  23116. }
  23117. // Fields returns all fields that were changed during this mutation. Note that in
  23118. // order to get all numeric fields that were incremented/decremented, call
  23119. // AddedFields().
  23120. func (m *SopStageMutation) Fields() []string {
  23121. fields := make([]string, 0, 14)
  23122. if m.created_at != nil {
  23123. fields = append(fields, sopstage.FieldCreatedAt)
  23124. }
  23125. if m.updated_at != nil {
  23126. fields = append(fields, sopstage.FieldUpdatedAt)
  23127. }
  23128. if m.status != nil {
  23129. fields = append(fields, sopstage.FieldStatus)
  23130. }
  23131. if m.deleted_at != nil {
  23132. fields = append(fields, sopstage.FieldDeletedAt)
  23133. }
  23134. if m.sop_task != nil {
  23135. fields = append(fields, sopstage.FieldTaskID)
  23136. }
  23137. if m.name != nil {
  23138. fields = append(fields, sopstage.FieldName)
  23139. }
  23140. if m.condition_type != nil {
  23141. fields = append(fields, sopstage.FieldConditionType)
  23142. }
  23143. if m.condition_operator != nil {
  23144. fields = append(fields, sopstage.FieldConditionOperator)
  23145. }
  23146. if m.condition_list != nil {
  23147. fields = append(fields, sopstage.FieldConditionList)
  23148. }
  23149. if m.action_message != nil {
  23150. fields = append(fields, sopstage.FieldActionMessage)
  23151. }
  23152. if m.action_label_add != nil {
  23153. fields = append(fields, sopstage.FieldActionLabelAdd)
  23154. }
  23155. if m.action_label_del != nil {
  23156. fields = append(fields, sopstage.FieldActionLabelDel)
  23157. }
  23158. if m.action_forward != nil {
  23159. fields = append(fields, sopstage.FieldActionForward)
  23160. }
  23161. if m.index_sort != nil {
  23162. fields = append(fields, sopstage.FieldIndexSort)
  23163. }
  23164. return fields
  23165. }
  23166. // Field returns the value of a field with the given name. The second boolean
  23167. // return value indicates that this field was not set, or was not defined in the
  23168. // schema.
  23169. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  23170. switch name {
  23171. case sopstage.FieldCreatedAt:
  23172. return m.CreatedAt()
  23173. case sopstage.FieldUpdatedAt:
  23174. return m.UpdatedAt()
  23175. case sopstage.FieldStatus:
  23176. return m.Status()
  23177. case sopstage.FieldDeletedAt:
  23178. return m.DeletedAt()
  23179. case sopstage.FieldTaskID:
  23180. return m.TaskID()
  23181. case sopstage.FieldName:
  23182. return m.Name()
  23183. case sopstage.FieldConditionType:
  23184. return m.ConditionType()
  23185. case sopstage.FieldConditionOperator:
  23186. return m.ConditionOperator()
  23187. case sopstage.FieldConditionList:
  23188. return m.ConditionList()
  23189. case sopstage.FieldActionMessage:
  23190. return m.ActionMessage()
  23191. case sopstage.FieldActionLabelAdd:
  23192. return m.ActionLabelAdd()
  23193. case sopstage.FieldActionLabelDel:
  23194. return m.ActionLabelDel()
  23195. case sopstage.FieldActionForward:
  23196. return m.ActionForward()
  23197. case sopstage.FieldIndexSort:
  23198. return m.IndexSort()
  23199. }
  23200. return nil, false
  23201. }
  23202. // OldField returns the old value of the field from the database. An error is
  23203. // returned if the mutation operation is not UpdateOne, or the query to the
  23204. // database failed.
  23205. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23206. switch name {
  23207. case sopstage.FieldCreatedAt:
  23208. return m.OldCreatedAt(ctx)
  23209. case sopstage.FieldUpdatedAt:
  23210. return m.OldUpdatedAt(ctx)
  23211. case sopstage.FieldStatus:
  23212. return m.OldStatus(ctx)
  23213. case sopstage.FieldDeletedAt:
  23214. return m.OldDeletedAt(ctx)
  23215. case sopstage.FieldTaskID:
  23216. return m.OldTaskID(ctx)
  23217. case sopstage.FieldName:
  23218. return m.OldName(ctx)
  23219. case sopstage.FieldConditionType:
  23220. return m.OldConditionType(ctx)
  23221. case sopstage.FieldConditionOperator:
  23222. return m.OldConditionOperator(ctx)
  23223. case sopstage.FieldConditionList:
  23224. return m.OldConditionList(ctx)
  23225. case sopstage.FieldActionMessage:
  23226. return m.OldActionMessage(ctx)
  23227. case sopstage.FieldActionLabelAdd:
  23228. return m.OldActionLabelAdd(ctx)
  23229. case sopstage.FieldActionLabelDel:
  23230. return m.OldActionLabelDel(ctx)
  23231. case sopstage.FieldActionForward:
  23232. return m.OldActionForward(ctx)
  23233. case sopstage.FieldIndexSort:
  23234. return m.OldIndexSort(ctx)
  23235. }
  23236. return nil, fmt.Errorf("unknown SopStage field %s", name)
  23237. }
  23238. // SetField sets the value of a field with the given name. It returns an error if
  23239. // the field is not defined in the schema, or if the type mismatched the field
  23240. // type.
  23241. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  23242. switch name {
  23243. case sopstage.FieldCreatedAt:
  23244. v, ok := value.(time.Time)
  23245. if !ok {
  23246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23247. }
  23248. m.SetCreatedAt(v)
  23249. return nil
  23250. case sopstage.FieldUpdatedAt:
  23251. v, ok := value.(time.Time)
  23252. if !ok {
  23253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23254. }
  23255. m.SetUpdatedAt(v)
  23256. return nil
  23257. case sopstage.FieldStatus:
  23258. v, ok := value.(uint8)
  23259. if !ok {
  23260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23261. }
  23262. m.SetStatus(v)
  23263. return nil
  23264. case sopstage.FieldDeletedAt:
  23265. v, ok := value.(time.Time)
  23266. if !ok {
  23267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23268. }
  23269. m.SetDeletedAt(v)
  23270. return nil
  23271. case sopstage.FieldTaskID:
  23272. v, ok := value.(uint64)
  23273. if !ok {
  23274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23275. }
  23276. m.SetTaskID(v)
  23277. return nil
  23278. case sopstage.FieldName:
  23279. v, ok := value.(string)
  23280. if !ok {
  23281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23282. }
  23283. m.SetName(v)
  23284. return nil
  23285. case sopstage.FieldConditionType:
  23286. v, ok := value.(int)
  23287. if !ok {
  23288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23289. }
  23290. m.SetConditionType(v)
  23291. return nil
  23292. case sopstage.FieldConditionOperator:
  23293. v, ok := value.(int)
  23294. if !ok {
  23295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23296. }
  23297. m.SetConditionOperator(v)
  23298. return nil
  23299. case sopstage.FieldConditionList:
  23300. v, ok := value.([]custom_types.Condition)
  23301. if !ok {
  23302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23303. }
  23304. m.SetConditionList(v)
  23305. return nil
  23306. case sopstage.FieldActionMessage:
  23307. v, ok := value.([]custom_types.Action)
  23308. if !ok {
  23309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23310. }
  23311. m.SetActionMessage(v)
  23312. return nil
  23313. case sopstage.FieldActionLabelAdd:
  23314. v, ok := value.([]uint64)
  23315. if !ok {
  23316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23317. }
  23318. m.SetActionLabelAdd(v)
  23319. return nil
  23320. case sopstage.FieldActionLabelDel:
  23321. v, ok := value.([]uint64)
  23322. if !ok {
  23323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23324. }
  23325. m.SetActionLabelDel(v)
  23326. return nil
  23327. case sopstage.FieldActionForward:
  23328. v, ok := value.(*custom_types.ActionForward)
  23329. if !ok {
  23330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23331. }
  23332. m.SetActionForward(v)
  23333. return nil
  23334. case sopstage.FieldIndexSort:
  23335. v, ok := value.(int)
  23336. if !ok {
  23337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23338. }
  23339. m.SetIndexSort(v)
  23340. return nil
  23341. }
  23342. return fmt.Errorf("unknown SopStage field %s", name)
  23343. }
  23344. // AddedFields returns all numeric fields that were incremented/decremented during
  23345. // this mutation.
  23346. func (m *SopStageMutation) AddedFields() []string {
  23347. var fields []string
  23348. if m.addstatus != nil {
  23349. fields = append(fields, sopstage.FieldStatus)
  23350. }
  23351. if m.addcondition_type != nil {
  23352. fields = append(fields, sopstage.FieldConditionType)
  23353. }
  23354. if m.addcondition_operator != nil {
  23355. fields = append(fields, sopstage.FieldConditionOperator)
  23356. }
  23357. if m.addindex_sort != nil {
  23358. fields = append(fields, sopstage.FieldIndexSort)
  23359. }
  23360. return fields
  23361. }
  23362. // AddedField returns the numeric value that was incremented/decremented on a field
  23363. // with the given name. The second boolean return value indicates that this field
  23364. // was not set, or was not defined in the schema.
  23365. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  23366. switch name {
  23367. case sopstage.FieldStatus:
  23368. return m.AddedStatus()
  23369. case sopstage.FieldConditionType:
  23370. return m.AddedConditionType()
  23371. case sopstage.FieldConditionOperator:
  23372. return m.AddedConditionOperator()
  23373. case sopstage.FieldIndexSort:
  23374. return m.AddedIndexSort()
  23375. }
  23376. return nil, false
  23377. }
  23378. // AddField adds the value to the field with the given name. It returns an error if
  23379. // the field is not defined in the schema, or if the type mismatched the field
  23380. // type.
  23381. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  23382. switch name {
  23383. case sopstage.FieldStatus:
  23384. v, ok := value.(int8)
  23385. if !ok {
  23386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23387. }
  23388. m.AddStatus(v)
  23389. return nil
  23390. case sopstage.FieldConditionType:
  23391. v, ok := value.(int)
  23392. if !ok {
  23393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23394. }
  23395. m.AddConditionType(v)
  23396. return nil
  23397. case sopstage.FieldConditionOperator:
  23398. v, ok := value.(int)
  23399. if !ok {
  23400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23401. }
  23402. m.AddConditionOperator(v)
  23403. return nil
  23404. case sopstage.FieldIndexSort:
  23405. v, ok := value.(int)
  23406. if !ok {
  23407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23408. }
  23409. m.AddIndexSort(v)
  23410. return nil
  23411. }
  23412. return fmt.Errorf("unknown SopStage numeric field %s", name)
  23413. }
  23414. // ClearedFields returns all nullable fields that were cleared during this
  23415. // mutation.
  23416. func (m *SopStageMutation) ClearedFields() []string {
  23417. var fields []string
  23418. if m.FieldCleared(sopstage.FieldStatus) {
  23419. fields = append(fields, sopstage.FieldStatus)
  23420. }
  23421. if m.FieldCleared(sopstage.FieldDeletedAt) {
  23422. fields = append(fields, sopstage.FieldDeletedAt)
  23423. }
  23424. if m.FieldCleared(sopstage.FieldActionMessage) {
  23425. fields = append(fields, sopstage.FieldActionMessage)
  23426. }
  23427. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  23428. fields = append(fields, sopstage.FieldActionLabelAdd)
  23429. }
  23430. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  23431. fields = append(fields, sopstage.FieldActionLabelDel)
  23432. }
  23433. if m.FieldCleared(sopstage.FieldActionForward) {
  23434. fields = append(fields, sopstage.FieldActionForward)
  23435. }
  23436. if m.FieldCleared(sopstage.FieldIndexSort) {
  23437. fields = append(fields, sopstage.FieldIndexSort)
  23438. }
  23439. return fields
  23440. }
  23441. // FieldCleared returns a boolean indicating if a field with the given name was
  23442. // cleared in this mutation.
  23443. func (m *SopStageMutation) FieldCleared(name string) bool {
  23444. _, ok := m.clearedFields[name]
  23445. return ok
  23446. }
  23447. // ClearField clears the value of the field with the given name. It returns an
  23448. // error if the field is not defined in the schema.
  23449. func (m *SopStageMutation) ClearField(name string) error {
  23450. switch name {
  23451. case sopstage.FieldStatus:
  23452. m.ClearStatus()
  23453. return nil
  23454. case sopstage.FieldDeletedAt:
  23455. m.ClearDeletedAt()
  23456. return nil
  23457. case sopstage.FieldActionMessage:
  23458. m.ClearActionMessage()
  23459. return nil
  23460. case sopstage.FieldActionLabelAdd:
  23461. m.ClearActionLabelAdd()
  23462. return nil
  23463. case sopstage.FieldActionLabelDel:
  23464. m.ClearActionLabelDel()
  23465. return nil
  23466. case sopstage.FieldActionForward:
  23467. m.ClearActionForward()
  23468. return nil
  23469. case sopstage.FieldIndexSort:
  23470. m.ClearIndexSort()
  23471. return nil
  23472. }
  23473. return fmt.Errorf("unknown SopStage nullable field %s", name)
  23474. }
  23475. // ResetField resets all changes in the mutation for the field with the given name.
  23476. // It returns an error if the field is not defined in the schema.
  23477. func (m *SopStageMutation) ResetField(name string) error {
  23478. switch name {
  23479. case sopstage.FieldCreatedAt:
  23480. m.ResetCreatedAt()
  23481. return nil
  23482. case sopstage.FieldUpdatedAt:
  23483. m.ResetUpdatedAt()
  23484. return nil
  23485. case sopstage.FieldStatus:
  23486. m.ResetStatus()
  23487. return nil
  23488. case sopstage.FieldDeletedAt:
  23489. m.ResetDeletedAt()
  23490. return nil
  23491. case sopstage.FieldTaskID:
  23492. m.ResetTaskID()
  23493. return nil
  23494. case sopstage.FieldName:
  23495. m.ResetName()
  23496. return nil
  23497. case sopstage.FieldConditionType:
  23498. m.ResetConditionType()
  23499. return nil
  23500. case sopstage.FieldConditionOperator:
  23501. m.ResetConditionOperator()
  23502. return nil
  23503. case sopstage.FieldConditionList:
  23504. m.ResetConditionList()
  23505. return nil
  23506. case sopstage.FieldActionMessage:
  23507. m.ResetActionMessage()
  23508. return nil
  23509. case sopstage.FieldActionLabelAdd:
  23510. m.ResetActionLabelAdd()
  23511. return nil
  23512. case sopstage.FieldActionLabelDel:
  23513. m.ResetActionLabelDel()
  23514. return nil
  23515. case sopstage.FieldActionForward:
  23516. m.ResetActionForward()
  23517. return nil
  23518. case sopstage.FieldIndexSort:
  23519. m.ResetIndexSort()
  23520. return nil
  23521. }
  23522. return fmt.Errorf("unknown SopStage field %s", name)
  23523. }
  23524. // AddedEdges returns all edge names that were set/added in this mutation.
  23525. func (m *SopStageMutation) AddedEdges() []string {
  23526. edges := make([]string, 0, 3)
  23527. if m.sop_task != nil {
  23528. edges = append(edges, sopstage.EdgeSopTask)
  23529. }
  23530. if m.stage_nodes != nil {
  23531. edges = append(edges, sopstage.EdgeStageNodes)
  23532. }
  23533. if m.stage_messages != nil {
  23534. edges = append(edges, sopstage.EdgeStageMessages)
  23535. }
  23536. return edges
  23537. }
  23538. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23539. // name in this mutation.
  23540. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  23541. switch name {
  23542. case sopstage.EdgeSopTask:
  23543. if id := m.sop_task; id != nil {
  23544. return []ent.Value{*id}
  23545. }
  23546. case sopstage.EdgeStageNodes:
  23547. ids := make([]ent.Value, 0, len(m.stage_nodes))
  23548. for id := range m.stage_nodes {
  23549. ids = append(ids, id)
  23550. }
  23551. return ids
  23552. case sopstage.EdgeStageMessages:
  23553. ids := make([]ent.Value, 0, len(m.stage_messages))
  23554. for id := range m.stage_messages {
  23555. ids = append(ids, id)
  23556. }
  23557. return ids
  23558. }
  23559. return nil
  23560. }
  23561. // RemovedEdges returns all edge names that were removed in this mutation.
  23562. func (m *SopStageMutation) RemovedEdges() []string {
  23563. edges := make([]string, 0, 3)
  23564. if m.removedstage_nodes != nil {
  23565. edges = append(edges, sopstage.EdgeStageNodes)
  23566. }
  23567. if m.removedstage_messages != nil {
  23568. edges = append(edges, sopstage.EdgeStageMessages)
  23569. }
  23570. return edges
  23571. }
  23572. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23573. // the given name in this mutation.
  23574. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  23575. switch name {
  23576. case sopstage.EdgeStageNodes:
  23577. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  23578. for id := range m.removedstage_nodes {
  23579. ids = append(ids, id)
  23580. }
  23581. return ids
  23582. case sopstage.EdgeStageMessages:
  23583. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  23584. for id := range m.removedstage_messages {
  23585. ids = append(ids, id)
  23586. }
  23587. return ids
  23588. }
  23589. return nil
  23590. }
  23591. // ClearedEdges returns all edge names that were cleared in this mutation.
  23592. func (m *SopStageMutation) ClearedEdges() []string {
  23593. edges := make([]string, 0, 3)
  23594. if m.clearedsop_task {
  23595. edges = append(edges, sopstage.EdgeSopTask)
  23596. }
  23597. if m.clearedstage_nodes {
  23598. edges = append(edges, sopstage.EdgeStageNodes)
  23599. }
  23600. if m.clearedstage_messages {
  23601. edges = append(edges, sopstage.EdgeStageMessages)
  23602. }
  23603. return edges
  23604. }
  23605. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23606. // was cleared in this mutation.
  23607. func (m *SopStageMutation) EdgeCleared(name string) bool {
  23608. switch name {
  23609. case sopstage.EdgeSopTask:
  23610. return m.clearedsop_task
  23611. case sopstage.EdgeStageNodes:
  23612. return m.clearedstage_nodes
  23613. case sopstage.EdgeStageMessages:
  23614. return m.clearedstage_messages
  23615. }
  23616. return false
  23617. }
  23618. // ClearEdge clears the value of the edge with the given name. It returns an error
  23619. // if that edge is not defined in the schema.
  23620. func (m *SopStageMutation) ClearEdge(name string) error {
  23621. switch name {
  23622. case sopstage.EdgeSopTask:
  23623. m.ClearSopTask()
  23624. return nil
  23625. }
  23626. return fmt.Errorf("unknown SopStage unique edge %s", name)
  23627. }
  23628. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23629. // It returns an error if the edge is not defined in the schema.
  23630. func (m *SopStageMutation) ResetEdge(name string) error {
  23631. switch name {
  23632. case sopstage.EdgeSopTask:
  23633. m.ResetSopTask()
  23634. return nil
  23635. case sopstage.EdgeStageNodes:
  23636. m.ResetStageNodes()
  23637. return nil
  23638. case sopstage.EdgeStageMessages:
  23639. m.ResetStageMessages()
  23640. return nil
  23641. }
  23642. return fmt.Errorf("unknown SopStage edge %s", name)
  23643. }
  23644. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  23645. type SopTaskMutation struct {
  23646. config
  23647. op Op
  23648. typ string
  23649. id *uint64
  23650. created_at *time.Time
  23651. updated_at *time.Time
  23652. status *uint8
  23653. addstatus *int8
  23654. deleted_at *time.Time
  23655. name *string
  23656. bot_wxid_list *[]string
  23657. appendbot_wxid_list []string
  23658. _type *int
  23659. add_type *int
  23660. plan_start_time *time.Time
  23661. plan_end_time *time.Time
  23662. creator_id *string
  23663. organization_id *uint64
  23664. addorganization_id *int64
  23665. token *[]string
  23666. appendtoken []string
  23667. clearedFields map[string]struct{}
  23668. task_stages map[uint64]struct{}
  23669. removedtask_stages map[uint64]struct{}
  23670. clearedtask_stages bool
  23671. done bool
  23672. oldValue func(context.Context) (*SopTask, error)
  23673. predicates []predicate.SopTask
  23674. }
  23675. var _ ent.Mutation = (*SopTaskMutation)(nil)
  23676. // soptaskOption allows management of the mutation configuration using functional options.
  23677. type soptaskOption func(*SopTaskMutation)
  23678. // newSopTaskMutation creates new mutation for the SopTask entity.
  23679. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  23680. m := &SopTaskMutation{
  23681. config: c,
  23682. op: op,
  23683. typ: TypeSopTask,
  23684. clearedFields: make(map[string]struct{}),
  23685. }
  23686. for _, opt := range opts {
  23687. opt(m)
  23688. }
  23689. return m
  23690. }
  23691. // withSopTaskID sets the ID field of the mutation.
  23692. func withSopTaskID(id uint64) soptaskOption {
  23693. return func(m *SopTaskMutation) {
  23694. var (
  23695. err error
  23696. once sync.Once
  23697. value *SopTask
  23698. )
  23699. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  23700. once.Do(func() {
  23701. if m.done {
  23702. err = errors.New("querying old values post mutation is not allowed")
  23703. } else {
  23704. value, err = m.Client().SopTask.Get(ctx, id)
  23705. }
  23706. })
  23707. return value, err
  23708. }
  23709. m.id = &id
  23710. }
  23711. }
  23712. // withSopTask sets the old SopTask of the mutation.
  23713. func withSopTask(node *SopTask) soptaskOption {
  23714. return func(m *SopTaskMutation) {
  23715. m.oldValue = func(context.Context) (*SopTask, error) {
  23716. return node, nil
  23717. }
  23718. m.id = &node.ID
  23719. }
  23720. }
  23721. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23722. // executed in a transaction (ent.Tx), a transactional client is returned.
  23723. func (m SopTaskMutation) Client() *Client {
  23724. client := &Client{config: m.config}
  23725. client.init()
  23726. return client
  23727. }
  23728. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23729. // it returns an error otherwise.
  23730. func (m SopTaskMutation) Tx() (*Tx, error) {
  23731. if _, ok := m.driver.(*txDriver); !ok {
  23732. return nil, errors.New("ent: mutation is not running in a transaction")
  23733. }
  23734. tx := &Tx{config: m.config}
  23735. tx.init()
  23736. return tx, nil
  23737. }
  23738. // SetID sets the value of the id field. Note that this
  23739. // operation is only accepted on creation of SopTask entities.
  23740. func (m *SopTaskMutation) SetID(id uint64) {
  23741. m.id = &id
  23742. }
  23743. // ID returns the ID value in the mutation. Note that the ID is only available
  23744. // if it was provided to the builder or after it was returned from the database.
  23745. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  23746. if m.id == nil {
  23747. return
  23748. }
  23749. return *m.id, true
  23750. }
  23751. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23752. // That means, if the mutation is applied within a transaction with an isolation level such
  23753. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23754. // or updated by the mutation.
  23755. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  23756. switch {
  23757. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23758. id, exists := m.ID()
  23759. if exists {
  23760. return []uint64{id}, nil
  23761. }
  23762. fallthrough
  23763. case m.op.Is(OpUpdate | OpDelete):
  23764. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  23765. default:
  23766. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23767. }
  23768. }
  23769. // SetCreatedAt sets the "created_at" field.
  23770. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  23771. m.created_at = &t
  23772. }
  23773. // CreatedAt returns the value of the "created_at" field in the mutation.
  23774. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  23775. v := m.created_at
  23776. if v == nil {
  23777. return
  23778. }
  23779. return *v, true
  23780. }
  23781. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  23782. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23784. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23785. if !m.op.Is(OpUpdateOne) {
  23786. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23787. }
  23788. if m.id == nil || m.oldValue == nil {
  23789. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23790. }
  23791. oldValue, err := m.oldValue(ctx)
  23792. if err != nil {
  23793. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23794. }
  23795. return oldValue.CreatedAt, nil
  23796. }
  23797. // ResetCreatedAt resets all changes to the "created_at" field.
  23798. func (m *SopTaskMutation) ResetCreatedAt() {
  23799. m.created_at = nil
  23800. }
  23801. // SetUpdatedAt sets the "updated_at" field.
  23802. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  23803. m.updated_at = &t
  23804. }
  23805. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23806. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  23807. v := m.updated_at
  23808. if v == nil {
  23809. return
  23810. }
  23811. return *v, true
  23812. }
  23813. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  23814. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23816. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23817. if !m.op.Is(OpUpdateOne) {
  23818. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23819. }
  23820. if m.id == nil || m.oldValue == nil {
  23821. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23822. }
  23823. oldValue, err := m.oldValue(ctx)
  23824. if err != nil {
  23825. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23826. }
  23827. return oldValue.UpdatedAt, nil
  23828. }
  23829. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23830. func (m *SopTaskMutation) ResetUpdatedAt() {
  23831. m.updated_at = nil
  23832. }
  23833. // SetStatus sets the "status" field.
  23834. func (m *SopTaskMutation) SetStatus(u uint8) {
  23835. m.status = &u
  23836. m.addstatus = nil
  23837. }
  23838. // Status returns the value of the "status" field in the mutation.
  23839. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  23840. v := m.status
  23841. if v == nil {
  23842. return
  23843. }
  23844. return *v, true
  23845. }
  23846. // OldStatus returns the old "status" field's value of the SopTask entity.
  23847. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23849. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23850. if !m.op.Is(OpUpdateOne) {
  23851. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23852. }
  23853. if m.id == nil || m.oldValue == nil {
  23854. return v, errors.New("OldStatus requires an ID field in the mutation")
  23855. }
  23856. oldValue, err := m.oldValue(ctx)
  23857. if err != nil {
  23858. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23859. }
  23860. return oldValue.Status, nil
  23861. }
  23862. // AddStatus adds u to the "status" field.
  23863. func (m *SopTaskMutation) AddStatus(u int8) {
  23864. if m.addstatus != nil {
  23865. *m.addstatus += u
  23866. } else {
  23867. m.addstatus = &u
  23868. }
  23869. }
  23870. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23871. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  23872. v := m.addstatus
  23873. if v == nil {
  23874. return
  23875. }
  23876. return *v, true
  23877. }
  23878. // ClearStatus clears the value of the "status" field.
  23879. func (m *SopTaskMutation) ClearStatus() {
  23880. m.status = nil
  23881. m.addstatus = nil
  23882. m.clearedFields[soptask.FieldStatus] = struct{}{}
  23883. }
  23884. // StatusCleared returns if the "status" field was cleared in this mutation.
  23885. func (m *SopTaskMutation) StatusCleared() bool {
  23886. _, ok := m.clearedFields[soptask.FieldStatus]
  23887. return ok
  23888. }
  23889. // ResetStatus resets all changes to the "status" field.
  23890. func (m *SopTaskMutation) ResetStatus() {
  23891. m.status = nil
  23892. m.addstatus = nil
  23893. delete(m.clearedFields, soptask.FieldStatus)
  23894. }
  23895. // SetDeletedAt sets the "deleted_at" field.
  23896. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  23897. m.deleted_at = &t
  23898. }
  23899. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23900. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  23901. v := m.deleted_at
  23902. if v == nil {
  23903. return
  23904. }
  23905. return *v, true
  23906. }
  23907. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  23908. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23910. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23911. if !m.op.Is(OpUpdateOne) {
  23912. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23913. }
  23914. if m.id == nil || m.oldValue == nil {
  23915. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23916. }
  23917. oldValue, err := m.oldValue(ctx)
  23918. if err != nil {
  23919. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23920. }
  23921. return oldValue.DeletedAt, nil
  23922. }
  23923. // ClearDeletedAt clears the value of the "deleted_at" field.
  23924. func (m *SopTaskMutation) ClearDeletedAt() {
  23925. m.deleted_at = nil
  23926. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  23927. }
  23928. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23929. func (m *SopTaskMutation) DeletedAtCleared() bool {
  23930. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  23931. return ok
  23932. }
  23933. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23934. func (m *SopTaskMutation) ResetDeletedAt() {
  23935. m.deleted_at = nil
  23936. delete(m.clearedFields, soptask.FieldDeletedAt)
  23937. }
  23938. // SetName sets the "name" field.
  23939. func (m *SopTaskMutation) SetName(s string) {
  23940. m.name = &s
  23941. }
  23942. // Name returns the value of the "name" field in the mutation.
  23943. func (m *SopTaskMutation) Name() (r string, exists bool) {
  23944. v := m.name
  23945. if v == nil {
  23946. return
  23947. }
  23948. return *v, true
  23949. }
  23950. // OldName returns the old "name" field's value of the SopTask entity.
  23951. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23953. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  23954. if !m.op.Is(OpUpdateOne) {
  23955. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23956. }
  23957. if m.id == nil || m.oldValue == nil {
  23958. return v, errors.New("OldName requires an ID field in the mutation")
  23959. }
  23960. oldValue, err := m.oldValue(ctx)
  23961. if err != nil {
  23962. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23963. }
  23964. return oldValue.Name, nil
  23965. }
  23966. // ResetName resets all changes to the "name" field.
  23967. func (m *SopTaskMutation) ResetName() {
  23968. m.name = nil
  23969. }
  23970. // SetBotWxidList sets the "bot_wxid_list" field.
  23971. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  23972. m.bot_wxid_list = &s
  23973. m.appendbot_wxid_list = nil
  23974. }
  23975. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  23976. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  23977. v := m.bot_wxid_list
  23978. if v == nil {
  23979. return
  23980. }
  23981. return *v, true
  23982. }
  23983. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  23984. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23986. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  23987. if !m.op.Is(OpUpdateOne) {
  23988. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  23989. }
  23990. if m.id == nil || m.oldValue == nil {
  23991. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  23992. }
  23993. oldValue, err := m.oldValue(ctx)
  23994. if err != nil {
  23995. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  23996. }
  23997. return oldValue.BotWxidList, nil
  23998. }
  23999. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  24000. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  24001. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  24002. }
  24003. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  24004. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  24005. if len(m.appendbot_wxid_list) == 0 {
  24006. return nil, false
  24007. }
  24008. return m.appendbot_wxid_list, true
  24009. }
  24010. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  24011. func (m *SopTaskMutation) ClearBotWxidList() {
  24012. m.bot_wxid_list = nil
  24013. m.appendbot_wxid_list = nil
  24014. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  24015. }
  24016. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  24017. func (m *SopTaskMutation) BotWxidListCleared() bool {
  24018. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  24019. return ok
  24020. }
  24021. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  24022. func (m *SopTaskMutation) ResetBotWxidList() {
  24023. m.bot_wxid_list = nil
  24024. m.appendbot_wxid_list = nil
  24025. delete(m.clearedFields, soptask.FieldBotWxidList)
  24026. }
  24027. // SetType sets the "type" field.
  24028. func (m *SopTaskMutation) SetType(i int) {
  24029. m._type = &i
  24030. m.add_type = nil
  24031. }
  24032. // GetType returns the value of the "type" field in the mutation.
  24033. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  24034. v := m._type
  24035. if v == nil {
  24036. return
  24037. }
  24038. return *v, true
  24039. }
  24040. // OldType returns the old "type" field's value of the SopTask entity.
  24041. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24043. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  24044. if !m.op.Is(OpUpdateOne) {
  24045. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24046. }
  24047. if m.id == nil || m.oldValue == nil {
  24048. return v, errors.New("OldType requires an ID field in the mutation")
  24049. }
  24050. oldValue, err := m.oldValue(ctx)
  24051. if err != nil {
  24052. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24053. }
  24054. return oldValue.Type, nil
  24055. }
  24056. // AddType adds i to the "type" field.
  24057. func (m *SopTaskMutation) AddType(i int) {
  24058. if m.add_type != nil {
  24059. *m.add_type += i
  24060. } else {
  24061. m.add_type = &i
  24062. }
  24063. }
  24064. // AddedType returns the value that was added to the "type" field in this mutation.
  24065. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  24066. v := m.add_type
  24067. if v == nil {
  24068. return
  24069. }
  24070. return *v, true
  24071. }
  24072. // ResetType resets all changes to the "type" field.
  24073. func (m *SopTaskMutation) ResetType() {
  24074. m._type = nil
  24075. m.add_type = nil
  24076. }
  24077. // SetPlanStartTime sets the "plan_start_time" field.
  24078. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  24079. m.plan_start_time = &t
  24080. }
  24081. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  24082. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  24083. v := m.plan_start_time
  24084. if v == nil {
  24085. return
  24086. }
  24087. return *v, true
  24088. }
  24089. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  24090. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24092. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  24093. if !m.op.Is(OpUpdateOne) {
  24094. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  24095. }
  24096. if m.id == nil || m.oldValue == nil {
  24097. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  24098. }
  24099. oldValue, err := m.oldValue(ctx)
  24100. if err != nil {
  24101. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  24102. }
  24103. return oldValue.PlanStartTime, nil
  24104. }
  24105. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  24106. func (m *SopTaskMutation) ClearPlanStartTime() {
  24107. m.plan_start_time = nil
  24108. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  24109. }
  24110. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  24111. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  24112. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  24113. return ok
  24114. }
  24115. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  24116. func (m *SopTaskMutation) ResetPlanStartTime() {
  24117. m.plan_start_time = nil
  24118. delete(m.clearedFields, soptask.FieldPlanStartTime)
  24119. }
  24120. // SetPlanEndTime sets the "plan_end_time" field.
  24121. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  24122. m.plan_end_time = &t
  24123. }
  24124. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  24125. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  24126. v := m.plan_end_time
  24127. if v == nil {
  24128. return
  24129. }
  24130. return *v, true
  24131. }
  24132. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  24133. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24135. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  24136. if !m.op.Is(OpUpdateOne) {
  24137. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  24138. }
  24139. if m.id == nil || m.oldValue == nil {
  24140. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  24141. }
  24142. oldValue, err := m.oldValue(ctx)
  24143. if err != nil {
  24144. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  24145. }
  24146. return oldValue.PlanEndTime, nil
  24147. }
  24148. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  24149. func (m *SopTaskMutation) ClearPlanEndTime() {
  24150. m.plan_end_time = nil
  24151. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  24152. }
  24153. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  24154. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  24155. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  24156. return ok
  24157. }
  24158. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  24159. func (m *SopTaskMutation) ResetPlanEndTime() {
  24160. m.plan_end_time = nil
  24161. delete(m.clearedFields, soptask.FieldPlanEndTime)
  24162. }
  24163. // SetCreatorID sets the "creator_id" field.
  24164. func (m *SopTaskMutation) SetCreatorID(s string) {
  24165. m.creator_id = &s
  24166. }
  24167. // CreatorID returns the value of the "creator_id" field in the mutation.
  24168. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  24169. v := m.creator_id
  24170. if v == nil {
  24171. return
  24172. }
  24173. return *v, true
  24174. }
  24175. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  24176. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24178. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  24179. if !m.op.Is(OpUpdateOne) {
  24180. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  24181. }
  24182. if m.id == nil || m.oldValue == nil {
  24183. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  24184. }
  24185. oldValue, err := m.oldValue(ctx)
  24186. if err != nil {
  24187. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  24188. }
  24189. return oldValue.CreatorID, nil
  24190. }
  24191. // ClearCreatorID clears the value of the "creator_id" field.
  24192. func (m *SopTaskMutation) ClearCreatorID() {
  24193. m.creator_id = nil
  24194. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  24195. }
  24196. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  24197. func (m *SopTaskMutation) CreatorIDCleared() bool {
  24198. _, ok := m.clearedFields[soptask.FieldCreatorID]
  24199. return ok
  24200. }
  24201. // ResetCreatorID resets all changes to the "creator_id" field.
  24202. func (m *SopTaskMutation) ResetCreatorID() {
  24203. m.creator_id = nil
  24204. delete(m.clearedFields, soptask.FieldCreatorID)
  24205. }
  24206. // SetOrganizationID sets the "organization_id" field.
  24207. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  24208. m.organization_id = &u
  24209. m.addorganization_id = nil
  24210. }
  24211. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24212. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  24213. v := m.organization_id
  24214. if v == nil {
  24215. return
  24216. }
  24217. return *v, true
  24218. }
  24219. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  24220. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24222. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24223. if !m.op.Is(OpUpdateOne) {
  24224. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24225. }
  24226. if m.id == nil || m.oldValue == nil {
  24227. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24228. }
  24229. oldValue, err := m.oldValue(ctx)
  24230. if err != nil {
  24231. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24232. }
  24233. return oldValue.OrganizationID, nil
  24234. }
  24235. // AddOrganizationID adds u to the "organization_id" field.
  24236. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  24237. if m.addorganization_id != nil {
  24238. *m.addorganization_id += u
  24239. } else {
  24240. m.addorganization_id = &u
  24241. }
  24242. }
  24243. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24244. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  24245. v := m.addorganization_id
  24246. if v == nil {
  24247. return
  24248. }
  24249. return *v, true
  24250. }
  24251. // ClearOrganizationID clears the value of the "organization_id" field.
  24252. func (m *SopTaskMutation) ClearOrganizationID() {
  24253. m.organization_id = nil
  24254. m.addorganization_id = nil
  24255. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  24256. }
  24257. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24258. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  24259. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  24260. return ok
  24261. }
  24262. // ResetOrganizationID resets all changes to the "organization_id" field.
  24263. func (m *SopTaskMutation) ResetOrganizationID() {
  24264. m.organization_id = nil
  24265. m.addorganization_id = nil
  24266. delete(m.clearedFields, soptask.FieldOrganizationID)
  24267. }
  24268. // SetToken sets the "token" field.
  24269. func (m *SopTaskMutation) SetToken(s []string) {
  24270. m.token = &s
  24271. m.appendtoken = nil
  24272. }
  24273. // Token returns the value of the "token" field in the mutation.
  24274. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  24275. v := m.token
  24276. if v == nil {
  24277. return
  24278. }
  24279. return *v, true
  24280. }
  24281. // OldToken returns the old "token" field's value of the SopTask entity.
  24282. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24284. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  24285. if !m.op.Is(OpUpdateOne) {
  24286. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24287. }
  24288. if m.id == nil || m.oldValue == nil {
  24289. return v, errors.New("OldToken requires an ID field in the mutation")
  24290. }
  24291. oldValue, err := m.oldValue(ctx)
  24292. if err != nil {
  24293. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  24294. }
  24295. return oldValue.Token, nil
  24296. }
  24297. // AppendToken adds s to the "token" field.
  24298. func (m *SopTaskMutation) AppendToken(s []string) {
  24299. m.appendtoken = append(m.appendtoken, s...)
  24300. }
  24301. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  24302. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  24303. if len(m.appendtoken) == 0 {
  24304. return nil, false
  24305. }
  24306. return m.appendtoken, true
  24307. }
  24308. // ClearToken clears the value of the "token" field.
  24309. func (m *SopTaskMutation) ClearToken() {
  24310. m.token = nil
  24311. m.appendtoken = nil
  24312. m.clearedFields[soptask.FieldToken] = struct{}{}
  24313. }
  24314. // TokenCleared returns if the "token" field was cleared in this mutation.
  24315. func (m *SopTaskMutation) TokenCleared() bool {
  24316. _, ok := m.clearedFields[soptask.FieldToken]
  24317. return ok
  24318. }
  24319. // ResetToken resets all changes to the "token" field.
  24320. func (m *SopTaskMutation) ResetToken() {
  24321. m.token = nil
  24322. m.appendtoken = nil
  24323. delete(m.clearedFields, soptask.FieldToken)
  24324. }
  24325. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  24326. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  24327. if m.task_stages == nil {
  24328. m.task_stages = make(map[uint64]struct{})
  24329. }
  24330. for i := range ids {
  24331. m.task_stages[ids[i]] = struct{}{}
  24332. }
  24333. }
  24334. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  24335. func (m *SopTaskMutation) ClearTaskStages() {
  24336. m.clearedtask_stages = true
  24337. }
  24338. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  24339. func (m *SopTaskMutation) TaskStagesCleared() bool {
  24340. return m.clearedtask_stages
  24341. }
  24342. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  24343. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  24344. if m.removedtask_stages == nil {
  24345. m.removedtask_stages = make(map[uint64]struct{})
  24346. }
  24347. for i := range ids {
  24348. delete(m.task_stages, ids[i])
  24349. m.removedtask_stages[ids[i]] = struct{}{}
  24350. }
  24351. }
  24352. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  24353. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  24354. for id := range m.removedtask_stages {
  24355. ids = append(ids, id)
  24356. }
  24357. return
  24358. }
  24359. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  24360. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  24361. for id := range m.task_stages {
  24362. ids = append(ids, id)
  24363. }
  24364. return
  24365. }
  24366. // ResetTaskStages resets all changes to the "task_stages" edge.
  24367. func (m *SopTaskMutation) ResetTaskStages() {
  24368. m.task_stages = nil
  24369. m.clearedtask_stages = false
  24370. m.removedtask_stages = nil
  24371. }
  24372. // Where appends a list predicates to the SopTaskMutation builder.
  24373. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  24374. m.predicates = append(m.predicates, ps...)
  24375. }
  24376. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  24377. // users can use type-assertion to append predicates that do not depend on any generated package.
  24378. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  24379. p := make([]predicate.SopTask, len(ps))
  24380. for i := range ps {
  24381. p[i] = ps[i]
  24382. }
  24383. m.Where(p...)
  24384. }
  24385. // Op returns the operation name.
  24386. func (m *SopTaskMutation) Op() Op {
  24387. return m.op
  24388. }
  24389. // SetOp allows setting the mutation operation.
  24390. func (m *SopTaskMutation) SetOp(op Op) {
  24391. m.op = op
  24392. }
  24393. // Type returns the node type of this mutation (SopTask).
  24394. func (m *SopTaskMutation) Type() string {
  24395. return m.typ
  24396. }
  24397. // Fields returns all fields that were changed during this mutation. Note that in
  24398. // order to get all numeric fields that were incremented/decremented, call
  24399. // AddedFields().
  24400. func (m *SopTaskMutation) Fields() []string {
  24401. fields := make([]string, 0, 12)
  24402. if m.created_at != nil {
  24403. fields = append(fields, soptask.FieldCreatedAt)
  24404. }
  24405. if m.updated_at != nil {
  24406. fields = append(fields, soptask.FieldUpdatedAt)
  24407. }
  24408. if m.status != nil {
  24409. fields = append(fields, soptask.FieldStatus)
  24410. }
  24411. if m.deleted_at != nil {
  24412. fields = append(fields, soptask.FieldDeletedAt)
  24413. }
  24414. if m.name != nil {
  24415. fields = append(fields, soptask.FieldName)
  24416. }
  24417. if m.bot_wxid_list != nil {
  24418. fields = append(fields, soptask.FieldBotWxidList)
  24419. }
  24420. if m._type != nil {
  24421. fields = append(fields, soptask.FieldType)
  24422. }
  24423. if m.plan_start_time != nil {
  24424. fields = append(fields, soptask.FieldPlanStartTime)
  24425. }
  24426. if m.plan_end_time != nil {
  24427. fields = append(fields, soptask.FieldPlanEndTime)
  24428. }
  24429. if m.creator_id != nil {
  24430. fields = append(fields, soptask.FieldCreatorID)
  24431. }
  24432. if m.organization_id != nil {
  24433. fields = append(fields, soptask.FieldOrganizationID)
  24434. }
  24435. if m.token != nil {
  24436. fields = append(fields, soptask.FieldToken)
  24437. }
  24438. return fields
  24439. }
  24440. // Field returns the value of a field with the given name. The second boolean
  24441. // return value indicates that this field was not set, or was not defined in the
  24442. // schema.
  24443. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  24444. switch name {
  24445. case soptask.FieldCreatedAt:
  24446. return m.CreatedAt()
  24447. case soptask.FieldUpdatedAt:
  24448. return m.UpdatedAt()
  24449. case soptask.FieldStatus:
  24450. return m.Status()
  24451. case soptask.FieldDeletedAt:
  24452. return m.DeletedAt()
  24453. case soptask.FieldName:
  24454. return m.Name()
  24455. case soptask.FieldBotWxidList:
  24456. return m.BotWxidList()
  24457. case soptask.FieldType:
  24458. return m.GetType()
  24459. case soptask.FieldPlanStartTime:
  24460. return m.PlanStartTime()
  24461. case soptask.FieldPlanEndTime:
  24462. return m.PlanEndTime()
  24463. case soptask.FieldCreatorID:
  24464. return m.CreatorID()
  24465. case soptask.FieldOrganizationID:
  24466. return m.OrganizationID()
  24467. case soptask.FieldToken:
  24468. return m.Token()
  24469. }
  24470. return nil, false
  24471. }
  24472. // OldField returns the old value of the field from the database. An error is
  24473. // returned if the mutation operation is not UpdateOne, or the query to the
  24474. // database failed.
  24475. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24476. switch name {
  24477. case soptask.FieldCreatedAt:
  24478. return m.OldCreatedAt(ctx)
  24479. case soptask.FieldUpdatedAt:
  24480. return m.OldUpdatedAt(ctx)
  24481. case soptask.FieldStatus:
  24482. return m.OldStatus(ctx)
  24483. case soptask.FieldDeletedAt:
  24484. return m.OldDeletedAt(ctx)
  24485. case soptask.FieldName:
  24486. return m.OldName(ctx)
  24487. case soptask.FieldBotWxidList:
  24488. return m.OldBotWxidList(ctx)
  24489. case soptask.FieldType:
  24490. return m.OldType(ctx)
  24491. case soptask.FieldPlanStartTime:
  24492. return m.OldPlanStartTime(ctx)
  24493. case soptask.FieldPlanEndTime:
  24494. return m.OldPlanEndTime(ctx)
  24495. case soptask.FieldCreatorID:
  24496. return m.OldCreatorID(ctx)
  24497. case soptask.FieldOrganizationID:
  24498. return m.OldOrganizationID(ctx)
  24499. case soptask.FieldToken:
  24500. return m.OldToken(ctx)
  24501. }
  24502. return nil, fmt.Errorf("unknown SopTask field %s", name)
  24503. }
  24504. // SetField sets the value of a field with the given name. It returns an error if
  24505. // the field is not defined in the schema, or if the type mismatched the field
  24506. // type.
  24507. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  24508. switch name {
  24509. case soptask.FieldCreatedAt:
  24510. v, ok := value.(time.Time)
  24511. if !ok {
  24512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24513. }
  24514. m.SetCreatedAt(v)
  24515. return nil
  24516. case soptask.FieldUpdatedAt:
  24517. v, ok := value.(time.Time)
  24518. if !ok {
  24519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24520. }
  24521. m.SetUpdatedAt(v)
  24522. return nil
  24523. case soptask.FieldStatus:
  24524. v, ok := value.(uint8)
  24525. if !ok {
  24526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24527. }
  24528. m.SetStatus(v)
  24529. return nil
  24530. case soptask.FieldDeletedAt:
  24531. v, ok := value.(time.Time)
  24532. if !ok {
  24533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24534. }
  24535. m.SetDeletedAt(v)
  24536. return nil
  24537. case soptask.FieldName:
  24538. v, ok := value.(string)
  24539. if !ok {
  24540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24541. }
  24542. m.SetName(v)
  24543. return nil
  24544. case soptask.FieldBotWxidList:
  24545. v, ok := value.([]string)
  24546. if !ok {
  24547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24548. }
  24549. m.SetBotWxidList(v)
  24550. return nil
  24551. case soptask.FieldType:
  24552. v, ok := value.(int)
  24553. if !ok {
  24554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24555. }
  24556. m.SetType(v)
  24557. return nil
  24558. case soptask.FieldPlanStartTime:
  24559. v, ok := value.(time.Time)
  24560. if !ok {
  24561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24562. }
  24563. m.SetPlanStartTime(v)
  24564. return nil
  24565. case soptask.FieldPlanEndTime:
  24566. v, ok := value.(time.Time)
  24567. if !ok {
  24568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24569. }
  24570. m.SetPlanEndTime(v)
  24571. return nil
  24572. case soptask.FieldCreatorID:
  24573. v, ok := value.(string)
  24574. if !ok {
  24575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24576. }
  24577. m.SetCreatorID(v)
  24578. return nil
  24579. case soptask.FieldOrganizationID:
  24580. v, ok := value.(uint64)
  24581. if !ok {
  24582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24583. }
  24584. m.SetOrganizationID(v)
  24585. return nil
  24586. case soptask.FieldToken:
  24587. v, ok := value.([]string)
  24588. if !ok {
  24589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24590. }
  24591. m.SetToken(v)
  24592. return nil
  24593. }
  24594. return fmt.Errorf("unknown SopTask field %s", name)
  24595. }
  24596. // AddedFields returns all numeric fields that were incremented/decremented during
  24597. // this mutation.
  24598. func (m *SopTaskMutation) AddedFields() []string {
  24599. var fields []string
  24600. if m.addstatus != nil {
  24601. fields = append(fields, soptask.FieldStatus)
  24602. }
  24603. if m.add_type != nil {
  24604. fields = append(fields, soptask.FieldType)
  24605. }
  24606. if m.addorganization_id != nil {
  24607. fields = append(fields, soptask.FieldOrganizationID)
  24608. }
  24609. return fields
  24610. }
  24611. // AddedField returns the numeric value that was incremented/decremented on a field
  24612. // with the given name. The second boolean return value indicates that this field
  24613. // was not set, or was not defined in the schema.
  24614. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  24615. switch name {
  24616. case soptask.FieldStatus:
  24617. return m.AddedStatus()
  24618. case soptask.FieldType:
  24619. return m.AddedType()
  24620. case soptask.FieldOrganizationID:
  24621. return m.AddedOrganizationID()
  24622. }
  24623. return nil, false
  24624. }
  24625. // AddField adds the value to the field with the given name. It returns an error if
  24626. // the field is not defined in the schema, or if the type mismatched the field
  24627. // type.
  24628. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  24629. switch name {
  24630. case soptask.FieldStatus:
  24631. v, ok := value.(int8)
  24632. if !ok {
  24633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24634. }
  24635. m.AddStatus(v)
  24636. return nil
  24637. case soptask.FieldType:
  24638. v, ok := value.(int)
  24639. if !ok {
  24640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24641. }
  24642. m.AddType(v)
  24643. return nil
  24644. case soptask.FieldOrganizationID:
  24645. v, ok := value.(int64)
  24646. if !ok {
  24647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24648. }
  24649. m.AddOrganizationID(v)
  24650. return nil
  24651. }
  24652. return fmt.Errorf("unknown SopTask numeric field %s", name)
  24653. }
  24654. // ClearedFields returns all nullable fields that were cleared during this
  24655. // mutation.
  24656. func (m *SopTaskMutation) ClearedFields() []string {
  24657. var fields []string
  24658. if m.FieldCleared(soptask.FieldStatus) {
  24659. fields = append(fields, soptask.FieldStatus)
  24660. }
  24661. if m.FieldCleared(soptask.FieldDeletedAt) {
  24662. fields = append(fields, soptask.FieldDeletedAt)
  24663. }
  24664. if m.FieldCleared(soptask.FieldBotWxidList) {
  24665. fields = append(fields, soptask.FieldBotWxidList)
  24666. }
  24667. if m.FieldCleared(soptask.FieldPlanStartTime) {
  24668. fields = append(fields, soptask.FieldPlanStartTime)
  24669. }
  24670. if m.FieldCleared(soptask.FieldPlanEndTime) {
  24671. fields = append(fields, soptask.FieldPlanEndTime)
  24672. }
  24673. if m.FieldCleared(soptask.FieldCreatorID) {
  24674. fields = append(fields, soptask.FieldCreatorID)
  24675. }
  24676. if m.FieldCleared(soptask.FieldOrganizationID) {
  24677. fields = append(fields, soptask.FieldOrganizationID)
  24678. }
  24679. if m.FieldCleared(soptask.FieldToken) {
  24680. fields = append(fields, soptask.FieldToken)
  24681. }
  24682. return fields
  24683. }
  24684. // FieldCleared returns a boolean indicating if a field with the given name was
  24685. // cleared in this mutation.
  24686. func (m *SopTaskMutation) FieldCleared(name string) bool {
  24687. _, ok := m.clearedFields[name]
  24688. return ok
  24689. }
  24690. // ClearField clears the value of the field with the given name. It returns an
  24691. // error if the field is not defined in the schema.
  24692. func (m *SopTaskMutation) ClearField(name string) error {
  24693. switch name {
  24694. case soptask.FieldStatus:
  24695. m.ClearStatus()
  24696. return nil
  24697. case soptask.FieldDeletedAt:
  24698. m.ClearDeletedAt()
  24699. return nil
  24700. case soptask.FieldBotWxidList:
  24701. m.ClearBotWxidList()
  24702. return nil
  24703. case soptask.FieldPlanStartTime:
  24704. m.ClearPlanStartTime()
  24705. return nil
  24706. case soptask.FieldPlanEndTime:
  24707. m.ClearPlanEndTime()
  24708. return nil
  24709. case soptask.FieldCreatorID:
  24710. m.ClearCreatorID()
  24711. return nil
  24712. case soptask.FieldOrganizationID:
  24713. m.ClearOrganizationID()
  24714. return nil
  24715. case soptask.FieldToken:
  24716. m.ClearToken()
  24717. return nil
  24718. }
  24719. return fmt.Errorf("unknown SopTask nullable field %s", name)
  24720. }
  24721. // ResetField resets all changes in the mutation for the field with the given name.
  24722. // It returns an error if the field is not defined in the schema.
  24723. func (m *SopTaskMutation) ResetField(name string) error {
  24724. switch name {
  24725. case soptask.FieldCreatedAt:
  24726. m.ResetCreatedAt()
  24727. return nil
  24728. case soptask.FieldUpdatedAt:
  24729. m.ResetUpdatedAt()
  24730. return nil
  24731. case soptask.FieldStatus:
  24732. m.ResetStatus()
  24733. return nil
  24734. case soptask.FieldDeletedAt:
  24735. m.ResetDeletedAt()
  24736. return nil
  24737. case soptask.FieldName:
  24738. m.ResetName()
  24739. return nil
  24740. case soptask.FieldBotWxidList:
  24741. m.ResetBotWxidList()
  24742. return nil
  24743. case soptask.FieldType:
  24744. m.ResetType()
  24745. return nil
  24746. case soptask.FieldPlanStartTime:
  24747. m.ResetPlanStartTime()
  24748. return nil
  24749. case soptask.FieldPlanEndTime:
  24750. m.ResetPlanEndTime()
  24751. return nil
  24752. case soptask.FieldCreatorID:
  24753. m.ResetCreatorID()
  24754. return nil
  24755. case soptask.FieldOrganizationID:
  24756. m.ResetOrganizationID()
  24757. return nil
  24758. case soptask.FieldToken:
  24759. m.ResetToken()
  24760. return nil
  24761. }
  24762. return fmt.Errorf("unknown SopTask field %s", name)
  24763. }
  24764. // AddedEdges returns all edge names that were set/added in this mutation.
  24765. func (m *SopTaskMutation) AddedEdges() []string {
  24766. edges := make([]string, 0, 1)
  24767. if m.task_stages != nil {
  24768. edges = append(edges, soptask.EdgeTaskStages)
  24769. }
  24770. return edges
  24771. }
  24772. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24773. // name in this mutation.
  24774. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  24775. switch name {
  24776. case soptask.EdgeTaskStages:
  24777. ids := make([]ent.Value, 0, len(m.task_stages))
  24778. for id := range m.task_stages {
  24779. ids = append(ids, id)
  24780. }
  24781. return ids
  24782. }
  24783. return nil
  24784. }
  24785. // RemovedEdges returns all edge names that were removed in this mutation.
  24786. func (m *SopTaskMutation) RemovedEdges() []string {
  24787. edges := make([]string, 0, 1)
  24788. if m.removedtask_stages != nil {
  24789. edges = append(edges, soptask.EdgeTaskStages)
  24790. }
  24791. return edges
  24792. }
  24793. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24794. // the given name in this mutation.
  24795. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  24796. switch name {
  24797. case soptask.EdgeTaskStages:
  24798. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  24799. for id := range m.removedtask_stages {
  24800. ids = append(ids, id)
  24801. }
  24802. return ids
  24803. }
  24804. return nil
  24805. }
  24806. // ClearedEdges returns all edge names that were cleared in this mutation.
  24807. func (m *SopTaskMutation) ClearedEdges() []string {
  24808. edges := make([]string, 0, 1)
  24809. if m.clearedtask_stages {
  24810. edges = append(edges, soptask.EdgeTaskStages)
  24811. }
  24812. return edges
  24813. }
  24814. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24815. // was cleared in this mutation.
  24816. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  24817. switch name {
  24818. case soptask.EdgeTaskStages:
  24819. return m.clearedtask_stages
  24820. }
  24821. return false
  24822. }
  24823. // ClearEdge clears the value of the edge with the given name. It returns an error
  24824. // if that edge is not defined in the schema.
  24825. func (m *SopTaskMutation) ClearEdge(name string) error {
  24826. switch name {
  24827. }
  24828. return fmt.Errorf("unknown SopTask unique edge %s", name)
  24829. }
  24830. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24831. // It returns an error if the edge is not defined in the schema.
  24832. func (m *SopTaskMutation) ResetEdge(name string) error {
  24833. switch name {
  24834. case soptask.EdgeTaskStages:
  24835. m.ResetTaskStages()
  24836. return nil
  24837. }
  24838. return fmt.Errorf("unknown SopTask edge %s", name)
  24839. }
  24840. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  24841. type TokenMutation struct {
  24842. config
  24843. op Op
  24844. typ string
  24845. id *uint64
  24846. created_at *time.Time
  24847. updated_at *time.Time
  24848. deleted_at *time.Time
  24849. expire_at *time.Time
  24850. token *string
  24851. mac *string
  24852. organization_id *uint64
  24853. addorganization_id *int64
  24854. custom_agent_base *string
  24855. custom_agent_key *string
  24856. openai_base *string
  24857. openai_key *string
  24858. clearedFields map[string]struct{}
  24859. agent *uint64
  24860. clearedagent bool
  24861. done bool
  24862. oldValue func(context.Context) (*Token, error)
  24863. predicates []predicate.Token
  24864. }
  24865. var _ ent.Mutation = (*TokenMutation)(nil)
  24866. // tokenOption allows management of the mutation configuration using functional options.
  24867. type tokenOption func(*TokenMutation)
  24868. // newTokenMutation creates new mutation for the Token entity.
  24869. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  24870. m := &TokenMutation{
  24871. config: c,
  24872. op: op,
  24873. typ: TypeToken,
  24874. clearedFields: make(map[string]struct{}),
  24875. }
  24876. for _, opt := range opts {
  24877. opt(m)
  24878. }
  24879. return m
  24880. }
  24881. // withTokenID sets the ID field of the mutation.
  24882. func withTokenID(id uint64) tokenOption {
  24883. return func(m *TokenMutation) {
  24884. var (
  24885. err error
  24886. once sync.Once
  24887. value *Token
  24888. )
  24889. m.oldValue = func(ctx context.Context) (*Token, error) {
  24890. once.Do(func() {
  24891. if m.done {
  24892. err = errors.New("querying old values post mutation is not allowed")
  24893. } else {
  24894. value, err = m.Client().Token.Get(ctx, id)
  24895. }
  24896. })
  24897. return value, err
  24898. }
  24899. m.id = &id
  24900. }
  24901. }
  24902. // withToken sets the old Token of the mutation.
  24903. func withToken(node *Token) tokenOption {
  24904. return func(m *TokenMutation) {
  24905. m.oldValue = func(context.Context) (*Token, error) {
  24906. return node, nil
  24907. }
  24908. m.id = &node.ID
  24909. }
  24910. }
  24911. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24912. // executed in a transaction (ent.Tx), a transactional client is returned.
  24913. func (m TokenMutation) Client() *Client {
  24914. client := &Client{config: m.config}
  24915. client.init()
  24916. return client
  24917. }
  24918. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24919. // it returns an error otherwise.
  24920. func (m TokenMutation) Tx() (*Tx, error) {
  24921. if _, ok := m.driver.(*txDriver); !ok {
  24922. return nil, errors.New("ent: mutation is not running in a transaction")
  24923. }
  24924. tx := &Tx{config: m.config}
  24925. tx.init()
  24926. return tx, nil
  24927. }
  24928. // SetID sets the value of the id field. Note that this
  24929. // operation is only accepted on creation of Token entities.
  24930. func (m *TokenMutation) SetID(id uint64) {
  24931. m.id = &id
  24932. }
  24933. // ID returns the ID value in the mutation. Note that the ID is only available
  24934. // if it was provided to the builder or after it was returned from the database.
  24935. func (m *TokenMutation) ID() (id uint64, exists bool) {
  24936. if m.id == nil {
  24937. return
  24938. }
  24939. return *m.id, true
  24940. }
  24941. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24942. // That means, if the mutation is applied within a transaction with an isolation level such
  24943. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24944. // or updated by the mutation.
  24945. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  24946. switch {
  24947. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24948. id, exists := m.ID()
  24949. if exists {
  24950. return []uint64{id}, nil
  24951. }
  24952. fallthrough
  24953. case m.op.Is(OpUpdate | OpDelete):
  24954. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  24955. default:
  24956. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24957. }
  24958. }
  24959. // SetCreatedAt sets the "created_at" field.
  24960. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  24961. m.created_at = &t
  24962. }
  24963. // CreatedAt returns the value of the "created_at" field in the mutation.
  24964. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  24965. v := m.created_at
  24966. if v == nil {
  24967. return
  24968. }
  24969. return *v, true
  24970. }
  24971. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  24972. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24974. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24975. if !m.op.Is(OpUpdateOne) {
  24976. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24977. }
  24978. if m.id == nil || m.oldValue == nil {
  24979. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24980. }
  24981. oldValue, err := m.oldValue(ctx)
  24982. if err != nil {
  24983. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24984. }
  24985. return oldValue.CreatedAt, nil
  24986. }
  24987. // ResetCreatedAt resets all changes to the "created_at" field.
  24988. func (m *TokenMutation) ResetCreatedAt() {
  24989. m.created_at = nil
  24990. }
  24991. // SetUpdatedAt sets the "updated_at" field.
  24992. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  24993. m.updated_at = &t
  24994. }
  24995. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24996. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  24997. v := m.updated_at
  24998. if v == nil {
  24999. return
  25000. }
  25001. return *v, true
  25002. }
  25003. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  25004. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25006. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25007. if !m.op.Is(OpUpdateOne) {
  25008. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25009. }
  25010. if m.id == nil || m.oldValue == nil {
  25011. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25012. }
  25013. oldValue, err := m.oldValue(ctx)
  25014. if err != nil {
  25015. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25016. }
  25017. return oldValue.UpdatedAt, nil
  25018. }
  25019. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25020. func (m *TokenMutation) ResetUpdatedAt() {
  25021. m.updated_at = nil
  25022. }
  25023. // SetDeletedAt sets the "deleted_at" field.
  25024. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  25025. m.deleted_at = &t
  25026. }
  25027. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25028. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  25029. v := m.deleted_at
  25030. if v == nil {
  25031. return
  25032. }
  25033. return *v, true
  25034. }
  25035. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  25036. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25038. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25039. if !m.op.Is(OpUpdateOne) {
  25040. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25041. }
  25042. if m.id == nil || m.oldValue == nil {
  25043. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25044. }
  25045. oldValue, err := m.oldValue(ctx)
  25046. if err != nil {
  25047. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25048. }
  25049. return oldValue.DeletedAt, nil
  25050. }
  25051. // ClearDeletedAt clears the value of the "deleted_at" field.
  25052. func (m *TokenMutation) ClearDeletedAt() {
  25053. m.deleted_at = nil
  25054. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  25055. }
  25056. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25057. func (m *TokenMutation) DeletedAtCleared() bool {
  25058. _, ok := m.clearedFields[token.FieldDeletedAt]
  25059. return ok
  25060. }
  25061. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25062. func (m *TokenMutation) ResetDeletedAt() {
  25063. m.deleted_at = nil
  25064. delete(m.clearedFields, token.FieldDeletedAt)
  25065. }
  25066. // SetExpireAt sets the "expire_at" field.
  25067. func (m *TokenMutation) SetExpireAt(t time.Time) {
  25068. m.expire_at = &t
  25069. }
  25070. // ExpireAt returns the value of the "expire_at" field in the mutation.
  25071. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  25072. v := m.expire_at
  25073. if v == nil {
  25074. return
  25075. }
  25076. return *v, true
  25077. }
  25078. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  25079. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25081. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  25082. if !m.op.Is(OpUpdateOne) {
  25083. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  25084. }
  25085. if m.id == nil || m.oldValue == nil {
  25086. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  25087. }
  25088. oldValue, err := m.oldValue(ctx)
  25089. if err != nil {
  25090. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  25091. }
  25092. return oldValue.ExpireAt, nil
  25093. }
  25094. // ClearExpireAt clears the value of the "expire_at" field.
  25095. func (m *TokenMutation) ClearExpireAt() {
  25096. m.expire_at = nil
  25097. m.clearedFields[token.FieldExpireAt] = struct{}{}
  25098. }
  25099. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  25100. func (m *TokenMutation) ExpireAtCleared() bool {
  25101. _, ok := m.clearedFields[token.FieldExpireAt]
  25102. return ok
  25103. }
  25104. // ResetExpireAt resets all changes to the "expire_at" field.
  25105. func (m *TokenMutation) ResetExpireAt() {
  25106. m.expire_at = nil
  25107. delete(m.clearedFields, token.FieldExpireAt)
  25108. }
  25109. // SetToken sets the "token" field.
  25110. func (m *TokenMutation) SetToken(s string) {
  25111. m.token = &s
  25112. }
  25113. // Token returns the value of the "token" field in the mutation.
  25114. func (m *TokenMutation) Token() (r string, exists bool) {
  25115. v := m.token
  25116. if v == nil {
  25117. return
  25118. }
  25119. return *v, true
  25120. }
  25121. // OldToken returns the old "token" field's value of the Token entity.
  25122. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25124. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  25125. if !m.op.Is(OpUpdateOne) {
  25126. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25127. }
  25128. if m.id == nil || m.oldValue == nil {
  25129. return v, errors.New("OldToken requires an ID field in the mutation")
  25130. }
  25131. oldValue, err := m.oldValue(ctx)
  25132. if err != nil {
  25133. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25134. }
  25135. return oldValue.Token, nil
  25136. }
  25137. // ClearToken clears the value of the "token" field.
  25138. func (m *TokenMutation) ClearToken() {
  25139. m.token = nil
  25140. m.clearedFields[token.FieldToken] = struct{}{}
  25141. }
  25142. // TokenCleared returns if the "token" field was cleared in this mutation.
  25143. func (m *TokenMutation) TokenCleared() bool {
  25144. _, ok := m.clearedFields[token.FieldToken]
  25145. return ok
  25146. }
  25147. // ResetToken resets all changes to the "token" field.
  25148. func (m *TokenMutation) ResetToken() {
  25149. m.token = nil
  25150. delete(m.clearedFields, token.FieldToken)
  25151. }
  25152. // SetMAC sets the "mac" field.
  25153. func (m *TokenMutation) SetMAC(s string) {
  25154. m.mac = &s
  25155. }
  25156. // MAC returns the value of the "mac" field in the mutation.
  25157. func (m *TokenMutation) MAC() (r string, exists bool) {
  25158. v := m.mac
  25159. if v == nil {
  25160. return
  25161. }
  25162. return *v, true
  25163. }
  25164. // OldMAC returns the old "mac" field's value of the Token entity.
  25165. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25167. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  25168. if !m.op.Is(OpUpdateOne) {
  25169. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  25170. }
  25171. if m.id == nil || m.oldValue == nil {
  25172. return v, errors.New("OldMAC requires an ID field in the mutation")
  25173. }
  25174. oldValue, err := m.oldValue(ctx)
  25175. if err != nil {
  25176. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  25177. }
  25178. return oldValue.MAC, nil
  25179. }
  25180. // ClearMAC clears the value of the "mac" field.
  25181. func (m *TokenMutation) ClearMAC() {
  25182. m.mac = nil
  25183. m.clearedFields[token.FieldMAC] = struct{}{}
  25184. }
  25185. // MACCleared returns if the "mac" field was cleared in this mutation.
  25186. func (m *TokenMutation) MACCleared() bool {
  25187. _, ok := m.clearedFields[token.FieldMAC]
  25188. return ok
  25189. }
  25190. // ResetMAC resets all changes to the "mac" field.
  25191. func (m *TokenMutation) ResetMAC() {
  25192. m.mac = nil
  25193. delete(m.clearedFields, token.FieldMAC)
  25194. }
  25195. // SetOrganizationID sets the "organization_id" field.
  25196. func (m *TokenMutation) SetOrganizationID(u uint64) {
  25197. m.organization_id = &u
  25198. m.addorganization_id = nil
  25199. }
  25200. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25201. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  25202. v := m.organization_id
  25203. if v == nil {
  25204. return
  25205. }
  25206. return *v, true
  25207. }
  25208. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  25209. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25211. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25212. if !m.op.Is(OpUpdateOne) {
  25213. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25214. }
  25215. if m.id == nil || m.oldValue == nil {
  25216. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25217. }
  25218. oldValue, err := m.oldValue(ctx)
  25219. if err != nil {
  25220. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25221. }
  25222. return oldValue.OrganizationID, nil
  25223. }
  25224. // AddOrganizationID adds u to the "organization_id" field.
  25225. func (m *TokenMutation) AddOrganizationID(u int64) {
  25226. if m.addorganization_id != nil {
  25227. *m.addorganization_id += u
  25228. } else {
  25229. m.addorganization_id = &u
  25230. }
  25231. }
  25232. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25233. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  25234. v := m.addorganization_id
  25235. if v == nil {
  25236. return
  25237. }
  25238. return *v, true
  25239. }
  25240. // ResetOrganizationID resets all changes to the "organization_id" field.
  25241. func (m *TokenMutation) ResetOrganizationID() {
  25242. m.organization_id = nil
  25243. m.addorganization_id = nil
  25244. }
  25245. // SetAgentID sets the "agent_id" field.
  25246. func (m *TokenMutation) SetAgentID(u uint64) {
  25247. m.agent = &u
  25248. }
  25249. // AgentID returns the value of the "agent_id" field in the mutation.
  25250. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  25251. v := m.agent
  25252. if v == nil {
  25253. return
  25254. }
  25255. return *v, true
  25256. }
  25257. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  25258. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25260. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  25261. if !m.op.Is(OpUpdateOne) {
  25262. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  25263. }
  25264. if m.id == nil || m.oldValue == nil {
  25265. return v, errors.New("OldAgentID requires an ID field in the mutation")
  25266. }
  25267. oldValue, err := m.oldValue(ctx)
  25268. if err != nil {
  25269. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  25270. }
  25271. return oldValue.AgentID, nil
  25272. }
  25273. // ResetAgentID resets all changes to the "agent_id" field.
  25274. func (m *TokenMutation) ResetAgentID() {
  25275. m.agent = nil
  25276. }
  25277. // SetCustomAgentBase sets the "custom_agent_base" field.
  25278. func (m *TokenMutation) SetCustomAgentBase(s string) {
  25279. m.custom_agent_base = &s
  25280. }
  25281. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  25282. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  25283. v := m.custom_agent_base
  25284. if v == nil {
  25285. return
  25286. }
  25287. return *v, true
  25288. }
  25289. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  25290. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25292. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  25293. if !m.op.Is(OpUpdateOne) {
  25294. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  25295. }
  25296. if m.id == nil || m.oldValue == nil {
  25297. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  25298. }
  25299. oldValue, err := m.oldValue(ctx)
  25300. if err != nil {
  25301. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  25302. }
  25303. return oldValue.CustomAgentBase, nil
  25304. }
  25305. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  25306. func (m *TokenMutation) ClearCustomAgentBase() {
  25307. m.custom_agent_base = nil
  25308. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  25309. }
  25310. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  25311. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  25312. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  25313. return ok
  25314. }
  25315. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  25316. func (m *TokenMutation) ResetCustomAgentBase() {
  25317. m.custom_agent_base = nil
  25318. delete(m.clearedFields, token.FieldCustomAgentBase)
  25319. }
  25320. // SetCustomAgentKey sets the "custom_agent_key" field.
  25321. func (m *TokenMutation) SetCustomAgentKey(s string) {
  25322. m.custom_agent_key = &s
  25323. }
  25324. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  25325. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  25326. v := m.custom_agent_key
  25327. if v == nil {
  25328. return
  25329. }
  25330. return *v, true
  25331. }
  25332. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  25333. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25335. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  25336. if !m.op.Is(OpUpdateOne) {
  25337. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  25338. }
  25339. if m.id == nil || m.oldValue == nil {
  25340. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  25341. }
  25342. oldValue, err := m.oldValue(ctx)
  25343. if err != nil {
  25344. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  25345. }
  25346. return oldValue.CustomAgentKey, nil
  25347. }
  25348. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  25349. func (m *TokenMutation) ClearCustomAgentKey() {
  25350. m.custom_agent_key = nil
  25351. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  25352. }
  25353. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  25354. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  25355. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  25356. return ok
  25357. }
  25358. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  25359. func (m *TokenMutation) ResetCustomAgentKey() {
  25360. m.custom_agent_key = nil
  25361. delete(m.clearedFields, token.FieldCustomAgentKey)
  25362. }
  25363. // SetOpenaiBase sets the "openai_base" field.
  25364. func (m *TokenMutation) SetOpenaiBase(s string) {
  25365. m.openai_base = &s
  25366. }
  25367. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  25368. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  25369. v := m.openai_base
  25370. if v == nil {
  25371. return
  25372. }
  25373. return *v, true
  25374. }
  25375. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  25376. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25378. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  25379. if !m.op.Is(OpUpdateOne) {
  25380. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  25381. }
  25382. if m.id == nil || m.oldValue == nil {
  25383. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  25384. }
  25385. oldValue, err := m.oldValue(ctx)
  25386. if err != nil {
  25387. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  25388. }
  25389. return oldValue.OpenaiBase, nil
  25390. }
  25391. // ClearOpenaiBase clears the value of the "openai_base" field.
  25392. func (m *TokenMutation) ClearOpenaiBase() {
  25393. m.openai_base = nil
  25394. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  25395. }
  25396. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  25397. func (m *TokenMutation) OpenaiBaseCleared() bool {
  25398. _, ok := m.clearedFields[token.FieldOpenaiBase]
  25399. return ok
  25400. }
  25401. // ResetOpenaiBase resets all changes to the "openai_base" field.
  25402. func (m *TokenMutation) ResetOpenaiBase() {
  25403. m.openai_base = nil
  25404. delete(m.clearedFields, token.FieldOpenaiBase)
  25405. }
  25406. // SetOpenaiKey sets the "openai_key" field.
  25407. func (m *TokenMutation) SetOpenaiKey(s string) {
  25408. m.openai_key = &s
  25409. }
  25410. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  25411. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  25412. v := m.openai_key
  25413. if v == nil {
  25414. return
  25415. }
  25416. return *v, true
  25417. }
  25418. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  25419. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25421. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  25422. if !m.op.Is(OpUpdateOne) {
  25423. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  25424. }
  25425. if m.id == nil || m.oldValue == nil {
  25426. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  25427. }
  25428. oldValue, err := m.oldValue(ctx)
  25429. if err != nil {
  25430. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  25431. }
  25432. return oldValue.OpenaiKey, nil
  25433. }
  25434. // ClearOpenaiKey clears the value of the "openai_key" field.
  25435. func (m *TokenMutation) ClearOpenaiKey() {
  25436. m.openai_key = nil
  25437. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  25438. }
  25439. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  25440. func (m *TokenMutation) OpenaiKeyCleared() bool {
  25441. _, ok := m.clearedFields[token.FieldOpenaiKey]
  25442. return ok
  25443. }
  25444. // ResetOpenaiKey resets all changes to the "openai_key" field.
  25445. func (m *TokenMutation) ResetOpenaiKey() {
  25446. m.openai_key = nil
  25447. delete(m.clearedFields, token.FieldOpenaiKey)
  25448. }
  25449. // ClearAgent clears the "agent" edge to the Agent entity.
  25450. func (m *TokenMutation) ClearAgent() {
  25451. m.clearedagent = true
  25452. m.clearedFields[token.FieldAgentID] = struct{}{}
  25453. }
  25454. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  25455. func (m *TokenMutation) AgentCleared() bool {
  25456. return m.clearedagent
  25457. }
  25458. // AgentIDs returns the "agent" edge IDs in the mutation.
  25459. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25460. // AgentID instead. It exists only for internal usage by the builders.
  25461. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  25462. if id := m.agent; id != nil {
  25463. ids = append(ids, *id)
  25464. }
  25465. return
  25466. }
  25467. // ResetAgent resets all changes to the "agent" edge.
  25468. func (m *TokenMutation) ResetAgent() {
  25469. m.agent = nil
  25470. m.clearedagent = false
  25471. }
  25472. // Where appends a list predicates to the TokenMutation builder.
  25473. func (m *TokenMutation) Where(ps ...predicate.Token) {
  25474. m.predicates = append(m.predicates, ps...)
  25475. }
  25476. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  25477. // users can use type-assertion to append predicates that do not depend on any generated package.
  25478. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  25479. p := make([]predicate.Token, len(ps))
  25480. for i := range ps {
  25481. p[i] = ps[i]
  25482. }
  25483. m.Where(p...)
  25484. }
  25485. // Op returns the operation name.
  25486. func (m *TokenMutation) Op() Op {
  25487. return m.op
  25488. }
  25489. // SetOp allows setting the mutation operation.
  25490. func (m *TokenMutation) SetOp(op Op) {
  25491. m.op = op
  25492. }
  25493. // Type returns the node type of this mutation (Token).
  25494. func (m *TokenMutation) Type() string {
  25495. return m.typ
  25496. }
  25497. // Fields returns all fields that were changed during this mutation. Note that in
  25498. // order to get all numeric fields that were incremented/decremented, call
  25499. // AddedFields().
  25500. func (m *TokenMutation) Fields() []string {
  25501. fields := make([]string, 0, 12)
  25502. if m.created_at != nil {
  25503. fields = append(fields, token.FieldCreatedAt)
  25504. }
  25505. if m.updated_at != nil {
  25506. fields = append(fields, token.FieldUpdatedAt)
  25507. }
  25508. if m.deleted_at != nil {
  25509. fields = append(fields, token.FieldDeletedAt)
  25510. }
  25511. if m.expire_at != nil {
  25512. fields = append(fields, token.FieldExpireAt)
  25513. }
  25514. if m.token != nil {
  25515. fields = append(fields, token.FieldToken)
  25516. }
  25517. if m.mac != nil {
  25518. fields = append(fields, token.FieldMAC)
  25519. }
  25520. if m.organization_id != nil {
  25521. fields = append(fields, token.FieldOrganizationID)
  25522. }
  25523. if m.agent != nil {
  25524. fields = append(fields, token.FieldAgentID)
  25525. }
  25526. if m.custom_agent_base != nil {
  25527. fields = append(fields, token.FieldCustomAgentBase)
  25528. }
  25529. if m.custom_agent_key != nil {
  25530. fields = append(fields, token.FieldCustomAgentKey)
  25531. }
  25532. if m.openai_base != nil {
  25533. fields = append(fields, token.FieldOpenaiBase)
  25534. }
  25535. if m.openai_key != nil {
  25536. fields = append(fields, token.FieldOpenaiKey)
  25537. }
  25538. return fields
  25539. }
  25540. // Field returns the value of a field with the given name. The second boolean
  25541. // return value indicates that this field was not set, or was not defined in the
  25542. // schema.
  25543. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  25544. switch name {
  25545. case token.FieldCreatedAt:
  25546. return m.CreatedAt()
  25547. case token.FieldUpdatedAt:
  25548. return m.UpdatedAt()
  25549. case token.FieldDeletedAt:
  25550. return m.DeletedAt()
  25551. case token.FieldExpireAt:
  25552. return m.ExpireAt()
  25553. case token.FieldToken:
  25554. return m.Token()
  25555. case token.FieldMAC:
  25556. return m.MAC()
  25557. case token.FieldOrganizationID:
  25558. return m.OrganizationID()
  25559. case token.FieldAgentID:
  25560. return m.AgentID()
  25561. case token.FieldCustomAgentBase:
  25562. return m.CustomAgentBase()
  25563. case token.FieldCustomAgentKey:
  25564. return m.CustomAgentKey()
  25565. case token.FieldOpenaiBase:
  25566. return m.OpenaiBase()
  25567. case token.FieldOpenaiKey:
  25568. return m.OpenaiKey()
  25569. }
  25570. return nil, false
  25571. }
  25572. // OldField returns the old value of the field from the database. An error is
  25573. // returned if the mutation operation is not UpdateOne, or the query to the
  25574. // database failed.
  25575. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25576. switch name {
  25577. case token.FieldCreatedAt:
  25578. return m.OldCreatedAt(ctx)
  25579. case token.FieldUpdatedAt:
  25580. return m.OldUpdatedAt(ctx)
  25581. case token.FieldDeletedAt:
  25582. return m.OldDeletedAt(ctx)
  25583. case token.FieldExpireAt:
  25584. return m.OldExpireAt(ctx)
  25585. case token.FieldToken:
  25586. return m.OldToken(ctx)
  25587. case token.FieldMAC:
  25588. return m.OldMAC(ctx)
  25589. case token.FieldOrganizationID:
  25590. return m.OldOrganizationID(ctx)
  25591. case token.FieldAgentID:
  25592. return m.OldAgentID(ctx)
  25593. case token.FieldCustomAgentBase:
  25594. return m.OldCustomAgentBase(ctx)
  25595. case token.FieldCustomAgentKey:
  25596. return m.OldCustomAgentKey(ctx)
  25597. case token.FieldOpenaiBase:
  25598. return m.OldOpenaiBase(ctx)
  25599. case token.FieldOpenaiKey:
  25600. return m.OldOpenaiKey(ctx)
  25601. }
  25602. return nil, fmt.Errorf("unknown Token field %s", name)
  25603. }
  25604. // SetField sets the value of a field with the given name. It returns an error if
  25605. // the field is not defined in the schema, or if the type mismatched the field
  25606. // type.
  25607. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  25608. switch name {
  25609. case token.FieldCreatedAt:
  25610. v, ok := value.(time.Time)
  25611. if !ok {
  25612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25613. }
  25614. m.SetCreatedAt(v)
  25615. return nil
  25616. case token.FieldUpdatedAt:
  25617. v, ok := value.(time.Time)
  25618. if !ok {
  25619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25620. }
  25621. m.SetUpdatedAt(v)
  25622. return nil
  25623. case token.FieldDeletedAt:
  25624. v, ok := value.(time.Time)
  25625. if !ok {
  25626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25627. }
  25628. m.SetDeletedAt(v)
  25629. return nil
  25630. case token.FieldExpireAt:
  25631. v, ok := value.(time.Time)
  25632. if !ok {
  25633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25634. }
  25635. m.SetExpireAt(v)
  25636. return nil
  25637. case token.FieldToken:
  25638. v, ok := value.(string)
  25639. if !ok {
  25640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25641. }
  25642. m.SetToken(v)
  25643. return nil
  25644. case token.FieldMAC:
  25645. v, ok := value.(string)
  25646. if !ok {
  25647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25648. }
  25649. m.SetMAC(v)
  25650. return nil
  25651. case token.FieldOrganizationID:
  25652. v, ok := value.(uint64)
  25653. if !ok {
  25654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25655. }
  25656. m.SetOrganizationID(v)
  25657. return nil
  25658. case token.FieldAgentID:
  25659. v, ok := value.(uint64)
  25660. if !ok {
  25661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25662. }
  25663. m.SetAgentID(v)
  25664. return nil
  25665. case token.FieldCustomAgentBase:
  25666. v, ok := value.(string)
  25667. if !ok {
  25668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25669. }
  25670. m.SetCustomAgentBase(v)
  25671. return nil
  25672. case token.FieldCustomAgentKey:
  25673. v, ok := value.(string)
  25674. if !ok {
  25675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25676. }
  25677. m.SetCustomAgentKey(v)
  25678. return nil
  25679. case token.FieldOpenaiBase:
  25680. v, ok := value.(string)
  25681. if !ok {
  25682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25683. }
  25684. m.SetOpenaiBase(v)
  25685. return nil
  25686. case token.FieldOpenaiKey:
  25687. v, ok := value.(string)
  25688. if !ok {
  25689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25690. }
  25691. m.SetOpenaiKey(v)
  25692. return nil
  25693. }
  25694. return fmt.Errorf("unknown Token field %s", name)
  25695. }
  25696. // AddedFields returns all numeric fields that were incremented/decremented during
  25697. // this mutation.
  25698. func (m *TokenMutation) AddedFields() []string {
  25699. var fields []string
  25700. if m.addorganization_id != nil {
  25701. fields = append(fields, token.FieldOrganizationID)
  25702. }
  25703. return fields
  25704. }
  25705. // AddedField returns the numeric value that was incremented/decremented on a field
  25706. // with the given name. The second boolean return value indicates that this field
  25707. // was not set, or was not defined in the schema.
  25708. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  25709. switch name {
  25710. case token.FieldOrganizationID:
  25711. return m.AddedOrganizationID()
  25712. }
  25713. return nil, false
  25714. }
  25715. // AddField adds the value to the field with the given name. It returns an error if
  25716. // the field is not defined in the schema, or if the type mismatched the field
  25717. // type.
  25718. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  25719. switch name {
  25720. case token.FieldOrganizationID:
  25721. v, ok := value.(int64)
  25722. if !ok {
  25723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25724. }
  25725. m.AddOrganizationID(v)
  25726. return nil
  25727. }
  25728. return fmt.Errorf("unknown Token numeric field %s", name)
  25729. }
  25730. // ClearedFields returns all nullable fields that were cleared during this
  25731. // mutation.
  25732. func (m *TokenMutation) ClearedFields() []string {
  25733. var fields []string
  25734. if m.FieldCleared(token.FieldDeletedAt) {
  25735. fields = append(fields, token.FieldDeletedAt)
  25736. }
  25737. if m.FieldCleared(token.FieldExpireAt) {
  25738. fields = append(fields, token.FieldExpireAt)
  25739. }
  25740. if m.FieldCleared(token.FieldToken) {
  25741. fields = append(fields, token.FieldToken)
  25742. }
  25743. if m.FieldCleared(token.FieldMAC) {
  25744. fields = append(fields, token.FieldMAC)
  25745. }
  25746. if m.FieldCleared(token.FieldCustomAgentBase) {
  25747. fields = append(fields, token.FieldCustomAgentBase)
  25748. }
  25749. if m.FieldCleared(token.FieldCustomAgentKey) {
  25750. fields = append(fields, token.FieldCustomAgentKey)
  25751. }
  25752. if m.FieldCleared(token.FieldOpenaiBase) {
  25753. fields = append(fields, token.FieldOpenaiBase)
  25754. }
  25755. if m.FieldCleared(token.FieldOpenaiKey) {
  25756. fields = append(fields, token.FieldOpenaiKey)
  25757. }
  25758. return fields
  25759. }
  25760. // FieldCleared returns a boolean indicating if a field with the given name was
  25761. // cleared in this mutation.
  25762. func (m *TokenMutation) FieldCleared(name string) bool {
  25763. _, ok := m.clearedFields[name]
  25764. return ok
  25765. }
  25766. // ClearField clears the value of the field with the given name. It returns an
  25767. // error if the field is not defined in the schema.
  25768. func (m *TokenMutation) ClearField(name string) error {
  25769. switch name {
  25770. case token.FieldDeletedAt:
  25771. m.ClearDeletedAt()
  25772. return nil
  25773. case token.FieldExpireAt:
  25774. m.ClearExpireAt()
  25775. return nil
  25776. case token.FieldToken:
  25777. m.ClearToken()
  25778. return nil
  25779. case token.FieldMAC:
  25780. m.ClearMAC()
  25781. return nil
  25782. case token.FieldCustomAgentBase:
  25783. m.ClearCustomAgentBase()
  25784. return nil
  25785. case token.FieldCustomAgentKey:
  25786. m.ClearCustomAgentKey()
  25787. return nil
  25788. case token.FieldOpenaiBase:
  25789. m.ClearOpenaiBase()
  25790. return nil
  25791. case token.FieldOpenaiKey:
  25792. m.ClearOpenaiKey()
  25793. return nil
  25794. }
  25795. return fmt.Errorf("unknown Token nullable field %s", name)
  25796. }
  25797. // ResetField resets all changes in the mutation for the field with the given name.
  25798. // It returns an error if the field is not defined in the schema.
  25799. func (m *TokenMutation) ResetField(name string) error {
  25800. switch name {
  25801. case token.FieldCreatedAt:
  25802. m.ResetCreatedAt()
  25803. return nil
  25804. case token.FieldUpdatedAt:
  25805. m.ResetUpdatedAt()
  25806. return nil
  25807. case token.FieldDeletedAt:
  25808. m.ResetDeletedAt()
  25809. return nil
  25810. case token.FieldExpireAt:
  25811. m.ResetExpireAt()
  25812. return nil
  25813. case token.FieldToken:
  25814. m.ResetToken()
  25815. return nil
  25816. case token.FieldMAC:
  25817. m.ResetMAC()
  25818. return nil
  25819. case token.FieldOrganizationID:
  25820. m.ResetOrganizationID()
  25821. return nil
  25822. case token.FieldAgentID:
  25823. m.ResetAgentID()
  25824. return nil
  25825. case token.FieldCustomAgentBase:
  25826. m.ResetCustomAgentBase()
  25827. return nil
  25828. case token.FieldCustomAgentKey:
  25829. m.ResetCustomAgentKey()
  25830. return nil
  25831. case token.FieldOpenaiBase:
  25832. m.ResetOpenaiBase()
  25833. return nil
  25834. case token.FieldOpenaiKey:
  25835. m.ResetOpenaiKey()
  25836. return nil
  25837. }
  25838. return fmt.Errorf("unknown Token field %s", name)
  25839. }
  25840. // AddedEdges returns all edge names that were set/added in this mutation.
  25841. func (m *TokenMutation) AddedEdges() []string {
  25842. edges := make([]string, 0, 1)
  25843. if m.agent != nil {
  25844. edges = append(edges, token.EdgeAgent)
  25845. }
  25846. return edges
  25847. }
  25848. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25849. // name in this mutation.
  25850. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  25851. switch name {
  25852. case token.EdgeAgent:
  25853. if id := m.agent; id != nil {
  25854. return []ent.Value{*id}
  25855. }
  25856. }
  25857. return nil
  25858. }
  25859. // RemovedEdges returns all edge names that were removed in this mutation.
  25860. func (m *TokenMutation) RemovedEdges() []string {
  25861. edges := make([]string, 0, 1)
  25862. return edges
  25863. }
  25864. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25865. // the given name in this mutation.
  25866. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  25867. return nil
  25868. }
  25869. // ClearedEdges returns all edge names that were cleared in this mutation.
  25870. func (m *TokenMutation) ClearedEdges() []string {
  25871. edges := make([]string, 0, 1)
  25872. if m.clearedagent {
  25873. edges = append(edges, token.EdgeAgent)
  25874. }
  25875. return edges
  25876. }
  25877. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25878. // was cleared in this mutation.
  25879. func (m *TokenMutation) EdgeCleared(name string) bool {
  25880. switch name {
  25881. case token.EdgeAgent:
  25882. return m.clearedagent
  25883. }
  25884. return false
  25885. }
  25886. // ClearEdge clears the value of the edge with the given name. It returns an error
  25887. // if that edge is not defined in the schema.
  25888. func (m *TokenMutation) ClearEdge(name string) error {
  25889. switch name {
  25890. case token.EdgeAgent:
  25891. m.ClearAgent()
  25892. return nil
  25893. }
  25894. return fmt.Errorf("unknown Token unique edge %s", name)
  25895. }
  25896. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25897. // It returns an error if the edge is not defined in the schema.
  25898. func (m *TokenMutation) ResetEdge(name string) error {
  25899. switch name {
  25900. case token.EdgeAgent:
  25901. m.ResetAgent()
  25902. return nil
  25903. }
  25904. return fmt.Errorf("unknown Token edge %s", name)
  25905. }
  25906. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  25907. type TutorialMutation struct {
  25908. config
  25909. op Op
  25910. typ string
  25911. id *uint64
  25912. created_at *time.Time
  25913. updated_at *time.Time
  25914. deleted_at *time.Time
  25915. index *int
  25916. addindex *int
  25917. title *string
  25918. content *string
  25919. organization_id *uint64
  25920. addorganization_id *int64
  25921. clearedFields map[string]struct{}
  25922. employee *uint64
  25923. clearedemployee bool
  25924. done bool
  25925. oldValue func(context.Context) (*Tutorial, error)
  25926. predicates []predicate.Tutorial
  25927. }
  25928. var _ ent.Mutation = (*TutorialMutation)(nil)
  25929. // tutorialOption allows management of the mutation configuration using functional options.
  25930. type tutorialOption func(*TutorialMutation)
  25931. // newTutorialMutation creates new mutation for the Tutorial entity.
  25932. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  25933. m := &TutorialMutation{
  25934. config: c,
  25935. op: op,
  25936. typ: TypeTutorial,
  25937. clearedFields: make(map[string]struct{}),
  25938. }
  25939. for _, opt := range opts {
  25940. opt(m)
  25941. }
  25942. return m
  25943. }
  25944. // withTutorialID sets the ID field of the mutation.
  25945. func withTutorialID(id uint64) tutorialOption {
  25946. return func(m *TutorialMutation) {
  25947. var (
  25948. err error
  25949. once sync.Once
  25950. value *Tutorial
  25951. )
  25952. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  25953. once.Do(func() {
  25954. if m.done {
  25955. err = errors.New("querying old values post mutation is not allowed")
  25956. } else {
  25957. value, err = m.Client().Tutorial.Get(ctx, id)
  25958. }
  25959. })
  25960. return value, err
  25961. }
  25962. m.id = &id
  25963. }
  25964. }
  25965. // withTutorial sets the old Tutorial of the mutation.
  25966. func withTutorial(node *Tutorial) tutorialOption {
  25967. return func(m *TutorialMutation) {
  25968. m.oldValue = func(context.Context) (*Tutorial, error) {
  25969. return node, nil
  25970. }
  25971. m.id = &node.ID
  25972. }
  25973. }
  25974. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25975. // executed in a transaction (ent.Tx), a transactional client is returned.
  25976. func (m TutorialMutation) Client() *Client {
  25977. client := &Client{config: m.config}
  25978. client.init()
  25979. return client
  25980. }
  25981. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25982. // it returns an error otherwise.
  25983. func (m TutorialMutation) Tx() (*Tx, error) {
  25984. if _, ok := m.driver.(*txDriver); !ok {
  25985. return nil, errors.New("ent: mutation is not running in a transaction")
  25986. }
  25987. tx := &Tx{config: m.config}
  25988. tx.init()
  25989. return tx, nil
  25990. }
  25991. // SetID sets the value of the id field. Note that this
  25992. // operation is only accepted on creation of Tutorial entities.
  25993. func (m *TutorialMutation) SetID(id uint64) {
  25994. m.id = &id
  25995. }
  25996. // ID returns the ID value in the mutation. Note that the ID is only available
  25997. // if it was provided to the builder or after it was returned from the database.
  25998. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  25999. if m.id == nil {
  26000. return
  26001. }
  26002. return *m.id, true
  26003. }
  26004. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26005. // That means, if the mutation is applied within a transaction with an isolation level such
  26006. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26007. // or updated by the mutation.
  26008. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  26009. switch {
  26010. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26011. id, exists := m.ID()
  26012. if exists {
  26013. return []uint64{id}, nil
  26014. }
  26015. fallthrough
  26016. case m.op.Is(OpUpdate | OpDelete):
  26017. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  26018. default:
  26019. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26020. }
  26021. }
  26022. // SetCreatedAt sets the "created_at" field.
  26023. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  26024. m.created_at = &t
  26025. }
  26026. // CreatedAt returns the value of the "created_at" field in the mutation.
  26027. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  26028. v := m.created_at
  26029. if v == nil {
  26030. return
  26031. }
  26032. return *v, true
  26033. }
  26034. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  26035. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26037. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26038. if !m.op.Is(OpUpdateOne) {
  26039. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26040. }
  26041. if m.id == nil || m.oldValue == nil {
  26042. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26043. }
  26044. oldValue, err := m.oldValue(ctx)
  26045. if err != nil {
  26046. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26047. }
  26048. return oldValue.CreatedAt, nil
  26049. }
  26050. // ResetCreatedAt resets all changes to the "created_at" field.
  26051. func (m *TutorialMutation) ResetCreatedAt() {
  26052. m.created_at = nil
  26053. }
  26054. // SetUpdatedAt sets the "updated_at" field.
  26055. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  26056. m.updated_at = &t
  26057. }
  26058. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26059. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  26060. v := m.updated_at
  26061. if v == nil {
  26062. return
  26063. }
  26064. return *v, true
  26065. }
  26066. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  26067. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26069. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26070. if !m.op.Is(OpUpdateOne) {
  26071. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26072. }
  26073. if m.id == nil || m.oldValue == nil {
  26074. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26075. }
  26076. oldValue, err := m.oldValue(ctx)
  26077. if err != nil {
  26078. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26079. }
  26080. return oldValue.UpdatedAt, nil
  26081. }
  26082. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26083. func (m *TutorialMutation) ResetUpdatedAt() {
  26084. m.updated_at = nil
  26085. }
  26086. // SetDeletedAt sets the "deleted_at" field.
  26087. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  26088. m.deleted_at = &t
  26089. }
  26090. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26091. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  26092. v := m.deleted_at
  26093. if v == nil {
  26094. return
  26095. }
  26096. return *v, true
  26097. }
  26098. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  26099. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26101. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26102. if !m.op.Is(OpUpdateOne) {
  26103. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26104. }
  26105. if m.id == nil || m.oldValue == nil {
  26106. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26107. }
  26108. oldValue, err := m.oldValue(ctx)
  26109. if err != nil {
  26110. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26111. }
  26112. return oldValue.DeletedAt, nil
  26113. }
  26114. // ClearDeletedAt clears the value of the "deleted_at" field.
  26115. func (m *TutorialMutation) ClearDeletedAt() {
  26116. m.deleted_at = nil
  26117. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  26118. }
  26119. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26120. func (m *TutorialMutation) DeletedAtCleared() bool {
  26121. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  26122. return ok
  26123. }
  26124. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26125. func (m *TutorialMutation) ResetDeletedAt() {
  26126. m.deleted_at = nil
  26127. delete(m.clearedFields, tutorial.FieldDeletedAt)
  26128. }
  26129. // SetEmployeeID sets the "employee_id" field.
  26130. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  26131. m.employee = &u
  26132. }
  26133. // EmployeeID returns the value of the "employee_id" field in the mutation.
  26134. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  26135. v := m.employee
  26136. if v == nil {
  26137. return
  26138. }
  26139. return *v, true
  26140. }
  26141. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  26142. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26144. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  26145. if !m.op.Is(OpUpdateOne) {
  26146. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  26147. }
  26148. if m.id == nil || m.oldValue == nil {
  26149. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  26150. }
  26151. oldValue, err := m.oldValue(ctx)
  26152. if err != nil {
  26153. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  26154. }
  26155. return oldValue.EmployeeID, nil
  26156. }
  26157. // ResetEmployeeID resets all changes to the "employee_id" field.
  26158. func (m *TutorialMutation) ResetEmployeeID() {
  26159. m.employee = nil
  26160. }
  26161. // SetIndex sets the "index" field.
  26162. func (m *TutorialMutation) SetIndex(i int) {
  26163. m.index = &i
  26164. m.addindex = nil
  26165. }
  26166. // Index returns the value of the "index" field in the mutation.
  26167. func (m *TutorialMutation) Index() (r int, exists bool) {
  26168. v := m.index
  26169. if v == nil {
  26170. return
  26171. }
  26172. return *v, true
  26173. }
  26174. // OldIndex returns the old "index" field's value of the Tutorial entity.
  26175. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26177. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  26178. if !m.op.Is(OpUpdateOne) {
  26179. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  26180. }
  26181. if m.id == nil || m.oldValue == nil {
  26182. return v, errors.New("OldIndex requires an ID field in the mutation")
  26183. }
  26184. oldValue, err := m.oldValue(ctx)
  26185. if err != nil {
  26186. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  26187. }
  26188. return oldValue.Index, nil
  26189. }
  26190. // AddIndex adds i to the "index" field.
  26191. func (m *TutorialMutation) AddIndex(i int) {
  26192. if m.addindex != nil {
  26193. *m.addindex += i
  26194. } else {
  26195. m.addindex = &i
  26196. }
  26197. }
  26198. // AddedIndex returns the value that was added to the "index" field in this mutation.
  26199. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  26200. v := m.addindex
  26201. if v == nil {
  26202. return
  26203. }
  26204. return *v, true
  26205. }
  26206. // ResetIndex resets all changes to the "index" field.
  26207. func (m *TutorialMutation) ResetIndex() {
  26208. m.index = nil
  26209. m.addindex = nil
  26210. }
  26211. // SetTitle sets the "title" field.
  26212. func (m *TutorialMutation) SetTitle(s string) {
  26213. m.title = &s
  26214. }
  26215. // Title returns the value of the "title" field in the mutation.
  26216. func (m *TutorialMutation) Title() (r string, exists bool) {
  26217. v := m.title
  26218. if v == nil {
  26219. return
  26220. }
  26221. return *v, true
  26222. }
  26223. // OldTitle returns the old "title" field's value of the Tutorial entity.
  26224. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26226. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  26227. if !m.op.Is(OpUpdateOne) {
  26228. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  26229. }
  26230. if m.id == nil || m.oldValue == nil {
  26231. return v, errors.New("OldTitle requires an ID field in the mutation")
  26232. }
  26233. oldValue, err := m.oldValue(ctx)
  26234. if err != nil {
  26235. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  26236. }
  26237. return oldValue.Title, nil
  26238. }
  26239. // ResetTitle resets all changes to the "title" field.
  26240. func (m *TutorialMutation) ResetTitle() {
  26241. m.title = nil
  26242. }
  26243. // SetContent sets the "content" field.
  26244. func (m *TutorialMutation) SetContent(s string) {
  26245. m.content = &s
  26246. }
  26247. // Content returns the value of the "content" field in the mutation.
  26248. func (m *TutorialMutation) Content() (r string, exists bool) {
  26249. v := m.content
  26250. if v == nil {
  26251. return
  26252. }
  26253. return *v, true
  26254. }
  26255. // OldContent returns the old "content" field's value of the Tutorial entity.
  26256. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26258. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  26259. if !m.op.Is(OpUpdateOne) {
  26260. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  26261. }
  26262. if m.id == nil || m.oldValue == nil {
  26263. return v, errors.New("OldContent requires an ID field in the mutation")
  26264. }
  26265. oldValue, err := m.oldValue(ctx)
  26266. if err != nil {
  26267. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  26268. }
  26269. return oldValue.Content, nil
  26270. }
  26271. // ResetContent resets all changes to the "content" field.
  26272. func (m *TutorialMutation) ResetContent() {
  26273. m.content = nil
  26274. }
  26275. // SetOrganizationID sets the "organization_id" field.
  26276. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  26277. m.organization_id = &u
  26278. m.addorganization_id = nil
  26279. }
  26280. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26281. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  26282. v := m.organization_id
  26283. if v == nil {
  26284. return
  26285. }
  26286. return *v, true
  26287. }
  26288. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  26289. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26291. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26292. if !m.op.Is(OpUpdateOne) {
  26293. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26294. }
  26295. if m.id == nil || m.oldValue == nil {
  26296. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26297. }
  26298. oldValue, err := m.oldValue(ctx)
  26299. if err != nil {
  26300. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26301. }
  26302. return oldValue.OrganizationID, nil
  26303. }
  26304. // AddOrganizationID adds u to the "organization_id" field.
  26305. func (m *TutorialMutation) AddOrganizationID(u int64) {
  26306. if m.addorganization_id != nil {
  26307. *m.addorganization_id += u
  26308. } else {
  26309. m.addorganization_id = &u
  26310. }
  26311. }
  26312. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26313. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  26314. v := m.addorganization_id
  26315. if v == nil {
  26316. return
  26317. }
  26318. return *v, true
  26319. }
  26320. // ResetOrganizationID resets all changes to the "organization_id" field.
  26321. func (m *TutorialMutation) ResetOrganizationID() {
  26322. m.organization_id = nil
  26323. m.addorganization_id = nil
  26324. }
  26325. // ClearEmployee clears the "employee" edge to the Employee entity.
  26326. func (m *TutorialMutation) ClearEmployee() {
  26327. m.clearedemployee = true
  26328. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  26329. }
  26330. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  26331. func (m *TutorialMutation) EmployeeCleared() bool {
  26332. return m.clearedemployee
  26333. }
  26334. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  26335. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26336. // EmployeeID instead. It exists only for internal usage by the builders.
  26337. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  26338. if id := m.employee; id != nil {
  26339. ids = append(ids, *id)
  26340. }
  26341. return
  26342. }
  26343. // ResetEmployee resets all changes to the "employee" edge.
  26344. func (m *TutorialMutation) ResetEmployee() {
  26345. m.employee = nil
  26346. m.clearedemployee = false
  26347. }
  26348. // Where appends a list predicates to the TutorialMutation builder.
  26349. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  26350. m.predicates = append(m.predicates, ps...)
  26351. }
  26352. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  26353. // users can use type-assertion to append predicates that do not depend on any generated package.
  26354. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  26355. p := make([]predicate.Tutorial, len(ps))
  26356. for i := range ps {
  26357. p[i] = ps[i]
  26358. }
  26359. m.Where(p...)
  26360. }
  26361. // Op returns the operation name.
  26362. func (m *TutorialMutation) Op() Op {
  26363. return m.op
  26364. }
  26365. // SetOp allows setting the mutation operation.
  26366. func (m *TutorialMutation) SetOp(op Op) {
  26367. m.op = op
  26368. }
  26369. // Type returns the node type of this mutation (Tutorial).
  26370. func (m *TutorialMutation) Type() string {
  26371. return m.typ
  26372. }
  26373. // Fields returns all fields that were changed during this mutation. Note that in
  26374. // order to get all numeric fields that were incremented/decremented, call
  26375. // AddedFields().
  26376. func (m *TutorialMutation) Fields() []string {
  26377. fields := make([]string, 0, 8)
  26378. if m.created_at != nil {
  26379. fields = append(fields, tutorial.FieldCreatedAt)
  26380. }
  26381. if m.updated_at != nil {
  26382. fields = append(fields, tutorial.FieldUpdatedAt)
  26383. }
  26384. if m.deleted_at != nil {
  26385. fields = append(fields, tutorial.FieldDeletedAt)
  26386. }
  26387. if m.employee != nil {
  26388. fields = append(fields, tutorial.FieldEmployeeID)
  26389. }
  26390. if m.index != nil {
  26391. fields = append(fields, tutorial.FieldIndex)
  26392. }
  26393. if m.title != nil {
  26394. fields = append(fields, tutorial.FieldTitle)
  26395. }
  26396. if m.content != nil {
  26397. fields = append(fields, tutorial.FieldContent)
  26398. }
  26399. if m.organization_id != nil {
  26400. fields = append(fields, tutorial.FieldOrganizationID)
  26401. }
  26402. return fields
  26403. }
  26404. // Field returns the value of a field with the given name. The second boolean
  26405. // return value indicates that this field was not set, or was not defined in the
  26406. // schema.
  26407. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  26408. switch name {
  26409. case tutorial.FieldCreatedAt:
  26410. return m.CreatedAt()
  26411. case tutorial.FieldUpdatedAt:
  26412. return m.UpdatedAt()
  26413. case tutorial.FieldDeletedAt:
  26414. return m.DeletedAt()
  26415. case tutorial.FieldEmployeeID:
  26416. return m.EmployeeID()
  26417. case tutorial.FieldIndex:
  26418. return m.Index()
  26419. case tutorial.FieldTitle:
  26420. return m.Title()
  26421. case tutorial.FieldContent:
  26422. return m.Content()
  26423. case tutorial.FieldOrganizationID:
  26424. return m.OrganizationID()
  26425. }
  26426. return nil, false
  26427. }
  26428. // OldField returns the old value of the field from the database. An error is
  26429. // returned if the mutation operation is not UpdateOne, or the query to the
  26430. // database failed.
  26431. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26432. switch name {
  26433. case tutorial.FieldCreatedAt:
  26434. return m.OldCreatedAt(ctx)
  26435. case tutorial.FieldUpdatedAt:
  26436. return m.OldUpdatedAt(ctx)
  26437. case tutorial.FieldDeletedAt:
  26438. return m.OldDeletedAt(ctx)
  26439. case tutorial.FieldEmployeeID:
  26440. return m.OldEmployeeID(ctx)
  26441. case tutorial.FieldIndex:
  26442. return m.OldIndex(ctx)
  26443. case tutorial.FieldTitle:
  26444. return m.OldTitle(ctx)
  26445. case tutorial.FieldContent:
  26446. return m.OldContent(ctx)
  26447. case tutorial.FieldOrganizationID:
  26448. return m.OldOrganizationID(ctx)
  26449. }
  26450. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  26451. }
  26452. // SetField sets the value of a field with the given name. It returns an error if
  26453. // the field is not defined in the schema, or if the type mismatched the field
  26454. // type.
  26455. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  26456. switch name {
  26457. case tutorial.FieldCreatedAt:
  26458. v, ok := value.(time.Time)
  26459. if !ok {
  26460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26461. }
  26462. m.SetCreatedAt(v)
  26463. return nil
  26464. case tutorial.FieldUpdatedAt:
  26465. v, ok := value.(time.Time)
  26466. if !ok {
  26467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26468. }
  26469. m.SetUpdatedAt(v)
  26470. return nil
  26471. case tutorial.FieldDeletedAt:
  26472. v, ok := value.(time.Time)
  26473. if !ok {
  26474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26475. }
  26476. m.SetDeletedAt(v)
  26477. return nil
  26478. case tutorial.FieldEmployeeID:
  26479. v, ok := value.(uint64)
  26480. if !ok {
  26481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26482. }
  26483. m.SetEmployeeID(v)
  26484. return nil
  26485. case tutorial.FieldIndex:
  26486. v, ok := value.(int)
  26487. if !ok {
  26488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26489. }
  26490. m.SetIndex(v)
  26491. return nil
  26492. case tutorial.FieldTitle:
  26493. v, ok := value.(string)
  26494. if !ok {
  26495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26496. }
  26497. m.SetTitle(v)
  26498. return nil
  26499. case tutorial.FieldContent:
  26500. v, ok := value.(string)
  26501. if !ok {
  26502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26503. }
  26504. m.SetContent(v)
  26505. return nil
  26506. case tutorial.FieldOrganizationID:
  26507. v, ok := value.(uint64)
  26508. if !ok {
  26509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26510. }
  26511. m.SetOrganizationID(v)
  26512. return nil
  26513. }
  26514. return fmt.Errorf("unknown Tutorial field %s", name)
  26515. }
  26516. // AddedFields returns all numeric fields that were incremented/decremented during
  26517. // this mutation.
  26518. func (m *TutorialMutation) AddedFields() []string {
  26519. var fields []string
  26520. if m.addindex != nil {
  26521. fields = append(fields, tutorial.FieldIndex)
  26522. }
  26523. if m.addorganization_id != nil {
  26524. fields = append(fields, tutorial.FieldOrganizationID)
  26525. }
  26526. return fields
  26527. }
  26528. // AddedField returns the numeric value that was incremented/decremented on a field
  26529. // with the given name. The second boolean return value indicates that this field
  26530. // was not set, or was not defined in the schema.
  26531. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  26532. switch name {
  26533. case tutorial.FieldIndex:
  26534. return m.AddedIndex()
  26535. case tutorial.FieldOrganizationID:
  26536. return m.AddedOrganizationID()
  26537. }
  26538. return nil, false
  26539. }
  26540. // AddField adds the value to the field with the given name. It returns an error if
  26541. // the field is not defined in the schema, or if the type mismatched the field
  26542. // type.
  26543. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  26544. switch name {
  26545. case tutorial.FieldIndex:
  26546. v, ok := value.(int)
  26547. if !ok {
  26548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26549. }
  26550. m.AddIndex(v)
  26551. return nil
  26552. case tutorial.FieldOrganizationID:
  26553. v, ok := value.(int64)
  26554. if !ok {
  26555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26556. }
  26557. m.AddOrganizationID(v)
  26558. return nil
  26559. }
  26560. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  26561. }
  26562. // ClearedFields returns all nullable fields that were cleared during this
  26563. // mutation.
  26564. func (m *TutorialMutation) ClearedFields() []string {
  26565. var fields []string
  26566. if m.FieldCleared(tutorial.FieldDeletedAt) {
  26567. fields = append(fields, tutorial.FieldDeletedAt)
  26568. }
  26569. return fields
  26570. }
  26571. // FieldCleared returns a boolean indicating if a field with the given name was
  26572. // cleared in this mutation.
  26573. func (m *TutorialMutation) FieldCleared(name string) bool {
  26574. _, ok := m.clearedFields[name]
  26575. return ok
  26576. }
  26577. // ClearField clears the value of the field with the given name. It returns an
  26578. // error if the field is not defined in the schema.
  26579. func (m *TutorialMutation) ClearField(name string) error {
  26580. switch name {
  26581. case tutorial.FieldDeletedAt:
  26582. m.ClearDeletedAt()
  26583. return nil
  26584. }
  26585. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  26586. }
  26587. // ResetField resets all changes in the mutation for the field with the given name.
  26588. // It returns an error if the field is not defined in the schema.
  26589. func (m *TutorialMutation) ResetField(name string) error {
  26590. switch name {
  26591. case tutorial.FieldCreatedAt:
  26592. m.ResetCreatedAt()
  26593. return nil
  26594. case tutorial.FieldUpdatedAt:
  26595. m.ResetUpdatedAt()
  26596. return nil
  26597. case tutorial.FieldDeletedAt:
  26598. m.ResetDeletedAt()
  26599. return nil
  26600. case tutorial.FieldEmployeeID:
  26601. m.ResetEmployeeID()
  26602. return nil
  26603. case tutorial.FieldIndex:
  26604. m.ResetIndex()
  26605. return nil
  26606. case tutorial.FieldTitle:
  26607. m.ResetTitle()
  26608. return nil
  26609. case tutorial.FieldContent:
  26610. m.ResetContent()
  26611. return nil
  26612. case tutorial.FieldOrganizationID:
  26613. m.ResetOrganizationID()
  26614. return nil
  26615. }
  26616. return fmt.Errorf("unknown Tutorial field %s", name)
  26617. }
  26618. // AddedEdges returns all edge names that were set/added in this mutation.
  26619. func (m *TutorialMutation) AddedEdges() []string {
  26620. edges := make([]string, 0, 1)
  26621. if m.employee != nil {
  26622. edges = append(edges, tutorial.EdgeEmployee)
  26623. }
  26624. return edges
  26625. }
  26626. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26627. // name in this mutation.
  26628. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  26629. switch name {
  26630. case tutorial.EdgeEmployee:
  26631. if id := m.employee; id != nil {
  26632. return []ent.Value{*id}
  26633. }
  26634. }
  26635. return nil
  26636. }
  26637. // RemovedEdges returns all edge names that were removed in this mutation.
  26638. func (m *TutorialMutation) RemovedEdges() []string {
  26639. edges := make([]string, 0, 1)
  26640. return edges
  26641. }
  26642. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26643. // the given name in this mutation.
  26644. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  26645. return nil
  26646. }
  26647. // ClearedEdges returns all edge names that were cleared in this mutation.
  26648. func (m *TutorialMutation) ClearedEdges() []string {
  26649. edges := make([]string, 0, 1)
  26650. if m.clearedemployee {
  26651. edges = append(edges, tutorial.EdgeEmployee)
  26652. }
  26653. return edges
  26654. }
  26655. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26656. // was cleared in this mutation.
  26657. func (m *TutorialMutation) EdgeCleared(name string) bool {
  26658. switch name {
  26659. case tutorial.EdgeEmployee:
  26660. return m.clearedemployee
  26661. }
  26662. return false
  26663. }
  26664. // ClearEdge clears the value of the edge with the given name. It returns an error
  26665. // if that edge is not defined in the schema.
  26666. func (m *TutorialMutation) ClearEdge(name string) error {
  26667. switch name {
  26668. case tutorial.EdgeEmployee:
  26669. m.ClearEmployee()
  26670. return nil
  26671. }
  26672. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  26673. }
  26674. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26675. // It returns an error if the edge is not defined in the schema.
  26676. func (m *TutorialMutation) ResetEdge(name string) error {
  26677. switch name {
  26678. case tutorial.EdgeEmployee:
  26679. m.ResetEmployee()
  26680. return nil
  26681. }
  26682. return fmt.Errorf("unknown Tutorial edge %s", name)
  26683. }
  26684. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  26685. type UsageDetailMutation struct {
  26686. config
  26687. op Op
  26688. typ string
  26689. id *uint64
  26690. created_at *time.Time
  26691. updated_at *time.Time
  26692. status *uint8
  26693. addstatus *int8
  26694. _type *int
  26695. add_type *int
  26696. bot_id *string
  26697. receiver_id *string
  26698. app *int
  26699. addapp *int
  26700. session_id *uint64
  26701. addsession_id *int64
  26702. request *string
  26703. response *string
  26704. original_data *custom_types.OriginalData
  26705. total_tokens *uint64
  26706. addtotal_tokens *int64
  26707. prompt_tokens *uint64
  26708. addprompt_tokens *int64
  26709. completion_tokens *uint64
  26710. addcompletion_tokens *int64
  26711. organization_id *uint64
  26712. addorganization_id *int64
  26713. clearedFields map[string]struct{}
  26714. done bool
  26715. oldValue func(context.Context) (*UsageDetail, error)
  26716. predicates []predicate.UsageDetail
  26717. }
  26718. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  26719. // usagedetailOption allows management of the mutation configuration using functional options.
  26720. type usagedetailOption func(*UsageDetailMutation)
  26721. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  26722. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  26723. m := &UsageDetailMutation{
  26724. config: c,
  26725. op: op,
  26726. typ: TypeUsageDetail,
  26727. clearedFields: make(map[string]struct{}),
  26728. }
  26729. for _, opt := range opts {
  26730. opt(m)
  26731. }
  26732. return m
  26733. }
  26734. // withUsageDetailID sets the ID field of the mutation.
  26735. func withUsageDetailID(id uint64) usagedetailOption {
  26736. return func(m *UsageDetailMutation) {
  26737. var (
  26738. err error
  26739. once sync.Once
  26740. value *UsageDetail
  26741. )
  26742. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  26743. once.Do(func() {
  26744. if m.done {
  26745. err = errors.New("querying old values post mutation is not allowed")
  26746. } else {
  26747. value, err = m.Client().UsageDetail.Get(ctx, id)
  26748. }
  26749. })
  26750. return value, err
  26751. }
  26752. m.id = &id
  26753. }
  26754. }
  26755. // withUsageDetail sets the old UsageDetail of the mutation.
  26756. func withUsageDetail(node *UsageDetail) usagedetailOption {
  26757. return func(m *UsageDetailMutation) {
  26758. m.oldValue = func(context.Context) (*UsageDetail, error) {
  26759. return node, nil
  26760. }
  26761. m.id = &node.ID
  26762. }
  26763. }
  26764. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26765. // executed in a transaction (ent.Tx), a transactional client is returned.
  26766. func (m UsageDetailMutation) Client() *Client {
  26767. client := &Client{config: m.config}
  26768. client.init()
  26769. return client
  26770. }
  26771. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26772. // it returns an error otherwise.
  26773. func (m UsageDetailMutation) Tx() (*Tx, error) {
  26774. if _, ok := m.driver.(*txDriver); !ok {
  26775. return nil, errors.New("ent: mutation is not running in a transaction")
  26776. }
  26777. tx := &Tx{config: m.config}
  26778. tx.init()
  26779. return tx, nil
  26780. }
  26781. // SetID sets the value of the id field. Note that this
  26782. // operation is only accepted on creation of UsageDetail entities.
  26783. func (m *UsageDetailMutation) SetID(id uint64) {
  26784. m.id = &id
  26785. }
  26786. // ID returns the ID value in the mutation. Note that the ID is only available
  26787. // if it was provided to the builder or after it was returned from the database.
  26788. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  26789. if m.id == nil {
  26790. return
  26791. }
  26792. return *m.id, true
  26793. }
  26794. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26795. // That means, if the mutation is applied within a transaction with an isolation level such
  26796. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26797. // or updated by the mutation.
  26798. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  26799. switch {
  26800. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26801. id, exists := m.ID()
  26802. if exists {
  26803. return []uint64{id}, nil
  26804. }
  26805. fallthrough
  26806. case m.op.Is(OpUpdate | OpDelete):
  26807. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  26808. default:
  26809. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26810. }
  26811. }
  26812. // SetCreatedAt sets the "created_at" field.
  26813. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  26814. m.created_at = &t
  26815. }
  26816. // CreatedAt returns the value of the "created_at" field in the mutation.
  26817. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  26818. v := m.created_at
  26819. if v == nil {
  26820. return
  26821. }
  26822. return *v, true
  26823. }
  26824. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  26825. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26827. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26828. if !m.op.Is(OpUpdateOne) {
  26829. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26830. }
  26831. if m.id == nil || m.oldValue == nil {
  26832. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26833. }
  26834. oldValue, err := m.oldValue(ctx)
  26835. if err != nil {
  26836. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26837. }
  26838. return oldValue.CreatedAt, nil
  26839. }
  26840. // ResetCreatedAt resets all changes to the "created_at" field.
  26841. func (m *UsageDetailMutation) ResetCreatedAt() {
  26842. m.created_at = nil
  26843. }
  26844. // SetUpdatedAt sets the "updated_at" field.
  26845. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  26846. m.updated_at = &t
  26847. }
  26848. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26849. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  26850. v := m.updated_at
  26851. if v == nil {
  26852. return
  26853. }
  26854. return *v, true
  26855. }
  26856. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  26857. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26859. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26860. if !m.op.Is(OpUpdateOne) {
  26861. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26862. }
  26863. if m.id == nil || m.oldValue == nil {
  26864. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26865. }
  26866. oldValue, err := m.oldValue(ctx)
  26867. if err != nil {
  26868. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26869. }
  26870. return oldValue.UpdatedAt, nil
  26871. }
  26872. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26873. func (m *UsageDetailMutation) ResetUpdatedAt() {
  26874. m.updated_at = nil
  26875. }
  26876. // SetStatus sets the "status" field.
  26877. func (m *UsageDetailMutation) SetStatus(u uint8) {
  26878. m.status = &u
  26879. m.addstatus = nil
  26880. }
  26881. // Status returns the value of the "status" field in the mutation.
  26882. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  26883. v := m.status
  26884. if v == nil {
  26885. return
  26886. }
  26887. return *v, true
  26888. }
  26889. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  26890. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26892. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26893. if !m.op.Is(OpUpdateOne) {
  26894. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26895. }
  26896. if m.id == nil || m.oldValue == nil {
  26897. return v, errors.New("OldStatus requires an ID field in the mutation")
  26898. }
  26899. oldValue, err := m.oldValue(ctx)
  26900. if err != nil {
  26901. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26902. }
  26903. return oldValue.Status, nil
  26904. }
  26905. // AddStatus adds u to the "status" field.
  26906. func (m *UsageDetailMutation) AddStatus(u int8) {
  26907. if m.addstatus != nil {
  26908. *m.addstatus += u
  26909. } else {
  26910. m.addstatus = &u
  26911. }
  26912. }
  26913. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26914. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  26915. v := m.addstatus
  26916. if v == nil {
  26917. return
  26918. }
  26919. return *v, true
  26920. }
  26921. // ClearStatus clears the value of the "status" field.
  26922. func (m *UsageDetailMutation) ClearStatus() {
  26923. m.status = nil
  26924. m.addstatus = nil
  26925. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  26926. }
  26927. // StatusCleared returns if the "status" field was cleared in this mutation.
  26928. func (m *UsageDetailMutation) StatusCleared() bool {
  26929. _, ok := m.clearedFields[usagedetail.FieldStatus]
  26930. return ok
  26931. }
  26932. // ResetStatus resets all changes to the "status" field.
  26933. func (m *UsageDetailMutation) ResetStatus() {
  26934. m.status = nil
  26935. m.addstatus = nil
  26936. delete(m.clearedFields, usagedetail.FieldStatus)
  26937. }
  26938. // SetType sets the "type" field.
  26939. func (m *UsageDetailMutation) SetType(i int) {
  26940. m._type = &i
  26941. m.add_type = nil
  26942. }
  26943. // GetType returns the value of the "type" field in the mutation.
  26944. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  26945. v := m._type
  26946. if v == nil {
  26947. return
  26948. }
  26949. return *v, true
  26950. }
  26951. // OldType returns the old "type" field's value of the UsageDetail entity.
  26952. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26954. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  26955. if !m.op.Is(OpUpdateOne) {
  26956. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26957. }
  26958. if m.id == nil || m.oldValue == nil {
  26959. return v, errors.New("OldType requires an ID field in the mutation")
  26960. }
  26961. oldValue, err := m.oldValue(ctx)
  26962. if err != nil {
  26963. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26964. }
  26965. return oldValue.Type, nil
  26966. }
  26967. // AddType adds i to the "type" field.
  26968. func (m *UsageDetailMutation) AddType(i int) {
  26969. if m.add_type != nil {
  26970. *m.add_type += i
  26971. } else {
  26972. m.add_type = &i
  26973. }
  26974. }
  26975. // AddedType returns the value that was added to the "type" field in this mutation.
  26976. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  26977. v := m.add_type
  26978. if v == nil {
  26979. return
  26980. }
  26981. return *v, true
  26982. }
  26983. // ClearType clears the value of the "type" field.
  26984. func (m *UsageDetailMutation) ClearType() {
  26985. m._type = nil
  26986. m.add_type = nil
  26987. m.clearedFields[usagedetail.FieldType] = struct{}{}
  26988. }
  26989. // TypeCleared returns if the "type" field was cleared in this mutation.
  26990. func (m *UsageDetailMutation) TypeCleared() bool {
  26991. _, ok := m.clearedFields[usagedetail.FieldType]
  26992. return ok
  26993. }
  26994. // ResetType resets all changes to the "type" field.
  26995. func (m *UsageDetailMutation) ResetType() {
  26996. m._type = nil
  26997. m.add_type = nil
  26998. delete(m.clearedFields, usagedetail.FieldType)
  26999. }
  27000. // SetBotID sets the "bot_id" field.
  27001. func (m *UsageDetailMutation) SetBotID(s string) {
  27002. m.bot_id = &s
  27003. }
  27004. // BotID returns the value of the "bot_id" field in the mutation.
  27005. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  27006. v := m.bot_id
  27007. if v == nil {
  27008. return
  27009. }
  27010. return *v, true
  27011. }
  27012. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  27013. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27015. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  27016. if !m.op.Is(OpUpdateOne) {
  27017. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  27018. }
  27019. if m.id == nil || m.oldValue == nil {
  27020. return v, errors.New("OldBotID requires an ID field in the mutation")
  27021. }
  27022. oldValue, err := m.oldValue(ctx)
  27023. if err != nil {
  27024. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27025. }
  27026. return oldValue.BotID, nil
  27027. }
  27028. // ResetBotID resets all changes to the "bot_id" field.
  27029. func (m *UsageDetailMutation) ResetBotID() {
  27030. m.bot_id = nil
  27031. }
  27032. // SetReceiverID sets the "receiver_id" field.
  27033. func (m *UsageDetailMutation) SetReceiverID(s string) {
  27034. m.receiver_id = &s
  27035. }
  27036. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  27037. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  27038. v := m.receiver_id
  27039. if v == nil {
  27040. return
  27041. }
  27042. return *v, true
  27043. }
  27044. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  27045. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27047. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  27048. if !m.op.Is(OpUpdateOne) {
  27049. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  27050. }
  27051. if m.id == nil || m.oldValue == nil {
  27052. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  27053. }
  27054. oldValue, err := m.oldValue(ctx)
  27055. if err != nil {
  27056. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  27057. }
  27058. return oldValue.ReceiverID, nil
  27059. }
  27060. // ResetReceiverID resets all changes to the "receiver_id" field.
  27061. func (m *UsageDetailMutation) ResetReceiverID() {
  27062. m.receiver_id = nil
  27063. }
  27064. // SetApp sets the "app" field.
  27065. func (m *UsageDetailMutation) SetApp(i int) {
  27066. m.app = &i
  27067. m.addapp = nil
  27068. }
  27069. // App returns the value of the "app" field in the mutation.
  27070. func (m *UsageDetailMutation) App() (r int, exists bool) {
  27071. v := m.app
  27072. if v == nil {
  27073. return
  27074. }
  27075. return *v, true
  27076. }
  27077. // OldApp returns the old "app" field's value of the UsageDetail entity.
  27078. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27080. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  27081. if !m.op.Is(OpUpdateOne) {
  27082. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  27083. }
  27084. if m.id == nil || m.oldValue == nil {
  27085. return v, errors.New("OldApp requires an ID field in the mutation")
  27086. }
  27087. oldValue, err := m.oldValue(ctx)
  27088. if err != nil {
  27089. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  27090. }
  27091. return oldValue.App, nil
  27092. }
  27093. // AddApp adds i to the "app" field.
  27094. func (m *UsageDetailMutation) AddApp(i int) {
  27095. if m.addapp != nil {
  27096. *m.addapp += i
  27097. } else {
  27098. m.addapp = &i
  27099. }
  27100. }
  27101. // AddedApp returns the value that was added to the "app" field in this mutation.
  27102. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  27103. v := m.addapp
  27104. if v == nil {
  27105. return
  27106. }
  27107. return *v, true
  27108. }
  27109. // ClearApp clears the value of the "app" field.
  27110. func (m *UsageDetailMutation) ClearApp() {
  27111. m.app = nil
  27112. m.addapp = nil
  27113. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  27114. }
  27115. // AppCleared returns if the "app" field was cleared in this mutation.
  27116. func (m *UsageDetailMutation) AppCleared() bool {
  27117. _, ok := m.clearedFields[usagedetail.FieldApp]
  27118. return ok
  27119. }
  27120. // ResetApp resets all changes to the "app" field.
  27121. func (m *UsageDetailMutation) ResetApp() {
  27122. m.app = nil
  27123. m.addapp = nil
  27124. delete(m.clearedFields, usagedetail.FieldApp)
  27125. }
  27126. // SetSessionID sets the "session_id" field.
  27127. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  27128. m.session_id = &u
  27129. m.addsession_id = nil
  27130. }
  27131. // SessionID returns the value of the "session_id" field in the mutation.
  27132. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  27133. v := m.session_id
  27134. if v == nil {
  27135. return
  27136. }
  27137. return *v, true
  27138. }
  27139. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  27140. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27142. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  27143. if !m.op.Is(OpUpdateOne) {
  27144. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  27145. }
  27146. if m.id == nil || m.oldValue == nil {
  27147. return v, errors.New("OldSessionID requires an ID field in the mutation")
  27148. }
  27149. oldValue, err := m.oldValue(ctx)
  27150. if err != nil {
  27151. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  27152. }
  27153. return oldValue.SessionID, nil
  27154. }
  27155. // AddSessionID adds u to the "session_id" field.
  27156. func (m *UsageDetailMutation) AddSessionID(u int64) {
  27157. if m.addsession_id != nil {
  27158. *m.addsession_id += u
  27159. } else {
  27160. m.addsession_id = &u
  27161. }
  27162. }
  27163. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  27164. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  27165. v := m.addsession_id
  27166. if v == nil {
  27167. return
  27168. }
  27169. return *v, true
  27170. }
  27171. // ClearSessionID clears the value of the "session_id" field.
  27172. func (m *UsageDetailMutation) ClearSessionID() {
  27173. m.session_id = nil
  27174. m.addsession_id = nil
  27175. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  27176. }
  27177. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  27178. func (m *UsageDetailMutation) SessionIDCleared() bool {
  27179. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  27180. return ok
  27181. }
  27182. // ResetSessionID resets all changes to the "session_id" field.
  27183. func (m *UsageDetailMutation) ResetSessionID() {
  27184. m.session_id = nil
  27185. m.addsession_id = nil
  27186. delete(m.clearedFields, usagedetail.FieldSessionID)
  27187. }
  27188. // SetRequest sets the "request" field.
  27189. func (m *UsageDetailMutation) SetRequest(s string) {
  27190. m.request = &s
  27191. }
  27192. // Request returns the value of the "request" field in the mutation.
  27193. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  27194. v := m.request
  27195. if v == nil {
  27196. return
  27197. }
  27198. return *v, true
  27199. }
  27200. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  27201. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27203. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  27204. if !m.op.Is(OpUpdateOne) {
  27205. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  27206. }
  27207. if m.id == nil || m.oldValue == nil {
  27208. return v, errors.New("OldRequest requires an ID field in the mutation")
  27209. }
  27210. oldValue, err := m.oldValue(ctx)
  27211. if err != nil {
  27212. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  27213. }
  27214. return oldValue.Request, nil
  27215. }
  27216. // ResetRequest resets all changes to the "request" field.
  27217. func (m *UsageDetailMutation) ResetRequest() {
  27218. m.request = nil
  27219. }
  27220. // SetResponse sets the "response" field.
  27221. func (m *UsageDetailMutation) SetResponse(s string) {
  27222. m.response = &s
  27223. }
  27224. // Response returns the value of the "response" field in the mutation.
  27225. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  27226. v := m.response
  27227. if v == nil {
  27228. return
  27229. }
  27230. return *v, true
  27231. }
  27232. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  27233. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27235. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  27236. if !m.op.Is(OpUpdateOne) {
  27237. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  27238. }
  27239. if m.id == nil || m.oldValue == nil {
  27240. return v, errors.New("OldResponse requires an ID field in the mutation")
  27241. }
  27242. oldValue, err := m.oldValue(ctx)
  27243. if err != nil {
  27244. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  27245. }
  27246. return oldValue.Response, nil
  27247. }
  27248. // ResetResponse resets all changes to the "response" field.
  27249. func (m *UsageDetailMutation) ResetResponse() {
  27250. m.response = nil
  27251. }
  27252. // SetOriginalData sets the "original_data" field.
  27253. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  27254. m.original_data = &ctd
  27255. }
  27256. // OriginalData returns the value of the "original_data" field in the mutation.
  27257. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  27258. v := m.original_data
  27259. if v == nil {
  27260. return
  27261. }
  27262. return *v, true
  27263. }
  27264. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  27265. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27267. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  27268. if !m.op.Is(OpUpdateOne) {
  27269. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  27270. }
  27271. if m.id == nil || m.oldValue == nil {
  27272. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  27273. }
  27274. oldValue, err := m.oldValue(ctx)
  27275. if err != nil {
  27276. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  27277. }
  27278. return oldValue.OriginalData, nil
  27279. }
  27280. // ResetOriginalData resets all changes to the "original_data" field.
  27281. func (m *UsageDetailMutation) ResetOriginalData() {
  27282. m.original_data = nil
  27283. }
  27284. // SetTotalTokens sets the "total_tokens" field.
  27285. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  27286. m.total_tokens = &u
  27287. m.addtotal_tokens = nil
  27288. }
  27289. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  27290. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  27291. v := m.total_tokens
  27292. if v == nil {
  27293. return
  27294. }
  27295. return *v, true
  27296. }
  27297. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  27298. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27300. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  27301. if !m.op.Is(OpUpdateOne) {
  27302. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  27303. }
  27304. if m.id == nil || m.oldValue == nil {
  27305. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  27306. }
  27307. oldValue, err := m.oldValue(ctx)
  27308. if err != nil {
  27309. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  27310. }
  27311. return oldValue.TotalTokens, nil
  27312. }
  27313. // AddTotalTokens adds u to the "total_tokens" field.
  27314. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  27315. if m.addtotal_tokens != nil {
  27316. *m.addtotal_tokens += u
  27317. } else {
  27318. m.addtotal_tokens = &u
  27319. }
  27320. }
  27321. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  27322. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  27323. v := m.addtotal_tokens
  27324. if v == nil {
  27325. return
  27326. }
  27327. return *v, true
  27328. }
  27329. // ClearTotalTokens clears the value of the "total_tokens" field.
  27330. func (m *UsageDetailMutation) ClearTotalTokens() {
  27331. m.total_tokens = nil
  27332. m.addtotal_tokens = nil
  27333. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  27334. }
  27335. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  27336. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  27337. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  27338. return ok
  27339. }
  27340. // ResetTotalTokens resets all changes to the "total_tokens" field.
  27341. func (m *UsageDetailMutation) ResetTotalTokens() {
  27342. m.total_tokens = nil
  27343. m.addtotal_tokens = nil
  27344. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  27345. }
  27346. // SetPromptTokens sets the "prompt_tokens" field.
  27347. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  27348. m.prompt_tokens = &u
  27349. m.addprompt_tokens = nil
  27350. }
  27351. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  27352. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  27353. v := m.prompt_tokens
  27354. if v == nil {
  27355. return
  27356. }
  27357. return *v, true
  27358. }
  27359. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  27360. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27362. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  27363. if !m.op.Is(OpUpdateOne) {
  27364. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  27365. }
  27366. if m.id == nil || m.oldValue == nil {
  27367. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  27368. }
  27369. oldValue, err := m.oldValue(ctx)
  27370. if err != nil {
  27371. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  27372. }
  27373. return oldValue.PromptTokens, nil
  27374. }
  27375. // AddPromptTokens adds u to the "prompt_tokens" field.
  27376. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  27377. if m.addprompt_tokens != nil {
  27378. *m.addprompt_tokens += u
  27379. } else {
  27380. m.addprompt_tokens = &u
  27381. }
  27382. }
  27383. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  27384. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  27385. v := m.addprompt_tokens
  27386. if v == nil {
  27387. return
  27388. }
  27389. return *v, true
  27390. }
  27391. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  27392. func (m *UsageDetailMutation) ClearPromptTokens() {
  27393. m.prompt_tokens = nil
  27394. m.addprompt_tokens = nil
  27395. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  27396. }
  27397. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  27398. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  27399. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  27400. return ok
  27401. }
  27402. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  27403. func (m *UsageDetailMutation) ResetPromptTokens() {
  27404. m.prompt_tokens = nil
  27405. m.addprompt_tokens = nil
  27406. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  27407. }
  27408. // SetCompletionTokens sets the "completion_tokens" field.
  27409. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  27410. m.completion_tokens = &u
  27411. m.addcompletion_tokens = nil
  27412. }
  27413. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  27414. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  27415. v := m.completion_tokens
  27416. if v == nil {
  27417. return
  27418. }
  27419. return *v, true
  27420. }
  27421. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  27422. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27424. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  27425. if !m.op.Is(OpUpdateOne) {
  27426. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  27427. }
  27428. if m.id == nil || m.oldValue == nil {
  27429. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  27430. }
  27431. oldValue, err := m.oldValue(ctx)
  27432. if err != nil {
  27433. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  27434. }
  27435. return oldValue.CompletionTokens, nil
  27436. }
  27437. // AddCompletionTokens adds u to the "completion_tokens" field.
  27438. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  27439. if m.addcompletion_tokens != nil {
  27440. *m.addcompletion_tokens += u
  27441. } else {
  27442. m.addcompletion_tokens = &u
  27443. }
  27444. }
  27445. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  27446. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  27447. v := m.addcompletion_tokens
  27448. if v == nil {
  27449. return
  27450. }
  27451. return *v, true
  27452. }
  27453. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  27454. func (m *UsageDetailMutation) ClearCompletionTokens() {
  27455. m.completion_tokens = nil
  27456. m.addcompletion_tokens = nil
  27457. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  27458. }
  27459. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  27460. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  27461. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  27462. return ok
  27463. }
  27464. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  27465. func (m *UsageDetailMutation) ResetCompletionTokens() {
  27466. m.completion_tokens = nil
  27467. m.addcompletion_tokens = nil
  27468. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  27469. }
  27470. // SetOrganizationID sets the "organization_id" field.
  27471. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  27472. m.organization_id = &u
  27473. m.addorganization_id = nil
  27474. }
  27475. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27476. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  27477. v := m.organization_id
  27478. if v == nil {
  27479. return
  27480. }
  27481. return *v, true
  27482. }
  27483. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  27484. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27486. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27487. if !m.op.Is(OpUpdateOne) {
  27488. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27489. }
  27490. if m.id == nil || m.oldValue == nil {
  27491. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27492. }
  27493. oldValue, err := m.oldValue(ctx)
  27494. if err != nil {
  27495. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27496. }
  27497. return oldValue.OrganizationID, nil
  27498. }
  27499. // AddOrganizationID adds u to the "organization_id" field.
  27500. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  27501. if m.addorganization_id != nil {
  27502. *m.addorganization_id += u
  27503. } else {
  27504. m.addorganization_id = &u
  27505. }
  27506. }
  27507. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27508. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  27509. v := m.addorganization_id
  27510. if v == nil {
  27511. return
  27512. }
  27513. return *v, true
  27514. }
  27515. // ClearOrganizationID clears the value of the "organization_id" field.
  27516. func (m *UsageDetailMutation) ClearOrganizationID() {
  27517. m.organization_id = nil
  27518. m.addorganization_id = nil
  27519. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  27520. }
  27521. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27522. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  27523. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  27524. return ok
  27525. }
  27526. // ResetOrganizationID resets all changes to the "organization_id" field.
  27527. func (m *UsageDetailMutation) ResetOrganizationID() {
  27528. m.organization_id = nil
  27529. m.addorganization_id = nil
  27530. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  27531. }
  27532. // Where appends a list predicates to the UsageDetailMutation builder.
  27533. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  27534. m.predicates = append(m.predicates, ps...)
  27535. }
  27536. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  27537. // users can use type-assertion to append predicates that do not depend on any generated package.
  27538. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  27539. p := make([]predicate.UsageDetail, len(ps))
  27540. for i := range ps {
  27541. p[i] = ps[i]
  27542. }
  27543. m.Where(p...)
  27544. }
  27545. // Op returns the operation name.
  27546. func (m *UsageDetailMutation) Op() Op {
  27547. return m.op
  27548. }
  27549. // SetOp allows setting the mutation operation.
  27550. func (m *UsageDetailMutation) SetOp(op Op) {
  27551. m.op = op
  27552. }
  27553. // Type returns the node type of this mutation (UsageDetail).
  27554. func (m *UsageDetailMutation) Type() string {
  27555. return m.typ
  27556. }
  27557. // Fields returns all fields that were changed during this mutation. Note that in
  27558. // order to get all numeric fields that were incremented/decremented, call
  27559. // AddedFields().
  27560. func (m *UsageDetailMutation) Fields() []string {
  27561. fields := make([]string, 0, 15)
  27562. if m.created_at != nil {
  27563. fields = append(fields, usagedetail.FieldCreatedAt)
  27564. }
  27565. if m.updated_at != nil {
  27566. fields = append(fields, usagedetail.FieldUpdatedAt)
  27567. }
  27568. if m.status != nil {
  27569. fields = append(fields, usagedetail.FieldStatus)
  27570. }
  27571. if m._type != nil {
  27572. fields = append(fields, usagedetail.FieldType)
  27573. }
  27574. if m.bot_id != nil {
  27575. fields = append(fields, usagedetail.FieldBotID)
  27576. }
  27577. if m.receiver_id != nil {
  27578. fields = append(fields, usagedetail.FieldReceiverID)
  27579. }
  27580. if m.app != nil {
  27581. fields = append(fields, usagedetail.FieldApp)
  27582. }
  27583. if m.session_id != nil {
  27584. fields = append(fields, usagedetail.FieldSessionID)
  27585. }
  27586. if m.request != nil {
  27587. fields = append(fields, usagedetail.FieldRequest)
  27588. }
  27589. if m.response != nil {
  27590. fields = append(fields, usagedetail.FieldResponse)
  27591. }
  27592. if m.original_data != nil {
  27593. fields = append(fields, usagedetail.FieldOriginalData)
  27594. }
  27595. if m.total_tokens != nil {
  27596. fields = append(fields, usagedetail.FieldTotalTokens)
  27597. }
  27598. if m.prompt_tokens != nil {
  27599. fields = append(fields, usagedetail.FieldPromptTokens)
  27600. }
  27601. if m.completion_tokens != nil {
  27602. fields = append(fields, usagedetail.FieldCompletionTokens)
  27603. }
  27604. if m.organization_id != nil {
  27605. fields = append(fields, usagedetail.FieldOrganizationID)
  27606. }
  27607. return fields
  27608. }
  27609. // Field returns the value of a field with the given name. The second boolean
  27610. // return value indicates that this field was not set, or was not defined in the
  27611. // schema.
  27612. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  27613. switch name {
  27614. case usagedetail.FieldCreatedAt:
  27615. return m.CreatedAt()
  27616. case usagedetail.FieldUpdatedAt:
  27617. return m.UpdatedAt()
  27618. case usagedetail.FieldStatus:
  27619. return m.Status()
  27620. case usagedetail.FieldType:
  27621. return m.GetType()
  27622. case usagedetail.FieldBotID:
  27623. return m.BotID()
  27624. case usagedetail.FieldReceiverID:
  27625. return m.ReceiverID()
  27626. case usagedetail.FieldApp:
  27627. return m.App()
  27628. case usagedetail.FieldSessionID:
  27629. return m.SessionID()
  27630. case usagedetail.FieldRequest:
  27631. return m.Request()
  27632. case usagedetail.FieldResponse:
  27633. return m.Response()
  27634. case usagedetail.FieldOriginalData:
  27635. return m.OriginalData()
  27636. case usagedetail.FieldTotalTokens:
  27637. return m.TotalTokens()
  27638. case usagedetail.FieldPromptTokens:
  27639. return m.PromptTokens()
  27640. case usagedetail.FieldCompletionTokens:
  27641. return m.CompletionTokens()
  27642. case usagedetail.FieldOrganizationID:
  27643. return m.OrganizationID()
  27644. }
  27645. return nil, false
  27646. }
  27647. // OldField returns the old value of the field from the database. An error is
  27648. // returned if the mutation operation is not UpdateOne, or the query to the
  27649. // database failed.
  27650. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27651. switch name {
  27652. case usagedetail.FieldCreatedAt:
  27653. return m.OldCreatedAt(ctx)
  27654. case usagedetail.FieldUpdatedAt:
  27655. return m.OldUpdatedAt(ctx)
  27656. case usagedetail.FieldStatus:
  27657. return m.OldStatus(ctx)
  27658. case usagedetail.FieldType:
  27659. return m.OldType(ctx)
  27660. case usagedetail.FieldBotID:
  27661. return m.OldBotID(ctx)
  27662. case usagedetail.FieldReceiverID:
  27663. return m.OldReceiverID(ctx)
  27664. case usagedetail.FieldApp:
  27665. return m.OldApp(ctx)
  27666. case usagedetail.FieldSessionID:
  27667. return m.OldSessionID(ctx)
  27668. case usagedetail.FieldRequest:
  27669. return m.OldRequest(ctx)
  27670. case usagedetail.FieldResponse:
  27671. return m.OldResponse(ctx)
  27672. case usagedetail.FieldOriginalData:
  27673. return m.OldOriginalData(ctx)
  27674. case usagedetail.FieldTotalTokens:
  27675. return m.OldTotalTokens(ctx)
  27676. case usagedetail.FieldPromptTokens:
  27677. return m.OldPromptTokens(ctx)
  27678. case usagedetail.FieldCompletionTokens:
  27679. return m.OldCompletionTokens(ctx)
  27680. case usagedetail.FieldOrganizationID:
  27681. return m.OldOrganizationID(ctx)
  27682. }
  27683. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  27684. }
  27685. // SetField sets the value of a field with the given name. It returns an error if
  27686. // the field is not defined in the schema, or if the type mismatched the field
  27687. // type.
  27688. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  27689. switch name {
  27690. case usagedetail.FieldCreatedAt:
  27691. v, ok := value.(time.Time)
  27692. if !ok {
  27693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27694. }
  27695. m.SetCreatedAt(v)
  27696. return nil
  27697. case usagedetail.FieldUpdatedAt:
  27698. v, ok := value.(time.Time)
  27699. if !ok {
  27700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27701. }
  27702. m.SetUpdatedAt(v)
  27703. return nil
  27704. case usagedetail.FieldStatus:
  27705. v, ok := value.(uint8)
  27706. if !ok {
  27707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27708. }
  27709. m.SetStatus(v)
  27710. return nil
  27711. case usagedetail.FieldType:
  27712. v, ok := value.(int)
  27713. if !ok {
  27714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27715. }
  27716. m.SetType(v)
  27717. return nil
  27718. case usagedetail.FieldBotID:
  27719. v, ok := value.(string)
  27720. if !ok {
  27721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27722. }
  27723. m.SetBotID(v)
  27724. return nil
  27725. case usagedetail.FieldReceiverID:
  27726. v, ok := value.(string)
  27727. if !ok {
  27728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27729. }
  27730. m.SetReceiverID(v)
  27731. return nil
  27732. case usagedetail.FieldApp:
  27733. v, ok := value.(int)
  27734. if !ok {
  27735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27736. }
  27737. m.SetApp(v)
  27738. return nil
  27739. case usagedetail.FieldSessionID:
  27740. v, ok := value.(uint64)
  27741. if !ok {
  27742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27743. }
  27744. m.SetSessionID(v)
  27745. return nil
  27746. case usagedetail.FieldRequest:
  27747. v, ok := value.(string)
  27748. if !ok {
  27749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27750. }
  27751. m.SetRequest(v)
  27752. return nil
  27753. case usagedetail.FieldResponse:
  27754. v, ok := value.(string)
  27755. if !ok {
  27756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27757. }
  27758. m.SetResponse(v)
  27759. return nil
  27760. case usagedetail.FieldOriginalData:
  27761. v, ok := value.(custom_types.OriginalData)
  27762. if !ok {
  27763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27764. }
  27765. m.SetOriginalData(v)
  27766. return nil
  27767. case usagedetail.FieldTotalTokens:
  27768. v, ok := value.(uint64)
  27769. if !ok {
  27770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27771. }
  27772. m.SetTotalTokens(v)
  27773. return nil
  27774. case usagedetail.FieldPromptTokens:
  27775. v, ok := value.(uint64)
  27776. if !ok {
  27777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27778. }
  27779. m.SetPromptTokens(v)
  27780. return nil
  27781. case usagedetail.FieldCompletionTokens:
  27782. v, ok := value.(uint64)
  27783. if !ok {
  27784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27785. }
  27786. m.SetCompletionTokens(v)
  27787. return nil
  27788. case usagedetail.FieldOrganizationID:
  27789. v, ok := value.(uint64)
  27790. if !ok {
  27791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27792. }
  27793. m.SetOrganizationID(v)
  27794. return nil
  27795. }
  27796. return fmt.Errorf("unknown UsageDetail field %s", name)
  27797. }
  27798. // AddedFields returns all numeric fields that were incremented/decremented during
  27799. // this mutation.
  27800. func (m *UsageDetailMutation) AddedFields() []string {
  27801. var fields []string
  27802. if m.addstatus != nil {
  27803. fields = append(fields, usagedetail.FieldStatus)
  27804. }
  27805. if m.add_type != nil {
  27806. fields = append(fields, usagedetail.FieldType)
  27807. }
  27808. if m.addapp != nil {
  27809. fields = append(fields, usagedetail.FieldApp)
  27810. }
  27811. if m.addsession_id != nil {
  27812. fields = append(fields, usagedetail.FieldSessionID)
  27813. }
  27814. if m.addtotal_tokens != nil {
  27815. fields = append(fields, usagedetail.FieldTotalTokens)
  27816. }
  27817. if m.addprompt_tokens != nil {
  27818. fields = append(fields, usagedetail.FieldPromptTokens)
  27819. }
  27820. if m.addcompletion_tokens != nil {
  27821. fields = append(fields, usagedetail.FieldCompletionTokens)
  27822. }
  27823. if m.addorganization_id != nil {
  27824. fields = append(fields, usagedetail.FieldOrganizationID)
  27825. }
  27826. return fields
  27827. }
  27828. // AddedField returns the numeric value that was incremented/decremented on a field
  27829. // with the given name. The second boolean return value indicates that this field
  27830. // was not set, or was not defined in the schema.
  27831. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  27832. switch name {
  27833. case usagedetail.FieldStatus:
  27834. return m.AddedStatus()
  27835. case usagedetail.FieldType:
  27836. return m.AddedType()
  27837. case usagedetail.FieldApp:
  27838. return m.AddedApp()
  27839. case usagedetail.FieldSessionID:
  27840. return m.AddedSessionID()
  27841. case usagedetail.FieldTotalTokens:
  27842. return m.AddedTotalTokens()
  27843. case usagedetail.FieldPromptTokens:
  27844. return m.AddedPromptTokens()
  27845. case usagedetail.FieldCompletionTokens:
  27846. return m.AddedCompletionTokens()
  27847. case usagedetail.FieldOrganizationID:
  27848. return m.AddedOrganizationID()
  27849. }
  27850. return nil, false
  27851. }
  27852. // AddField adds the value to the field with the given name. It returns an error if
  27853. // the field is not defined in the schema, or if the type mismatched the field
  27854. // type.
  27855. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  27856. switch name {
  27857. case usagedetail.FieldStatus:
  27858. v, ok := value.(int8)
  27859. if !ok {
  27860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27861. }
  27862. m.AddStatus(v)
  27863. return nil
  27864. case usagedetail.FieldType:
  27865. v, ok := value.(int)
  27866. if !ok {
  27867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27868. }
  27869. m.AddType(v)
  27870. return nil
  27871. case usagedetail.FieldApp:
  27872. v, ok := value.(int)
  27873. if !ok {
  27874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27875. }
  27876. m.AddApp(v)
  27877. return nil
  27878. case usagedetail.FieldSessionID:
  27879. v, ok := value.(int64)
  27880. if !ok {
  27881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27882. }
  27883. m.AddSessionID(v)
  27884. return nil
  27885. case usagedetail.FieldTotalTokens:
  27886. v, ok := value.(int64)
  27887. if !ok {
  27888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27889. }
  27890. m.AddTotalTokens(v)
  27891. return nil
  27892. case usagedetail.FieldPromptTokens:
  27893. v, ok := value.(int64)
  27894. if !ok {
  27895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27896. }
  27897. m.AddPromptTokens(v)
  27898. return nil
  27899. case usagedetail.FieldCompletionTokens:
  27900. v, ok := value.(int64)
  27901. if !ok {
  27902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27903. }
  27904. m.AddCompletionTokens(v)
  27905. return nil
  27906. case usagedetail.FieldOrganizationID:
  27907. v, ok := value.(int64)
  27908. if !ok {
  27909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27910. }
  27911. m.AddOrganizationID(v)
  27912. return nil
  27913. }
  27914. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  27915. }
  27916. // ClearedFields returns all nullable fields that were cleared during this
  27917. // mutation.
  27918. func (m *UsageDetailMutation) ClearedFields() []string {
  27919. var fields []string
  27920. if m.FieldCleared(usagedetail.FieldStatus) {
  27921. fields = append(fields, usagedetail.FieldStatus)
  27922. }
  27923. if m.FieldCleared(usagedetail.FieldType) {
  27924. fields = append(fields, usagedetail.FieldType)
  27925. }
  27926. if m.FieldCleared(usagedetail.FieldApp) {
  27927. fields = append(fields, usagedetail.FieldApp)
  27928. }
  27929. if m.FieldCleared(usagedetail.FieldSessionID) {
  27930. fields = append(fields, usagedetail.FieldSessionID)
  27931. }
  27932. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  27933. fields = append(fields, usagedetail.FieldTotalTokens)
  27934. }
  27935. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  27936. fields = append(fields, usagedetail.FieldPromptTokens)
  27937. }
  27938. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  27939. fields = append(fields, usagedetail.FieldCompletionTokens)
  27940. }
  27941. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  27942. fields = append(fields, usagedetail.FieldOrganizationID)
  27943. }
  27944. return fields
  27945. }
  27946. // FieldCleared returns a boolean indicating if a field with the given name was
  27947. // cleared in this mutation.
  27948. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  27949. _, ok := m.clearedFields[name]
  27950. return ok
  27951. }
  27952. // ClearField clears the value of the field with the given name. It returns an
  27953. // error if the field is not defined in the schema.
  27954. func (m *UsageDetailMutation) ClearField(name string) error {
  27955. switch name {
  27956. case usagedetail.FieldStatus:
  27957. m.ClearStatus()
  27958. return nil
  27959. case usagedetail.FieldType:
  27960. m.ClearType()
  27961. return nil
  27962. case usagedetail.FieldApp:
  27963. m.ClearApp()
  27964. return nil
  27965. case usagedetail.FieldSessionID:
  27966. m.ClearSessionID()
  27967. return nil
  27968. case usagedetail.FieldTotalTokens:
  27969. m.ClearTotalTokens()
  27970. return nil
  27971. case usagedetail.FieldPromptTokens:
  27972. m.ClearPromptTokens()
  27973. return nil
  27974. case usagedetail.FieldCompletionTokens:
  27975. m.ClearCompletionTokens()
  27976. return nil
  27977. case usagedetail.FieldOrganizationID:
  27978. m.ClearOrganizationID()
  27979. return nil
  27980. }
  27981. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  27982. }
  27983. // ResetField resets all changes in the mutation for the field with the given name.
  27984. // It returns an error if the field is not defined in the schema.
  27985. func (m *UsageDetailMutation) ResetField(name string) error {
  27986. switch name {
  27987. case usagedetail.FieldCreatedAt:
  27988. m.ResetCreatedAt()
  27989. return nil
  27990. case usagedetail.FieldUpdatedAt:
  27991. m.ResetUpdatedAt()
  27992. return nil
  27993. case usagedetail.FieldStatus:
  27994. m.ResetStatus()
  27995. return nil
  27996. case usagedetail.FieldType:
  27997. m.ResetType()
  27998. return nil
  27999. case usagedetail.FieldBotID:
  28000. m.ResetBotID()
  28001. return nil
  28002. case usagedetail.FieldReceiverID:
  28003. m.ResetReceiverID()
  28004. return nil
  28005. case usagedetail.FieldApp:
  28006. m.ResetApp()
  28007. return nil
  28008. case usagedetail.FieldSessionID:
  28009. m.ResetSessionID()
  28010. return nil
  28011. case usagedetail.FieldRequest:
  28012. m.ResetRequest()
  28013. return nil
  28014. case usagedetail.FieldResponse:
  28015. m.ResetResponse()
  28016. return nil
  28017. case usagedetail.FieldOriginalData:
  28018. m.ResetOriginalData()
  28019. return nil
  28020. case usagedetail.FieldTotalTokens:
  28021. m.ResetTotalTokens()
  28022. return nil
  28023. case usagedetail.FieldPromptTokens:
  28024. m.ResetPromptTokens()
  28025. return nil
  28026. case usagedetail.FieldCompletionTokens:
  28027. m.ResetCompletionTokens()
  28028. return nil
  28029. case usagedetail.FieldOrganizationID:
  28030. m.ResetOrganizationID()
  28031. return nil
  28032. }
  28033. return fmt.Errorf("unknown UsageDetail field %s", name)
  28034. }
  28035. // AddedEdges returns all edge names that were set/added in this mutation.
  28036. func (m *UsageDetailMutation) AddedEdges() []string {
  28037. edges := make([]string, 0, 0)
  28038. return edges
  28039. }
  28040. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28041. // name in this mutation.
  28042. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  28043. return nil
  28044. }
  28045. // RemovedEdges returns all edge names that were removed in this mutation.
  28046. func (m *UsageDetailMutation) RemovedEdges() []string {
  28047. edges := make([]string, 0, 0)
  28048. return edges
  28049. }
  28050. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28051. // the given name in this mutation.
  28052. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  28053. return nil
  28054. }
  28055. // ClearedEdges returns all edge names that were cleared in this mutation.
  28056. func (m *UsageDetailMutation) ClearedEdges() []string {
  28057. edges := make([]string, 0, 0)
  28058. return edges
  28059. }
  28060. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28061. // was cleared in this mutation.
  28062. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  28063. return false
  28064. }
  28065. // ClearEdge clears the value of the edge with the given name. It returns an error
  28066. // if that edge is not defined in the schema.
  28067. func (m *UsageDetailMutation) ClearEdge(name string) error {
  28068. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  28069. }
  28070. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28071. // It returns an error if the edge is not defined in the schema.
  28072. func (m *UsageDetailMutation) ResetEdge(name string) error {
  28073. return fmt.Errorf("unknown UsageDetail edge %s", name)
  28074. }
  28075. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  28076. type UsageStatisticDayMutation struct {
  28077. config
  28078. op Op
  28079. typ string
  28080. id *uint64
  28081. created_at *time.Time
  28082. updated_at *time.Time
  28083. status *uint8
  28084. addstatus *int8
  28085. deleted_at *time.Time
  28086. addtime *uint64
  28087. addaddtime *int64
  28088. _type *int
  28089. add_type *int
  28090. bot_id *string
  28091. organization_id *uint64
  28092. addorganization_id *int64
  28093. ai_response *uint64
  28094. addai_response *int64
  28095. sop_run *uint64
  28096. addsop_run *int64
  28097. total_friend *uint64
  28098. addtotal_friend *int64
  28099. total_group *uint64
  28100. addtotal_group *int64
  28101. account_balance *uint64
  28102. addaccount_balance *int64
  28103. consume_token *uint64
  28104. addconsume_token *int64
  28105. active_user *uint64
  28106. addactive_user *int64
  28107. new_user *int64
  28108. addnew_user *int64
  28109. label_dist *[]custom_types.LabelDist
  28110. appendlabel_dist []custom_types.LabelDist
  28111. clearedFields map[string]struct{}
  28112. done bool
  28113. oldValue func(context.Context) (*UsageStatisticDay, error)
  28114. predicates []predicate.UsageStatisticDay
  28115. }
  28116. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  28117. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  28118. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  28119. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  28120. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  28121. m := &UsageStatisticDayMutation{
  28122. config: c,
  28123. op: op,
  28124. typ: TypeUsageStatisticDay,
  28125. clearedFields: make(map[string]struct{}),
  28126. }
  28127. for _, opt := range opts {
  28128. opt(m)
  28129. }
  28130. return m
  28131. }
  28132. // withUsageStatisticDayID sets the ID field of the mutation.
  28133. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  28134. return func(m *UsageStatisticDayMutation) {
  28135. var (
  28136. err error
  28137. once sync.Once
  28138. value *UsageStatisticDay
  28139. )
  28140. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  28141. once.Do(func() {
  28142. if m.done {
  28143. err = errors.New("querying old values post mutation is not allowed")
  28144. } else {
  28145. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  28146. }
  28147. })
  28148. return value, err
  28149. }
  28150. m.id = &id
  28151. }
  28152. }
  28153. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  28154. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  28155. return func(m *UsageStatisticDayMutation) {
  28156. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  28157. return node, nil
  28158. }
  28159. m.id = &node.ID
  28160. }
  28161. }
  28162. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28163. // executed in a transaction (ent.Tx), a transactional client is returned.
  28164. func (m UsageStatisticDayMutation) Client() *Client {
  28165. client := &Client{config: m.config}
  28166. client.init()
  28167. return client
  28168. }
  28169. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28170. // it returns an error otherwise.
  28171. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  28172. if _, ok := m.driver.(*txDriver); !ok {
  28173. return nil, errors.New("ent: mutation is not running in a transaction")
  28174. }
  28175. tx := &Tx{config: m.config}
  28176. tx.init()
  28177. return tx, nil
  28178. }
  28179. // SetID sets the value of the id field. Note that this
  28180. // operation is only accepted on creation of UsageStatisticDay entities.
  28181. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  28182. m.id = &id
  28183. }
  28184. // ID returns the ID value in the mutation. Note that the ID is only available
  28185. // if it was provided to the builder or after it was returned from the database.
  28186. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  28187. if m.id == nil {
  28188. return
  28189. }
  28190. return *m.id, true
  28191. }
  28192. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28193. // That means, if the mutation is applied within a transaction with an isolation level such
  28194. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28195. // or updated by the mutation.
  28196. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  28197. switch {
  28198. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28199. id, exists := m.ID()
  28200. if exists {
  28201. return []uint64{id}, nil
  28202. }
  28203. fallthrough
  28204. case m.op.Is(OpUpdate | OpDelete):
  28205. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  28206. default:
  28207. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28208. }
  28209. }
  28210. // SetCreatedAt sets the "created_at" field.
  28211. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  28212. m.created_at = &t
  28213. }
  28214. // CreatedAt returns the value of the "created_at" field in the mutation.
  28215. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  28216. v := m.created_at
  28217. if v == nil {
  28218. return
  28219. }
  28220. return *v, true
  28221. }
  28222. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  28223. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28225. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28226. if !m.op.Is(OpUpdateOne) {
  28227. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28228. }
  28229. if m.id == nil || m.oldValue == nil {
  28230. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28231. }
  28232. oldValue, err := m.oldValue(ctx)
  28233. if err != nil {
  28234. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28235. }
  28236. return oldValue.CreatedAt, nil
  28237. }
  28238. // ResetCreatedAt resets all changes to the "created_at" field.
  28239. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  28240. m.created_at = nil
  28241. }
  28242. // SetUpdatedAt sets the "updated_at" field.
  28243. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  28244. m.updated_at = &t
  28245. }
  28246. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28247. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  28248. v := m.updated_at
  28249. if v == nil {
  28250. return
  28251. }
  28252. return *v, true
  28253. }
  28254. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  28255. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28257. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28258. if !m.op.Is(OpUpdateOne) {
  28259. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28260. }
  28261. if m.id == nil || m.oldValue == nil {
  28262. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28263. }
  28264. oldValue, err := m.oldValue(ctx)
  28265. if err != nil {
  28266. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28267. }
  28268. return oldValue.UpdatedAt, nil
  28269. }
  28270. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28271. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  28272. m.updated_at = nil
  28273. }
  28274. // SetStatus sets the "status" field.
  28275. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  28276. m.status = &u
  28277. m.addstatus = nil
  28278. }
  28279. // Status returns the value of the "status" field in the mutation.
  28280. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  28281. v := m.status
  28282. if v == nil {
  28283. return
  28284. }
  28285. return *v, true
  28286. }
  28287. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  28288. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28290. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28291. if !m.op.Is(OpUpdateOne) {
  28292. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28293. }
  28294. if m.id == nil || m.oldValue == nil {
  28295. return v, errors.New("OldStatus requires an ID field in the mutation")
  28296. }
  28297. oldValue, err := m.oldValue(ctx)
  28298. if err != nil {
  28299. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28300. }
  28301. return oldValue.Status, nil
  28302. }
  28303. // AddStatus adds u to the "status" field.
  28304. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  28305. if m.addstatus != nil {
  28306. *m.addstatus += u
  28307. } else {
  28308. m.addstatus = &u
  28309. }
  28310. }
  28311. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28312. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  28313. v := m.addstatus
  28314. if v == nil {
  28315. return
  28316. }
  28317. return *v, true
  28318. }
  28319. // ClearStatus clears the value of the "status" field.
  28320. func (m *UsageStatisticDayMutation) ClearStatus() {
  28321. m.status = nil
  28322. m.addstatus = nil
  28323. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  28324. }
  28325. // StatusCleared returns if the "status" field was cleared in this mutation.
  28326. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  28327. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  28328. return ok
  28329. }
  28330. // ResetStatus resets all changes to the "status" field.
  28331. func (m *UsageStatisticDayMutation) ResetStatus() {
  28332. m.status = nil
  28333. m.addstatus = nil
  28334. delete(m.clearedFields, usagestatisticday.FieldStatus)
  28335. }
  28336. // SetDeletedAt sets the "deleted_at" field.
  28337. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  28338. m.deleted_at = &t
  28339. }
  28340. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28341. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  28342. v := m.deleted_at
  28343. if v == nil {
  28344. return
  28345. }
  28346. return *v, true
  28347. }
  28348. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  28349. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28351. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28352. if !m.op.Is(OpUpdateOne) {
  28353. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28354. }
  28355. if m.id == nil || m.oldValue == nil {
  28356. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28357. }
  28358. oldValue, err := m.oldValue(ctx)
  28359. if err != nil {
  28360. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28361. }
  28362. return oldValue.DeletedAt, nil
  28363. }
  28364. // ClearDeletedAt clears the value of the "deleted_at" field.
  28365. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  28366. m.deleted_at = nil
  28367. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  28368. }
  28369. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28370. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  28371. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  28372. return ok
  28373. }
  28374. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28375. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  28376. m.deleted_at = nil
  28377. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  28378. }
  28379. // SetAddtime sets the "addtime" field.
  28380. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  28381. m.addtime = &u
  28382. m.addaddtime = nil
  28383. }
  28384. // Addtime returns the value of the "addtime" field in the mutation.
  28385. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  28386. v := m.addtime
  28387. if v == nil {
  28388. return
  28389. }
  28390. return *v, true
  28391. }
  28392. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  28393. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28395. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  28396. if !m.op.Is(OpUpdateOne) {
  28397. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  28398. }
  28399. if m.id == nil || m.oldValue == nil {
  28400. return v, errors.New("OldAddtime requires an ID field in the mutation")
  28401. }
  28402. oldValue, err := m.oldValue(ctx)
  28403. if err != nil {
  28404. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  28405. }
  28406. return oldValue.Addtime, nil
  28407. }
  28408. // AddAddtime adds u to the "addtime" field.
  28409. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  28410. if m.addaddtime != nil {
  28411. *m.addaddtime += u
  28412. } else {
  28413. m.addaddtime = &u
  28414. }
  28415. }
  28416. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  28417. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  28418. v := m.addaddtime
  28419. if v == nil {
  28420. return
  28421. }
  28422. return *v, true
  28423. }
  28424. // ResetAddtime resets all changes to the "addtime" field.
  28425. func (m *UsageStatisticDayMutation) ResetAddtime() {
  28426. m.addtime = nil
  28427. m.addaddtime = nil
  28428. }
  28429. // SetType sets the "type" field.
  28430. func (m *UsageStatisticDayMutation) SetType(i int) {
  28431. m._type = &i
  28432. m.add_type = nil
  28433. }
  28434. // GetType returns the value of the "type" field in the mutation.
  28435. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  28436. v := m._type
  28437. if v == nil {
  28438. return
  28439. }
  28440. return *v, true
  28441. }
  28442. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  28443. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28445. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  28446. if !m.op.Is(OpUpdateOne) {
  28447. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28448. }
  28449. if m.id == nil || m.oldValue == nil {
  28450. return v, errors.New("OldType requires an ID field in the mutation")
  28451. }
  28452. oldValue, err := m.oldValue(ctx)
  28453. if err != nil {
  28454. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28455. }
  28456. return oldValue.Type, nil
  28457. }
  28458. // AddType adds i to the "type" field.
  28459. func (m *UsageStatisticDayMutation) AddType(i int) {
  28460. if m.add_type != nil {
  28461. *m.add_type += i
  28462. } else {
  28463. m.add_type = &i
  28464. }
  28465. }
  28466. // AddedType returns the value that was added to the "type" field in this mutation.
  28467. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  28468. v := m.add_type
  28469. if v == nil {
  28470. return
  28471. }
  28472. return *v, true
  28473. }
  28474. // ResetType resets all changes to the "type" field.
  28475. func (m *UsageStatisticDayMutation) ResetType() {
  28476. m._type = nil
  28477. m.add_type = nil
  28478. }
  28479. // SetBotID sets the "bot_id" field.
  28480. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  28481. m.bot_id = &s
  28482. }
  28483. // BotID returns the value of the "bot_id" field in the mutation.
  28484. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  28485. v := m.bot_id
  28486. if v == nil {
  28487. return
  28488. }
  28489. return *v, true
  28490. }
  28491. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  28492. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28494. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  28495. if !m.op.Is(OpUpdateOne) {
  28496. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28497. }
  28498. if m.id == nil || m.oldValue == nil {
  28499. return v, errors.New("OldBotID requires an ID field in the mutation")
  28500. }
  28501. oldValue, err := m.oldValue(ctx)
  28502. if err != nil {
  28503. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28504. }
  28505. return oldValue.BotID, nil
  28506. }
  28507. // ClearBotID clears the value of the "bot_id" field.
  28508. func (m *UsageStatisticDayMutation) ClearBotID() {
  28509. m.bot_id = nil
  28510. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  28511. }
  28512. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28513. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  28514. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  28515. return ok
  28516. }
  28517. // ResetBotID resets all changes to the "bot_id" field.
  28518. func (m *UsageStatisticDayMutation) ResetBotID() {
  28519. m.bot_id = nil
  28520. delete(m.clearedFields, usagestatisticday.FieldBotID)
  28521. }
  28522. // SetOrganizationID sets the "organization_id" field.
  28523. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  28524. m.organization_id = &u
  28525. m.addorganization_id = nil
  28526. }
  28527. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28528. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  28529. v := m.organization_id
  28530. if v == nil {
  28531. return
  28532. }
  28533. return *v, true
  28534. }
  28535. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  28536. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28538. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28539. if !m.op.Is(OpUpdateOne) {
  28540. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28541. }
  28542. if m.id == nil || m.oldValue == nil {
  28543. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28544. }
  28545. oldValue, err := m.oldValue(ctx)
  28546. if err != nil {
  28547. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28548. }
  28549. return oldValue.OrganizationID, nil
  28550. }
  28551. // AddOrganizationID adds u to the "organization_id" field.
  28552. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  28553. if m.addorganization_id != nil {
  28554. *m.addorganization_id += u
  28555. } else {
  28556. m.addorganization_id = &u
  28557. }
  28558. }
  28559. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28560. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  28561. v := m.addorganization_id
  28562. if v == nil {
  28563. return
  28564. }
  28565. return *v, true
  28566. }
  28567. // ClearOrganizationID clears the value of the "organization_id" field.
  28568. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  28569. m.organization_id = nil
  28570. m.addorganization_id = nil
  28571. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  28572. }
  28573. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28574. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  28575. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  28576. return ok
  28577. }
  28578. // ResetOrganizationID resets all changes to the "organization_id" field.
  28579. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  28580. m.organization_id = nil
  28581. m.addorganization_id = nil
  28582. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  28583. }
  28584. // SetAiResponse sets the "ai_response" field.
  28585. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  28586. m.ai_response = &u
  28587. m.addai_response = nil
  28588. }
  28589. // AiResponse returns the value of the "ai_response" field in the mutation.
  28590. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  28591. v := m.ai_response
  28592. if v == nil {
  28593. return
  28594. }
  28595. return *v, true
  28596. }
  28597. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  28598. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28600. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28601. if !m.op.Is(OpUpdateOne) {
  28602. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28603. }
  28604. if m.id == nil || m.oldValue == nil {
  28605. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28606. }
  28607. oldValue, err := m.oldValue(ctx)
  28608. if err != nil {
  28609. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28610. }
  28611. return oldValue.AiResponse, nil
  28612. }
  28613. // AddAiResponse adds u to the "ai_response" field.
  28614. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  28615. if m.addai_response != nil {
  28616. *m.addai_response += u
  28617. } else {
  28618. m.addai_response = &u
  28619. }
  28620. }
  28621. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28622. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  28623. v := m.addai_response
  28624. if v == nil {
  28625. return
  28626. }
  28627. return *v, true
  28628. }
  28629. // ResetAiResponse resets all changes to the "ai_response" field.
  28630. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  28631. m.ai_response = nil
  28632. m.addai_response = nil
  28633. }
  28634. // SetSopRun sets the "sop_run" field.
  28635. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  28636. m.sop_run = &u
  28637. m.addsop_run = nil
  28638. }
  28639. // SopRun returns the value of the "sop_run" field in the mutation.
  28640. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  28641. v := m.sop_run
  28642. if v == nil {
  28643. return
  28644. }
  28645. return *v, true
  28646. }
  28647. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  28648. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28650. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  28651. if !m.op.Is(OpUpdateOne) {
  28652. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28653. }
  28654. if m.id == nil || m.oldValue == nil {
  28655. return v, errors.New("OldSopRun requires an ID field in the mutation")
  28656. }
  28657. oldValue, err := m.oldValue(ctx)
  28658. if err != nil {
  28659. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  28660. }
  28661. return oldValue.SopRun, nil
  28662. }
  28663. // AddSopRun adds u to the "sop_run" field.
  28664. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  28665. if m.addsop_run != nil {
  28666. *m.addsop_run += u
  28667. } else {
  28668. m.addsop_run = &u
  28669. }
  28670. }
  28671. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  28672. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  28673. v := m.addsop_run
  28674. if v == nil {
  28675. return
  28676. }
  28677. return *v, true
  28678. }
  28679. // ResetSopRun resets all changes to the "sop_run" field.
  28680. func (m *UsageStatisticDayMutation) ResetSopRun() {
  28681. m.sop_run = nil
  28682. m.addsop_run = nil
  28683. }
  28684. // SetTotalFriend sets the "total_friend" field.
  28685. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  28686. m.total_friend = &u
  28687. m.addtotal_friend = nil
  28688. }
  28689. // TotalFriend returns the value of the "total_friend" field in the mutation.
  28690. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  28691. v := m.total_friend
  28692. if v == nil {
  28693. return
  28694. }
  28695. return *v, true
  28696. }
  28697. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  28698. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28700. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  28701. if !m.op.Is(OpUpdateOne) {
  28702. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  28703. }
  28704. if m.id == nil || m.oldValue == nil {
  28705. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  28706. }
  28707. oldValue, err := m.oldValue(ctx)
  28708. if err != nil {
  28709. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  28710. }
  28711. return oldValue.TotalFriend, nil
  28712. }
  28713. // AddTotalFriend adds u to the "total_friend" field.
  28714. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  28715. if m.addtotal_friend != nil {
  28716. *m.addtotal_friend += u
  28717. } else {
  28718. m.addtotal_friend = &u
  28719. }
  28720. }
  28721. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  28722. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  28723. v := m.addtotal_friend
  28724. if v == nil {
  28725. return
  28726. }
  28727. return *v, true
  28728. }
  28729. // ResetTotalFriend resets all changes to the "total_friend" field.
  28730. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  28731. m.total_friend = nil
  28732. m.addtotal_friend = nil
  28733. }
  28734. // SetTotalGroup sets the "total_group" field.
  28735. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  28736. m.total_group = &u
  28737. m.addtotal_group = nil
  28738. }
  28739. // TotalGroup returns the value of the "total_group" field in the mutation.
  28740. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  28741. v := m.total_group
  28742. if v == nil {
  28743. return
  28744. }
  28745. return *v, true
  28746. }
  28747. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  28748. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28750. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  28751. if !m.op.Is(OpUpdateOne) {
  28752. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  28753. }
  28754. if m.id == nil || m.oldValue == nil {
  28755. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  28756. }
  28757. oldValue, err := m.oldValue(ctx)
  28758. if err != nil {
  28759. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  28760. }
  28761. return oldValue.TotalGroup, nil
  28762. }
  28763. // AddTotalGroup adds u to the "total_group" field.
  28764. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  28765. if m.addtotal_group != nil {
  28766. *m.addtotal_group += u
  28767. } else {
  28768. m.addtotal_group = &u
  28769. }
  28770. }
  28771. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  28772. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  28773. v := m.addtotal_group
  28774. if v == nil {
  28775. return
  28776. }
  28777. return *v, true
  28778. }
  28779. // ResetTotalGroup resets all changes to the "total_group" field.
  28780. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  28781. m.total_group = nil
  28782. m.addtotal_group = nil
  28783. }
  28784. // SetAccountBalance sets the "account_balance" field.
  28785. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  28786. m.account_balance = &u
  28787. m.addaccount_balance = nil
  28788. }
  28789. // AccountBalance returns the value of the "account_balance" field in the mutation.
  28790. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  28791. v := m.account_balance
  28792. if v == nil {
  28793. return
  28794. }
  28795. return *v, true
  28796. }
  28797. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  28798. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28800. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  28801. if !m.op.Is(OpUpdateOne) {
  28802. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  28803. }
  28804. if m.id == nil || m.oldValue == nil {
  28805. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  28806. }
  28807. oldValue, err := m.oldValue(ctx)
  28808. if err != nil {
  28809. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  28810. }
  28811. return oldValue.AccountBalance, nil
  28812. }
  28813. // AddAccountBalance adds u to the "account_balance" field.
  28814. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  28815. if m.addaccount_balance != nil {
  28816. *m.addaccount_balance += u
  28817. } else {
  28818. m.addaccount_balance = &u
  28819. }
  28820. }
  28821. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  28822. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  28823. v := m.addaccount_balance
  28824. if v == nil {
  28825. return
  28826. }
  28827. return *v, true
  28828. }
  28829. // ResetAccountBalance resets all changes to the "account_balance" field.
  28830. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  28831. m.account_balance = nil
  28832. m.addaccount_balance = nil
  28833. }
  28834. // SetConsumeToken sets the "consume_token" field.
  28835. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  28836. m.consume_token = &u
  28837. m.addconsume_token = nil
  28838. }
  28839. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  28840. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  28841. v := m.consume_token
  28842. if v == nil {
  28843. return
  28844. }
  28845. return *v, true
  28846. }
  28847. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  28848. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28850. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  28851. if !m.op.Is(OpUpdateOne) {
  28852. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  28853. }
  28854. if m.id == nil || m.oldValue == nil {
  28855. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  28856. }
  28857. oldValue, err := m.oldValue(ctx)
  28858. if err != nil {
  28859. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  28860. }
  28861. return oldValue.ConsumeToken, nil
  28862. }
  28863. // AddConsumeToken adds u to the "consume_token" field.
  28864. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  28865. if m.addconsume_token != nil {
  28866. *m.addconsume_token += u
  28867. } else {
  28868. m.addconsume_token = &u
  28869. }
  28870. }
  28871. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  28872. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  28873. v := m.addconsume_token
  28874. if v == nil {
  28875. return
  28876. }
  28877. return *v, true
  28878. }
  28879. // ResetConsumeToken resets all changes to the "consume_token" field.
  28880. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  28881. m.consume_token = nil
  28882. m.addconsume_token = nil
  28883. }
  28884. // SetActiveUser sets the "active_user" field.
  28885. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  28886. m.active_user = &u
  28887. m.addactive_user = nil
  28888. }
  28889. // ActiveUser returns the value of the "active_user" field in the mutation.
  28890. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  28891. v := m.active_user
  28892. if v == nil {
  28893. return
  28894. }
  28895. return *v, true
  28896. }
  28897. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  28898. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28900. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  28901. if !m.op.Is(OpUpdateOne) {
  28902. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  28903. }
  28904. if m.id == nil || m.oldValue == nil {
  28905. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  28906. }
  28907. oldValue, err := m.oldValue(ctx)
  28908. if err != nil {
  28909. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  28910. }
  28911. return oldValue.ActiveUser, nil
  28912. }
  28913. // AddActiveUser adds u to the "active_user" field.
  28914. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  28915. if m.addactive_user != nil {
  28916. *m.addactive_user += u
  28917. } else {
  28918. m.addactive_user = &u
  28919. }
  28920. }
  28921. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  28922. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  28923. v := m.addactive_user
  28924. if v == nil {
  28925. return
  28926. }
  28927. return *v, true
  28928. }
  28929. // ResetActiveUser resets all changes to the "active_user" field.
  28930. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  28931. m.active_user = nil
  28932. m.addactive_user = nil
  28933. }
  28934. // SetNewUser sets the "new_user" field.
  28935. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  28936. m.new_user = &i
  28937. m.addnew_user = nil
  28938. }
  28939. // NewUser returns the value of the "new_user" field in the mutation.
  28940. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  28941. v := m.new_user
  28942. if v == nil {
  28943. return
  28944. }
  28945. return *v, true
  28946. }
  28947. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  28948. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28950. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  28951. if !m.op.Is(OpUpdateOne) {
  28952. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  28953. }
  28954. if m.id == nil || m.oldValue == nil {
  28955. return v, errors.New("OldNewUser requires an ID field in the mutation")
  28956. }
  28957. oldValue, err := m.oldValue(ctx)
  28958. if err != nil {
  28959. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28960. }
  28961. return oldValue.NewUser, nil
  28962. }
  28963. // AddNewUser adds i to the "new_user" field.
  28964. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  28965. if m.addnew_user != nil {
  28966. *m.addnew_user += i
  28967. } else {
  28968. m.addnew_user = &i
  28969. }
  28970. }
  28971. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28972. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  28973. v := m.addnew_user
  28974. if v == nil {
  28975. return
  28976. }
  28977. return *v, true
  28978. }
  28979. // ResetNewUser resets all changes to the "new_user" field.
  28980. func (m *UsageStatisticDayMutation) ResetNewUser() {
  28981. m.new_user = nil
  28982. m.addnew_user = nil
  28983. }
  28984. // SetLabelDist sets the "label_dist" field.
  28985. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  28986. m.label_dist = &ctd
  28987. m.appendlabel_dist = nil
  28988. }
  28989. // LabelDist returns the value of the "label_dist" field in the mutation.
  28990. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  28991. v := m.label_dist
  28992. if v == nil {
  28993. return
  28994. }
  28995. return *v, true
  28996. }
  28997. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  28998. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29000. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  29001. if !m.op.Is(OpUpdateOne) {
  29002. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  29003. }
  29004. if m.id == nil || m.oldValue == nil {
  29005. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  29006. }
  29007. oldValue, err := m.oldValue(ctx)
  29008. if err != nil {
  29009. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  29010. }
  29011. return oldValue.LabelDist, nil
  29012. }
  29013. // AppendLabelDist adds ctd to the "label_dist" field.
  29014. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  29015. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  29016. }
  29017. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  29018. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  29019. if len(m.appendlabel_dist) == 0 {
  29020. return nil, false
  29021. }
  29022. return m.appendlabel_dist, true
  29023. }
  29024. // ResetLabelDist resets all changes to the "label_dist" field.
  29025. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  29026. m.label_dist = nil
  29027. m.appendlabel_dist = nil
  29028. }
  29029. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  29030. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  29031. m.predicates = append(m.predicates, ps...)
  29032. }
  29033. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  29034. // users can use type-assertion to append predicates that do not depend on any generated package.
  29035. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  29036. p := make([]predicate.UsageStatisticDay, len(ps))
  29037. for i := range ps {
  29038. p[i] = ps[i]
  29039. }
  29040. m.Where(p...)
  29041. }
  29042. // Op returns the operation name.
  29043. func (m *UsageStatisticDayMutation) Op() Op {
  29044. return m.op
  29045. }
  29046. // SetOp allows setting the mutation operation.
  29047. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  29048. m.op = op
  29049. }
  29050. // Type returns the node type of this mutation (UsageStatisticDay).
  29051. func (m *UsageStatisticDayMutation) Type() string {
  29052. return m.typ
  29053. }
  29054. // Fields returns all fields that were changed during this mutation. Note that in
  29055. // order to get all numeric fields that were incremented/decremented, call
  29056. // AddedFields().
  29057. func (m *UsageStatisticDayMutation) Fields() []string {
  29058. fields := make([]string, 0, 17)
  29059. if m.created_at != nil {
  29060. fields = append(fields, usagestatisticday.FieldCreatedAt)
  29061. }
  29062. if m.updated_at != nil {
  29063. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  29064. }
  29065. if m.status != nil {
  29066. fields = append(fields, usagestatisticday.FieldStatus)
  29067. }
  29068. if m.deleted_at != nil {
  29069. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29070. }
  29071. if m.addtime != nil {
  29072. fields = append(fields, usagestatisticday.FieldAddtime)
  29073. }
  29074. if m._type != nil {
  29075. fields = append(fields, usagestatisticday.FieldType)
  29076. }
  29077. if m.bot_id != nil {
  29078. fields = append(fields, usagestatisticday.FieldBotID)
  29079. }
  29080. if m.organization_id != nil {
  29081. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29082. }
  29083. if m.ai_response != nil {
  29084. fields = append(fields, usagestatisticday.FieldAiResponse)
  29085. }
  29086. if m.sop_run != nil {
  29087. fields = append(fields, usagestatisticday.FieldSopRun)
  29088. }
  29089. if m.total_friend != nil {
  29090. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29091. }
  29092. if m.total_group != nil {
  29093. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29094. }
  29095. if m.account_balance != nil {
  29096. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29097. }
  29098. if m.consume_token != nil {
  29099. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29100. }
  29101. if m.active_user != nil {
  29102. fields = append(fields, usagestatisticday.FieldActiveUser)
  29103. }
  29104. if m.new_user != nil {
  29105. fields = append(fields, usagestatisticday.FieldNewUser)
  29106. }
  29107. if m.label_dist != nil {
  29108. fields = append(fields, usagestatisticday.FieldLabelDist)
  29109. }
  29110. return fields
  29111. }
  29112. // Field returns the value of a field with the given name. The second boolean
  29113. // return value indicates that this field was not set, or was not defined in the
  29114. // schema.
  29115. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  29116. switch name {
  29117. case usagestatisticday.FieldCreatedAt:
  29118. return m.CreatedAt()
  29119. case usagestatisticday.FieldUpdatedAt:
  29120. return m.UpdatedAt()
  29121. case usagestatisticday.FieldStatus:
  29122. return m.Status()
  29123. case usagestatisticday.FieldDeletedAt:
  29124. return m.DeletedAt()
  29125. case usagestatisticday.FieldAddtime:
  29126. return m.Addtime()
  29127. case usagestatisticday.FieldType:
  29128. return m.GetType()
  29129. case usagestatisticday.FieldBotID:
  29130. return m.BotID()
  29131. case usagestatisticday.FieldOrganizationID:
  29132. return m.OrganizationID()
  29133. case usagestatisticday.FieldAiResponse:
  29134. return m.AiResponse()
  29135. case usagestatisticday.FieldSopRun:
  29136. return m.SopRun()
  29137. case usagestatisticday.FieldTotalFriend:
  29138. return m.TotalFriend()
  29139. case usagestatisticday.FieldTotalGroup:
  29140. return m.TotalGroup()
  29141. case usagestatisticday.FieldAccountBalance:
  29142. return m.AccountBalance()
  29143. case usagestatisticday.FieldConsumeToken:
  29144. return m.ConsumeToken()
  29145. case usagestatisticday.FieldActiveUser:
  29146. return m.ActiveUser()
  29147. case usagestatisticday.FieldNewUser:
  29148. return m.NewUser()
  29149. case usagestatisticday.FieldLabelDist:
  29150. return m.LabelDist()
  29151. }
  29152. return nil, false
  29153. }
  29154. // OldField returns the old value of the field from the database. An error is
  29155. // returned if the mutation operation is not UpdateOne, or the query to the
  29156. // database failed.
  29157. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29158. switch name {
  29159. case usagestatisticday.FieldCreatedAt:
  29160. return m.OldCreatedAt(ctx)
  29161. case usagestatisticday.FieldUpdatedAt:
  29162. return m.OldUpdatedAt(ctx)
  29163. case usagestatisticday.FieldStatus:
  29164. return m.OldStatus(ctx)
  29165. case usagestatisticday.FieldDeletedAt:
  29166. return m.OldDeletedAt(ctx)
  29167. case usagestatisticday.FieldAddtime:
  29168. return m.OldAddtime(ctx)
  29169. case usagestatisticday.FieldType:
  29170. return m.OldType(ctx)
  29171. case usagestatisticday.FieldBotID:
  29172. return m.OldBotID(ctx)
  29173. case usagestatisticday.FieldOrganizationID:
  29174. return m.OldOrganizationID(ctx)
  29175. case usagestatisticday.FieldAiResponse:
  29176. return m.OldAiResponse(ctx)
  29177. case usagestatisticday.FieldSopRun:
  29178. return m.OldSopRun(ctx)
  29179. case usagestatisticday.FieldTotalFriend:
  29180. return m.OldTotalFriend(ctx)
  29181. case usagestatisticday.FieldTotalGroup:
  29182. return m.OldTotalGroup(ctx)
  29183. case usagestatisticday.FieldAccountBalance:
  29184. return m.OldAccountBalance(ctx)
  29185. case usagestatisticday.FieldConsumeToken:
  29186. return m.OldConsumeToken(ctx)
  29187. case usagestatisticday.FieldActiveUser:
  29188. return m.OldActiveUser(ctx)
  29189. case usagestatisticday.FieldNewUser:
  29190. return m.OldNewUser(ctx)
  29191. case usagestatisticday.FieldLabelDist:
  29192. return m.OldLabelDist(ctx)
  29193. }
  29194. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29195. }
  29196. // SetField sets the value of a field with the given name. It returns an error if
  29197. // the field is not defined in the schema, or if the type mismatched the field
  29198. // type.
  29199. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  29200. switch name {
  29201. case usagestatisticday.FieldCreatedAt:
  29202. v, ok := value.(time.Time)
  29203. if !ok {
  29204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29205. }
  29206. m.SetCreatedAt(v)
  29207. return nil
  29208. case usagestatisticday.FieldUpdatedAt:
  29209. v, ok := value.(time.Time)
  29210. if !ok {
  29211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29212. }
  29213. m.SetUpdatedAt(v)
  29214. return nil
  29215. case usagestatisticday.FieldStatus:
  29216. v, ok := value.(uint8)
  29217. if !ok {
  29218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29219. }
  29220. m.SetStatus(v)
  29221. return nil
  29222. case usagestatisticday.FieldDeletedAt:
  29223. v, ok := value.(time.Time)
  29224. if !ok {
  29225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29226. }
  29227. m.SetDeletedAt(v)
  29228. return nil
  29229. case usagestatisticday.FieldAddtime:
  29230. v, ok := value.(uint64)
  29231. if !ok {
  29232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29233. }
  29234. m.SetAddtime(v)
  29235. return nil
  29236. case usagestatisticday.FieldType:
  29237. v, ok := value.(int)
  29238. if !ok {
  29239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29240. }
  29241. m.SetType(v)
  29242. return nil
  29243. case usagestatisticday.FieldBotID:
  29244. v, ok := value.(string)
  29245. if !ok {
  29246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29247. }
  29248. m.SetBotID(v)
  29249. return nil
  29250. case usagestatisticday.FieldOrganizationID:
  29251. v, ok := value.(uint64)
  29252. if !ok {
  29253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29254. }
  29255. m.SetOrganizationID(v)
  29256. return nil
  29257. case usagestatisticday.FieldAiResponse:
  29258. v, ok := value.(uint64)
  29259. if !ok {
  29260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29261. }
  29262. m.SetAiResponse(v)
  29263. return nil
  29264. case usagestatisticday.FieldSopRun:
  29265. v, ok := value.(uint64)
  29266. if !ok {
  29267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29268. }
  29269. m.SetSopRun(v)
  29270. return nil
  29271. case usagestatisticday.FieldTotalFriend:
  29272. v, ok := value.(uint64)
  29273. if !ok {
  29274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29275. }
  29276. m.SetTotalFriend(v)
  29277. return nil
  29278. case usagestatisticday.FieldTotalGroup:
  29279. v, ok := value.(uint64)
  29280. if !ok {
  29281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29282. }
  29283. m.SetTotalGroup(v)
  29284. return nil
  29285. case usagestatisticday.FieldAccountBalance:
  29286. v, ok := value.(uint64)
  29287. if !ok {
  29288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29289. }
  29290. m.SetAccountBalance(v)
  29291. return nil
  29292. case usagestatisticday.FieldConsumeToken:
  29293. v, ok := value.(uint64)
  29294. if !ok {
  29295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29296. }
  29297. m.SetConsumeToken(v)
  29298. return nil
  29299. case usagestatisticday.FieldActiveUser:
  29300. v, ok := value.(uint64)
  29301. if !ok {
  29302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29303. }
  29304. m.SetActiveUser(v)
  29305. return nil
  29306. case usagestatisticday.FieldNewUser:
  29307. v, ok := value.(int64)
  29308. if !ok {
  29309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29310. }
  29311. m.SetNewUser(v)
  29312. return nil
  29313. case usagestatisticday.FieldLabelDist:
  29314. v, ok := value.([]custom_types.LabelDist)
  29315. if !ok {
  29316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29317. }
  29318. m.SetLabelDist(v)
  29319. return nil
  29320. }
  29321. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29322. }
  29323. // AddedFields returns all numeric fields that were incremented/decremented during
  29324. // this mutation.
  29325. func (m *UsageStatisticDayMutation) AddedFields() []string {
  29326. var fields []string
  29327. if m.addstatus != nil {
  29328. fields = append(fields, usagestatisticday.FieldStatus)
  29329. }
  29330. if m.addaddtime != nil {
  29331. fields = append(fields, usagestatisticday.FieldAddtime)
  29332. }
  29333. if m.add_type != nil {
  29334. fields = append(fields, usagestatisticday.FieldType)
  29335. }
  29336. if m.addorganization_id != nil {
  29337. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29338. }
  29339. if m.addai_response != nil {
  29340. fields = append(fields, usagestatisticday.FieldAiResponse)
  29341. }
  29342. if m.addsop_run != nil {
  29343. fields = append(fields, usagestatisticday.FieldSopRun)
  29344. }
  29345. if m.addtotal_friend != nil {
  29346. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29347. }
  29348. if m.addtotal_group != nil {
  29349. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29350. }
  29351. if m.addaccount_balance != nil {
  29352. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29353. }
  29354. if m.addconsume_token != nil {
  29355. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29356. }
  29357. if m.addactive_user != nil {
  29358. fields = append(fields, usagestatisticday.FieldActiveUser)
  29359. }
  29360. if m.addnew_user != nil {
  29361. fields = append(fields, usagestatisticday.FieldNewUser)
  29362. }
  29363. return fields
  29364. }
  29365. // AddedField returns the numeric value that was incremented/decremented on a field
  29366. // with the given name. The second boolean return value indicates that this field
  29367. // was not set, or was not defined in the schema.
  29368. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  29369. switch name {
  29370. case usagestatisticday.FieldStatus:
  29371. return m.AddedStatus()
  29372. case usagestatisticday.FieldAddtime:
  29373. return m.AddedAddtime()
  29374. case usagestatisticday.FieldType:
  29375. return m.AddedType()
  29376. case usagestatisticday.FieldOrganizationID:
  29377. return m.AddedOrganizationID()
  29378. case usagestatisticday.FieldAiResponse:
  29379. return m.AddedAiResponse()
  29380. case usagestatisticday.FieldSopRun:
  29381. return m.AddedSopRun()
  29382. case usagestatisticday.FieldTotalFriend:
  29383. return m.AddedTotalFriend()
  29384. case usagestatisticday.FieldTotalGroup:
  29385. return m.AddedTotalGroup()
  29386. case usagestatisticday.FieldAccountBalance:
  29387. return m.AddedAccountBalance()
  29388. case usagestatisticday.FieldConsumeToken:
  29389. return m.AddedConsumeToken()
  29390. case usagestatisticday.FieldActiveUser:
  29391. return m.AddedActiveUser()
  29392. case usagestatisticday.FieldNewUser:
  29393. return m.AddedNewUser()
  29394. }
  29395. return nil, false
  29396. }
  29397. // AddField adds the value to the field with the given name. It returns an error if
  29398. // the field is not defined in the schema, or if the type mismatched the field
  29399. // type.
  29400. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  29401. switch name {
  29402. case usagestatisticday.FieldStatus:
  29403. v, ok := value.(int8)
  29404. if !ok {
  29405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29406. }
  29407. m.AddStatus(v)
  29408. return nil
  29409. case usagestatisticday.FieldAddtime:
  29410. v, ok := value.(int64)
  29411. if !ok {
  29412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29413. }
  29414. m.AddAddtime(v)
  29415. return nil
  29416. case usagestatisticday.FieldType:
  29417. v, ok := value.(int)
  29418. if !ok {
  29419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29420. }
  29421. m.AddType(v)
  29422. return nil
  29423. case usagestatisticday.FieldOrganizationID:
  29424. v, ok := value.(int64)
  29425. if !ok {
  29426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29427. }
  29428. m.AddOrganizationID(v)
  29429. return nil
  29430. case usagestatisticday.FieldAiResponse:
  29431. v, ok := value.(int64)
  29432. if !ok {
  29433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29434. }
  29435. m.AddAiResponse(v)
  29436. return nil
  29437. case usagestatisticday.FieldSopRun:
  29438. v, ok := value.(int64)
  29439. if !ok {
  29440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29441. }
  29442. m.AddSopRun(v)
  29443. return nil
  29444. case usagestatisticday.FieldTotalFriend:
  29445. v, ok := value.(int64)
  29446. if !ok {
  29447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29448. }
  29449. m.AddTotalFriend(v)
  29450. return nil
  29451. case usagestatisticday.FieldTotalGroup:
  29452. v, ok := value.(int64)
  29453. if !ok {
  29454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29455. }
  29456. m.AddTotalGroup(v)
  29457. return nil
  29458. case usagestatisticday.FieldAccountBalance:
  29459. v, ok := value.(int64)
  29460. if !ok {
  29461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29462. }
  29463. m.AddAccountBalance(v)
  29464. return nil
  29465. case usagestatisticday.FieldConsumeToken:
  29466. v, ok := value.(int64)
  29467. if !ok {
  29468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29469. }
  29470. m.AddConsumeToken(v)
  29471. return nil
  29472. case usagestatisticday.FieldActiveUser:
  29473. v, ok := value.(int64)
  29474. if !ok {
  29475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29476. }
  29477. m.AddActiveUser(v)
  29478. return nil
  29479. case usagestatisticday.FieldNewUser:
  29480. v, ok := value.(int64)
  29481. if !ok {
  29482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29483. }
  29484. m.AddNewUser(v)
  29485. return nil
  29486. }
  29487. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  29488. }
  29489. // ClearedFields returns all nullable fields that were cleared during this
  29490. // mutation.
  29491. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  29492. var fields []string
  29493. if m.FieldCleared(usagestatisticday.FieldStatus) {
  29494. fields = append(fields, usagestatisticday.FieldStatus)
  29495. }
  29496. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  29497. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29498. }
  29499. if m.FieldCleared(usagestatisticday.FieldBotID) {
  29500. fields = append(fields, usagestatisticday.FieldBotID)
  29501. }
  29502. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  29503. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29504. }
  29505. return fields
  29506. }
  29507. // FieldCleared returns a boolean indicating if a field with the given name was
  29508. // cleared in this mutation.
  29509. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  29510. _, ok := m.clearedFields[name]
  29511. return ok
  29512. }
  29513. // ClearField clears the value of the field with the given name. It returns an
  29514. // error if the field is not defined in the schema.
  29515. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  29516. switch name {
  29517. case usagestatisticday.FieldStatus:
  29518. m.ClearStatus()
  29519. return nil
  29520. case usagestatisticday.FieldDeletedAt:
  29521. m.ClearDeletedAt()
  29522. return nil
  29523. case usagestatisticday.FieldBotID:
  29524. m.ClearBotID()
  29525. return nil
  29526. case usagestatisticday.FieldOrganizationID:
  29527. m.ClearOrganizationID()
  29528. return nil
  29529. }
  29530. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  29531. }
  29532. // ResetField resets all changes in the mutation for the field with the given name.
  29533. // It returns an error if the field is not defined in the schema.
  29534. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  29535. switch name {
  29536. case usagestatisticday.FieldCreatedAt:
  29537. m.ResetCreatedAt()
  29538. return nil
  29539. case usagestatisticday.FieldUpdatedAt:
  29540. m.ResetUpdatedAt()
  29541. return nil
  29542. case usagestatisticday.FieldStatus:
  29543. m.ResetStatus()
  29544. return nil
  29545. case usagestatisticday.FieldDeletedAt:
  29546. m.ResetDeletedAt()
  29547. return nil
  29548. case usagestatisticday.FieldAddtime:
  29549. m.ResetAddtime()
  29550. return nil
  29551. case usagestatisticday.FieldType:
  29552. m.ResetType()
  29553. return nil
  29554. case usagestatisticday.FieldBotID:
  29555. m.ResetBotID()
  29556. return nil
  29557. case usagestatisticday.FieldOrganizationID:
  29558. m.ResetOrganizationID()
  29559. return nil
  29560. case usagestatisticday.FieldAiResponse:
  29561. m.ResetAiResponse()
  29562. return nil
  29563. case usagestatisticday.FieldSopRun:
  29564. m.ResetSopRun()
  29565. return nil
  29566. case usagestatisticday.FieldTotalFriend:
  29567. m.ResetTotalFriend()
  29568. return nil
  29569. case usagestatisticday.FieldTotalGroup:
  29570. m.ResetTotalGroup()
  29571. return nil
  29572. case usagestatisticday.FieldAccountBalance:
  29573. m.ResetAccountBalance()
  29574. return nil
  29575. case usagestatisticday.FieldConsumeToken:
  29576. m.ResetConsumeToken()
  29577. return nil
  29578. case usagestatisticday.FieldActiveUser:
  29579. m.ResetActiveUser()
  29580. return nil
  29581. case usagestatisticday.FieldNewUser:
  29582. m.ResetNewUser()
  29583. return nil
  29584. case usagestatisticday.FieldLabelDist:
  29585. m.ResetLabelDist()
  29586. return nil
  29587. }
  29588. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29589. }
  29590. // AddedEdges returns all edge names that were set/added in this mutation.
  29591. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  29592. edges := make([]string, 0, 0)
  29593. return edges
  29594. }
  29595. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29596. // name in this mutation.
  29597. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  29598. return nil
  29599. }
  29600. // RemovedEdges returns all edge names that were removed in this mutation.
  29601. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  29602. edges := make([]string, 0, 0)
  29603. return edges
  29604. }
  29605. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29606. // the given name in this mutation.
  29607. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  29608. return nil
  29609. }
  29610. // ClearedEdges returns all edge names that were cleared in this mutation.
  29611. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  29612. edges := make([]string, 0, 0)
  29613. return edges
  29614. }
  29615. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29616. // was cleared in this mutation.
  29617. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  29618. return false
  29619. }
  29620. // ClearEdge clears the value of the edge with the given name. It returns an error
  29621. // if that edge is not defined in the schema.
  29622. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  29623. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  29624. }
  29625. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29626. // It returns an error if the edge is not defined in the schema.
  29627. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  29628. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  29629. }
  29630. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  29631. type UsageStatisticHourMutation struct {
  29632. config
  29633. op Op
  29634. typ string
  29635. id *uint64
  29636. created_at *time.Time
  29637. updated_at *time.Time
  29638. status *uint8
  29639. addstatus *int8
  29640. deleted_at *time.Time
  29641. addtime *uint64
  29642. addaddtime *int64
  29643. _type *int
  29644. add_type *int
  29645. bot_id *string
  29646. organization_id *uint64
  29647. addorganization_id *int64
  29648. ai_response *uint64
  29649. addai_response *int64
  29650. sop_run *uint64
  29651. addsop_run *int64
  29652. total_friend *uint64
  29653. addtotal_friend *int64
  29654. total_group *uint64
  29655. addtotal_group *int64
  29656. account_balance *uint64
  29657. addaccount_balance *int64
  29658. consume_token *uint64
  29659. addconsume_token *int64
  29660. active_user *uint64
  29661. addactive_user *int64
  29662. new_user *int64
  29663. addnew_user *int64
  29664. label_dist *[]custom_types.LabelDist
  29665. appendlabel_dist []custom_types.LabelDist
  29666. clearedFields map[string]struct{}
  29667. done bool
  29668. oldValue func(context.Context) (*UsageStatisticHour, error)
  29669. predicates []predicate.UsageStatisticHour
  29670. }
  29671. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  29672. // usagestatistichourOption allows management of the mutation configuration using functional options.
  29673. type usagestatistichourOption func(*UsageStatisticHourMutation)
  29674. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  29675. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  29676. m := &UsageStatisticHourMutation{
  29677. config: c,
  29678. op: op,
  29679. typ: TypeUsageStatisticHour,
  29680. clearedFields: make(map[string]struct{}),
  29681. }
  29682. for _, opt := range opts {
  29683. opt(m)
  29684. }
  29685. return m
  29686. }
  29687. // withUsageStatisticHourID sets the ID field of the mutation.
  29688. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  29689. return func(m *UsageStatisticHourMutation) {
  29690. var (
  29691. err error
  29692. once sync.Once
  29693. value *UsageStatisticHour
  29694. )
  29695. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  29696. once.Do(func() {
  29697. if m.done {
  29698. err = errors.New("querying old values post mutation is not allowed")
  29699. } else {
  29700. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  29701. }
  29702. })
  29703. return value, err
  29704. }
  29705. m.id = &id
  29706. }
  29707. }
  29708. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  29709. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  29710. return func(m *UsageStatisticHourMutation) {
  29711. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  29712. return node, nil
  29713. }
  29714. m.id = &node.ID
  29715. }
  29716. }
  29717. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29718. // executed in a transaction (ent.Tx), a transactional client is returned.
  29719. func (m UsageStatisticHourMutation) Client() *Client {
  29720. client := &Client{config: m.config}
  29721. client.init()
  29722. return client
  29723. }
  29724. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29725. // it returns an error otherwise.
  29726. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  29727. if _, ok := m.driver.(*txDriver); !ok {
  29728. return nil, errors.New("ent: mutation is not running in a transaction")
  29729. }
  29730. tx := &Tx{config: m.config}
  29731. tx.init()
  29732. return tx, nil
  29733. }
  29734. // SetID sets the value of the id field. Note that this
  29735. // operation is only accepted on creation of UsageStatisticHour entities.
  29736. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  29737. m.id = &id
  29738. }
  29739. // ID returns the ID value in the mutation. Note that the ID is only available
  29740. // if it was provided to the builder or after it was returned from the database.
  29741. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  29742. if m.id == nil {
  29743. return
  29744. }
  29745. return *m.id, true
  29746. }
  29747. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29748. // That means, if the mutation is applied within a transaction with an isolation level such
  29749. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29750. // or updated by the mutation.
  29751. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  29752. switch {
  29753. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29754. id, exists := m.ID()
  29755. if exists {
  29756. return []uint64{id}, nil
  29757. }
  29758. fallthrough
  29759. case m.op.Is(OpUpdate | OpDelete):
  29760. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  29761. default:
  29762. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29763. }
  29764. }
  29765. // SetCreatedAt sets the "created_at" field.
  29766. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  29767. m.created_at = &t
  29768. }
  29769. // CreatedAt returns the value of the "created_at" field in the mutation.
  29770. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  29771. v := m.created_at
  29772. if v == nil {
  29773. return
  29774. }
  29775. return *v, true
  29776. }
  29777. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  29778. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29780. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29781. if !m.op.Is(OpUpdateOne) {
  29782. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29783. }
  29784. if m.id == nil || m.oldValue == nil {
  29785. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29786. }
  29787. oldValue, err := m.oldValue(ctx)
  29788. if err != nil {
  29789. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29790. }
  29791. return oldValue.CreatedAt, nil
  29792. }
  29793. // ResetCreatedAt resets all changes to the "created_at" field.
  29794. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  29795. m.created_at = nil
  29796. }
  29797. // SetUpdatedAt sets the "updated_at" field.
  29798. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  29799. m.updated_at = &t
  29800. }
  29801. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29802. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  29803. v := m.updated_at
  29804. if v == nil {
  29805. return
  29806. }
  29807. return *v, true
  29808. }
  29809. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  29810. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29812. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29813. if !m.op.Is(OpUpdateOne) {
  29814. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29815. }
  29816. if m.id == nil || m.oldValue == nil {
  29817. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29818. }
  29819. oldValue, err := m.oldValue(ctx)
  29820. if err != nil {
  29821. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29822. }
  29823. return oldValue.UpdatedAt, nil
  29824. }
  29825. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29826. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  29827. m.updated_at = nil
  29828. }
  29829. // SetStatus sets the "status" field.
  29830. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  29831. m.status = &u
  29832. m.addstatus = nil
  29833. }
  29834. // Status returns the value of the "status" field in the mutation.
  29835. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  29836. v := m.status
  29837. if v == nil {
  29838. return
  29839. }
  29840. return *v, true
  29841. }
  29842. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  29843. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29845. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29846. if !m.op.Is(OpUpdateOne) {
  29847. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29848. }
  29849. if m.id == nil || m.oldValue == nil {
  29850. return v, errors.New("OldStatus requires an ID field in the mutation")
  29851. }
  29852. oldValue, err := m.oldValue(ctx)
  29853. if err != nil {
  29854. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29855. }
  29856. return oldValue.Status, nil
  29857. }
  29858. // AddStatus adds u to the "status" field.
  29859. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  29860. if m.addstatus != nil {
  29861. *m.addstatus += u
  29862. } else {
  29863. m.addstatus = &u
  29864. }
  29865. }
  29866. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29867. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  29868. v := m.addstatus
  29869. if v == nil {
  29870. return
  29871. }
  29872. return *v, true
  29873. }
  29874. // ClearStatus clears the value of the "status" field.
  29875. func (m *UsageStatisticHourMutation) ClearStatus() {
  29876. m.status = nil
  29877. m.addstatus = nil
  29878. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  29879. }
  29880. // StatusCleared returns if the "status" field was cleared in this mutation.
  29881. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  29882. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  29883. return ok
  29884. }
  29885. // ResetStatus resets all changes to the "status" field.
  29886. func (m *UsageStatisticHourMutation) ResetStatus() {
  29887. m.status = nil
  29888. m.addstatus = nil
  29889. delete(m.clearedFields, usagestatistichour.FieldStatus)
  29890. }
  29891. // SetDeletedAt sets the "deleted_at" field.
  29892. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  29893. m.deleted_at = &t
  29894. }
  29895. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29896. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  29897. v := m.deleted_at
  29898. if v == nil {
  29899. return
  29900. }
  29901. return *v, true
  29902. }
  29903. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  29904. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29906. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29907. if !m.op.Is(OpUpdateOne) {
  29908. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29909. }
  29910. if m.id == nil || m.oldValue == nil {
  29911. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29912. }
  29913. oldValue, err := m.oldValue(ctx)
  29914. if err != nil {
  29915. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29916. }
  29917. return oldValue.DeletedAt, nil
  29918. }
  29919. // ClearDeletedAt clears the value of the "deleted_at" field.
  29920. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  29921. m.deleted_at = nil
  29922. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  29923. }
  29924. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29925. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  29926. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  29927. return ok
  29928. }
  29929. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29930. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  29931. m.deleted_at = nil
  29932. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  29933. }
  29934. // SetAddtime sets the "addtime" field.
  29935. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  29936. m.addtime = &u
  29937. m.addaddtime = nil
  29938. }
  29939. // Addtime returns the value of the "addtime" field in the mutation.
  29940. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  29941. v := m.addtime
  29942. if v == nil {
  29943. return
  29944. }
  29945. return *v, true
  29946. }
  29947. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  29948. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29950. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29951. if !m.op.Is(OpUpdateOne) {
  29952. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29953. }
  29954. if m.id == nil || m.oldValue == nil {
  29955. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29956. }
  29957. oldValue, err := m.oldValue(ctx)
  29958. if err != nil {
  29959. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29960. }
  29961. return oldValue.Addtime, nil
  29962. }
  29963. // AddAddtime adds u to the "addtime" field.
  29964. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  29965. if m.addaddtime != nil {
  29966. *m.addaddtime += u
  29967. } else {
  29968. m.addaddtime = &u
  29969. }
  29970. }
  29971. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29972. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  29973. v := m.addaddtime
  29974. if v == nil {
  29975. return
  29976. }
  29977. return *v, true
  29978. }
  29979. // ResetAddtime resets all changes to the "addtime" field.
  29980. func (m *UsageStatisticHourMutation) ResetAddtime() {
  29981. m.addtime = nil
  29982. m.addaddtime = nil
  29983. }
  29984. // SetType sets the "type" field.
  29985. func (m *UsageStatisticHourMutation) SetType(i int) {
  29986. m._type = &i
  29987. m.add_type = nil
  29988. }
  29989. // GetType returns the value of the "type" field in the mutation.
  29990. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  29991. v := m._type
  29992. if v == nil {
  29993. return
  29994. }
  29995. return *v, true
  29996. }
  29997. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  29998. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30000. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  30001. if !m.op.Is(OpUpdateOne) {
  30002. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30003. }
  30004. if m.id == nil || m.oldValue == nil {
  30005. return v, errors.New("OldType requires an ID field in the mutation")
  30006. }
  30007. oldValue, err := m.oldValue(ctx)
  30008. if err != nil {
  30009. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30010. }
  30011. return oldValue.Type, nil
  30012. }
  30013. // AddType adds i to the "type" field.
  30014. func (m *UsageStatisticHourMutation) AddType(i int) {
  30015. if m.add_type != nil {
  30016. *m.add_type += i
  30017. } else {
  30018. m.add_type = &i
  30019. }
  30020. }
  30021. // AddedType returns the value that was added to the "type" field in this mutation.
  30022. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  30023. v := m.add_type
  30024. if v == nil {
  30025. return
  30026. }
  30027. return *v, true
  30028. }
  30029. // ResetType resets all changes to the "type" field.
  30030. func (m *UsageStatisticHourMutation) ResetType() {
  30031. m._type = nil
  30032. m.add_type = nil
  30033. }
  30034. // SetBotID sets the "bot_id" field.
  30035. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  30036. m.bot_id = &s
  30037. }
  30038. // BotID returns the value of the "bot_id" field in the mutation.
  30039. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  30040. v := m.bot_id
  30041. if v == nil {
  30042. return
  30043. }
  30044. return *v, true
  30045. }
  30046. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  30047. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30049. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  30050. if !m.op.Is(OpUpdateOne) {
  30051. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30052. }
  30053. if m.id == nil || m.oldValue == nil {
  30054. return v, errors.New("OldBotID requires an ID field in the mutation")
  30055. }
  30056. oldValue, err := m.oldValue(ctx)
  30057. if err != nil {
  30058. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30059. }
  30060. return oldValue.BotID, nil
  30061. }
  30062. // ClearBotID clears the value of the "bot_id" field.
  30063. func (m *UsageStatisticHourMutation) ClearBotID() {
  30064. m.bot_id = nil
  30065. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  30066. }
  30067. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30068. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  30069. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  30070. return ok
  30071. }
  30072. // ResetBotID resets all changes to the "bot_id" field.
  30073. func (m *UsageStatisticHourMutation) ResetBotID() {
  30074. m.bot_id = nil
  30075. delete(m.clearedFields, usagestatistichour.FieldBotID)
  30076. }
  30077. // SetOrganizationID sets the "organization_id" field.
  30078. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  30079. m.organization_id = &u
  30080. m.addorganization_id = nil
  30081. }
  30082. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30083. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  30084. v := m.organization_id
  30085. if v == nil {
  30086. return
  30087. }
  30088. return *v, true
  30089. }
  30090. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  30091. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30093. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30094. if !m.op.Is(OpUpdateOne) {
  30095. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30096. }
  30097. if m.id == nil || m.oldValue == nil {
  30098. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30099. }
  30100. oldValue, err := m.oldValue(ctx)
  30101. if err != nil {
  30102. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30103. }
  30104. return oldValue.OrganizationID, nil
  30105. }
  30106. // AddOrganizationID adds u to the "organization_id" field.
  30107. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  30108. if m.addorganization_id != nil {
  30109. *m.addorganization_id += u
  30110. } else {
  30111. m.addorganization_id = &u
  30112. }
  30113. }
  30114. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30115. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  30116. v := m.addorganization_id
  30117. if v == nil {
  30118. return
  30119. }
  30120. return *v, true
  30121. }
  30122. // ClearOrganizationID clears the value of the "organization_id" field.
  30123. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  30124. m.organization_id = nil
  30125. m.addorganization_id = nil
  30126. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  30127. }
  30128. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30129. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  30130. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  30131. return ok
  30132. }
  30133. // ResetOrganizationID resets all changes to the "organization_id" field.
  30134. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  30135. m.organization_id = nil
  30136. m.addorganization_id = nil
  30137. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  30138. }
  30139. // SetAiResponse sets the "ai_response" field.
  30140. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  30141. m.ai_response = &u
  30142. m.addai_response = nil
  30143. }
  30144. // AiResponse returns the value of the "ai_response" field in the mutation.
  30145. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  30146. v := m.ai_response
  30147. if v == nil {
  30148. return
  30149. }
  30150. return *v, true
  30151. }
  30152. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  30153. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30155. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30156. if !m.op.Is(OpUpdateOne) {
  30157. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30158. }
  30159. if m.id == nil || m.oldValue == nil {
  30160. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30161. }
  30162. oldValue, err := m.oldValue(ctx)
  30163. if err != nil {
  30164. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30165. }
  30166. return oldValue.AiResponse, nil
  30167. }
  30168. // AddAiResponse adds u to the "ai_response" field.
  30169. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  30170. if m.addai_response != nil {
  30171. *m.addai_response += u
  30172. } else {
  30173. m.addai_response = &u
  30174. }
  30175. }
  30176. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30177. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  30178. v := m.addai_response
  30179. if v == nil {
  30180. return
  30181. }
  30182. return *v, true
  30183. }
  30184. // ResetAiResponse resets all changes to the "ai_response" field.
  30185. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  30186. m.ai_response = nil
  30187. m.addai_response = nil
  30188. }
  30189. // SetSopRun sets the "sop_run" field.
  30190. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  30191. m.sop_run = &u
  30192. m.addsop_run = nil
  30193. }
  30194. // SopRun returns the value of the "sop_run" field in the mutation.
  30195. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  30196. v := m.sop_run
  30197. if v == nil {
  30198. return
  30199. }
  30200. return *v, true
  30201. }
  30202. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  30203. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30205. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30206. if !m.op.Is(OpUpdateOne) {
  30207. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30208. }
  30209. if m.id == nil || m.oldValue == nil {
  30210. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30211. }
  30212. oldValue, err := m.oldValue(ctx)
  30213. if err != nil {
  30214. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30215. }
  30216. return oldValue.SopRun, nil
  30217. }
  30218. // AddSopRun adds u to the "sop_run" field.
  30219. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  30220. if m.addsop_run != nil {
  30221. *m.addsop_run += u
  30222. } else {
  30223. m.addsop_run = &u
  30224. }
  30225. }
  30226. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30227. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  30228. v := m.addsop_run
  30229. if v == nil {
  30230. return
  30231. }
  30232. return *v, true
  30233. }
  30234. // ResetSopRun resets all changes to the "sop_run" field.
  30235. func (m *UsageStatisticHourMutation) ResetSopRun() {
  30236. m.sop_run = nil
  30237. m.addsop_run = nil
  30238. }
  30239. // SetTotalFriend sets the "total_friend" field.
  30240. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  30241. m.total_friend = &u
  30242. m.addtotal_friend = nil
  30243. }
  30244. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30245. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  30246. v := m.total_friend
  30247. if v == nil {
  30248. return
  30249. }
  30250. return *v, true
  30251. }
  30252. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  30253. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30255. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30256. if !m.op.Is(OpUpdateOne) {
  30257. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30258. }
  30259. if m.id == nil || m.oldValue == nil {
  30260. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30261. }
  30262. oldValue, err := m.oldValue(ctx)
  30263. if err != nil {
  30264. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30265. }
  30266. return oldValue.TotalFriend, nil
  30267. }
  30268. // AddTotalFriend adds u to the "total_friend" field.
  30269. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  30270. if m.addtotal_friend != nil {
  30271. *m.addtotal_friend += u
  30272. } else {
  30273. m.addtotal_friend = &u
  30274. }
  30275. }
  30276. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30277. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  30278. v := m.addtotal_friend
  30279. if v == nil {
  30280. return
  30281. }
  30282. return *v, true
  30283. }
  30284. // ResetTotalFriend resets all changes to the "total_friend" field.
  30285. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  30286. m.total_friend = nil
  30287. m.addtotal_friend = nil
  30288. }
  30289. // SetTotalGroup sets the "total_group" field.
  30290. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  30291. m.total_group = &u
  30292. m.addtotal_group = nil
  30293. }
  30294. // TotalGroup returns the value of the "total_group" field in the mutation.
  30295. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  30296. v := m.total_group
  30297. if v == nil {
  30298. return
  30299. }
  30300. return *v, true
  30301. }
  30302. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  30303. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30305. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30306. if !m.op.Is(OpUpdateOne) {
  30307. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30308. }
  30309. if m.id == nil || m.oldValue == nil {
  30310. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30311. }
  30312. oldValue, err := m.oldValue(ctx)
  30313. if err != nil {
  30314. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30315. }
  30316. return oldValue.TotalGroup, nil
  30317. }
  30318. // AddTotalGroup adds u to the "total_group" field.
  30319. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  30320. if m.addtotal_group != nil {
  30321. *m.addtotal_group += u
  30322. } else {
  30323. m.addtotal_group = &u
  30324. }
  30325. }
  30326. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30327. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  30328. v := m.addtotal_group
  30329. if v == nil {
  30330. return
  30331. }
  30332. return *v, true
  30333. }
  30334. // ResetTotalGroup resets all changes to the "total_group" field.
  30335. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  30336. m.total_group = nil
  30337. m.addtotal_group = nil
  30338. }
  30339. // SetAccountBalance sets the "account_balance" field.
  30340. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  30341. m.account_balance = &u
  30342. m.addaccount_balance = nil
  30343. }
  30344. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30345. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  30346. v := m.account_balance
  30347. if v == nil {
  30348. return
  30349. }
  30350. return *v, true
  30351. }
  30352. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  30353. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30355. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30356. if !m.op.Is(OpUpdateOne) {
  30357. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30358. }
  30359. if m.id == nil || m.oldValue == nil {
  30360. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30361. }
  30362. oldValue, err := m.oldValue(ctx)
  30363. if err != nil {
  30364. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30365. }
  30366. return oldValue.AccountBalance, nil
  30367. }
  30368. // AddAccountBalance adds u to the "account_balance" field.
  30369. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  30370. if m.addaccount_balance != nil {
  30371. *m.addaccount_balance += u
  30372. } else {
  30373. m.addaccount_balance = &u
  30374. }
  30375. }
  30376. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30377. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  30378. v := m.addaccount_balance
  30379. if v == nil {
  30380. return
  30381. }
  30382. return *v, true
  30383. }
  30384. // ResetAccountBalance resets all changes to the "account_balance" field.
  30385. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  30386. m.account_balance = nil
  30387. m.addaccount_balance = nil
  30388. }
  30389. // SetConsumeToken sets the "consume_token" field.
  30390. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  30391. m.consume_token = &u
  30392. m.addconsume_token = nil
  30393. }
  30394. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  30395. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  30396. v := m.consume_token
  30397. if v == nil {
  30398. return
  30399. }
  30400. return *v, true
  30401. }
  30402. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  30403. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30405. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  30406. if !m.op.Is(OpUpdateOne) {
  30407. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  30408. }
  30409. if m.id == nil || m.oldValue == nil {
  30410. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  30411. }
  30412. oldValue, err := m.oldValue(ctx)
  30413. if err != nil {
  30414. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  30415. }
  30416. return oldValue.ConsumeToken, nil
  30417. }
  30418. // AddConsumeToken adds u to the "consume_token" field.
  30419. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  30420. if m.addconsume_token != nil {
  30421. *m.addconsume_token += u
  30422. } else {
  30423. m.addconsume_token = &u
  30424. }
  30425. }
  30426. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  30427. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  30428. v := m.addconsume_token
  30429. if v == nil {
  30430. return
  30431. }
  30432. return *v, true
  30433. }
  30434. // ResetConsumeToken resets all changes to the "consume_token" field.
  30435. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  30436. m.consume_token = nil
  30437. m.addconsume_token = nil
  30438. }
  30439. // SetActiveUser sets the "active_user" field.
  30440. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  30441. m.active_user = &u
  30442. m.addactive_user = nil
  30443. }
  30444. // ActiveUser returns the value of the "active_user" field in the mutation.
  30445. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  30446. v := m.active_user
  30447. if v == nil {
  30448. return
  30449. }
  30450. return *v, true
  30451. }
  30452. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  30453. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30455. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  30456. if !m.op.Is(OpUpdateOne) {
  30457. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30458. }
  30459. if m.id == nil || m.oldValue == nil {
  30460. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30461. }
  30462. oldValue, err := m.oldValue(ctx)
  30463. if err != nil {
  30464. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30465. }
  30466. return oldValue.ActiveUser, nil
  30467. }
  30468. // AddActiveUser adds u to the "active_user" field.
  30469. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  30470. if m.addactive_user != nil {
  30471. *m.addactive_user += u
  30472. } else {
  30473. m.addactive_user = &u
  30474. }
  30475. }
  30476. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30477. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  30478. v := m.addactive_user
  30479. if v == nil {
  30480. return
  30481. }
  30482. return *v, true
  30483. }
  30484. // ResetActiveUser resets all changes to the "active_user" field.
  30485. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  30486. m.active_user = nil
  30487. m.addactive_user = nil
  30488. }
  30489. // SetNewUser sets the "new_user" field.
  30490. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  30491. m.new_user = &i
  30492. m.addnew_user = nil
  30493. }
  30494. // NewUser returns the value of the "new_user" field in the mutation.
  30495. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  30496. v := m.new_user
  30497. if v == nil {
  30498. return
  30499. }
  30500. return *v, true
  30501. }
  30502. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  30503. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30505. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30506. if !m.op.Is(OpUpdateOne) {
  30507. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30508. }
  30509. if m.id == nil || m.oldValue == nil {
  30510. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30511. }
  30512. oldValue, err := m.oldValue(ctx)
  30513. if err != nil {
  30514. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30515. }
  30516. return oldValue.NewUser, nil
  30517. }
  30518. // AddNewUser adds i to the "new_user" field.
  30519. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  30520. if m.addnew_user != nil {
  30521. *m.addnew_user += i
  30522. } else {
  30523. m.addnew_user = &i
  30524. }
  30525. }
  30526. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30527. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  30528. v := m.addnew_user
  30529. if v == nil {
  30530. return
  30531. }
  30532. return *v, true
  30533. }
  30534. // ResetNewUser resets all changes to the "new_user" field.
  30535. func (m *UsageStatisticHourMutation) ResetNewUser() {
  30536. m.new_user = nil
  30537. m.addnew_user = nil
  30538. }
  30539. // SetLabelDist sets the "label_dist" field.
  30540. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30541. m.label_dist = &ctd
  30542. m.appendlabel_dist = nil
  30543. }
  30544. // LabelDist returns the value of the "label_dist" field in the mutation.
  30545. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30546. v := m.label_dist
  30547. if v == nil {
  30548. return
  30549. }
  30550. return *v, true
  30551. }
  30552. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  30553. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30555. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30556. if !m.op.Is(OpUpdateOne) {
  30557. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30558. }
  30559. if m.id == nil || m.oldValue == nil {
  30560. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30561. }
  30562. oldValue, err := m.oldValue(ctx)
  30563. if err != nil {
  30564. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30565. }
  30566. return oldValue.LabelDist, nil
  30567. }
  30568. // AppendLabelDist adds ctd to the "label_dist" field.
  30569. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30570. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30571. }
  30572. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30573. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30574. if len(m.appendlabel_dist) == 0 {
  30575. return nil, false
  30576. }
  30577. return m.appendlabel_dist, true
  30578. }
  30579. // ResetLabelDist resets all changes to the "label_dist" field.
  30580. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  30581. m.label_dist = nil
  30582. m.appendlabel_dist = nil
  30583. }
  30584. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  30585. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  30586. m.predicates = append(m.predicates, ps...)
  30587. }
  30588. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  30589. // users can use type-assertion to append predicates that do not depend on any generated package.
  30590. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  30591. p := make([]predicate.UsageStatisticHour, len(ps))
  30592. for i := range ps {
  30593. p[i] = ps[i]
  30594. }
  30595. m.Where(p...)
  30596. }
  30597. // Op returns the operation name.
  30598. func (m *UsageStatisticHourMutation) Op() Op {
  30599. return m.op
  30600. }
  30601. // SetOp allows setting the mutation operation.
  30602. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  30603. m.op = op
  30604. }
  30605. // Type returns the node type of this mutation (UsageStatisticHour).
  30606. func (m *UsageStatisticHourMutation) Type() string {
  30607. return m.typ
  30608. }
  30609. // Fields returns all fields that were changed during this mutation. Note that in
  30610. // order to get all numeric fields that were incremented/decremented, call
  30611. // AddedFields().
  30612. func (m *UsageStatisticHourMutation) Fields() []string {
  30613. fields := make([]string, 0, 17)
  30614. if m.created_at != nil {
  30615. fields = append(fields, usagestatistichour.FieldCreatedAt)
  30616. }
  30617. if m.updated_at != nil {
  30618. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  30619. }
  30620. if m.status != nil {
  30621. fields = append(fields, usagestatistichour.FieldStatus)
  30622. }
  30623. if m.deleted_at != nil {
  30624. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30625. }
  30626. if m.addtime != nil {
  30627. fields = append(fields, usagestatistichour.FieldAddtime)
  30628. }
  30629. if m._type != nil {
  30630. fields = append(fields, usagestatistichour.FieldType)
  30631. }
  30632. if m.bot_id != nil {
  30633. fields = append(fields, usagestatistichour.FieldBotID)
  30634. }
  30635. if m.organization_id != nil {
  30636. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30637. }
  30638. if m.ai_response != nil {
  30639. fields = append(fields, usagestatistichour.FieldAiResponse)
  30640. }
  30641. if m.sop_run != nil {
  30642. fields = append(fields, usagestatistichour.FieldSopRun)
  30643. }
  30644. if m.total_friend != nil {
  30645. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30646. }
  30647. if m.total_group != nil {
  30648. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30649. }
  30650. if m.account_balance != nil {
  30651. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30652. }
  30653. if m.consume_token != nil {
  30654. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30655. }
  30656. if m.active_user != nil {
  30657. fields = append(fields, usagestatistichour.FieldActiveUser)
  30658. }
  30659. if m.new_user != nil {
  30660. fields = append(fields, usagestatistichour.FieldNewUser)
  30661. }
  30662. if m.label_dist != nil {
  30663. fields = append(fields, usagestatistichour.FieldLabelDist)
  30664. }
  30665. return fields
  30666. }
  30667. // Field returns the value of a field with the given name. The second boolean
  30668. // return value indicates that this field was not set, or was not defined in the
  30669. // schema.
  30670. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  30671. switch name {
  30672. case usagestatistichour.FieldCreatedAt:
  30673. return m.CreatedAt()
  30674. case usagestatistichour.FieldUpdatedAt:
  30675. return m.UpdatedAt()
  30676. case usagestatistichour.FieldStatus:
  30677. return m.Status()
  30678. case usagestatistichour.FieldDeletedAt:
  30679. return m.DeletedAt()
  30680. case usagestatistichour.FieldAddtime:
  30681. return m.Addtime()
  30682. case usagestatistichour.FieldType:
  30683. return m.GetType()
  30684. case usagestatistichour.FieldBotID:
  30685. return m.BotID()
  30686. case usagestatistichour.FieldOrganizationID:
  30687. return m.OrganizationID()
  30688. case usagestatistichour.FieldAiResponse:
  30689. return m.AiResponse()
  30690. case usagestatistichour.FieldSopRun:
  30691. return m.SopRun()
  30692. case usagestatistichour.FieldTotalFriend:
  30693. return m.TotalFriend()
  30694. case usagestatistichour.FieldTotalGroup:
  30695. return m.TotalGroup()
  30696. case usagestatistichour.FieldAccountBalance:
  30697. return m.AccountBalance()
  30698. case usagestatistichour.FieldConsumeToken:
  30699. return m.ConsumeToken()
  30700. case usagestatistichour.FieldActiveUser:
  30701. return m.ActiveUser()
  30702. case usagestatistichour.FieldNewUser:
  30703. return m.NewUser()
  30704. case usagestatistichour.FieldLabelDist:
  30705. return m.LabelDist()
  30706. }
  30707. return nil, false
  30708. }
  30709. // OldField returns the old value of the field from the database. An error is
  30710. // returned if the mutation operation is not UpdateOne, or the query to the
  30711. // database failed.
  30712. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30713. switch name {
  30714. case usagestatistichour.FieldCreatedAt:
  30715. return m.OldCreatedAt(ctx)
  30716. case usagestatistichour.FieldUpdatedAt:
  30717. return m.OldUpdatedAt(ctx)
  30718. case usagestatistichour.FieldStatus:
  30719. return m.OldStatus(ctx)
  30720. case usagestatistichour.FieldDeletedAt:
  30721. return m.OldDeletedAt(ctx)
  30722. case usagestatistichour.FieldAddtime:
  30723. return m.OldAddtime(ctx)
  30724. case usagestatistichour.FieldType:
  30725. return m.OldType(ctx)
  30726. case usagestatistichour.FieldBotID:
  30727. return m.OldBotID(ctx)
  30728. case usagestatistichour.FieldOrganizationID:
  30729. return m.OldOrganizationID(ctx)
  30730. case usagestatistichour.FieldAiResponse:
  30731. return m.OldAiResponse(ctx)
  30732. case usagestatistichour.FieldSopRun:
  30733. return m.OldSopRun(ctx)
  30734. case usagestatistichour.FieldTotalFriend:
  30735. return m.OldTotalFriend(ctx)
  30736. case usagestatistichour.FieldTotalGroup:
  30737. return m.OldTotalGroup(ctx)
  30738. case usagestatistichour.FieldAccountBalance:
  30739. return m.OldAccountBalance(ctx)
  30740. case usagestatistichour.FieldConsumeToken:
  30741. return m.OldConsumeToken(ctx)
  30742. case usagestatistichour.FieldActiveUser:
  30743. return m.OldActiveUser(ctx)
  30744. case usagestatistichour.FieldNewUser:
  30745. return m.OldNewUser(ctx)
  30746. case usagestatistichour.FieldLabelDist:
  30747. return m.OldLabelDist(ctx)
  30748. }
  30749. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30750. }
  30751. // SetField sets the value of a field with the given name. It returns an error if
  30752. // the field is not defined in the schema, or if the type mismatched the field
  30753. // type.
  30754. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  30755. switch name {
  30756. case usagestatistichour.FieldCreatedAt:
  30757. v, ok := value.(time.Time)
  30758. if !ok {
  30759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30760. }
  30761. m.SetCreatedAt(v)
  30762. return nil
  30763. case usagestatistichour.FieldUpdatedAt:
  30764. v, ok := value.(time.Time)
  30765. if !ok {
  30766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30767. }
  30768. m.SetUpdatedAt(v)
  30769. return nil
  30770. case usagestatistichour.FieldStatus:
  30771. v, ok := value.(uint8)
  30772. if !ok {
  30773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30774. }
  30775. m.SetStatus(v)
  30776. return nil
  30777. case usagestatistichour.FieldDeletedAt:
  30778. v, ok := value.(time.Time)
  30779. if !ok {
  30780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30781. }
  30782. m.SetDeletedAt(v)
  30783. return nil
  30784. case usagestatistichour.FieldAddtime:
  30785. v, ok := value.(uint64)
  30786. if !ok {
  30787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30788. }
  30789. m.SetAddtime(v)
  30790. return nil
  30791. case usagestatistichour.FieldType:
  30792. v, ok := value.(int)
  30793. if !ok {
  30794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30795. }
  30796. m.SetType(v)
  30797. return nil
  30798. case usagestatistichour.FieldBotID:
  30799. v, ok := value.(string)
  30800. if !ok {
  30801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30802. }
  30803. m.SetBotID(v)
  30804. return nil
  30805. case usagestatistichour.FieldOrganizationID:
  30806. v, ok := value.(uint64)
  30807. if !ok {
  30808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30809. }
  30810. m.SetOrganizationID(v)
  30811. return nil
  30812. case usagestatistichour.FieldAiResponse:
  30813. v, ok := value.(uint64)
  30814. if !ok {
  30815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30816. }
  30817. m.SetAiResponse(v)
  30818. return nil
  30819. case usagestatistichour.FieldSopRun:
  30820. v, ok := value.(uint64)
  30821. if !ok {
  30822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30823. }
  30824. m.SetSopRun(v)
  30825. return nil
  30826. case usagestatistichour.FieldTotalFriend:
  30827. v, ok := value.(uint64)
  30828. if !ok {
  30829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30830. }
  30831. m.SetTotalFriend(v)
  30832. return nil
  30833. case usagestatistichour.FieldTotalGroup:
  30834. v, ok := value.(uint64)
  30835. if !ok {
  30836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30837. }
  30838. m.SetTotalGroup(v)
  30839. return nil
  30840. case usagestatistichour.FieldAccountBalance:
  30841. v, ok := value.(uint64)
  30842. if !ok {
  30843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30844. }
  30845. m.SetAccountBalance(v)
  30846. return nil
  30847. case usagestatistichour.FieldConsumeToken:
  30848. v, ok := value.(uint64)
  30849. if !ok {
  30850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30851. }
  30852. m.SetConsumeToken(v)
  30853. return nil
  30854. case usagestatistichour.FieldActiveUser:
  30855. v, ok := value.(uint64)
  30856. if !ok {
  30857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30858. }
  30859. m.SetActiveUser(v)
  30860. return nil
  30861. case usagestatistichour.FieldNewUser:
  30862. v, ok := value.(int64)
  30863. if !ok {
  30864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30865. }
  30866. m.SetNewUser(v)
  30867. return nil
  30868. case usagestatistichour.FieldLabelDist:
  30869. v, ok := value.([]custom_types.LabelDist)
  30870. if !ok {
  30871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30872. }
  30873. m.SetLabelDist(v)
  30874. return nil
  30875. }
  30876. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30877. }
  30878. // AddedFields returns all numeric fields that were incremented/decremented during
  30879. // this mutation.
  30880. func (m *UsageStatisticHourMutation) AddedFields() []string {
  30881. var fields []string
  30882. if m.addstatus != nil {
  30883. fields = append(fields, usagestatistichour.FieldStatus)
  30884. }
  30885. if m.addaddtime != nil {
  30886. fields = append(fields, usagestatistichour.FieldAddtime)
  30887. }
  30888. if m.add_type != nil {
  30889. fields = append(fields, usagestatistichour.FieldType)
  30890. }
  30891. if m.addorganization_id != nil {
  30892. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30893. }
  30894. if m.addai_response != nil {
  30895. fields = append(fields, usagestatistichour.FieldAiResponse)
  30896. }
  30897. if m.addsop_run != nil {
  30898. fields = append(fields, usagestatistichour.FieldSopRun)
  30899. }
  30900. if m.addtotal_friend != nil {
  30901. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30902. }
  30903. if m.addtotal_group != nil {
  30904. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30905. }
  30906. if m.addaccount_balance != nil {
  30907. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30908. }
  30909. if m.addconsume_token != nil {
  30910. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30911. }
  30912. if m.addactive_user != nil {
  30913. fields = append(fields, usagestatistichour.FieldActiveUser)
  30914. }
  30915. if m.addnew_user != nil {
  30916. fields = append(fields, usagestatistichour.FieldNewUser)
  30917. }
  30918. return fields
  30919. }
  30920. // AddedField returns the numeric value that was incremented/decremented on a field
  30921. // with the given name. The second boolean return value indicates that this field
  30922. // was not set, or was not defined in the schema.
  30923. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  30924. switch name {
  30925. case usagestatistichour.FieldStatus:
  30926. return m.AddedStatus()
  30927. case usagestatistichour.FieldAddtime:
  30928. return m.AddedAddtime()
  30929. case usagestatistichour.FieldType:
  30930. return m.AddedType()
  30931. case usagestatistichour.FieldOrganizationID:
  30932. return m.AddedOrganizationID()
  30933. case usagestatistichour.FieldAiResponse:
  30934. return m.AddedAiResponse()
  30935. case usagestatistichour.FieldSopRun:
  30936. return m.AddedSopRun()
  30937. case usagestatistichour.FieldTotalFriend:
  30938. return m.AddedTotalFriend()
  30939. case usagestatistichour.FieldTotalGroup:
  30940. return m.AddedTotalGroup()
  30941. case usagestatistichour.FieldAccountBalance:
  30942. return m.AddedAccountBalance()
  30943. case usagestatistichour.FieldConsumeToken:
  30944. return m.AddedConsumeToken()
  30945. case usagestatistichour.FieldActiveUser:
  30946. return m.AddedActiveUser()
  30947. case usagestatistichour.FieldNewUser:
  30948. return m.AddedNewUser()
  30949. }
  30950. return nil, false
  30951. }
  30952. // AddField adds the value to the field with the given name. It returns an error if
  30953. // the field is not defined in the schema, or if the type mismatched the field
  30954. // type.
  30955. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  30956. switch name {
  30957. case usagestatistichour.FieldStatus:
  30958. v, ok := value.(int8)
  30959. if !ok {
  30960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30961. }
  30962. m.AddStatus(v)
  30963. return nil
  30964. case usagestatistichour.FieldAddtime:
  30965. v, ok := value.(int64)
  30966. if !ok {
  30967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30968. }
  30969. m.AddAddtime(v)
  30970. return nil
  30971. case usagestatistichour.FieldType:
  30972. v, ok := value.(int)
  30973. if !ok {
  30974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30975. }
  30976. m.AddType(v)
  30977. return nil
  30978. case usagestatistichour.FieldOrganizationID:
  30979. v, ok := value.(int64)
  30980. if !ok {
  30981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30982. }
  30983. m.AddOrganizationID(v)
  30984. return nil
  30985. case usagestatistichour.FieldAiResponse:
  30986. v, ok := value.(int64)
  30987. if !ok {
  30988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30989. }
  30990. m.AddAiResponse(v)
  30991. return nil
  30992. case usagestatistichour.FieldSopRun:
  30993. v, ok := value.(int64)
  30994. if !ok {
  30995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30996. }
  30997. m.AddSopRun(v)
  30998. return nil
  30999. case usagestatistichour.FieldTotalFriend:
  31000. v, ok := value.(int64)
  31001. if !ok {
  31002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31003. }
  31004. m.AddTotalFriend(v)
  31005. return nil
  31006. case usagestatistichour.FieldTotalGroup:
  31007. v, ok := value.(int64)
  31008. if !ok {
  31009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31010. }
  31011. m.AddTotalGroup(v)
  31012. return nil
  31013. case usagestatistichour.FieldAccountBalance:
  31014. v, ok := value.(int64)
  31015. if !ok {
  31016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31017. }
  31018. m.AddAccountBalance(v)
  31019. return nil
  31020. case usagestatistichour.FieldConsumeToken:
  31021. v, ok := value.(int64)
  31022. if !ok {
  31023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31024. }
  31025. m.AddConsumeToken(v)
  31026. return nil
  31027. case usagestatistichour.FieldActiveUser:
  31028. v, ok := value.(int64)
  31029. if !ok {
  31030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31031. }
  31032. m.AddActiveUser(v)
  31033. return nil
  31034. case usagestatistichour.FieldNewUser:
  31035. v, ok := value.(int64)
  31036. if !ok {
  31037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31038. }
  31039. m.AddNewUser(v)
  31040. return nil
  31041. }
  31042. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  31043. }
  31044. // ClearedFields returns all nullable fields that were cleared during this
  31045. // mutation.
  31046. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  31047. var fields []string
  31048. if m.FieldCleared(usagestatistichour.FieldStatus) {
  31049. fields = append(fields, usagestatistichour.FieldStatus)
  31050. }
  31051. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  31052. fields = append(fields, usagestatistichour.FieldDeletedAt)
  31053. }
  31054. if m.FieldCleared(usagestatistichour.FieldBotID) {
  31055. fields = append(fields, usagestatistichour.FieldBotID)
  31056. }
  31057. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  31058. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31059. }
  31060. return fields
  31061. }
  31062. // FieldCleared returns a boolean indicating if a field with the given name was
  31063. // cleared in this mutation.
  31064. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  31065. _, ok := m.clearedFields[name]
  31066. return ok
  31067. }
  31068. // ClearField clears the value of the field with the given name. It returns an
  31069. // error if the field is not defined in the schema.
  31070. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  31071. switch name {
  31072. case usagestatistichour.FieldStatus:
  31073. m.ClearStatus()
  31074. return nil
  31075. case usagestatistichour.FieldDeletedAt:
  31076. m.ClearDeletedAt()
  31077. return nil
  31078. case usagestatistichour.FieldBotID:
  31079. m.ClearBotID()
  31080. return nil
  31081. case usagestatistichour.FieldOrganizationID:
  31082. m.ClearOrganizationID()
  31083. return nil
  31084. }
  31085. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  31086. }
  31087. // ResetField resets all changes in the mutation for the field with the given name.
  31088. // It returns an error if the field is not defined in the schema.
  31089. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  31090. switch name {
  31091. case usagestatistichour.FieldCreatedAt:
  31092. m.ResetCreatedAt()
  31093. return nil
  31094. case usagestatistichour.FieldUpdatedAt:
  31095. m.ResetUpdatedAt()
  31096. return nil
  31097. case usagestatistichour.FieldStatus:
  31098. m.ResetStatus()
  31099. return nil
  31100. case usagestatistichour.FieldDeletedAt:
  31101. m.ResetDeletedAt()
  31102. return nil
  31103. case usagestatistichour.FieldAddtime:
  31104. m.ResetAddtime()
  31105. return nil
  31106. case usagestatistichour.FieldType:
  31107. m.ResetType()
  31108. return nil
  31109. case usagestatistichour.FieldBotID:
  31110. m.ResetBotID()
  31111. return nil
  31112. case usagestatistichour.FieldOrganizationID:
  31113. m.ResetOrganizationID()
  31114. return nil
  31115. case usagestatistichour.FieldAiResponse:
  31116. m.ResetAiResponse()
  31117. return nil
  31118. case usagestatistichour.FieldSopRun:
  31119. m.ResetSopRun()
  31120. return nil
  31121. case usagestatistichour.FieldTotalFriend:
  31122. m.ResetTotalFriend()
  31123. return nil
  31124. case usagestatistichour.FieldTotalGroup:
  31125. m.ResetTotalGroup()
  31126. return nil
  31127. case usagestatistichour.FieldAccountBalance:
  31128. m.ResetAccountBalance()
  31129. return nil
  31130. case usagestatistichour.FieldConsumeToken:
  31131. m.ResetConsumeToken()
  31132. return nil
  31133. case usagestatistichour.FieldActiveUser:
  31134. m.ResetActiveUser()
  31135. return nil
  31136. case usagestatistichour.FieldNewUser:
  31137. m.ResetNewUser()
  31138. return nil
  31139. case usagestatistichour.FieldLabelDist:
  31140. m.ResetLabelDist()
  31141. return nil
  31142. }
  31143. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31144. }
  31145. // AddedEdges returns all edge names that were set/added in this mutation.
  31146. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  31147. edges := make([]string, 0, 0)
  31148. return edges
  31149. }
  31150. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31151. // name in this mutation.
  31152. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  31153. return nil
  31154. }
  31155. // RemovedEdges returns all edge names that were removed in this mutation.
  31156. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  31157. edges := make([]string, 0, 0)
  31158. return edges
  31159. }
  31160. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31161. // the given name in this mutation.
  31162. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  31163. return nil
  31164. }
  31165. // ClearedEdges returns all edge names that were cleared in this mutation.
  31166. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  31167. edges := make([]string, 0, 0)
  31168. return edges
  31169. }
  31170. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31171. // was cleared in this mutation.
  31172. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  31173. return false
  31174. }
  31175. // ClearEdge clears the value of the edge with the given name. It returns an error
  31176. // if that edge is not defined in the schema.
  31177. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  31178. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  31179. }
  31180. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31181. // It returns an error if the edge is not defined in the schema.
  31182. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  31183. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  31184. }
  31185. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  31186. type UsageStatisticMonthMutation struct {
  31187. config
  31188. op Op
  31189. typ string
  31190. id *uint64
  31191. created_at *time.Time
  31192. updated_at *time.Time
  31193. status *uint8
  31194. addstatus *int8
  31195. deleted_at *time.Time
  31196. addtime *uint64
  31197. addaddtime *int64
  31198. _type *int
  31199. add_type *int
  31200. bot_id *string
  31201. organization_id *uint64
  31202. addorganization_id *int64
  31203. ai_response *uint64
  31204. addai_response *int64
  31205. sop_run *uint64
  31206. addsop_run *int64
  31207. total_friend *uint64
  31208. addtotal_friend *int64
  31209. total_group *uint64
  31210. addtotal_group *int64
  31211. account_balance *uint64
  31212. addaccount_balance *int64
  31213. consume_token *uint64
  31214. addconsume_token *int64
  31215. active_user *uint64
  31216. addactive_user *int64
  31217. new_user *int64
  31218. addnew_user *int64
  31219. label_dist *[]custom_types.LabelDist
  31220. appendlabel_dist []custom_types.LabelDist
  31221. clearedFields map[string]struct{}
  31222. done bool
  31223. oldValue func(context.Context) (*UsageStatisticMonth, error)
  31224. predicates []predicate.UsageStatisticMonth
  31225. }
  31226. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  31227. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  31228. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  31229. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  31230. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  31231. m := &UsageStatisticMonthMutation{
  31232. config: c,
  31233. op: op,
  31234. typ: TypeUsageStatisticMonth,
  31235. clearedFields: make(map[string]struct{}),
  31236. }
  31237. for _, opt := range opts {
  31238. opt(m)
  31239. }
  31240. return m
  31241. }
  31242. // withUsageStatisticMonthID sets the ID field of the mutation.
  31243. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  31244. return func(m *UsageStatisticMonthMutation) {
  31245. var (
  31246. err error
  31247. once sync.Once
  31248. value *UsageStatisticMonth
  31249. )
  31250. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  31251. once.Do(func() {
  31252. if m.done {
  31253. err = errors.New("querying old values post mutation is not allowed")
  31254. } else {
  31255. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  31256. }
  31257. })
  31258. return value, err
  31259. }
  31260. m.id = &id
  31261. }
  31262. }
  31263. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  31264. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  31265. return func(m *UsageStatisticMonthMutation) {
  31266. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  31267. return node, nil
  31268. }
  31269. m.id = &node.ID
  31270. }
  31271. }
  31272. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31273. // executed in a transaction (ent.Tx), a transactional client is returned.
  31274. func (m UsageStatisticMonthMutation) Client() *Client {
  31275. client := &Client{config: m.config}
  31276. client.init()
  31277. return client
  31278. }
  31279. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31280. // it returns an error otherwise.
  31281. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  31282. if _, ok := m.driver.(*txDriver); !ok {
  31283. return nil, errors.New("ent: mutation is not running in a transaction")
  31284. }
  31285. tx := &Tx{config: m.config}
  31286. tx.init()
  31287. return tx, nil
  31288. }
  31289. // SetID sets the value of the id field. Note that this
  31290. // operation is only accepted on creation of UsageStatisticMonth entities.
  31291. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  31292. m.id = &id
  31293. }
  31294. // ID returns the ID value in the mutation. Note that the ID is only available
  31295. // if it was provided to the builder or after it was returned from the database.
  31296. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  31297. if m.id == nil {
  31298. return
  31299. }
  31300. return *m.id, true
  31301. }
  31302. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31303. // That means, if the mutation is applied within a transaction with an isolation level such
  31304. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31305. // or updated by the mutation.
  31306. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  31307. switch {
  31308. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31309. id, exists := m.ID()
  31310. if exists {
  31311. return []uint64{id}, nil
  31312. }
  31313. fallthrough
  31314. case m.op.Is(OpUpdate | OpDelete):
  31315. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  31316. default:
  31317. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31318. }
  31319. }
  31320. // SetCreatedAt sets the "created_at" field.
  31321. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  31322. m.created_at = &t
  31323. }
  31324. // CreatedAt returns the value of the "created_at" field in the mutation.
  31325. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  31326. v := m.created_at
  31327. if v == nil {
  31328. return
  31329. }
  31330. return *v, true
  31331. }
  31332. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  31333. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31335. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31336. if !m.op.Is(OpUpdateOne) {
  31337. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31338. }
  31339. if m.id == nil || m.oldValue == nil {
  31340. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31341. }
  31342. oldValue, err := m.oldValue(ctx)
  31343. if err != nil {
  31344. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31345. }
  31346. return oldValue.CreatedAt, nil
  31347. }
  31348. // ResetCreatedAt resets all changes to the "created_at" field.
  31349. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  31350. m.created_at = nil
  31351. }
  31352. // SetUpdatedAt sets the "updated_at" field.
  31353. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  31354. m.updated_at = &t
  31355. }
  31356. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31357. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  31358. v := m.updated_at
  31359. if v == nil {
  31360. return
  31361. }
  31362. return *v, true
  31363. }
  31364. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  31365. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31367. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31368. if !m.op.Is(OpUpdateOne) {
  31369. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31370. }
  31371. if m.id == nil || m.oldValue == nil {
  31372. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31373. }
  31374. oldValue, err := m.oldValue(ctx)
  31375. if err != nil {
  31376. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31377. }
  31378. return oldValue.UpdatedAt, nil
  31379. }
  31380. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31381. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  31382. m.updated_at = nil
  31383. }
  31384. // SetStatus sets the "status" field.
  31385. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  31386. m.status = &u
  31387. m.addstatus = nil
  31388. }
  31389. // Status returns the value of the "status" field in the mutation.
  31390. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  31391. v := m.status
  31392. if v == nil {
  31393. return
  31394. }
  31395. return *v, true
  31396. }
  31397. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  31398. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31400. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31401. if !m.op.Is(OpUpdateOne) {
  31402. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31403. }
  31404. if m.id == nil || m.oldValue == nil {
  31405. return v, errors.New("OldStatus requires an ID field in the mutation")
  31406. }
  31407. oldValue, err := m.oldValue(ctx)
  31408. if err != nil {
  31409. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31410. }
  31411. return oldValue.Status, nil
  31412. }
  31413. // AddStatus adds u to the "status" field.
  31414. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  31415. if m.addstatus != nil {
  31416. *m.addstatus += u
  31417. } else {
  31418. m.addstatus = &u
  31419. }
  31420. }
  31421. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31422. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  31423. v := m.addstatus
  31424. if v == nil {
  31425. return
  31426. }
  31427. return *v, true
  31428. }
  31429. // ClearStatus clears the value of the "status" field.
  31430. func (m *UsageStatisticMonthMutation) ClearStatus() {
  31431. m.status = nil
  31432. m.addstatus = nil
  31433. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  31434. }
  31435. // StatusCleared returns if the "status" field was cleared in this mutation.
  31436. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  31437. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  31438. return ok
  31439. }
  31440. // ResetStatus resets all changes to the "status" field.
  31441. func (m *UsageStatisticMonthMutation) ResetStatus() {
  31442. m.status = nil
  31443. m.addstatus = nil
  31444. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  31445. }
  31446. // SetDeletedAt sets the "deleted_at" field.
  31447. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  31448. m.deleted_at = &t
  31449. }
  31450. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31451. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  31452. v := m.deleted_at
  31453. if v == nil {
  31454. return
  31455. }
  31456. return *v, true
  31457. }
  31458. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  31459. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31461. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31462. if !m.op.Is(OpUpdateOne) {
  31463. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31464. }
  31465. if m.id == nil || m.oldValue == nil {
  31466. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31467. }
  31468. oldValue, err := m.oldValue(ctx)
  31469. if err != nil {
  31470. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31471. }
  31472. return oldValue.DeletedAt, nil
  31473. }
  31474. // ClearDeletedAt clears the value of the "deleted_at" field.
  31475. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  31476. m.deleted_at = nil
  31477. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  31478. }
  31479. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31480. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  31481. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  31482. return ok
  31483. }
  31484. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31485. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  31486. m.deleted_at = nil
  31487. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  31488. }
  31489. // SetAddtime sets the "addtime" field.
  31490. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  31491. m.addtime = &u
  31492. m.addaddtime = nil
  31493. }
  31494. // Addtime returns the value of the "addtime" field in the mutation.
  31495. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  31496. v := m.addtime
  31497. if v == nil {
  31498. return
  31499. }
  31500. return *v, true
  31501. }
  31502. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  31503. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31505. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31506. if !m.op.Is(OpUpdateOne) {
  31507. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31508. }
  31509. if m.id == nil || m.oldValue == nil {
  31510. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31511. }
  31512. oldValue, err := m.oldValue(ctx)
  31513. if err != nil {
  31514. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31515. }
  31516. return oldValue.Addtime, nil
  31517. }
  31518. // AddAddtime adds u to the "addtime" field.
  31519. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  31520. if m.addaddtime != nil {
  31521. *m.addaddtime += u
  31522. } else {
  31523. m.addaddtime = &u
  31524. }
  31525. }
  31526. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31527. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  31528. v := m.addaddtime
  31529. if v == nil {
  31530. return
  31531. }
  31532. return *v, true
  31533. }
  31534. // ResetAddtime resets all changes to the "addtime" field.
  31535. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  31536. m.addtime = nil
  31537. m.addaddtime = nil
  31538. }
  31539. // SetType sets the "type" field.
  31540. func (m *UsageStatisticMonthMutation) SetType(i int) {
  31541. m._type = &i
  31542. m.add_type = nil
  31543. }
  31544. // GetType returns the value of the "type" field in the mutation.
  31545. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  31546. v := m._type
  31547. if v == nil {
  31548. return
  31549. }
  31550. return *v, true
  31551. }
  31552. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  31553. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31555. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  31556. if !m.op.Is(OpUpdateOne) {
  31557. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31558. }
  31559. if m.id == nil || m.oldValue == nil {
  31560. return v, errors.New("OldType requires an ID field in the mutation")
  31561. }
  31562. oldValue, err := m.oldValue(ctx)
  31563. if err != nil {
  31564. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31565. }
  31566. return oldValue.Type, nil
  31567. }
  31568. // AddType adds i to the "type" field.
  31569. func (m *UsageStatisticMonthMutation) AddType(i int) {
  31570. if m.add_type != nil {
  31571. *m.add_type += i
  31572. } else {
  31573. m.add_type = &i
  31574. }
  31575. }
  31576. // AddedType returns the value that was added to the "type" field in this mutation.
  31577. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  31578. v := m.add_type
  31579. if v == nil {
  31580. return
  31581. }
  31582. return *v, true
  31583. }
  31584. // ResetType resets all changes to the "type" field.
  31585. func (m *UsageStatisticMonthMutation) ResetType() {
  31586. m._type = nil
  31587. m.add_type = nil
  31588. }
  31589. // SetBotID sets the "bot_id" field.
  31590. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  31591. m.bot_id = &s
  31592. }
  31593. // BotID returns the value of the "bot_id" field in the mutation.
  31594. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  31595. v := m.bot_id
  31596. if v == nil {
  31597. return
  31598. }
  31599. return *v, true
  31600. }
  31601. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  31602. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31604. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  31605. if !m.op.Is(OpUpdateOne) {
  31606. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31607. }
  31608. if m.id == nil || m.oldValue == nil {
  31609. return v, errors.New("OldBotID requires an ID field in the mutation")
  31610. }
  31611. oldValue, err := m.oldValue(ctx)
  31612. if err != nil {
  31613. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31614. }
  31615. return oldValue.BotID, nil
  31616. }
  31617. // ClearBotID clears the value of the "bot_id" field.
  31618. func (m *UsageStatisticMonthMutation) ClearBotID() {
  31619. m.bot_id = nil
  31620. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  31621. }
  31622. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31623. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  31624. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  31625. return ok
  31626. }
  31627. // ResetBotID resets all changes to the "bot_id" field.
  31628. func (m *UsageStatisticMonthMutation) ResetBotID() {
  31629. m.bot_id = nil
  31630. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  31631. }
  31632. // SetOrganizationID sets the "organization_id" field.
  31633. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  31634. m.organization_id = &u
  31635. m.addorganization_id = nil
  31636. }
  31637. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31638. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  31639. v := m.organization_id
  31640. if v == nil {
  31641. return
  31642. }
  31643. return *v, true
  31644. }
  31645. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  31646. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31648. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31649. if !m.op.Is(OpUpdateOne) {
  31650. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31651. }
  31652. if m.id == nil || m.oldValue == nil {
  31653. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31654. }
  31655. oldValue, err := m.oldValue(ctx)
  31656. if err != nil {
  31657. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31658. }
  31659. return oldValue.OrganizationID, nil
  31660. }
  31661. // AddOrganizationID adds u to the "organization_id" field.
  31662. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  31663. if m.addorganization_id != nil {
  31664. *m.addorganization_id += u
  31665. } else {
  31666. m.addorganization_id = &u
  31667. }
  31668. }
  31669. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31670. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  31671. v := m.addorganization_id
  31672. if v == nil {
  31673. return
  31674. }
  31675. return *v, true
  31676. }
  31677. // ClearOrganizationID clears the value of the "organization_id" field.
  31678. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  31679. m.organization_id = nil
  31680. m.addorganization_id = nil
  31681. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  31682. }
  31683. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31684. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  31685. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  31686. return ok
  31687. }
  31688. // ResetOrganizationID resets all changes to the "organization_id" field.
  31689. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  31690. m.organization_id = nil
  31691. m.addorganization_id = nil
  31692. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  31693. }
  31694. // SetAiResponse sets the "ai_response" field.
  31695. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  31696. m.ai_response = &u
  31697. m.addai_response = nil
  31698. }
  31699. // AiResponse returns the value of the "ai_response" field in the mutation.
  31700. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  31701. v := m.ai_response
  31702. if v == nil {
  31703. return
  31704. }
  31705. return *v, true
  31706. }
  31707. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  31708. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31710. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31711. if !m.op.Is(OpUpdateOne) {
  31712. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31713. }
  31714. if m.id == nil || m.oldValue == nil {
  31715. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31716. }
  31717. oldValue, err := m.oldValue(ctx)
  31718. if err != nil {
  31719. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31720. }
  31721. return oldValue.AiResponse, nil
  31722. }
  31723. // AddAiResponse adds u to the "ai_response" field.
  31724. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  31725. if m.addai_response != nil {
  31726. *m.addai_response += u
  31727. } else {
  31728. m.addai_response = &u
  31729. }
  31730. }
  31731. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31732. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  31733. v := m.addai_response
  31734. if v == nil {
  31735. return
  31736. }
  31737. return *v, true
  31738. }
  31739. // ResetAiResponse resets all changes to the "ai_response" field.
  31740. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  31741. m.ai_response = nil
  31742. m.addai_response = nil
  31743. }
  31744. // SetSopRun sets the "sop_run" field.
  31745. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  31746. m.sop_run = &u
  31747. m.addsop_run = nil
  31748. }
  31749. // SopRun returns the value of the "sop_run" field in the mutation.
  31750. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  31751. v := m.sop_run
  31752. if v == nil {
  31753. return
  31754. }
  31755. return *v, true
  31756. }
  31757. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  31758. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31760. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31761. if !m.op.Is(OpUpdateOne) {
  31762. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31763. }
  31764. if m.id == nil || m.oldValue == nil {
  31765. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31766. }
  31767. oldValue, err := m.oldValue(ctx)
  31768. if err != nil {
  31769. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31770. }
  31771. return oldValue.SopRun, nil
  31772. }
  31773. // AddSopRun adds u to the "sop_run" field.
  31774. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  31775. if m.addsop_run != nil {
  31776. *m.addsop_run += u
  31777. } else {
  31778. m.addsop_run = &u
  31779. }
  31780. }
  31781. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31782. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  31783. v := m.addsop_run
  31784. if v == nil {
  31785. return
  31786. }
  31787. return *v, true
  31788. }
  31789. // ResetSopRun resets all changes to the "sop_run" field.
  31790. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  31791. m.sop_run = nil
  31792. m.addsop_run = nil
  31793. }
  31794. // SetTotalFriend sets the "total_friend" field.
  31795. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  31796. m.total_friend = &u
  31797. m.addtotal_friend = nil
  31798. }
  31799. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31800. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  31801. v := m.total_friend
  31802. if v == nil {
  31803. return
  31804. }
  31805. return *v, true
  31806. }
  31807. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  31808. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31810. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31811. if !m.op.Is(OpUpdateOne) {
  31812. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31813. }
  31814. if m.id == nil || m.oldValue == nil {
  31815. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31816. }
  31817. oldValue, err := m.oldValue(ctx)
  31818. if err != nil {
  31819. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31820. }
  31821. return oldValue.TotalFriend, nil
  31822. }
  31823. // AddTotalFriend adds u to the "total_friend" field.
  31824. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  31825. if m.addtotal_friend != nil {
  31826. *m.addtotal_friend += u
  31827. } else {
  31828. m.addtotal_friend = &u
  31829. }
  31830. }
  31831. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31832. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  31833. v := m.addtotal_friend
  31834. if v == nil {
  31835. return
  31836. }
  31837. return *v, true
  31838. }
  31839. // ResetTotalFriend resets all changes to the "total_friend" field.
  31840. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  31841. m.total_friend = nil
  31842. m.addtotal_friend = nil
  31843. }
  31844. // SetTotalGroup sets the "total_group" field.
  31845. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  31846. m.total_group = &u
  31847. m.addtotal_group = nil
  31848. }
  31849. // TotalGroup returns the value of the "total_group" field in the mutation.
  31850. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  31851. v := m.total_group
  31852. if v == nil {
  31853. return
  31854. }
  31855. return *v, true
  31856. }
  31857. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  31858. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31860. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31861. if !m.op.Is(OpUpdateOne) {
  31862. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31863. }
  31864. if m.id == nil || m.oldValue == nil {
  31865. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31866. }
  31867. oldValue, err := m.oldValue(ctx)
  31868. if err != nil {
  31869. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31870. }
  31871. return oldValue.TotalGroup, nil
  31872. }
  31873. // AddTotalGroup adds u to the "total_group" field.
  31874. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  31875. if m.addtotal_group != nil {
  31876. *m.addtotal_group += u
  31877. } else {
  31878. m.addtotal_group = &u
  31879. }
  31880. }
  31881. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31882. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  31883. v := m.addtotal_group
  31884. if v == nil {
  31885. return
  31886. }
  31887. return *v, true
  31888. }
  31889. // ResetTotalGroup resets all changes to the "total_group" field.
  31890. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  31891. m.total_group = nil
  31892. m.addtotal_group = nil
  31893. }
  31894. // SetAccountBalance sets the "account_balance" field.
  31895. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  31896. m.account_balance = &u
  31897. m.addaccount_balance = nil
  31898. }
  31899. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31900. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  31901. v := m.account_balance
  31902. if v == nil {
  31903. return
  31904. }
  31905. return *v, true
  31906. }
  31907. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  31908. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31910. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31911. if !m.op.Is(OpUpdateOne) {
  31912. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31913. }
  31914. if m.id == nil || m.oldValue == nil {
  31915. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31916. }
  31917. oldValue, err := m.oldValue(ctx)
  31918. if err != nil {
  31919. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31920. }
  31921. return oldValue.AccountBalance, nil
  31922. }
  31923. // AddAccountBalance adds u to the "account_balance" field.
  31924. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  31925. if m.addaccount_balance != nil {
  31926. *m.addaccount_balance += u
  31927. } else {
  31928. m.addaccount_balance = &u
  31929. }
  31930. }
  31931. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31932. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  31933. v := m.addaccount_balance
  31934. if v == nil {
  31935. return
  31936. }
  31937. return *v, true
  31938. }
  31939. // ResetAccountBalance resets all changes to the "account_balance" field.
  31940. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  31941. m.account_balance = nil
  31942. m.addaccount_balance = nil
  31943. }
  31944. // SetConsumeToken sets the "consume_token" field.
  31945. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  31946. m.consume_token = &u
  31947. m.addconsume_token = nil
  31948. }
  31949. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31950. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  31951. v := m.consume_token
  31952. if v == nil {
  31953. return
  31954. }
  31955. return *v, true
  31956. }
  31957. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  31958. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31960. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31961. if !m.op.Is(OpUpdateOne) {
  31962. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31963. }
  31964. if m.id == nil || m.oldValue == nil {
  31965. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31966. }
  31967. oldValue, err := m.oldValue(ctx)
  31968. if err != nil {
  31969. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31970. }
  31971. return oldValue.ConsumeToken, nil
  31972. }
  31973. // AddConsumeToken adds u to the "consume_token" field.
  31974. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  31975. if m.addconsume_token != nil {
  31976. *m.addconsume_token += u
  31977. } else {
  31978. m.addconsume_token = &u
  31979. }
  31980. }
  31981. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31982. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  31983. v := m.addconsume_token
  31984. if v == nil {
  31985. return
  31986. }
  31987. return *v, true
  31988. }
  31989. // ResetConsumeToken resets all changes to the "consume_token" field.
  31990. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  31991. m.consume_token = nil
  31992. m.addconsume_token = nil
  31993. }
  31994. // SetActiveUser sets the "active_user" field.
  31995. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  31996. m.active_user = &u
  31997. m.addactive_user = nil
  31998. }
  31999. // ActiveUser returns the value of the "active_user" field in the mutation.
  32000. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  32001. v := m.active_user
  32002. if v == nil {
  32003. return
  32004. }
  32005. return *v, true
  32006. }
  32007. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  32008. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32010. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32011. if !m.op.Is(OpUpdateOne) {
  32012. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32013. }
  32014. if m.id == nil || m.oldValue == nil {
  32015. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32016. }
  32017. oldValue, err := m.oldValue(ctx)
  32018. if err != nil {
  32019. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32020. }
  32021. return oldValue.ActiveUser, nil
  32022. }
  32023. // AddActiveUser adds u to the "active_user" field.
  32024. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  32025. if m.addactive_user != nil {
  32026. *m.addactive_user += u
  32027. } else {
  32028. m.addactive_user = &u
  32029. }
  32030. }
  32031. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32032. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  32033. v := m.addactive_user
  32034. if v == nil {
  32035. return
  32036. }
  32037. return *v, true
  32038. }
  32039. // ResetActiveUser resets all changes to the "active_user" field.
  32040. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  32041. m.active_user = nil
  32042. m.addactive_user = nil
  32043. }
  32044. // SetNewUser sets the "new_user" field.
  32045. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  32046. m.new_user = &i
  32047. m.addnew_user = nil
  32048. }
  32049. // NewUser returns the value of the "new_user" field in the mutation.
  32050. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  32051. v := m.new_user
  32052. if v == nil {
  32053. return
  32054. }
  32055. return *v, true
  32056. }
  32057. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  32058. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32060. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32061. if !m.op.Is(OpUpdateOne) {
  32062. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32063. }
  32064. if m.id == nil || m.oldValue == nil {
  32065. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32066. }
  32067. oldValue, err := m.oldValue(ctx)
  32068. if err != nil {
  32069. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32070. }
  32071. return oldValue.NewUser, nil
  32072. }
  32073. // AddNewUser adds i to the "new_user" field.
  32074. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  32075. if m.addnew_user != nil {
  32076. *m.addnew_user += i
  32077. } else {
  32078. m.addnew_user = &i
  32079. }
  32080. }
  32081. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32082. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  32083. v := m.addnew_user
  32084. if v == nil {
  32085. return
  32086. }
  32087. return *v, true
  32088. }
  32089. // ResetNewUser resets all changes to the "new_user" field.
  32090. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  32091. m.new_user = nil
  32092. m.addnew_user = nil
  32093. }
  32094. // SetLabelDist sets the "label_dist" field.
  32095. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32096. m.label_dist = &ctd
  32097. m.appendlabel_dist = nil
  32098. }
  32099. // LabelDist returns the value of the "label_dist" field in the mutation.
  32100. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32101. v := m.label_dist
  32102. if v == nil {
  32103. return
  32104. }
  32105. return *v, true
  32106. }
  32107. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  32108. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32110. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32111. if !m.op.Is(OpUpdateOne) {
  32112. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32113. }
  32114. if m.id == nil || m.oldValue == nil {
  32115. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32116. }
  32117. oldValue, err := m.oldValue(ctx)
  32118. if err != nil {
  32119. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32120. }
  32121. return oldValue.LabelDist, nil
  32122. }
  32123. // AppendLabelDist adds ctd to the "label_dist" field.
  32124. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32125. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32126. }
  32127. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32128. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32129. if len(m.appendlabel_dist) == 0 {
  32130. return nil, false
  32131. }
  32132. return m.appendlabel_dist, true
  32133. }
  32134. // ResetLabelDist resets all changes to the "label_dist" field.
  32135. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  32136. m.label_dist = nil
  32137. m.appendlabel_dist = nil
  32138. }
  32139. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  32140. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  32141. m.predicates = append(m.predicates, ps...)
  32142. }
  32143. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  32144. // users can use type-assertion to append predicates that do not depend on any generated package.
  32145. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  32146. p := make([]predicate.UsageStatisticMonth, len(ps))
  32147. for i := range ps {
  32148. p[i] = ps[i]
  32149. }
  32150. m.Where(p...)
  32151. }
  32152. // Op returns the operation name.
  32153. func (m *UsageStatisticMonthMutation) Op() Op {
  32154. return m.op
  32155. }
  32156. // SetOp allows setting the mutation operation.
  32157. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  32158. m.op = op
  32159. }
  32160. // Type returns the node type of this mutation (UsageStatisticMonth).
  32161. func (m *UsageStatisticMonthMutation) Type() string {
  32162. return m.typ
  32163. }
  32164. // Fields returns all fields that were changed during this mutation. Note that in
  32165. // order to get all numeric fields that were incremented/decremented, call
  32166. // AddedFields().
  32167. func (m *UsageStatisticMonthMutation) Fields() []string {
  32168. fields := make([]string, 0, 17)
  32169. if m.created_at != nil {
  32170. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  32171. }
  32172. if m.updated_at != nil {
  32173. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  32174. }
  32175. if m.status != nil {
  32176. fields = append(fields, usagestatisticmonth.FieldStatus)
  32177. }
  32178. if m.deleted_at != nil {
  32179. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32180. }
  32181. if m.addtime != nil {
  32182. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32183. }
  32184. if m._type != nil {
  32185. fields = append(fields, usagestatisticmonth.FieldType)
  32186. }
  32187. if m.bot_id != nil {
  32188. fields = append(fields, usagestatisticmonth.FieldBotID)
  32189. }
  32190. if m.organization_id != nil {
  32191. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32192. }
  32193. if m.ai_response != nil {
  32194. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32195. }
  32196. if m.sop_run != nil {
  32197. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32198. }
  32199. if m.total_friend != nil {
  32200. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32201. }
  32202. if m.total_group != nil {
  32203. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32204. }
  32205. if m.account_balance != nil {
  32206. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32207. }
  32208. if m.consume_token != nil {
  32209. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32210. }
  32211. if m.active_user != nil {
  32212. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32213. }
  32214. if m.new_user != nil {
  32215. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32216. }
  32217. if m.label_dist != nil {
  32218. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  32219. }
  32220. return fields
  32221. }
  32222. // Field returns the value of a field with the given name. The second boolean
  32223. // return value indicates that this field was not set, or was not defined in the
  32224. // schema.
  32225. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  32226. switch name {
  32227. case usagestatisticmonth.FieldCreatedAt:
  32228. return m.CreatedAt()
  32229. case usagestatisticmonth.FieldUpdatedAt:
  32230. return m.UpdatedAt()
  32231. case usagestatisticmonth.FieldStatus:
  32232. return m.Status()
  32233. case usagestatisticmonth.FieldDeletedAt:
  32234. return m.DeletedAt()
  32235. case usagestatisticmonth.FieldAddtime:
  32236. return m.Addtime()
  32237. case usagestatisticmonth.FieldType:
  32238. return m.GetType()
  32239. case usagestatisticmonth.FieldBotID:
  32240. return m.BotID()
  32241. case usagestatisticmonth.FieldOrganizationID:
  32242. return m.OrganizationID()
  32243. case usagestatisticmonth.FieldAiResponse:
  32244. return m.AiResponse()
  32245. case usagestatisticmonth.FieldSopRun:
  32246. return m.SopRun()
  32247. case usagestatisticmonth.FieldTotalFriend:
  32248. return m.TotalFriend()
  32249. case usagestatisticmonth.FieldTotalGroup:
  32250. return m.TotalGroup()
  32251. case usagestatisticmonth.FieldAccountBalance:
  32252. return m.AccountBalance()
  32253. case usagestatisticmonth.FieldConsumeToken:
  32254. return m.ConsumeToken()
  32255. case usagestatisticmonth.FieldActiveUser:
  32256. return m.ActiveUser()
  32257. case usagestatisticmonth.FieldNewUser:
  32258. return m.NewUser()
  32259. case usagestatisticmonth.FieldLabelDist:
  32260. return m.LabelDist()
  32261. }
  32262. return nil, false
  32263. }
  32264. // OldField returns the old value of the field from the database. An error is
  32265. // returned if the mutation operation is not UpdateOne, or the query to the
  32266. // database failed.
  32267. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32268. switch name {
  32269. case usagestatisticmonth.FieldCreatedAt:
  32270. return m.OldCreatedAt(ctx)
  32271. case usagestatisticmonth.FieldUpdatedAt:
  32272. return m.OldUpdatedAt(ctx)
  32273. case usagestatisticmonth.FieldStatus:
  32274. return m.OldStatus(ctx)
  32275. case usagestatisticmonth.FieldDeletedAt:
  32276. return m.OldDeletedAt(ctx)
  32277. case usagestatisticmonth.FieldAddtime:
  32278. return m.OldAddtime(ctx)
  32279. case usagestatisticmonth.FieldType:
  32280. return m.OldType(ctx)
  32281. case usagestatisticmonth.FieldBotID:
  32282. return m.OldBotID(ctx)
  32283. case usagestatisticmonth.FieldOrganizationID:
  32284. return m.OldOrganizationID(ctx)
  32285. case usagestatisticmonth.FieldAiResponse:
  32286. return m.OldAiResponse(ctx)
  32287. case usagestatisticmonth.FieldSopRun:
  32288. return m.OldSopRun(ctx)
  32289. case usagestatisticmonth.FieldTotalFriend:
  32290. return m.OldTotalFriend(ctx)
  32291. case usagestatisticmonth.FieldTotalGroup:
  32292. return m.OldTotalGroup(ctx)
  32293. case usagestatisticmonth.FieldAccountBalance:
  32294. return m.OldAccountBalance(ctx)
  32295. case usagestatisticmonth.FieldConsumeToken:
  32296. return m.OldConsumeToken(ctx)
  32297. case usagestatisticmonth.FieldActiveUser:
  32298. return m.OldActiveUser(ctx)
  32299. case usagestatisticmonth.FieldNewUser:
  32300. return m.OldNewUser(ctx)
  32301. case usagestatisticmonth.FieldLabelDist:
  32302. return m.OldLabelDist(ctx)
  32303. }
  32304. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32305. }
  32306. // SetField sets the value of a field with the given name. It returns an error if
  32307. // the field is not defined in the schema, or if the type mismatched the field
  32308. // type.
  32309. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  32310. switch name {
  32311. case usagestatisticmonth.FieldCreatedAt:
  32312. v, ok := value.(time.Time)
  32313. if !ok {
  32314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32315. }
  32316. m.SetCreatedAt(v)
  32317. return nil
  32318. case usagestatisticmonth.FieldUpdatedAt:
  32319. v, ok := value.(time.Time)
  32320. if !ok {
  32321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32322. }
  32323. m.SetUpdatedAt(v)
  32324. return nil
  32325. case usagestatisticmonth.FieldStatus:
  32326. v, ok := value.(uint8)
  32327. if !ok {
  32328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32329. }
  32330. m.SetStatus(v)
  32331. return nil
  32332. case usagestatisticmonth.FieldDeletedAt:
  32333. v, ok := value.(time.Time)
  32334. if !ok {
  32335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32336. }
  32337. m.SetDeletedAt(v)
  32338. return nil
  32339. case usagestatisticmonth.FieldAddtime:
  32340. v, ok := value.(uint64)
  32341. if !ok {
  32342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32343. }
  32344. m.SetAddtime(v)
  32345. return nil
  32346. case usagestatisticmonth.FieldType:
  32347. v, ok := value.(int)
  32348. if !ok {
  32349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32350. }
  32351. m.SetType(v)
  32352. return nil
  32353. case usagestatisticmonth.FieldBotID:
  32354. v, ok := value.(string)
  32355. if !ok {
  32356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32357. }
  32358. m.SetBotID(v)
  32359. return nil
  32360. case usagestatisticmonth.FieldOrganizationID:
  32361. v, ok := value.(uint64)
  32362. if !ok {
  32363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32364. }
  32365. m.SetOrganizationID(v)
  32366. return nil
  32367. case usagestatisticmonth.FieldAiResponse:
  32368. v, ok := value.(uint64)
  32369. if !ok {
  32370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32371. }
  32372. m.SetAiResponse(v)
  32373. return nil
  32374. case usagestatisticmonth.FieldSopRun:
  32375. v, ok := value.(uint64)
  32376. if !ok {
  32377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32378. }
  32379. m.SetSopRun(v)
  32380. return nil
  32381. case usagestatisticmonth.FieldTotalFriend:
  32382. v, ok := value.(uint64)
  32383. if !ok {
  32384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32385. }
  32386. m.SetTotalFriend(v)
  32387. return nil
  32388. case usagestatisticmonth.FieldTotalGroup:
  32389. v, ok := value.(uint64)
  32390. if !ok {
  32391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32392. }
  32393. m.SetTotalGroup(v)
  32394. return nil
  32395. case usagestatisticmonth.FieldAccountBalance:
  32396. v, ok := value.(uint64)
  32397. if !ok {
  32398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32399. }
  32400. m.SetAccountBalance(v)
  32401. return nil
  32402. case usagestatisticmonth.FieldConsumeToken:
  32403. v, ok := value.(uint64)
  32404. if !ok {
  32405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32406. }
  32407. m.SetConsumeToken(v)
  32408. return nil
  32409. case usagestatisticmonth.FieldActiveUser:
  32410. v, ok := value.(uint64)
  32411. if !ok {
  32412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32413. }
  32414. m.SetActiveUser(v)
  32415. return nil
  32416. case usagestatisticmonth.FieldNewUser:
  32417. v, ok := value.(int64)
  32418. if !ok {
  32419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32420. }
  32421. m.SetNewUser(v)
  32422. return nil
  32423. case usagestatisticmonth.FieldLabelDist:
  32424. v, ok := value.([]custom_types.LabelDist)
  32425. if !ok {
  32426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32427. }
  32428. m.SetLabelDist(v)
  32429. return nil
  32430. }
  32431. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32432. }
  32433. // AddedFields returns all numeric fields that were incremented/decremented during
  32434. // this mutation.
  32435. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  32436. var fields []string
  32437. if m.addstatus != nil {
  32438. fields = append(fields, usagestatisticmonth.FieldStatus)
  32439. }
  32440. if m.addaddtime != nil {
  32441. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32442. }
  32443. if m.add_type != nil {
  32444. fields = append(fields, usagestatisticmonth.FieldType)
  32445. }
  32446. if m.addorganization_id != nil {
  32447. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32448. }
  32449. if m.addai_response != nil {
  32450. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32451. }
  32452. if m.addsop_run != nil {
  32453. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32454. }
  32455. if m.addtotal_friend != nil {
  32456. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32457. }
  32458. if m.addtotal_group != nil {
  32459. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32460. }
  32461. if m.addaccount_balance != nil {
  32462. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32463. }
  32464. if m.addconsume_token != nil {
  32465. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32466. }
  32467. if m.addactive_user != nil {
  32468. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32469. }
  32470. if m.addnew_user != nil {
  32471. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32472. }
  32473. return fields
  32474. }
  32475. // AddedField returns the numeric value that was incremented/decremented on a field
  32476. // with the given name. The second boolean return value indicates that this field
  32477. // was not set, or was not defined in the schema.
  32478. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  32479. switch name {
  32480. case usagestatisticmonth.FieldStatus:
  32481. return m.AddedStatus()
  32482. case usagestatisticmonth.FieldAddtime:
  32483. return m.AddedAddtime()
  32484. case usagestatisticmonth.FieldType:
  32485. return m.AddedType()
  32486. case usagestatisticmonth.FieldOrganizationID:
  32487. return m.AddedOrganizationID()
  32488. case usagestatisticmonth.FieldAiResponse:
  32489. return m.AddedAiResponse()
  32490. case usagestatisticmonth.FieldSopRun:
  32491. return m.AddedSopRun()
  32492. case usagestatisticmonth.FieldTotalFriend:
  32493. return m.AddedTotalFriend()
  32494. case usagestatisticmonth.FieldTotalGroup:
  32495. return m.AddedTotalGroup()
  32496. case usagestatisticmonth.FieldAccountBalance:
  32497. return m.AddedAccountBalance()
  32498. case usagestatisticmonth.FieldConsumeToken:
  32499. return m.AddedConsumeToken()
  32500. case usagestatisticmonth.FieldActiveUser:
  32501. return m.AddedActiveUser()
  32502. case usagestatisticmonth.FieldNewUser:
  32503. return m.AddedNewUser()
  32504. }
  32505. return nil, false
  32506. }
  32507. // AddField adds the value to the field with the given name. It returns an error if
  32508. // the field is not defined in the schema, or if the type mismatched the field
  32509. // type.
  32510. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  32511. switch name {
  32512. case usagestatisticmonth.FieldStatus:
  32513. v, ok := value.(int8)
  32514. if !ok {
  32515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32516. }
  32517. m.AddStatus(v)
  32518. return nil
  32519. case usagestatisticmonth.FieldAddtime:
  32520. v, ok := value.(int64)
  32521. if !ok {
  32522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32523. }
  32524. m.AddAddtime(v)
  32525. return nil
  32526. case usagestatisticmonth.FieldType:
  32527. v, ok := value.(int)
  32528. if !ok {
  32529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32530. }
  32531. m.AddType(v)
  32532. return nil
  32533. case usagestatisticmonth.FieldOrganizationID:
  32534. v, ok := value.(int64)
  32535. if !ok {
  32536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32537. }
  32538. m.AddOrganizationID(v)
  32539. return nil
  32540. case usagestatisticmonth.FieldAiResponse:
  32541. v, ok := value.(int64)
  32542. if !ok {
  32543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32544. }
  32545. m.AddAiResponse(v)
  32546. return nil
  32547. case usagestatisticmonth.FieldSopRun:
  32548. v, ok := value.(int64)
  32549. if !ok {
  32550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32551. }
  32552. m.AddSopRun(v)
  32553. return nil
  32554. case usagestatisticmonth.FieldTotalFriend:
  32555. v, ok := value.(int64)
  32556. if !ok {
  32557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32558. }
  32559. m.AddTotalFriend(v)
  32560. return nil
  32561. case usagestatisticmonth.FieldTotalGroup:
  32562. v, ok := value.(int64)
  32563. if !ok {
  32564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32565. }
  32566. m.AddTotalGroup(v)
  32567. return nil
  32568. case usagestatisticmonth.FieldAccountBalance:
  32569. v, ok := value.(int64)
  32570. if !ok {
  32571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32572. }
  32573. m.AddAccountBalance(v)
  32574. return nil
  32575. case usagestatisticmonth.FieldConsumeToken:
  32576. v, ok := value.(int64)
  32577. if !ok {
  32578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32579. }
  32580. m.AddConsumeToken(v)
  32581. return nil
  32582. case usagestatisticmonth.FieldActiveUser:
  32583. v, ok := value.(int64)
  32584. if !ok {
  32585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32586. }
  32587. m.AddActiveUser(v)
  32588. return nil
  32589. case usagestatisticmonth.FieldNewUser:
  32590. v, ok := value.(int64)
  32591. if !ok {
  32592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32593. }
  32594. m.AddNewUser(v)
  32595. return nil
  32596. }
  32597. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  32598. }
  32599. // ClearedFields returns all nullable fields that were cleared during this
  32600. // mutation.
  32601. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  32602. var fields []string
  32603. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  32604. fields = append(fields, usagestatisticmonth.FieldStatus)
  32605. }
  32606. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  32607. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32608. }
  32609. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  32610. fields = append(fields, usagestatisticmonth.FieldBotID)
  32611. }
  32612. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  32613. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32614. }
  32615. return fields
  32616. }
  32617. // FieldCleared returns a boolean indicating if a field with the given name was
  32618. // cleared in this mutation.
  32619. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  32620. _, ok := m.clearedFields[name]
  32621. return ok
  32622. }
  32623. // ClearField clears the value of the field with the given name. It returns an
  32624. // error if the field is not defined in the schema.
  32625. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  32626. switch name {
  32627. case usagestatisticmonth.FieldStatus:
  32628. m.ClearStatus()
  32629. return nil
  32630. case usagestatisticmonth.FieldDeletedAt:
  32631. m.ClearDeletedAt()
  32632. return nil
  32633. case usagestatisticmonth.FieldBotID:
  32634. m.ClearBotID()
  32635. return nil
  32636. case usagestatisticmonth.FieldOrganizationID:
  32637. m.ClearOrganizationID()
  32638. return nil
  32639. }
  32640. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  32641. }
  32642. // ResetField resets all changes in the mutation for the field with the given name.
  32643. // It returns an error if the field is not defined in the schema.
  32644. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  32645. switch name {
  32646. case usagestatisticmonth.FieldCreatedAt:
  32647. m.ResetCreatedAt()
  32648. return nil
  32649. case usagestatisticmonth.FieldUpdatedAt:
  32650. m.ResetUpdatedAt()
  32651. return nil
  32652. case usagestatisticmonth.FieldStatus:
  32653. m.ResetStatus()
  32654. return nil
  32655. case usagestatisticmonth.FieldDeletedAt:
  32656. m.ResetDeletedAt()
  32657. return nil
  32658. case usagestatisticmonth.FieldAddtime:
  32659. m.ResetAddtime()
  32660. return nil
  32661. case usagestatisticmonth.FieldType:
  32662. m.ResetType()
  32663. return nil
  32664. case usagestatisticmonth.FieldBotID:
  32665. m.ResetBotID()
  32666. return nil
  32667. case usagestatisticmonth.FieldOrganizationID:
  32668. m.ResetOrganizationID()
  32669. return nil
  32670. case usagestatisticmonth.FieldAiResponse:
  32671. m.ResetAiResponse()
  32672. return nil
  32673. case usagestatisticmonth.FieldSopRun:
  32674. m.ResetSopRun()
  32675. return nil
  32676. case usagestatisticmonth.FieldTotalFriend:
  32677. m.ResetTotalFriend()
  32678. return nil
  32679. case usagestatisticmonth.FieldTotalGroup:
  32680. m.ResetTotalGroup()
  32681. return nil
  32682. case usagestatisticmonth.FieldAccountBalance:
  32683. m.ResetAccountBalance()
  32684. return nil
  32685. case usagestatisticmonth.FieldConsumeToken:
  32686. m.ResetConsumeToken()
  32687. return nil
  32688. case usagestatisticmonth.FieldActiveUser:
  32689. m.ResetActiveUser()
  32690. return nil
  32691. case usagestatisticmonth.FieldNewUser:
  32692. m.ResetNewUser()
  32693. return nil
  32694. case usagestatisticmonth.FieldLabelDist:
  32695. m.ResetLabelDist()
  32696. return nil
  32697. }
  32698. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32699. }
  32700. // AddedEdges returns all edge names that were set/added in this mutation.
  32701. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  32702. edges := make([]string, 0, 0)
  32703. return edges
  32704. }
  32705. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32706. // name in this mutation.
  32707. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  32708. return nil
  32709. }
  32710. // RemovedEdges returns all edge names that were removed in this mutation.
  32711. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  32712. edges := make([]string, 0, 0)
  32713. return edges
  32714. }
  32715. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32716. // the given name in this mutation.
  32717. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  32718. return nil
  32719. }
  32720. // ClearedEdges returns all edge names that were cleared in this mutation.
  32721. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  32722. edges := make([]string, 0, 0)
  32723. return edges
  32724. }
  32725. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32726. // was cleared in this mutation.
  32727. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  32728. return false
  32729. }
  32730. // ClearEdge clears the value of the edge with the given name. It returns an error
  32731. // if that edge is not defined in the schema.
  32732. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  32733. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  32734. }
  32735. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32736. // It returns an error if the edge is not defined in the schema.
  32737. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  32738. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  32739. }
  32740. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  32741. type UsageTotalMutation struct {
  32742. config
  32743. op Op
  32744. typ string
  32745. id *uint64
  32746. created_at *time.Time
  32747. updated_at *time.Time
  32748. status *uint8
  32749. addstatus *int8
  32750. _type *int
  32751. add_type *int
  32752. bot_id *string
  32753. total_tokens *uint64
  32754. addtotal_tokens *int64
  32755. start_index *uint64
  32756. addstart_index *int64
  32757. end_index *uint64
  32758. addend_index *int64
  32759. organization_id *uint64
  32760. addorganization_id *int64
  32761. clearedFields map[string]struct{}
  32762. done bool
  32763. oldValue func(context.Context) (*UsageTotal, error)
  32764. predicates []predicate.UsageTotal
  32765. }
  32766. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  32767. // usagetotalOption allows management of the mutation configuration using functional options.
  32768. type usagetotalOption func(*UsageTotalMutation)
  32769. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  32770. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  32771. m := &UsageTotalMutation{
  32772. config: c,
  32773. op: op,
  32774. typ: TypeUsageTotal,
  32775. clearedFields: make(map[string]struct{}),
  32776. }
  32777. for _, opt := range opts {
  32778. opt(m)
  32779. }
  32780. return m
  32781. }
  32782. // withUsageTotalID sets the ID field of the mutation.
  32783. func withUsageTotalID(id uint64) usagetotalOption {
  32784. return func(m *UsageTotalMutation) {
  32785. var (
  32786. err error
  32787. once sync.Once
  32788. value *UsageTotal
  32789. )
  32790. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  32791. once.Do(func() {
  32792. if m.done {
  32793. err = errors.New("querying old values post mutation is not allowed")
  32794. } else {
  32795. value, err = m.Client().UsageTotal.Get(ctx, id)
  32796. }
  32797. })
  32798. return value, err
  32799. }
  32800. m.id = &id
  32801. }
  32802. }
  32803. // withUsageTotal sets the old UsageTotal of the mutation.
  32804. func withUsageTotal(node *UsageTotal) usagetotalOption {
  32805. return func(m *UsageTotalMutation) {
  32806. m.oldValue = func(context.Context) (*UsageTotal, error) {
  32807. return node, nil
  32808. }
  32809. m.id = &node.ID
  32810. }
  32811. }
  32812. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32813. // executed in a transaction (ent.Tx), a transactional client is returned.
  32814. func (m UsageTotalMutation) Client() *Client {
  32815. client := &Client{config: m.config}
  32816. client.init()
  32817. return client
  32818. }
  32819. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32820. // it returns an error otherwise.
  32821. func (m UsageTotalMutation) Tx() (*Tx, error) {
  32822. if _, ok := m.driver.(*txDriver); !ok {
  32823. return nil, errors.New("ent: mutation is not running in a transaction")
  32824. }
  32825. tx := &Tx{config: m.config}
  32826. tx.init()
  32827. return tx, nil
  32828. }
  32829. // SetID sets the value of the id field. Note that this
  32830. // operation is only accepted on creation of UsageTotal entities.
  32831. func (m *UsageTotalMutation) SetID(id uint64) {
  32832. m.id = &id
  32833. }
  32834. // ID returns the ID value in the mutation. Note that the ID is only available
  32835. // if it was provided to the builder or after it was returned from the database.
  32836. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  32837. if m.id == nil {
  32838. return
  32839. }
  32840. return *m.id, true
  32841. }
  32842. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32843. // That means, if the mutation is applied within a transaction with an isolation level such
  32844. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32845. // or updated by the mutation.
  32846. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  32847. switch {
  32848. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32849. id, exists := m.ID()
  32850. if exists {
  32851. return []uint64{id}, nil
  32852. }
  32853. fallthrough
  32854. case m.op.Is(OpUpdate | OpDelete):
  32855. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  32856. default:
  32857. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32858. }
  32859. }
  32860. // SetCreatedAt sets the "created_at" field.
  32861. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  32862. m.created_at = &t
  32863. }
  32864. // CreatedAt returns the value of the "created_at" field in the mutation.
  32865. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  32866. v := m.created_at
  32867. if v == nil {
  32868. return
  32869. }
  32870. return *v, true
  32871. }
  32872. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  32873. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32875. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32876. if !m.op.Is(OpUpdateOne) {
  32877. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32878. }
  32879. if m.id == nil || m.oldValue == nil {
  32880. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32881. }
  32882. oldValue, err := m.oldValue(ctx)
  32883. if err != nil {
  32884. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32885. }
  32886. return oldValue.CreatedAt, nil
  32887. }
  32888. // ResetCreatedAt resets all changes to the "created_at" field.
  32889. func (m *UsageTotalMutation) ResetCreatedAt() {
  32890. m.created_at = nil
  32891. }
  32892. // SetUpdatedAt sets the "updated_at" field.
  32893. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  32894. m.updated_at = &t
  32895. }
  32896. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32897. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  32898. v := m.updated_at
  32899. if v == nil {
  32900. return
  32901. }
  32902. return *v, true
  32903. }
  32904. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  32905. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32907. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32908. if !m.op.Is(OpUpdateOne) {
  32909. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32910. }
  32911. if m.id == nil || m.oldValue == nil {
  32912. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32913. }
  32914. oldValue, err := m.oldValue(ctx)
  32915. if err != nil {
  32916. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32917. }
  32918. return oldValue.UpdatedAt, nil
  32919. }
  32920. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32921. func (m *UsageTotalMutation) ResetUpdatedAt() {
  32922. m.updated_at = nil
  32923. }
  32924. // SetStatus sets the "status" field.
  32925. func (m *UsageTotalMutation) SetStatus(u uint8) {
  32926. m.status = &u
  32927. m.addstatus = nil
  32928. }
  32929. // Status returns the value of the "status" field in the mutation.
  32930. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  32931. v := m.status
  32932. if v == nil {
  32933. return
  32934. }
  32935. return *v, true
  32936. }
  32937. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  32938. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32940. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32941. if !m.op.Is(OpUpdateOne) {
  32942. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32943. }
  32944. if m.id == nil || m.oldValue == nil {
  32945. return v, errors.New("OldStatus requires an ID field in the mutation")
  32946. }
  32947. oldValue, err := m.oldValue(ctx)
  32948. if err != nil {
  32949. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32950. }
  32951. return oldValue.Status, nil
  32952. }
  32953. // AddStatus adds u to the "status" field.
  32954. func (m *UsageTotalMutation) AddStatus(u int8) {
  32955. if m.addstatus != nil {
  32956. *m.addstatus += u
  32957. } else {
  32958. m.addstatus = &u
  32959. }
  32960. }
  32961. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32962. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  32963. v := m.addstatus
  32964. if v == nil {
  32965. return
  32966. }
  32967. return *v, true
  32968. }
  32969. // ClearStatus clears the value of the "status" field.
  32970. func (m *UsageTotalMutation) ClearStatus() {
  32971. m.status = nil
  32972. m.addstatus = nil
  32973. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  32974. }
  32975. // StatusCleared returns if the "status" field was cleared in this mutation.
  32976. func (m *UsageTotalMutation) StatusCleared() bool {
  32977. _, ok := m.clearedFields[usagetotal.FieldStatus]
  32978. return ok
  32979. }
  32980. // ResetStatus resets all changes to the "status" field.
  32981. func (m *UsageTotalMutation) ResetStatus() {
  32982. m.status = nil
  32983. m.addstatus = nil
  32984. delete(m.clearedFields, usagetotal.FieldStatus)
  32985. }
  32986. // SetType sets the "type" field.
  32987. func (m *UsageTotalMutation) SetType(i int) {
  32988. m._type = &i
  32989. m.add_type = nil
  32990. }
  32991. // GetType returns the value of the "type" field in the mutation.
  32992. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  32993. v := m._type
  32994. if v == nil {
  32995. return
  32996. }
  32997. return *v, true
  32998. }
  32999. // OldType returns the old "type" field's value of the UsageTotal entity.
  33000. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33002. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  33003. if !m.op.Is(OpUpdateOne) {
  33004. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33005. }
  33006. if m.id == nil || m.oldValue == nil {
  33007. return v, errors.New("OldType requires an ID field in the mutation")
  33008. }
  33009. oldValue, err := m.oldValue(ctx)
  33010. if err != nil {
  33011. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33012. }
  33013. return oldValue.Type, nil
  33014. }
  33015. // AddType adds i to the "type" field.
  33016. func (m *UsageTotalMutation) AddType(i int) {
  33017. if m.add_type != nil {
  33018. *m.add_type += i
  33019. } else {
  33020. m.add_type = &i
  33021. }
  33022. }
  33023. // AddedType returns the value that was added to the "type" field in this mutation.
  33024. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  33025. v := m.add_type
  33026. if v == nil {
  33027. return
  33028. }
  33029. return *v, true
  33030. }
  33031. // ClearType clears the value of the "type" field.
  33032. func (m *UsageTotalMutation) ClearType() {
  33033. m._type = nil
  33034. m.add_type = nil
  33035. m.clearedFields[usagetotal.FieldType] = struct{}{}
  33036. }
  33037. // TypeCleared returns if the "type" field was cleared in this mutation.
  33038. func (m *UsageTotalMutation) TypeCleared() bool {
  33039. _, ok := m.clearedFields[usagetotal.FieldType]
  33040. return ok
  33041. }
  33042. // ResetType resets all changes to the "type" field.
  33043. func (m *UsageTotalMutation) ResetType() {
  33044. m._type = nil
  33045. m.add_type = nil
  33046. delete(m.clearedFields, usagetotal.FieldType)
  33047. }
  33048. // SetBotID sets the "bot_id" field.
  33049. func (m *UsageTotalMutation) SetBotID(s string) {
  33050. m.bot_id = &s
  33051. }
  33052. // BotID returns the value of the "bot_id" field in the mutation.
  33053. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  33054. v := m.bot_id
  33055. if v == nil {
  33056. return
  33057. }
  33058. return *v, true
  33059. }
  33060. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  33061. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33063. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  33064. if !m.op.Is(OpUpdateOne) {
  33065. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33066. }
  33067. if m.id == nil || m.oldValue == nil {
  33068. return v, errors.New("OldBotID requires an ID field in the mutation")
  33069. }
  33070. oldValue, err := m.oldValue(ctx)
  33071. if err != nil {
  33072. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33073. }
  33074. return oldValue.BotID, nil
  33075. }
  33076. // ResetBotID resets all changes to the "bot_id" field.
  33077. func (m *UsageTotalMutation) ResetBotID() {
  33078. m.bot_id = nil
  33079. }
  33080. // SetTotalTokens sets the "total_tokens" field.
  33081. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  33082. m.total_tokens = &u
  33083. m.addtotal_tokens = nil
  33084. }
  33085. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  33086. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  33087. v := m.total_tokens
  33088. if v == nil {
  33089. return
  33090. }
  33091. return *v, true
  33092. }
  33093. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  33094. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33096. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  33097. if !m.op.Is(OpUpdateOne) {
  33098. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  33099. }
  33100. if m.id == nil || m.oldValue == nil {
  33101. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  33102. }
  33103. oldValue, err := m.oldValue(ctx)
  33104. if err != nil {
  33105. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  33106. }
  33107. return oldValue.TotalTokens, nil
  33108. }
  33109. // AddTotalTokens adds u to the "total_tokens" field.
  33110. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  33111. if m.addtotal_tokens != nil {
  33112. *m.addtotal_tokens += u
  33113. } else {
  33114. m.addtotal_tokens = &u
  33115. }
  33116. }
  33117. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  33118. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  33119. v := m.addtotal_tokens
  33120. if v == nil {
  33121. return
  33122. }
  33123. return *v, true
  33124. }
  33125. // ClearTotalTokens clears the value of the "total_tokens" field.
  33126. func (m *UsageTotalMutation) ClearTotalTokens() {
  33127. m.total_tokens = nil
  33128. m.addtotal_tokens = nil
  33129. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  33130. }
  33131. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33132. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  33133. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  33134. return ok
  33135. }
  33136. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33137. func (m *UsageTotalMutation) ResetTotalTokens() {
  33138. m.total_tokens = nil
  33139. m.addtotal_tokens = nil
  33140. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  33141. }
  33142. // SetStartIndex sets the "start_index" field.
  33143. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  33144. m.start_index = &u
  33145. m.addstart_index = nil
  33146. }
  33147. // StartIndex returns the value of the "start_index" field in the mutation.
  33148. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  33149. v := m.start_index
  33150. if v == nil {
  33151. return
  33152. }
  33153. return *v, true
  33154. }
  33155. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  33156. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33158. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  33159. if !m.op.Is(OpUpdateOne) {
  33160. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  33161. }
  33162. if m.id == nil || m.oldValue == nil {
  33163. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  33164. }
  33165. oldValue, err := m.oldValue(ctx)
  33166. if err != nil {
  33167. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  33168. }
  33169. return oldValue.StartIndex, nil
  33170. }
  33171. // AddStartIndex adds u to the "start_index" field.
  33172. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  33173. if m.addstart_index != nil {
  33174. *m.addstart_index += u
  33175. } else {
  33176. m.addstart_index = &u
  33177. }
  33178. }
  33179. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  33180. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  33181. v := m.addstart_index
  33182. if v == nil {
  33183. return
  33184. }
  33185. return *v, true
  33186. }
  33187. // ClearStartIndex clears the value of the "start_index" field.
  33188. func (m *UsageTotalMutation) ClearStartIndex() {
  33189. m.start_index = nil
  33190. m.addstart_index = nil
  33191. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  33192. }
  33193. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  33194. func (m *UsageTotalMutation) StartIndexCleared() bool {
  33195. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  33196. return ok
  33197. }
  33198. // ResetStartIndex resets all changes to the "start_index" field.
  33199. func (m *UsageTotalMutation) ResetStartIndex() {
  33200. m.start_index = nil
  33201. m.addstart_index = nil
  33202. delete(m.clearedFields, usagetotal.FieldStartIndex)
  33203. }
  33204. // SetEndIndex sets the "end_index" field.
  33205. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  33206. m.end_index = &u
  33207. m.addend_index = nil
  33208. }
  33209. // EndIndex returns the value of the "end_index" field in the mutation.
  33210. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  33211. v := m.end_index
  33212. if v == nil {
  33213. return
  33214. }
  33215. return *v, true
  33216. }
  33217. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  33218. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33220. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  33221. if !m.op.Is(OpUpdateOne) {
  33222. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  33223. }
  33224. if m.id == nil || m.oldValue == nil {
  33225. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  33226. }
  33227. oldValue, err := m.oldValue(ctx)
  33228. if err != nil {
  33229. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  33230. }
  33231. return oldValue.EndIndex, nil
  33232. }
  33233. // AddEndIndex adds u to the "end_index" field.
  33234. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  33235. if m.addend_index != nil {
  33236. *m.addend_index += u
  33237. } else {
  33238. m.addend_index = &u
  33239. }
  33240. }
  33241. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  33242. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  33243. v := m.addend_index
  33244. if v == nil {
  33245. return
  33246. }
  33247. return *v, true
  33248. }
  33249. // ClearEndIndex clears the value of the "end_index" field.
  33250. func (m *UsageTotalMutation) ClearEndIndex() {
  33251. m.end_index = nil
  33252. m.addend_index = nil
  33253. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  33254. }
  33255. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  33256. func (m *UsageTotalMutation) EndIndexCleared() bool {
  33257. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  33258. return ok
  33259. }
  33260. // ResetEndIndex resets all changes to the "end_index" field.
  33261. func (m *UsageTotalMutation) ResetEndIndex() {
  33262. m.end_index = nil
  33263. m.addend_index = nil
  33264. delete(m.clearedFields, usagetotal.FieldEndIndex)
  33265. }
  33266. // SetOrganizationID sets the "organization_id" field.
  33267. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  33268. m.organization_id = &u
  33269. m.addorganization_id = nil
  33270. }
  33271. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33272. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  33273. v := m.organization_id
  33274. if v == nil {
  33275. return
  33276. }
  33277. return *v, true
  33278. }
  33279. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  33280. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33282. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33283. if !m.op.Is(OpUpdateOne) {
  33284. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33285. }
  33286. if m.id == nil || m.oldValue == nil {
  33287. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33288. }
  33289. oldValue, err := m.oldValue(ctx)
  33290. if err != nil {
  33291. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33292. }
  33293. return oldValue.OrganizationID, nil
  33294. }
  33295. // AddOrganizationID adds u to the "organization_id" field.
  33296. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  33297. if m.addorganization_id != nil {
  33298. *m.addorganization_id += u
  33299. } else {
  33300. m.addorganization_id = &u
  33301. }
  33302. }
  33303. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33304. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  33305. v := m.addorganization_id
  33306. if v == nil {
  33307. return
  33308. }
  33309. return *v, true
  33310. }
  33311. // ClearOrganizationID clears the value of the "organization_id" field.
  33312. func (m *UsageTotalMutation) ClearOrganizationID() {
  33313. m.organization_id = nil
  33314. m.addorganization_id = nil
  33315. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  33316. }
  33317. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33318. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  33319. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  33320. return ok
  33321. }
  33322. // ResetOrganizationID resets all changes to the "organization_id" field.
  33323. func (m *UsageTotalMutation) ResetOrganizationID() {
  33324. m.organization_id = nil
  33325. m.addorganization_id = nil
  33326. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  33327. }
  33328. // Where appends a list predicates to the UsageTotalMutation builder.
  33329. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  33330. m.predicates = append(m.predicates, ps...)
  33331. }
  33332. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  33333. // users can use type-assertion to append predicates that do not depend on any generated package.
  33334. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  33335. p := make([]predicate.UsageTotal, len(ps))
  33336. for i := range ps {
  33337. p[i] = ps[i]
  33338. }
  33339. m.Where(p...)
  33340. }
  33341. // Op returns the operation name.
  33342. func (m *UsageTotalMutation) Op() Op {
  33343. return m.op
  33344. }
  33345. // SetOp allows setting the mutation operation.
  33346. func (m *UsageTotalMutation) SetOp(op Op) {
  33347. m.op = op
  33348. }
  33349. // Type returns the node type of this mutation (UsageTotal).
  33350. func (m *UsageTotalMutation) Type() string {
  33351. return m.typ
  33352. }
  33353. // Fields returns all fields that were changed during this mutation. Note that in
  33354. // order to get all numeric fields that were incremented/decremented, call
  33355. // AddedFields().
  33356. func (m *UsageTotalMutation) Fields() []string {
  33357. fields := make([]string, 0, 9)
  33358. if m.created_at != nil {
  33359. fields = append(fields, usagetotal.FieldCreatedAt)
  33360. }
  33361. if m.updated_at != nil {
  33362. fields = append(fields, usagetotal.FieldUpdatedAt)
  33363. }
  33364. if m.status != nil {
  33365. fields = append(fields, usagetotal.FieldStatus)
  33366. }
  33367. if m._type != nil {
  33368. fields = append(fields, usagetotal.FieldType)
  33369. }
  33370. if m.bot_id != nil {
  33371. fields = append(fields, usagetotal.FieldBotID)
  33372. }
  33373. if m.total_tokens != nil {
  33374. fields = append(fields, usagetotal.FieldTotalTokens)
  33375. }
  33376. if m.start_index != nil {
  33377. fields = append(fields, usagetotal.FieldStartIndex)
  33378. }
  33379. if m.end_index != nil {
  33380. fields = append(fields, usagetotal.FieldEndIndex)
  33381. }
  33382. if m.organization_id != nil {
  33383. fields = append(fields, usagetotal.FieldOrganizationID)
  33384. }
  33385. return fields
  33386. }
  33387. // Field returns the value of a field with the given name. The second boolean
  33388. // return value indicates that this field was not set, or was not defined in the
  33389. // schema.
  33390. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  33391. switch name {
  33392. case usagetotal.FieldCreatedAt:
  33393. return m.CreatedAt()
  33394. case usagetotal.FieldUpdatedAt:
  33395. return m.UpdatedAt()
  33396. case usagetotal.FieldStatus:
  33397. return m.Status()
  33398. case usagetotal.FieldType:
  33399. return m.GetType()
  33400. case usagetotal.FieldBotID:
  33401. return m.BotID()
  33402. case usagetotal.FieldTotalTokens:
  33403. return m.TotalTokens()
  33404. case usagetotal.FieldStartIndex:
  33405. return m.StartIndex()
  33406. case usagetotal.FieldEndIndex:
  33407. return m.EndIndex()
  33408. case usagetotal.FieldOrganizationID:
  33409. return m.OrganizationID()
  33410. }
  33411. return nil, false
  33412. }
  33413. // OldField returns the old value of the field from the database. An error is
  33414. // returned if the mutation operation is not UpdateOne, or the query to the
  33415. // database failed.
  33416. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33417. switch name {
  33418. case usagetotal.FieldCreatedAt:
  33419. return m.OldCreatedAt(ctx)
  33420. case usagetotal.FieldUpdatedAt:
  33421. return m.OldUpdatedAt(ctx)
  33422. case usagetotal.FieldStatus:
  33423. return m.OldStatus(ctx)
  33424. case usagetotal.FieldType:
  33425. return m.OldType(ctx)
  33426. case usagetotal.FieldBotID:
  33427. return m.OldBotID(ctx)
  33428. case usagetotal.FieldTotalTokens:
  33429. return m.OldTotalTokens(ctx)
  33430. case usagetotal.FieldStartIndex:
  33431. return m.OldStartIndex(ctx)
  33432. case usagetotal.FieldEndIndex:
  33433. return m.OldEndIndex(ctx)
  33434. case usagetotal.FieldOrganizationID:
  33435. return m.OldOrganizationID(ctx)
  33436. }
  33437. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  33438. }
  33439. // SetField sets the value of a field with the given name. It returns an error if
  33440. // the field is not defined in the schema, or if the type mismatched the field
  33441. // type.
  33442. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  33443. switch name {
  33444. case usagetotal.FieldCreatedAt:
  33445. v, ok := value.(time.Time)
  33446. if !ok {
  33447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33448. }
  33449. m.SetCreatedAt(v)
  33450. return nil
  33451. case usagetotal.FieldUpdatedAt:
  33452. v, ok := value.(time.Time)
  33453. if !ok {
  33454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33455. }
  33456. m.SetUpdatedAt(v)
  33457. return nil
  33458. case usagetotal.FieldStatus:
  33459. v, ok := value.(uint8)
  33460. if !ok {
  33461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33462. }
  33463. m.SetStatus(v)
  33464. return nil
  33465. case usagetotal.FieldType:
  33466. v, ok := value.(int)
  33467. if !ok {
  33468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33469. }
  33470. m.SetType(v)
  33471. return nil
  33472. case usagetotal.FieldBotID:
  33473. v, ok := value.(string)
  33474. if !ok {
  33475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33476. }
  33477. m.SetBotID(v)
  33478. return nil
  33479. case usagetotal.FieldTotalTokens:
  33480. v, ok := value.(uint64)
  33481. if !ok {
  33482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33483. }
  33484. m.SetTotalTokens(v)
  33485. return nil
  33486. case usagetotal.FieldStartIndex:
  33487. v, ok := value.(uint64)
  33488. if !ok {
  33489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33490. }
  33491. m.SetStartIndex(v)
  33492. return nil
  33493. case usagetotal.FieldEndIndex:
  33494. v, ok := value.(uint64)
  33495. if !ok {
  33496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33497. }
  33498. m.SetEndIndex(v)
  33499. return nil
  33500. case usagetotal.FieldOrganizationID:
  33501. v, ok := value.(uint64)
  33502. if !ok {
  33503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33504. }
  33505. m.SetOrganizationID(v)
  33506. return nil
  33507. }
  33508. return fmt.Errorf("unknown UsageTotal field %s", name)
  33509. }
  33510. // AddedFields returns all numeric fields that were incremented/decremented during
  33511. // this mutation.
  33512. func (m *UsageTotalMutation) AddedFields() []string {
  33513. var fields []string
  33514. if m.addstatus != nil {
  33515. fields = append(fields, usagetotal.FieldStatus)
  33516. }
  33517. if m.add_type != nil {
  33518. fields = append(fields, usagetotal.FieldType)
  33519. }
  33520. if m.addtotal_tokens != nil {
  33521. fields = append(fields, usagetotal.FieldTotalTokens)
  33522. }
  33523. if m.addstart_index != nil {
  33524. fields = append(fields, usagetotal.FieldStartIndex)
  33525. }
  33526. if m.addend_index != nil {
  33527. fields = append(fields, usagetotal.FieldEndIndex)
  33528. }
  33529. if m.addorganization_id != nil {
  33530. fields = append(fields, usagetotal.FieldOrganizationID)
  33531. }
  33532. return fields
  33533. }
  33534. // AddedField returns the numeric value that was incremented/decremented on a field
  33535. // with the given name. The second boolean return value indicates that this field
  33536. // was not set, or was not defined in the schema.
  33537. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  33538. switch name {
  33539. case usagetotal.FieldStatus:
  33540. return m.AddedStatus()
  33541. case usagetotal.FieldType:
  33542. return m.AddedType()
  33543. case usagetotal.FieldTotalTokens:
  33544. return m.AddedTotalTokens()
  33545. case usagetotal.FieldStartIndex:
  33546. return m.AddedStartIndex()
  33547. case usagetotal.FieldEndIndex:
  33548. return m.AddedEndIndex()
  33549. case usagetotal.FieldOrganizationID:
  33550. return m.AddedOrganizationID()
  33551. }
  33552. return nil, false
  33553. }
  33554. // AddField adds the value to the field with the given name. It returns an error if
  33555. // the field is not defined in the schema, or if the type mismatched the field
  33556. // type.
  33557. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  33558. switch name {
  33559. case usagetotal.FieldStatus:
  33560. v, ok := value.(int8)
  33561. if !ok {
  33562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33563. }
  33564. m.AddStatus(v)
  33565. return nil
  33566. case usagetotal.FieldType:
  33567. v, ok := value.(int)
  33568. if !ok {
  33569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33570. }
  33571. m.AddType(v)
  33572. return nil
  33573. case usagetotal.FieldTotalTokens:
  33574. v, ok := value.(int64)
  33575. if !ok {
  33576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33577. }
  33578. m.AddTotalTokens(v)
  33579. return nil
  33580. case usagetotal.FieldStartIndex:
  33581. v, ok := value.(int64)
  33582. if !ok {
  33583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33584. }
  33585. m.AddStartIndex(v)
  33586. return nil
  33587. case usagetotal.FieldEndIndex:
  33588. v, ok := value.(int64)
  33589. if !ok {
  33590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33591. }
  33592. m.AddEndIndex(v)
  33593. return nil
  33594. case usagetotal.FieldOrganizationID:
  33595. v, ok := value.(int64)
  33596. if !ok {
  33597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33598. }
  33599. m.AddOrganizationID(v)
  33600. return nil
  33601. }
  33602. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  33603. }
  33604. // ClearedFields returns all nullable fields that were cleared during this
  33605. // mutation.
  33606. func (m *UsageTotalMutation) ClearedFields() []string {
  33607. var fields []string
  33608. if m.FieldCleared(usagetotal.FieldStatus) {
  33609. fields = append(fields, usagetotal.FieldStatus)
  33610. }
  33611. if m.FieldCleared(usagetotal.FieldType) {
  33612. fields = append(fields, usagetotal.FieldType)
  33613. }
  33614. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  33615. fields = append(fields, usagetotal.FieldTotalTokens)
  33616. }
  33617. if m.FieldCleared(usagetotal.FieldStartIndex) {
  33618. fields = append(fields, usagetotal.FieldStartIndex)
  33619. }
  33620. if m.FieldCleared(usagetotal.FieldEndIndex) {
  33621. fields = append(fields, usagetotal.FieldEndIndex)
  33622. }
  33623. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  33624. fields = append(fields, usagetotal.FieldOrganizationID)
  33625. }
  33626. return fields
  33627. }
  33628. // FieldCleared returns a boolean indicating if a field with the given name was
  33629. // cleared in this mutation.
  33630. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  33631. _, ok := m.clearedFields[name]
  33632. return ok
  33633. }
  33634. // ClearField clears the value of the field with the given name. It returns an
  33635. // error if the field is not defined in the schema.
  33636. func (m *UsageTotalMutation) ClearField(name string) error {
  33637. switch name {
  33638. case usagetotal.FieldStatus:
  33639. m.ClearStatus()
  33640. return nil
  33641. case usagetotal.FieldType:
  33642. m.ClearType()
  33643. return nil
  33644. case usagetotal.FieldTotalTokens:
  33645. m.ClearTotalTokens()
  33646. return nil
  33647. case usagetotal.FieldStartIndex:
  33648. m.ClearStartIndex()
  33649. return nil
  33650. case usagetotal.FieldEndIndex:
  33651. m.ClearEndIndex()
  33652. return nil
  33653. case usagetotal.FieldOrganizationID:
  33654. m.ClearOrganizationID()
  33655. return nil
  33656. }
  33657. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  33658. }
  33659. // ResetField resets all changes in the mutation for the field with the given name.
  33660. // It returns an error if the field is not defined in the schema.
  33661. func (m *UsageTotalMutation) ResetField(name string) error {
  33662. switch name {
  33663. case usagetotal.FieldCreatedAt:
  33664. m.ResetCreatedAt()
  33665. return nil
  33666. case usagetotal.FieldUpdatedAt:
  33667. m.ResetUpdatedAt()
  33668. return nil
  33669. case usagetotal.FieldStatus:
  33670. m.ResetStatus()
  33671. return nil
  33672. case usagetotal.FieldType:
  33673. m.ResetType()
  33674. return nil
  33675. case usagetotal.FieldBotID:
  33676. m.ResetBotID()
  33677. return nil
  33678. case usagetotal.FieldTotalTokens:
  33679. m.ResetTotalTokens()
  33680. return nil
  33681. case usagetotal.FieldStartIndex:
  33682. m.ResetStartIndex()
  33683. return nil
  33684. case usagetotal.FieldEndIndex:
  33685. m.ResetEndIndex()
  33686. return nil
  33687. case usagetotal.FieldOrganizationID:
  33688. m.ResetOrganizationID()
  33689. return nil
  33690. }
  33691. return fmt.Errorf("unknown UsageTotal field %s", name)
  33692. }
  33693. // AddedEdges returns all edge names that were set/added in this mutation.
  33694. func (m *UsageTotalMutation) AddedEdges() []string {
  33695. edges := make([]string, 0, 0)
  33696. return edges
  33697. }
  33698. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33699. // name in this mutation.
  33700. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  33701. return nil
  33702. }
  33703. // RemovedEdges returns all edge names that were removed in this mutation.
  33704. func (m *UsageTotalMutation) RemovedEdges() []string {
  33705. edges := make([]string, 0, 0)
  33706. return edges
  33707. }
  33708. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33709. // the given name in this mutation.
  33710. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  33711. return nil
  33712. }
  33713. // ClearedEdges returns all edge names that were cleared in this mutation.
  33714. func (m *UsageTotalMutation) ClearedEdges() []string {
  33715. edges := make([]string, 0, 0)
  33716. return edges
  33717. }
  33718. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33719. // was cleared in this mutation.
  33720. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  33721. return false
  33722. }
  33723. // ClearEdge clears the value of the edge with the given name. It returns an error
  33724. // if that edge is not defined in the schema.
  33725. func (m *UsageTotalMutation) ClearEdge(name string) error {
  33726. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  33727. }
  33728. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33729. // It returns an error if the edge is not defined in the schema.
  33730. func (m *UsageTotalMutation) ResetEdge(name string) error {
  33731. return fmt.Errorf("unknown UsageTotal edge %s", name)
  33732. }
  33733. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  33734. type WhatsappMutation struct {
  33735. config
  33736. op Op
  33737. typ string
  33738. id *uint64
  33739. created_at *time.Time
  33740. updated_at *time.Time
  33741. status *uint8
  33742. addstatus *int8
  33743. deleted_at *time.Time
  33744. wa_id *string
  33745. wa_name *string
  33746. callback *string
  33747. account *string
  33748. cc *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(s string) {
  34037. m.wa_id = &s
  34038. }
  34039. // WaID returns the value of the "wa_id" field in the mutation.
  34040. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  34041. v := m.wa_id
  34042. if v == nil {
  34043. return
  34044. }
  34045. return *v, true
  34046. }
  34047. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  34048. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34050. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  34051. if !m.op.Is(OpUpdateOne) {
  34052. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  34053. }
  34054. if m.id == nil || m.oldValue == nil {
  34055. return v, errors.New("OldWaID requires an ID field in the mutation")
  34056. }
  34057. oldValue, err := m.oldValue(ctx)
  34058. if err != nil {
  34059. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  34060. }
  34061. return oldValue.WaID, nil
  34062. }
  34063. // ClearWaID clears the value of the "wa_id" field.
  34064. func (m *WhatsappMutation) ClearWaID() {
  34065. m.wa_id = nil
  34066. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  34067. }
  34068. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  34069. func (m *WhatsappMutation) WaIDCleared() bool {
  34070. _, ok := m.clearedFields[whatsapp.FieldWaID]
  34071. return ok
  34072. }
  34073. // ResetWaID resets all changes to the "wa_id" field.
  34074. func (m *WhatsappMutation) ResetWaID() {
  34075. m.wa_id = nil
  34076. delete(m.clearedFields, whatsapp.FieldWaID)
  34077. }
  34078. // SetWaName sets the "wa_name" field.
  34079. func (m *WhatsappMutation) SetWaName(s string) {
  34080. m.wa_name = &s
  34081. }
  34082. // WaName returns the value of the "wa_name" field in the mutation.
  34083. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  34084. v := m.wa_name
  34085. if v == nil {
  34086. return
  34087. }
  34088. return *v, true
  34089. }
  34090. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  34091. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34093. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  34094. if !m.op.Is(OpUpdateOne) {
  34095. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  34096. }
  34097. if m.id == nil || m.oldValue == nil {
  34098. return v, errors.New("OldWaName requires an ID field in the mutation")
  34099. }
  34100. oldValue, err := m.oldValue(ctx)
  34101. if err != nil {
  34102. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  34103. }
  34104. return oldValue.WaName, nil
  34105. }
  34106. // ClearWaName clears the value of the "wa_name" field.
  34107. func (m *WhatsappMutation) ClearWaName() {
  34108. m.wa_name = nil
  34109. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  34110. }
  34111. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  34112. func (m *WhatsappMutation) WaNameCleared() bool {
  34113. _, ok := m.clearedFields[whatsapp.FieldWaName]
  34114. return ok
  34115. }
  34116. // ResetWaName resets all changes to the "wa_name" field.
  34117. func (m *WhatsappMutation) ResetWaName() {
  34118. m.wa_name = nil
  34119. delete(m.clearedFields, whatsapp.FieldWaName)
  34120. }
  34121. // SetCallback sets the "callback" field.
  34122. func (m *WhatsappMutation) SetCallback(s string) {
  34123. m.callback = &s
  34124. }
  34125. // Callback returns the value of the "callback" field in the mutation.
  34126. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  34127. v := m.callback
  34128. if v == nil {
  34129. return
  34130. }
  34131. return *v, true
  34132. }
  34133. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  34134. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34136. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  34137. if !m.op.Is(OpUpdateOne) {
  34138. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  34139. }
  34140. if m.id == nil || m.oldValue == nil {
  34141. return v, errors.New("OldCallback requires an ID field in the mutation")
  34142. }
  34143. oldValue, err := m.oldValue(ctx)
  34144. if err != nil {
  34145. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  34146. }
  34147. return oldValue.Callback, nil
  34148. }
  34149. // ClearCallback clears the value of the "callback" field.
  34150. func (m *WhatsappMutation) ClearCallback() {
  34151. m.callback = nil
  34152. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  34153. }
  34154. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  34155. func (m *WhatsappMutation) CallbackCleared() bool {
  34156. _, ok := m.clearedFields[whatsapp.FieldCallback]
  34157. return ok
  34158. }
  34159. // ResetCallback resets all changes to the "callback" field.
  34160. func (m *WhatsappMutation) ResetCallback() {
  34161. m.callback = nil
  34162. delete(m.clearedFields, whatsapp.FieldCallback)
  34163. }
  34164. // SetAgentID sets the "agent_id" field.
  34165. func (m *WhatsappMutation) SetAgentID(u uint64) {
  34166. m.agent = &u
  34167. }
  34168. // AgentID returns the value of the "agent_id" field in the mutation.
  34169. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  34170. v := m.agent
  34171. if v == nil {
  34172. return
  34173. }
  34174. return *v, true
  34175. }
  34176. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  34177. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34178. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34179. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  34180. if !m.op.Is(OpUpdateOne) {
  34181. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  34182. }
  34183. if m.id == nil || m.oldValue == nil {
  34184. return v, errors.New("OldAgentID requires an ID field in the mutation")
  34185. }
  34186. oldValue, err := m.oldValue(ctx)
  34187. if err != nil {
  34188. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  34189. }
  34190. return oldValue.AgentID, nil
  34191. }
  34192. // ResetAgentID resets all changes to the "agent_id" field.
  34193. func (m *WhatsappMutation) ResetAgentID() {
  34194. m.agent = nil
  34195. }
  34196. // SetAccount sets the "account" field.
  34197. func (m *WhatsappMutation) SetAccount(s string) {
  34198. m.account = &s
  34199. }
  34200. // Account returns the value of the "account" field in the mutation.
  34201. func (m *WhatsappMutation) Account() (r string, exists bool) {
  34202. v := m.account
  34203. if v == nil {
  34204. return
  34205. }
  34206. return *v, true
  34207. }
  34208. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  34209. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34211. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  34212. if !m.op.Is(OpUpdateOne) {
  34213. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  34214. }
  34215. if m.id == nil || m.oldValue == nil {
  34216. return v, errors.New("OldAccount requires an ID field in the mutation")
  34217. }
  34218. oldValue, err := m.oldValue(ctx)
  34219. if err != nil {
  34220. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  34221. }
  34222. return oldValue.Account, nil
  34223. }
  34224. // ClearAccount clears the value of the "account" field.
  34225. func (m *WhatsappMutation) ClearAccount() {
  34226. m.account = nil
  34227. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  34228. }
  34229. // AccountCleared returns if the "account" field was cleared in this mutation.
  34230. func (m *WhatsappMutation) AccountCleared() bool {
  34231. _, ok := m.clearedFields[whatsapp.FieldAccount]
  34232. return ok
  34233. }
  34234. // ResetAccount resets all changes to the "account" field.
  34235. func (m *WhatsappMutation) ResetAccount() {
  34236. m.account = nil
  34237. delete(m.clearedFields, whatsapp.FieldAccount)
  34238. }
  34239. // SetCc sets the "cc" field.
  34240. func (m *WhatsappMutation) SetCc(s string) {
  34241. m.cc = &s
  34242. }
  34243. // Cc returns the value of the "cc" field in the mutation.
  34244. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  34245. v := m.cc
  34246. if v == nil {
  34247. return
  34248. }
  34249. return *v, true
  34250. }
  34251. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  34252. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34254. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  34255. if !m.op.Is(OpUpdateOne) {
  34256. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  34257. }
  34258. if m.id == nil || m.oldValue == nil {
  34259. return v, errors.New("OldCc requires an ID field in the mutation")
  34260. }
  34261. oldValue, err := m.oldValue(ctx)
  34262. if err != nil {
  34263. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  34264. }
  34265. return oldValue.Cc, nil
  34266. }
  34267. // ResetCc resets all changes to the "cc" field.
  34268. func (m *WhatsappMutation) ResetCc() {
  34269. m.cc = nil
  34270. }
  34271. // SetPhone sets the "phone" field.
  34272. func (m *WhatsappMutation) SetPhone(s string) {
  34273. m.phone = &s
  34274. }
  34275. // Phone returns the value of the "phone" field in the mutation.
  34276. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  34277. v := m.phone
  34278. if v == nil {
  34279. return
  34280. }
  34281. return *v, true
  34282. }
  34283. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  34284. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34286. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  34287. if !m.op.Is(OpUpdateOne) {
  34288. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  34289. }
  34290. if m.id == nil || m.oldValue == nil {
  34291. return v, errors.New("OldPhone requires an ID field in the mutation")
  34292. }
  34293. oldValue, err := m.oldValue(ctx)
  34294. if err != nil {
  34295. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  34296. }
  34297. return oldValue.Phone, nil
  34298. }
  34299. // ResetPhone resets all changes to the "phone" field.
  34300. func (m *WhatsappMutation) ResetPhone() {
  34301. m.phone = nil
  34302. }
  34303. // SetPhoneName sets the "phone_name" field.
  34304. func (m *WhatsappMutation) SetPhoneName(s string) {
  34305. m.phone_name = &s
  34306. }
  34307. // PhoneName returns the value of the "phone_name" field in the mutation.
  34308. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  34309. v := m.phone_name
  34310. if v == nil {
  34311. return
  34312. }
  34313. return *v, true
  34314. }
  34315. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  34316. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34318. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  34319. if !m.op.Is(OpUpdateOne) {
  34320. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  34321. }
  34322. if m.id == nil || m.oldValue == nil {
  34323. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  34324. }
  34325. oldValue, err := m.oldValue(ctx)
  34326. if err != nil {
  34327. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  34328. }
  34329. return oldValue.PhoneName, nil
  34330. }
  34331. // ResetPhoneName resets all changes to the "phone_name" field.
  34332. func (m *WhatsappMutation) ResetPhoneName() {
  34333. m.phone_name = nil
  34334. }
  34335. // SetPhoneStatus sets the "phone_status" field.
  34336. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  34337. m.phone_status = &i
  34338. m.addphone_status = nil
  34339. }
  34340. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  34341. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  34342. v := m.phone_status
  34343. if v == nil {
  34344. return
  34345. }
  34346. return *v, true
  34347. }
  34348. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  34349. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34351. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  34352. if !m.op.Is(OpUpdateOne) {
  34353. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  34354. }
  34355. if m.id == nil || m.oldValue == nil {
  34356. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  34357. }
  34358. oldValue, err := m.oldValue(ctx)
  34359. if err != nil {
  34360. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  34361. }
  34362. return oldValue.PhoneStatus, nil
  34363. }
  34364. // AddPhoneStatus adds i to the "phone_status" field.
  34365. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  34366. if m.addphone_status != nil {
  34367. *m.addphone_status += i
  34368. } else {
  34369. m.addphone_status = &i
  34370. }
  34371. }
  34372. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  34373. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  34374. v := m.addphone_status
  34375. if v == nil {
  34376. return
  34377. }
  34378. return *v, true
  34379. }
  34380. // ResetPhoneStatus resets all changes to the "phone_status" field.
  34381. func (m *WhatsappMutation) ResetPhoneStatus() {
  34382. m.phone_status = nil
  34383. m.addphone_status = nil
  34384. }
  34385. // SetOrganizationID sets the "organization_id" field.
  34386. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  34387. m.organization_id = &u
  34388. m.addorganization_id = nil
  34389. }
  34390. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34391. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  34392. v := m.organization_id
  34393. if v == nil {
  34394. return
  34395. }
  34396. return *v, true
  34397. }
  34398. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  34399. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34401. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34402. if !m.op.Is(OpUpdateOne) {
  34403. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34404. }
  34405. if m.id == nil || m.oldValue == nil {
  34406. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34407. }
  34408. oldValue, err := m.oldValue(ctx)
  34409. if err != nil {
  34410. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34411. }
  34412. return oldValue.OrganizationID, nil
  34413. }
  34414. // AddOrganizationID adds u to the "organization_id" field.
  34415. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  34416. if m.addorganization_id != nil {
  34417. *m.addorganization_id += u
  34418. } else {
  34419. m.addorganization_id = &u
  34420. }
  34421. }
  34422. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34423. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  34424. v := m.addorganization_id
  34425. if v == nil {
  34426. return
  34427. }
  34428. return *v, true
  34429. }
  34430. // ClearOrganizationID clears the value of the "organization_id" field.
  34431. func (m *WhatsappMutation) ClearOrganizationID() {
  34432. m.organization_id = nil
  34433. m.addorganization_id = nil
  34434. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  34435. }
  34436. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34437. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  34438. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  34439. return ok
  34440. }
  34441. // ResetOrganizationID resets all changes to the "organization_id" field.
  34442. func (m *WhatsappMutation) ResetOrganizationID() {
  34443. m.organization_id = nil
  34444. m.addorganization_id = nil
  34445. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  34446. }
  34447. // SetAPIBase sets the "api_base" field.
  34448. func (m *WhatsappMutation) SetAPIBase(s string) {
  34449. m.api_base = &s
  34450. }
  34451. // APIBase returns the value of the "api_base" field in the mutation.
  34452. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  34453. v := m.api_base
  34454. if v == nil {
  34455. return
  34456. }
  34457. return *v, true
  34458. }
  34459. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  34460. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34462. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  34463. if !m.op.Is(OpUpdateOne) {
  34464. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  34465. }
  34466. if m.id == nil || m.oldValue == nil {
  34467. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  34468. }
  34469. oldValue, err := m.oldValue(ctx)
  34470. if err != nil {
  34471. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  34472. }
  34473. return oldValue.APIBase, nil
  34474. }
  34475. // ClearAPIBase clears the value of the "api_base" field.
  34476. func (m *WhatsappMutation) ClearAPIBase() {
  34477. m.api_base = nil
  34478. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  34479. }
  34480. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  34481. func (m *WhatsappMutation) APIBaseCleared() bool {
  34482. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  34483. return ok
  34484. }
  34485. // ResetAPIBase resets all changes to the "api_base" field.
  34486. func (m *WhatsappMutation) ResetAPIBase() {
  34487. m.api_base = nil
  34488. delete(m.clearedFields, whatsapp.FieldAPIBase)
  34489. }
  34490. // SetAPIKey sets the "api_key" field.
  34491. func (m *WhatsappMutation) SetAPIKey(s string) {
  34492. m.api_key = &s
  34493. }
  34494. // APIKey returns the value of the "api_key" field in the mutation.
  34495. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  34496. v := m.api_key
  34497. if v == nil {
  34498. return
  34499. }
  34500. return *v, true
  34501. }
  34502. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  34503. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34505. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  34506. if !m.op.Is(OpUpdateOne) {
  34507. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  34508. }
  34509. if m.id == nil || m.oldValue == nil {
  34510. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  34511. }
  34512. oldValue, err := m.oldValue(ctx)
  34513. if err != nil {
  34514. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  34515. }
  34516. return oldValue.APIKey, nil
  34517. }
  34518. // ClearAPIKey clears the value of the "api_key" field.
  34519. func (m *WhatsappMutation) ClearAPIKey() {
  34520. m.api_key = nil
  34521. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  34522. }
  34523. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  34524. func (m *WhatsappMutation) APIKeyCleared() bool {
  34525. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  34526. return ok
  34527. }
  34528. // ResetAPIKey resets all changes to the "api_key" field.
  34529. func (m *WhatsappMutation) ResetAPIKey() {
  34530. m.api_key = nil
  34531. delete(m.clearedFields, whatsapp.FieldAPIKey)
  34532. }
  34533. // SetAllowList sets the "allow_list" field.
  34534. func (m *WhatsappMutation) SetAllowList(s []string) {
  34535. m.allow_list = &s
  34536. m.appendallow_list = nil
  34537. }
  34538. // AllowList returns the value of the "allow_list" field in the mutation.
  34539. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  34540. v := m.allow_list
  34541. if v == nil {
  34542. return
  34543. }
  34544. return *v, true
  34545. }
  34546. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  34547. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34549. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  34550. if !m.op.Is(OpUpdateOne) {
  34551. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  34552. }
  34553. if m.id == nil || m.oldValue == nil {
  34554. return v, errors.New("OldAllowList requires an ID field in the mutation")
  34555. }
  34556. oldValue, err := m.oldValue(ctx)
  34557. if err != nil {
  34558. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  34559. }
  34560. return oldValue.AllowList, nil
  34561. }
  34562. // AppendAllowList adds s to the "allow_list" field.
  34563. func (m *WhatsappMutation) AppendAllowList(s []string) {
  34564. m.appendallow_list = append(m.appendallow_list, s...)
  34565. }
  34566. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  34567. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  34568. if len(m.appendallow_list) == 0 {
  34569. return nil, false
  34570. }
  34571. return m.appendallow_list, true
  34572. }
  34573. // ClearAllowList clears the value of the "allow_list" field.
  34574. func (m *WhatsappMutation) ClearAllowList() {
  34575. m.allow_list = nil
  34576. m.appendallow_list = nil
  34577. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  34578. }
  34579. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  34580. func (m *WhatsappMutation) AllowListCleared() bool {
  34581. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  34582. return ok
  34583. }
  34584. // ResetAllowList resets all changes to the "allow_list" field.
  34585. func (m *WhatsappMutation) ResetAllowList() {
  34586. m.allow_list = nil
  34587. m.appendallow_list = nil
  34588. delete(m.clearedFields, whatsapp.FieldAllowList)
  34589. }
  34590. // SetGroupAllowList sets the "group_allow_list" field.
  34591. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  34592. m.group_allow_list = &s
  34593. m.appendgroup_allow_list = nil
  34594. }
  34595. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  34596. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  34597. v := m.group_allow_list
  34598. if v == nil {
  34599. return
  34600. }
  34601. return *v, true
  34602. }
  34603. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  34604. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34606. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  34607. if !m.op.Is(OpUpdateOne) {
  34608. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  34609. }
  34610. if m.id == nil || m.oldValue == nil {
  34611. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  34612. }
  34613. oldValue, err := m.oldValue(ctx)
  34614. if err != nil {
  34615. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  34616. }
  34617. return oldValue.GroupAllowList, nil
  34618. }
  34619. // AppendGroupAllowList adds s to the "group_allow_list" field.
  34620. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  34621. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  34622. }
  34623. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  34624. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  34625. if len(m.appendgroup_allow_list) == 0 {
  34626. return nil, false
  34627. }
  34628. return m.appendgroup_allow_list, true
  34629. }
  34630. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  34631. func (m *WhatsappMutation) ClearGroupAllowList() {
  34632. m.group_allow_list = nil
  34633. m.appendgroup_allow_list = nil
  34634. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  34635. }
  34636. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  34637. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  34638. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  34639. return ok
  34640. }
  34641. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  34642. func (m *WhatsappMutation) ResetGroupAllowList() {
  34643. m.group_allow_list = nil
  34644. m.appendgroup_allow_list = nil
  34645. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  34646. }
  34647. // SetBlockList sets the "block_list" field.
  34648. func (m *WhatsappMutation) SetBlockList(s []string) {
  34649. m.block_list = &s
  34650. m.appendblock_list = nil
  34651. }
  34652. // BlockList returns the value of the "block_list" field in the mutation.
  34653. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  34654. v := m.block_list
  34655. if v == nil {
  34656. return
  34657. }
  34658. return *v, true
  34659. }
  34660. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  34661. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34663. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  34664. if !m.op.Is(OpUpdateOne) {
  34665. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  34666. }
  34667. if m.id == nil || m.oldValue == nil {
  34668. return v, errors.New("OldBlockList requires an ID field in the mutation")
  34669. }
  34670. oldValue, err := m.oldValue(ctx)
  34671. if err != nil {
  34672. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  34673. }
  34674. return oldValue.BlockList, nil
  34675. }
  34676. // AppendBlockList adds s to the "block_list" field.
  34677. func (m *WhatsappMutation) AppendBlockList(s []string) {
  34678. m.appendblock_list = append(m.appendblock_list, s...)
  34679. }
  34680. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  34681. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  34682. if len(m.appendblock_list) == 0 {
  34683. return nil, false
  34684. }
  34685. return m.appendblock_list, true
  34686. }
  34687. // ClearBlockList clears the value of the "block_list" field.
  34688. func (m *WhatsappMutation) ClearBlockList() {
  34689. m.block_list = nil
  34690. m.appendblock_list = nil
  34691. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  34692. }
  34693. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  34694. func (m *WhatsappMutation) BlockListCleared() bool {
  34695. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  34696. return ok
  34697. }
  34698. // ResetBlockList resets all changes to the "block_list" field.
  34699. func (m *WhatsappMutation) ResetBlockList() {
  34700. m.block_list = nil
  34701. m.appendblock_list = nil
  34702. delete(m.clearedFields, whatsapp.FieldBlockList)
  34703. }
  34704. // SetGroupBlockList sets the "group_block_list" field.
  34705. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  34706. m.group_block_list = &s
  34707. m.appendgroup_block_list = nil
  34708. }
  34709. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  34710. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  34711. v := m.group_block_list
  34712. if v == nil {
  34713. return
  34714. }
  34715. return *v, true
  34716. }
  34717. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  34718. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34720. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  34721. if !m.op.Is(OpUpdateOne) {
  34722. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  34723. }
  34724. if m.id == nil || m.oldValue == nil {
  34725. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  34726. }
  34727. oldValue, err := m.oldValue(ctx)
  34728. if err != nil {
  34729. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  34730. }
  34731. return oldValue.GroupBlockList, nil
  34732. }
  34733. // AppendGroupBlockList adds s to the "group_block_list" field.
  34734. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  34735. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  34736. }
  34737. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  34738. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  34739. if len(m.appendgroup_block_list) == 0 {
  34740. return nil, false
  34741. }
  34742. return m.appendgroup_block_list, true
  34743. }
  34744. // ClearGroupBlockList clears the value of the "group_block_list" field.
  34745. func (m *WhatsappMutation) ClearGroupBlockList() {
  34746. m.group_block_list = nil
  34747. m.appendgroup_block_list = nil
  34748. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  34749. }
  34750. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  34751. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  34752. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  34753. return ok
  34754. }
  34755. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  34756. func (m *WhatsappMutation) ResetGroupBlockList() {
  34757. m.group_block_list = nil
  34758. m.appendgroup_block_list = nil
  34759. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  34760. }
  34761. // ClearAgent clears the "agent" edge to the Agent entity.
  34762. func (m *WhatsappMutation) ClearAgent() {
  34763. m.clearedagent = true
  34764. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  34765. }
  34766. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  34767. func (m *WhatsappMutation) AgentCleared() bool {
  34768. return m.clearedagent
  34769. }
  34770. // AgentIDs returns the "agent" edge IDs in the mutation.
  34771. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34772. // AgentID instead. It exists only for internal usage by the builders.
  34773. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  34774. if id := m.agent; id != nil {
  34775. ids = append(ids, *id)
  34776. }
  34777. return
  34778. }
  34779. // ResetAgent resets all changes to the "agent" edge.
  34780. func (m *WhatsappMutation) ResetAgent() {
  34781. m.agent = nil
  34782. m.clearedagent = false
  34783. }
  34784. // Where appends a list predicates to the WhatsappMutation builder.
  34785. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  34786. m.predicates = append(m.predicates, ps...)
  34787. }
  34788. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  34789. // users can use type-assertion to append predicates that do not depend on any generated package.
  34790. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  34791. p := make([]predicate.Whatsapp, len(ps))
  34792. for i := range ps {
  34793. p[i] = ps[i]
  34794. }
  34795. m.Where(p...)
  34796. }
  34797. // Op returns the operation name.
  34798. func (m *WhatsappMutation) Op() Op {
  34799. return m.op
  34800. }
  34801. // SetOp allows setting the mutation operation.
  34802. func (m *WhatsappMutation) SetOp(op Op) {
  34803. m.op = op
  34804. }
  34805. // Type returns the node type of this mutation (Whatsapp).
  34806. func (m *WhatsappMutation) Type() string {
  34807. return m.typ
  34808. }
  34809. // Fields returns all fields that were changed during this mutation. Note that in
  34810. // order to get all numeric fields that were incremented/decremented, call
  34811. // AddedFields().
  34812. func (m *WhatsappMutation) Fields() []string {
  34813. fields := make([]string, 0, 20)
  34814. if m.created_at != nil {
  34815. fields = append(fields, whatsapp.FieldCreatedAt)
  34816. }
  34817. if m.updated_at != nil {
  34818. fields = append(fields, whatsapp.FieldUpdatedAt)
  34819. }
  34820. if m.status != nil {
  34821. fields = append(fields, whatsapp.FieldStatus)
  34822. }
  34823. if m.deleted_at != nil {
  34824. fields = append(fields, whatsapp.FieldDeletedAt)
  34825. }
  34826. if m.wa_id != nil {
  34827. fields = append(fields, whatsapp.FieldWaID)
  34828. }
  34829. if m.wa_name != nil {
  34830. fields = append(fields, whatsapp.FieldWaName)
  34831. }
  34832. if m.callback != nil {
  34833. fields = append(fields, whatsapp.FieldCallback)
  34834. }
  34835. if m.agent != nil {
  34836. fields = append(fields, whatsapp.FieldAgentID)
  34837. }
  34838. if m.account != nil {
  34839. fields = append(fields, whatsapp.FieldAccount)
  34840. }
  34841. if m.cc != nil {
  34842. fields = append(fields, whatsapp.FieldCc)
  34843. }
  34844. if m.phone != nil {
  34845. fields = append(fields, whatsapp.FieldPhone)
  34846. }
  34847. if m.phone_name != nil {
  34848. fields = append(fields, whatsapp.FieldPhoneName)
  34849. }
  34850. if m.phone_status != nil {
  34851. fields = append(fields, whatsapp.FieldPhoneStatus)
  34852. }
  34853. if m.organization_id != nil {
  34854. fields = append(fields, whatsapp.FieldOrganizationID)
  34855. }
  34856. if m.api_base != nil {
  34857. fields = append(fields, whatsapp.FieldAPIBase)
  34858. }
  34859. if m.api_key != nil {
  34860. fields = append(fields, whatsapp.FieldAPIKey)
  34861. }
  34862. if m.allow_list != nil {
  34863. fields = append(fields, whatsapp.FieldAllowList)
  34864. }
  34865. if m.group_allow_list != nil {
  34866. fields = append(fields, whatsapp.FieldGroupAllowList)
  34867. }
  34868. if m.block_list != nil {
  34869. fields = append(fields, whatsapp.FieldBlockList)
  34870. }
  34871. if m.group_block_list != nil {
  34872. fields = append(fields, whatsapp.FieldGroupBlockList)
  34873. }
  34874. return fields
  34875. }
  34876. // Field returns the value of a field with the given name. The second boolean
  34877. // return value indicates that this field was not set, or was not defined in the
  34878. // schema.
  34879. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  34880. switch name {
  34881. case whatsapp.FieldCreatedAt:
  34882. return m.CreatedAt()
  34883. case whatsapp.FieldUpdatedAt:
  34884. return m.UpdatedAt()
  34885. case whatsapp.FieldStatus:
  34886. return m.Status()
  34887. case whatsapp.FieldDeletedAt:
  34888. return m.DeletedAt()
  34889. case whatsapp.FieldWaID:
  34890. return m.WaID()
  34891. case whatsapp.FieldWaName:
  34892. return m.WaName()
  34893. case whatsapp.FieldCallback:
  34894. return m.Callback()
  34895. case whatsapp.FieldAgentID:
  34896. return m.AgentID()
  34897. case whatsapp.FieldAccount:
  34898. return m.Account()
  34899. case whatsapp.FieldCc:
  34900. return m.Cc()
  34901. case whatsapp.FieldPhone:
  34902. return m.Phone()
  34903. case whatsapp.FieldPhoneName:
  34904. return m.PhoneName()
  34905. case whatsapp.FieldPhoneStatus:
  34906. return m.PhoneStatus()
  34907. case whatsapp.FieldOrganizationID:
  34908. return m.OrganizationID()
  34909. case whatsapp.FieldAPIBase:
  34910. return m.APIBase()
  34911. case whatsapp.FieldAPIKey:
  34912. return m.APIKey()
  34913. case whatsapp.FieldAllowList:
  34914. return m.AllowList()
  34915. case whatsapp.FieldGroupAllowList:
  34916. return m.GroupAllowList()
  34917. case whatsapp.FieldBlockList:
  34918. return m.BlockList()
  34919. case whatsapp.FieldGroupBlockList:
  34920. return m.GroupBlockList()
  34921. }
  34922. return nil, false
  34923. }
  34924. // OldField returns the old value of the field from the database. An error is
  34925. // returned if the mutation operation is not UpdateOne, or the query to the
  34926. // database failed.
  34927. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34928. switch name {
  34929. case whatsapp.FieldCreatedAt:
  34930. return m.OldCreatedAt(ctx)
  34931. case whatsapp.FieldUpdatedAt:
  34932. return m.OldUpdatedAt(ctx)
  34933. case whatsapp.FieldStatus:
  34934. return m.OldStatus(ctx)
  34935. case whatsapp.FieldDeletedAt:
  34936. return m.OldDeletedAt(ctx)
  34937. case whatsapp.FieldWaID:
  34938. return m.OldWaID(ctx)
  34939. case whatsapp.FieldWaName:
  34940. return m.OldWaName(ctx)
  34941. case whatsapp.FieldCallback:
  34942. return m.OldCallback(ctx)
  34943. case whatsapp.FieldAgentID:
  34944. return m.OldAgentID(ctx)
  34945. case whatsapp.FieldAccount:
  34946. return m.OldAccount(ctx)
  34947. case whatsapp.FieldCc:
  34948. return m.OldCc(ctx)
  34949. case whatsapp.FieldPhone:
  34950. return m.OldPhone(ctx)
  34951. case whatsapp.FieldPhoneName:
  34952. return m.OldPhoneName(ctx)
  34953. case whatsapp.FieldPhoneStatus:
  34954. return m.OldPhoneStatus(ctx)
  34955. case whatsapp.FieldOrganizationID:
  34956. return m.OldOrganizationID(ctx)
  34957. case whatsapp.FieldAPIBase:
  34958. return m.OldAPIBase(ctx)
  34959. case whatsapp.FieldAPIKey:
  34960. return m.OldAPIKey(ctx)
  34961. case whatsapp.FieldAllowList:
  34962. return m.OldAllowList(ctx)
  34963. case whatsapp.FieldGroupAllowList:
  34964. return m.OldGroupAllowList(ctx)
  34965. case whatsapp.FieldBlockList:
  34966. return m.OldBlockList(ctx)
  34967. case whatsapp.FieldGroupBlockList:
  34968. return m.OldGroupBlockList(ctx)
  34969. }
  34970. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  34971. }
  34972. // SetField sets the value of a field with the given name. It returns an error if
  34973. // the field is not defined in the schema, or if the type mismatched the field
  34974. // type.
  34975. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  34976. switch name {
  34977. case whatsapp.FieldCreatedAt:
  34978. v, ok := value.(time.Time)
  34979. if !ok {
  34980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34981. }
  34982. m.SetCreatedAt(v)
  34983. return nil
  34984. case whatsapp.FieldUpdatedAt:
  34985. v, ok := value.(time.Time)
  34986. if !ok {
  34987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34988. }
  34989. m.SetUpdatedAt(v)
  34990. return nil
  34991. case whatsapp.FieldStatus:
  34992. v, ok := value.(uint8)
  34993. if !ok {
  34994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34995. }
  34996. m.SetStatus(v)
  34997. return nil
  34998. case whatsapp.FieldDeletedAt:
  34999. v, ok := value.(time.Time)
  35000. if !ok {
  35001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35002. }
  35003. m.SetDeletedAt(v)
  35004. return nil
  35005. case whatsapp.FieldWaID:
  35006. v, ok := value.(string)
  35007. if !ok {
  35008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35009. }
  35010. m.SetWaID(v)
  35011. return nil
  35012. case whatsapp.FieldWaName:
  35013. v, ok := value.(string)
  35014. if !ok {
  35015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35016. }
  35017. m.SetWaName(v)
  35018. return nil
  35019. case whatsapp.FieldCallback:
  35020. v, ok := value.(string)
  35021. if !ok {
  35022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35023. }
  35024. m.SetCallback(v)
  35025. return nil
  35026. case whatsapp.FieldAgentID:
  35027. v, ok := value.(uint64)
  35028. if !ok {
  35029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35030. }
  35031. m.SetAgentID(v)
  35032. return nil
  35033. case whatsapp.FieldAccount:
  35034. v, ok := value.(string)
  35035. if !ok {
  35036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35037. }
  35038. m.SetAccount(v)
  35039. return nil
  35040. case whatsapp.FieldCc:
  35041. v, ok := value.(string)
  35042. if !ok {
  35043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35044. }
  35045. m.SetCc(v)
  35046. return nil
  35047. case whatsapp.FieldPhone:
  35048. v, ok := value.(string)
  35049. if !ok {
  35050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35051. }
  35052. m.SetPhone(v)
  35053. return nil
  35054. case whatsapp.FieldPhoneName:
  35055. v, ok := value.(string)
  35056. if !ok {
  35057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35058. }
  35059. m.SetPhoneName(v)
  35060. return nil
  35061. case whatsapp.FieldPhoneStatus:
  35062. v, ok := value.(int8)
  35063. if !ok {
  35064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35065. }
  35066. m.SetPhoneStatus(v)
  35067. return nil
  35068. case whatsapp.FieldOrganizationID:
  35069. v, ok := value.(uint64)
  35070. if !ok {
  35071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35072. }
  35073. m.SetOrganizationID(v)
  35074. return nil
  35075. case whatsapp.FieldAPIBase:
  35076. v, ok := value.(string)
  35077. if !ok {
  35078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35079. }
  35080. m.SetAPIBase(v)
  35081. return nil
  35082. case whatsapp.FieldAPIKey:
  35083. v, ok := value.(string)
  35084. if !ok {
  35085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35086. }
  35087. m.SetAPIKey(v)
  35088. return nil
  35089. case whatsapp.FieldAllowList:
  35090. v, ok := value.([]string)
  35091. if !ok {
  35092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35093. }
  35094. m.SetAllowList(v)
  35095. return nil
  35096. case whatsapp.FieldGroupAllowList:
  35097. v, ok := value.([]string)
  35098. if !ok {
  35099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35100. }
  35101. m.SetGroupAllowList(v)
  35102. return nil
  35103. case whatsapp.FieldBlockList:
  35104. v, ok := value.([]string)
  35105. if !ok {
  35106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35107. }
  35108. m.SetBlockList(v)
  35109. return nil
  35110. case whatsapp.FieldGroupBlockList:
  35111. v, ok := value.([]string)
  35112. if !ok {
  35113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35114. }
  35115. m.SetGroupBlockList(v)
  35116. return nil
  35117. }
  35118. return fmt.Errorf("unknown Whatsapp field %s", name)
  35119. }
  35120. // AddedFields returns all numeric fields that were incremented/decremented during
  35121. // this mutation.
  35122. func (m *WhatsappMutation) AddedFields() []string {
  35123. var fields []string
  35124. if m.addstatus != nil {
  35125. fields = append(fields, whatsapp.FieldStatus)
  35126. }
  35127. if m.addphone_status != nil {
  35128. fields = append(fields, whatsapp.FieldPhoneStatus)
  35129. }
  35130. if m.addorganization_id != nil {
  35131. fields = append(fields, whatsapp.FieldOrganizationID)
  35132. }
  35133. return fields
  35134. }
  35135. // AddedField returns the numeric value that was incremented/decremented on a field
  35136. // with the given name. The second boolean return value indicates that this field
  35137. // was not set, or was not defined in the schema.
  35138. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  35139. switch name {
  35140. case whatsapp.FieldStatus:
  35141. return m.AddedStatus()
  35142. case whatsapp.FieldPhoneStatus:
  35143. return m.AddedPhoneStatus()
  35144. case whatsapp.FieldOrganizationID:
  35145. return m.AddedOrganizationID()
  35146. }
  35147. return nil, false
  35148. }
  35149. // AddField adds the value to the field with the given name. It returns an error if
  35150. // the field is not defined in the schema, or if the type mismatched the field
  35151. // type.
  35152. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  35153. switch name {
  35154. case whatsapp.FieldStatus:
  35155. v, ok := value.(int8)
  35156. if !ok {
  35157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35158. }
  35159. m.AddStatus(v)
  35160. return nil
  35161. case whatsapp.FieldPhoneStatus:
  35162. v, ok := value.(int8)
  35163. if !ok {
  35164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35165. }
  35166. m.AddPhoneStatus(v)
  35167. return nil
  35168. case whatsapp.FieldOrganizationID:
  35169. v, ok := value.(int64)
  35170. if !ok {
  35171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35172. }
  35173. m.AddOrganizationID(v)
  35174. return nil
  35175. }
  35176. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  35177. }
  35178. // ClearedFields returns all nullable fields that were cleared during this
  35179. // mutation.
  35180. func (m *WhatsappMutation) ClearedFields() []string {
  35181. var fields []string
  35182. if m.FieldCleared(whatsapp.FieldStatus) {
  35183. fields = append(fields, whatsapp.FieldStatus)
  35184. }
  35185. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  35186. fields = append(fields, whatsapp.FieldDeletedAt)
  35187. }
  35188. if m.FieldCleared(whatsapp.FieldWaID) {
  35189. fields = append(fields, whatsapp.FieldWaID)
  35190. }
  35191. if m.FieldCleared(whatsapp.FieldWaName) {
  35192. fields = append(fields, whatsapp.FieldWaName)
  35193. }
  35194. if m.FieldCleared(whatsapp.FieldCallback) {
  35195. fields = append(fields, whatsapp.FieldCallback)
  35196. }
  35197. if m.FieldCleared(whatsapp.FieldAccount) {
  35198. fields = append(fields, whatsapp.FieldAccount)
  35199. }
  35200. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  35201. fields = append(fields, whatsapp.FieldOrganizationID)
  35202. }
  35203. if m.FieldCleared(whatsapp.FieldAPIBase) {
  35204. fields = append(fields, whatsapp.FieldAPIBase)
  35205. }
  35206. if m.FieldCleared(whatsapp.FieldAPIKey) {
  35207. fields = append(fields, whatsapp.FieldAPIKey)
  35208. }
  35209. if m.FieldCleared(whatsapp.FieldAllowList) {
  35210. fields = append(fields, whatsapp.FieldAllowList)
  35211. }
  35212. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  35213. fields = append(fields, whatsapp.FieldGroupAllowList)
  35214. }
  35215. if m.FieldCleared(whatsapp.FieldBlockList) {
  35216. fields = append(fields, whatsapp.FieldBlockList)
  35217. }
  35218. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  35219. fields = append(fields, whatsapp.FieldGroupBlockList)
  35220. }
  35221. return fields
  35222. }
  35223. // FieldCleared returns a boolean indicating if a field with the given name was
  35224. // cleared in this mutation.
  35225. func (m *WhatsappMutation) FieldCleared(name string) bool {
  35226. _, ok := m.clearedFields[name]
  35227. return ok
  35228. }
  35229. // ClearField clears the value of the field with the given name. It returns an
  35230. // error if the field is not defined in the schema.
  35231. func (m *WhatsappMutation) ClearField(name string) error {
  35232. switch name {
  35233. case whatsapp.FieldStatus:
  35234. m.ClearStatus()
  35235. return nil
  35236. case whatsapp.FieldDeletedAt:
  35237. m.ClearDeletedAt()
  35238. return nil
  35239. case whatsapp.FieldWaID:
  35240. m.ClearWaID()
  35241. return nil
  35242. case whatsapp.FieldWaName:
  35243. m.ClearWaName()
  35244. return nil
  35245. case whatsapp.FieldCallback:
  35246. m.ClearCallback()
  35247. return nil
  35248. case whatsapp.FieldAccount:
  35249. m.ClearAccount()
  35250. return nil
  35251. case whatsapp.FieldOrganizationID:
  35252. m.ClearOrganizationID()
  35253. return nil
  35254. case whatsapp.FieldAPIBase:
  35255. m.ClearAPIBase()
  35256. return nil
  35257. case whatsapp.FieldAPIKey:
  35258. m.ClearAPIKey()
  35259. return nil
  35260. case whatsapp.FieldAllowList:
  35261. m.ClearAllowList()
  35262. return nil
  35263. case whatsapp.FieldGroupAllowList:
  35264. m.ClearGroupAllowList()
  35265. return nil
  35266. case whatsapp.FieldBlockList:
  35267. m.ClearBlockList()
  35268. return nil
  35269. case whatsapp.FieldGroupBlockList:
  35270. m.ClearGroupBlockList()
  35271. return nil
  35272. }
  35273. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  35274. }
  35275. // ResetField resets all changes in the mutation for the field with the given name.
  35276. // It returns an error if the field is not defined in the schema.
  35277. func (m *WhatsappMutation) ResetField(name string) error {
  35278. switch name {
  35279. case whatsapp.FieldCreatedAt:
  35280. m.ResetCreatedAt()
  35281. return nil
  35282. case whatsapp.FieldUpdatedAt:
  35283. m.ResetUpdatedAt()
  35284. return nil
  35285. case whatsapp.FieldStatus:
  35286. m.ResetStatus()
  35287. return nil
  35288. case whatsapp.FieldDeletedAt:
  35289. m.ResetDeletedAt()
  35290. return nil
  35291. case whatsapp.FieldWaID:
  35292. m.ResetWaID()
  35293. return nil
  35294. case whatsapp.FieldWaName:
  35295. m.ResetWaName()
  35296. return nil
  35297. case whatsapp.FieldCallback:
  35298. m.ResetCallback()
  35299. return nil
  35300. case whatsapp.FieldAgentID:
  35301. m.ResetAgentID()
  35302. return nil
  35303. case whatsapp.FieldAccount:
  35304. m.ResetAccount()
  35305. return nil
  35306. case whatsapp.FieldCc:
  35307. m.ResetCc()
  35308. return nil
  35309. case whatsapp.FieldPhone:
  35310. m.ResetPhone()
  35311. return nil
  35312. case whatsapp.FieldPhoneName:
  35313. m.ResetPhoneName()
  35314. return nil
  35315. case whatsapp.FieldPhoneStatus:
  35316. m.ResetPhoneStatus()
  35317. return nil
  35318. case whatsapp.FieldOrganizationID:
  35319. m.ResetOrganizationID()
  35320. return nil
  35321. case whatsapp.FieldAPIBase:
  35322. m.ResetAPIBase()
  35323. return nil
  35324. case whatsapp.FieldAPIKey:
  35325. m.ResetAPIKey()
  35326. return nil
  35327. case whatsapp.FieldAllowList:
  35328. m.ResetAllowList()
  35329. return nil
  35330. case whatsapp.FieldGroupAllowList:
  35331. m.ResetGroupAllowList()
  35332. return nil
  35333. case whatsapp.FieldBlockList:
  35334. m.ResetBlockList()
  35335. return nil
  35336. case whatsapp.FieldGroupBlockList:
  35337. m.ResetGroupBlockList()
  35338. return nil
  35339. }
  35340. return fmt.Errorf("unknown Whatsapp field %s", name)
  35341. }
  35342. // AddedEdges returns all edge names that were set/added in this mutation.
  35343. func (m *WhatsappMutation) AddedEdges() []string {
  35344. edges := make([]string, 0, 1)
  35345. if m.agent != nil {
  35346. edges = append(edges, whatsapp.EdgeAgent)
  35347. }
  35348. return edges
  35349. }
  35350. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35351. // name in this mutation.
  35352. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  35353. switch name {
  35354. case whatsapp.EdgeAgent:
  35355. if id := m.agent; id != nil {
  35356. return []ent.Value{*id}
  35357. }
  35358. }
  35359. return nil
  35360. }
  35361. // RemovedEdges returns all edge names that were removed in this mutation.
  35362. func (m *WhatsappMutation) RemovedEdges() []string {
  35363. edges := make([]string, 0, 1)
  35364. return edges
  35365. }
  35366. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35367. // the given name in this mutation.
  35368. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  35369. return nil
  35370. }
  35371. // ClearedEdges returns all edge names that were cleared in this mutation.
  35372. func (m *WhatsappMutation) ClearedEdges() []string {
  35373. edges := make([]string, 0, 1)
  35374. if m.clearedagent {
  35375. edges = append(edges, whatsapp.EdgeAgent)
  35376. }
  35377. return edges
  35378. }
  35379. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35380. // was cleared in this mutation.
  35381. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  35382. switch name {
  35383. case whatsapp.EdgeAgent:
  35384. return m.clearedagent
  35385. }
  35386. return false
  35387. }
  35388. // ClearEdge clears the value of the edge with the given name. It returns an error
  35389. // if that edge is not defined in the schema.
  35390. func (m *WhatsappMutation) ClearEdge(name string) error {
  35391. switch name {
  35392. case whatsapp.EdgeAgent:
  35393. m.ClearAgent()
  35394. return nil
  35395. }
  35396. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  35397. }
  35398. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35399. // It returns an error if the edge is not defined in the schema.
  35400. func (m *WhatsappMutation) ResetEdge(name string) error {
  35401. switch name {
  35402. case whatsapp.EdgeAgent:
  35403. m.ResetAgent()
  35404. return nil
  35405. }
  35406. return fmt.Errorf("unknown Whatsapp edge %s", name)
  35407. }
  35408. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  35409. type WhatsappChannelMutation struct {
  35410. config
  35411. op Op
  35412. typ string
  35413. id *uint64
  35414. created_at *time.Time
  35415. updated_at *time.Time
  35416. status *uint8
  35417. addstatus *int8
  35418. deleted_at *time.Time
  35419. ak *string
  35420. sk *string
  35421. wa_id *string
  35422. wa_name *string
  35423. waba_id *uint64
  35424. addwaba_id *int64
  35425. business_id *uint64
  35426. addbusiness_id *int64
  35427. organization_id *uint64
  35428. addorganization_id *int64
  35429. verify_account *string
  35430. clearedFields map[string]struct{}
  35431. done bool
  35432. oldValue func(context.Context) (*WhatsappChannel, error)
  35433. predicates []predicate.WhatsappChannel
  35434. }
  35435. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  35436. // whatsappchannelOption allows management of the mutation configuration using functional options.
  35437. type whatsappchannelOption func(*WhatsappChannelMutation)
  35438. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  35439. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  35440. m := &WhatsappChannelMutation{
  35441. config: c,
  35442. op: op,
  35443. typ: TypeWhatsappChannel,
  35444. clearedFields: make(map[string]struct{}),
  35445. }
  35446. for _, opt := range opts {
  35447. opt(m)
  35448. }
  35449. return m
  35450. }
  35451. // withWhatsappChannelID sets the ID field of the mutation.
  35452. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  35453. return func(m *WhatsappChannelMutation) {
  35454. var (
  35455. err error
  35456. once sync.Once
  35457. value *WhatsappChannel
  35458. )
  35459. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  35460. once.Do(func() {
  35461. if m.done {
  35462. err = errors.New("querying old values post mutation is not allowed")
  35463. } else {
  35464. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  35465. }
  35466. })
  35467. return value, err
  35468. }
  35469. m.id = &id
  35470. }
  35471. }
  35472. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  35473. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  35474. return func(m *WhatsappChannelMutation) {
  35475. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  35476. return node, nil
  35477. }
  35478. m.id = &node.ID
  35479. }
  35480. }
  35481. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35482. // executed in a transaction (ent.Tx), a transactional client is returned.
  35483. func (m WhatsappChannelMutation) Client() *Client {
  35484. client := &Client{config: m.config}
  35485. client.init()
  35486. return client
  35487. }
  35488. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35489. // it returns an error otherwise.
  35490. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  35491. if _, ok := m.driver.(*txDriver); !ok {
  35492. return nil, errors.New("ent: mutation is not running in a transaction")
  35493. }
  35494. tx := &Tx{config: m.config}
  35495. tx.init()
  35496. return tx, nil
  35497. }
  35498. // SetID sets the value of the id field. Note that this
  35499. // operation is only accepted on creation of WhatsappChannel entities.
  35500. func (m *WhatsappChannelMutation) SetID(id uint64) {
  35501. m.id = &id
  35502. }
  35503. // ID returns the ID value in the mutation. Note that the ID is only available
  35504. // if it was provided to the builder or after it was returned from the database.
  35505. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  35506. if m.id == nil {
  35507. return
  35508. }
  35509. return *m.id, true
  35510. }
  35511. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35512. // That means, if the mutation is applied within a transaction with an isolation level such
  35513. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35514. // or updated by the mutation.
  35515. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  35516. switch {
  35517. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35518. id, exists := m.ID()
  35519. if exists {
  35520. return []uint64{id}, nil
  35521. }
  35522. fallthrough
  35523. case m.op.Is(OpUpdate | OpDelete):
  35524. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  35525. default:
  35526. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35527. }
  35528. }
  35529. // SetCreatedAt sets the "created_at" field.
  35530. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  35531. m.created_at = &t
  35532. }
  35533. // CreatedAt returns the value of the "created_at" field in the mutation.
  35534. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  35535. v := m.created_at
  35536. if v == nil {
  35537. return
  35538. }
  35539. return *v, true
  35540. }
  35541. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  35542. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35544. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35545. if !m.op.Is(OpUpdateOne) {
  35546. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35547. }
  35548. if m.id == nil || m.oldValue == nil {
  35549. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35550. }
  35551. oldValue, err := m.oldValue(ctx)
  35552. if err != nil {
  35553. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35554. }
  35555. return oldValue.CreatedAt, nil
  35556. }
  35557. // ResetCreatedAt resets all changes to the "created_at" field.
  35558. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  35559. m.created_at = nil
  35560. }
  35561. // SetUpdatedAt sets the "updated_at" field.
  35562. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  35563. m.updated_at = &t
  35564. }
  35565. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35566. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  35567. v := m.updated_at
  35568. if v == nil {
  35569. return
  35570. }
  35571. return *v, true
  35572. }
  35573. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  35574. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35576. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35577. if !m.op.Is(OpUpdateOne) {
  35578. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35579. }
  35580. if m.id == nil || m.oldValue == nil {
  35581. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35582. }
  35583. oldValue, err := m.oldValue(ctx)
  35584. if err != nil {
  35585. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35586. }
  35587. return oldValue.UpdatedAt, nil
  35588. }
  35589. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35590. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  35591. m.updated_at = nil
  35592. }
  35593. // SetStatus sets the "status" field.
  35594. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  35595. m.status = &u
  35596. m.addstatus = nil
  35597. }
  35598. // Status returns the value of the "status" field in the mutation.
  35599. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  35600. v := m.status
  35601. if v == nil {
  35602. return
  35603. }
  35604. return *v, true
  35605. }
  35606. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  35607. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35609. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35610. if !m.op.Is(OpUpdateOne) {
  35611. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35612. }
  35613. if m.id == nil || m.oldValue == nil {
  35614. return v, errors.New("OldStatus requires an ID field in the mutation")
  35615. }
  35616. oldValue, err := m.oldValue(ctx)
  35617. if err != nil {
  35618. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35619. }
  35620. return oldValue.Status, nil
  35621. }
  35622. // AddStatus adds u to the "status" field.
  35623. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  35624. if m.addstatus != nil {
  35625. *m.addstatus += u
  35626. } else {
  35627. m.addstatus = &u
  35628. }
  35629. }
  35630. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35631. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  35632. v := m.addstatus
  35633. if v == nil {
  35634. return
  35635. }
  35636. return *v, true
  35637. }
  35638. // ClearStatus clears the value of the "status" field.
  35639. func (m *WhatsappChannelMutation) ClearStatus() {
  35640. m.status = nil
  35641. m.addstatus = nil
  35642. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  35643. }
  35644. // StatusCleared returns if the "status" field was cleared in this mutation.
  35645. func (m *WhatsappChannelMutation) StatusCleared() bool {
  35646. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  35647. return ok
  35648. }
  35649. // ResetStatus resets all changes to the "status" field.
  35650. func (m *WhatsappChannelMutation) ResetStatus() {
  35651. m.status = nil
  35652. m.addstatus = nil
  35653. delete(m.clearedFields, whatsappchannel.FieldStatus)
  35654. }
  35655. // SetDeletedAt sets the "deleted_at" field.
  35656. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  35657. m.deleted_at = &t
  35658. }
  35659. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35660. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  35661. v := m.deleted_at
  35662. if v == nil {
  35663. return
  35664. }
  35665. return *v, true
  35666. }
  35667. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  35668. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35670. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35671. if !m.op.Is(OpUpdateOne) {
  35672. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35673. }
  35674. if m.id == nil || m.oldValue == nil {
  35675. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35676. }
  35677. oldValue, err := m.oldValue(ctx)
  35678. if err != nil {
  35679. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35680. }
  35681. return oldValue.DeletedAt, nil
  35682. }
  35683. // ClearDeletedAt clears the value of the "deleted_at" field.
  35684. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  35685. m.deleted_at = nil
  35686. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  35687. }
  35688. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35689. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  35690. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  35691. return ok
  35692. }
  35693. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35694. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  35695. m.deleted_at = nil
  35696. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  35697. }
  35698. // SetAk sets the "ak" field.
  35699. func (m *WhatsappChannelMutation) SetAk(s string) {
  35700. m.ak = &s
  35701. }
  35702. // Ak returns the value of the "ak" field in the mutation.
  35703. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  35704. v := m.ak
  35705. if v == nil {
  35706. return
  35707. }
  35708. return *v, true
  35709. }
  35710. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  35711. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35713. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  35714. if !m.op.Is(OpUpdateOne) {
  35715. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  35716. }
  35717. if m.id == nil || m.oldValue == nil {
  35718. return v, errors.New("OldAk requires an ID field in the mutation")
  35719. }
  35720. oldValue, err := m.oldValue(ctx)
  35721. if err != nil {
  35722. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  35723. }
  35724. return oldValue.Ak, nil
  35725. }
  35726. // ClearAk clears the value of the "ak" field.
  35727. func (m *WhatsappChannelMutation) ClearAk() {
  35728. m.ak = nil
  35729. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  35730. }
  35731. // AkCleared returns if the "ak" field was cleared in this mutation.
  35732. func (m *WhatsappChannelMutation) AkCleared() bool {
  35733. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  35734. return ok
  35735. }
  35736. // ResetAk resets all changes to the "ak" field.
  35737. func (m *WhatsappChannelMutation) ResetAk() {
  35738. m.ak = nil
  35739. delete(m.clearedFields, whatsappchannel.FieldAk)
  35740. }
  35741. // SetSk sets the "sk" field.
  35742. func (m *WhatsappChannelMutation) SetSk(s string) {
  35743. m.sk = &s
  35744. }
  35745. // Sk returns the value of the "sk" field in the mutation.
  35746. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  35747. v := m.sk
  35748. if v == nil {
  35749. return
  35750. }
  35751. return *v, true
  35752. }
  35753. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  35754. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35756. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  35757. if !m.op.Is(OpUpdateOne) {
  35758. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  35759. }
  35760. if m.id == nil || m.oldValue == nil {
  35761. return v, errors.New("OldSk requires an ID field in the mutation")
  35762. }
  35763. oldValue, err := m.oldValue(ctx)
  35764. if err != nil {
  35765. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  35766. }
  35767. return oldValue.Sk, nil
  35768. }
  35769. // ResetSk resets all changes to the "sk" field.
  35770. func (m *WhatsappChannelMutation) ResetSk() {
  35771. m.sk = nil
  35772. }
  35773. // SetWaID sets the "wa_id" field.
  35774. func (m *WhatsappChannelMutation) SetWaID(s string) {
  35775. m.wa_id = &s
  35776. }
  35777. // WaID returns the value of the "wa_id" field in the mutation.
  35778. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  35779. v := m.wa_id
  35780. if v == nil {
  35781. return
  35782. }
  35783. return *v, true
  35784. }
  35785. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  35786. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35788. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  35789. if !m.op.Is(OpUpdateOne) {
  35790. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  35791. }
  35792. if m.id == nil || m.oldValue == nil {
  35793. return v, errors.New("OldWaID requires an ID field in the mutation")
  35794. }
  35795. oldValue, err := m.oldValue(ctx)
  35796. if err != nil {
  35797. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  35798. }
  35799. return oldValue.WaID, nil
  35800. }
  35801. // ClearWaID clears the value of the "wa_id" field.
  35802. func (m *WhatsappChannelMutation) ClearWaID() {
  35803. m.wa_id = nil
  35804. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  35805. }
  35806. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  35807. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  35808. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  35809. return ok
  35810. }
  35811. // ResetWaID resets all changes to the "wa_id" field.
  35812. func (m *WhatsappChannelMutation) ResetWaID() {
  35813. m.wa_id = nil
  35814. delete(m.clearedFields, whatsappchannel.FieldWaID)
  35815. }
  35816. // SetWaName sets the "wa_name" field.
  35817. func (m *WhatsappChannelMutation) SetWaName(s string) {
  35818. m.wa_name = &s
  35819. }
  35820. // WaName returns the value of the "wa_name" field in the mutation.
  35821. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  35822. v := m.wa_name
  35823. if v == nil {
  35824. return
  35825. }
  35826. return *v, true
  35827. }
  35828. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  35829. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35831. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  35832. if !m.op.Is(OpUpdateOne) {
  35833. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  35834. }
  35835. if m.id == nil || m.oldValue == nil {
  35836. return v, errors.New("OldWaName requires an ID field in the mutation")
  35837. }
  35838. oldValue, err := m.oldValue(ctx)
  35839. if err != nil {
  35840. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  35841. }
  35842. return oldValue.WaName, nil
  35843. }
  35844. // ClearWaName clears the value of the "wa_name" field.
  35845. func (m *WhatsappChannelMutation) ClearWaName() {
  35846. m.wa_name = nil
  35847. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  35848. }
  35849. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  35850. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  35851. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  35852. return ok
  35853. }
  35854. // ResetWaName resets all changes to the "wa_name" field.
  35855. func (m *WhatsappChannelMutation) ResetWaName() {
  35856. m.wa_name = nil
  35857. delete(m.clearedFields, whatsappchannel.FieldWaName)
  35858. }
  35859. // SetWabaID sets the "waba_id" field.
  35860. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  35861. m.waba_id = &u
  35862. m.addwaba_id = nil
  35863. }
  35864. // WabaID returns the value of the "waba_id" field in the mutation.
  35865. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  35866. v := m.waba_id
  35867. if v == nil {
  35868. return
  35869. }
  35870. return *v, true
  35871. }
  35872. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  35873. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35875. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  35876. if !m.op.Is(OpUpdateOne) {
  35877. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  35878. }
  35879. if m.id == nil || m.oldValue == nil {
  35880. return v, errors.New("OldWabaID requires an ID field in the mutation")
  35881. }
  35882. oldValue, err := m.oldValue(ctx)
  35883. if err != nil {
  35884. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  35885. }
  35886. return oldValue.WabaID, nil
  35887. }
  35888. // AddWabaID adds u to the "waba_id" field.
  35889. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  35890. if m.addwaba_id != nil {
  35891. *m.addwaba_id += u
  35892. } else {
  35893. m.addwaba_id = &u
  35894. }
  35895. }
  35896. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  35897. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  35898. v := m.addwaba_id
  35899. if v == nil {
  35900. return
  35901. }
  35902. return *v, true
  35903. }
  35904. // ResetWabaID resets all changes to the "waba_id" field.
  35905. func (m *WhatsappChannelMutation) ResetWabaID() {
  35906. m.waba_id = nil
  35907. m.addwaba_id = nil
  35908. }
  35909. // SetBusinessID sets the "business_id" field.
  35910. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  35911. m.business_id = &u
  35912. m.addbusiness_id = nil
  35913. }
  35914. // BusinessID returns the value of the "business_id" field in the mutation.
  35915. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  35916. v := m.business_id
  35917. if v == nil {
  35918. return
  35919. }
  35920. return *v, true
  35921. }
  35922. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  35923. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35925. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  35926. if !m.op.Is(OpUpdateOne) {
  35927. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  35928. }
  35929. if m.id == nil || m.oldValue == nil {
  35930. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  35931. }
  35932. oldValue, err := m.oldValue(ctx)
  35933. if err != nil {
  35934. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  35935. }
  35936. return oldValue.BusinessID, nil
  35937. }
  35938. // AddBusinessID adds u to the "business_id" field.
  35939. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  35940. if m.addbusiness_id != nil {
  35941. *m.addbusiness_id += u
  35942. } else {
  35943. m.addbusiness_id = &u
  35944. }
  35945. }
  35946. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  35947. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  35948. v := m.addbusiness_id
  35949. if v == nil {
  35950. return
  35951. }
  35952. return *v, true
  35953. }
  35954. // ResetBusinessID resets all changes to the "business_id" field.
  35955. func (m *WhatsappChannelMutation) ResetBusinessID() {
  35956. m.business_id = nil
  35957. m.addbusiness_id = nil
  35958. }
  35959. // SetOrganizationID sets the "organization_id" field.
  35960. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  35961. m.organization_id = &u
  35962. m.addorganization_id = nil
  35963. }
  35964. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35965. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  35966. v := m.organization_id
  35967. if v == nil {
  35968. return
  35969. }
  35970. return *v, true
  35971. }
  35972. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  35973. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  35974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35975. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35976. if !m.op.Is(OpUpdateOne) {
  35977. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35978. }
  35979. if m.id == nil || m.oldValue == nil {
  35980. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35981. }
  35982. oldValue, err := m.oldValue(ctx)
  35983. if err != nil {
  35984. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35985. }
  35986. return oldValue.OrganizationID, nil
  35987. }
  35988. // AddOrganizationID adds u to the "organization_id" field.
  35989. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  35990. if m.addorganization_id != nil {
  35991. *m.addorganization_id += u
  35992. } else {
  35993. m.addorganization_id = &u
  35994. }
  35995. }
  35996. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35997. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  35998. v := m.addorganization_id
  35999. if v == nil {
  36000. return
  36001. }
  36002. return *v, true
  36003. }
  36004. // ClearOrganizationID clears the value of the "organization_id" field.
  36005. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  36006. m.organization_id = nil
  36007. m.addorganization_id = nil
  36008. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  36009. }
  36010. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36011. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  36012. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  36013. return ok
  36014. }
  36015. // ResetOrganizationID resets all changes to the "organization_id" field.
  36016. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  36017. m.organization_id = nil
  36018. m.addorganization_id = nil
  36019. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  36020. }
  36021. // SetVerifyAccount sets the "verify_account" field.
  36022. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  36023. m.verify_account = &s
  36024. }
  36025. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  36026. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  36027. v := m.verify_account
  36028. if v == nil {
  36029. return
  36030. }
  36031. return *v, true
  36032. }
  36033. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  36034. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  36035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36036. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  36037. if !m.op.Is(OpUpdateOne) {
  36038. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  36039. }
  36040. if m.id == nil || m.oldValue == nil {
  36041. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  36042. }
  36043. oldValue, err := m.oldValue(ctx)
  36044. if err != nil {
  36045. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  36046. }
  36047. return oldValue.VerifyAccount, nil
  36048. }
  36049. // ResetVerifyAccount resets all changes to the "verify_account" field.
  36050. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  36051. m.verify_account = nil
  36052. }
  36053. // Where appends a list predicates to the WhatsappChannelMutation builder.
  36054. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  36055. m.predicates = append(m.predicates, ps...)
  36056. }
  36057. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  36058. // users can use type-assertion to append predicates that do not depend on any generated package.
  36059. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  36060. p := make([]predicate.WhatsappChannel, len(ps))
  36061. for i := range ps {
  36062. p[i] = ps[i]
  36063. }
  36064. m.Where(p...)
  36065. }
  36066. // Op returns the operation name.
  36067. func (m *WhatsappChannelMutation) Op() Op {
  36068. return m.op
  36069. }
  36070. // SetOp allows setting the mutation operation.
  36071. func (m *WhatsappChannelMutation) SetOp(op Op) {
  36072. m.op = op
  36073. }
  36074. // Type returns the node type of this mutation (WhatsappChannel).
  36075. func (m *WhatsappChannelMutation) Type() string {
  36076. return m.typ
  36077. }
  36078. // Fields returns all fields that were changed during this mutation. Note that in
  36079. // order to get all numeric fields that were incremented/decremented, call
  36080. // AddedFields().
  36081. func (m *WhatsappChannelMutation) Fields() []string {
  36082. fields := make([]string, 0, 12)
  36083. if m.created_at != nil {
  36084. fields = append(fields, whatsappchannel.FieldCreatedAt)
  36085. }
  36086. if m.updated_at != nil {
  36087. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  36088. }
  36089. if m.status != nil {
  36090. fields = append(fields, whatsappchannel.FieldStatus)
  36091. }
  36092. if m.deleted_at != nil {
  36093. fields = append(fields, whatsappchannel.FieldDeletedAt)
  36094. }
  36095. if m.ak != nil {
  36096. fields = append(fields, whatsappchannel.FieldAk)
  36097. }
  36098. if m.sk != nil {
  36099. fields = append(fields, whatsappchannel.FieldSk)
  36100. }
  36101. if m.wa_id != nil {
  36102. fields = append(fields, whatsappchannel.FieldWaID)
  36103. }
  36104. if m.wa_name != nil {
  36105. fields = append(fields, whatsappchannel.FieldWaName)
  36106. }
  36107. if m.waba_id != nil {
  36108. fields = append(fields, whatsappchannel.FieldWabaID)
  36109. }
  36110. if m.business_id != nil {
  36111. fields = append(fields, whatsappchannel.FieldBusinessID)
  36112. }
  36113. if m.organization_id != nil {
  36114. fields = append(fields, whatsappchannel.FieldOrganizationID)
  36115. }
  36116. if m.verify_account != nil {
  36117. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  36118. }
  36119. return fields
  36120. }
  36121. // Field returns the value of a field with the given name. The second boolean
  36122. // return value indicates that this field was not set, or was not defined in the
  36123. // schema.
  36124. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  36125. switch name {
  36126. case whatsappchannel.FieldCreatedAt:
  36127. return m.CreatedAt()
  36128. case whatsappchannel.FieldUpdatedAt:
  36129. return m.UpdatedAt()
  36130. case whatsappchannel.FieldStatus:
  36131. return m.Status()
  36132. case whatsappchannel.FieldDeletedAt:
  36133. return m.DeletedAt()
  36134. case whatsappchannel.FieldAk:
  36135. return m.Ak()
  36136. case whatsappchannel.FieldSk:
  36137. return m.Sk()
  36138. case whatsappchannel.FieldWaID:
  36139. return m.WaID()
  36140. case whatsappchannel.FieldWaName:
  36141. return m.WaName()
  36142. case whatsappchannel.FieldWabaID:
  36143. return m.WabaID()
  36144. case whatsappchannel.FieldBusinessID:
  36145. return m.BusinessID()
  36146. case whatsappchannel.FieldOrganizationID:
  36147. return m.OrganizationID()
  36148. case whatsappchannel.FieldVerifyAccount:
  36149. return m.VerifyAccount()
  36150. }
  36151. return nil, false
  36152. }
  36153. // OldField returns the old value of the field from the database. An error is
  36154. // returned if the mutation operation is not UpdateOne, or the query to the
  36155. // database failed.
  36156. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36157. switch name {
  36158. case whatsappchannel.FieldCreatedAt:
  36159. return m.OldCreatedAt(ctx)
  36160. case whatsappchannel.FieldUpdatedAt:
  36161. return m.OldUpdatedAt(ctx)
  36162. case whatsappchannel.FieldStatus:
  36163. return m.OldStatus(ctx)
  36164. case whatsappchannel.FieldDeletedAt:
  36165. return m.OldDeletedAt(ctx)
  36166. case whatsappchannel.FieldAk:
  36167. return m.OldAk(ctx)
  36168. case whatsappchannel.FieldSk:
  36169. return m.OldSk(ctx)
  36170. case whatsappchannel.FieldWaID:
  36171. return m.OldWaID(ctx)
  36172. case whatsappchannel.FieldWaName:
  36173. return m.OldWaName(ctx)
  36174. case whatsappchannel.FieldWabaID:
  36175. return m.OldWabaID(ctx)
  36176. case whatsappchannel.FieldBusinessID:
  36177. return m.OldBusinessID(ctx)
  36178. case whatsappchannel.FieldOrganizationID:
  36179. return m.OldOrganizationID(ctx)
  36180. case whatsappchannel.FieldVerifyAccount:
  36181. return m.OldVerifyAccount(ctx)
  36182. }
  36183. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  36184. }
  36185. // SetField sets the value of a field with the given name. It returns an error if
  36186. // the field is not defined in the schema, or if the type mismatched the field
  36187. // type.
  36188. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  36189. switch name {
  36190. case whatsappchannel.FieldCreatedAt:
  36191. v, ok := value.(time.Time)
  36192. if !ok {
  36193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36194. }
  36195. m.SetCreatedAt(v)
  36196. return nil
  36197. case whatsappchannel.FieldUpdatedAt:
  36198. v, ok := value.(time.Time)
  36199. if !ok {
  36200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36201. }
  36202. m.SetUpdatedAt(v)
  36203. return nil
  36204. case whatsappchannel.FieldStatus:
  36205. v, ok := value.(uint8)
  36206. if !ok {
  36207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36208. }
  36209. m.SetStatus(v)
  36210. return nil
  36211. case whatsappchannel.FieldDeletedAt:
  36212. v, ok := value.(time.Time)
  36213. if !ok {
  36214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36215. }
  36216. m.SetDeletedAt(v)
  36217. return nil
  36218. case whatsappchannel.FieldAk:
  36219. v, ok := value.(string)
  36220. if !ok {
  36221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36222. }
  36223. m.SetAk(v)
  36224. return nil
  36225. case whatsappchannel.FieldSk:
  36226. v, ok := value.(string)
  36227. if !ok {
  36228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36229. }
  36230. m.SetSk(v)
  36231. return nil
  36232. case whatsappchannel.FieldWaID:
  36233. v, ok := value.(string)
  36234. if !ok {
  36235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36236. }
  36237. m.SetWaID(v)
  36238. return nil
  36239. case whatsappchannel.FieldWaName:
  36240. v, ok := value.(string)
  36241. if !ok {
  36242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36243. }
  36244. m.SetWaName(v)
  36245. return nil
  36246. case whatsappchannel.FieldWabaID:
  36247. v, ok := value.(uint64)
  36248. if !ok {
  36249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36250. }
  36251. m.SetWabaID(v)
  36252. return nil
  36253. case whatsappchannel.FieldBusinessID:
  36254. v, ok := value.(uint64)
  36255. if !ok {
  36256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36257. }
  36258. m.SetBusinessID(v)
  36259. return nil
  36260. case whatsappchannel.FieldOrganizationID:
  36261. v, ok := value.(uint64)
  36262. if !ok {
  36263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36264. }
  36265. m.SetOrganizationID(v)
  36266. return nil
  36267. case whatsappchannel.FieldVerifyAccount:
  36268. v, ok := value.(string)
  36269. if !ok {
  36270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36271. }
  36272. m.SetVerifyAccount(v)
  36273. return nil
  36274. }
  36275. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  36276. }
  36277. // AddedFields returns all numeric fields that were incremented/decremented during
  36278. // this mutation.
  36279. func (m *WhatsappChannelMutation) AddedFields() []string {
  36280. var fields []string
  36281. if m.addstatus != nil {
  36282. fields = append(fields, whatsappchannel.FieldStatus)
  36283. }
  36284. if m.addwaba_id != nil {
  36285. fields = append(fields, whatsappchannel.FieldWabaID)
  36286. }
  36287. if m.addbusiness_id != nil {
  36288. fields = append(fields, whatsappchannel.FieldBusinessID)
  36289. }
  36290. if m.addorganization_id != nil {
  36291. fields = append(fields, whatsappchannel.FieldOrganizationID)
  36292. }
  36293. return fields
  36294. }
  36295. // AddedField returns the numeric value that was incremented/decremented on a field
  36296. // with the given name. The second boolean return value indicates that this field
  36297. // was not set, or was not defined in the schema.
  36298. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  36299. switch name {
  36300. case whatsappchannel.FieldStatus:
  36301. return m.AddedStatus()
  36302. case whatsappchannel.FieldWabaID:
  36303. return m.AddedWabaID()
  36304. case whatsappchannel.FieldBusinessID:
  36305. return m.AddedBusinessID()
  36306. case whatsappchannel.FieldOrganizationID:
  36307. return m.AddedOrganizationID()
  36308. }
  36309. return nil, false
  36310. }
  36311. // AddField adds the value to the field with the given name. It returns an error if
  36312. // the field is not defined in the schema, or if the type mismatched the field
  36313. // type.
  36314. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  36315. switch name {
  36316. case whatsappchannel.FieldStatus:
  36317. v, ok := value.(int8)
  36318. if !ok {
  36319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36320. }
  36321. m.AddStatus(v)
  36322. return nil
  36323. case whatsappchannel.FieldWabaID:
  36324. v, ok := value.(int64)
  36325. if !ok {
  36326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36327. }
  36328. m.AddWabaID(v)
  36329. return nil
  36330. case whatsappchannel.FieldBusinessID:
  36331. v, ok := value.(int64)
  36332. if !ok {
  36333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36334. }
  36335. m.AddBusinessID(v)
  36336. return nil
  36337. case whatsappchannel.FieldOrganizationID:
  36338. v, ok := value.(int64)
  36339. if !ok {
  36340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36341. }
  36342. m.AddOrganizationID(v)
  36343. return nil
  36344. }
  36345. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  36346. }
  36347. // ClearedFields returns all nullable fields that were cleared during this
  36348. // mutation.
  36349. func (m *WhatsappChannelMutation) ClearedFields() []string {
  36350. var fields []string
  36351. if m.FieldCleared(whatsappchannel.FieldStatus) {
  36352. fields = append(fields, whatsappchannel.FieldStatus)
  36353. }
  36354. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  36355. fields = append(fields, whatsappchannel.FieldDeletedAt)
  36356. }
  36357. if m.FieldCleared(whatsappchannel.FieldAk) {
  36358. fields = append(fields, whatsappchannel.FieldAk)
  36359. }
  36360. if m.FieldCleared(whatsappchannel.FieldWaID) {
  36361. fields = append(fields, whatsappchannel.FieldWaID)
  36362. }
  36363. if m.FieldCleared(whatsappchannel.FieldWaName) {
  36364. fields = append(fields, whatsappchannel.FieldWaName)
  36365. }
  36366. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  36367. fields = append(fields, whatsappchannel.FieldOrganizationID)
  36368. }
  36369. return fields
  36370. }
  36371. // FieldCleared returns a boolean indicating if a field with the given name was
  36372. // cleared in this mutation.
  36373. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  36374. _, ok := m.clearedFields[name]
  36375. return ok
  36376. }
  36377. // ClearField clears the value of the field with the given name. It returns an
  36378. // error if the field is not defined in the schema.
  36379. func (m *WhatsappChannelMutation) ClearField(name string) error {
  36380. switch name {
  36381. case whatsappchannel.FieldStatus:
  36382. m.ClearStatus()
  36383. return nil
  36384. case whatsappchannel.FieldDeletedAt:
  36385. m.ClearDeletedAt()
  36386. return nil
  36387. case whatsappchannel.FieldAk:
  36388. m.ClearAk()
  36389. return nil
  36390. case whatsappchannel.FieldWaID:
  36391. m.ClearWaID()
  36392. return nil
  36393. case whatsappchannel.FieldWaName:
  36394. m.ClearWaName()
  36395. return nil
  36396. case whatsappchannel.FieldOrganizationID:
  36397. m.ClearOrganizationID()
  36398. return nil
  36399. }
  36400. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  36401. }
  36402. // ResetField resets all changes in the mutation for the field with the given name.
  36403. // It returns an error if the field is not defined in the schema.
  36404. func (m *WhatsappChannelMutation) ResetField(name string) error {
  36405. switch name {
  36406. case whatsappchannel.FieldCreatedAt:
  36407. m.ResetCreatedAt()
  36408. return nil
  36409. case whatsappchannel.FieldUpdatedAt:
  36410. m.ResetUpdatedAt()
  36411. return nil
  36412. case whatsappchannel.FieldStatus:
  36413. m.ResetStatus()
  36414. return nil
  36415. case whatsappchannel.FieldDeletedAt:
  36416. m.ResetDeletedAt()
  36417. return nil
  36418. case whatsappchannel.FieldAk:
  36419. m.ResetAk()
  36420. return nil
  36421. case whatsappchannel.FieldSk:
  36422. m.ResetSk()
  36423. return nil
  36424. case whatsappchannel.FieldWaID:
  36425. m.ResetWaID()
  36426. return nil
  36427. case whatsappchannel.FieldWaName:
  36428. m.ResetWaName()
  36429. return nil
  36430. case whatsappchannel.FieldWabaID:
  36431. m.ResetWabaID()
  36432. return nil
  36433. case whatsappchannel.FieldBusinessID:
  36434. m.ResetBusinessID()
  36435. return nil
  36436. case whatsappchannel.FieldOrganizationID:
  36437. m.ResetOrganizationID()
  36438. return nil
  36439. case whatsappchannel.FieldVerifyAccount:
  36440. m.ResetVerifyAccount()
  36441. return nil
  36442. }
  36443. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  36444. }
  36445. // AddedEdges returns all edge names that were set/added in this mutation.
  36446. func (m *WhatsappChannelMutation) AddedEdges() []string {
  36447. edges := make([]string, 0, 0)
  36448. return edges
  36449. }
  36450. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36451. // name in this mutation.
  36452. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  36453. return nil
  36454. }
  36455. // RemovedEdges returns all edge names that were removed in this mutation.
  36456. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  36457. edges := make([]string, 0, 0)
  36458. return edges
  36459. }
  36460. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36461. // the given name in this mutation.
  36462. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  36463. return nil
  36464. }
  36465. // ClearedEdges returns all edge names that were cleared in this mutation.
  36466. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  36467. edges := make([]string, 0, 0)
  36468. return edges
  36469. }
  36470. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36471. // was cleared in this mutation.
  36472. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  36473. return false
  36474. }
  36475. // ClearEdge clears the value of the edge with the given name. It returns an error
  36476. // if that edge is not defined in the schema.
  36477. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  36478. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  36479. }
  36480. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36481. // It returns an error if the edge is not defined in the schema.
  36482. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  36483. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  36484. }
  36485. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  36486. type WorkExperienceMutation struct {
  36487. config
  36488. op Op
  36489. typ string
  36490. id *uint64
  36491. created_at *time.Time
  36492. updated_at *time.Time
  36493. deleted_at *time.Time
  36494. start_date *time.Time
  36495. end_date *time.Time
  36496. company *string
  36497. experience *string
  36498. organization_id *uint64
  36499. addorganization_id *int64
  36500. clearedFields map[string]struct{}
  36501. employee *uint64
  36502. clearedemployee bool
  36503. done bool
  36504. oldValue func(context.Context) (*WorkExperience, error)
  36505. predicates []predicate.WorkExperience
  36506. }
  36507. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  36508. // workexperienceOption allows management of the mutation configuration using functional options.
  36509. type workexperienceOption func(*WorkExperienceMutation)
  36510. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  36511. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  36512. m := &WorkExperienceMutation{
  36513. config: c,
  36514. op: op,
  36515. typ: TypeWorkExperience,
  36516. clearedFields: make(map[string]struct{}),
  36517. }
  36518. for _, opt := range opts {
  36519. opt(m)
  36520. }
  36521. return m
  36522. }
  36523. // withWorkExperienceID sets the ID field of the mutation.
  36524. func withWorkExperienceID(id uint64) workexperienceOption {
  36525. return func(m *WorkExperienceMutation) {
  36526. var (
  36527. err error
  36528. once sync.Once
  36529. value *WorkExperience
  36530. )
  36531. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  36532. once.Do(func() {
  36533. if m.done {
  36534. err = errors.New("querying old values post mutation is not allowed")
  36535. } else {
  36536. value, err = m.Client().WorkExperience.Get(ctx, id)
  36537. }
  36538. })
  36539. return value, err
  36540. }
  36541. m.id = &id
  36542. }
  36543. }
  36544. // withWorkExperience sets the old WorkExperience of the mutation.
  36545. func withWorkExperience(node *WorkExperience) workexperienceOption {
  36546. return func(m *WorkExperienceMutation) {
  36547. m.oldValue = func(context.Context) (*WorkExperience, error) {
  36548. return node, nil
  36549. }
  36550. m.id = &node.ID
  36551. }
  36552. }
  36553. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36554. // executed in a transaction (ent.Tx), a transactional client is returned.
  36555. func (m WorkExperienceMutation) Client() *Client {
  36556. client := &Client{config: m.config}
  36557. client.init()
  36558. return client
  36559. }
  36560. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36561. // it returns an error otherwise.
  36562. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  36563. if _, ok := m.driver.(*txDriver); !ok {
  36564. return nil, errors.New("ent: mutation is not running in a transaction")
  36565. }
  36566. tx := &Tx{config: m.config}
  36567. tx.init()
  36568. return tx, nil
  36569. }
  36570. // SetID sets the value of the id field. Note that this
  36571. // operation is only accepted on creation of WorkExperience entities.
  36572. func (m *WorkExperienceMutation) SetID(id uint64) {
  36573. m.id = &id
  36574. }
  36575. // ID returns the ID value in the mutation. Note that the ID is only available
  36576. // if it was provided to the builder or after it was returned from the database.
  36577. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  36578. if m.id == nil {
  36579. return
  36580. }
  36581. return *m.id, true
  36582. }
  36583. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36584. // That means, if the mutation is applied within a transaction with an isolation level such
  36585. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36586. // or updated by the mutation.
  36587. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  36588. switch {
  36589. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36590. id, exists := m.ID()
  36591. if exists {
  36592. return []uint64{id}, nil
  36593. }
  36594. fallthrough
  36595. case m.op.Is(OpUpdate | OpDelete):
  36596. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  36597. default:
  36598. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36599. }
  36600. }
  36601. // SetCreatedAt sets the "created_at" field.
  36602. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  36603. m.created_at = &t
  36604. }
  36605. // CreatedAt returns the value of the "created_at" field in the mutation.
  36606. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  36607. v := m.created_at
  36608. if v == nil {
  36609. return
  36610. }
  36611. return *v, true
  36612. }
  36613. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  36614. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36616. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36617. if !m.op.Is(OpUpdateOne) {
  36618. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36619. }
  36620. if m.id == nil || m.oldValue == nil {
  36621. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36622. }
  36623. oldValue, err := m.oldValue(ctx)
  36624. if err != nil {
  36625. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36626. }
  36627. return oldValue.CreatedAt, nil
  36628. }
  36629. // ResetCreatedAt resets all changes to the "created_at" field.
  36630. func (m *WorkExperienceMutation) ResetCreatedAt() {
  36631. m.created_at = nil
  36632. }
  36633. // SetUpdatedAt sets the "updated_at" field.
  36634. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  36635. m.updated_at = &t
  36636. }
  36637. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36638. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  36639. v := m.updated_at
  36640. if v == nil {
  36641. return
  36642. }
  36643. return *v, true
  36644. }
  36645. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  36646. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36648. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36649. if !m.op.Is(OpUpdateOne) {
  36650. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36651. }
  36652. if m.id == nil || m.oldValue == nil {
  36653. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36654. }
  36655. oldValue, err := m.oldValue(ctx)
  36656. if err != nil {
  36657. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36658. }
  36659. return oldValue.UpdatedAt, nil
  36660. }
  36661. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36662. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  36663. m.updated_at = nil
  36664. }
  36665. // SetDeletedAt sets the "deleted_at" field.
  36666. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  36667. m.deleted_at = &t
  36668. }
  36669. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36670. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  36671. v := m.deleted_at
  36672. if v == nil {
  36673. return
  36674. }
  36675. return *v, true
  36676. }
  36677. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  36678. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36680. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36681. if !m.op.Is(OpUpdateOne) {
  36682. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36683. }
  36684. if m.id == nil || m.oldValue == nil {
  36685. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36686. }
  36687. oldValue, err := m.oldValue(ctx)
  36688. if err != nil {
  36689. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36690. }
  36691. return oldValue.DeletedAt, nil
  36692. }
  36693. // ClearDeletedAt clears the value of the "deleted_at" field.
  36694. func (m *WorkExperienceMutation) ClearDeletedAt() {
  36695. m.deleted_at = nil
  36696. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  36697. }
  36698. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36699. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  36700. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  36701. return ok
  36702. }
  36703. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36704. func (m *WorkExperienceMutation) ResetDeletedAt() {
  36705. m.deleted_at = nil
  36706. delete(m.clearedFields, workexperience.FieldDeletedAt)
  36707. }
  36708. // SetEmployeeID sets the "employee_id" field.
  36709. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  36710. m.employee = &u
  36711. }
  36712. // EmployeeID returns the value of the "employee_id" field in the mutation.
  36713. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  36714. v := m.employee
  36715. if v == nil {
  36716. return
  36717. }
  36718. return *v, true
  36719. }
  36720. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  36721. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36723. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  36724. if !m.op.Is(OpUpdateOne) {
  36725. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  36726. }
  36727. if m.id == nil || m.oldValue == nil {
  36728. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  36729. }
  36730. oldValue, err := m.oldValue(ctx)
  36731. if err != nil {
  36732. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  36733. }
  36734. return oldValue.EmployeeID, nil
  36735. }
  36736. // ResetEmployeeID resets all changes to the "employee_id" field.
  36737. func (m *WorkExperienceMutation) ResetEmployeeID() {
  36738. m.employee = nil
  36739. }
  36740. // SetStartDate sets the "start_date" field.
  36741. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  36742. m.start_date = &t
  36743. }
  36744. // StartDate returns the value of the "start_date" field in the mutation.
  36745. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  36746. v := m.start_date
  36747. if v == nil {
  36748. return
  36749. }
  36750. return *v, true
  36751. }
  36752. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  36753. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36755. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  36756. if !m.op.Is(OpUpdateOne) {
  36757. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  36758. }
  36759. if m.id == nil || m.oldValue == nil {
  36760. return v, errors.New("OldStartDate requires an ID field in the mutation")
  36761. }
  36762. oldValue, err := m.oldValue(ctx)
  36763. if err != nil {
  36764. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  36765. }
  36766. return oldValue.StartDate, nil
  36767. }
  36768. // ResetStartDate resets all changes to the "start_date" field.
  36769. func (m *WorkExperienceMutation) ResetStartDate() {
  36770. m.start_date = nil
  36771. }
  36772. // SetEndDate sets the "end_date" field.
  36773. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  36774. m.end_date = &t
  36775. }
  36776. // EndDate returns the value of the "end_date" field in the mutation.
  36777. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  36778. v := m.end_date
  36779. if v == nil {
  36780. return
  36781. }
  36782. return *v, true
  36783. }
  36784. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  36785. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36787. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  36788. if !m.op.Is(OpUpdateOne) {
  36789. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  36790. }
  36791. if m.id == nil || m.oldValue == nil {
  36792. return v, errors.New("OldEndDate requires an ID field in the mutation")
  36793. }
  36794. oldValue, err := m.oldValue(ctx)
  36795. if err != nil {
  36796. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  36797. }
  36798. return oldValue.EndDate, nil
  36799. }
  36800. // ResetEndDate resets all changes to the "end_date" field.
  36801. func (m *WorkExperienceMutation) ResetEndDate() {
  36802. m.end_date = nil
  36803. }
  36804. // SetCompany sets the "company" field.
  36805. func (m *WorkExperienceMutation) SetCompany(s string) {
  36806. m.company = &s
  36807. }
  36808. // Company returns the value of the "company" field in the mutation.
  36809. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  36810. v := m.company
  36811. if v == nil {
  36812. return
  36813. }
  36814. return *v, true
  36815. }
  36816. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  36817. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36819. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  36820. if !m.op.Is(OpUpdateOne) {
  36821. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  36822. }
  36823. if m.id == nil || m.oldValue == nil {
  36824. return v, errors.New("OldCompany requires an ID field in the mutation")
  36825. }
  36826. oldValue, err := m.oldValue(ctx)
  36827. if err != nil {
  36828. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  36829. }
  36830. return oldValue.Company, nil
  36831. }
  36832. // ResetCompany resets all changes to the "company" field.
  36833. func (m *WorkExperienceMutation) ResetCompany() {
  36834. m.company = nil
  36835. }
  36836. // SetExperience sets the "experience" field.
  36837. func (m *WorkExperienceMutation) SetExperience(s string) {
  36838. m.experience = &s
  36839. }
  36840. // Experience returns the value of the "experience" field in the mutation.
  36841. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  36842. v := m.experience
  36843. if v == nil {
  36844. return
  36845. }
  36846. return *v, true
  36847. }
  36848. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  36849. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36851. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  36852. if !m.op.Is(OpUpdateOne) {
  36853. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  36854. }
  36855. if m.id == nil || m.oldValue == nil {
  36856. return v, errors.New("OldExperience requires an ID field in the mutation")
  36857. }
  36858. oldValue, err := m.oldValue(ctx)
  36859. if err != nil {
  36860. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  36861. }
  36862. return oldValue.Experience, nil
  36863. }
  36864. // ResetExperience resets all changes to the "experience" field.
  36865. func (m *WorkExperienceMutation) ResetExperience() {
  36866. m.experience = nil
  36867. }
  36868. // SetOrganizationID sets the "organization_id" field.
  36869. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  36870. m.organization_id = &u
  36871. m.addorganization_id = nil
  36872. }
  36873. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36874. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  36875. v := m.organization_id
  36876. if v == nil {
  36877. return
  36878. }
  36879. return *v, true
  36880. }
  36881. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  36882. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  36883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36884. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36885. if !m.op.Is(OpUpdateOne) {
  36886. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36887. }
  36888. if m.id == nil || m.oldValue == nil {
  36889. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36890. }
  36891. oldValue, err := m.oldValue(ctx)
  36892. if err != nil {
  36893. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36894. }
  36895. return oldValue.OrganizationID, nil
  36896. }
  36897. // AddOrganizationID adds u to the "organization_id" field.
  36898. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  36899. if m.addorganization_id != nil {
  36900. *m.addorganization_id += u
  36901. } else {
  36902. m.addorganization_id = &u
  36903. }
  36904. }
  36905. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36906. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  36907. v := m.addorganization_id
  36908. if v == nil {
  36909. return
  36910. }
  36911. return *v, true
  36912. }
  36913. // ResetOrganizationID resets all changes to the "organization_id" field.
  36914. func (m *WorkExperienceMutation) ResetOrganizationID() {
  36915. m.organization_id = nil
  36916. m.addorganization_id = nil
  36917. }
  36918. // ClearEmployee clears the "employee" edge to the Employee entity.
  36919. func (m *WorkExperienceMutation) ClearEmployee() {
  36920. m.clearedemployee = true
  36921. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  36922. }
  36923. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  36924. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  36925. return m.clearedemployee
  36926. }
  36927. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  36928. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  36929. // EmployeeID instead. It exists only for internal usage by the builders.
  36930. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  36931. if id := m.employee; id != nil {
  36932. ids = append(ids, *id)
  36933. }
  36934. return
  36935. }
  36936. // ResetEmployee resets all changes to the "employee" edge.
  36937. func (m *WorkExperienceMutation) ResetEmployee() {
  36938. m.employee = nil
  36939. m.clearedemployee = false
  36940. }
  36941. // Where appends a list predicates to the WorkExperienceMutation builder.
  36942. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  36943. m.predicates = append(m.predicates, ps...)
  36944. }
  36945. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  36946. // users can use type-assertion to append predicates that do not depend on any generated package.
  36947. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  36948. p := make([]predicate.WorkExperience, len(ps))
  36949. for i := range ps {
  36950. p[i] = ps[i]
  36951. }
  36952. m.Where(p...)
  36953. }
  36954. // Op returns the operation name.
  36955. func (m *WorkExperienceMutation) Op() Op {
  36956. return m.op
  36957. }
  36958. // SetOp allows setting the mutation operation.
  36959. func (m *WorkExperienceMutation) SetOp(op Op) {
  36960. m.op = op
  36961. }
  36962. // Type returns the node type of this mutation (WorkExperience).
  36963. func (m *WorkExperienceMutation) Type() string {
  36964. return m.typ
  36965. }
  36966. // Fields returns all fields that were changed during this mutation. Note that in
  36967. // order to get all numeric fields that were incremented/decremented, call
  36968. // AddedFields().
  36969. func (m *WorkExperienceMutation) Fields() []string {
  36970. fields := make([]string, 0, 9)
  36971. if m.created_at != nil {
  36972. fields = append(fields, workexperience.FieldCreatedAt)
  36973. }
  36974. if m.updated_at != nil {
  36975. fields = append(fields, workexperience.FieldUpdatedAt)
  36976. }
  36977. if m.deleted_at != nil {
  36978. fields = append(fields, workexperience.FieldDeletedAt)
  36979. }
  36980. if m.employee != nil {
  36981. fields = append(fields, workexperience.FieldEmployeeID)
  36982. }
  36983. if m.start_date != nil {
  36984. fields = append(fields, workexperience.FieldStartDate)
  36985. }
  36986. if m.end_date != nil {
  36987. fields = append(fields, workexperience.FieldEndDate)
  36988. }
  36989. if m.company != nil {
  36990. fields = append(fields, workexperience.FieldCompany)
  36991. }
  36992. if m.experience != nil {
  36993. fields = append(fields, workexperience.FieldExperience)
  36994. }
  36995. if m.organization_id != nil {
  36996. fields = append(fields, workexperience.FieldOrganizationID)
  36997. }
  36998. return fields
  36999. }
  37000. // Field returns the value of a field with the given name. The second boolean
  37001. // return value indicates that this field was not set, or was not defined in the
  37002. // schema.
  37003. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  37004. switch name {
  37005. case workexperience.FieldCreatedAt:
  37006. return m.CreatedAt()
  37007. case workexperience.FieldUpdatedAt:
  37008. return m.UpdatedAt()
  37009. case workexperience.FieldDeletedAt:
  37010. return m.DeletedAt()
  37011. case workexperience.FieldEmployeeID:
  37012. return m.EmployeeID()
  37013. case workexperience.FieldStartDate:
  37014. return m.StartDate()
  37015. case workexperience.FieldEndDate:
  37016. return m.EndDate()
  37017. case workexperience.FieldCompany:
  37018. return m.Company()
  37019. case workexperience.FieldExperience:
  37020. return m.Experience()
  37021. case workexperience.FieldOrganizationID:
  37022. return m.OrganizationID()
  37023. }
  37024. return nil, false
  37025. }
  37026. // OldField returns the old value of the field from the database. An error is
  37027. // returned if the mutation operation is not UpdateOne, or the query to the
  37028. // database failed.
  37029. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37030. switch name {
  37031. case workexperience.FieldCreatedAt:
  37032. return m.OldCreatedAt(ctx)
  37033. case workexperience.FieldUpdatedAt:
  37034. return m.OldUpdatedAt(ctx)
  37035. case workexperience.FieldDeletedAt:
  37036. return m.OldDeletedAt(ctx)
  37037. case workexperience.FieldEmployeeID:
  37038. return m.OldEmployeeID(ctx)
  37039. case workexperience.FieldStartDate:
  37040. return m.OldStartDate(ctx)
  37041. case workexperience.FieldEndDate:
  37042. return m.OldEndDate(ctx)
  37043. case workexperience.FieldCompany:
  37044. return m.OldCompany(ctx)
  37045. case workexperience.FieldExperience:
  37046. return m.OldExperience(ctx)
  37047. case workexperience.FieldOrganizationID:
  37048. return m.OldOrganizationID(ctx)
  37049. }
  37050. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  37051. }
  37052. // SetField sets the value of a field with the given name. It returns an error if
  37053. // the field is not defined in the schema, or if the type mismatched the field
  37054. // type.
  37055. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  37056. switch name {
  37057. case workexperience.FieldCreatedAt:
  37058. v, ok := value.(time.Time)
  37059. if !ok {
  37060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37061. }
  37062. m.SetCreatedAt(v)
  37063. return nil
  37064. case workexperience.FieldUpdatedAt:
  37065. v, ok := value.(time.Time)
  37066. if !ok {
  37067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37068. }
  37069. m.SetUpdatedAt(v)
  37070. return nil
  37071. case workexperience.FieldDeletedAt:
  37072. v, ok := value.(time.Time)
  37073. if !ok {
  37074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37075. }
  37076. m.SetDeletedAt(v)
  37077. return nil
  37078. case workexperience.FieldEmployeeID:
  37079. v, ok := value.(uint64)
  37080. if !ok {
  37081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37082. }
  37083. m.SetEmployeeID(v)
  37084. return nil
  37085. case workexperience.FieldStartDate:
  37086. v, ok := value.(time.Time)
  37087. if !ok {
  37088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37089. }
  37090. m.SetStartDate(v)
  37091. return nil
  37092. case workexperience.FieldEndDate:
  37093. v, ok := value.(time.Time)
  37094. if !ok {
  37095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37096. }
  37097. m.SetEndDate(v)
  37098. return nil
  37099. case workexperience.FieldCompany:
  37100. v, ok := value.(string)
  37101. if !ok {
  37102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37103. }
  37104. m.SetCompany(v)
  37105. return nil
  37106. case workexperience.FieldExperience:
  37107. v, ok := value.(string)
  37108. if !ok {
  37109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37110. }
  37111. m.SetExperience(v)
  37112. return nil
  37113. case workexperience.FieldOrganizationID:
  37114. v, ok := value.(uint64)
  37115. if !ok {
  37116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37117. }
  37118. m.SetOrganizationID(v)
  37119. return nil
  37120. }
  37121. return fmt.Errorf("unknown WorkExperience field %s", name)
  37122. }
  37123. // AddedFields returns all numeric fields that were incremented/decremented during
  37124. // this mutation.
  37125. func (m *WorkExperienceMutation) AddedFields() []string {
  37126. var fields []string
  37127. if m.addorganization_id != nil {
  37128. fields = append(fields, workexperience.FieldOrganizationID)
  37129. }
  37130. return fields
  37131. }
  37132. // AddedField returns the numeric value that was incremented/decremented on a field
  37133. // with the given name. The second boolean return value indicates that this field
  37134. // was not set, or was not defined in the schema.
  37135. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  37136. switch name {
  37137. case workexperience.FieldOrganizationID:
  37138. return m.AddedOrganizationID()
  37139. }
  37140. return nil, false
  37141. }
  37142. // AddField adds the value to the field with the given name. It returns an error if
  37143. // the field is not defined in the schema, or if the type mismatched the field
  37144. // type.
  37145. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  37146. switch name {
  37147. case workexperience.FieldOrganizationID:
  37148. v, ok := value.(int64)
  37149. if !ok {
  37150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37151. }
  37152. m.AddOrganizationID(v)
  37153. return nil
  37154. }
  37155. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  37156. }
  37157. // ClearedFields returns all nullable fields that were cleared during this
  37158. // mutation.
  37159. func (m *WorkExperienceMutation) ClearedFields() []string {
  37160. var fields []string
  37161. if m.FieldCleared(workexperience.FieldDeletedAt) {
  37162. fields = append(fields, workexperience.FieldDeletedAt)
  37163. }
  37164. return fields
  37165. }
  37166. // FieldCleared returns a boolean indicating if a field with the given name was
  37167. // cleared in this mutation.
  37168. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  37169. _, ok := m.clearedFields[name]
  37170. return ok
  37171. }
  37172. // ClearField clears the value of the field with the given name. It returns an
  37173. // error if the field is not defined in the schema.
  37174. func (m *WorkExperienceMutation) ClearField(name string) error {
  37175. switch name {
  37176. case workexperience.FieldDeletedAt:
  37177. m.ClearDeletedAt()
  37178. return nil
  37179. }
  37180. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  37181. }
  37182. // ResetField resets all changes in the mutation for the field with the given name.
  37183. // It returns an error if the field is not defined in the schema.
  37184. func (m *WorkExperienceMutation) ResetField(name string) error {
  37185. switch name {
  37186. case workexperience.FieldCreatedAt:
  37187. m.ResetCreatedAt()
  37188. return nil
  37189. case workexperience.FieldUpdatedAt:
  37190. m.ResetUpdatedAt()
  37191. return nil
  37192. case workexperience.FieldDeletedAt:
  37193. m.ResetDeletedAt()
  37194. return nil
  37195. case workexperience.FieldEmployeeID:
  37196. m.ResetEmployeeID()
  37197. return nil
  37198. case workexperience.FieldStartDate:
  37199. m.ResetStartDate()
  37200. return nil
  37201. case workexperience.FieldEndDate:
  37202. m.ResetEndDate()
  37203. return nil
  37204. case workexperience.FieldCompany:
  37205. m.ResetCompany()
  37206. return nil
  37207. case workexperience.FieldExperience:
  37208. m.ResetExperience()
  37209. return nil
  37210. case workexperience.FieldOrganizationID:
  37211. m.ResetOrganizationID()
  37212. return nil
  37213. }
  37214. return fmt.Errorf("unknown WorkExperience field %s", name)
  37215. }
  37216. // AddedEdges returns all edge names that were set/added in this mutation.
  37217. func (m *WorkExperienceMutation) AddedEdges() []string {
  37218. edges := make([]string, 0, 1)
  37219. if m.employee != nil {
  37220. edges = append(edges, workexperience.EdgeEmployee)
  37221. }
  37222. return edges
  37223. }
  37224. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37225. // name in this mutation.
  37226. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  37227. switch name {
  37228. case workexperience.EdgeEmployee:
  37229. if id := m.employee; id != nil {
  37230. return []ent.Value{*id}
  37231. }
  37232. }
  37233. return nil
  37234. }
  37235. // RemovedEdges returns all edge names that were removed in this mutation.
  37236. func (m *WorkExperienceMutation) RemovedEdges() []string {
  37237. edges := make([]string, 0, 1)
  37238. return edges
  37239. }
  37240. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37241. // the given name in this mutation.
  37242. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  37243. return nil
  37244. }
  37245. // ClearedEdges returns all edge names that were cleared in this mutation.
  37246. func (m *WorkExperienceMutation) ClearedEdges() []string {
  37247. edges := make([]string, 0, 1)
  37248. if m.clearedemployee {
  37249. edges = append(edges, workexperience.EdgeEmployee)
  37250. }
  37251. return edges
  37252. }
  37253. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37254. // was cleared in this mutation.
  37255. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  37256. switch name {
  37257. case workexperience.EdgeEmployee:
  37258. return m.clearedemployee
  37259. }
  37260. return false
  37261. }
  37262. // ClearEdge clears the value of the edge with the given name. It returns an error
  37263. // if that edge is not defined in the schema.
  37264. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  37265. switch name {
  37266. case workexperience.EdgeEmployee:
  37267. m.ClearEmployee()
  37268. return nil
  37269. }
  37270. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  37271. }
  37272. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37273. // It returns an error if the edge is not defined in the schema.
  37274. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  37275. switch name {
  37276. case workexperience.EdgeEmployee:
  37277. m.ResetEmployee()
  37278. return nil
  37279. }
  37280. return fmt.Errorf("unknown WorkExperience edge %s", name)
  37281. }
  37282. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  37283. type WpChatroomMutation struct {
  37284. config
  37285. op Op
  37286. typ string
  37287. id *uint64
  37288. created_at *time.Time
  37289. updated_at *time.Time
  37290. status *uint8
  37291. addstatus *int8
  37292. wx_wxid *string
  37293. chatroom_id *string
  37294. nickname *string
  37295. owner *string
  37296. avatar *string
  37297. member_list *[]string
  37298. appendmember_list []string
  37299. clearedFields map[string]struct{}
  37300. done bool
  37301. oldValue func(context.Context) (*WpChatroom, error)
  37302. predicates []predicate.WpChatroom
  37303. }
  37304. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  37305. // wpchatroomOption allows management of the mutation configuration using functional options.
  37306. type wpchatroomOption func(*WpChatroomMutation)
  37307. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  37308. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  37309. m := &WpChatroomMutation{
  37310. config: c,
  37311. op: op,
  37312. typ: TypeWpChatroom,
  37313. clearedFields: make(map[string]struct{}),
  37314. }
  37315. for _, opt := range opts {
  37316. opt(m)
  37317. }
  37318. return m
  37319. }
  37320. // withWpChatroomID sets the ID field of the mutation.
  37321. func withWpChatroomID(id uint64) wpchatroomOption {
  37322. return func(m *WpChatroomMutation) {
  37323. var (
  37324. err error
  37325. once sync.Once
  37326. value *WpChatroom
  37327. )
  37328. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  37329. once.Do(func() {
  37330. if m.done {
  37331. err = errors.New("querying old values post mutation is not allowed")
  37332. } else {
  37333. value, err = m.Client().WpChatroom.Get(ctx, id)
  37334. }
  37335. })
  37336. return value, err
  37337. }
  37338. m.id = &id
  37339. }
  37340. }
  37341. // withWpChatroom sets the old WpChatroom of the mutation.
  37342. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  37343. return func(m *WpChatroomMutation) {
  37344. m.oldValue = func(context.Context) (*WpChatroom, error) {
  37345. return node, nil
  37346. }
  37347. m.id = &node.ID
  37348. }
  37349. }
  37350. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37351. // executed in a transaction (ent.Tx), a transactional client is returned.
  37352. func (m WpChatroomMutation) Client() *Client {
  37353. client := &Client{config: m.config}
  37354. client.init()
  37355. return client
  37356. }
  37357. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37358. // it returns an error otherwise.
  37359. func (m WpChatroomMutation) Tx() (*Tx, error) {
  37360. if _, ok := m.driver.(*txDriver); !ok {
  37361. return nil, errors.New("ent: mutation is not running in a transaction")
  37362. }
  37363. tx := &Tx{config: m.config}
  37364. tx.init()
  37365. return tx, nil
  37366. }
  37367. // SetID sets the value of the id field. Note that this
  37368. // operation is only accepted on creation of WpChatroom entities.
  37369. func (m *WpChatroomMutation) SetID(id uint64) {
  37370. m.id = &id
  37371. }
  37372. // ID returns the ID value in the mutation. Note that the ID is only available
  37373. // if it was provided to the builder or after it was returned from the database.
  37374. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  37375. if m.id == nil {
  37376. return
  37377. }
  37378. return *m.id, true
  37379. }
  37380. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37381. // That means, if the mutation is applied within a transaction with an isolation level such
  37382. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37383. // or updated by the mutation.
  37384. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  37385. switch {
  37386. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37387. id, exists := m.ID()
  37388. if exists {
  37389. return []uint64{id}, nil
  37390. }
  37391. fallthrough
  37392. case m.op.Is(OpUpdate | OpDelete):
  37393. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  37394. default:
  37395. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37396. }
  37397. }
  37398. // SetCreatedAt sets the "created_at" field.
  37399. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  37400. m.created_at = &t
  37401. }
  37402. // CreatedAt returns the value of the "created_at" field in the mutation.
  37403. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  37404. v := m.created_at
  37405. if v == nil {
  37406. return
  37407. }
  37408. return *v, true
  37409. }
  37410. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  37411. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37413. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37414. if !m.op.Is(OpUpdateOne) {
  37415. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37416. }
  37417. if m.id == nil || m.oldValue == nil {
  37418. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37419. }
  37420. oldValue, err := m.oldValue(ctx)
  37421. if err != nil {
  37422. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37423. }
  37424. return oldValue.CreatedAt, nil
  37425. }
  37426. // ResetCreatedAt resets all changes to the "created_at" field.
  37427. func (m *WpChatroomMutation) ResetCreatedAt() {
  37428. m.created_at = nil
  37429. }
  37430. // SetUpdatedAt sets the "updated_at" field.
  37431. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  37432. m.updated_at = &t
  37433. }
  37434. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37435. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  37436. v := m.updated_at
  37437. if v == nil {
  37438. return
  37439. }
  37440. return *v, true
  37441. }
  37442. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  37443. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37445. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37446. if !m.op.Is(OpUpdateOne) {
  37447. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37448. }
  37449. if m.id == nil || m.oldValue == nil {
  37450. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37451. }
  37452. oldValue, err := m.oldValue(ctx)
  37453. if err != nil {
  37454. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37455. }
  37456. return oldValue.UpdatedAt, nil
  37457. }
  37458. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37459. func (m *WpChatroomMutation) ResetUpdatedAt() {
  37460. m.updated_at = nil
  37461. }
  37462. // SetStatus sets the "status" field.
  37463. func (m *WpChatroomMutation) SetStatus(u uint8) {
  37464. m.status = &u
  37465. m.addstatus = nil
  37466. }
  37467. // Status returns the value of the "status" field in the mutation.
  37468. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  37469. v := m.status
  37470. if v == nil {
  37471. return
  37472. }
  37473. return *v, true
  37474. }
  37475. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  37476. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37478. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37479. if !m.op.Is(OpUpdateOne) {
  37480. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37481. }
  37482. if m.id == nil || m.oldValue == nil {
  37483. return v, errors.New("OldStatus requires an ID field in the mutation")
  37484. }
  37485. oldValue, err := m.oldValue(ctx)
  37486. if err != nil {
  37487. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37488. }
  37489. return oldValue.Status, nil
  37490. }
  37491. // AddStatus adds u to the "status" field.
  37492. func (m *WpChatroomMutation) AddStatus(u int8) {
  37493. if m.addstatus != nil {
  37494. *m.addstatus += u
  37495. } else {
  37496. m.addstatus = &u
  37497. }
  37498. }
  37499. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37500. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  37501. v := m.addstatus
  37502. if v == nil {
  37503. return
  37504. }
  37505. return *v, true
  37506. }
  37507. // ClearStatus clears the value of the "status" field.
  37508. func (m *WpChatroomMutation) ClearStatus() {
  37509. m.status = nil
  37510. m.addstatus = nil
  37511. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  37512. }
  37513. // StatusCleared returns if the "status" field was cleared in this mutation.
  37514. func (m *WpChatroomMutation) StatusCleared() bool {
  37515. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  37516. return ok
  37517. }
  37518. // ResetStatus resets all changes to the "status" field.
  37519. func (m *WpChatroomMutation) ResetStatus() {
  37520. m.status = nil
  37521. m.addstatus = nil
  37522. delete(m.clearedFields, wpchatroom.FieldStatus)
  37523. }
  37524. // SetWxWxid sets the "wx_wxid" field.
  37525. func (m *WpChatroomMutation) SetWxWxid(s string) {
  37526. m.wx_wxid = &s
  37527. }
  37528. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  37529. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  37530. v := m.wx_wxid
  37531. if v == nil {
  37532. return
  37533. }
  37534. return *v, true
  37535. }
  37536. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  37537. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37539. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  37540. if !m.op.Is(OpUpdateOne) {
  37541. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  37542. }
  37543. if m.id == nil || m.oldValue == nil {
  37544. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  37545. }
  37546. oldValue, err := m.oldValue(ctx)
  37547. if err != nil {
  37548. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  37549. }
  37550. return oldValue.WxWxid, nil
  37551. }
  37552. // ResetWxWxid resets all changes to the "wx_wxid" field.
  37553. func (m *WpChatroomMutation) ResetWxWxid() {
  37554. m.wx_wxid = nil
  37555. }
  37556. // SetChatroomID sets the "chatroom_id" field.
  37557. func (m *WpChatroomMutation) SetChatroomID(s string) {
  37558. m.chatroom_id = &s
  37559. }
  37560. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  37561. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  37562. v := m.chatroom_id
  37563. if v == nil {
  37564. return
  37565. }
  37566. return *v, true
  37567. }
  37568. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  37569. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37571. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  37572. if !m.op.Is(OpUpdateOne) {
  37573. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  37574. }
  37575. if m.id == nil || m.oldValue == nil {
  37576. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  37577. }
  37578. oldValue, err := m.oldValue(ctx)
  37579. if err != nil {
  37580. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  37581. }
  37582. return oldValue.ChatroomID, nil
  37583. }
  37584. // ResetChatroomID resets all changes to the "chatroom_id" field.
  37585. func (m *WpChatroomMutation) ResetChatroomID() {
  37586. m.chatroom_id = nil
  37587. }
  37588. // SetNickname sets the "nickname" field.
  37589. func (m *WpChatroomMutation) SetNickname(s string) {
  37590. m.nickname = &s
  37591. }
  37592. // Nickname returns the value of the "nickname" field in the mutation.
  37593. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  37594. v := m.nickname
  37595. if v == nil {
  37596. return
  37597. }
  37598. return *v, true
  37599. }
  37600. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  37601. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37603. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  37604. if !m.op.Is(OpUpdateOne) {
  37605. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  37606. }
  37607. if m.id == nil || m.oldValue == nil {
  37608. return v, errors.New("OldNickname requires an ID field in the mutation")
  37609. }
  37610. oldValue, err := m.oldValue(ctx)
  37611. if err != nil {
  37612. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  37613. }
  37614. return oldValue.Nickname, nil
  37615. }
  37616. // ResetNickname resets all changes to the "nickname" field.
  37617. func (m *WpChatroomMutation) ResetNickname() {
  37618. m.nickname = nil
  37619. }
  37620. // SetOwner sets the "owner" field.
  37621. func (m *WpChatroomMutation) SetOwner(s string) {
  37622. m.owner = &s
  37623. }
  37624. // Owner returns the value of the "owner" field in the mutation.
  37625. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  37626. v := m.owner
  37627. if v == nil {
  37628. return
  37629. }
  37630. return *v, true
  37631. }
  37632. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  37633. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37635. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  37636. if !m.op.Is(OpUpdateOne) {
  37637. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  37638. }
  37639. if m.id == nil || m.oldValue == nil {
  37640. return v, errors.New("OldOwner requires an ID field in the mutation")
  37641. }
  37642. oldValue, err := m.oldValue(ctx)
  37643. if err != nil {
  37644. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  37645. }
  37646. return oldValue.Owner, nil
  37647. }
  37648. // ResetOwner resets all changes to the "owner" field.
  37649. func (m *WpChatroomMutation) ResetOwner() {
  37650. m.owner = nil
  37651. }
  37652. // SetAvatar sets the "avatar" field.
  37653. func (m *WpChatroomMutation) SetAvatar(s string) {
  37654. m.avatar = &s
  37655. }
  37656. // Avatar returns the value of the "avatar" field in the mutation.
  37657. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  37658. v := m.avatar
  37659. if v == nil {
  37660. return
  37661. }
  37662. return *v, true
  37663. }
  37664. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  37665. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37667. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  37668. if !m.op.Is(OpUpdateOne) {
  37669. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  37670. }
  37671. if m.id == nil || m.oldValue == nil {
  37672. return v, errors.New("OldAvatar requires an ID field in the mutation")
  37673. }
  37674. oldValue, err := m.oldValue(ctx)
  37675. if err != nil {
  37676. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  37677. }
  37678. return oldValue.Avatar, nil
  37679. }
  37680. // ResetAvatar resets all changes to the "avatar" field.
  37681. func (m *WpChatroomMutation) ResetAvatar() {
  37682. m.avatar = nil
  37683. }
  37684. // SetMemberList sets the "member_list" field.
  37685. func (m *WpChatroomMutation) SetMemberList(s []string) {
  37686. m.member_list = &s
  37687. m.appendmember_list = nil
  37688. }
  37689. // MemberList returns the value of the "member_list" field in the mutation.
  37690. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  37691. v := m.member_list
  37692. if v == nil {
  37693. return
  37694. }
  37695. return *v, true
  37696. }
  37697. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  37698. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  37699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37700. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  37701. if !m.op.Is(OpUpdateOne) {
  37702. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  37703. }
  37704. if m.id == nil || m.oldValue == nil {
  37705. return v, errors.New("OldMemberList requires an ID field in the mutation")
  37706. }
  37707. oldValue, err := m.oldValue(ctx)
  37708. if err != nil {
  37709. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  37710. }
  37711. return oldValue.MemberList, nil
  37712. }
  37713. // AppendMemberList adds s to the "member_list" field.
  37714. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  37715. m.appendmember_list = append(m.appendmember_list, s...)
  37716. }
  37717. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  37718. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  37719. if len(m.appendmember_list) == 0 {
  37720. return nil, false
  37721. }
  37722. return m.appendmember_list, true
  37723. }
  37724. // ResetMemberList resets all changes to the "member_list" field.
  37725. func (m *WpChatroomMutation) ResetMemberList() {
  37726. m.member_list = nil
  37727. m.appendmember_list = nil
  37728. }
  37729. // Where appends a list predicates to the WpChatroomMutation builder.
  37730. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  37731. m.predicates = append(m.predicates, ps...)
  37732. }
  37733. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  37734. // users can use type-assertion to append predicates that do not depend on any generated package.
  37735. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  37736. p := make([]predicate.WpChatroom, len(ps))
  37737. for i := range ps {
  37738. p[i] = ps[i]
  37739. }
  37740. m.Where(p...)
  37741. }
  37742. // Op returns the operation name.
  37743. func (m *WpChatroomMutation) Op() Op {
  37744. return m.op
  37745. }
  37746. // SetOp allows setting the mutation operation.
  37747. func (m *WpChatroomMutation) SetOp(op Op) {
  37748. m.op = op
  37749. }
  37750. // Type returns the node type of this mutation (WpChatroom).
  37751. func (m *WpChatroomMutation) Type() string {
  37752. return m.typ
  37753. }
  37754. // Fields returns all fields that were changed during this mutation. Note that in
  37755. // order to get all numeric fields that were incremented/decremented, call
  37756. // AddedFields().
  37757. func (m *WpChatroomMutation) Fields() []string {
  37758. fields := make([]string, 0, 9)
  37759. if m.created_at != nil {
  37760. fields = append(fields, wpchatroom.FieldCreatedAt)
  37761. }
  37762. if m.updated_at != nil {
  37763. fields = append(fields, wpchatroom.FieldUpdatedAt)
  37764. }
  37765. if m.status != nil {
  37766. fields = append(fields, wpchatroom.FieldStatus)
  37767. }
  37768. if m.wx_wxid != nil {
  37769. fields = append(fields, wpchatroom.FieldWxWxid)
  37770. }
  37771. if m.chatroom_id != nil {
  37772. fields = append(fields, wpchatroom.FieldChatroomID)
  37773. }
  37774. if m.nickname != nil {
  37775. fields = append(fields, wpchatroom.FieldNickname)
  37776. }
  37777. if m.owner != nil {
  37778. fields = append(fields, wpchatroom.FieldOwner)
  37779. }
  37780. if m.avatar != nil {
  37781. fields = append(fields, wpchatroom.FieldAvatar)
  37782. }
  37783. if m.member_list != nil {
  37784. fields = append(fields, wpchatroom.FieldMemberList)
  37785. }
  37786. return fields
  37787. }
  37788. // Field returns the value of a field with the given name. The second boolean
  37789. // return value indicates that this field was not set, or was not defined in the
  37790. // schema.
  37791. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  37792. switch name {
  37793. case wpchatroom.FieldCreatedAt:
  37794. return m.CreatedAt()
  37795. case wpchatroom.FieldUpdatedAt:
  37796. return m.UpdatedAt()
  37797. case wpchatroom.FieldStatus:
  37798. return m.Status()
  37799. case wpchatroom.FieldWxWxid:
  37800. return m.WxWxid()
  37801. case wpchatroom.FieldChatroomID:
  37802. return m.ChatroomID()
  37803. case wpchatroom.FieldNickname:
  37804. return m.Nickname()
  37805. case wpchatroom.FieldOwner:
  37806. return m.Owner()
  37807. case wpchatroom.FieldAvatar:
  37808. return m.Avatar()
  37809. case wpchatroom.FieldMemberList:
  37810. return m.MemberList()
  37811. }
  37812. return nil, false
  37813. }
  37814. // OldField returns the old value of the field from the database. An error is
  37815. // returned if the mutation operation is not UpdateOne, or the query to the
  37816. // database failed.
  37817. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37818. switch name {
  37819. case wpchatroom.FieldCreatedAt:
  37820. return m.OldCreatedAt(ctx)
  37821. case wpchatroom.FieldUpdatedAt:
  37822. return m.OldUpdatedAt(ctx)
  37823. case wpchatroom.FieldStatus:
  37824. return m.OldStatus(ctx)
  37825. case wpchatroom.FieldWxWxid:
  37826. return m.OldWxWxid(ctx)
  37827. case wpchatroom.FieldChatroomID:
  37828. return m.OldChatroomID(ctx)
  37829. case wpchatroom.FieldNickname:
  37830. return m.OldNickname(ctx)
  37831. case wpchatroom.FieldOwner:
  37832. return m.OldOwner(ctx)
  37833. case wpchatroom.FieldAvatar:
  37834. return m.OldAvatar(ctx)
  37835. case wpchatroom.FieldMemberList:
  37836. return m.OldMemberList(ctx)
  37837. }
  37838. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  37839. }
  37840. // SetField sets the value of a field with the given name. It returns an error if
  37841. // the field is not defined in the schema, or if the type mismatched the field
  37842. // type.
  37843. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  37844. switch name {
  37845. case wpchatroom.FieldCreatedAt:
  37846. v, ok := value.(time.Time)
  37847. if !ok {
  37848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37849. }
  37850. m.SetCreatedAt(v)
  37851. return nil
  37852. case wpchatroom.FieldUpdatedAt:
  37853. v, ok := value.(time.Time)
  37854. if !ok {
  37855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37856. }
  37857. m.SetUpdatedAt(v)
  37858. return nil
  37859. case wpchatroom.FieldStatus:
  37860. v, ok := value.(uint8)
  37861. if !ok {
  37862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37863. }
  37864. m.SetStatus(v)
  37865. return nil
  37866. case wpchatroom.FieldWxWxid:
  37867. v, ok := value.(string)
  37868. if !ok {
  37869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37870. }
  37871. m.SetWxWxid(v)
  37872. return nil
  37873. case wpchatroom.FieldChatroomID:
  37874. v, ok := value.(string)
  37875. if !ok {
  37876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37877. }
  37878. m.SetChatroomID(v)
  37879. return nil
  37880. case wpchatroom.FieldNickname:
  37881. v, ok := value.(string)
  37882. if !ok {
  37883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37884. }
  37885. m.SetNickname(v)
  37886. return nil
  37887. case wpchatroom.FieldOwner:
  37888. v, ok := value.(string)
  37889. if !ok {
  37890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37891. }
  37892. m.SetOwner(v)
  37893. return nil
  37894. case wpchatroom.FieldAvatar:
  37895. v, ok := value.(string)
  37896. if !ok {
  37897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37898. }
  37899. m.SetAvatar(v)
  37900. return nil
  37901. case wpchatroom.FieldMemberList:
  37902. v, ok := value.([]string)
  37903. if !ok {
  37904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37905. }
  37906. m.SetMemberList(v)
  37907. return nil
  37908. }
  37909. return fmt.Errorf("unknown WpChatroom field %s", name)
  37910. }
  37911. // AddedFields returns all numeric fields that were incremented/decremented during
  37912. // this mutation.
  37913. func (m *WpChatroomMutation) AddedFields() []string {
  37914. var fields []string
  37915. if m.addstatus != nil {
  37916. fields = append(fields, wpchatroom.FieldStatus)
  37917. }
  37918. return fields
  37919. }
  37920. // AddedField returns the numeric value that was incremented/decremented on a field
  37921. // with the given name. The second boolean return value indicates that this field
  37922. // was not set, or was not defined in the schema.
  37923. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  37924. switch name {
  37925. case wpchatroom.FieldStatus:
  37926. return m.AddedStatus()
  37927. }
  37928. return nil, false
  37929. }
  37930. // AddField adds the value to the field with the given name. It returns an error if
  37931. // the field is not defined in the schema, or if the type mismatched the field
  37932. // type.
  37933. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  37934. switch name {
  37935. case wpchatroom.FieldStatus:
  37936. v, ok := value.(int8)
  37937. if !ok {
  37938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37939. }
  37940. m.AddStatus(v)
  37941. return nil
  37942. }
  37943. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  37944. }
  37945. // ClearedFields returns all nullable fields that were cleared during this
  37946. // mutation.
  37947. func (m *WpChatroomMutation) ClearedFields() []string {
  37948. var fields []string
  37949. if m.FieldCleared(wpchatroom.FieldStatus) {
  37950. fields = append(fields, wpchatroom.FieldStatus)
  37951. }
  37952. return fields
  37953. }
  37954. // FieldCleared returns a boolean indicating if a field with the given name was
  37955. // cleared in this mutation.
  37956. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  37957. _, ok := m.clearedFields[name]
  37958. return ok
  37959. }
  37960. // ClearField clears the value of the field with the given name. It returns an
  37961. // error if the field is not defined in the schema.
  37962. func (m *WpChatroomMutation) ClearField(name string) error {
  37963. switch name {
  37964. case wpchatroom.FieldStatus:
  37965. m.ClearStatus()
  37966. return nil
  37967. }
  37968. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  37969. }
  37970. // ResetField resets all changes in the mutation for the field with the given name.
  37971. // It returns an error if the field is not defined in the schema.
  37972. func (m *WpChatroomMutation) ResetField(name string) error {
  37973. switch name {
  37974. case wpchatroom.FieldCreatedAt:
  37975. m.ResetCreatedAt()
  37976. return nil
  37977. case wpchatroom.FieldUpdatedAt:
  37978. m.ResetUpdatedAt()
  37979. return nil
  37980. case wpchatroom.FieldStatus:
  37981. m.ResetStatus()
  37982. return nil
  37983. case wpchatroom.FieldWxWxid:
  37984. m.ResetWxWxid()
  37985. return nil
  37986. case wpchatroom.FieldChatroomID:
  37987. m.ResetChatroomID()
  37988. return nil
  37989. case wpchatroom.FieldNickname:
  37990. m.ResetNickname()
  37991. return nil
  37992. case wpchatroom.FieldOwner:
  37993. m.ResetOwner()
  37994. return nil
  37995. case wpchatroom.FieldAvatar:
  37996. m.ResetAvatar()
  37997. return nil
  37998. case wpchatroom.FieldMemberList:
  37999. m.ResetMemberList()
  38000. return nil
  38001. }
  38002. return fmt.Errorf("unknown WpChatroom field %s", name)
  38003. }
  38004. // AddedEdges returns all edge names that were set/added in this mutation.
  38005. func (m *WpChatroomMutation) AddedEdges() []string {
  38006. edges := make([]string, 0, 0)
  38007. return edges
  38008. }
  38009. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38010. // name in this mutation.
  38011. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  38012. return nil
  38013. }
  38014. // RemovedEdges returns all edge names that were removed in this mutation.
  38015. func (m *WpChatroomMutation) RemovedEdges() []string {
  38016. edges := make([]string, 0, 0)
  38017. return edges
  38018. }
  38019. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38020. // the given name in this mutation.
  38021. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  38022. return nil
  38023. }
  38024. // ClearedEdges returns all edge names that were cleared in this mutation.
  38025. func (m *WpChatroomMutation) ClearedEdges() []string {
  38026. edges := make([]string, 0, 0)
  38027. return edges
  38028. }
  38029. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38030. // was cleared in this mutation.
  38031. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  38032. return false
  38033. }
  38034. // ClearEdge clears the value of the edge with the given name. It returns an error
  38035. // if that edge is not defined in the schema.
  38036. func (m *WpChatroomMutation) ClearEdge(name string) error {
  38037. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  38038. }
  38039. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38040. // It returns an error if the edge is not defined in the schema.
  38041. func (m *WpChatroomMutation) ResetEdge(name string) error {
  38042. return fmt.Errorf("unknown WpChatroom edge %s", name)
  38043. }
  38044. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  38045. type WpChatroomMemberMutation struct {
  38046. config
  38047. op Op
  38048. typ string
  38049. id *uint64
  38050. created_at *time.Time
  38051. updated_at *time.Time
  38052. status *uint8
  38053. addstatus *int8
  38054. wx_wxid *string
  38055. wxid *string
  38056. nickname *string
  38057. avatar *string
  38058. clearedFields map[string]struct{}
  38059. done bool
  38060. oldValue func(context.Context) (*WpChatroomMember, error)
  38061. predicates []predicate.WpChatroomMember
  38062. }
  38063. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  38064. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  38065. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  38066. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  38067. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  38068. m := &WpChatroomMemberMutation{
  38069. config: c,
  38070. op: op,
  38071. typ: TypeWpChatroomMember,
  38072. clearedFields: make(map[string]struct{}),
  38073. }
  38074. for _, opt := range opts {
  38075. opt(m)
  38076. }
  38077. return m
  38078. }
  38079. // withWpChatroomMemberID sets the ID field of the mutation.
  38080. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  38081. return func(m *WpChatroomMemberMutation) {
  38082. var (
  38083. err error
  38084. once sync.Once
  38085. value *WpChatroomMember
  38086. )
  38087. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  38088. once.Do(func() {
  38089. if m.done {
  38090. err = errors.New("querying old values post mutation is not allowed")
  38091. } else {
  38092. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  38093. }
  38094. })
  38095. return value, err
  38096. }
  38097. m.id = &id
  38098. }
  38099. }
  38100. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  38101. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  38102. return func(m *WpChatroomMemberMutation) {
  38103. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  38104. return node, nil
  38105. }
  38106. m.id = &node.ID
  38107. }
  38108. }
  38109. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38110. // executed in a transaction (ent.Tx), a transactional client is returned.
  38111. func (m WpChatroomMemberMutation) Client() *Client {
  38112. client := &Client{config: m.config}
  38113. client.init()
  38114. return client
  38115. }
  38116. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38117. // it returns an error otherwise.
  38118. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  38119. if _, ok := m.driver.(*txDriver); !ok {
  38120. return nil, errors.New("ent: mutation is not running in a transaction")
  38121. }
  38122. tx := &Tx{config: m.config}
  38123. tx.init()
  38124. return tx, nil
  38125. }
  38126. // SetID sets the value of the id field. Note that this
  38127. // operation is only accepted on creation of WpChatroomMember entities.
  38128. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  38129. m.id = &id
  38130. }
  38131. // ID returns the ID value in the mutation. Note that the ID is only available
  38132. // if it was provided to the builder or after it was returned from the database.
  38133. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  38134. if m.id == nil {
  38135. return
  38136. }
  38137. return *m.id, true
  38138. }
  38139. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38140. // That means, if the mutation is applied within a transaction with an isolation level such
  38141. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38142. // or updated by the mutation.
  38143. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  38144. switch {
  38145. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38146. id, exists := m.ID()
  38147. if exists {
  38148. return []uint64{id}, nil
  38149. }
  38150. fallthrough
  38151. case m.op.Is(OpUpdate | OpDelete):
  38152. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  38153. default:
  38154. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38155. }
  38156. }
  38157. // SetCreatedAt sets the "created_at" field.
  38158. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  38159. m.created_at = &t
  38160. }
  38161. // CreatedAt returns the value of the "created_at" field in the mutation.
  38162. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  38163. v := m.created_at
  38164. if v == nil {
  38165. return
  38166. }
  38167. return *v, true
  38168. }
  38169. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  38170. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38172. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38173. if !m.op.Is(OpUpdateOne) {
  38174. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38175. }
  38176. if m.id == nil || m.oldValue == nil {
  38177. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38178. }
  38179. oldValue, err := m.oldValue(ctx)
  38180. if err != nil {
  38181. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38182. }
  38183. return oldValue.CreatedAt, nil
  38184. }
  38185. // ResetCreatedAt resets all changes to the "created_at" field.
  38186. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  38187. m.created_at = nil
  38188. }
  38189. // SetUpdatedAt sets the "updated_at" field.
  38190. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  38191. m.updated_at = &t
  38192. }
  38193. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38194. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  38195. v := m.updated_at
  38196. if v == nil {
  38197. return
  38198. }
  38199. return *v, true
  38200. }
  38201. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  38202. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38204. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38205. if !m.op.Is(OpUpdateOne) {
  38206. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38207. }
  38208. if m.id == nil || m.oldValue == nil {
  38209. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38210. }
  38211. oldValue, err := m.oldValue(ctx)
  38212. if err != nil {
  38213. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38214. }
  38215. return oldValue.UpdatedAt, nil
  38216. }
  38217. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38218. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  38219. m.updated_at = nil
  38220. }
  38221. // SetStatus sets the "status" field.
  38222. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  38223. m.status = &u
  38224. m.addstatus = nil
  38225. }
  38226. // Status returns the value of the "status" field in the mutation.
  38227. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  38228. v := m.status
  38229. if v == nil {
  38230. return
  38231. }
  38232. return *v, true
  38233. }
  38234. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  38235. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38237. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38238. if !m.op.Is(OpUpdateOne) {
  38239. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38240. }
  38241. if m.id == nil || m.oldValue == nil {
  38242. return v, errors.New("OldStatus requires an ID field in the mutation")
  38243. }
  38244. oldValue, err := m.oldValue(ctx)
  38245. if err != nil {
  38246. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38247. }
  38248. return oldValue.Status, nil
  38249. }
  38250. // AddStatus adds u to the "status" field.
  38251. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  38252. if m.addstatus != nil {
  38253. *m.addstatus += u
  38254. } else {
  38255. m.addstatus = &u
  38256. }
  38257. }
  38258. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38259. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  38260. v := m.addstatus
  38261. if v == nil {
  38262. return
  38263. }
  38264. return *v, true
  38265. }
  38266. // ClearStatus clears the value of the "status" field.
  38267. func (m *WpChatroomMemberMutation) ClearStatus() {
  38268. m.status = nil
  38269. m.addstatus = nil
  38270. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  38271. }
  38272. // StatusCleared returns if the "status" field was cleared in this mutation.
  38273. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  38274. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  38275. return ok
  38276. }
  38277. // ResetStatus resets all changes to the "status" field.
  38278. func (m *WpChatroomMemberMutation) ResetStatus() {
  38279. m.status = nil
  38280. m.addstatus = nil
  38281. delete(m.clearedFields, wpchatroommember.FieldStatus)
  38282. }
  38283. // SetWxWxid sets the "wx_wxid" field.
  38284. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  38285. m.wx_wxid = &s
  38286. }
  38287. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  38288. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  38289. v := m.wx_wxid
  38290. if v == nil {
  38291. return
  38292. }
  38293. return *v, true
  38294. }
  38295. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  38296. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38298. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  38299. if !m.op.Is(OpUpdateOne) {
  38300. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  38301. }
  38302. if m.id == nil || m.oldValue == nil {
  38303. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  38304. }
  38305. oldValue, err := m.oldValue(ctx)
  38306. if err != nil {
  38307. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  38308. }
  38309. return oldValue.WxWxid, nil
  38310. }
  38311. // ResetWxWxid resets all changes to the "wx_wxid" field.
  38312. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  38313. m.wx_wxid = nil
  38314. }
  38315. // SetWxid sets the "wxid" field.
  38316. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  38317. m.wxid = &s
  38318. }
  38319. // Wxid returns the value of the "wxid" field in the mutation.
  38320. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  38321. v := m.wxid
  38322. if v == nil {
  38323. return
  38324. }
  38325. return *v, true
  38326. }
  38327. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  38328. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38330. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  38331. if !m.op.Is(OpUpdateOne) {
  38332. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  38333. }
  38334. if m.id == nil || m.oldValue == nil {
  38335. return v, errors.New("OldWxid requires an ID field in the mutation")
  38336. }
  38337. oldValue, err := m.oldValue(ctx)
  38338. if err != nil {
  38339. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  38340. }
  38341. return oldValue.Wxid, nil
  38342. }
  38343. // ResetWxid resets all changes to the "wxid" field.
  38344. func (m *WpChatroomMemberMutation) ResetWxid() {
  38345. m.wxid = nil
  38346. }
  38347. // SetNickname sets the "nickname" field.
  38348. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  38349. m.nickname = &s
  38350. }
  38351. // Nickname returns the value of the "nickname" field in the mutation.
  38352. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  38353. v := m.nickname
  38354. if v == nil {
  38355. return
  38356. }
  38357. return *v, true
  38358. }
  38359. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  38360. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38362. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  38363. if !m.op.Is(OpUpdateOne) {
  38364. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  38365. }
  38366. if m.id == nil || m.oldValue == nil {
  38367. return v, errors.New("OldNickname requires an ID field in the mutation")
  38368. }
  38369. oldValue, err := m.oldValue(ctx)
  38370. if err != nil {
  38371. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  38372. }
  38373. return oldValue.Nickname, nil
  38374. }
  38375. // ResetNickname resets all changes to the "nickname" field.
  38376. func (m *WpChatroomMemberMutation) ResetNickname() {
  38377. m.nickname = nil
  38378. }
  38379. // SetAvatar sets the "avatar" field.
  38380. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  38381. m.avatar = &s
  38382. }
  38383. // Avatar returns the value of the "avatar" field in the mutation.
  38384. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  38385. v := m.avatar
  38386. if v == nil {
  38387. return
  38388. }
  38389. return *v, true
  38390. }
  38391. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  38392. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  38393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38394. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  38395. if !m.op.Is(OpUpdateOne) {
  38396. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  38397. }
  38398. if m.id == nil || m.oldValue == nil {
  38399. return v, errors.New("OldAvatar requires an ID field in the mutation")
  38400. }
  38401. oldValue, err := m.oldValue(ctx)
  38402. if err != nil {
  38403. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  38404. }
  38405. return oldValue.Avatar, nil
  38406. }
  38407. // ResetAvatar resets all changes to the "avatar" field.
  38408. func (m *WpChatroomMemberMutation) ResetAvatar() {
  38409. m.avatar = nil
  38410. }
  38411. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  38412. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  38413. m.predicates = append(m.predicates, ps...)
  38414. }
  38415. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  38416. // users can use type-assertion to append predicates that do not depend on any generated package.
  38417. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  38418. p := make([]predicate.WpChatroomMember, len(ps))
  38419. for i := range ps {
  38420. p[i] = ps[i]
  38421. }
  38422. m.Where(p...)
  38423. }
  38424. // Op returns the operation name.
  38425. func (m *WpChatroomMemberMutation) Op() Op {
  38426. return m.op
  38427. }
  38428. // SetOp allows setting the mutation operation.
  38429. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  38430. m.op = op
  38431. }
  38432. // Type returns the node type of this mutation (WpChatroomMember).
  38433. func (m *WpChatroomMemberMutation) Type() string {
  38434. return m.typ
  38435. }
  38436. // Fields returns all fields that were changed during this mutation. Note that in
  38437. // order to get all numeric fields that were incremented/decremented, call
  38438. // AddedFields().
  38439. func (m *WpChatroomMemberMutation) Fields() []string {
  38440. fields := make([]string, 0, 7)
  38441. if m.created_at != nil {
  38442. fields = append(fields, wpchatroommember.FieldCreatedAt)
  38443. }
  38444. if m.updated_at != nil {
  38445. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  38446. }
  38447. if m.status != nil {
  38448. fields = append(fields, wpchatroommember.FieldStatus)
  38449. }
  38450. if m.wx_wxid != nil {
  38451. fields = append(fields, wpchatroommember.FieldWxWxid)
  38452. }
  38453. if m.wxid != nil {
  38454. fields = append(fields, wpchatroommember.FieldWxid)
  38455. }
  38456. if m.nickname != nil {
  38457. fields = append(fields, wpchatroommember.FieldNickname)
  38458. }
  38459. if m.avatar != nil {
  38460. fields = append(fields, wpchatroommember.FieldAvatar)
  38461. }
  38462. return fields
  38463. }
  38464. // Field returns the value of a field with the given name. The second boolean
  38465. // return value indicates that this field was not set, or was not defined in the
  38466. // schema.
  38467. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  38468. switch name {
  38469. case wpchatroommember.FieldCreatedAt:
  38470. return m.CreatedAt()
  38471. case wpchatroommember.FieldUpdatedAt:
  38472. return m.UpdatedAt()
  38473. case wpchatroommember.FieldStatus:
  38474. return m.Status()
  38475. case wpchatroommember.FieldWxWxid:
  38476. return m.WxWxid()
  38477. case wpchatroommember.FieldWxid:
  38478. return m.Wxid()
  38479. case wpchatroommember.FieldNickname:
  38480. return m.Nickname()
  38481. case wpchatroommember.FieldAvatar:
  38482. return m.Avatar()
  38483. }
  38484. return nil, false
  38485. }
  38486. // OldField returns the old value of the field from the database. An error is
  38487. // returned if the mutation operation is not UpdateOne, or the query to the
  38488. // database failed.
  38489. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38490. switch name {
  38491. case wpchatroommember.FieldCreatedAt:
  38492. return m.OldCreatedAt(ctx)
  38493. case wpchatroommember.FieldUpdatedAt:
  38494. return m.OldUpdatedAt(ctx)
  38495. case wpchatroommember.FieldStatus:
  38496. return m.OldStatus(ctx)
  38497. case wpchatroommember.FieldWxWxid:
  38498. return m.OldWxWxid(ctx)
  38499. case wpchatroommember.FieldWxid:
  38500. return m.OldWxid(ctx)
  38501. case wpchatroommember.FieldNickname:
  38502. return m.OldNickname(ctx)
  38503. case wpchatroommember.FieldAvatar:
  38504. return m.OldAvatar(ctx)
  38505. }
  38506. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  38507. }
  38508. // SetField sets the value of a field with the given name. It returns an error if
  38509. // the field is not defined in the schema, or if the type mismatched the field
  38510. // type.
  38511. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  38512. switch name {
  38513. case wpchatroommember.FieldCreatedAt:
  38514. v, ok := value.(time.Time)
  38515. if !ok {
  38516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38517. }
  38518. m.SetCreatedAt(v)
  38519. return nil
  38520. case wpchatroommember.FieldUpdatedAt:
  38521. v, ok := value.(time.Time)
  38522. if !ok {
  38523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38524. }
  38525. m.SetUpdatedAt(v)
  38526. return nil
  38527. case wpchatroommember.FieldStatus:
  38528. v, ok := value.(uint8)
  38529. if !ok {
  38530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38531. }
  38532. m.SetStatus(v)
  38533. return nil
  38534. case wpchatroommember.FieldWxWxid:
  38535. v, ok := value.(string)
  38536. if !ok {
  38537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38538. }
  38539. m.SetWxWxid(v)
  38540. return nil
  38541. case wpchatroommember.FieldWxid:
  38542. v, ok := value.(string)
  38543. if !ok {
  38544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38545. }
  38546. m.SetWxid(v)
  38547. return nil
  38548. case wpchatroommember.FieldNickname:
  38549. v, ok := value.(string)
  38550. if !ok {
  38551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38552. }
  38553. m.SetNickname(v)
  38554. return nil
  38555. case wpchatroommember.FieldAvatar:
  38556. v, ok := value.(string)
  38557. if !ok {
  38558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38559. }
  38560. m.SetAvatar(v)
  38561. return nil
  38562. }
  38563. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  38564. }
  38565. // AddedFields returns all numeric fields that were incremented/decremented during
  38566. // this mutation.
  38567. func (m *WpChatroomMemberMutation) AddedFields() []string {
  38568. var fields []string
  38569. if m.addstatus != nil {
  38570. fields = append(fields, wpchatroommember.FieldStatus)
  38571. }
  38572. return fields
  38573. }
  38574. // AddedField returns the numeric value that was incremented/decremented on a field
  38575. // with the given name. The second boolean return value indicates that this field
  38576. // was not set, or was not defined in the schema.
  38577. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  38578. switch name {
  38579. case wpchatroommember.FieldStatus:
  38580. return m.AddedStatus()
  38581. }
  38582. return nil, false
  38583. }
  38584. // AddField adds the value to the field with the given name. It returns an error if
  38585. // the field is not defined in the schema, or if the type mismatched the field
  38586. // type.
  38587. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  38588. switch name {
  38589. case wpchatroommember.FieldStatus:
  38590. v, ok := value.(int8)
  38591. if !ok {
  38592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38593. }
  38594. m.AddStatus(v)
  38595. return nil
  38596. }
  38597. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  38598. }
  38599. // ClearedFields returns all nullable fields that were cleared during this
  38600. // mutation.
  38601. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  38602. var fields []string
  38603. if m.FieldCleared(wpchatroommember.FieldStatus) {
  38604. fields = append(fields, wpchatroommember.FieldStatus)
  38605. }
  38606. return fields
  38607. }
  38608. // FieldCleared returns a boolean indicating if a field with the given name was
  38609. // cleared in this mutation.
  38610. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  38611. _, ok := m.clearedFields[name]
  38612. return ok
  38613. }
  38614. // ClearField clears the value of the field with the given name. It returns an
  38615. // error if the field is not defined in the schema.
  38616. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  38617. switch name {
  38618. case wpchatroommember.FieldStatus:
  38619. m.ClearStatus()
  38620. return nil
  38621. }
  38622. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  38623. }
  38624. // ResetField resets all changes in the mutation for the field with the given name.
  38625. // It returns an error if the field is not defined in the schema.
  38626. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  38627. switch name {
  38628. case wpchatroommember.FieldCreatedAt:
  38629. m.ResetCreatedAt()
  38630. return nil
  38631. case wpchatroommember.FieldUpdatedAt:
  38632. m.ResetUpdatedAt()
  38633. return nil
  38634. case wpchatroommember.FieldStatus:
  38635. m.ResetStatus()
  38636. return nil
  38637. case wpchatroommember.FieldWxWxid:
  38638. m.ResetWxWxid()
  38639. return nil
  38640. case wpchatroommember.FieldWxid:
  38641. m.ResetWxid()
  38642. return nil
  38643. case wpchatroommember.FieldNickname:
  38644. m.ResetNickname()
  38645. return nil
  38646. case wpchatroommember.FieldAvatar:
  38647. m.ResetAvatar()
  38648. return nil
  38649. }
  38650. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  38651. }
  38652. // AddedEdges returns all edge names that were set/added in this mutation.
  38653. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  38654. edges := make([]string, 0, 0)
  38655. return edges
  38656. }
  38657. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38658. // name in this mutation.
  38659. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  38660. return nil
  38661. }
  38662. // RemovedEdges returns all edge names that were removed in this mutation.
  38663. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  38664. edges := make([]string, 0, 0)
  38665. return edges
  38666. }
  38667. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38668. // the given name in this mutation.
  38669. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  38670. return nil
  38671. }
  38672. // ClearedEdges returns all edge names that were cleared in this mutation.
  38673. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  38674. edges := make([]string, 0, 0)
  38675. return edges
  38676. }
  38677. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38678. // was cleared in this mutation.
  38679. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  38680. return false
  38681. }
  38682. // ClearEdge clears the value of the edge with the given name. It returns an error
  38683. // if that edge is not defined in the schema.
  38684. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  38685. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  38686. }
  38687. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38688. // It returns an error if the edge is not defined in the schema.
  38689. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  38690. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  38691. }
  38692. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  38693. type WxMutation struct {
  38694. config
  38695. op Op
  38696. typ string
  38697. id *uint64
  38698. created_at *time.Time
  38699. updated_at *time.Time
  38700. status *uint8
  38701. addstatus *int8
  38702. deleted_at *time.Time
  38703. port *string
  38704. process_id *string
  38705. callback *string
  38706. wxid *string
  38707. account *string
  38708. nickname *string
  38709. tel *string
  38710. head_big *string
  38711. organization_id *uint64
  38712. addorganization_id *int64
  38713. api_base *string
  38714. api_key *string
  38715. allow_list *[]string
  38716. appendallow_list []string
  38717. group_allow_list *[]string
  38718. appendgroup_allow_list []string
  38719. block_list *[]string
  38720. appendblock_list []string
  38721. group_block_list *[]string
  38722. appendgroup_block_list []string
  38723. clearedFields map[string]struct{}
  38724. server *uint64
  38725. clearedserver bool
  38726. agent *uint64
  38727. clearedagent bool
  38728. done bool
  38729. oldValue func(context.Context) (*Wx, error)
  38730. predicates []predicate.Wx
  38731. }
  38732. var _ ent.Mutation = (*WxMutation)(nil)
  38733. // wxOption allows management of the mutation configuration using functional options.
  38734. type wxOption func(*WxMutation)
  38735. // newWxMutation creates new mutation for the Wx entity.
  38736. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  38737. m := &WxMutation{
  38738. config: c,
  38739. op: op,
  38740. typ: TypeWx,
  38741. clearedFields: make(map[string]struct{}),
  38742. }
  38743. for _, opt := range opts {
  38744. opt(m)
  38745. }
  38746. return m
  38747. }
  38748. // withWxID sets the ID field of the mutation.
  38749. func withWxID(id uint64) wxOption {
  38750. return func(m *WxMutation) {
  38751. var (
  38752. err error
  38753. once sync.Once
  38754. value *Wx
  38755. )
  38756. m.oldValue = func(ctx context.Context) (*Wx, error) {
  38757. once.Do(func() {
  38758. if m.done {
  38759. err = errors.New("querying old values post mutation is not allowed")
  38760. } else {
  38761. value, err = m.Client().Wx.Get(ctx, id)
  38762. }
  38763. })
  38764. return value, err
  38765. }
  38766. m.id = &id
  38767. }
  38768. }
  38769. // withWx sets the old Wx of the mutation.
  38770. func withWx(node *Wx) wxOption {
  38771. return func(m *WxMutation) {
  38772. m.oldValue = func(context.Context) (*Wx, error) {
  38773. return node, nil
  38774. }
  38775. m.id = &node.ID
  38776. }
  38777. }
  38778. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38779. // executed in a transaction (ent.Tx), a transactional client is returned.
  38780. func (m WxMutation) Client() *Client {
  38781. client := &Client{config: m.config}
  38782. client.init()
  38783. return client
  38784. }
  38785. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38786. // it returns an error otherwise.
  38787. func (m WxMutation) Tx() (*Tx, error) {
  38788. if _, ok := m.driver.(*txDriver); !ok {
  38789. return nil, errors.New("ent: mutation is not running in a transaction")
  38790. }
  38791. tx := &Tx{config: m.config}
  38792. tx.init()
  38793. return tx, nil
  38794. }
  38795. // SetID sets the value of the id field. Note that this
  38796. // operation is only accepted on creation of Wx entities.
  38797. func (m *WxMutation) SetID(id uint64) {
  38798. m.id = &id
  38799. }
  38800. // ID returns the ID value in the mutation. Note that the ID is only available
  38801. // if it was provided to the builder or after it was returned from the database.
  38802. func (m *WxMutation) ID() (id uint64, exists bool) {
  38803. if m.id == nil {
  38804. return
  38805. }
  38806. return *m.id, true
  38807. }
  38808. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38809. // That means, if the mutation is applied within a transaction with an isolation level such
  38810. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38811. // or updated by the mutation.
  38812. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  38813. switch {
  38814. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38815. id, exists := m.ID()
  38816. if exists {
  38817. return []uint64{id}, nil
  38818. }
  38819. fallthrough
  38820. case m.op.Is(OpUpdate | OpDelete):
  38821. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  38822. default:
  38823. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38824. }
  38825. }
  38826. // SetCreatedAt sets the "created_at" field.
  38827. func (m *WxMutation) SetCreatedAt(t time.Time) {
  38828. m.created_at = &t
  38829. }
  38830. // CreatedAt returns the value of the "created_at" field in the mutation.
  38831. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  38832. v := m.created_at
  38833. if v == nil {
  38834. return
  38835. }
  38836. return *v, true
  38837. }
  38838. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  38839. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38841. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38842. if !m.op.Is(OpUpdateOne) {
  38843. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38844. }
  38845. if m.id == nil || m.oldValue == nil {
  38846. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38847. }
  38848. oldValue, err := m.oldValue(ctx)
  38849. if err != nil {
  38850. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38851. }
  38852. return oldValue.CreatedAt, nil
  38853. }
  38854. // ResetCreatedAt resets all changes to the "created_at" field.
  38855. func (m *WxMutation) ResetCreatedAt() {
  38856. m.created_at = nil
  38857. }
  38858. // SetUpdatedAt sets the "updated_at" field.
  38859. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  38860. m.updated_at = &t
  38861. }
  38862. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38863. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  38864. v := m.updated_at
  38865. if v == nil {
  38866. return
  38867. }
  38868. return *v, true
  38869. }
  38870. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  38871. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38873. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38874. if !m.op.Is(OpUpdateOne) {
  38875. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38876. }
  38877. if m.id == nil || m.oldValue == nil {
  38878. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38879. }
  38880. oldValue, err := m.oldValue(ctx)
  38881. if err != nil {
  38882. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38883. }
  38884. return oldValue.UpdatedAt, nil
  38885. }
  38886. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38887. func (m *WxMutation) ResetUpdatedAt() {
  38888. m.updated_at = nil
  38889. }
  38890. // SetStatus sets the "status" field.
  38891. func (m *WxMutation) SetStatus(u uint8) {
  38892. m.status = &u
  38893. m.addstatus = nil
  38894. }
  38895. // Status returns the value of the "status" field in the mutation.
  38896. func (m *WxMutation) Status() (r uint8, exists bool) {
  38897. v := m.status
  38898. if v == nil {
  38899. return
  38900. }
  38901. return *v, true
  38902. }
  38903. // OldStatus returns the old "status" field's value of the Wx entity.
  38904. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38906. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38907. if !m.op.Is(OpUpdateOne) {
  38908. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38909. }
  38910. if m.id == nil || m.oldValue == nil {
  38911. return v, errors.New("OldStatus requires an ID field in the mutation")
  38912. }
  38913. oldValue, err := m.oldValue(ctx)
  38914. if err != nil {
  38915. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38916. }
  38917. return oldValue.Status, nil
  38918. }
  38919. // AddStatus adds u to the "status" field.
  38920. func (m *WxMutation) AddStatus(u int8) {
  38921. if m.addstatus != nil {
  38922. *m.addstatus += u
  38923. } else {
  38924. m.addstatus = &u
  38925. }
  38926. }
  38927. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38928. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  38929. v := m.addstatus
  38930. if v == nil {
  38931. return
  38932. }
  38933. return *v, true
  38934. }
  38935. // ClearStatus clears the value of the "status" field.
  38936. func (m *WxMutation) ClearStatus() {
  38937. m.status = nil
  38938. m.addstatus = nil
  38939. m.clearedFields[wx.FieldStatus] = struct{}{}
  38940. }
  38941. // StatusCleared returns if the "status" field was cleared in this mutation.
  38942. func (m *WxMutation) StatusCleared() bool {
  38943. _, ok := m.clearedFields[wx.FieldStatus]
  38944. return ok
  38945. }
  38946. // ResetStatus resets all changes to the "status" field.
  38947. func (m *WxMutation) ResetStatus() {
  38948. m.status = nil
  38949. m.addstatus = nil
  38950. delete(m.clearedFields, wx.FieldStatus)
  38951. }
  38952. // SetDeletedAt sets the "deleted_at" field.
  38953. func (m *WxMutation) SetDeletedAt(t time.Time) {
  38954. m.deleted_at = &t
  38955. }
  38956. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38957. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  38958. v := m.deleted_at
  38959. if v == nil {
  38960. return
  38961. }
  38962. return *v, true
  38963. }
  38964. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  38965. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38967. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38968. if !m.op.Is(OpUpdateOne) {
  38969. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38970. }
  38971. if m.id == nil || m.oldValue == nil {
  38972. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38973. }
  38974. oldValue, err := m.oldValue(ctx)
  38975. if err != nil {
  38976. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38977. }
  38978. return oldValue.DeletedAt, nil
  38979. }
  38980. // ClearDeletedAt clears the value of the "deleted_at" field.
  38981. func (m *WxMutation) ClearDeletedAt() {
  38982. m.deleted_at = nil
  38983. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  38984. }
  38985. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38986. func (m *WxMutation) DeletedAtCleared() bool {
  38987. _, ok := m.clearedFields[wx.FieldDeletedAt]
  38988. return ok
  38989. }
  38990. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38991. func (m *WxMutation) ResetDeletedAt() {
  38992. m.deleted_at = nil
  38993. delete(m.clearedFields, wx.FieldDeletedAt)
  38994. }
  38995. // SetServerID sets the "server_id" field.
  38996. func (m *WxMutation) SetServerID(u uint64) {
  38997. m.server = &u
  38998. }
  38999. // ServerID returns the value of the "server_id" field in the mutation.
  39000. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  39001. v := m.server
  39002. if v == nil {
  39003. return
  39004. }
  39005. return *v, true
  39006. }
  39007. // OldServerID returns the old "server_id" field's value of the Wx entity.
  39008. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39010. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  39011. if !m.op.Is(OpUpdateOne) {
  39012. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  39013. }
  39014. if m.id == nil || m.oldValue == nil {
  39015. return v, errors.New("OldServerID requires an ID field in the mutation")
  39016. }
  39017. oldValue, err := m.oldValue(ctx)
  39018. if err != nil {
  39019. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  39020. }
  39021. return oldValue.ServerID, nil
  39022. }
  39023. // ClearServerID clears the value of the "server_id" field.
  39024. func (m *WxMutation) ClearServerID() {
  39025. m.server = nil
  39026. m.clearedFields[wx.FieldServerID] = struct{}{}
  39027. }
  39028. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  39029. func (m *WxMutation) ServerIDCleared() bool {
  39030. _, ok := m.clearedFields[wx.FieldServerID]
  39031. return ok
  39032. }
  39033. // ResetServerID resets all changes to the "server_id" field.
  39034. func (m *WxMutation) ResetServerID() {
  39035. m.server = nil
  39036. delete(m.clearedFields, wx.FieldServerID)
  39037. }
  39038. // SetPort sets the "port" field.
  39039. func (m *WxMutation) SetPort(s string) {
  39040. m.port = &s
  39041. }
  39042. // Port returns the value of the "port" field in the mutation.
  39043. func (m *WxMutation) Port() (r string, exists bool) {
  39044. v := m.port
  39045. if v == nil {
  39046. return
  39047. }
  39048. return *v, true
  39049. }
  39050. // OldPort returns the old "port" field's value of the Wx entity.
  39051. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39053. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  39054. if !m.op.Is(OpUpdateOne) {
  39055. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  39056. }
  39057. if m.id == nil || m.oldValue == nil {
  39058. return v, errors.New("OldPort requires an ID field in the mutation")
  39059. }
  39060. oldValue, err := m.oldValue(ctx)
  39061. if err != nil {
  39062. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  39063. }
  39064. return oldValue.Port, nil
  39065. }
  39066. // ResetPort resets all changes to the "port" field.
  39067. func (m *WxMutation) ResetPort() {
  39068. m.port = nil
  39069. }
  39070. // SetProcessID sets the "process_id" field.
  39071. func (m *WxMutation) SetProcessID(s string) {
  39072. m.process_id = &s
  39073. }
  39074. // ProcessID returns the value of the "process_id" field in the mutation.
  39075. func (m *WxMutation) ProcessID() (r string, exists bool) {
  39076. v := m.process_id
  39077. if v == nil {
  39078. return
  39079. }
  39080. return *v, true
  39081. }
  39082. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  39083. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39085. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  39086. if !m.op.Is(OpUpdateOne) {
  39087. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  39088. }
  39089. if m.id == nil || m.oldValue == nil {
  39090. return v, errors.New("OldProcessID requires an ID field in the mutation")
  39091. }
  39092. oldValue, err := m.oldValue(ctx)
  39093. if err != nil {
  39094. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  39095. }
  39096. return oldValue.ProcessID, nil
  39097. }
  39098. // ResetProcessID resets all changes to the "process_id" field.
  39099. func (m *WxMutation) ResetProcessID() {
  39100. m.process_id = nil
  39101. }
  39102. // SetCallback sets the "callback" field.
  39103. func (m *WxMutation) SetCallback(s string) {
  39104. m.callback = &s
  39105. }
  39106. // Callback returns the value of the "callback" field in the mutation.
  39107. func (m *WxMutation) Callback() (r string, exists bool) {
  39108. v := m.callback
  39109. if v == nil {
  39110. return
  39111. }
  39112. return *v, true
  39113. }
  39114. // OldCallback returns the old "callback" field's value of the Wx entity.
  39115. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39117. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  39118. if !m.op.Is(OpUpdateOne) {
  39119. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  39120. }
  39121. if m.id == nil || m.oldValue == nil {
  39122. return v, errors.New("OldCallback requires an ID field in the mutation")
  39123. }
  39124. oldValue, err := m.oldValue(ctx)
  39125. if err != nil {
  39126. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  39127. }
  39128. return oldValue.Callback, nil
  39129. }
  39130. // ResetCallback resets all changes to the "callback" field.
  39131. func (m *WxMutation) ResetCallback() {
  39132. m.callback = nil
  39133. }
  39134. // SetWxid sets the "wxid" field.
  39135. func (m *WxMutation) SetWxid(s string) {
  39136. m.wxid = &s
  39137. }
  39138. // Wxid returns the value of the "wxid" field in the mutation.
  39139. func (m *WxMutation) Wxid() (r string, exists bool) {
  39140. v := m.wxid
  39141. if v == nil {
  39142. return
  39143. }
  39144. return *v, true
  39145. }
  39146. // OldWxid returns the old "wxid" field's value of the Wx entity.
  39147. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39149. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  39150. if !m.op.Is(OpUpdateOne) {
  39151. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  39152. }
  39153. if m.id == nil || m.oldValue == nil {
  39154. return v, errors.New("OldWxid requires an ID field in the mutation")
  39155. }
  39156. oldValue, err := m.oldValue(ctx)
  39157. if err != nil {
  39158. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  39159. }
  39160. return oldValue.Wxid, nil
  39161. }
  39162. // ResetWxid resets all changes to the "wxid" field.
  39163. func (m *WxMutation) ResetWxid() {
  39164. m.wxid = nil
  39165. }
  39166. // SetAccount sets the "account" field.
  39167. func (m *WxMutation) SetAccount(s string) {
  39168. m.account = &s
  39169. }
  39170. // Account returns the value of the "account" field in the mutation.
  39171. func (m *WxMutation) Account() (r string, exists bool) {
  39172. v := m.account
  39173. if v == nil {
  39174. return
  39175. }
  39176. return *v, true
  39177. }
  39178. // OldAccount returns the old "account" field's value of the Wx entity.
  39179. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39181. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  39182. if !m.op.Is(OpUpdateOne) {
  39183. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  39184. }
  39185. if m.id == nil || m.oldValue == nil {
  39186. return v, errors.New("OldAccount requires an ID field in the mutation")
  39187. }
  39188. oldValue, err := m.oldValue(ctx)
  39189. if err != nil {
  39190. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  39191. }
  39192. return oldValue.Account, nil
  39193. }
  39194. // ResetAccount resets all changes to the "account" field.
  39195. func (m *WxMutation) ResetAccount() {
  39196. m.account = nil
  39197. }
  39198. // SetNickname sets the "nickname" field.
  39199. func (m *WxMutation) SetNickname(s string) {
  39200. m.nickname = &s
  39201. }
  39202. // Nickname returns the value of the "nickname" field in the mutation.
  39203. func (m *WxMutation) Nickname() (r string, exists bool) {
  39204. v := m.nickname
  39205. if v == nil {
  39206. return
  39207. }
  39208. return *v, true
  39209. }
  39210. // OldNickname returns the old "nickname" field's value of the Wx entity.
  39211. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39213. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  39214. if !m.op.Is(OpUpdateOne) {
  39215. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39216. }
  39217. if m.id == nil || m.oldValue == nil {
  39218. return v, errors.New("OldNickname requires an ID field in the mutation")
  39219. }
  39220. oldValue, err := m.oldValue(ctx)
  39221. if err != nil {
  39222. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39223. }
  39224. return oldValue.Nickname, nil
  39225. }
  39226. // ResetNickname resets all changes to the "nickname" field.
  39227. func (m *WxMutation) ResetNickname() {
  39228. m.nickname = nil
  39229. }
  39230. // SetTel sets the "tel" field.
  39231. func (m *WxMutation) SetTel(s string) {
  39232. m.tel = &s
  39233. }
  39234. // Tel returns the value of the "tel" field in the mutation.
  39235. func (m *WxMutation) Tel() (r string, exists bool) {
  39236. v := m.tel
  39237. if v == nil {
  39238. return
  39239. }
  39240. return *v, true
  39241. }
  39242. // OldTel returns the old "tel" field's value of the Wx entity.
  39243. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39245. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  39246. if !m.op.Is(OpUpdateOne) {
  39247. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  39248. }
  39249. if m.id == nil || m.oldValue == nil {
  39250. return v, errors.New("OldTel requires an ID field in the mutation")
  39251. }
  39252. oldValue, err := m.oldValue(ctx)
  39253. if err != nil {
  39254. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  39255. }
  39256. return oldValue.Tel, nil
  39257. }
  39258. // ResetTel resets all changes to the "tel" field.
  39259. func (m *WxMutation) ResetTel() {
  39260. m.tel = nil
  39261. }
  39262. // SetHeadBig sets the "head_big" field.
  39263. func (m *WxMutation) SetHeadBig(s string) {
  39264. m.head_big = &s
  39265. }
  39266. // HeadBig returns the value of the "head_big" field in the mutation.
  39267. func (m *WxMutation) HeadBig() (r string, exists bool) {
  39268. v := m.head_big
  39269. if v == nil {
  39270. return
  39271. }
  39272. return *v, true
  39273. }
  39274. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  39275. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39277. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  39278. if !m.op.Is(OpUpdateOne) {
  39279. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  39280. }
  39281. if m.id == nil || m.oldValue == nil {
  39282. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  39283. }
  39284. oldValue, err := m.oldValue(ctx)
  39285. if err != nil {
  39286. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  39287. }
  39288. return oldValue.HeadBig, nil
  39289. }
  39290. // ResetHeadBig resets all changes to the "head_big" field.
  39291. func (m *WxMutation) ResetHeadBig() {
  39292. m.head_big = nil
  39293. }
  39294. // SetOrganizationID sets the "organization_id" field.
  39295. func (m *WxMutation) SetOrganizationID(u uint64) {
  39296. m.organization_id = &u
  39297. m.addorganization_id = nil
  39298. }
  39299. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39300. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  39301. v := m.organization_id
  39302. if v == nil {
  39303. return
  39304. }
  39305. return *v, true
  39306. }
  39307. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  39308. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39310. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39311. if !m.op.Is(OpUpdateOne) {
  39312. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39313. }
  39314. if m.id == nil || m.oldValue == nil {
  39315. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39316. }
  39317. oldValue, err := m.oldValue(ctx)
  39318. if err != nil {
  39319. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39320. }
  39321. return oldValue.OrganizationID, nil
  39322. }
  39323. // AddOrganizationID adds u to the "organization_id" field.
  39324. func (m *WxMutation) AddOrganizationID(u int64) {
  39325. if m.addorganization_id != nil {
  39326. *m.addorganization_id += u
  39327. } else {
  39328. m.addorganization_id = &u
  39329. }
  39330. }
  39331. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39332. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  39333. v := m.addorganization_id
  39334. if v == nil {
  39335. return
  39336. }
  39337. return *v, true
  39338. }
  39339. // ClearOrganizationID clears the value of the "organization_id" field.
  39340. func (m *WxMutation) ClearOrganizationID() {
  39341. m.organization_id = nil
  39342. m.addorganization_id = nil
  39343. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  39344. }
  39345. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39346. func (m *WxMutation) OrganizationIDCleared() bool {
  39347. _, ok := m.clearedFields[wx.FieldOrganizationID]
  39348. return ok
  39349. }
  39350. // ResetOrganizationID resets all changes to the "organization_id" field.
  39351. func (m *WxMutation) ResetOrganizationID() {
  39352. m.organization_id = nil
  39353. m.addorganization_id = nil
  39354. delete(m.clearedFields, wx.FieldOrganizationID)
  39355. }
  39356. // SetAgentID sets the "agent_id" field.
  39357. func (m *WxMutation) SetAgentID(u uint64) {
  39358. m.agent = &u
  39359. }
  39360. // AgentID returns the value of the "agent_id" field in the mutation.
  39361. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  39362. v := m.agent
  39363. if v == nil {
  39364. return
  39365. }
  39366. return *v, true
  39367. }
  39368. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  39369. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39371. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  39372. if !m.op.Is(OpUpdateOne) {
  39373. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  39374. }
  39375. if m.id == nil || m.oldValue == nil {
  39376. return v, errors.New("OldAgentID requires an ID field in the mutation")
  39377. }
  39378. oldValue, err := m.oldValue(ctx)
  39379. if err != nil {
  39380. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  39381. }
  39382. return oldValue.AgentID, nil
  39383. }
  39384. // ResetAgentID resets all changes to the "agent_id" field.
  39385. func (m *WxMutation) ResetAgentID() {
  39386. m.agent = nil
  39387. }
  39388. // SetAPIBase sets the "api_base" field.
  39389. func (m *WxMutation) SetAPIBase(s string) {
  39390. m.api_base = &s
  39391. }
  39392. // APIBase returns the value of the "api_base" field in the mutation.
  39393. func (m *WxMutation) APIBase() (r string, exists bool) {
  39394. v := m.api_base
  39395. if v == nil {
  39396. return
  39397. }
  39398. return *v, true
  39399. }
  39400. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  39401. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39403. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  39404. if !m.op.Is(OpUpdateOne) {
  39405. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  39406. }
  39407. if m.id == nil || m.oldValue == nil {
  39408. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  39409. }
  39410. oldValue, err := m.oldValue(ctx)
  39411. if err != nil {
  39412. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  39413. }
  39414. return oldValue.APIBase, nil
  39415. }
  39416. // ClearAPIBase clears the value of the "api_base" field.
  39417. func (m *WxMutation) ClearAPIBase() {
  39418. m.api_base = nil
  39419. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  39420. }
  39421. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  39422. func (m *WxMutation) APIBaseCleared() bool {
  39423. _, ok := m.clearedFields[wx.FieldAPIBase]
  39424. return ok
  39425. }
  39426. // ResetAPIBase resets all changes to the "api_base" field.
  39427. func (m *WxMutation) ResetAPIBase() {
  39428. m.api_base = nil
  39429. delete(m.clearedFields, wx.FieldAPIBase)
  39430. }
  39431. // SetAPIKey sets the "api_key" field.
  39432. func (m *WxMutation) SetAPIKey(s string) {
  39433. m.api_key = &s
  39434. }
  39435. // APIKey returns the value of the "api_key" field in the mutation.
  39436. func (m *WxMutation) APIKey() (r string, exists bool) {
  39437. v := m.api_key
  39438. if v == nil {
  39439. return
  39440. }
  39441. return *v, true
  39442. }
  39443. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  39444. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39446. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  39447. if !m.op.Is(OpUpdateOne) {
  39448. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  39449. }
  39450. if m.id == nil || m.oldValue == nil {
  39451. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  39452. }
  39453. oldValue, err := m.oldValue(ctx)
  39454. if err != nil {
  39455. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  39456. }
  39457. return oldValue.APIKey, nil
  39458. }
  39459. // ClearAPIKey clears the value of the "api_key" field.
  39460. func (m *WxMutation) ClearAPIKey() {
  39461. m.api_key = nil
  39462. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  39463. }
  39464. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  39465. func (m *WxMutation) APIKeyCleared() bool {
  39466. _, ok := m.clearedFields[wx.FieldAPIKey]
  39467. return ok
  39468. }
  39469. // ResetAPIKey resets all changes to the "api_key" field.
  39470. func (m *WxMutation) ResetAPIKey() {
  39471. m.api_key = nil
  39472. delete(m.clearedFields, wx.FieldAPIKey)
  39473. }
  39474. // SetAllowList sets the "allow_list" field.
  39475. func (m *WxMutation) SetAllowList(s []string) {
  39476. m.allow_list = &s
  39477. m.appendallow_list = nil
  39478. }
  39479. // AllowList returns the value of the "allow_list" field in the mutation.
  39480. func (m *WxMutation) AllowList() (r []string, exists bool) {
  39481. v := m.allow_list
  39482. if v == nil {
  39483. return
  39484. }
  39485. return *v, true
  39486. }
  39487. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  39488. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39490. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  39491. if !m.op.Is(OpUpdateOne) {
  39492. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  39493. }
  39494. if m.id == nil || m.oldValue == nil {
  39495. return v, errors.New("OldAllowList requires an ID field in the mutation")
  39496. }
  39497. oldValue, err := m.oldValue(ctx)
  39498. if err != nil {
  39499. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  39500. }
  39501. return oldValue.AllowList, nil
  39502. }
  39503. // AppendAllowList adds s to the "allow_list" field.
  39504. func (m *WxMutation) AppendAllowList(s []string) {
  39505. m.appendallow_list = append(m.appendallow_list, s...)
  39506. }
  39507. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  39508. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  39509. if len(m.appendallow_list) == 0 {
  39510. return nil, false
  39511. }
  39512. return m.appendallow_list, true
  39513. }
  39514. // ResetAllowList resets all changes to the "allow_list" field.
  39515. func (m *WxMutation) ResetAllowList() {
  39516. m.allow_list = nil
  39517. m.appendallow_list = nil
  39518. }
  39519. // SetGroupAllowList sets the "group_allow_list" field.
  39520. func (m *WxMutation) SetGroupAllowList(s []string) {
  39521. m.group_allow_list = &s
  39522. m.appendgroup_allow_list = nil
  39523. }
  39524. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  39525. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  39526. v := m.group_allow_list
  39527. if v == nil {
  39528. return
  39529. }
  39530. return *v, true
  39531. }
  39532. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  39533. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39535. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  39536. if !m.op.Is(OpUpdateOne) {
  39537. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  39538. }
  39539. if m.id == nil || m.oldValue == nil {
  39540. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  39541. }
  39542. oldValue, err := m.oldValue(ctx)
  39543. if err != nil {
  39544. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  39545. }
  39546. return oldValue.GroupAllowList, nil
  39547. }
  39548. // AppendGroupAllowList adds s to the "group_allow_list" field.
  39549. func (m *WxMutation) AppendGroupAllowList(s []string) {
  39550. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  39551. }
  39552. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  39553. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  39554. if len(m.appendgroup_allow_list) == 0 {
  39555. return nil, false
  39556. }
  39557. return m.appendgroup_allow_list, true
  39558. }
  39559. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  39560. func (m *WxMutation) ResetGroupAllowList() {
  39561. m.group_allow_list = nil
  39562. m.appendgroup_allow_list = nil
  39563. }
  39564. // SetBlockList sets the "block_list" field.
  39565. func (m *WxMutation) SetBlockList(s []string) {
  39566. m.block_list = &s
  39567. m.appendblock_list = nil
  39568. }
  39569. // BlockList returns the value of the "block_list" field in the mutation.
  39570. func (m *WxMutation) BlockList() (r []string, exists bool) {
  39571. v := m.block_list
  39572. if v == nil {
  39573. return
  39574. }
  39575. return *v, true
  39576. }
  39577. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  39578. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39580. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  39581. if !m.op.Is(OpUpdateOne) {
  39582. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  39583. }
  39584. if m.id == nil || m.oldValue == nil {
  39585. return v, errors.New("OldBlockList requires an ID field in the mutation")
  39586. }
  39587. oldValue, err := m.oldValue(ctx)
  39588. if err != nil {
  39589. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  39590. }
  39591. return oldValue.BlockList, nil
  39592. }
  39593. // AppendBlockList adds s to the "block_list" field.
  39594. func (m *WxMutation) AppendBlockList(s []string) {
  39595. m.appendblock_list = append(m.appendblock_list, s...)
  39596. }
  39597. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  39598. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  39599. if len(m.appendblock_list) == 0 {
  39600. return nil, false
  39601. }
  39602. return m.appendblock_list, true
  39603. }
  39604. // ResetBlockList resets all changes to the "block_list" field.
  39605. func (m *WxMutation) ResetBlockList() {
  39606. m.block_list = nil
  39607. m.appendblock_list = nil
  39608. }
  39609. // SetGroupBlockList sets the "group_block_list" field.
  39610. func (m *WxMutation) SetGroupBlockList(s []string) {
  39611. m.group_block_list = &s
  39612. m.appendgroup_block_list = nil
  39613. }
  39614. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  39615. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  39616. v := m.group_block_list
  39617. if v == nil {
  39618. return
  39619. }
  39620. return *v, true
  39621. }
  39622. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  39623. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  39624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39625. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  39626. if !m.op.Is(OpUpdateOne) {
  39627. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  39628. }
  39629. if m.id == nil || m.oldValue == nil {
  39630. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  39631. }
  39632. oldValue, err := m.oldValue(ctx)
  39633. if err != nil {
  39634. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  39635. }
  39636. return oldValue.GroupBlockList, nil
  39637. }
  39638. // AppendGroupBlockList adds s to the "group_block_list" field.
  39639. func (m *WxMutation) AppendGroupBlockList(s []string) {
  39640. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  39641. }
  39642. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  39643. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  39644. if len(m.appendgroup_block_list) == 0 {
  39645. return nil, false
  39646. }
  39647. return m.appendgroup_block_list, true
  39648. }
  39649. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  39650. func (m *WxMutation) ResetGroupBlockList() {
  39651. m.group_block_list = nil
  39652. m.appendgroup_block_list = nil
  39653. }
  39654. // ClearServer clears the "server" edge to the Server entity.
  39655. func (m *WxMutation) ClearServer() {
  39656. m.clearedserver = true
  39657. m.clearedFields[wx.FieldServerID] = struct{}{}
  39658. }
  39659. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  39660. func (m *WxMutation) ServerCleared() bool {
  39661. return m.ServerIDCleared() || m.clearedserver
  39662. }
  39663. // ServerIDs returns the "server" edge IDs in the mutation.
  39664. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39665. // ServerID instead. It exists only for internal usage by the builders.
  39666. func (m *WxMutation) ServerIDs() (ids []uint64) {
  39667. if id := m.server; id != nil {
  39668. ids = append(ids, *id)
  39669. }
  39670. return
  39671. }
  39672. // ResetServer resets all changes to the "server" edge.
  39673. func (m *WxMutation) ResetServer() {
  39674. m.server = nil
  39675. m.clearedserver = false
  39676. }
  39677. // ClearAgent clears the "agent" edge to the Agent entity.
  39678. func (m *WxMutation) ClearAgent() {
  39679. m.clearedagent = true
  39680. m.clearedFields[wx.FieldAgentID] = struct{}{}
  39681. }
  39682. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  39683. func (m *WxMutation) AgentCleared() bool {
  39684. return m.clearedagent
  39685. }
  39686. // AgentIDs returns the "agent" edge IDs in the mutation.
  39687. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39688. // AgentID instead. It exists only for internal usage by the builders.
  39689. func (m *WxMutation) AgentIDs() (ids []uint64) {
  39690. if id := m.agent; id != nil {
  39691. ids = append(ids, *id)
  39692. }
  39693. return
  39694. }
  39695. // ResetAgent resets all changes to the "agent" edge.
  39696. func (m *WxMutation) ResetAgent() {
  39697. m.agent = nil
  39698. m.clearedagent = false
  39699. }
  39700. // Where appends a list predicates to the WxMutation builder.
  39701. func (m *WxMutation) Where(ps ...predicate.Wx) {
  39702. m.predicates = append(m.predicates, ps...)
  39703. }
  39704. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  39705. // users can use type-assertion to append predicates that do not depend on any generated package.
  39706. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  39707. p := make([]predicate.Wx, len(ps))
  39708. for i := range ps {
  39709. p[i] = ps[i]
  39710. }
  39711. m.Where(p...)
  39712. }
  39713. // Op returns the operation name.
  39714. func (m *WxMutation) Op() Op {
  39715. return m.op
  39716. }
  39717. // SetOp allows setting the mutation operation.
  39718. func (m *WxMutation) SetOp(op Op) {
  39719. m.op = op
  39720. }
  39721. // Type returns the node type of this mutation (Wx).
  39722. func (m *WxMutation) Type() string {
  39723. return m.typ
  39724. }
  39725. // Fields returns all fields that were changed during this mutation. Note that in
  39726. // order to get all numeric fields that were incremented/decremented, call
  39727. // AddedFields().
  39728. func (m *WxMutation) Fields() []string {
  39729. fields := make([]string, 0, 21)
  39730. if m.created_at != nil {
  39731. fields = append(fields, wx.FieldCreatedAt)
  39732. }
  39733. if m.updated_at != nil {
  39734. fields = append(fields, wx.FieldUpdatedAt)
  39735. }
  39736. if m.status != nil {
  39737. fields = append(fields, wx.FieldStatus)
  39738. }
  39739. if m.deleted_at != nil {
  39740. fields = append(fields, wx.FieldDeletedAt)
  39741. }
  39742. if m.server != nil {
  39743. fields = append(fields, wx.FieldServerID)
  39744. }
  39745. if m.port != nil {
  39746. fields = append(fields, wx.FieldPort)
  39747. }
  39748. if m.process_id != nil {
  39749. fields = append(fields, wx.FieldProcessID)
  39750. }
  39751. if m.callback != nil {
  39752. fields = append(fields, wx.FieldCallback)
  39753. }
  39754. if m.wxid != nil {
  39755. fields = append(fields, wx.FieldWxid)
  39756. }
  39757. if m.account != nil {
  39758. fields = append(fields, wx.FieldAccount)
  39759. }
  39760. if m.nickname != nil {
  39761. fields = append(fields, wx.FieldNickname)
  39762. }
  39763. if m.tel != nil {
  39764. fields = append(fields, wx.FieldTel)
  39765. }
  39766. if m.head_big != nil {
  39767. fields = append(fields, wx.FieldHeadBig)
  39768. }
  39769. if m.organization_id != nil {
  39770. fields = append(fields, wx.FieldOrganizationID)
  39771. }
  39772. if m.agent != nil {
  39773. fields = append(fields, wx.FieldAgentID)
  39774. }
  39775. if m.api_base != nil {
  39776. fields = append(fields, wx.FieldAPIBase)
  39777. }
  39778. if m.api_key != nil {
  39779. fields = append(fields, wx.FieldAPIKey)
  39780. }
  39781. if m.allow_list != nil {
  39782. fields = append(fields, wx.FieldAllowList)
  39783. }
  39784. if m.group_allow_list != nil {
  39785. fields = append(fields, wx.FieldGroupAllowList)
  39786. }
  39787. if m.block_list != nil {
  39788. fields = append(fields, wx.FieldBlockList)
  39789. }
  39790. if m.group_block_list != nil {
  39791. fields = append(fields, wx.FieldGroupBlockList)
  39792. }
  39793. return fields
  39794. }
  39795. // Field returns the value of a field with the given name. The second boolean
  39796. // return value indicates that this field was not set, or was not defined in the
  39797. // schema.
  39798. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  39799. switch name {
  39800. case wx.FieldCreatedAt:
  39801. return m.CreatedAt()
  39802. case wx.FieldUpdatedAt:
  39803. return m.UpdatedAt()
  39804. case wx.FieldStatus:
  39805. return m.Status()
  39806. case wx.FieldDeletedAt:
  39807. return m.DeletedAt()
  39808. case wx.FieldServerID:
  39809. return m.ServerID()
  39810. case wx.FieldPort:
  39811. return m.Port()
  39812. case wx.FieldProcessID:
  39813. return m.ProcessID()
  39814. case wx.FieldCallback:
  39815. return m.Callback()
  39816. case wx.FieldWxid:
  39817. return m.Wxid()
  39818. case wx.FieldAccount:
  39819. return m.Account()
  39820. case wx.FieldNickname:
  39821. return m.Nickname()
  39822. case wx.FieldTel:
  39823. return m.Tel()
  39824. case wx.FieldHeadBig:
  39825. return m.HeadBig()
  39826. case wx.FieldOrganizationID:
  39827. return m.OrganizationID()
  39828. case wx.FieldAgentID:
  39829. return m.AgentID()
  39830. case wx.FieldAPIBase:
  39831. return m.APIBase()
  39832. case wx.FieldAPIKey:
  39833. return m.APIKey()
  39834. case wx.FieldAllowList:
  39835. return m.AllowList()
  39836. case wx.FieldGroupAllowList:
  39837. return m.GroupAllowList()
  39838. case wx.FieldBlockList:
  39839. return m.BlockList()
  39840. case wx.FieldGroupBlockList:
  39841. return m.GroupBlockList()
  39842. }
  39843. return nil, false
  39844. }
  39845. // OldField returns the old value of the field from the database. An error is
  39846. // returned if the mutation operation is not UpdateOne, or the query to the
  39847. // database failed.
  39848. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39849. switch name {
  39850. case wx.FieldCreatedAt:
  39851. return m.OldCreatedAt(ctx)
  39852. case wx.FieldUpdatedAt:
  39853. return m.OldUpdatedAt(ctx)
  39854. case wx.FieldStatus:
  39855. return m.OldStatus(ctx)
  39856. case wx.FieldDeletedAt:
  39857. return m.OldDeletedAt(ctx)
  39858. case wx.FieldServerID:
  39859. return m.OldServerID(ctx)
  39860. case wx.FieldPort:
  39861. return m.OldPort(ctx)
  39862. case wx.FieldProcessID:
  39863. return m.OldProcessID(ctx)
  39864. case wx.FieldCallback:
  39865. return m.OldCallback(ctx)
  39866. case wx.FieldWxid:
  39867. return m.OldWxid(ctx)
  39868. case wx.FieldAccount:
  39869. return m.OldAccount(ctx)
  39870. case wx.FieldNickname:
  39871. return m.OldNickname(ctx)
  39872. case wx.FieldTel:
  39873. return m.OldTel(ctx)
  39874. case wx.FieldHeadBig:
  39875. return m.OldHeadBig(ctx)
  39876. case wx.FieldOrganizationID:
  39877. return m.OldOrganizationID(ctx)
  39878. case wx.FieldAgentID:
  39879. return m.OldAgentID(ctx)
  39880. case wx.FieldAPIBase:
  39881. return m.OldAPIBase(ctx)
  39882. case wx.FieldAPIKey:
  39883. return m.OldAPIKey(ctx)
  39884. case wx.FieldAllowList:
  39885. return m.OldAllowList(ctx)
  39886. case wx.FieldGroupAllowList:
  39887. return m.OldGroupAllowList(ctx)
  39888. case wx.FieldBlockList:
  39889. return m.OldBlockList(ctx)
  39890. case wx.FieldGroupBlockList:
  39891. return m.OldGroupBlockList(ctx)
  39892. }
  39893. return nil, fmt.Errorf("unknown Wx field %s", name)
  39894. }
  39895. // SetField sets the value of a field with the given name. It returns an error if
  39896. // the field is not defined in the schema, or if the type mismatched the field
  39897. // type.
  39898. func (m *WxMutation) SetField(name string, value ent.Value) error {
  39899. switch name {
  39900. case wx.FieldCreatedAt:
  39901. v, ok := value.(time.Time)
  39902. if !ok {
  39903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39904. }
  39905. m.SetCreatedAt(v)
  39906. return nil
  39907. case wx.FieldUpdatedAt:
  39908. v, ok := value.(time.Time)
  39909. if !ok {
  39910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39911. }
  39912. m.SetUpdatedAt(v)
  39913. return nil
  39914. case wx.FieldStatus:
  39915. v, ok := value.(uint8)
  39916. if !ok {
  39917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39918. }
  39919. m.SetStatus(v)
  39920. return nil
  39921. case wx.FieldDeletedAt:
  39922. v, ok := value.(time.Time)
  39923. if !ok {
  39924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39925. }
  39926. m.SetDeletedAt(v)
  39927. return nil
  39928. case wx.FieldServerID:
  39929. v, ok := value.(uint64)
  39930. if !ok {
  39931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39932. }
  39933. m.SetServerID(v)
  39934. return nil
  39935. case wx.FieldPort:
  39936. v, ok := value.(string)
  39937. if !ok {
  39938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39939. }
  39940. m.SetPort(v)
  39941. return nil
  39942. case wx.FieldProcessID:
  39943. v, ok := value.(string)
  39944. if !ok {
  39945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39946. }
  39947. m.SetProcessID(v)
  39948. return nil
  39949. case wx.FieldCallback:
  39950. v, ok := value.(string)
  39951. if !ok {
  39952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39953. }
  39954. m.SetCallback(v)
  39955. return nil
  39956. case wx.FieldWxid:
  39957. v, ok := value.(string)
  39958. if !ok {
  39959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39960. }
  39961. m.SetWxid(v)
  39962. return nil
  39963. case wx.FieldAccount:
  39964. v, ok := value.(string)
  39965. if !ok {
  39966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39967. }
  39968. m.SetAccount(v)
  39969. return nil
  39970. case wx.FieldNickname:
  39971. v, ok := value.(string)
  39972. if !ok {
  39973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39974. }
  39975. m.SetNickname(v)
  39976. return nil
  39977. case wx.FieldTel:
  39978. v, ok := value.(string)
  39979. if !ok {
  39980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39981. }
  39982. m.SetTel(v)
  39983. return nil
  39984. case wx.FieldHeadBig:
  39985. v, ok := value.(string)
  39986. if !ok {
  39987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39988. }
  39989. m.SetHeadBig(v)
  39990. return nil
  39991. case wx.FieldOrganizationID:
  39992. v, ok := value.(uint64)
  39993. if !ok {
  39994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39995. }
  39996. m.SetOrganizationID(v)
  39997. return nil
  39998. case wx.FieldAgentID:
  39999. v, ok := value.(uint64)
  40000. if !ok {
  40001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40002. }
  40003. m.SetAgentID(v)
  40004. return nil
  40005. case wx.FieldAPIBase:
  40006. v, ok := value.(string)
  40007. if !ok {
  40008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40009. }
  40010. m.SetAPIBase(v)
  40011. return nil
  40012. case wx.FieldAPIKey:
  40013. v, ok := value.(string)
  40014. if !ok {
  40015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40016. }
  40017. m.SetAPIKey(v)
  40018. return nil
  40019. case wx.FieldAllowList:
  40020. v, ok := value.([]string)
  40021. if !ok {
  40022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40023. }
  40024. m.SetAllowList(v)
  40025. return nil
  40026. case wx.FieldGroupAllowList:
  40027. v, ok := value.([]string)
  40028. if !ok {
  40029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40030. }
  40031. m.SetGroupAllowList(v)
  40032. return nil
  40033. case wx.FieldBlockList:
  40034. v, ok := value.([]string)
  40035. if !ok {
  40036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40037. }
  40038. m.SetBlockList(v)
  40039. return nil
  40040. case wx.FieldGroupBlockList:
  40041. v, ok := value.([]string)
  40042. if !ok {
  40043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40044. }
  40045. m.SetGroupBlockList(v)
  40046. return nil
  40047. }
  40048. return fmt.Errorf("unknown Wx field %s", name)
  40049. }
  40050. // AddedFields returns all numeric fields that were incremented/decremented during
  40051. // this mutation.
  40052. func (m *WxMutation) AddedFields() []string {
  40053. var fields []string
  40054. if m.addstatus != nil {
  40055. fields = append(fields, wx.FieldStatus)
  40056. }
  40057. if m.addorganization_id != nil {
  40058. fields = append(fields, wx.FieldOrganizationID)
  40059. }
  40060. return fields
  40061. }
  40062. // AddedField returns the numeric value that was incremented/decremented on a field
  40063. // with the given name. The second boolean return value indicates that this field
  40064. // was not set, or was not defined in the schema.
  40065. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  40066. switch name {
  40067. case wx.FieldStatus:
  40068. return m.AddedStatus()
  40069. case wx.FieldOrganizationID:
  40070. return m.AddedOrganizationID()
  40071. }
  40072. return nil, false
  40073. }
  40074. // AddField adds the value to the field with the given name. It returns an error if
  40075. // the field is not defined in the schema, or if the type mismatched the field
  40076. // type.
  40077. func (m *WxMutation) AddField(name string, value ent.Value) error {
  40078. switch name {
  40079. case wx.FieldStatus:
  40080. v, ok := value.(int8)
  40081. if !ok {
  40082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40083. }
  40084. m.AddStatus(v)
  40085. return nil
  40086. case wx.FieldOrganizationID:
  40087. v, ok := value.(int64)
  40088. if !ok {
  40089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40090. }
  40091. m.AddOrganizationID(v)
  40092. return nil
  40093. }
  40094. return fmt.Errorf("unknown Wx numeric field %s", name)
  40095. }
  40096. // ClearedFields returns all nullable fields that were cleared during this
  40097. // mutation.
  40098. func (m *WxMutation) ClearedFields() []string {
  40099. var fields []string
  40100. if m.FieldCleared(wx.FieldStatus) {
  40101. fields = append(fields, wx.FieldStatus)
  40102. }
  40103. if m.FieldCleared(wx.FieldDeletedAt) {
  40104. fields = append(fields, wx.FieldDeletedAt)
  40105. }
  40106. if m.FieldCleared(wx.FieldServerID) {
  40107. fields = append(fields, wx.FieldServerID)
  40108. }
  40109. if m.FieldCleared(wx.FieldOrganizationID) {
  40110. fields = append(fields, wx.FieldOrganizationID)
  40111. }
  40112. if m.FieldCleared(wx.FieldAPIBase) {
  40113. fields = append(fields, wx.FieldAPIBase)
  40114. }
  40115. if m.FieldCleared(wx.FieldAPIKey) {
  40116. fields = append(fields, wx.FieldAPIKey)
  40117. }
  40118. return fields
  40119. }
  40120. // FieldCleared returns a boolean indicating if a field with the given name was
  40121. // cleared in this mutation.
  40122. func (m *WxMutation) FieldCleared(name string) bool {
  40123. _, ok := m.clearedFields[name]
  40124. return ok
  40125. }
  40126. // ClearField clears the value of the field with the given name. It returns an
  40127. // error if the field is not defined in the schema.
  40128. func (m *WxMutation) ClearField(name string) error {
  40129. switch name {
  40130. case wx.FieldStatus:
  40131. m.ClearStatus()
  40132. return nil
  40133. case wx.FieldDeletedAt:
  40134. m.ClearDeletedAt()
  40135. return nil
  40136. case wx.FieldServerID:
  40137. m.ClearServerID()
  40138. return nil
  40139. case wx.FieldOrganizationID:
  40140. m.ClearOrganizationID()
  40141. return nil
  40142. case wx.FieldAPIBase:
  40143. m.ClearAPIBase()
  40144. return nil
  40145. case wx.FieldAPIKey:
  40146. m.ClearAPIKey()
  40147. return nil
  40148. }
  40149. return fmt.Errorf("unknown Wx nullable field %s", name)
  40150. }
  40151. // ResetField resets all changes in the mutation for the field with the given name.
  40152. // It returns an error if the field is not defined in the schema.
  40153. func (m *WxMutation) ResetField(name string) error {
  40154. switch name {
  40155. case wx.FieldCreatedAt:
  40156. m.ResetCreatedAt()
  40157. return nil
  40158. case wx.FieldUpdatedAt:
  40159. m.ResetUpdatedAt()
  40160. return nil
  40161. case wx.FieldStatus:
  40162. m.ResetStatus()
  40163. return nil
  40164. case wx.FieldDeletedAt:
  40165. m.ResetDeletedAt()
  40166. return nil
  40167. case wx.FieldServerID:
  40168. m.ResetServerID()
  40169. return nil
  40170. case wx.FieldPort:
  40171. m.ResetPort()
  40172. return nil
  40173. case wx.FieldProcessID:
  40174. m.ResetProcessID()
  40175. return nil
  40176. case wx.FieldCallback:
  40177. m.ResetCallback()
  40178. return nil
  40179. case wx.FieldWxid:
  40180. m.ResetWxid()
  40181. return nil
  40182. case wx.FieldAccount:
  40183. m.ResetAccount()
  40184. return nil
  40185. case wx.FieldNickname:
  40186. m.ResetNickname()
  40187. return nil
  40188. case wx.FieldTel:
  40189. m.ResetTel()
  40190. return nil
  40191. case wx.FieldHeadBig:
  40192. m.ResetHeadBig()
  40193. return nil
  40194. case wx.FieldOrganizationID:
  40195. m.ResetOrganizationID()
  40196. return nil
  40197. case wx.FieldAgentID:
  40198. m.ResetAgentID()
  40199. return nil
  40200. case wx.FieldAPIBase:
  40201. m.ResetAPIBase()
  40202. return nil
  40203. case wx.FieldAPIKey:
  40204. m.ResetAPIKey()
  40205. return nil
  40206. case wx.FieldAllowList:
  40207. m.ResetAllowList()
  40208. return nil
  40209. case wx.FieldGroupAllowList:
  40210. m.ResetGroupAllowList()
  40211. return nil
  40212. case wx.FieldBlockList:
  40213. m.ResetBlockList()
  40214. return nil
  40215. case wx.FieldGroupBlockList:
  40216. m.ResetGroupBlockList()
  40217. return nil
  40218. }
  40219. return fmt.Errorf("unknown Wx field %s", name)
  40220. }
  40221. // AddedEdges returns all edge names that were set/added in this mutation.
  40222. func (m *WxMutation) AddedEdges() []string {
  40223. edges := make([]string, 0, 2)
  40224. if m.server != nil {
  40225. edges = append(edges, wx.EdgeServer)
  40226. }
  40227. if m.agent != nil {
  40228. edges = append(edges, wx.EdgeAgent)
  40229. }
  40230. return edges
  40231. }
  40232. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40233. // name in this mutation.
  40234. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  40235. switch name {
  40236. case wx.EdgeServer:
  40237. if id := m.server; id != nil {
  40238. return []ent.Value{*id}
  40239. }
  40240. case wx.EdgeAgent:
  40241. if id := m.agent; id != nil {
  40242. return []ent.Value{*id}
  40243. }
  40244. }
  40245. return nil
  40246. }
  40247. // RemovedEdges returns all edge names that were removed in this mutation.
  40248. func (m *WxMutation) RemovedEdges() []string {
  40249. edges := make([]string, 0, 2)
  40250. return edges
  40251. }
  40252. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40253. // the given name in this mutation.
  40254. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  40255. return nil
  40256. }
  40257. // ClearedEdges returns all edge names that were cleared in this mutation.
  40258. func (m *WxMutation) ClearedEdges() []string {
  40259. edges := make([]string, 0, 2)
  40260. if m.clearedserver {
  40261. edges = append(edges, wx.EdgeServer)
  40262. }
  40263. if m.clearedagent {
  40264. edges = append(edges, wx.EdgeAgent)
  40265. }
  40266. return edges
  40267. }
  40268. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40269. // was cleared in this mutation.
  40270. func (m *WxMutation) EdgeCleared(name string) bool {
  40271. switch name {
  40272. case wx.EdgeServer:
  40273. return m.clearedserver
  40274. case wx.EdgeAgent:
  40275. return m.clearedagent
  40276. }
  40277. return false
  40278. }
  40279. // ClearEdge clears the value of the edge with the given name. It returns an error
  40280. // if that edge is not defined in the schema.
  40281. func (m *WxMutation) ClearEdge(name string) error {
  40282. switch name {
  40283. case wx.EdgeServer:
  40284. m.ClearServer()
  40285. return nil
  40286. case wx.EdgeAgent:
  40287. m.ClearAgent()
  40288. return nil
  40289. }
  40290. return fmt.Errorf("unknown Wx unique edge %s", name)
  40291. }
  40292. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40293. // It returns an error if the edge is not defined in the schema.
  40294. func (m *WxMutation) ResetEdge(name string) error {
  40295. switch name {
  40296. case wx.EdgeServer:
  40297. m.ResetServer()
  40298. return nil
  40299. case wx.EdgeAgent:
  40300. m.ResetAgent()
  40301. return nil
  40302. }
  40303. return fmt.Errorf("unknown Wx edge %s", name)
  40304. }
  40305. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  40306. type WxCardMutation struct {
  40307. config
  40308. op Op
  40309. typ string
  40310. id *uint64
  40311. created_at *time.Time
  40312. updated_at *time.Time
  40313. deleted_at *time.Time
  40314. user_id *uint64
  40315. adduser_id *int64
  40316. wx_user_id *uint64
  40317. addwx_user_id *int64
  40318. avatar *string
  40319. logo *string
  40320. name *string
  40321. company *string
  40322. address *string
  40323. phone *string
  40324. official_account *string
  40325. wechat_account *string
  40326. email *string
  40327. api_base *string
  40328. api_key *string
  40329. ai_info *string
  40330. intro *string
  40331. clearedFields map[string]struct{}
  40332. done bool
  40333. oldValue func(context.Context) (*WxCard, error)
  40334. predicates []predicate.WxCard
  40335. }
  40336. var _ ent.Mutation = (*WxCardMutation)(nil)
  40337. // wxcardOption allows management of the mutation configuration using functional options.
  40338. type wxcardOption func(*WxCardMutation)
  40339. // newWxCardMutation creates new mutation for the WxCard entity.
  40340. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  40341. m := &WxCardMutation{
  40342. config: c,
  40343. op: op,
  40344. typ: TypeWxCard,
  40345. clearedFields: make(map[string]struct{}),
  40346. }
  40347. for _, opt := range opts {
  40348. opt(m)
  40349. }
  40350. return m
  40351. }
  40352. // withWxCardID sets the ID field of the mutation.
  40353. func withWxCardID(id uint64) wxcardOption {
  40354. return func(m *WxCardMutation) {
  40355. var (
  40356. err error
  40357. once sync.Once
  40358. value *WxCard
  40359. )
  40360. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  40361. once.Do(func() {
  40362. if m.done {
  40363. err = errors.New("querying old values post mutation is not allowed")
  40364. } else {
  40365. value, err = m.Client().WxCard.Get(ctx, id)
  40366. }
  40367. })
  40368. return value, err
  40369. }
  40370. m.id = &id
  40371. }
  40372. }
  40373. // withWxCard sets the old WxCard of the mutation.
  40374. func withWxCard(node *WxCard) wxcardOption {
  40375. return func(m *WxCardMutation) {
  40376. m.oldValue = func(context.Context) (*WxCard, error) {
  40377. return node, nil
  40378. }
  40379. m.id = &node.ID
  40380. }
  40381. }
  40382. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40383. // executed in a transaction (ent.Tx), a transactional client is returned.
  40384. func (m WxCardMutation) Client() *Client {
  40385. client := &Client{config: m.config}
  40386. client.init()
  40387. return client
  40388. }
  40389. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40390. // it returns an error otherwise.
  40391. func (m WxCardMutation) Tx() (*Tx, error) {
  40392. if _, ok := m.driver.(*txDriver); !ok {
  40393. return nil, errors.New("ent: mutation is not running in a transaction")
  40394. }
  40395. tx := &Tx{config: m.config}
  40396. tx.init()
  40397. return tx, nil
  40398. }
  40399. // SetID sets the value of the id field. Note that this
  40400. // operation is only accepted on creation of WxCard entities.
  40401. func (m *WxCardMutation) SetID(id uint64) {
  40402. m.id = &id
  40403. }
  40404. // ID returns the ID value in the mutation. Note that the ID is only available
  40405. // if it was provided to the builder or after it was returned from the database.
  40406. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  40407. if m.id == nil {
  40408. return
  40409. }
  40410. return *m.id, true
  40411. }
  40412. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40413. // That means, if the mutation is applied within a transaction with an isolation level such
  40414. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40415. // or updated by the mutation.
  40416. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  40417. switch {
  40418. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40419. id, exists := m.ID()
  40420. if exists {
  40421. return []uint64{id}, nil
  40422. }
  40423. fallthrough
  40424. case m.op.Is(OpUpdate | OpDelete):
  40425. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  40426. default:
  40427. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40428. }
  40429. }
  40430. // SetCreatedAt sets the "created_at" field.
  40431. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  40432. m.created_at = &t
  40433. }
  40434. // CreatedAt returns the value of the "created_at" field in the mutation.
  40435. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  40436. v := m.created_at
  40437. if v == nil {
  40438. return
  40439. }
  40440. return *v, true
  40441. }
  40442. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  40443. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40445. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40446. if !m.op.Is(OpUpdateOne) {
  40447. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40448. }
  40449. if m.id == nil || m.oldValue == nil {
  40450. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40451. }
  40452. oldValue, err := m.oldValue(ctx)
  40453. if err != nil {
  40454. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40455. }
  40456. return oldValue.CreatedAt, nil
  40457. }
  40458. // ResetCreatedAt resets all changes to the "created_at" field.
  40459. func (m *WxCardMutation) ResetCreatedAt() {
  40460. m.created_at = nil
  40461. }
  40462. // SetUpdatedAt sets the "updated_at" field.
  40463. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  40464. m.updated_at = &t
  40465. }
  40466. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40467. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  40468. v := m.updated_at
  40469. if v == nil {
  40470. return
  40471. }
  40472. return *v, true
  40473. }
  40474. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  40475. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40477. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40478. if !m.op.Is(OpUpdateOne) {
  40479. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40480. }
  40481. if m.id == nil || m.oldValue == nil {
  40482. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40483. }
  40484. oldValue, err := m.oldValue(ctx)
  40485. if err != nil {
  40486. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40487. }
  40488. return oldValue.UpdatedAt, nil
  40489. }
  40490. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40491. func (m *WxCardMutation) ResetUpdatedAt() {
  40492. m.updated_at = nil
  40493. }
  40494. // SetDeletedAt sets the "deleted_at" field.
  40495. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  40496. m.deleted_at = &t
  40497. }
  40498. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40499. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  40500. v := m.deleted_at
  40501. if v == nil {
  40502. return
  40503. }
  40504. return *v, true
  40505. }
  40506. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  40507. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40509. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40510. if !m.op.Is(OpUpdateOne) {
  40511. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40512. }
  40513. if m.id == nil || m.oldValue == nil {
  40514. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40515. }
  40516. oldValue, err := m.oldValue(ctx)
  40517. if err != nil {
  40518. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40519. }
  40520. return oldValue.DeletedAt, nil
  40521. }
  40522. // ClearDeletedAt clears the value of the "deleted_at" field.
  40523. func (m *WxCardMutation) ClearDeletedAt() {
  40524. m.deleted_at = nil
  40525. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  40526. }
  40527. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40528. func (m *WxCardMutation) DeletedAtCleared() bool {
  40529. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  40530. return ok
  40531. }
  40532. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40533. func (m *WxCardMutation) ResetDeletedAt() {
  40534. m.deleted_at = nil
  40535. delete(m.clearedFields, wxcard.FieldDeletedAt)
  40536. }
  40537. // SetUserID sets the "user_id" field.
  40538. func (m *WxCardMutation) SetUserID(u uint64) {
  40539. m.user_id = &u
  40540. m.adduser_id = nil
  40541. }
  40542. // UserID returns the value of the "user_id" field in the mutation.
  40543. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  40544. v := m.user_id
  40545. if v == nil {
  40546. return
  40547. }
  40548. return *v, true
  40549. }
  40550. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  40551. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40553. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  40554. if !m.op.Is(OpUpdateOne) {
  40555. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  40556. }
  40557. if m.id == nil || m.oldValue == nil {
  40558. return v, errors.New("OldUserID requires an ID field in the mutation")
  40559. }
  40560. oldValue, err := m.oldValue(ctx)
  40561. if err != nil {
  40562. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  40563. }
  40564. return oldValue.UserID, nil
  40565. }
  40566. // AddUserID adds u to the "user_id" field.
  40567. func (m *WxCardMutation) AddUserID(u int64) {
  40568. if m.adduser_id != nil {
  40569. *m.adduser_id += u
  40570. } else {
  40571. m.adduser_id = &u
  40572. }
  40573. }
  40574. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  40575. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  40576. v := m.adduser_id
  40577. if v == nil {
  40578. return
  40579. }
  40580. return *v, true
  40581. }
  40582. // ClearUserID clears the value of the "user_id" field.
  40583. func (m *WxCardMutation) ClearUserID() {
  40584. m.user_id = nil
  40585. m.adduser_id = nil
  40586. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  40587. }
  40588. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  40589. func (m *WxCardMutation) UserIDCleared() bool {
  40590. _, ok := m.clearedFields[wxcard.FieldUserID]
  40591. return ok
  40592. }
  40593. // ResetUserID resets all changes to the "user_id" field.
  40594. func (m *WxCardMutation) ResetUserID() {
  40595. m.user_id = nil
  40596. m.adduser_id = nil
  40597. delete(m.clearedFields, wxcard.FieldUserID)
  40598. }
  40599. // SetWxUserID sets the "wx_user_id" field.
  40600. func (m *WxCardMutation) SetWxUserID(u uint64) {
  40601. m.wx_user_id = &u
  40602. m.addwx_user_id = nil
  40603. }
  40604. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  40605. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  40606. v := m.wx_user_id
  40607. if v == nil {
  40608. return
  40609. }
  40610. return *v, true
  40611. }
  40612. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  40613. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40615. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  40616. if !m.op.Is(OpUpdateOne) {
  40617. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  40618. }
  40619. if m.id == nil || m.oldValue == nil {
  40620. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  40621. }
  40622. oldValue, err := m.oldValue(ctx)
  40623. if err != nil {
  40624. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  40625. }
  40626. return oldValue.WxUserID, nil
  40627. }
  40628. // AddWxUserID adds u to the "wx_user_id" field.
  40629. func (m *WxCardMutation) AddWxUserID(u int64) {
  40630. if m.addwx_user_id != nil {
  40631. *m.addwx_user_id += u
  40632. } else {
  40633. m.addwx_user_id = &u
  40634. }
  40635. }
  40636. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  40637. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  40638. v := m.addwx_user_id
  40639. if v == nil {
  40640. return
  40641. }
  40642. return *v, true
  40643. }
  40644. // ClearWxUserID clears the value of the "wx_user_id" field.
  40645. func (m *WxCardMutation) ClearWxUserID() {
  40646. m.wx_user_id = nil
  40647. m.addwx_user_id = nil
  40648. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  40649. }
  40650. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  40651. func (m *WxCardMutation) WxUserIDCleared() bool {
  40652. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  40653. return ok
  40654. }
  40655. // ResetWxUserID resets all changes to the "wx_user_id" field.
  40656. func (m *WxCardMutation) ResetWxUserID() {
  40657. m.wx_user_id = nil
  40658. m.addwx_user_id = nil
  40659. delete(m.clearedFields, wxcard.FieldWxUserID)
  40660. }
  40661. // SetAvatar sets the "avatar" field.
  40662. func (m *WxCardMutation) SetAvatar(s string) {
  40663. m.avatar = &s
  40664. }
  40665. // Avatar returns the value of the "avatar" field in the mutation.
  40666. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  40667. v := m.avatar
  40668. if v == nil {
  40669. return
  40670. }
  40671. return *v, true
  40672. }
  40673. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  40674. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40676. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40677. if !m.op.Is(OpUpdateOne) {
  40678. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40679. }
  40680. if m.id == nil || m.oldValue == nil {
  40681. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40682. }
  40683. oldValue, err := m.oldValue(ctx)
  40684. if err != nil {
  40685. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40686. }
  40687. return oldValue.Avatar, nil
  40688. }
  40689. // ResetAvatar resets all changes to the "avatar" field.
  40690. func (m *WxCardMutation) ResetAvatar() {
  40691. m.avatar = nil
  40692. }
  40693. // SetLogo sets the "logo" field.
  40694. func (m *WxCardMutation) SetLogo(s string) {
  40695. m.logo = &s
  40696. }
  40697. // Logo returns the value of the "logo" field in the mutation.
  40698. func (m *WxCardMutation) Logo() (r string, exists bool) {
  40699. v := m.logo
  40700. if v == nil {
  40701. return
  40702. }
  40703. return *v, true
  40704. }
  40705. // OldLogo returns the old "logo" field's value of the WxCard entity.
  40706. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40708. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  40709. if !m.op.Is(OpUpdateOne) {
  40710. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  40711. }
  40712. if m.id == nil || m.oldValue == nil {
  40713. return v, errors.New("OldLogo requires an ID field in the mutation")
  40714. }
  40715. oldValue, err := m.oldValue(ctx)
  40716. if err != nil {
  40717. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  40718. }
  40719. return oldValue.Logo, nil
  40720. }
  40721. // ResetLogo resets all changes to the "logo" field.
  40722. func (m *WxCardMutation) ResetLogo() {
  40723. m.logo = nil
  40724. }
  40725. // SetName sets the "name" field.
  40726. func (m *WxCardMutation) SetName(s string) {
  40727. m.name = &s
  40728. }
  40729. // Name returns the value of the "name" field in the mutation.
  40730. func (m *WxCardMutation) Name() (r string, exists bool) {
  40731. v := m.name
  40732. if v == nil {
  40733. return
  40734. }
  40735. return *v, true
  40736. }
  40737. // OldName returns the old "name" field's value of the WxCard entity.
  40738. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40740. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  40741. if !m.op.Is(OpUpdateOne) {
  40742. return v, errors.New("OldName is only allowed on UpdateOne operations")
  40743. }
  40744. if m.id == nil || m.oldValue == nil {
  40745. return v, errors.New("OldName requires an ID field in the mutation")
  40746. }
  40747. oldValue, err := m.oldValue(ctx)
  40748. if err != nil {
  40749. return v, fmt.Errorf("querying old value for OldName: %w", err)
  40750. }
  40751. return oldValue.Name, nil
  40752. }
  40753. // ResetName resets all changes to the "name" field.
  40754. func (m *WxCardMutation) ResetName() {
  40755. m.name = nil
  40756. }
  40757. // SetCompany sets the "company" field.
  40758. func (m *WxCardMutation) SetCompany(s string) {
  40759. m.company = &s
  40760. }
  40761. // Company returns the value of the "company" field in the mutation.
  40762. func (m *WxCardMutation) Company() (r string, exists bool) {
  40763. v := m.company
  40764. if v == nil {
  40765. return
  40766. }
  40767. return *v, true
  40768. }
  40769. // OldCompany returns the old "company" field's value of the WxCard entity.
  40770. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40772. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  40773. if !m.op.Is(OpUpdateOne) {
  40774. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  40775. }
  40776. if m.id == nil || m.oldValue == nil {
  40777. return v, errors.New("OldCompany requires an ID field in the mutation")
  40778. }
  40779. oldValue, err := m.oldValue(ctx)
  40780. if err != nil {
  40781. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  40782. }
  40783. return oldValue.Company, nil
  40784. }
  40785. // ResetCompany resets all changes to the "company" field.
  40786. func (m *WxCardMutation) ResetCompany() {
  40787. m.company = nil
  40788. }
  40789. // SetAddress sets the "address" field.
  40790. func (m *WxCardMutation) SetAddress(s string) {
  40791. m.address = &s
  40792. }
  40793. // Address returns the value of the "address" field in the mutation.
  40794. func (m *WxCardMutation) Address() (r string, exists bool) {
  40795. v := m.address
  40796. if v == nil {
  40797. return
  40798. }
  40799. return *v, true
  40800. }
  40801. // OldAddress returns the old "address" field's value of the WxCard entity.
  40802. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40804. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  40805. if !m.op.Is(OpUpdateOne) {
  40806. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  40807. }
  40808. if m.id == nil || m.oldValue == nil {
  40809. return v, errors.New("OldAddress requires an ID field in the mutation")
  40810. }
  40811. oldValue, err := m.oldValue(ctx)
  40812. if err != nil {
  40813. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  40814. }
  40815. return oldValue.Address, nil
  40816. }
  40817. // ResetAddress resets all changes to the "address" field.
  40818. func (m *WxCardMutation) ResetAddress() {
  40819. m.address = nil
  40820. }
  40821. // SetPhone sets the "phone" field.
  40822. func (m *WxCardMutation) SetPhone(s string) {
  40823. m.phone = &s
  40824. }
  40825. // Phone returns the value of the "phone" field in the mutation.
  40826. func (m *WxCardMutation) Phone() (r string, exists bool) {
  40827. v := m.phone
  40828. if v == nil {
  40829. return
  40830. }
  40831. return *v, true
  40832. }
  40833. // OldPhone returns the old "phone" field's value of the WxCard entity.
  40834. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40836. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  40837. if !m.op.Is(OpUpdateOne) {
  40838. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  40839. }
  40840. if m.id == nil || m.oldValue == nil {
  40841. return v, errors.New("OldPhone requires an ID field in the mutation")
  40842. }
  40843. oldValue, err := m.oldValue(ctx)
  40844. if err != nil {
  40845. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  40846. }
  40847. return oldValue.Phone, nil
  40848. }
  40849. // ResetPhone resets all changes to the "phone" field.
  40850. func (m *WxCardMutation) ResetPhone() {
  40851. m.phone = nil
  40852. }
  40853. // SetOfficialAccount sets the "official_account" field.
  40854. func (m *WxCardMutation) SetOfficialAccount(s string) {
  40855. m.official_account = &s
  40856. }
  40857. // OfficialAccount returns the value of the "official_account" field in the mutation.
  40858. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  40859. v := m.official_account
  40860. if v == nil {
  40861. return
  40862. }
  40863. return *v, true
  40864. }
  40865. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  40866. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40868. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  40869. if !m.op.Is(OpUpdateOne) {
  40870. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  40871. }
  40872. if m.id == nil || m.oldValue == nil {
  40873. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  40874. }
  40875. oldValue, err := m.oldValue(ctx)
  40876. if err != nil {
  40877. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  40878. }
  40879. return oldValue.OfficialAccount, nil
  40880. }
  40881. // ResetOfficialAccount resets all changes to the "official_account" field.
  40882. func (m *WxCardMutation) ResetOfficialAccount() {
  40883. m.official_account = nil
  40884. }
  40885. // SetWechatAccount sets the "wechat_account" field.
  40886. func (m *WxCardMutation) SetWechatAccount(s string) {
  40887. m.wechat_account = &s
  40888. }
  40889. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  40890. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  40891. v := m.wechat_account
  40892. if v == nil {
  40893. return
  40894. }
  40895. return *v, true
  40896. }
  40897. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  40898. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40900. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  40901. if !m.op.Is(OpUpdateOne) {
  40902. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  40903. }
  40904. if m.id == nil || m.oldValue == nil {
  40905. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  40906. }
  40907. oldValue, err := m.oldValue(ctx)
  40908. if err != nil {
  40909. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  40910. }
  40911. return oldValue.WechatAccount, nil
  40912. }
  40913. // ResetWechatAccount resets all changes to the "wechat_account" field.
  40914. func (m *WxCardMutation) ResetWechatAccount() {
  40915. m.wechat_account = nil
  40916. }
  40917. // SetEmail sets the "email" field.
  40918. func (m *WxCardMutation) SetEmail(s string) {
  40919. m.email = &s
  40920. }
  40921. // Email returns the value of the "email" field in the mutation.
  40922. func (m *WxCardMutation) Email() (r string, exists bool) {
  40923. v := m.email
  40924. if v == nil {
  40925. return
  40926. }
  40927. return *v, true
  40928. }
  40929. // OldEmail returns the old "email" field's value of the WxCard entity.
  40930. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40932. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  40933. if !m.op.Is(OpUpdateOne) {
  40934. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  40935. }
  40936. if m.id == nil || m.oldValue == nil {
  40937. return v, errors.New("OldEmail requires an ID field in the mutation")
  40938. }
  40939. oldValue, err := m.oldValue(ctx)
  40940. if err != nil {
  40941. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  40942. }
  40943. return oldValue.Email, nil
  40944. }
  40945. // ClearEmail clears the value of the "email" field.
  40946. func (m *WxCardMutation) ClearEmail() {
  40947. m.email = nil
  40948. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  40949. }
  40950. // EmailCleared returns if the "email" field was cleared in this mutation.
  40951. func (m *WxCardMutation) EmailCleared() bool {
  40952. _, ok := m.clearedFields[wxcard.FieldEmail]
  40953. return ok
  40954. }
  40955. // ResetEmail resets all changes to the "email" field.
  40956. func (m *WxCardMutation) ResetEmail() {
  40957. m.email = nil
  40958. delete(m.clearedFields, wxcard.FieldEmail)
  40959. }
  40960. // SetAPIBase sets the "api_base" field.
  40961. func (m *WxCardMutation) SetAPIBase(s string) {
  40962. m.api_base = &s
  40963. }
  40964. // APIBase returns the value of the "api_base" field in the mutation.
  40965. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  40966. v := m.api_base
  40967. if v == nil {
  40968. return
  40969. }
  40970. return *v, true
  40971. }
  40972. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  40973. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  40974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40975. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  40976. if !m.op.Is(OpUpdateOne) {
  40977. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  40978. }
  40979. if m.id == nil || m.oldValue == nil {
  40980. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  40981. }
  40982. oldValue, err := m.oldValue(ctx)
  40983. if err != nil {
  40984. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  40985. }
  40986. return oldValue.APIBase, nil
  40987. }
  40988. // ClearAPIBase clears the value of the "api_base" field.
  40989. func (m *WxCardMutation) ClearAPIBase() {
  40990. m.api_base = nil
  40991. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  40992. }
  40993. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  40994. func (m *WxCardMutation) APIBaseCleared() bool {
  40995. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  40996. return ok
  40997. }
  40998. // ResetAPIBase resets all changes to the "api_base" field.
  40999. func (m *WxCardMutation) ResetAPIBase() {
  41000. m.api_base = nil
  41001. delete(m.clearedFields, wxcard.FieldAPIBase)
  41002. }
  41003. // SetAPIKey sets the "api_key" field.
  41004. func (m *WxCardMutation) SetAPIKey(s string) {
  41005. m.api_key = &s
  41006. }
  41007. // APIKey returns the value of the "api_key" field in the mutation.
  41008. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  41009. v := m.api_key
  41010. if v == nil {
  41011. return
  41012. }
  41013. return *v, true
  41014. }
  41015. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  41016. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41018. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  41019. if !m.op.Is(OpUpdateOne) {
  41020. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  41021. }
  41022. if m.id == nil || m.oldValue == nil {
  41023. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  41024. }
  41025. oldValue, err := m.oldValue(ctx)
  41026. if err != nil {
  41027. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  41028. }
  41029. return oldValue.APIKey, nil
  41030. }
  41031. // ClearAPIKey clears the value of the "api_key" field.
  41032. func (m *WxCardMutation) ClearAPIKey() {
  41033. m.api_key = nil
  41034. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  41035. }
  41036. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  41037. func (m *WxCardMutation) APIKeyCleared() bool {
  41038. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  41039. return ok
  41040. }
  41041. // ResetAPIKey resets all changes to the "api_key" field.
  41042. func (m *WxCardMutation) ResetAPIKey() {
  41043. m.api_key = nil
  41044. delete(m.clearedFields, wxcard.FieldAPIKey)
  41045. }
  41046. // SetAiInfo sets the "ai_info" field.
  41047. func (m *WxCardMutation) SetAiInfo(s string) {
  41048. m.ai_info = &s
  41049. }
  41050. // AiInfo returns the value of the "ai_info" field in the mutation.
  41051. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  41052. v := m.ai_info
  41053. if v == nil {
  41054. return
  41055. }
  41056. return *v, true
  41057. }
  41058. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  41059. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41061. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  41062. if !m.op.Is(OpUpdateOne) {
  41063. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  41064. }
  41065. if m.id == nil || m.oldValue == nil {
  41066. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  41067. }
  41068. oldValue, err := m.oldValue(ctx)
  41069. if err != nil {
  41070. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  41071. }
  41072. return oldValue.AiInfo, nil
  41073. }
  41074. // ClearAiInfo clears the value of the "ai_info" field.
  41075. func (m *WxCardMutation) ClearAiInfo() {
  41076. m.ai_info = nil
  41077. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  41078. }
  41079. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  41080. func (m *WxCardMutation) AiInfoCleared() bool {
  41081. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  41082. return ok
  41083. }
  41084. // ResetAiInfo resets all changes to the "ai_info" field.
  41085. func (m *WxCardMutation) ResetAiInfo() {
  41086. m.ai_info = nil
  41087. delete(m.clearedFields, wxcard.FieldAiInfo)
  41088. }
  41089. // SetIntro sets the "intro" field.
  41090. func (m *WxCardMutation) SetIntro(s string) {
  41091. m.intro = &s
  41092. }
  41093. // Intro returns the value of the "intro" field in the mutation.
  41094. func (m *WxCardMutation) Intro() (r string, exists bool) {
  41095. v := m.intro
  41096. if v == nil {
  41097. return
  41098. }
  41099. return *v, true
  41100. }
  41101. // OldIntro returns the old "intro" field's value of the WxCard entity.
  41102. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  41103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41104. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  41105. if !m.op.Is(OpUpdateOne) {
  41106. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  41107. }
  41108. if m.id == nil || m.oldValue == nil {
  41109. return v, errors.New("OldIntro requires an ID field in the mutation")
  41110. }
  41111. oldValue, err := m.oldValue(ctx)
  41112. if err != nil {
  41113. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  41114. }
  41115. return oldValue.Intro, nil
  41116. }
  41117. // ClearIntro clears the value of the "intro" field.
  41118. func (m *WxCardMutation) ClearIntro() {
  41119. m.intro = nil
  41120. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  41121. }
  41122. // IntroCleared returns if the "intro" field was cleared in this mutation.
  41123. func (m *WxCardMutation) IntroCleared() bool {
  41124. _, ok := m.clearedFields[wxcard.FieldIntro]
  41125. return ok
  41126. }
  41127. // ResetIntro resets all changes to the "intro" field.
  41128. func (m *WxCardMutation) ResetIntro() {
  41129. m.intro = nil
  41130. delete(m.clearedFields, wxcard.FieldIntro)
  41131. }
  41132. // Where appends a list predicates to the WxCardMutation builder.
  41133. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  41134. m.predicates = append(m.predicates, ps...)
  41135. }
  41136. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  41137. // users can use type-assertion to append predicates that do not depend on any generated package.
  41138. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  41139. p := make([]predicate.WxCard, len(ps))
  41140. for i := range ps {
  41141. p[i] = ps[i]
  41142. }
  41143. m.Where(p...)
  41144. }
  41145. // Op returns the operation name.
  41146. func (m *WxCardMutation) Op() Op {
  41147. return m.op
  41148. }
  41149. // SetOp allows setting the mutation operation.
  41150. func (m *WxCardMutation) SetOp(op Op) {
  41151. m.op = op
  41152. }
  41153. // Type returns the node type of this mutation (WxCard).
  41154. func (m *WxCardMutation) Type() string {
  41155. return m.typ
  41156. }
  41157. // Fields returns all fields that were changed during this mutation. Note that in
  41158. // order to get all numeric fields that were incremented/decremented, call
  41159. // AddedFields().
  41160. func (m *WxCardMutation) Fields() []string {
  41161. fields := make([]string, 0, 18)
  41162. if m.created_at != nil {
  41163. fields = append(fields, wxcard.FieldCreatedAt)
  41164. }
  41165. if m.updated_at != nil {
  41166. fields = append(fields, wxcard.FieldUpdatedAt)
  41167. }
  41168. if m.deleted_at != nil {
  41169. fields = append(fields, wxcard.FieldDeletedAt)
  41170. }
  41171. if m.user_id != nil {
  41172. fields = append(fields, wxcard.FieldUserID)
  41173. }
  41174. if m.wx_user_id != nil {
  41175. fields = append(fields, wxcard.FieldWxUserID)
  41176. }
  41177. if m.avatar != nil {
  41178. fields = append(fields, wxcard.FieldAvatar)
  41179. }
  41180. if m.logo != nil {
  41181. fields = append(fields, wxcard.FieldLogo)
  41182. }
  41183. if m.name != nil {
  41184. fields = append(fields, wxcard.FieldName)
  41185. }
  41186. if m.company != nil {
  41187. fields = append(fields, wxcard.FieldCompany)
  41188. }
  41189. if m.address != nil {
  41190. fields = append(fields, wxcard.FieldAddress)
  41191. }
  41192. if m.phone != nil {
  41193. fields = append(fields, wxcard.FieldPhone)
  41194. }
  41195. if m.official_account != nil {
  41196. fields = append(fields, wxcard.FieldOfficialAccount)
  41197. }
  41198. if m.wechat_account != nil {
  41199. fields = append(fields, wxcard.FieldWechatAccount)
  41200. }
  41201. if m.email != nil {
  41202. fields = append(fields, wxcard.FieldEmail)
  41203. }
  41204. if m.api_base != nil {
  41205. fields = append(fields, wxcard.FieldAPIBase)
  41206. }
  41207. if m.api_key != nil {
  41208. fields = append(fields, wxcard.FieldAPIKey)
  41209. }
  41210. if m.ai_info != nil {
  41211. fields = append(fields, wxcard.FieldAiInfo)
  41212. }
  41213. if m.intro != nil {
  41214. fields = append(fields, wxcard.FieldIntro)
  41215. }
  41216. return fields
  41217. }
  41218. // Field returns the value of a field with the given name. The second boolean
  41219. // return value indicates that this field was not set, or was not defined in the
  41220. // schema.
  41221. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  41222. switch name {
  41223. case wxcard.FieldCreatedAt:
  41224. return m.CreatedAt()
  41225. case wxcard.FieldUpdatedAt:
  41226. return m.UpdatedAt()
  41227. case wxcard.FieldDeletedAt:
  41228. return m.DeletedAt()
  41229. case wxcard.FieldUserID:
  41230. return m.UserID()
  41231. case wxcard.FieldWxUserID:
  41232. return m.WxUserID()
  41233. case wxcard.FieldAvatar:
  41234. return m.Avatar()
  41235. case wxcard.FieldLogo:
  41236. return m.Logo()
  41237. case wxcard.FieldName:
  41238. return m.Name()
  41239. case wxcard.FieldCompany:
  41240. return m.Company()
  41241. case wxcard.FieldAddress:
  41242. return m.Address()
  41243. case wxcard.FieldPhone:
  41244. return m.Phone()
  41245. case wxcard.FieldOfficialAccount:
  41246. return m.OfficialAccount()
  41247. case wxcard.FieldWechatAccount:
  41248. return m.WechatAccount()
  41249. case wxcard.FieldEmail:
  41250. return m.Email()
  41251. case wxcard.FieldAPIBase:
  41252. return m.APIBase()
  41253. case wxcard.FieldAPIKey:
  41254. return m.APIKey()
  41255. case wxcard.FieldAiInfo:
  41256. return m.AiInfo()
  41257. case wxcard.FieldIntro:
  41258. return m.Intro()
  41259. }
  41260. return nil, false
  41261. }
  41262. // OldField returns the old value of the field from the database. An error is
  41263. // returned if the mutation operation is not UpdateOne, or the query to the
  41264. // database failed.
  41265. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41266. switch name {
  41267. case wxcard.FieldCreatedAt:
  41268. return m.OldCreatedAt(ctx)
  41269. case wxcard.FieldUpdatedAt:
  41270. return m.OldUpdatedAt(ctx)
  41271. case wxcard.FieldDeletedAt:
  41272. return m.OldDeletedAt(ctx)
  41273. case wxcard.FieldUserID:
  41274. return m.OldUserID(ctx)
  41275. case wxcard.FieldWxUserID:
  41276. return m.OldWxUserID(ctx)
  41277. case wxcard.FieldAvatar:
  41278. return m.OldAvatar(ctx)
  41279. case wxcard.FieldLogo:
  41280. return m.OldLogo(ctx)
  41281. case wxcard.FieldName:
  41282. return m.OldName(ctx)
  41283. case wxcard.FieldCompany:
  41284. return m.OldCompany(ctx)
  41285. case wxcard.FieldAddress:
  41286. return m.OldAddress(ctx)
  41287. case wxcard.FieldPhone:
  41288. return m.OldPhone(ctx)
  41289. case wxcard.FieldOfficialAccount:
  41290. return m.OldOfficialAccount(ctx)
  41291. case wxcard.FieldWechatAccount:
  41292. return m.OldWechatAccount(ctx)
  41293. case wxcard.FieldEmail:
  41294. return m.OldEmail(ctx)
  41295. case wxcard.FieldAPIBase:
  41296. return m.OldAPIBase(ctx)
  41297. case wxcard.FieldAPIKey:
  41298. return m.OldAPIKey(ctx)
  41299. case wxcard.FieldAiInfo:
  41300. return m.OldAiInfo(ctx)
  41301. case wxcard.FieldIntro:
  41302. return m.OldIntro(ctx)
  41303. }
  41304. return nil, fmt.Errorf("unknown WxCard field %s", name)
  41305. }
  41306. // SetField sets the value of a field with the given name. It returns an error if
  41307. // the field is not defined in the schema, or if the type mismatched the field
  41308. // type.
  41309. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  41310. switch name {
  41311. case wxcard.FieldCreatedAt:
  41312. v, ok := value.(time.Time)
  41313. if !ok {
  41314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41315. }
  41316. m.SetCreatedAt(v)
  41317. return nil
  41318. case wxcard.FieldUpdatedAt:
  41319. v, ok := value.(time.Time)
  41320. if !ok {
  41321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41322. }
  41323. m.SetUpdatedAt(v)
  41324. return nil
  41325. case wxcard.FieldDeletedAt:
  41326. v, ok := value.(time.Time)
  41327. if !ok {
  41328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41329. }
  41330. m.SetDeletedAt(v)
  41331. return nil
  41332. case wxcard.FieldUserID:
  41333. v, ok := value.(uint64)
  41334. if !ok {
  41335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41336. }
  41337. m.SetUserID(v)
  41338. return nil
  41339. case wxcard.FieldWxUserID:
  41340. v, ok := value.(uint64)
  41341. if !ok {
  41342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41343. }
  41344. m.SetWxUserID(v)
  41345. return nil
  41346. case wxcard.FieldAvatar:
  41347. v, ok := value.(string)
  41348. if !ok {
  41349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41350. }
  41351. m.SetAvatar(v)
  41352. return nil
  41353. case wxcard.FieldLogo:
  41354. v, ok := value.(string)
  41355. if !ok {
  41356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41357. }
  41358. m.SetLogo(v)
  41359. return nil
  41360. case wxcard.FieldName:
  41361. v, ok := value.(string)
  41362. if !ok {
  41363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41364. }
  41365. m.SetName(v)
  41366. return nil
  41367. case wxcard.FieldCompany:
  41368. v, ok := value.(string)
  41369. if !ok {
  41370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41371. }
  41372. m.SetCompany(v)
  41373. return nil
  41374. case wxcard.FieldAddress:
  41375. v, ok := value.(string)
  41376. if !ok {
  41377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41378. }
  41379. m.SetAddress(v)
  41380. return nil
  41381. case wxcard.FieldPhone:
  41382. v, ok := value.(string)
  41383. if !ok {
  41384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41385. }
  41386. m.SetPhone(v)
  41387. return nil
  41388. case wxcard.FieldOfficialAccount:
  41389. v, ok := value.(string)
  41390. if !ok {
  41391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41392. }
  41393. m.SetOfficialAccount(v)
  41394. return nil
  41395. case wxcard.FieldWechatAccount:
  41396. v, ok := value.(string)
  41397. if !ok {
  41398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41399. }
  41400. m.SetWechatAccount(v)
  41401. return nil
  41402. case wxcard.FieldEmail:
  41403. v, ok := value.(string)
  41404. if !ok {
  41405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41406. }
  41407. m.SetEmail(v)
  41408. return nil
  41409. case wxcard.FieldAPIBase:
  41410. v, ok := value.(string)
  41411. if !ok {
  41412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41413. }
  41414. m.SetAPIBase(v)
  41415. return nil
  41416. case wxcard.FieldAPIKey:
  41417. v, ok := value.(string)
  41418. if !ok {
  41419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41420. }
  41421. m.SetAPIKey(v)
  41422. return nil
  41423. case wxcard.FieldAiInfo:
  41424. v, ok := value.(string)
  41425. if !ok {
  41426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41427. }
  41428. m.SetAiInfo(v)
  41429. return nil
  41430. case wxcard.FieldIntro:
  41431. v, ok := value.(string)
  41432. if !ok {
  41433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41434. }
  41435. m.SetIntro(v)
  41436. return nil
  41437. }
  41438. return fmt.Errorf("unknown WxCard field %s", name)
  41439. }
  41440. // AddedFields returns all numeric fields that were incremented/decremented during
  41441. // this mutation.
  41442. func (m *WxCardMutation) AddedFields() []string {
  41443. var fields []string
  41444. if m.adduser_id != nil {
  41445. fields = append(fields, wxcard.FieldUserID)
  41446. }
  41447. if m.addwx_user_id != nil {
  41448. fields = append(fields, wxcard.FieldWxUserID)
  41449. }
  41450. return fields
  41451. }
  41452. // AddedField returns the numeric value that was incremented/decremented on a field
  41453. // with the given name. The second boolean return value indicates that this field
  41454. // was not set, or was not defined in the schema.
  41455. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  41456. switch name {
  41457. case wxcard.FieldUserID:
  41458. return m.AddedUserID()
  41459. case wxcard.FieldWxUserID:
  41460. return m.AddedWxUserID()
  41461. }
  41462. return nil, false
  41463. }
  41464. // AddField adds the value to the field with the given name. It returns an error if
  41465. // the field is not defined in the schema, or if the type mismatched the field
  41466. // type.
  41467. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  41468. switch name {
  41469. case wxcard.FieldUserID:
  41470. v, ok := value.(int64)
  41471. if !ok {
  41472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41473. }
  41474. m.AddUserID(v)
  41475. return nil
  41476. case wxcard.FieldWxUserID:
  41477. v, ok := value.(int64)
  41478. if !ok {
  41479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41480. }
  41481. m.AddWxUserID(v)
  41482. return nil
  41483. }
  41484. return fmt.Errorf("unknown WxCard numeric field %s", name)
  41485. }
  41486. // ClearedFields returns all nullable fields that were cleared during this
  41487. // mutation.
  41488. func (m *WxCardMutation) ClearedFields() []string {
  41489. var fields []string
  41490. if m.FieldCleared(wxcard.FieldDeletedAt) {
  41491. fields = append(fields, wxcard.FieldDeletedAt)
  41492. }
  41493. if m.FieldCleared(wxcard.FieldUserID) {
  41494. fields = append(fields, wxcard.FieldUserID)
  41495. }
  41496. if m.FieldCleared(wxcard.FieldWxUserID) {
  41497. fields = append(fields, wxcard.FieldWxUserID)
  41498. }
  41499. if m.FieldCleared(wxcard.FieldEmail) {
  41500. fields = append(fields, wxcard.FieldEmail)
  41501. }
  41502. if m.FieldCleared(wxcard.FieldAPIBase) {
  41503. fields = append(fields, wxcard.FieldAPIBase)
  41504. }
  41505. if m.FieldCleared(wxcard.FieldAPIKey) {
  41506. fields = append(fields, wxcard.FieldAPIKey)
  41507. }
  41508. if m.FieldCleared(wxcard.FieldAiInfo) {
  41509. fields = append(fields, wxcard.FieldAiInfo)
  41510. }
  41511. if m.FieldCleared(wxcard.FieldIntro) {
  41512. fields = append(fields, wxcard.FieldIntro)
  41513. }
  41514. return fields
  41515. }
  41516. // FieldCleared returns a boolean indicating if a field with the given name was
  41517. // cleared in this mutation.
  41518. func (m *WxCardMutation) FieldCleared(name string) bool {
  41519. _, ok := m.clearedFields[name]
  41520. return ok
  41521. }
  41522. // ClearField clears the value of the field with the given name. It returns an
  41523. // error if the field is not defined in the schema.
  41524. func (m *WxCardMutation) ClearField(name string) error {
  41525. switch name {
  41526. case wxcard.FieldDeletedAt:
  41527. m.ClearDeletedAt()
  41528. return nil
  41529. case wxcard.FieldUserID:
  41530. m.ClearUserID()
  41531. return nil
  41532. case wxcard.FieldWxUserID:
  41533. m.ClearWxUserID()
  41534. return nil
  41535. case wxcard.FieldEmail:
  41536. m.ClearEmail()
  41537. return nil
  41538. case wxcard.FieldAPIBase:
  41539. m.ClearAPIBase()
  41540. return nil
  41541. case wxcard.FieldAPIKey:
  41542. m.ClearAPIKey()
  41543. return nil
  41544. case wxcard.FieldAiInfo:
  41545. m.ClearAiInfo()
  41546. return nil
  41547. case wxcard.FieldIntro:
  41548. m.ClearIntro()
  41549. return nil
  41550. }
  41551. return fmt.Errorf("unknown WxCard nullable field %s", name)
  41552. }
  41553. // ResetField resets all changes in the mutation for the field with the given name.
  41554. // It returns an error if the field is not defined in the schema.
  41555. func (m *WxCardMutation) ResetField(name string) error {
  41556. switch name {
  41557. case wxcard.FieldCreatedAt:
  41558. m.ResetCreatedAt()
  41559. return nil
  41560. case wxcard.FieldUpdatedAt:
  41561. m.ResetUpdatedAt()
  41562. return nil
  41563. case wxcard.FieldDeletedAt:
  41564. m.ResetDeletedAt()
  41565. return nil
  41566. case wxcard.FieldUserID:
  41567. m.ResetUserID()
  41568. return nil
  41569. case wxcard.FieldWxUserID:
  41570. m.ResetWxUserID()
  41571. return nil
  41572. case wxcard.FieldAvatar:
  41573. m.ResetAvatar()
  41574. return nil
  41575. case wxcard.FieldLogo:
  41576. m.ResetLogo()
  41577. return nil
  41578. case wxcard.FieldName:
  41579. m.ResetName()
  41580. return nil
  41581. case wxcard.FieldCompany:
  41582. m.ResetCompany()
  41583. return nil
  41584. case wxcard.FieldAddress:
  41585. m.ResetAddress()
  41586. return nil
  41587. case wxcard.FieldPhone:
  41588. m.ResetPhone()
  41589. return nil
  41590. case wxcard.FieldOfficialAccount:
  41591. m.ResetOfficialAccount()
  41592. return nil
  41593. case wxcard.FieldWechatAccount:
  41594. m.ResetWechatAccount()
  41595. return nil
  41596. case wxcard.FieldEmail:
  41597. m.ResetEmail()
  41598. return nil
  41599. case wxcard.FieldAPIBase:
  41600. m.ResetAPIBase()
  41601. return nil
  41602. case wxcard.FieldAPIKey:
  41603. m.ResetAPIKey()
  41604. return nil
  41605. case wxcard.FieldAiInfo:
  41606. m.ResetAiInfo()
  41607. return nil
  41608. case wxcard.FieldIntro:
  41609. m.ResetIntro()
  41610. return nil
  41611. }
  41612. return fmt.Errorf("unknown WxCard field %s", name)
  41613. }
  41614. // AddedEdges returns all edge names that were set/added in this mutation.
  41615. func (m *WxCardMutation) AddedEdges() []string {
  41616. edges := make([]string, 0, 0)
  41617. return edges
  41618. }
  41619. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41620. // name in this mutation.
  41621. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  41622. return nil
  41623. }
  41624. // RemovedEdges returns all edge names that were removed in this mutation.
  41625. func (m *WxCardMutation) RemovedEdges() []string {
  41626. edges := make([]string, 0, 0)
  41627. return edges
  41628. }
  41629. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41630. // the given name in this mutation.
  41631. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  41632. return nil
  41633. }
  41634. // ClearedEdges returns all edge names that were cleared in this mutation.
  41635. func (m *WxCardMutation) ClearedEdges() []string {
  41636. edges := make([]string, 0, 0)
  41637. return edges
  41638. }
  41639. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41640. // was cleared in this mutation.
  41641. func (m *WxCardMutation) EdgeCleared(name string) bool {
  41642. return false
  41643. }
  41644. // ClearEdge clears the value of the edge with the given name. It returns an error
  41645. // if that edge is not defined in the schema.
  41646. func (m *WxCardMutation) ClearEdge(name string) error {
  41647. return fmt.Errorf("unknown WxCard unique edge %s", name)
  41648. }
  41649. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41650. // It returns an error if the edge is not defined in the schema.
  41651. func (m *WxCardMutation) ResetEdge(name string) error {
  41652. return fmt.Errorf("unknown WxCard edge %s", name)
  41653. }
  41654. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  41655. type WxCardUserMutation struct {
  41656. config
  41657. op Op
  41658. typ string
  41659. id *uint64
  41660. created_at *time.Time
  41661. updated_at *time.Time
  41662. deleted_at *time.Time
  41663. wxid *string
  41664. account *string
  41665. avatar *string
  41666. nickname *string
  41667. remark *string
  41668. phone *string
  41669. open_id *string
  41670. union_id *string
  41671. session_key *string
  41672. is_vip *int
  41673. addis_vip *int
  41674. clearedFields map[string]struct{}
  41675. done bool
  41676. oldValue func(context.Context) (*WxCardUser, error)
  41677. predicates []predicate.WxCardUser
  41678. }
  41679. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  41680. // wxcarduserOption allows management of the mutation configuration using functional options.
  41681. type wxcarduserOption func(*WxCardUserMutation)
  41682. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  41683. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  41684. m := &WxCardUserMutation{
  41685. config: c,
  41686. op: op,
  41687. typ: TypeWxCardUser,
  41688. clearedFields: make(map[string]struct{}),
  41689. }
  41690. for _, opt := range opts {
  41691. opt(m)
  41692. }
  41693. return m
  41694. }
  41695. // withWxCardUserID sets the ID field of the mutation.
  41696. func withWxCardUserID(id uint64) wxcarduserOption {
  41697. return func(m *WxCardUserMutation) {
  41698. var (
  41699. err error
  41700. once sync.Once
  41701. value *WxCardUser
  41702. )
  41703. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  41704. once.Do(func() {
  41705. if m.done {
  41706. err = errors.New("querying old values post mutation is not allowed")
  41707. } else {
  41708. value, err = m.Client().WxCardUser.Get(ctx, id)
  41709. }
  41710. })
  41711. return value, err
  41712. }
  41713. m.id = &id
  41714. }
  41715. }
  41716. // withWxCardUser sets the old WxCardUser of the mutation.
  41717. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  41718. return func(m *WxCardUserMutation) {
  41719. m.oldValue = func(context.Context) (*WxCardUser, error) {
  41720. return node, nil
  41721. }
  41722. m.id = &node.ID
  41723. }
  41724. }
  41725. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41726. // executed in a transaction (ent.Tx), a transactional client is returned.
  41727. func (m WxCardUserMutation) Client() *Client {
  41728. client := &Client{config: m.config}
  41729. client.init()
  41730. return client
  41731. }
  41732. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41733. // it returns an error otherwise.
  41734. func (m WxCardUserMutation) Tx() (*Tx, error) {
  41735. if _, ok := m.driver.(*txDriver); !ok {
  41736. return nil, errors.New("ent: mutation is not running in a transaction")
  41737. }
  41738. tx := &Tx{config: m.config}
  41739. tx.init()
  41740. return tx, nil
  41741. }
  41742. // SetID sets the value of the id field. Note that this
  41743. // operation is only accepted on creation of WxCardUser entities.
  41744. func (m *WxCardUserMutation) SetID(id uint64) {
  41745. m.id = &id
  41746. }
  41747. // ID returns the ID value in the mutation. Note that the ID is only available
  41748. // if it was provided to the builder or after it was returned from the database.
  41749. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  41750. if m.id == nil {
  41751. return
  41752. }
  41753. return *m.id, true
  41754. }
  41755. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41756. // That means, if the mutation is applied within a transaction with an isolation level such
  41757. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41758. // or updated by the mutation.
  41759. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  41760. switch {
  41761. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41762. id, exists := m.ID()
  41763. if exists {
  41764. return []uint64{id}, nil
  41765. }
  41766. fallthrough
  41767. case m.op.Is(OpUpdate | OpDelete):
  41768. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  41769. default:
  41770. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41771. }
  41772. }
  41773. // SetCreatedAt sets the "created_at" field.
  41774. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  41775. m.created_at = &t
  41776. }
  41777. // CreatedAt returns the value of the "created_at" field in the mutation.
  41778. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  41779. v := m.created_at
  41780. if v == nil {
  41781. return
  41782. }
  41783. return *v, true
  41784. }
  41785. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  41786. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41788. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41789. if !m.op.Is(OpUpdateOne) {
  41790. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41791. }
  41792. if m.id == nil || m.oldValue == nil {
  41793. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41794. }
  41795. oldValue, err := m.oldValue(ctx)
  41796. if err != nil {
  41797. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41798. }
  41799. return oldValue.CreatedAt, nil
  41800. }
  41801. // ResetCreatedAt resets all changes to the "created_at" field.
  41802. func (m *WxCardUserMutation) ResetCreatedAt() {
  41803. m.created_at = nil
  41804. }
  41805. // SetUpdatedAt sets the "updated_at" field.
  41806. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  41807. m.updated_at = &t
  41808. }
  41809. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41810. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  41811. v := m.updated_at
  41812. if v == nil {
  41813. return
  41814. }
  41815. return *v, true
  41816. }
  41817. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  41818. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41820. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41821. if !m.op.Is(OpUpdateOne) {
  41822. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41823. }
  41824. if m.id == nil || m.oldValue == nil {
  41825. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41826. }
  41827. oldValue, err := m.oldValue(ctx)
  41828. if err != nil {
  41829. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41830. }
  41831. return oldValue.UpdatedAt, nil
  41832. }
  41833. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41834. func (m *WxCardUserMutation) ResetUpdatedAt() {
  41835. m.updated_at = nil
  41836. }
  41837. // SetDeletedAt sets the "deleted_at" field.
  41838. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  41839. m.deleted_at = &t
  41840. }
  41841. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41842. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  41843. v := m.deleted_at
  41844. if v == nil {
  41845. return
  41846. }
  41847. return *v, true
  41848. }
  41849. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  41850. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41852. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41853. if !m.op.Is(OpUpdateOne) {
  41854. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41855. }
  41856. if m.id == nil || m.oldValue == nil {
  41857. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41858. }
  41859. oldValue, err := m.oldValue(ctx)
  41860. if err != nil {
  41861. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41862. }
  41863. return oldValue.DeletedAt, nil
  41864. }
  41865. // ClearDeletedAt clears the value of the "deleted_at" field.
  41866. func (m *WxCardUserMutation) ClearDeletedAt() {
  41867. m.deleted_at = nil
  41868. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  41869. }
  41870. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41871. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  41872. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  41873. return ok
  41874. }
  41875. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41876. func (m *WxCardUserMutation) ResetDeletedAt() {
  41877. m.deleted_at = nil
  41878. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  41879. }
  41880. // SetWxid sets the "wxid" field.
  41881. func (m *WxCardUserMutation) SetWxid(s string) {
  41882. m.wxid = &s
  41883. }
  41884. // Wxid returns the value of the "wxid" field in the mutation.
  41885. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  41886. v := m.wxid
  41887. if v == nil {
  41888. return
  41889. }
  41890. return *v, true
  41891. }
  41892. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  41893. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41895. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  41896. if !m.op.Is(OpUpdateOne) {
  41897. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  41898. }
  41899. if m.id == nil || m.oldValue == nil {
  41900. return v, errors.New("OldWxid requires an ID field in the mutation")
  41901. }
  41902. oldValue, err := m.oldValue(ctx)
  41903. if err != nil {
  41904. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41905. }
  41906. return oldValue.Wxid, nil
  41907. }
  41908. // ResetWxid resets all changes to the "wxid" field.
  41909. func (m *WxCardUserMutation) ResetWxid() {
  41910. m.wxid = nil
  41911. }
  41912. // SetAccount sets the "account" field.
  41913. func (m *WxCardUserMutation) SetAccount(s string) {
  41914. m.account = &s
  41915. }
  41916. // Account returns the value of the "account" field in the mutation.
  41917. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  41918. v := m.account
  41919. if v == nil {
  41920. return
  41921. }
  41922. return *v, true
  41923. }
  41924. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  41925. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41927. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  41928. if !m.op.Is(OpUpdateOne) {
  41929. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41930. }
  41931. if m.id == nil || m.oldValue == nil {
  41932. return v, errors.New("OldAccount requires an ID field in the mutation")
  41933. }
  41934. oldValue, err := m.oldValue(ctx)
  41935. if err != nil {
  41936. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  41937. }
  41938. return oldValue.Account, nil
  41939. }
  41940. // ResetAccount resets all changes to the "account" field.
  41941. func (m *WxCardUserMutation) ResetAccount() {
  41942. m.account = nil
  41943. }
  41944. // SetAvatar sets the "avatar" field.
  41945. func (m *WxCardUserMutation) SetAvatar(s string) {
  41946. m.avatar = &s
  41947. }
  41948. // Avatar returns the value of the "avatar" field in the mutation.
  41949. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  41950. v := m.avatar
  41951. if v == nil {
  41952. return
  41953. }
  41954. return *v, true
  41955. }
  41956. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  41957. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41959. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41960. if !m.op.Is(OpUpdateOne) {
  41961. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41962. }
  41963. if m.id == nil || m.oldValue == nil {
  41964. return v, errors.New("OldAvatar requires an ID field in the mutation")
  41965. }
  41966. oldValue, err := m.oldValue(ctx)
  41967. if err != nil {
  41968. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  41969. }
  41970. return oldValue.Avatar, nil
  41971. }
  41972. // ResetAvatar resets all changes to the "avatar" field.
  41973. func (m *WxCardUserMutation) ResetAvatar() {
  41974. m.avatar = nil
  41975. }
  41976. // SetNickname sets the "nickname" field.
  41977. func (m *WxCardUserMutation) SetNickname(s string) {
  41978. m.nickname = &s
  41979. }
  41980. // Nickname returns the value of the "nickname" field in the mutation.
  41981. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  41982. v := m.nickname
  41983. if v == nil {
  41984. return
  41985. }
  41986. return *v, true
  41987. }
  41988. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  41989. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  41990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41991. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  41992. if !m.op.Is(OpUpdateOne) {
  41993. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41994. }
  41995. if m.id == nil || m.oldValue == nil {
  41996. return v, errors.New("OldNickname requires an ID field in the mutation")
  41997. }
  41998. oldValue, err := m.oldValue(ctx)
  41999. if err != nil {
  42000. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  42001. }
  42002. return oldValue.Nickname, nil
  42003. }
  42004. // ResetNickname resets all changes to the "nickname" field.
  42005. func (m *WxCardUserMutation) ResetNickname() {
  42006. m.nickname = nil
  42007. }
  42008. // SetRemark sets the "remark" field.
  42009. func (m *WxCardUserMutation) SetRemark(s string) {
  42010. m.remark = &s
  42011. }
  42012. // Remark returns the value of the "remark" field in the mutation.
  42013. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  42014. v := m.remark
  42015. if v == nil {
  42016. return
  42017. }
  42018. return *v, true
  42019. }
  42020. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  42021. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42023. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  42024. if !m.op.Is(OpUpdateOne) {
  42025. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  42026. }
  42027. if m.id == nil || m.oldValue == nil {
  42028. return v, errors.New("OldRemark requires an ID field in the mutation")
  42029. }
  42030. oldValue, err := m.oldValue(ctx)
  42031. if err != nil {
  42032. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  42033. }
  42034. return oldValue.Remark, nil
  42035. }
  42036. // ResetRemark resets all changes to the "remark" field.
  42037. func (m *WxCardUserMutation) ResetRemark() {
  42038. m.remark = nil
  42039. }
  42040. // SetPhone sets the "phone" field.
  42041. func (m *WxCardUserMutation) SetPhone(s string) {
  42042. m.phone = &s
  42043. }
  42044. // Phone returns the value of the "phone" field in the mutation.
  42045. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  42046. v := m.phone
  42047. if v == nil {
  42048. return
  42049. }
  42050. return *v, true
  42051. }
  42052. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  42053. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42055. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  42056. if !m.op.Is(OpUpdateOne) {
  42057. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  42058. }
  42059. if m.id == nil || m.oldValue == nil {
  42060. return v, errors.New("OldPhone requires an ID field in the mutation")
  42061. }
  42062. oldValue, err := m.oldValue(ctx)
  42063. if err != nil {
  42064. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  42065. }
  42066. return oldValue.Phone, nil
  42067. }
  42068. // ResetPhone resets all changes to the "phone" field.
  42069. func (m *WxCardUserMutation) ResetPhone() {
  42070. m.phone = nil
  42071. }
  42072. // SetOpenID sets the "open_id" field.
  42073. func (m *WxCardUserMutation) SetOpenID(s string) {
  42074. m.open_id = &s
  42075. }
  42076. // OpenID returns the value of the "open_id" field in the mutation.
  42077. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  42078. v := m.open_id
  42079. if v == nil {
  42080. return
  42081. }
  42082. return *v, true
  42083. }
  42084. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  42085. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42087. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  42088. if !m.op.Is(OpUpdateOne) {
  42089. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  42090. }
  42091. if m.id == nil || m.oldValue == nil {
  42092. return v, errors.New("OldOpenID requires an ID field in the mutation")
  42093. }
  42094. oldValue, err := m.oldValue(ctx)
  42095. if err != nil {
  42096. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  42097. }
  42098. return oldValue.OpenID, nil
  42099. }
  42100. // ResetOpenID resets all changes to the "open_id" field.
  42101. func (m *WxCardUserMutation) ResetOpenID() {
  42102. m.open_id = nil
  42103. }
  42104. // SetUnionID sets the "union_id" field.
  42105. func (m *WxCardUserMutation) SetUnionID(s string) {
  42106. m.union_id = &s
  42107. }
  42108. // UnionID returns the value of the "union_id" field in the mutation.
  42109. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  42110. v := m.union_id
  42111. if v == nil {
  42112. return
  42113. }
  42114. return *v, true
  42115. }
  42116. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  42117. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42119. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  42120. if !m.op.Is(OpUpdateOne) {
  42121. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  42122. }
  42123. if m.id == nil || m.oldValue == nil {
  42124. return v, errors.New("OldUnionID requires an ID field in the mutation")
  42125. }
  42126. oldValue, err := m.oldValue(ctx)
  42127. if err != nil {
  42128. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  42129. }
  42130. return oldValue.UnionID, nil
  42131. }
  42132. // ResetUnionID resets all changes to the "union_id" field.
  42133. func (m *WxCardUserMutation) ResetUnionID() {
  42134. m.union_id = nil
  42135. }
  42136. // SetSessionKey sets the "session_key" field.
  42137. func (m *WxCardUserMutation) SetSessionKey(s string) {
  42138. m.session_key = &s
  42139. }
  42140. // SessionKey returns the value of the "session_key" field in the mutation.
  42141. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  42142. v := m.session_key
  42143. if v == nil {
  42144. return
  42145. }
  42146. return *v, true
  42147. }
  42148. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  42149. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42151. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  42152. if !m.op.Is(OpUpdateOne) {
  42153. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  42154. }
  42155. if m.id == nil || m.oldValue == nil {
  42156. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  42157. }
  42158. oldValue, err := m.oldValue(ctx)
  42159. if err != nil {
  42160. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  42161. }
  42162. return oldValue.SessionKey, nil
  42163. }
  42164. // ResetSessionKey resets all changes to the "session_key" field.
  42165. func (m *WxCardUserMutation) ResetSessionKey() {
  42166. m.session_key = nil
  42167. }
  42168. // SetIsVip sets the "is_vip" field.
  42169. func (m *WxCardUserMutation) SetIsVip(i int) {
  42170. m.is_vip = &i
  42171. m.addis_vip = nil
  42172. }
  42173. // IsVip returns the value of the "is_vip" field in the mutation.
  42174. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  42175. v := m.is_vip
  42176. if v == nil {
  42177. return
  42178. }
  42179. return *v, true
  42180. }
  42181. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  42182. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  42183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42184. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  42185. if !m.op.Is(OpUpdateOne) {
  42186. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  42187. }
  42188. if m.id == nil || m.oldValue == nil {
  42189. return v, errors.New("OldIsVip requires an ID field in the mutation")
  42190. }
  42191. oldValue, err := m.oldValue(ctx)
  42192. if err != nil {
  42193. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  42194. }
  42195. return oldValue.IsVip, nil
  42196. }
  42197. // AddIsVip adds i to the "is_vip" field.
  42198. func (m *WxCardUserMutation) AddIsVip(i int) {
  42199. if m.addis_vip != nil {
  42200. *m.addis_vip += i
  42201. } else {
  42202. m.addis_vip = &i
  42203. }
  42204. }
  42205. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  42206. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  42207. v := m.addis_vip
  42208. if v == nil {
  42209. return
  42210. }
  42211. return *v, true
  42212. }
  42213. // ResetIsVip resets all changes to the "is_vip" field.
  42214. func (m *WxCardUserMutation) ResetIsVip() {
  42215. m.is_vip = nil
  42216. m.addis_vip = nil
  42217. }
  42218. // Where appends a list predicates to the WxCardUserMutation builder.
  42219. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  42220. m.predicates = append(m.predicates, ps...)
  42221. }
  42222. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  42223. // users can use type-assertion to append predicates that do not depend on any generated package.
  42224. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  42225. p := make([]predicate.WxCardUser, len(ps))
  42226. for i := range ps {
  42227. p[i] = ps[i]
  42228. }
  42229. m.Where(p...)
  42230. }
  42231. // Op returns the operation name.
  42232. func (m *WxCardUserMutation) Op() Op {
  42233. return m.op
  42234. }
  42235. // SetOp allows setting the mutation operation.
  42236. func (m *WxCardUserMutation) SetOp(op Op) {
  42237. m.op = op
  42238. }
  42239. // Type returns the node type of this mutation (WxCardUser).
  42240. func (m *WxCardUserMutation) Type() string {
  42241. return m.typ
  42242. }
  42243. // Fields returns all fields that were changed during this mutation. Note that in
  42244. // order to get all numeric fields that were incremented/decremented, call
  42245. // AddedFields().
  42246. func (m *WxCardUserMutation) Fields() []string {
  42247. fields := make([]string, 0, 13)
  42248. if m.created_at != nil {
  42249. fields = append(fields, wxcarduser.FieldCreatedAt)
  42250. }
  42251. if m.updated_at != nil {
  42252. fields = append(fields, wxcarduser.FieldUpdatedAt)
  42253. }
  42254. if m.deleted_at != nil {
  42255. fields = append(fields, wxcarduser.FieldDeletedAt)
  42256. }
  42257. if m.wxid != nil {
  42258. fields = append(fields, wxcarduser.FieldWxid)
  42259. }
  42260. if m.account != nil {
  42261. fields = append(fields, wxcarduser.FieldAccount)
  42262. }
  42263. if m.avatar != nil {
  42264. fields = append(fields, wxcarduser.FieldAvatar)
  42265. }
  42266. if m.nickname != nil {
  42267. fields = append(fields, wxcarduser.FieldNickname)
  42268. }
  42269. if m.remark != nil {
  42270. fields = append(fields, wxcarduser.FieldRemark)
  42271. }
  42272. if m.phone != nil {
  42273. fields = append(fields, wxcarduser.FieldPhone)
  42274. }
  42275. if m.open_id != nil {
  42276. fields = append(fields, wxcarduser.FieldOpenID)
  42277. }
  42278. if m.union_id != nil {
  42279. fields = append(fields, wxcarduser.FieldUnionID)
  42280. }
  42281. if m.session_key != nil {
  42282. fields = append(fields, wxcarduser.FieldSessionKey)
  42283. }
  42284. if m.is_vip != nil {
  42285. fields = append(fields, wxcarduser.FieldIsVip)
  42286. }
  42287. return fields
  42288. }
  42289. // Field returns the value of a field with the given name. The second boolean
  42290. // return value indicates that this field was not set, or was not defined in the
  42291. // schema.
  42292. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  42293. switch name {
  42294. case wxcarduser.FieldCreatedAt:
  42295. return m.CreatedAt()
  42296. case wxcarduser.FieldUpdatedAt:
  42297. return m.UpdatedAt()
  42298. case wxcarduser.FieldDeletedAt:
  42299. return m.DeletedAt()
  42300. case wxcarduser.FieldWxid:
  42301. return m.Wxid()
  42302. case wxcarduser.FieldAccount:
  42303. return m.Account()
  42304. case wxcarduser.FieldAvatar:
  42305. return m.Avatar()
  42306. case wxcarduser.FieldNickname:
  42307. return m.Nickname()
  42308. case wxcarduser.FieldRemark:
  42309. return m.Remark()
  42310. case wxcarduser.FieldPhone:
  42311. return m.Phone()
  42312. case wxcarduser.FieldOpenID:
  42313. return m.OpenID()
  42314. case wxcarduser.FieldUnionID:
  42315. return m.UnionID()
  42316. case wxcarduser.FieldSessionKey:
  42317. return m.SessionKey()
  42318. case wxcarduser.FieldIsVip:
  42319. return m.IsVip()
  42320. }
  42321. return nil, false
  42322. }
  42323. // OldField returns the old value of the field from the database. An error is
  42324. // returned if the mutation operation is not UpdateOne, or the query to the
  42325. // database failed.
  42326. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42327. switch name {
  42328. case wxcarduser.FieldCreatedAt:
  42329. return m.OldCreatedAt(ctx)
  42330. case wxcarduser.FieldUpdatedAt:
  42331. return m.OldUpdatedAt(ctx)
  42332. case wxcarduser.FieldDeletedAt:
  42333. return m.OldDeletedAt(ctx)
  42334. case wxcarduser.FieldWxid:
  42335. return m.OldWxid(ctx)
  42336. case wxcarduser.FieldAccount:
  42337. return m.OldAccount(ctx)
  42338. case wxcarduser.FieldAvatar:
  42339. return m.OldAvatar(ctx)
  42340. case wxcarduser.FieldNickname:
  42341. return m.OldNickname(ctx)
  42342. case wxcarduser.FieldRemark:
  42343. return m.OldRemark(ctx)
  42344. case wxcarduser.FieldPhone:
  42345. return m.OldPhone(ctx)
  42346. case wxcarduser.FieldOpenID:
  42347. return m.OldOpenID(ctx)
  42348. case wxcarduser.FieldUnionID:
  42349. return m.OldUnionID(ctx)
  42350. case wxcarduser.FieldSessionKey:
  42351. return m.OldSessionKey(ctx)
  42352. case wxcarduser.FieldIsVip:
  42353. return m.OldIsVip(ctx)
  42354. }
  42355. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  42356. }
  42357. // SetField sets the value of a field with the given name. It returns an error if
  42358. // the field is not defined in the schema, or if the type mismatched the field
  42359. // type.
  42360. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  42361. switch name {
  42362. case wxcarduser.FieldCreatedAt:
  42363. v, ok := value.(time.Time)
  42364. if !ok {
  42365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42366. }
  42367. m.SetCreatedAt(v)
  42368. return nil
  42369. case wxcarduser.FieldUpdatedAt:
  42370. v, ok := value.(time.Time)
  42371. if !ok {
  42372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42373. }
  42374. m.SetUpdatedAt(v)
  42375. return nil
  42376. case wxcarduser.FieldDeletedAt:
  42377. v, ok := value.(time.Time)
  42378. if !ok {
  42379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42380. }
  42381. m.SetDeletedAt(v)
  42382. return nil
  42383. case wxcarduser.FieldWxid:
  42384. v, ok := value.(string)
  42385. if !ok {
  42386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42387. }
  42388. m.SetWxid(v)
  42389. return nil
  42390. case wxcarduser.FieldAccount:
  42391. v, ok := value.(string)
  42392. if !ok {
  42393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42394. }
  42395. m.SetAccount(v)
  42396. return nil
  42397. case wxcarduser.FieldAvatar:
  42398. v, ok := value.(string)
  42399. if !ok {
  42400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42401. }
  42402. m.SetAvatar(v)
  42403. return nil
  42404. case wxcarduser.FieldNickname:
  42405. v, ok := value.(string)
  42406. if !ok {
  42407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42408. }
  42409. m.SetNickname(v)
  42410. return nil
  42411. case wxcarduser.FieldRemark:
  42412. v, ok := value.(string)
  42413. if !ok {
  42414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42415. }
  42416. m.SetRemark(v)
  42417. return nil
  42418. case wxcarduser.FieldPhone:
  42419. v, ok := value.(string)
  42420. if !ok {
  42421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42422. }
  42423. m.SetPhone(v)
  42424. return nil
  42425. case wxcarduser.FieldOpenID:
  42426. v, ok := value.(string)
  42427. if !ok {
  42428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42429. }
  42430. m.SetOpenID(v)
  42431. return nil
  42432. case wxcarduser.FieldUnionID:
  42433. v, ok := value.(string)
  42434. if !ok {
  42435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42436. }
  42437. m.SetUnionID(v)
  42438. return nil
  42439. case wxcarduser.FieldSessionKey:
  42440. v, ok := value.(string)
  42441. if !ok {
  42442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42443. }
  42444. m.SetSessionKey(v)
  42445. return nil
  42446. case wxcarduser.FieldIsVip:
  42447. v, ok := value.(int)
  42448. if !ok {
  42449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42450. }
  42451. m.SetIsVip(v)
  42452. return nil
  42453. }
  42454. return fmt.Errorf("unknown WxCardUser field %s", name)
  42455. }
  42456. // AddedFields returns all numeric fields that were incremented/decremented during
  42457. // this mutation.
  42458. func (m *WxCardUserMutation) AddedFields() []string {
  42459. var fields []string
  42460. if m.addis_vip != nil {
  42461. fields = append(fields, wxcarduser.FieldIsVip)
  42462. }
  42463. return fields
  42464. }
  42465. // AddedField returns the numeric value that was incremented/decremented on a field
  42466. // with the given name. The second boolean return value indicates that this field
  42467. // was not set, or was not defined in the schema.
  42468. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  42469. switch name {
  42470. case wxcarduser.FieldIsVip:
  42471. return m.AddedIsVip()
  42472. }
  42473. return nil, false
  42474. }
  42475. // AddField adds the value to the field with the given name. It returns an error if
  42476. // the field is not defined in the schema, or if the type mismatched the field
  42477. // type.
  42478. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  42479. switch name {
  42480. case wxcarduser.FieldIsVip:
  42481. v, ok := value.(int)
  42482. if !ok {
  42483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42484. }
  42485. m.AddIsVip(v)
  42486. return nil
  42487. }
  42488. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  42489. }
  42490. // ClearedFields returns all nullable fields that were cleared during this
  42491. // mutation.
  42492. func (m *WxCardUserMutation) ClearedFields() []string {
  42493. var fields []string
  42494. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  42495. fields = append(fields, wxcarduser.FieldDeletedAt)
  42496. }
  42497. return fields
  42498. }
  42499. // FieldCleared returns a boolean indicating if a field with the given name was
  42500. // cleared in this mutation.
  42501. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  42502. _, ok := m.clearedFields[name]
  42503. return ok
  42504. }
  42505. // ClearField clears the value of the field with the given name. It returns an
  42506. // error if the field is not defined in the schema.
  42507. func (m *WxCardUserMutation) ClearField(name string) error {
  42508. switch name {
  42509. case wxcarduser.FieldDeletedAt:
  42510. m.ClearDeletedAt()
  42511. return nil
  42512. }
  42513. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  42514. }
  42515. // ResetField resets all changes in the mutation for the field with the given name.
  42516. // It returns an error if the field is not defined in the schema.
  42517. func (m *WxCardUserMutation) ResetField(name string) error {
  42518. switch name {
  42519. case wxcarduser.FieldCreatedAt:
  42520. m.ResetCreatedAt()
  42521. return nil
  42522. case wxcarduser.FieldUpdatedAt:
  42523. m.ResetUpdatedAt()
  42524. return nil
  42525. case wxcarduser.FieldDeletedAt:
  42526. m.ResetDeletedAt()
  42527. return nil
  42528. case wxcarduser.FieldWxid:
  42529. m.ResetWxid()
  42530. return nil
  42531. case wxcarduser.FieldAccount:
  42532. m.ResetAccount()
  42533. return nil
  42534. case wxcarduser.FieldAvatar:
  42535. m.ResetAvatar()
  42536. return nil
  42537. case wxcarduser.FieldNickname:
  42538. m.ResetNickname()
  42539. return nil
  42540. case wxcarduser.FieldRemark:
  42541. m.ResetRemark()
  42542. return nil
  42543. case wxcarduser.FieldPhone:
  42544. m.ResetPhone()
  42545. return nil
  42546. case wxcarduser.FieldOpenID:
  42547. m.ResetOpenID()
  42548. return nil
  42549. case wxcarduser.FieldUnionID:
  42550. m.ResetUnionID()
  42551. return nil
  42552. case wxcarduser.FieldSessionKey:
  42553. m.ResetSessionKey()
  42554. return nil
  42555. case wxcarduser.FieldIsVip:
  42556. m.ResetIsVip()
  42557. return nil
  42558. }
  42559. return fmt.Errorf("unknown WxCardUser field %s", name)
  42560. }
  42561. // AddedEdges returns all edge names that were set/added in this mutation.
  42562. func (m *WxCardUserMutation) AddedEdges() []string {
  42563. edges := make([]string, 0, 0)
  42564. return edges
  42565. }
  42566. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42567. // name in this mutation.
  42568. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  42569. return nil
  42570. }
  42571. // RemovedEdges returns all edge names that were removed in this mutation.
  42572. func (m *WxCardUserMutation) RemovedEdges() []string {
  42573. edges := make([]string, 0, 0)
  42574. return edges
  42575. }
  42576. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42577. // the given name in this mutation.
  42578. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  42579. return nil
  42580. }
  42581. // ClearedEdges returns all edge names that were cleared in this mutation.
  42582. func (m *WxCardUserMutation) ClearedEdges() []string {
  42583. edges := make([]string, 0, 0)
  42584. return edges
  42585. }
  42586. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42587. // was cleared in this mutation.
  42588. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  42589. return false
  42590. }
  42591. // ClearEdge clears the value of the edge with the given name. It returns an error
  42592. // if that edge is not defined in the schema.
  42593. func (m *WxCardUserMutation) ClearEdge(name string) error {
  42594. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  42595. }
  42596. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42597. // It returns an error if the edge is not defined in the schema.
  42598. func (m *WxCardUserMutation) ResetEdge(name string) error {
  42599. return fmt.Errorf("unknown WxCardUser edge %s", name)
  42600. }
  42601. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  42602. type WxCardVisitMutation struct {
  42603. config
  42604. op Op
  42605. typ string
  42606. id *uint64
  42607. created_at *time.Time
  42608. updated_at *time.Time
  42609. deleted_at *time.Time
  42610. user_id *uint64
  42611. adduser_id *int64
  42612. bot_id *uint64
  42613. addbot_id *int64
  42614. bot_type *uint8
  42615. addbot_type *int8
  42616. clearedFields map[string]struct{}
  42617. done bool
  42618. oldValue func(context.Context) (*WxCardVisit, error)
  42619. predicates []predicate.WxCardVisit
  42620. }
  42621. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  42622. // wxcardvisitOption allows management of the mutation configuration using functional options.
  42623. type wxcardvisitOption func(*WxCardVisitMutation)
  42624. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  42625. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  42626. m := &WxCardVisitMutation{
  42627. config: c,
  42628. op: op,
  42629. typ: TypeWxCardVisit,
  42630. clearedFields: make(map[string]struct{}),
  42631. }
  42632. for _, opt := range opts {
  42633. opt(m)
  42634. }
  42635. return m
  42636. }
  42637. // withWxCardVisitID sets the ID field of the mutation.
  42638. func withWxCardVisitID(id uint64) wxcardvisitOption {
  42639. return func(m *WxCardVisitMutation) {
  42640. var (
  42641. err error
  42642. once sync.Once
  42643. value *WxCardVisit
  42644. )
  42645. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  42646. once.Do(func() {
  42647. if m.done {
  42648. err = errors.New("querying old values post mutation is not allowed")
  42649. } else {
  42650. value, err = m.Client().WxCardVisit.Get(ctx, id)
  42651. }
  42652. })
  42653. return value, err
  42654. }
  42655. m.id = &id
  42656. }
  42657. }
  42658. // withWxCardVisit sets the old WxCardVisit of the mutation.
  42659. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  42660. return func(m *WxCardVisitMutation) {
  42661. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  42662. return node, nil
  42663. }
  42664. m.id = &node.ID
  42665. }
  42666. }
  42667. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42668. // executed in a transaction (ent.Tx), a transactional client is returned.
  42669. func (m WxCardVisitMutation) Client() *Client {
  42670. client := &Client{config: m.config}
  42671. client.init()
  42672. return client
  42673. }
  42674. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42675. // it returns an error otherwise.
  42676. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  42677. if _, ok := m.driver.(*txDriver); !ok {
  42678. return nil, errors.New("ent: mutation is not running in a transaction")
  42679. }
  42680. tx := &Tx{config: m.config}
  42681. tx.init()
  42682. return tx, nil
  42683. }
  42684. // SetID sets the value of the id field. Note that this
  42685. // operation is only accepted on creation of WxCardVisit entities.
  42686. func (m *WxCardVisitMutation) SetID(id uint64) {
  42687. m.id = &id
  42688. }
  42689. // ID returns the ID value in the mutation. Note that the ID is only available
  42690. // if it was provided to the builder or after it was returned from the database.
  42691. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  42692. if m.id == nil {
  42693. return
  42694. }
  42695. return *m.id, true
  42696. }
  42697. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42698. // That means, if the mutation is applied within a transaction with an isolation level such
  42699. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42700. // or updated by the mutation.
  42701. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  42702. switch {
  42703. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42704. id, exists := m.ID()
  42705. if exists {
  42706. return []uint64{id}, nil
  42707. }
  42708. fallthrough
  42709. case m.op.Is(OpUpdate | OpDelete):
  42710. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  42711. default:
  42712. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42713. }
  42714. }
  42715. // SetCreatedAt sets the "created_at" field.
  42716. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  42717. m.created_at = &t
  42718. }
  42719. // CreatedAt returns the value of the "created_at" field in the mutation.
  42720. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  42721. v := m.created_at
  42722. if v == nil {
  42723. return
  42724. }
  42725. return *v, true
  42726. }
  42727. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  42728. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42730. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42731. if !m.op.Is(OpUpdateOne) {
  42732. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42733. }
  42734. if m.id == nil || m.oldValue == nil {
  42735. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42736. }
  42737. oldValue, err := m.oldValue(ctx)
  42738. if err != nil {
  42739. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42740. }
  42741. return oldValue.CreatedAt, nil
  42742. }
  42743. // ResetCreatedAt resets all changes to the "created_at" field.
  42744. func (m *WxCardVisitMutation) ResetCreatedAt() {
  42745. m.created_at = nil
  42746. }
  42747. // SetUpdatedAt sets the "updated_at" field.
  42748. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  42749. m.updated_at = &t
  42750. }
  42751. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42752. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  42753. v := m.updated_at
  42754. if v == nil {
  42755. return
  42756. }
  42757. return *v, true
  42758. }
  42759. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  42760. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42762. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42763. if !m.op.Is(OpUpdateOne) {
  42764. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42765. }
  42766. if m.id == nil || m.oldValue == nil {
  42767. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42768. }
  42769. oldValue, err := m.oldValue(ctx)
  42770. if err != nil {
  42771. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42772. }
  42773. return oldValue.UpdatedAt, nil
  42774. }
  42775. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42776. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  42777. m.updated_at = nil
  42778. }
  42779. // SetDeletedAt sets the "deleted_at" field.
  42780. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  42781. m.deleted_at = &t
  42782. }
  42783. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42784. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  42785. v := m.deleted_at
  42786. if v == nil {
  42787. return
  42788. }
  42789. return *v, true
  42790. }
  42791. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  42792. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42794. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42795. if !m.op.Is(OpUpdateOne) {
  42796. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42797. }
  42798. if m.id == nil || m.oldValue == nil {
  42799. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42800. }
  42801. oldValue, err := m.oldValue(ctx)
  42802. if err != nil {
  42803. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42804. }
  42805. return oldValue.DeletedAt, nil
  42806. }
  42807. // ClearDeletedAt clears the value of the "deleted_at" field.
  42808. func (m *WxCardVisitMutation) ClearDeletedAt() {
  42809. m.deleted_at = nil
  42810. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  42811. }
  42812. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42813. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  42814. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  42815. return ok
  42816. }
  42817. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42818. func (m *WxCardVisitMutation) ResetDeletedAt() {
  42819. m.deleted_at = nil
  42820. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  42821. }
  42822. // SetUserID sets the "user_id" field.
  42823. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  42824. m.user_id = &u
  42825. m.adduser_id = nil
  42826. }
  42827. // UserID returns the value of the "user_id" field in the mutation.
  42828. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  42829. v := m.user_id
  42830. if v == nil {
  42831. return
  42832. }
  42833. return *v, true
  42834. }
  42835. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  42836. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42838. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  42839. if !m.op.Is(OpUpdateOne) {
  42840. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  42841. }
  42842. if m.id == nil || m.oldValue == nil {
  42843. return v, errors.New("OldUserID requires an ID field in the mutation")
  42844. }
  42845. oldValue, err := m.oldValue(ctx)
  42846. if err != nil {
  42847. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  42848. }
  42849. return oldValue.UserID, nil
  42850. }
  42851. // AddUserID adds u to the "user_id" field.
  42852. func (m *WxCardVisitMutation) AddUserID(u int64) {
  42853. if m.adduser_id != nil {
  42854. *m.adduser_id += u
  42855. } else {
  42856. m.adduser_id = &u
  42857. }
  42858. }
  42859. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  42860. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  42861. v := m.adduser_id
  42862. if v == nil {
  42863. return
  42864. }
  42865. return *v, true
  42866. }
  42867. // ClearUserID clears the value of the "user_id" field.
  42868. func (m *WxCardVisitMutation) ClearUserID() {
  42869. m.user_id = nil
  42870. m.adduser_id = nil
  42871. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  42872. }
  42873. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  42874. func (m *WxCardVisitMutation) UserIDCleared() bool {
  42875. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  42876. return ok
  42877. }
  42878. // ResetUserID resets all changes to the "user_id" field.
  42879. func (m *WxCardVisitMutation) ResetUserID() {
  42880. m.user_id = nil
  42881. m.adduser_id = nil
  42882. delete(m.clearedFields, wxcardvisit.FieldUserID)
  42883. }
  42884. // SetBotID sets the "bot_id" field.
  42885. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  42886. m.bot_id = &u
  42887. m.addbot_id = nil
  42888. }
  42889. // BotID returns the value of the "bot_id" field in the mutation.
  42890. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  42891. v := m.bot_id
  42892. if v == nil {
  42893. return
  42894. }
  42895. return *v, true
  42896. }
  42897. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  42898. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42900. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  42901. if !m.op.Is(OpUpdateOne) {
  42902. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  42903. }
  42904. if m.id == nil || m.oldValue == nil {
  42905. return v, errors.New("OldBotID requires an ID field in the mutation")
  42906. }
  42907. oldValue, err := m.oldValue(ctx)
  42908. if err != nil {
  42909. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  42910. }
  42911. return oldValue.BotID, nil
  42912. }
  42913. // AddBotID adds u to the "bot_id" field.
  42914. func (m *WxCardVisitMutation) AddBotID(u int64) {
  42915. if m.addbot_id != nil {
  42916. *m.addbot_id += u
  42917. } else {
  42918. m.addbot_id = &u
  42919. }
  42920. }
  42921. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  42922. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  42923. v := m.addbot_id
  42924. if v == nil {
  42925. return
  42926. }
  42927. return *v, true
  42928. }
  42929. // ResetBotID resets all changes to the "bot_id" field.
  42930. func (m *WxCardVisitMutation) ResetBotID() {
  42931. m.bot_id = nil
  42932. m.addbot_id = nil
  42933. }
  42934. // SetBotType sets the "bot_type" field.
  42935. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  42936. m.bot_type = &u
  42937. m.addbot_type = nil
  42938. }
  42939. // BotType returns the value of the "bot_type" field in the mutation.
  42940. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  42941. v := m.bot_type
  42942. if v == nil {
  42943. return
  42944. }
  42945. return *v, true
  42946. }
  42947. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  42948. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  42949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42950. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  42951. if !m.op.Is(OpUpdateOne) {
  42952. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  42953. }
  42954. if m.id == nil || m.oldValue == nil {
  42955. return v, errors.New("OldBotType requires an ID field in the mutation")
  42956. }
  42957. oldValue, err := m.oldValue(ctx)
  42958. if err != nil {
  42959. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  42960. }
  42961. return oldValue.BotType, nil
  42962. }
  42963. // AddBotType adds u to the "bot_type" field.
  42964. func (m *WxCardVisitMutation) AddBotType(u int8) {
  42965. if m.addbot_type != nil {
  42966. *m.addbot_type += u
  42967. } else {
  42968. m.addbot_type = &u
  42969. }
  42970. }
  42971. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  42972. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  42973. v := m.addbot_type
  42974. if v == nil {
  42975. return
  42976. }
  42977. return *v, true
  42978. }
  42979. // ResetBotType resets all changes to the "bot_type" field.
  42980. func (m *WxCardVisitMutation) ResetBotType() {
  42981. m.bot_type = nil
  42982. m.addbot_type = nil
  42983. }
  42984. // Where appends a list predicates to the WxCardVisitMutation builder.
  42985. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  42986. m.predicates = append(m.predicates, ps...)
  42987. }
  42988. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  42989. // users can use type-assertion to append predicates that do not depend on any generated package.
  42990. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  42991. p := make([]predicate.WxCardVisit, len(ps))
  42992. for i := range ps {
  42993. p[i] = ps[i]
  42994. }
  42995. m.Where(p...)
  42996. }
  42997. // Op returns the operation name.
  42998. func (m *WxCardVisitMutation) Op() Op {
  42999. return m.op
  43000. }
  43001. // SetOp allows setting the mutation operation.
  43002. func (m *WxCardVisitMutation) SetOp(op Op) {
  43003. m.op = op
  43004. }
  43005. // Type returns the node type of this mutation (WxCardVisit).
  43006. func (m *WxCardVisitMutation) Type() string {
  43007. return m.typ
  43008. }
  43009. // Fields returns all fields that were changed during this mutation. Note that in
  43010. // order to get all numeric fields that were incremented/decremented, call
  43011. // AddedFields().
  43012. func (m *WxCardVisitMutation) Fields() []string {
  43013. fields := make([]string, 0, 6)
  43014. if m.created_at != nil {
  43015. fields = append(fields, wxcardvisit.FieldCreatedAt)
  43016. }
  43017. if m.updated_at != nil {
  43018. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  43019. }
  43020. if m.deleted_at != nil {
  43021. fields = append(fields, wxcardvisit.FieldDeletedAt)
  43022. }
  43023. if m.user_id != nil {
  43024. fields = append(fields, wxcardvisit.FieldUserID)
  43025. }
  43026. if m.bot_id != nil {
  43027. fields = append(fields, wxcardvisit.FieldBotID)
  43028. }
  43029. if m.bot_type != nil {
  43030. fields = append(fields, wxcardvisit.FieldBotType)
  43031. }
  43032. return fields
  43033. }
  43034. // Field returns the value of a field with the given name. The second boolean
  43035. // return value indicates that this field was not set, or was not defined in the
  43036. // schema.
  43037. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  43038. switch name {
  43039. case wxcardvisit.FieldCreatedAt:
  43040. return m.CreatedAt()
  43041. case wxcardvisit.FieldUpdatedAt:
  43042. return m.UpdatedAt()
  43043. case wxcardvisit.FieldDeletedAt:
  43044. return m.DeletedAt()
  43045. case wxcardvisit.FieldUserID:
  43046. return m.UserID()
  43047. case wxcardvisit.FieldBotID:
  43048. return m.BotID()
  43049. case wxcardvisit.FieldBotType:
  43050. return m.BotType()
  43051. }
  43052. return nil, false
  43053. }
  43054. // OldField returns the old value of the field from the database. An error is
  43055. // returned if the mutation operation is not UpdateOne, or the query to the
  43056. // database failed.
  43057. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43058. switch name {
  43059. case wxcardvisit.FieldCreatedAt:
  43060. return m.OldCreatedAt(ctx)
  43061. case wxcardvisit.FieldUpdatedAt:
  43062. return m.OldUpdatedAt(ctx)
  43063. case wxcardvisit.FieldDeletedAt:
  43064. return m.OldDeletedAt(ctx)
  43065. case wxcardvisit.FieldUserID:
  43066. return m.OldUserID(ctx)
  43067. case wxcardvisit.FieldBotID:
  43068. return m.OldBotID(ctx)
  43069. case wxcardvisit.FieldBotType:
  43070. return m.OldBotType(ctx)
  43071. }
  43072. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  43073. }
  43074. // SetField sets the value of a field with the given name. It returns an error if
  43075. // the field is not defined in the schema, or if the type mismatched the field
  43076. // type.
  43077. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  43078. switch name {
  43079. case wxcardvisit.FieldCreatedAt:
  43080. v, ok := value.(time.Time)
  43081. if !ok {
  43082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43083. }
  43084. m.SetCreatedAt(v)
  43085. return nil
  43086. case wxcardvisit.FieldUpdatedAt:
  43087. v, ok := value.(time.Time)
  43088. if !ok {
  43089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43090. }
  43091. m.SetUpdatedAt(v)
  43092. return nil
  43093. case wxcardvisit.FieldDeletedAt:
  43094. v, ok := value.(time.Time)
  43095. if !ok {
  43096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43097. }
  43098. m.SetDeletedAt(v)
  43099. return nil
  43100. case wxcardvisit.FieldUserID:
  43101. v, ok := value.(uint64)
  43102. if !ok {
  43103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43104. }
  43105. m.SetUserID(v)
  43106. return nil
  43107. case wxcardvisit.FieldBotID:
  43108. v, ok := value.(uint64)
  43109. if !ok {
  43110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43111. }
  43112. m.SetBotID(v)
  43113. return nil
  43114. case wxcardvisit.FieldBotType:
  43115. v, ok := value.(uint8)
  43116. if !ok {
  43117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43118. }
  43119. m.SetBotType(v)
  43120. return nil
  43121. }
  43122. return fmt.Errorf("unknown WxCardVisit field %s", name)
  43123. }
  43124. // AddedFields returns all numeric fields that were incremented/decremented during
  43125. // this mutation.
  43126. func (m *WxCardVisitMutation) AddedFields() []string {
  43127. var fields []string
  43128. if m.adduser_id != nil {
  43129. fields = append(fields, wxcardvisit.FieldUserID)
  43130. }
  43131. if m.addbot_id != nil {
  43132. fields = append(fields, wxcardvisit.FieldBotID)
  43133. }
  43134. if m.addbot_type != nil {
  43135. fields = append(fields, wxcardvisit.FieldBotType)
  43136. }
  43137. return fields
  43138. }
  43139. // AddedField returns the numeric value that was incremented/decremented on a field
  43140. // with the given name. The second boolean return value indicates that this field
  43141. // was not set, or was not defined in the schema.
  43142. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  43143. switch name {
  43144. case wxcardvisit.FieldUserID:
  43145. return m.AddedUserID()
  43146. case wxcardvisit.FieldBotID:
  43147. return m.AddedBotID()
  43148. case wxcardvisit.FieldBotType:
  43149. return m.AddedBotType()
  43150. }
  43151. return nil, false
  43152. }
  43153. // AddField adds the value to the field with the given name. It returns an error if
  43154. // the field is not defined in the schema, or if the type mismatched the field
  43155. // type.
  43156. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  43157. switch name {
  43158. case wxcardvisit.FieldUserID:
  43159. v, ok := value.(int64)
  43160. if !ok {
  43161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43162. }
  43163. m.AddUserID(v)
  43164. return nil
  43165. case wxcardvisit.FieldBotID:
  43166. v, ok := value.(int64)
  43167. if !ok {
  43168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43169. }
  43170. m.AddBotID(v)
  43171. return nil
  43172. case wxcardvisit.FieldBotType:
  43173. v, ok := value.(int8)
  43174. if !ok {
  43175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43176. }
  43177. m.AddBotType(v)
  43178. return nil
  43179. }
  43180. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  43181. }
  43182. // ClearedFields returns all nullable fields that were cleared during this
  43183. // mutation.
  43184. func (m *WxCardVisitMutation) ClearedFields() []string {
  43185. var fields []string
  43186. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  43187. fields = append(fields, wxcardvisit.FieldDeletedAt)
  43188. }
  43189. if m.FieldCleared(wxcardvisit.FieldUserID) {
  43190. fields = append(fields, wxcardvisit.FieldUserID)
  43191. }
  43192. return fields
  43193. }
  43194. // FieldCleared returns a boolean indicating if a field with the given name was
  43195. // cleared in this mutation.
  43196. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  43197. _, ok := m.clearedFields[name]
  43198. return ok
  43199. }
  43200. // ClearField clears the value of the field with the given name. It returns an
  43201. // error if the field is not defined in the schema.
  43202. func (m *WxCardVisitMutation) ClearField(name string) error {
  43203. switch name {
  43204. case wxcardvisit.FieldDeletedAt:
  43205. m.ClearDeletedAt()
  43206. return nil
  43207. case wxcardvisit.FieldUserID:
  43208. m.ClearUserID()
  43209. return nil
  43210. }
  43211. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  43212. }
  43213. // ResetField resets all changes in the mutation for the field with the given name.
  43214. // It returns an error if the field is not defined in the schema.
  43215. func (m *WxCardVisitMutation) ResetField(name string) error {
  43216. switch name {
  43217. case wxcardvisit.FieldCreatedAt:
  43218. m.ResetCreatedAt()
  43219. return nil
  43220. case wxcardvisit.FieldUpdatedAt:
  43221. m.ResetUpdatedAt()
  43222. return nil
  43223. case wxcardvisit.FieldDeletedAt:
  43224. m.ResetDeletedAt()
  43225. return nil
  43226. case wxcardvisit.FieldUserID:
  43227. m.ResetUserID()
  43228. return nil
  43229. case wxcardvisit.FieldBotID:
  43230. m.ResetBotID()
  43231. return nil
  43232. case wxcardvisit.FieldBotType:
  43233. m.ResetBotType()
  43234. return nil
  43235. }
  43236. return fmt.Errorf("unknown WxCardVisit field %s", name)
  43237. }
  43238. // AddedEdges returns all edge names that were set/added in this mutation.
  43239. func (m *WxCardVisitMutation) AddedEdges() []string {
  43240. edges := make([]string, 0, 0)
  43241. return edges
  43242. }
  43243. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43244. // name in this mutation.
  43245. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  43246. return nil
  43247. }
  43248. // RemovedEdges returns all edge names that were removed in this mutation.
  43249. func (m *WxCardVisitMutation) RemovedEdges() []string {
  43250. edges := make([]string, 0, 0)
  43251. return edges
  43252. }
  43253. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43254. // the given name in this mutation.
  43255. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  43256. return nil
  43257. }
  43258. // ClearedEdges returns all edge names that were cleared in this mutation.
  43259. func (m *WxCardVisitMutation) ClearedEdges() []string {
  43260. edges := make([]string, 0, 0)
  43261. return edges
  43262. }
  43263. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43264. // was cleared in this mutation.
  43265. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  43266. return false
  43267. }
  43268. // ClearEdge clears the value of the edge with the given name. It returns an error
  43269. // if that edge is not defined in the schema.
  43270. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  43271. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  43272. }
  43273. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43274. // It returns an error if the edge is not defined in the schema.
  43275. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  43276. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  43277. }